diff --git a/packages/google-cloud-backupdr/google/cloud/backupdr/gapic_version.py b/packages/google-cloud-backupdr/google/cloud/backupdr/gapic_version.py index 51d2795b9d6b..558c8aab67c5 100644 --- a/packages/google-cloud-backupdr/google/cloud/backupdr/gapic_version.py +++ b/packages/google-cloud-backupdr/google/cloud/backupdr/gapic_version.py @@ -13,4 +13,4 @@ # See the License for the specific language governing permissions and # limitations under the License. # -__version__ = "0.1.6" # {x-release-please-version} +__version__ = "0.0.0" # {x-release-please-version} diff --git a/packages/google-cloud-backupdr/google/cloud/backupdr_v1/gapic_version.py b/packages/google-cloud-backupdr/google/cloud/backupdr_v1/gapic_version.py index 51d2795b9d6b..558c8aab67c5 100644 --- a/packages/google-cloud-backupdr/google/cloud/backupdr_v1/gapic_version.py +++ b/packages/google-cloud-backupdr/google/cloud/backupdr_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.6" # {x-release-please-version} +__version__ = "0.0.0" # {x-release-please-version} diff --git a/packages/google-cloud-backupdr/google/cloud/backupdr_v1/services/backup_dr/async_client.py b/packages/google-cloud-backupdr/google/cloud/backupdr_v1/services/backup_dr/async_client.py index 5e9037a1922a..c8870919dd24 100644 --- a/packages/google-cloud-backupdr/google/cloud/backupdr_v1/services/backup_dr/async_client.py +++ b/packages/google-cloud-backupdr/google/cloud/backupdr_v1/services/backup_dr/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, BackupDRTransport from .transports.grpc_asyncio import BackupDRGrpcAsyncIOTransport +try: + from google.api_core import client_logging # type: ignore + + CLIENT_LOGGING_SUPPORTED = True # pragma: NO COVER +except ImportError: # pragma: NO COVER + CLIENT_LOGGING_SUPPORTED = False + +_LOGGER = std_logging.getLogger(__name__) + class BackupDRAsyncClient: """The BackupDR 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.cloud.backupdr_v1.BackupDRAsyncClient`.", + extra={ + "serviceName": "google.cloud.backupdr.v1.BackupDR", + "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.backupdr.v1.BackupDR", + "credentialsType": None, + }, + ) + async def list_management_servers( self, request: Optional[Union[backupdr.ListManagementServersRequest, dict]] = None, @@ -288,7 +320,7 @@ async def list_management_servers( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListManagementServersAsyncPager: r"""Lists ManagementServers in a given project and location. @@ -338,8 +370,10 @@ async def sample_list_management_servers(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.backupdr_v1.services.backup_dr.pagers.ListManagementServersAsyncPager: @@ -414,7 +448,7 @@ async def get_management_server( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> backupdr.ManagementServer: r"""Gets details of a single ManagementServer. @@ -459,8 +493,10 @@ async def sample_get_management_server(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.backupdr_v1.types.ManagementServer: @@ -523,7 +559,7 @@ async def create_management_server( management_server_id: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation_async.AsyncOperation: r"""Creates a new ManagementServer in a given project and location. @@ -591,8 +627,10 @@ async def sample_create_management_server(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.api_core.operation_async.AsyncOperation: @@ -669,7 +707,7 @@ async def delete_management_server( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation_async.AsyncOperation: r"""Deletes a single ManagementServer. @@ -715,8 +753,10 @@ async def sample_delete_management_server(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.api_core.operation_async.AsyncOperation: @@ -797,7 +837,7 @@ async def create_backup_vault( backup_vault_id: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, 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 BackupVault in a given project and location. @@ -857,8 +897,10 @@ async def sample_create_backup_vault(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.api_core.operation_async.AsyncOperation: @@ -934,7 +976,7 @@ async def list_backup_vaults( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListBackupVaultsAsyncPager: r"""Lists BackupVaults in a given project and location. @@ -984,8 +1026,10 @@ async def sample_list_backup_vaults(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.backupdr_v1.services.backup_dr.pagers.ListBackupVaultsAsyncPager: @@ -1062,7 +1106,7 @@ async def fetch_usable_backup_vaults( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.FetchUsableBackupVaultsAsyncPager: r"""FetchUsableBackupVaults lists usable BackupVaults in a given project and location. Usable BackupVault are the @@ -1114,8 +1158,10 @@ async def sample_fetch_usable_backup_vaults(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.backupdr_v1.services.backup_dr.pagers.FetchUsableBackupVaultsAsyncPager: @@ -1190,7 +1236,7 @@ async def get_backup_vault( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> backupvault.BackupVault: r"""Gets details of a BackupVault. @@ -1235,8 +1281,10 @@ async def sample_get_backup_vault(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.backupdr_v1.types.BackupVault: @@ -1298,7 +1346,7 @@ async def update_backup_vault( update_mask: Optional[field_mask_pb2.FieldMask] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, 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 settings of a BackupVault. @@ -1354,8 +1402,10 @@ async def sample_update_backup_vault(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.api_core.operation_async.AsyncOperation: @@ -1431,7 +1481,7 @@ async def delete_backup_vault( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, 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 BackupVault. @@ -1476,8 +1526,10 @@ async def sample_delete_backup_vault(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.api_core.operation_async.AsyncOperation: @@ -1556,7 +1608,7 @@ async def list_data_sources( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListDataSourcesAsyncPager: r"""Lists DataSources in a given project and location. @@ -1605,8 +1657,10 @@ async def sample_list_data_sources(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.backupdr_v1.services.backup_dr.pagers.ListDataSourcesAsyncPager: @@ -1681,7 +1735,7 @@ async def get_data_source( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> backupvault.DataSource: r"""Gets details of a DataSource. @@ -1726,8 +1780,10 @@ async def sample_get_data_source(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.backupdr_v1.types.DataSource: @@ -1791,7 +1847,7 @@ async def update_data_source( update_mask: Optional[field_mask_pb2.FieldMask] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation_async.AsyncOperation: r"""Updates the settings of a DataSource. @@ -1847,8 +1903,10 @@ async def sample_update_data_source(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.api_core.operation_async.AsyncOperation: @@ -1924,7 +1982,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. @@ -1972,8 +2030,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.backupdr_v1.services.backup_dr.pagers.ListBackupsAsyncPager: @@ -2048,7 +2108,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]]] = (), ) -> backupvault.Backup: r"""Gets details of a Backup. @@ -2092,8 +2152,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.backupdr_v1.types.Backup: @@ -2153,7 +2215,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 settings of a Backup. @@ -2209,8 +2271,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: @@ -2286,7 +2350,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 Backup. @@ -2331,8 +2395,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: @@ -2404,7 +2470,7 @@ async def restore_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"""Restore from a Backup @@ -2458,8 +2524,10 @@ async def sample_restore_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: @@ -2533,7 +2601,7 @@ async def create_backup_plan( backup_plan_id: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation_async.AsyncOperation: r"""Create a BackupPlan @@ -2609,8 +2677,10 @@ async def sample_create_backup_plan(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + 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_backup_plan( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> backupplan.BackupPlan: r"""Gets details of a single BackupPlan. @@ -2733,8 +2803,10 @@ async def sample_get_backup_plan(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.backupdr_v1.types.BackupPlan: @@ -2797,7 +2869,7 @@ async def list_backup_plans( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListBackupPlansAsyncPager: r"""Lists BackupPlans in a given project and location. @@ -2845,8 +2917,10 @@ async def sample_list_backup_plans(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.backupdr_v1.services.backup_dr.pagers.ListBackupPlansAsyncPager: @@ -2920,7 +2994,7 @@ async def delete_backup_plan( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, 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 BackupPlan. @@ -2970,8 +3044,10 @@ async def sample_delete_backup_plan(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.api_core.operation_async.AsyncOperation: @@ -3056,7 +3132,7 @@ async def create_backup_plan_association( backup_plan_association_id: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation_async.AsyncOperation: r"""Create a BackupPlanAssociation @@ -3127,8 +3203,10 @@ async def sample_create_backup_plan_association(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.api_core.operation_async.AsyncOperation: @@ -3209,7 +3287,7 @@ async def get_backup_plan_association( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> backupplanassociation.BackupPlanAssociation: r"""Gets details of a single BackupPlanAssociation. @@ -3254,8 +3332,10 @@ async def sample_get_backup_plan_association(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.backupdr_v1.types.BackupPlanAssociation: @@ -3322,7 +3402,7 @@ async def list_backup_plan_associations( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListBackupPlanAssociationsAsyncPager: r"""Lists BackupPlanAssociations in a given project and location. @@ -3372,8 +3452,10 @@ async def sample_list_backup_plan_associations(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.backupdr_v1.services.backup_dr.pagers.ListBackupPlanAssociationsAsyncPager: @@ -3452,7 +3534,7 @@ async def delete_backup_plan_association( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, 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 BackupPlanAssociation. @@ -3501,8 +3583,10 @@ async def sample_delete_backup_plan_association(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.api_core.operation_async.AsyncOperation: @@ -3586,7 +3670,7 @@ async def trigger_backup( rule_id: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation_async.AsyncOperation: r"""Triggers a new Backup. @@ -3643,8 +3727,10 @@ async def sample_trigger_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: @@ -3716,7 +3802,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. @@ -3727,8 +3813,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. @@ -3769,7 +3857,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. @@ -3780,8 +3868,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. @@ -3822,7 +3912,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. @@ -3838,8 +3928,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 """ @@ -3876,7 +3968,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. @@ -3891,8 +3983,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 """ @@ -3929,7 +4023,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. @@ -3942,8 +4036,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. @@ -4048,7 +4144,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. @@ -4062,8 +4158,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. @@ -4168,7 +4266,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. @@ -4183,8 +4281,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. @@ -4228,7 +4328,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. @@ -4239,8 +4339,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. @@ -4281,7 +4383,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. @@ -4292,8 +4394,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-backupdr/google/cloud/backupdr_v1/services/backup_dr/client.py b/packages/google-cloud-backupdr/google/cloud/backupdr_v1/services/backup_dr/client.py index cad43136427b..fa774032bfe4 100644 --- a/packages/google-cloud-backupdr/google/cloud/backupdr_v1/services/backup_dr/client.py +++ b/packages/google-cloud-backupdr/google/cloud/backupdr_v1/services/backup_dr/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 @@ -715,6 +725,10 @@ def __init__( # Initialize the universe domain validation. self._is_universe_domain_valid = False + if CLIENT_LOGGING_SUPPORTED: # pragma: NO COVER + # Setup logging. + client_logging.initialize_logging() + api_key_value = getattr(self._client_options, "api_key", None) if api_key_value and credentials: raise ValueError( @@ -777,6 +791,29 @@ def __init__( api_audience=self._client_options.api_audience, ) + if "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.backupdr_v1.BackupDRClient`.", + extra={ + "serviceName": "google.cloud.backupdr.v1.BackupDR", + "universeDomain": getattr( + self._transport._credentials, "universe_domain", "" + ), + "credentialsType": f"{type(self._transport._credentials).__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.backupdr.v1.BackupDR", + "credentialsType": None, + }, + ) + def list_management_servers( self, request: Optional[Union[backupdr.ListManagementServersRequest, dict]] = None, @@ -784,7 +821,7 @@ def list_management_servers( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListManagementServersPager: r"""Lists ManagementServers in a given project and location. @@ -834,8 +871,10 @@ def sample_list_management_servers(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.backupdr_v1.services.backup_dr.pagers.ListManagementServersPager: @@ -907,7 +946,7 @@ def get_management_server( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> backupdr.ManagementServer: r"""Gets details of a single ManagementServer. @@ -952,8 +991,10 @@ def sample_get_management_server(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.backupdr_v1.types.ManagementServer: @@ -1013,7 +1054,7 @@ def create_management_server( management_server_id: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation.Operation: r"""Creates a new ManagementServer in a given project and location. @@ -1081,8 +1122,10 @@ def sample_create_management_server(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.api_core.operation.Operation: @@ -1156,7 +1199,7 @@ def delete_management_server( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation.Operation: r"""Deletes a single ManagementServer. @@ -1202,8 +1245,10 @@ def sample_delete_management_server(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.api_core.operation.Operation: @@ -1281,7 +1326,7 @@ def create_backup_vault( backup_vault_id: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.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 BackupVault in a given project and location. @@ -1341,8 +1386,10 @@ def sample_create_backup_vault(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.api_core.operation.Operation: @@ -1415,7 +1462,7 @@ def list_backup_vaults( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListBackupVaultsPager: r"""Lists BackupVaults in a given project and location. @@ -1465,8 +1512,10 @@ def sample_list_backup_vaults(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.backupdr_v1.services.backup_dr.pagers.ListBackupVaultsPager: @@ -1540,7 +1589,7 @@ def fetch_usable_backup_vaults( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.FetchUsableBackupVaultsPager: r"""FetchUsableBackupVaults lists usable BackupVaults in a given project and location. Usable BackupVault are the @@ -1592,8 +1641,10 @@ def sample_fetch_usable_backup_vaults(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.backupdr_v1.services.backup_dr.pagers.FetchUsableBackupVaultsPager: @@ -1667,7 +1718,7 @@ def get_backup_vault( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> backupvault.BackupVault: r"""Gets details of a BackupVault. @@ -1712,8 +1763,10 @@ def sample_get_backup_vault(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.backupdr_v1.types.BackupVault: @@ -1772,7 +1825,7 @@ def update_backup_vault( update_mask: Optional[field_mask_pb2.FieldMask] = None, retry: OptionalRetry = gapic_v1.method.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 settings of a BackupVault. @@ -1828,8 +1881,10 @@ def sample_update_backup_vault(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.api_core.operation.Operation: @@ -1902,7 +1957,7 @@ def delete_backup_vault( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.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 BackupVault. @@ -1947,8 +2002,10 @@ def sample_delete_backup_vault(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.api_core.operation.Operation: @@ -2024,7 +2081,7 @@ def list_data_sources( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListDataSourcesPager: r"""Lists DataSources in a given project and location. @@ -2073,8 +2130,10 @@ def sample_list_data_sources(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.backupdr_v1.services.backup_dr.pagers.ListDataSourcesPager: @@ -2146,7 +2205,7 @@ def get_data_source( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> backupvault.DataSource: r"""Gets details of a DataSource. @@ -2191,8 +2250,10 @@ def sample_get_data_source(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.backupdr_v1.types.DataSource: @@ -2253,7 +2314,7 @@ def update_data_source( update_mask: Optional[field_mask_pb2.FieldMask] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation.Operation: r"""Updates the settings of a DataSource. @@ -2309,8 +2370,10 @@ def sample_update_data_source(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.api_core.operation.Operation: @@ -2383,7 +2446,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. @@ -2431,8 +2494,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.backupdr_v1.services.backup_dr.pagers.ListBackupsPager: @@ -2504,7 +2569,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]]] = (), ) -> backupvault.Backup: r"""Gets details of a Backup. @@ -2548,8 +2613,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.backupdr_v1.types.Backup: @@ -2606,7 +2673,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 settings of a Backup. @@ -2662,8 +2729,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: @@ -2736,7 +2805,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 Backup. @@ -2781,8 +2850,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: @@ -2851,7 +2922,7 @@ def restore_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"""Restore from a Backup @@ -2905,8 +2976,10 @@ def sample_restore_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: @@ -2977,7 +3050,7 @@ def create_backup_plan( backup_plan_id: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation.Operation: r"""Create a BackupPlan @@ -3053,8 +3126,10 @@ def sample_create_backup_plan(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.api_core.operation.Operation: @@ -3128,7 +3203,7 @@ def get_backup_plan( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> backupplan.BackupPlan: r"""Gets details of a single BackupPlan. @@ -3174,8 +3249,10 @@ def sample_get_backup_plan(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.backupdr_v1.types.BackupPlan: @@ -3235,7 +3312,7 @@ def list_backup_plans( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListBackupPlansPager: r"""Lists BackupPlans in a given project and location. @@ -3283,8 +3360,10 @@ def sample_list_backup_plans(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.backupdr_v1.services.backup_dr.pagers.ListBackupPlansPager: @@ -3355,7 +3434,7 @@ def delete_backup_plan( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.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 BackupPlan. @@ -3405,8 +3484,10 @@ def sample_delete_backup_plan(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.api_core.operation.Operation: @@ -3488,7 +3569,7 @@ def create_backup_plan_association( backup_plan_association_id: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation.Operation: r"""Create a BackupPlanAssociation @@ -3559,8 +3640,10 @@ def sample_create_backup_plan_association(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.api_core.operation.Operation: @@ -3640,7 +3723,7 @@ def get_backup_plan_association( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> backupplanassociation.BackupPlanAssociation: r"""Gets details of a single BackupPlanAssociation. @@ -3685,8 +3768,10 @@ def sample_get_backup_plan_association(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.backupdr_v1.types.BackupPlanAssociation: @@ -3752,7 +3837,7 @@ def list_backup_plan_associations( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListBackupPlanAssociationsPager: r"""Lists BackupPlanAssociations in a given project and location. @@ -3802,8 +3887,10 @@ def sample_list_backup_plan_associations(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.backupdr_v1.services.backup_dr.pagers.ListBackupPlanAssociationsPager: @@ -3881,7 +3968,7 @@ def delete_backup_plan_association( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.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 BackupPlanAssociation. @@ -3930,8 +4017,10 @@ def sample_delete_backup_plan_association(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.api_core.operation.Operation: @@ -4014,7 +4103,7 @@ def trigger_backup( rule_id: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation.Operation: r"""Triggers a new Backup. @@ -4071,8 +4160,10 @@ def sample_trigger_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: @@ -4154,7 +4245,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. @@ -4165,8 +4256,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. @@ -4207,7 +4300,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. @@ -4218,8 +4311,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. @@ -4260,7 +4355,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. @@ -4276,8 +4371,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 """ @@ -4314,7 +4411,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. @@ -4329,8 +4426,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 """ @@ -4367,7 +4466,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. @@ -4380,8 +4479,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. @@ -4486,7 +4587,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. @@ -4500,8 +4601,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. @@ -4606,7 +4709,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. @@ -4621,8 +4724,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. @@ -4664,7 +4769,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. @@ -4675,8 +4780,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. @@ -4717,7 +4824,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. @@ -4728,8 +4835,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-backupdr/google/cloud/backupdr_v1/services/backup_dr/pagers.py b/packages/google-cloud-backupdr/google/cloud/backupdr_v1/services/backup_dr/pagers.py index 3594ed629a56..a50b7d085a1e 100644 --- a/packages/google-cloud-backupdr/google/cloud/backupdr_v1/services/backup_dr/pagers.py +++ b/packages/google-cloud-backupdr/google/cloud/backupdr_v1/services/backup_dr/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 = backupdr.ListManagementServersRequest(request) @@ -146,7 +148,7 @@ def __init__( *, retry: OptionalAsyncRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiates the pager. @@ -160,8 +162,10 @@ def __init__( retry (google.api_core.retry.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. """ self._method = method self._request = backupdr.ListManagementServersRequest(request) @@ -224,7 +228,7 @@ def __init__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiate the pager. @@ -238,8 +242,10 @@ def __init__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. """ self._method = method self._request = backupvault.ListBackupVaultsRequest(request) @@ -298,7 +304,7 @@ def __init__( *, retry: OptionalAsyncRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiates the pager. @@ -312,8 +318,10 @@ def __init__( retry (google.api_core.retry.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. """ self._method = method self._request = backupvault.ListBackupVaultsRequest(request) @@ -376,7 +384,7 @@ def __init__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiate the pager. @@ -390,8 +398,10 @@ def __init__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. """ self._method = method self._request = backupvault.FetchUsableBackupVaultsRequest(request) @@ -450,7 +460,7 @@ def __init__( *, retry: OptionalAsyncRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiates the pager. @@ -464,8 +474,10 @@ def __init__( retry (google.api_core.retry.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. """ self._method = method self._request = backupvault.FetchUsableBackupVaultsRequest(request) @@ -528,7 +540,7 @@ def __init__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiate the pager. @@ -542,8 +554,10 @@ def __init__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. """ self._method = method self._request = backupvault.ListDataSourcesRequest(request) @@ -602,7 +616,7 @@ def __init__( *, retry: OptionalAsyncRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiates the pager. @@ -616,8 +630,10 @@ def __init__( retry (google.api_core.retry.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. """ self._method = method self._request = backupvault.ListDataSourcesRequest(request) @@ -680,7 +696,7 @@ def __init__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiate the pager. @@ -694,8 +710,10 @@ def __init__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. """ self._method = method self._request = backupvault.ListBackupsRequest(request) @@ -754,7 +772,7 @@ def __init__( *, retry: OptionalAsyncRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiates the pager. @@ -768,8 +786,10 @@ def __init__( retry (google.api_core.retry.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. """ self._method = method self._request = backupvault.ListBackupsRequest(request) @@ -832,7 +852,7 @@ def __init__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiate the pager. @@ -846,8 +866,10 @@ def __init__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. """ self._method = method self._request = backupplan.ListBackupPlansRequest(request) @@ -906,7 +928,7 @@ def __init__( *, retry: OptionalAsyncRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiates the pager. @@ -920,8 +942,10 @@ def __init__( retry (google.api_core.retry.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. """ self._method = method self._request = backupplan.ListBackupPlansRequest(request) @@ -984,7 +1008,7 @@ def __init__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiate the pager. @@ -998,8 +1022,10 @@ def __init__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. """ self._method = method self._request = backupplanassociation.ListBackupPlanAssociationsRequest(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 = backupplanassociation.ListBackupPlanAssociationsRequest(request) diff --git a/packages/google-cloud-backupdr/google/cloud/backupdr_v1/services/backup_dr/transports/grpc.py b/packages/google-cloud-backupdr/google/cloud/backupdr_v1/services/backup_dr/transports/grpc.py index 63c287d5bfa1..e2e13a00be74 100644 --- a/packages/google-cloud-backupdr/google/cloud/backupdr_v1/services/backup_dr/transports/grpc.py +++ b/packages/google-cloud-backupdr/google/cloud/backupdr_v1/services/backup_dr/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.backupdr_v1.types import ( backupdr, @@ -35,6 +41,81 @@ from .base import DEFAULT_CLIENT_INFO, BackupDRTransport +try: + from google.api_core import client_logging # 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.backupdr.v1.BackupDR", + "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.backupdr.v1.BackupDR", + "rpcName": client_call_details.method, + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class BackupDRGrpcTransport(BackupDRTransport): """gRPC backend transport for BackupDR. @@ -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 @@ -253,7 +339,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 @@ -280,7 +368,7 @@ def list_management_servers( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_management_servers" not in self._stubs: - self._stubs["list_management_servers"] = self.grpc_channel.unary_unary( + self._stubs["list_management_servers"] = self._logged_channel.unary_unary( "/google.cloud.backupdr.v1.BackupDR/ListManagementServers", request_serializer=backupdr.ListManagementServersRequest.serialize, response_deserializer=backupdr.ListManagementServersResponse.deserialize, @@ -306,7 +394,7 @@ def get_management_server( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_management_server" not in self._stubs: - self._stubs["get_management_server"] = self.grpc_channel.unary_unary( + self._stubs["get_management_server"] = self._logged_channel.unary_unary( "/google.cloud.backupdr.v1.BackupDR/GetManagementServer", request_serializer=backupdr.GetManagementServerRequest.serialize, response_deserializer=backupdr.ManagementServer.deserialize, @@ -333,7 +421,7 @@ def create_management_server( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_management_server" not in self._stubs: - self._stubs["create_management_server"] = self.grpc_channel.unary_unary( + self._stubs["create_management_server"] = self._logged_channel.unary_unary( "/google.cloud.backupdr.v1.BackupDR/CreateManagementServer", request_serializer=backupdr.CreateManagementServerRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -359,7 +447,7 @@ def delete_management_server( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_management_server" not in self._stubs: - self._stubs["delete_management_server"] = self.grpc_channel.unary_unary( + self._stubs["delete_management_server"] = self._logged_channel.unary_unary( "/google.cloud.backupdr.v1.BackupDR/DeleteManagementServer", request_serializer=backupdr.DeleteManagementServerRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -386,7 +474,7 @@ def create_backup_vault( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_backup_vault" not in self._stubs: - self._stubs["create_backup_vault"] = self.grpc_channel.unary_unary( + self._stubs["create_backup_vault"] = self._logged_channel.unary_unary( "/google.cloud.backupdr.v1.BackupDR/CreateBackupVault", request_serializer=backupvault.CreateBackupVaultRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -414,7 +502,7 @@ def list_backup_vaults( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_backup_vaults" not in self._stubs: - self._stubs["list_backup_vaults"] = self.grpc_channel.unary_unary( + self._stubs["list_backup_vaults"] = self._logged_channel.unary_unary( "/google.cloud.backupdr.v1.BackupDR/ListBackupVaults", request_serializer=backupvault.ListBackupVaultsRequest.serialize, response_deserializer=backupvault.ListBackupVaultsResponse.deserialize, @@ -445,7 +533,9 @@ def fetch_usable_backup_vaults( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "fetch_usable_backup_vaults" not in self._stubs: - self._stubs["fetch_usable_backup_vaults"] = self.grpc_channel.unary_unary( + self._stubs[ + "fetch_usable_backup_vaults" + ] = self._logged_channel.unary_unary( "/google.cloud.backupdr.v1.BackupDR/FetchUsableBackupVaults", request_serializer=backupvault.FetchUsableBackupVaultsRequest.serialize, response_deserializer=backupvault.FetchUsableBackupVaultsResponse.deserialize, @@ -471,7 +561,7 @@ def get_backup_vault( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_backup_vault" not in self._stubs: - self._stubs["get_backup_vault"] = self.grpc_channel.unary_unary( + self._stubs["get_backup_vault"] = self._logged_channel.unary_unary( "/google.cloud.backupdr.v1.BackupDR/GetBackupVault", request_serializer=backupvault.GetBackupVaultRequest.serialize, response_deserializer=backupvault.BackupVault.deserialize, @@ -497,7 +587,7 @@ def update_backup_vault( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_backup_vault" not in self._stubs: - self._stubs["update_backup_vault"] = self.grpc_channel.unary_unary( + self._stubs["update_backup_vault"] = self._logged_channel.unary_unary( "/google.cloud.backupdr.v1.BackupDR/UpdateBackupVault", request_serializer=backupvault.UpdateBackupVaultRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -523,7 +613,7 @@ def delete_backup_vault( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_backup_vault" not in self._stubs: - self._stubs["delete_backup_vault"] = self.grpc_channel.unary_unary( + self._stubs["delete_backup_vault"] = self._logged_channel.unary_unary( "/google.cloud.backupdr.v1.BackupDR/DeleteBackupVault", request_serializer=backupvault.DeleteBackupVaultRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -551,7 +641,7 @@ def list_data_sources( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_data_sources" not in self._stubs: - self._stubs["list_data_sources"] = self.grpc_channel.unary_unary( + self._stubs["list_data_sources"] = self._logged_channel.unary_unary( "/google.cloud.backupdr.v1.BackupDR/ListDataSources", request_serializer=backupvault.ListDataSourcesRequest.serialize, response_deserializer=backupvault.ListDataSourcesResponse.deserialize, @@ -577,7 +667,7 @@ def get_data_source( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_data_source" not in self._stubs: - self._stubs["get_data_source"] = self.grpc_channel.unary_unary( + self._stubs["get_data_source"] = self._logged_channel.unary_unary( "/google.cloud.backupdr.v1.BackupDR/GetDataSource", request_serializer=backupvault.GetDataSourceRequest.serialize, response_deserializer=backupvault.DataSource.deserialize, @@ -603,7 +693,7 @@ def update_data_source( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_data_source" not in self._stubs: - self._stubs["update_data_source"] = self.grpc_channel.unary_unary( + self._stubs["update_data_source"] = self._logged_channel.unary_unary( "/google.cloud.backupdr.v1.BackupDR/UpdateDataSource", request_serializer=backupvault.UpdateDataSourceRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -629,7 +719,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.backupdr.v1.BackupDR/ListBackups", request_serializer=backupvault.ListBackupsRequest.serialize, response_deserializer=backupvault.ListBackupsResponse.deserialize, @@ -655,7 +745,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.backupdr.v1.BackupDR/GetBackup", request_serializer=backupvault.GetBackupRequest.serialize, response_deserializer=backupvault.Backup.deserialize, @@ -681,7 +771,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.backupdr.v1.BackupDR/UpdateBackup", request_serializer=backupvault.UpdateBackupRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -707,7 +797,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.backupdr.v1.BackupDR/DeleteBackup", request_serializer=backupvault.DeleteBackupRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -733,7 +823,7 @@ def restore_backup( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "restore_backup" not in self._stubs: - self._stubs["restore_backup"] = self.grpc_channel.unary_unary( + self._stubs["restore_backup"] = self._logged_channel.unary_unary( "/google.cloud.backupdr.v1.BackupDR/RestoreBackup", request_serializer=backupvault.RestoreBackupRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -759,7 +849,7 @@ def create_backup_plan( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_backup_plan" not in self._stubs: - self._stubs["create_backup_plan"] = self.grpc_channel.unary_unary( + self._stubs["create_backup_plan"] = self._logged_channel.unary_unary( "/google.cloud.backupdr.v1.BackupDR/CreateBackupPlan", request_serializer=backupplan.CreateBackupPlanRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -785,7 +875,7 @@ def get_backup_plan( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_backup_plan" not in self._stubs: - self._stubs["get_backup_plan"] = self.grpc_channel.unary_unary( + self._stubs["get_backup_plan"] = self._logged_channel.unary_unary( "/google.cloud.backupdr.v1.BackupDR/GetBackupPlan", request_serializer=backupplan.GetBackupPlanRequest.serialize, response_deserializer=backupplan.BackupPlan.deserialize, @@ -813,7 +903,7 @@ def list_backup_plans( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_backup_plans" not in self._stubs: - self._stubs["list_backup_plans"] = self.grpc_channel.unary_unary( + self._stubs["list_backup_plans"] = self._logged_channel.unary_unary( "/google.cloud.backupdr.v1.BackupDR/ListBackupPlans", request_serializer=backupplan.ListBackupPlansRequest.serialize, response_deserializer=backupplan.ListBackupPlansResponse.deserialize, @@ -839,7 +929,7 @@ def delete_backup_plan( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_backup_plan" not in self._stubs: - self._stubs["delete_backup_plan"] = self.grpc_channel.unary_unary( + self._stubs["delete_backup_plan"] = self._logged_channel.unary_unary( "/google.cloud.backupdr.v1.BackupDR/DeleteBackupPlan", request_serializer=backupplan.DeleteBackupPlanRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -870,7 +960,7 @@ def create_backup_plan_association( if "create_backup_plan_association" not in self._stubs: self._stubs[ "create_backup_plan_association" - ] = self.grpc_channel.unary_unary( + ] = self._logged_channel.unary_unary( "/google.cloud.backupdr.v1.BackupDR/CreateBackupPlanAssociation", request_serializer=backupplanassociation.CreateBackupPlanAssociationRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -899,7 +989,9 @@ def get_backup_plan_association( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_backup_plan_association" not in self._stubs: - self._stubs["get_backup_plan_association"] = self.grpc_channel.unary_unary( + self._stubs[ + "get_backup_plan_association" + ] = self._logged_channel.unary_unary( "/google.cloud.backupdr.v1.BackupDR/GetBackupPlanAssociation", request_serializer=backupplanassociation.GetBackupPlanAssociationRequest.serialize, response_deserializer=backupplanassociation.BackupPlanAssociation.deserialize, @@ -931,7 +1023,7 @@ def list_backup_plan_associations( if "list_backup_plan_associations" not in self._stubs: self._stubs[ "list_backup_plan_associations" - ] = self.grpc_channel.unary_unary( + ] = self._logged_channel.unary_unary( "/google.cloud.backupdr.v1.BackupDR/ListBackupPlanAssociations", request_serializer=backupplanassociation.ListBackupPlanAssociationsRequest.serialize, response_deserializer=backupplanassociation.ListBackupPlanAssociationsResponse.deserialize, @@ -962,7 +1054,7 @@ def delete_backup_plan_association( if "delete_backup_plan_association" not in self._stubs: self._stubs[ "delete_backup_plan_association" - ] = self.grpc_channel.unary_unary( + ] = self._logged_channel.unary_unary( "/google.cloud.backupdr.v1.BackupDR/DeleteBackupPlanAssociation", request_serializer=backupplanassociation.DeleteBackupPlanAssociationRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -990,7 +1082,7 @@ def trigger_backup( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "trigger_backup" not in self._stubs: - self._stubs["trigger_backup"] = self.grpc_channel.unary_unary( + self._stubs["trigger_backup"] = self._logged_channel.unary_unary( "/google.cloud.backupdr.v1.BackupDR/TriggerBackup", request_serializer=backupplanassociation.TriggerBackupRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -998,7 +1090,7 @@ def trigger_backup( return self._stubs["trigger_backup"] def close(self): - self.grpc_channel.close() + self._logged_channel.close() @property def delete_operation( @@ -1010,7 +1102,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, @@ -1027,7 +1119,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, @@ -1044,7 +1136,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, @@ -1063,7 +1155,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, @@ -1082,7 +1174,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, @@ -1099,7 +1191,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, @@ -1124,7 +1216,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, @@ -1150,7 +1242,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, @@ -1179,7 +1271,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-backupdr/google/cloud/backupdr_v1/services/backup_dr/transports/grpc_asyncio.py b/packages/google-cloud-backupdr/google/cloud/backupdr_v1/services/backup_dr/transports/grpc_asyncio.py index fbfe093225d9..80a10bbe29be 100644 --- a/packages/google-cloud-backupdr/google/cloud/backupdr_v1/services/backup_dr/transports/grpc_asyncio.py +++ b/packages/google-cloud-backupdr/google/cloud/backupdr_v1/services/backup_dr/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.backupdr_v1.types import ( backupdr, @@ -39,6 +45,82 @@ from .base import DEFAULT_CLIENT_INFO, BackupDRTransport from .grpc import BackupDRGrpcTransport +try: + from google.api_core import client_logging # 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.backupdr.v1.BackupDR", + "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.backupdr.v1.BackupDR", + "rpcName": str(client_call_details.method), + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class BackupDRGrpcAsyncIOTransport(BackupDRTransport): """gRPC AsyncIO backend transport for BackupDR. @@ -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 @@ -262,7 +347,7 @@ def operations_client(self) -> operations_v1.OperationsAsyncClient: # Quick check: Only create a new client if we do not already have one. if self._operations_client is None: self._operations_client = operations_v1.OperationsAsyncClient( - self.grpc_channel + self._logged_channel ) # Return the client from cache. @@ -291,7 +376,7 @@ def list_management_servers( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_management_servers" not in self._stubs: - self._stubs["list_management_servers"] = self.grpc_channel.unary_unary( + self._stubs["list_management_servers"] = self._logged_channel.unary_unary( "/google.cloud.backupdr.v1.BackupDR/ListManagementServers", request_serializer=backupdr.ListManagementServersRequest.serialize, response_deserializer=backupdr.ListManagementServersResponse.deserialize, @@ -319,7 +404,7 @@ def get_management_server( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_management_server" not in self._stubs: - self._stubs["get_management_server"] = self.grpc_channel.unary_unary( + self._stubs["get_management_server"] = self._logged_channel.unary_unary( "/google.cloud.backupdr.v1.BackupDR/GetManagementServer", request_serializer=backupdr.GetManagementServerRequest.serialize, response_deserializer=backupdr.ManagementServer.deserialize, @@ -348,7 +433,7 @@ def create_management_server( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_management_server" not in self._stubs: - self._stubs["create_management_server"] = self.grpc_channel.unary_unary( + self._stubs["create_management_server"] = self._logged_channel.unary_unary( "/google.cloud.backupdr.v1.BackupDR/CreateManagementServer", request_serializer=backupdr.CreateManagementServerRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -376,7 +461,7 @@ def delete_management_server( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_management_server" not in self._stubs: - self._stubs["delete_management_server"] = self.grpc_channel.unary_unary( + self._stubs["delete_management_server"] = self._logged_channel.unary_unary( "/google.cloud.backupdr.v1.BackupDR/DeleteManagementServer", request_serializer=backupdr.DeleteManagementServerRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -405,7 +490,7 @@ def create_backup_vault( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_backup_vault" not in self._stubs: - self._stubs["create_backup_vault"] = self.grpc_channel.unary_unary( + self._stubs["create_backup_vault"] = self._logged_channel.unary_unary( "/google.cloud.backupdr.v1.BackupDR/CreateBackupVault", request_serializer=backupvault.CreateBackupVaultRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -434,7 +519,7 @@ def list_backup_vaults( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_backup_vaults" not in self._stubs: - self._stubs["list_backup_vaults"] = self.grpc_channel.unary_unary( + self._stubs["list_backup_vaults"] = self._logged_channel.unary_unary( "/google.cloud.backupdr.v1.BackupDR/ListBackupVaults", request_serializer=backupvault.ListBackupVaultsRequest.serialize, response_deserializer=backupvault.ListBackupVaultsResponse.deserialize, @@ -465,7 +550,9 @@ def fetch_usable_backup_vaults( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "fetch_usable_backup_vaults" not in self._stubs: - self._stubs["fetch_usable_backup_vaults"] = self.grpc_channel.unary_unary( + self._stubs[ + "fetch_usable_backup_vaults" + ] = self._logged_channel.unary_unary( "/google.cloud.backupdr.v1.BackupDR/FetchUsableBackupVaults", request_serializer=backupvault.FetchUsableBackupVaultsRequest.serialize, response_deserializer=backupvault.FetchUsableBackupVaultsResponse.deserialize, @@ -493,7 +580,7 @@ def get_backup_vault( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_backup_vault" not in self._stubs: - self._stubs["get_backup_vault"] = self.grpc_channel.unary_unary( + self._stubs["get_backup_vault"] = self._logged_channel.unary_unary( "/google.cloud.backupdr.v1.BackupDR/GetBackupVault", request_serializer=backupvault.GetBackupVaultRequest.serialize, response_deserializer=backupvault.BackupVault.deserialize, @@ -521,7 +608,7 @@ def update_backup_vault( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_backup_vault" not in self._stubs: - self._stubs["update_backup_vault"] = self.grpc_channel.unary_unary( + self._stubs["update_backup_vault"] = self._logged_channel.unary_unary( "/google.cloud.backupdr.v1.BackupDR/UpdateBackupVault", request_serializer=backupvault.UpdateBackupVaultRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -549,7 +636,7 @@ def delete_backup_vault( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_backup_vault" not in self._stubs: - self._stubs["delete_backup_vault"] = self.grpc_channel.unary_unary( + self._stubs["delete_backup_vault"] = self._logged_channel.unary_unary( "/google.cloud.backupdr.v1.BackupDR/DeleteBackupVault", request_serializer=backupvault.DeleteBackupVaultRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -578,7 +665,7 @@ def list_data_sources( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_data_sources" not in self._stubs: - self._stubs["list_data_sources"] = self.grpc_channel.unary_unary( + self._stubs["list_data_sources"] = self._logged_channel.unary_unary( "/google.cloud.backupdr.v1.BackupDR/ListDataSources", request_serializer=backupvault.ListDataSourcesRequest.serialize, response_deserializer=backupvault.ListDataSourcesResponse.deserialize, @@ -606,7 +693,7 @@ def get_data_source( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_data_source" not in self._stubs: - self._stubs["get_data_source"] = self.grpc_channel.unary_unary( + self._stubs["get_data_source"] = self._logged_channel.unary_unary( "/google.cloud.backupdr.v1.BackupDR/GetDataSource", request_serializer=backupvault.GetDataSourceRequest.serialize, response_deserializer=backupvault.DataSource.deserialize, @@ -634,7 +721,7 @@ def update_data_source( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_data_source" not in self._stubs: - self._stubs["update_data_source"] = self.grpc_channel.unary_unary( + self._stubs["update_data_source"] = self._logged_channel.unary_unary( "/google.cloud.backupdr.v1.BackupDR/UpdateDataSource", request_serializer=backupvault.UpdateDataSourceRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -662,7 +749,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.backupdr.v1.BackupDR/ListBackups", request_serializer=backupvault.ListBackupsRequest.serialize, response_deserializer=backupvault.ListBackupsResponse.deserialize, @@ -688,7 +775,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.backupdr.v1.BackupDR/GetBackup", request_serializer=backupvault.GetBackupRequest.serialize, response_deserializer=backupvault.Backup.deserialize, @@ -716,7 +803,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.backupdr.v1.BackupDR/UpdateBackup", request_serializer=backupvault.UpdateBackupRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -744,7 +831,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.backupdr.v1.BackupDR/DeleteBackup", request_serializer=backupvault.DeleteBackupRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -772,7 +859,7 @@ def restore_backup( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "restore_backup" not in self._stubs: - self._stubs["restore_backup"] = self.grpc_channel.unary_unary( + self._stubs["restore_backup"] = self._logged_channel.unary_unary( "/google.cloud.backupdr.v1.BackupDR/RestoreBackup", request_serializer=backupvault.RestoreBackupRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -800,7 +887,7 @@ def create_backup_plan( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_backup_plan" not in self._stubs: - self._stubs["create_backup_plan"] = self.grpc_channel.unary_unary( + self._stubs["create_backup_plan"] = self._logged_channel.unary_unary( "/google.cloud.backupdr.v1.BackupDR/CreateBackupPlan", request_serializer=backupplan.CreateBackupPlanRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -826,7 +913,7 @@ def get_backup_plan( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_backup_plan" not in self._stubs: - self._stubs["get_backup_plan"] = self.grpc_channel.unary_unary( + self._stubs["get_backup_plan"] = self._logged_channel.unary_unary( "/google.cloud.backupdr.v1.BackupDR/GetBackupPlan", request_serializer=backupplan.GetBackupPlanRequest.serialize, response_deserializer=backupplan.BackupPlan.deserialize, @@ -855,7 +942,7 @@ def list_backup_plans( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_backup_plans" not in self._stubs: - self._stubs["list_backup_plans"] = self.grpc_channel.unary_unary( + self._stubs["list_backup_plans"] = self._logged_channel.unary_unary( "/google.cloud.backupdr.v1.BackupDR/ListBackupPlans", request_serializer=backupplan.ListBackupPlansRequest.serialize, response_deserializer=backupplan.ListBackupPlansResponse.deserialize, @@ -883,7 +970,7 @@ def delete_backup_plan( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_backup_plan" not in self._stubs: - self._stubs["delete_backup_plan"] = self.grpc_channel.unary_unary( + self._stubs["delete_backup_plan"] = self._logged_channel.unary_unary( "/google.cloud.backupdr.v1.BackupDR/DeleteBackupPlan", request_serializer=backupplan.DeleteBackupPlanRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -914,7 +1001,7 @@ def create_backup_plan_association( if "create_backup_plan_association" not in self._stubs: self._stubs[ "create_backup_plan_association" - ] = self.grpc_channel.unary_unary( + ] = self._logged_channel.unary_unary( "/google.cloud.backupdr.v1.BackupDR/CreateBackupPlanAssociation", request_serializer=backupplanassociation.CreateBackupPlanAssociationRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -943,7 +1030,9 @@ def get_backup_plan_association( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_backup_plan_association" not in self._stubs: - self._stubs["get_backup_plan_association"] = self.grpc_channel.unary_unary( + self._stubs[ + "get_backup_plan_association" + ] = self._logged_channel.unary_unary( "/google.cloud.backupdr.v1.BackupDR/GetBackupPlanAssociation", request_serializer=backupplanassociation.GetBackupPlanAssociationRequest.serialize, response_deserializer=backupplanassociation.BackupPlanAssociation.deserialize, @@ -975,7 +1064,7 @@ def list_backup_plan_associations( if "list_backup_plan_associations" not in self._stubs: self._stubs[ "list_backup_plan_associations" - ] = self.grpc_channel.unary_unary( + ] = self._logged_channel.unary_unary( "/google.cloud.backupdr.v1.BackupDR/ListBackupPlanAssociations", request_serializer=backupplanassociation.ListBackupPlanAssociationsRequest.serialize, response_deserializer=backupplanassociation.ListBackupPlanAssociationsResponse.deserialize, @@ -1006,7 +1095,7 @@ def delete_backup_plan_association( if "delete_backup_plan_association" not in self._stubs: self._stubs[ "delete_backup_plan_association" - ] = self.grpc_channel.unary_unary( + ] = self._logged_channel.unary_unary( "/google.cloud.backupdr.v1.BackupDR/DeleteBackupPlanAssociation", request_serializer=backupplanassociation.DeleteBackupPlanAssociationRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -1035,7 +1124,7 @@ def trigger_backup( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "trigger_backup" not in self._stubs: - self._stubs["trigger_backup"] = self.grpc_channel.unary_unary( + self._stubs["trigger_backup"] = self._logged_channel.unary_unary( "/google.cloud.backupdr.v1.BackupDR/TriggerBackup", request_serializer=backupplanassociation.TriggerBackupRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -1332,7 +1421,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: @@ -1348,7 +1437,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, @@ -1365,7 +1454,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, @@ -1382,7 +1471,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, @@ -1401,7 +1490,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, @@ -1420,7 +1509,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, @@ -1437,7 +1526,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, @@ -1462,7 +1551,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, @@ -1488,7 +1577,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, @@ -1517,7 +1606,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-backupdr/google/cloud/backupdr_v1/services/backup_dr/transports/rest.py b/packages/google-cloud-backupdr/google/cloud/backupdr_v1/services/backup_dr/transports/rest.py index 631430a0f021..e4db8c8a1cd0 100644 --- a/packages/google-cloud-backupdr/google/cloud/backupdr_v1/services/backup_dr/transports/rest.py +++ b/packages/google-cloud-backupdr/google/cloud/backupdr_v1/services/backup_dr/transports/rest.py @@ -13,9 +13,9 @@ # See the License for the specific language governing permissions and # limitations under the License. # - import dataclasses import json # type: ignore +import logging from typing import Any, Callable, Dict, List, Optional, Sequence, Tuple, Union import warnings @@ -46,6 +46,14 @@ except AttributeError: # pragma: NO COVER OptionalRetry = Union[retries.Retry, object, None] # type: ignore +try: + from google.api_core import client_logging # type: ignore + + CLIENT_LOGGING_SUPPORTED = True # pragma: NO COVER +except ImportError: # pragma: NO COVER + CLIENT_LOGGING_SUPPORTED = False + +_LOGGER = logging.getLogger(__name__) DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo( gapic_version=BASE_DEFAULT_CLIENT_INFO.gapic_version, @@ -294,8 +302,10 @@ def post_update_data_source(self, response): def pre_create_backup_plan( self, request: backupplan.CreateBackupPlanRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[backupplan.CreateBackupPlanRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + backupplan.CreateBackupPlanRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for create_backup_plan Override in a subclass to manipulate the request or metadata @@ -317,10 +327,10 @@ def post_create_backup_plan( def pre_create_backup_plan_association( self, request: backupplanassociation.CreateBackupPlanAssociationRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ backupplanassociation.CreateBackupPlanAssociationRequest, - Sequence[Tuple[str, str]], + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for create_backup_plan_association @@ -343,8 +353,10 @@ def post_create_backup_plan_association( def pre_create_backup_vault( self, request: backupvault.CreateBackupVaultRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[backupvault.CreateBackupVaultRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + backupvault.CreateBackupVaultRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for create_backup_vault Override in a subclass to manipulate the request or metadata @@ -366,8 +378,10 @@ def post_create_backup_vault( def pre_create_management_server( self, request: backupdr.CreateManagementServerRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[backupdr.CreateManagementServerRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + backupdr.CreateManagementServerRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for create_management_server Override in a subclass to manipulate the request or metadata @@ -389,8 +403,10 @@ def post_create_management_server( def pre_delete_backup( self, request: backupvault.DeleteBackupRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[backupvault.DeleteBackupRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + backupvault.DeleteBackupRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for delete_backup Override in a subclass to manipulate the request or metadata @@ -412,8 +428,10 @@ def post_delete_backup( def pre_delete_backup_plan( self, request: backupplan.DeleteBackupPlanRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[backupplan.DeleteBackupPlanRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + backupplan.DeleteBackupPlanRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for delete_backup_plan Override in a subclass to manipulate the request or metadata @@ -435,10 +453,10 @@ def post_delete_backup_plan( def pre_delete_backup_plan_association( self, request: backupplanassociation.DeleteBackupPlanAssociationRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ backupplanassociation.DeleteBackupPlanAssociationRequest, - Sequence[Tuple[str, str]], + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for delete_backup_plan_association @@ -461,8 +479,10 @@ def post_delete_backup_plan_association( def pre_delete_backup_vault( self, request: backupvault.DeleteBackupVaultRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[backupvault.DeleteBackupVaultRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + backupvault.DeleteBackupVaultRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for delete_backup_vault Override in a subclass to manipulate the request or metadata @@ -484,8 +504,10 @@ def post_delete_backup_vault( def pre_delete_management_server( self, request: backupdr.DeleteManagementServerRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[backupdr.DeleteManagementServerRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + backupdr.DeleteManagementServerRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for delete_management_server Override in a subclass to manipulate the request or metadata @@ -507,8 +529,11 @@ def post_delete_management_server( def pre_fetch_usable_backup_vaults( self, request: backupvault.FetchUsableBackupVaultsRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[backupvault.FetchUsableBackupVaultsRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + backupvault.FetchUsableBackupVaultsRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for fetch_usable_backup_vaults Override in a subclass to manipulate the request or metadata @@ -528,8 +553,10 @@ def post_fetch_usable_backup_vaults( return response def pre_get_backup( - self, request: backupvault.GetBackupRequest, metadata: Sequence[Tuple[str, str]] - ) -> Tuple[backupvault.GetBackupRequest, Sequence[Tuple[str, str]]]: + self, + request: backupvault.GetBackupRequest, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[backupvault.GetBackupRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for get_backup Override in a subclass to manipulate the request or metadata @@ -549,8 +576,10 @@ def post_get_backup(self, response: backupvault.Backup) -> backupvault.Backup: def pre_get_backup_plan( self, request: backupplan.GetBackupPlanRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[backupplan.GetBackupPlanRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + backupplan.GetBackupPlanRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for get_backup_plan Override in a subclass to manipulate the request or metadata @@ -572,9 +601,10 @@ def post_get_backup_plan( def pre_get_backup_plan_association( self, request: backupplanassociation.GetBackupPlanAssociationRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ - backupplanassociation.GetBackupPlanAssociationRequest, Sequence[Tuple[str, str]] + backupplanassociation.GetBackupPlanAssociationRequest, + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for get_backup_plan_association @@ -597,8 +627,10 @@ def post_get_backup_plan_association( def pre_get_backup_vault( self, request: backupvault.GetBackupVaultRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[backupvault.GetBackupVaultRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + backupvault.GetBackupVaultRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for get_backup_vault Override in a subclass to manipulate the request or metadata @@ -620,8 +652,10 @@ def post_get_backup_vault( def pre_get_data_source( self, request: backupvault.GetDataSourceRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[backupvault.GetDataSourceRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + backupvault.GetDataSourceRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for get_data_source Override in a subclass to manipulate the request or metadata @@ -643,8 +677,10 @@ def post_get_data_source( def pre_get_management_server( self, request: backupdr.GetManagementServerRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[backupdr.GetManagementServerRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + backupdr.GetManagementServerRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for get_management_server Override in a subclass to manipulate the request or metadata @@ -666,10 +702,10 @@ def post_get_management_server( def pre_list_backup_plan_associations( self, request: backupplanassociation.ListBackupPlanAssociationsRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ backupplanassociation.ListBackupPlanAssociationsRequest, - Sequence[Tuple[str, str]], + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for list_backup_plan_associations @@ -692,8 +728,10 @@ def post_list_backup_plan_associations( def pre_list_backup_plans( self, request: backupplan.ListBackupPlansRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[backupplan.ListBackupPlansRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + backupplan.ListBackupPlansRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for list_backup_plans Override in a subclass to manipulate the request or metadata @@ -715,8 +753,8 @@ def post_list_backup_plans( def pre_list_backups( self, request: backupvault.ListBackupsRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[backupvault.ListBackupsRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[backupvault.ListBackupsRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for list_backups Override in a subclass to manipulate the request or metadata @@ -738,8 +776,10 @@ def post_list_backups( def pre_list_backup_vaults( self, request: backupvault.ListBackupVaultsRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[backupvault.ListBackupVaultsRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + backupvault.ListBackupVaultsRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for list_backup_vaults Override in a subclass to manipulate the request or metadata @@ -761,8 +801,10 @@ def post_list_backup_vaults( def pre_list_data_sources( self, request: backupvault.ListDataSourcesRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[backupvault.ListDataSourcesRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + backupvault.ListDataSourcesRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for list_data_sources Override in a subclass to manipulate the request or metadata @@ -784,8 +826,10 @@ def post_list_data_sources( def pre_list_management_servers( self, request: backupdr.ListManagementServersRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[backupdr.ListManagementServersRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + backupdr.ListManagementServersRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for list_management_servers Override in a subclass to manipulate the request or metadata @@ -807,8 +851,10 @@ def post_list_management_servers( def pre_restore_backup( self, request: backupvault.RestoreBackupRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[backupvault.RestoreBackupRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + backupvault.RestoreBackupRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for restore_backup Override in a subclass to manipulate the request or metadata @@ -830,8 +876,11 @@ def post_restore_backup( def pre_trigger_backup( self, request: backupplanassociation.TriggerBackupRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[backupplanassociation.TriggerBackupRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + backupplanassociation.TriggerBackupRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for trigger_backup Override in a subclass to manipulate the request or metadata @@ -853,8 +902,10 @@ def post_trigger_backup( def pre_update_backup( self, request: backupvault.UpdateBackupRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[backupvault.UpdateBackupRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + backupvault.UpdateBackupRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for update_backup Override in a subclass to manipulate the request or metadata @@ -876,8 +927,10 @@ def post_update_backup( def pre_update_backup_vault( self, request: backupvault.UpdateBackupVaultRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[backupvault.UpdateBackupVaultRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + backupvault.UpdateBackupVaultRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for update_backup_vault Override in a subclass to manipulate the request or metadata @@ -899,8 +952,10 @@ def post_update_backup_vault( def pre_update_data_source( self, request: backupvault.UpdateDataSourceRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[backupvault.UpdateDataSourceRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + backupvault.UpdateDataSourceRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for update_data_source Override in a subclass to manipulate the request or metadata @@ -922,8 +977,10 @@ def post_update_data_source( 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 @@ -945,8 +1002,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 @@ -968,8 +1027,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 @@ -989,8 +1050,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 @@ -1010,8 +1073,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 @@ -1033,8 +1099,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 @@ -1054,8 +1122,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 @@ -1075,8 +1145,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 @@ -1098,8 +1170,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 @@ -1294,7 +1368,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Call the create backup plan method over HTTP. @@ -1304,8 +1378,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.operations_pb2.Operation: @@ -1318,6 +1394,7 @@ def __call__( http_options = ( _BaseBackupDRRestTransport._BaseCreateBackupPlan._get_http_options() ) + request, metadata = self._interceptor.pre_create_backup_plan( request, metadata ) @@ -1338,6 +1415,33 @@ def __call__( ) ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.backupdr_v1.BackupDRClient.CreateBackupPlan", + extra={ + "serviceName": "google.cloud.backupdr.v1.BackupDR", + "rpcName": "CreateBackupPlan", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = BackupDRRestTransport._CreateBackupPlan._get_response( self._host, @@ -1357,7 +1461,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_plan(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = json_format.MessageToJson(resp) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.backupdr_v1.BackupDRClient.create_backup_plan", + extra={ + "serviceName": "google.cloud.backupdr.v1.BackupDR", + "rpcName": "CreateBackupPlan", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _CreateBackupPlanAssociation( @@ -1395,7 +1521,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.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 plan association method over HTTP. @@ -1407,8 +1533,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.operations_pb2.Operation: @@ -1421,6 +1549,7 @@ def __call__( http_options = ( _BaseBackupDRRestTransport._BaseCreateBackupPlanAssociation._get_http_options() ) + request, metadata = self._interceptor.pre_create_backup_plan_association( request, metadata ) @@ -1437,6 +1566,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.backupdr_v1.BackupDRClient.CreateBackupPlanAssociation", + extra={ + "serviceName": "google.cloud.backupdr.v1.BackupDR", + "rpcName": "CreateBackupPlanAssociation", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = BackupDRRestTransport._CreateBackupPlanAssociation._get_response( self._host, @@ -1456,7 +1612,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_plan_association(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = json_format.MessageToJson(resp) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.backupdr_v1.BackupDRClient.create_backup_plan_association", + extra={ + "serviceName": "google.cloud.backupdr.v1.BackupDR", + "rpcName": "CreateBackupPlanAssociation", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _CreateBackupVault( @@ -1494,7 +1672,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.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 vault method over HTTP. @@ -1504,8 +1682,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.operations_pb2.Operation: @@ -1518,6 +1698,7 @@ def __call__( http_options = ( _BaseBackupDRRestTransport._BaseCreateBackupVault._get_http_options() ) + request, metadata = self._interceptor.pre_create_backup_vault( request, metadata ) @@ -1534,6 +1715,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.backupdr_v1.BackupDRClient.CreateBackupVault", + extra={ + "serviceName": "google.cloud.backupdr.v1.BackupDR", + "rpcName": "CreateBackupVault", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = BackupDRRestTransport._CreateBackupVault._get_response( self._host, @@ -1553,7 +1761,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_vault(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = json_format.MessageToJson(resp) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.backupdr_v1.BackupDRClient.create_backup_vault", + extra={ + "serviceName": "google.cloud.backupdr.v1.BackupDR", + "rpcName": "CreateBackupVault", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _CreateManagementServer( @@ -1591,7 +1821,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Call the create management server method over HTTP. @@ -1602,8 +1832,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.operations_pb2.Operation: @@ -1616,6 +1848,7 @@ def __call__( http_options = ( _BaseBackupDRRestTransport._BaseCreateManagementServer._get_http_options() ) + request, metadata = self._interceptor.pre_create_management_server( request, metadata ) @@ -1632,6 +1865,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.backupdr_v1.BackupDRClient.CreateManagementServer", + extra={ + "serviceName": "google.cloud.backupdr.v1.BackupDR", + "rpcName": "CreateManagementServer", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = BackupDRRestTransport._CreateManagementServer._get_response( self._host, @@ -1651,7 +1911,29 @@ def __call__( # Return the response resp = operations_pb2.Operation() json_format.Parse(response.content, resp, ignore_unknown_fields=True) + resp = self._interceptor.post_create_management_server(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = json_format.MessageToJson(resp) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.backupdr_v1.BackupDRClient.create_management_server", + extra={ + "serviceName": "google.cloud.backupdr.v1.BackupDR", + "rpcName": "CreateManagementServer", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _DeleteBackup(_BaseBackupDRRestTransport._BaseDeleteBackup, BackupDRRestStub): @@ -1686,7 +1968,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Call the delete backup method over HTTP. @@ -1696,8 +1978,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.operations_pb2.Operation: @@ -1710,6 +1994,7 @@ def __call__( http_options = ( _BaseBackupDRRestTransport._BaseDeleteBackup._get_http_options() ) + request, metadata = self._interceptor.pre_delete_backup(request, metadata) transcoded_request = ( _BaseBackupDRRestTransport._BaseDeleteBackup._get_transcoded_request( @@ -1724,6 +2009,33 @@ def __call__( ) ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.backupdr_v1.BackupDRClient.DeleteBackup", + extra={ + "serviceName": "google.cloud.backupdr.v1.BackupDR", + "rpcName": "DeleteBackup", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = BackupDRRestTransport._DeleteBackup._get_response( self._host, @@ -1742,7 +2054,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.backupdr_v1.BackupDRClient.delete_backup", + extra={ + "serviceName": "google.cloud.backupdr.v1.BackupDR", + "rpcName": "DeleteBackup", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _DeleteBackupPlan( @@ -1779,7 +2113,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.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 plan method over HTTP. @@ -1789,8 +2123,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.operations_pb2.Operation: @@ -1803,6 +2139,7 @@ def __call__( http_options = ( _BaseBackupDRRestTransport._BaseDeleteBackupPlan._get_http_options() ) + request, metadata = self._interceptor.pre_delete_backup_plan( request, metadata ) @@ -1817,6 +2154,33 @@ def __call__( ) ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.backupdr_v1.BackupDRClient.DeleteBackupPlan", + extra={ + "serviceName": "google.cloud.backupdr.v1.BackupDR", + "rpcName": "DeleteBackupPlan", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = BackupDRRestTransport._DeleteBackupPlan._get_response( self._host, @@ -1835,7 +2199,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_plan(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = json_format.MessageToJson(resp) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.backupdr_v1.BackupDRClient.delete_backup_plan", + extra={ + "serviceName": "google.cloud.backupdr.v1.BackupDR", + "rpcName": "DeleteBackupPlan", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _DeleteBackupPlanAssociation( @@ -1872,7 +2258,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Call the delete backup plan association method over HTTP. @@ -1884,8 +2270,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.operations_pb2.Operation: @@ -1898,6 +2286,7 @@ def __call__( http_options = ( _BaseBackupDRRestTransport._BaseDeleteBackupPlanAssociation._get_http_options() ) + request, metadata = self._interceptor.pre_delete_backup_plan_association( request, metadata ) @@ -1910,6 +2299,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.backupdr_v1.BackupDRClient.DeleteBackupPlanAssociation", + extra={ + "serviceName": "google.cloud.backupdr.v1.BackupDR", + "rpcName": "DeleteBackupPlanAssociation", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = BackupDRRestTransport._DeleteBackupPlanAssociation._get_response( self._host, @@ -1928,7 +2344,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_plan_association(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = json_format.MessageToJson(resp) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.backupdr_v1.BackupDRClient.delete_backup_plan_association", + extra={ + "serviceName": "google.cloud.backupdr.v1.BackupDR", + "rpcName": "DeleteBackupPlanAssociation", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _DeleteBackupVault( @@ -1965,7 +2403,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.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 vault method over HTTP. @@ -1975,8 +2413,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.operations_pb2.Operation: @@ -1989,6 +2429,7 @@ def __call__( http_options = ( _BaseBackupDRRestTransport._BaseDeleteBackupVault._get_http_options() ) + request, metadata = self._interceptor.pre_delete_backup_vault( request, metadata ) @@ -2001,6 +2442,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.backupdr_v1.BackupDRClient.DeleteBackupVault", + extra={ + "serviceName": "google.cloud.backupdr.v1.BackupDR", + "rpcName": "DeleteBackupVault", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = BackupDRRestTransport._DeleteBackupVault._get_response( self._host, @@ -2019,7 +2487,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_vault(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = json_format.MessageToJson(resp) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.backupdr_v1.BackupDRClient.delete_backup_vault", + extra={ + "serviceName": "google.cloud.backupdr.v1.BackupDR", + "rpcName": "DeleteBackupVault", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _DeleteManagementServer( @@ -2056,7 +2546,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Call the delete management server method over HTTP. @@ -2067,8 +2557,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.operations_pb2.Operation: @@ -2081,6 +2573,7 @@ def __call__( http_options = ( _BaseBackupDRRestTransport._BaseDeleteManagementServer._get_http_options() ) + request, metadata = self._interceptor.pre_delete_management_server( request, metadata ) @@ -2093,6 +2586,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.backupdr_v1.BackupDRClient.DeleteManagementServer", + extra={ + "serviceName": "google.cloud.backupdr.v1.BackupDR", + "rpcName": "DeleteManagementServer", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = BackupDRRestTransport._DeleteManagementServer._get_response( self._host, @@ -2111,7 +2631,29 @@ def __call__( # Return the response resp = operations_pb2.Operation() json_format.Parse(response.content, resp, ignore_unknown_fields=True) + resp = self._interceptor.post_delete_management_server(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = json_format.MessageToJson(resp) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.backupdr_v1.BackupDRClient.delete_management_server", + extra={ + "serviceName": "google.cloud.backupdr.v1.BackupDR", + "rpcName": "DeleteManagementServer", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _FetchUsableBackupVaults( @@ -2148,7 +2690,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> backupvault.FetchUsableBackupVaultsResponse: r"""Call the fetch usable backup vaults method over HTTP. @@ -2160,8 +2702,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.backupvault.FetchUsableBackupVaultsResponse: @@ -2173,6 +2717,7 @@ def __call__( http_options = ( _BaseBackupDRRestTransport._BaseFetchUsableBackupVaults._get_http_options() ) + request, metadata = self._interceptor.pre_fetch_usable_backup_vaults( request, metadata ) @@ -2185,6 +2730,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.backupdr_v1.BackupDRClient.FetchUsableBackupVaults", + extra={ + "serviceName": "google.cloud.backupdr.v1.BackupDR", + "rpcName": "FetchUsableBackupVaults", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = BackupDRRestTransport._FetchUsableBackupVaults._get_response( self._host, @@ -2205,7 +2777,31 @@ def __call__( pb_resp = backupvault.FetchUsableBackupVaultsResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_fetch_usable_backup_vaults(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = ( + backupvault.FetchUsableBackupVaultsResponse.to_json(response) + ) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.backupdr_v1.BackupDRClient.fetch_usable_backup_vaults", + extra={ + "serviceName": "google.cloud.backupdr.v1.BackupDR", + "rpcName": "FetchUsableBackupVaults", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _GetBackup(_BaseBackupDRRestTransport._BaseGetBackup, BackupDRRestStub): @@ -2240,7 +2836,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> backupvault.Backup: r"""Call the get backup method over HTTP. @@ -2250,8 +2846,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.backupvault.Backup: @@ -2259,6 +2857,7 @@ def __call__( """ http_options = _BaseBackupDRRestTransport._BaseGetBackup._get_http_options() + request, metadata = self._interceptor.pre_get_backup(request, metadata) transcoded_request = ( _BaseBackupDRRestTransport._BaseGetBackup._get_transcoded_request( @@ -2273,6 +2872,33 @@ def __call__( ) ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.backupdr_v1.BackupDRClient.GetBackup", + extra={ + "serviceName": "google.cloud.backupdr.v1.BackupDR", + "rpcName": "GetBackup", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = BackupDRRestTransport._GetBackup._get_response( self._host, @@ -2293,7 +2919,29 @@ def __call__( pb_resp = backupvault.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 = backupvault.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.backupdr_v1.BackupDRClient.get_backup", + extra={ + "serviceName": "google.cloud.backupdr.v1.BackupDR", + "rpcName": "GetBackup", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _GetBackupPlan( @@ -2330,7 +2978,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> backupplan.BackupPlan: r"""Call the get backup plan method over HTTP. @@ -2340,8 +2988,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.backupplan.BackupPlan: @@ -2356,6 +3006,7 @@ def __call__( http_options = ( _BaseBackupDRRestTransport._BaseGetBackupPlan._get_http_options() ) + request, metadata = self._interceptor.pre_get_backup_plan(request, metadata) transcoded_request = ( _BaseBackupDRRestTransport._BaseGetBackupPlan._get_transcoded_request( @@ -2370,6 +3021,33 @@ def __call__( ) ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.backupdr_v1.BackupDRClient.GetBackupPlan", + extra={ + "serviceName": "google.cloud.backupdr.v1.BackupDR", + "rpcName": "GetBackupPlan", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = BackupDRRestTransport._GetBackupPlan._get_response( self._host, @@ -2390,7 +3068,29 @@ def __call__( pb_resp = backupplan.BackupPlan.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_backup_plan(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = backupplan.BackupPlan.to_json(response) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.backupdr_v1.BackupDRClient.get_backup_plan", + extra={ + "serviceName": "google.cloud.backupdr.v1.BackupDR", + "rpcName": "GetBackupPlan", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _GetBackupPlanAssociation( @@ -2427,7 +3127,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> backupplanassociation.BackupPlanAssociation: r"""Call the get backup plan association method over HTTP. @@ -2439,8 +3139,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.backupplanassociation.BackupPlanAssociation: @@ -2454,6 +3156,7 @@ def __call__( http_options = ( _BaseBackupDRRestTransport._BaseGetBackupPlanAssociation._get_http_options() ) + request, metadata = self._interceptor.pre_get_backup_plan_association( request, metadata ) @@ -2466,6 +3169,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.backupdr_v1.BackupDRClient.GetBackupPlanAssociation", + extra={ + "serviceName": "google.cloud.backupdr.v1.BackupDR", + "rpcName": "GetBackupPlanAssociation", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = BackupDRRestTransport._GetBackupPlanAssociation._get_response( self._host, @@ -2486,7 +3216,31 @@ def __call__( pb_resp = backupplanassociation.BackupPlanAssociation.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_backup_plan_association(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = ( + backupplanassociation.BackupPlanAssociation.to_json(response) + ) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.backupdr_v1.BackupDRClient.get_backup_plan_association", + extra={ + "serviceName": "google.cloud.backupdr.v1.BackupDR", + "rpcName": "GetBackupPlanAssociation", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _GetBackupVault( @@ -2523,7 +3277,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> backupvault.BackupVault: r"""Call the get backup vault method over HTTP. @@ -2534,8 +3288,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.backupvault.BackupVault: @@ -2547,6 +3303,7 @@ def __call__( http_options = ( _BaseBackupDRRestTransport._BaseGetBackupVault._get_http_options() ) + request, metadata = self._interceptor.pre_get_backup_vault( request, metadata ) @@ -2563,6 +3320,33 @@ def __call__( ) ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.backupdr_v1.BackupDRClient.GetBackupVault", + extra={ + "serviceName": "google.cloud.backupdr.v1.BackupDR", + "rpcName": "GetBackupVault", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = BackupDRRestTransport._GetBackupVault._get_response( self._host, @@ -2583,7 +3367,29 @@ def __call__( pb_resp = backupvault.BackupVault.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_backup_vault(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = backupvault.BackupVault.to_json(response) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.backupdr_v1.BackupDRClient.get_backup_vault", + extra={ + "serviceName": "google.cloud.backupdr.v1.BackupDR", + "rpcName": "GetBackupVault", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _GetDataSource( @@ -2620,7 +3426,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> backupvault.DataSource: r"""Call the get data source method over HTTP. @@ -2631,8 +3437,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.backupvault.DataSource: @@ -2646,6 +3454,7 @@ def __call__( http_options = ( _BaseBackupDRRestTransport._BaseGetDataSource._get_http_options() ) + request, metadata = self._interceptor.pre_get_data_source(request, metadata) transcoded_request = ( _BaseBackupDRRestTransport._BaseGetDataSource._get_transcoded_request( @@ -2660,6 +3469,33 @@ def __call__( ) ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.backupdr_v1.BackupDRClient.GetDataSource", + extra={ + "serviceName": "google.cloud.backupdr.v1.BackupDR", + "rpcName": "GetDataSource", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = BackupDRRestTransport._GetDataSource._get_response( self._host, @@ -2680,7 +3516,29 @@ def __call__( pb_resp = backupvault.DataSource.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_data_source(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = backupvault.DataSource.to_json(response) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.backupdr_v1.BackupDRClient.get_data_source", + extra={ + "serviceName": "google.cloud.backupdr.v1.BackupDR", + "rpcName": "GetDataSource", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _GetManagementServer( @@ -2717,7 +3575,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> backupdr.ManagementServer: r"""Call the get management server method over HTTP. @@ -2728,8 +3586,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.backupdr.ManagementServer: @@ -2741,6 +3601,7 @@ def __call__( http_options = ( _BaseBackupDRRestTransport._BaseGetManagementServer._get_http_options() ) + request, metadata = self._interceptor.pre_get_management_server( request, metadata ) @@ -2753,6 +3614,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.backupdr_v1.BackupDRClient.GetManagementServer", + extra={ + "serviceName": "google.cloud.backupdr.v1.BackupDR", + "rpcName": "GetManagementServer", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = BackupDRRestTransport._GetManagementServer._get_response( self._host, @@ -2773,7 +3661,29 @@ def __call__( pb_resp = backupdr.ManagementServer.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_management_server(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = backupdr.ManagementServer.to_json(response) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.backupdr_v1.BackupDRClient.get_management_server", + extra={ + "serviceName": "google.cloud.backupdr.v1.BackupDR", + "rpcName": "GetManagementServer", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ListBackupPlanAssociations( @@ -2810,7 +3720,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> backupplanassociation.ListBackupPlanAssociationsResponse: r"""Call the list backup plan associations method over HTTP. @@ -2822,8 +3732,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.backupplanassociation.ListBackupPlanAssociationsResponse: @@ -2835,6 +3747,7 @@ def __call__( http_options = ( _BaseBackupDRRestTransport._BaseListBackupPlanAssociations._get_http_options() ) + request, metadata = self._interceptor.pre_list_backup_plan_associations( request, metadata ) @@ -2847,6 +3760,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.backupdr_v1.BackupDRClient.ListBackupPlanAssociations", + extra={ + "serviceName": "google.cloud.backupdr.v1.BackupDR", + "rpcName": "ListBackupPlanAssociations", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = BackupDRRestTransport._ListBackupPlanAssociations._get_response( self._host, @@ -2867,7 +3807,31 @@ def __call__( pb_resp = backupplanassociation.ListBackupPlanAssociationsResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_backup_plan_associations(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = backupplanassociation.ListBackupPlanAssociationsResponse.to_json( + response + ) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.backupdr_v1.BackupDRClient.list_backup_plan_associations", + extra={ + "serviceName": "google.cloud.backupdr.v1.BackupDR", + "rpcName": "ListBackupPlanAssociations", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ListBackupPlans( @@ -2904,7 +3868,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> backupplan.ListBackupPlansResponse: r"""Call the list backup plans method over HTTP. @@ -2914,8 +3878,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.backupplan.ListBackupPlansResponse: @@ -2927,6 +3893,7 @@ def __call__( http_options = ( _BaseBackupDRRestTransport._BaseListBackupPlans._get_http_options() ) + request, metadata = self._interceptor.pre_list_backup_plans( request, metadata ) @@ -2943,6 +3910,33 @@ def __call__( ) ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.backupdr_v1.BackupDRClient.ListBackupPlans", + extra={ + "serviceName": "google.cloud.backupdr.v1.BackupDR", + "rpcName": "ListBackupPlans", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = BackupDRRestTransport._ListBackupPlans._get_response( self._host, @@ -2963,7 +3957,31 @@ def __call__( pb_resp = backupplan.ListBackupPlansResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_backup_plans(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = backupplan.ListBackupPlansResponse.to_json( + response + ) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.backupdr_v1.BackupDRClient.list_backup_plans", + extra={ + "serviceName": "google.cloud.backupdr.v1.BackupDR", + "rpcName": "ListBackupPlans", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ListBackups(_BaseBackupDRRestTransport._BaseListBackups, BackupDRRestStub): @@ -2998,7 +4016,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> backupvault.ListBackupsResponse: r"""Call the list backups method over HTTP. @@ -3008,8 +4026,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.backupvault.ListBackupsResponse: @@ -3019,6 +4039,7 @@ def __call__( http_options = ( _BaseBackupDRRestTransport._BaseListBackups._get_http_options() ) + request, metadata = self._interceptor.pre_list_backups(request, metadata) transcoded_request = ( _BaseBackupDRRestTransport._BaseListBackups._get_transcoded_request( @@ -3033,6 +4054,33 @@ def __call__( ) ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.backupdr_v1.BackupDRClient.ListBackups", + extra={ + "serviceName": "google.cloud.backupdr.v1.BackupDR", + "rpcName": "ListBackups", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = BackupDRRestTransport._ListBackups._get_response( self._host, @@ -3053,7 +4101,29 @@ def __call__( pb_resp = backupvault.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 = backupvault.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.backupdr_v1.BackupDRClient.list_backups", + extra={ + "serviceName": "google.cloud.backupdr.v1.BackupDR", + "rpcName": "ListBackups", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ListBackupVaults( @@ -3090,7 +4160,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> backupvault.ListBackupVaultsResponse: r"""Call the list backup vaults method over HTTP. @@ -3101,8 +4171,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.backupvault.ListBackupVaultsResponse: @@ -3114,6 +4186,7 @@ def __call__( http_options = ( _BaseBackupDRRestTransport._BaseListBackupVaults._get_http_options() ) + request, metadata = self._interceptor.pre_list_backup_vaults( request, metadata ) @@ -3128,6 +4201,33 @@ def __call__( ) ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.backupdr_v1.BackupDRClient.ListBackupVaults", + extra={ + "serviceName": "google.cloud.backupdr.v1.BackupDR", + "rpcName": "ListBackupVaults", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = BackupDRRestTransport._ListBackupVaults._get_response( self._host, @@ -3148,7 +4248,31 @@ def __call__( pb_resp = backupvault.ListBackupVaultsResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_backup_vaults(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = backupvault.ListBackupVaultsResponse.to_json( + response + ) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.backupdr_v1.BackupDRClient.list_backup_vaults", + extra={ + "serviceName": "google.cloud.backupdr.v1.BackupDR", + "rpcName": "ListBackupVaults", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ListDataSources( @@ -3185,7 +4309,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> backupvault.ListDataSourcesResponse: r"""Call the list data sources method over HTTP. @@ -3196,8 +4320,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.backupvault.ListDataSourcesResponse: @@ -3209,6 +4335,7 @@ def __call__( http_options = ( _BaseBackupDRRestTransport._BaseListDataSources._get_http_options() ) + request, metadata = self._interceptor.pre_list_data_sources( request, metadata ) @@ -3225,6 +4352,33 @@ def __call__( ) ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.backupdr_v1.BackupDRClient.ListDataSources", + extra={ + "serviceName": "google.cloud.backupdr.v1.BackupDR", + "rpcName": "ListDataSources", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = BackupDRRestTransport._ListDataSources._get_response( self._host, @@ -3245,7 +4399,31 @@ def __call__( pb_resp = backupvault.ListDataSourcesResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_data_sources(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = backupvault.ListDataSourcesResponse.to_json( + response + ) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.backupdr_v1.BackupDRClient.list_data_sources", + extra={ + "serviceName": "google.cloud.backupdr.v1.BackupDR", + "rpcName": "ListDataSources", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ListManagementServers( @@ -3282,7 +4460,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> backupdr.ListManagementServersResponse: r"""Call the list management servers method over HTTP. @@ -3293,8 +4471,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.backupdr.ListManagementServersResponse: @@ -3306,6 +4486,7 @@ def __call__( http_options = ( _BaseBackupDRRestTransport._BaseListManagementServers._get_http_options() ) + request, metadata = self._interceptor.pre_list_management_servers( request, metadata ) @@ -3318,6 +4499,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.backupdr_v1.BackupDRClient.ListManagementServers", + extra={ + "serviceName": "google.cloud.backupdr.v1.BackupDR", + "rpcName": "ListManagementServers", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = BackupDRRestTransport._ListManagementServers._get_response( self._host, @@ -3338,7 +4546,31 @@ def __call__( pb_resp = backupdr.ListManagementServersResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_management_servers(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = backupdr.ListManagementServersResponse.to_json( + response + ) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.backupdr_v1.BackupDRClient.list_management_servers", + extra={ + "serviceName": "google.cloud.backupdr.v1.BackupDR", + "rpcName": "ListManagementServers", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _RestoreBackup( @@ -3376,7 +4608,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.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 backup method over HTTP. @@ -3387,8 +4619,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.operations_pb2.Operation: @@ -3401,6 +4635,7 @@ def __call__( http_options = ( _BaseBackupDRRestTransport._BaseRestoreBackup._get_http_options() ) + request, metadata = self._interceptor.pre_restore_backup(request, metadata) transcoded_request = ( _BaseBackupDRRestTransport._BaseRestoreBackup._get_transcoded_request( @@ -3419,6 +4654,33 @@ def __call__( ) ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.backupdr_v1.BackupDRClient.RestoreBackup", + extra={ + "serviceName": "google.cloud.backupdr.v1.BackupDR", + "rpcName": "RestoreBackup", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = BackupDRRestTransport._RestoreBackup._get_response( self._host, @@ -3438,7 +4700,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_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.backupdr_v1.BackupDRClient.restore_backup", + extra={ + "serviceName": "google.cloud.backupdr.v1.BackupDR", + "rpcName": "RestoreBackup", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _TriggerBackup( @@ -3476,7 +4760,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Call the trigger backup method over HTTP. @@ -3487,8 +4771,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.operations_pb2.Operation: @@ -3501,6 +4787,7 @@ def __call__( http_options = ( _BaseBackupDRRestTransport._BaseTriggerBackup._get_http_options() ) + request, metadata = self._interceptor.pre_trigger_backup(request, metadata) transcoded_request = ( _BaseBackupDRRestTransport._BaseTriggerBackup._get_transcoded_request( @@ -3519,6 +4806,33 @@ def __call__( ) ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.backupdr_v1.BackupDRClient.TriggerBackup", + extra={ + "serviceName": "google.cloud.backupdr.v1.BackupDR", + "rpcName": "TriggerBackup", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = BackupDRRestTransport._TriggerBackup._get_response( self._host, @@ -3538,7 +4852,29 @@ def __call__( # Return the response resp = operations_pb2.Operation() json_format.Parse(response.content, resp, ignore_unknown_fields=True) + resp = self._interceptor.post_trigger_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.backupdr_v1.BackupDRClient.trigger_backup", + extra={ + "serviceName": "google.cloud.backupdr.v1.BackupDR", + "rpcName": "TriggerBackup", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _UpdateBackup(_BaseBackupDRRestTransport._BaseUpdateBackup, BackupDRRestStub): @@ -3574,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]]] = (), ) -> operations_pb2.Operation: r"""Call the update backup method over HTTP. @@ -3585,8 +4921,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.operations_pb2.Operation: @@ -3599,6 +4937,7 @@ def __call__( http_options = ( _BaseBackupDRRestTransport._BaseUpdateBackup._get_http_options() ) + request, metadata = self._interceptor.pre_update_backup(request, metadata) transcoded_request = ( _BaseBackupDRRestTransport._BaseUpdateBackup._get_transcoded_request( @@ -3617,6 +4956,33 @@ def __call__( ) ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.backupdr_v1.BackupDRClient.UpdateBackup", + extra={ + "serviceName": "google.cloud.backupdr.v1.BackupDR", + "rpcName": "UpdateBackup", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = BackupDRRestTransport._UpdateBackup._get_response( self._host, @@ -3636,7 +5002,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.backupdr_v1.BackupDRClient.update_backup", + extra={ + "serviceName": "google.cloud.backupdr.v1.BackupDR", + "rpcName": "UpdateBackup", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _UpdateBackupVault( @@ -3674,7 +5062,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.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 vault method over HTTP. @@ -3685,8 +5073,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.operations_pb2.Operation: @@ -3699,6 +5089,7 @@ def __call__( http_options = ( _BaseBackupDRRestTransport._BaseUpdateBackupVault._get_http_options() ) + request, metadata = self._interceptor.pre_update_backup_vault( request, metadata ) @@ -3715,6 +5106,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.backupdr_v1.BackupDRClient.UpdateBackupVault", + extra={ + "serviceName": "google.cloud.backupdr.v1.BackupDR", + "rpcName": "UpdateBackupVault", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = BackupDRRestTransport._UpdateBackupVault._get_response( self._host, @@ -3734,7 +5152,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_vault(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = json_format.MessageToJson(resp) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.backupdr_v1.BackupDRClient.update_backup_vault", + extra={ + "serviceName": "google.cloud.backupdr.v1.BackupDR", + "rpcName": "UpdateBackupVault", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _UpdateDataSource( @@ -3772,7 +5212,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.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 data source method over HTTP. @@ -3783,8 +5223,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.operations_pb2.Operation: @@ -3797,6 +5239,7 @@ def __call__( http_options = ( _BaseBackupDRRestTransport._BaseUpdateDataSource._get_http_options() ) + request, metadata = self._interceptor.pre_update_data_source( request, metadata ) @@ -3817,6 +5260,33 @@ def __call__( ) ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.backupdr_v1.BackupDRClient.UpdateDataSource", + extra={ + "serviceName": "google.cloud.backupdr.v1.BackupDR", + "rpcName": "UpdateDataSource", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = BackupDRRestTransport._UpdateDataSource._get_response( self._host, @@ -3836,7 +5306,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_data_source(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = json_format.MessageToJson(resp) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.backupdr_v1.BackupDRClient.update_data_source", + extra={ + "serviceName": "google.cloud.backupdr.v1.BackupDR", + "rpcName": "UpdateDataSource", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp @property @@ -4116,7 +5608,7 @@ 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. @@ -4126,8 +5618,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each 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. @@ -4136,6 +5630,7 @@ def __call__( http_options = ( _BaseBackupDRRestTransport._BaseGetLocation._get_http_options() ) + request, metadata = self._interceptor.pre_get_location(request, metadata) transcoded_request = ( _BaseBackupDRRestTransport._BaseGetLocation._get_transcoded_request( @@ -4150,6 +5645,33 @@ def __call__( ) ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.backupdr_v1.BackupDRClient.GetLocation", + extra={ + "serviceName": "google.cloud.backupdr.v1.BackupDR", + "rpcName": "GetLocation", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = BackupDRRestTransport._GetLocation._get_response( self._host, @@ -4169,6 +5691,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.backupdr_v1.BackupDRAsyncClient.GetLocation", + extra={ + "serviceName": "google.cloud.backupdr.v1.BackupDR", + "rpcName": "GetLocation", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property @@ -4209,7 +5752,7 @@ 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. @@ -4219,8 +5762,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each 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. @@ -4229,6 +5774,7 @@ def __call__( http_options = ( _BaseBackupDRRestTransport._BaseListLocations._get_http_options() ) + request, metadata = self._interceptor.pre_list_locations(request, metadata) transcoded_request = ( _BaseBackupDRRestTransport._BaseListLocations._get_transcoded_request( @@ -4243,6 +5789,33 @@ def __call__( ) ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.backupdr_v1.BackupDRClient.ListLocations", + extra={ + "serviceName": "google.cloud.backupdr.v1.BackupDR", + "rpcName": "ListLocations", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = BackupDRRestTransport._ListLocations._get_response( self._host, @@ -4262,6 +5835,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.backupdr_v1.BackupDRAsyncClient.ListLocations", + extra={ + "serviceName": "google.cloud.backupdr.v1.BackupDR", + "rpcName": "ListLocations", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property @@ -4300,7 +5894,7 @@ 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. @@ -4310,8 +5904,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each 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. @@ -4320,6 +5916,7 @@ def __call__( http_options = ( _BaseBackupDRRestTransport._BaseGetIamPolicy._get_http_options() ) + request, metadata = self._interceptor.pre_get_iam_policy(request, metadata) transcoded_request = ( _BaseBackupDRRestTransport._BaseGetIamPolicy._get_transcoded_request( @@ -4334,6 +5931,33 @@ def __call__( ) ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.backupdr_v1.BackupDRClient.GetIamPolicy", + extra={ + "serviceName": "google.cloud.backupdr.v1.BackupDR", + "rpcName": "GetIamPolicy", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = BackupDRRestTransport._GetIamPolicy._get_response( self._host, @@ -4353,6 +5977,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.backupdr_v1.BackupDRAsyncClient.GetIamPolicy", + extra={ + "serviceName": "google.cloud.backupdr.v1.BackupDR", + "rpcName": "GetIamPolicy", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property @@ -4392,7 +6037,7 @@ 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. @@ -4402,8 +6047,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each 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. @@ -4412,6 +6059,7 @@ def __call__( http_options = ( _BaseBackupDRRestTransport._BaseSetIamPolicy._get_http_options() ) + request, metadata = self._interceptor.pre_set_iam_policy(request, metadata) transcoded_request = ( _BaseBackupDRRestTransport._BaseSetIamPolicy._get_transcoded_request( @@ -4430,6 +6078,33 @@ def __call__( ) ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.backupdr_v1.BackupDRClient.SetIamPolicy", + extra={ + "serviceName": "google.cloud.backupdr.v1.BackupDR", + "rpcName": "SetIamPolicy", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = BackupDRRestTransport._SetIamPolicy._get_response( self._host, @@ -4450,6 +6125,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.backupdr_v1.BackupDRAsyncClient.SetIamPolicy", + extra={ + "serviceName": "google.cloud.backupdr.v1.BackupDR", + "rpcName": "SetIamPolicy", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property @@ -4491,7 +6187,7 @@ 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. @@ -4501,8 +6197,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each 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. @@ -4511,6 +6209,7 @@ def __call__( http_options = ( _BaseBackupDRRestTransport._BaseTestIamPermissions._get_http_options() ) + request, metadata = self._interceptor.pre_test_iam_permissions( request, metadata ) @@ -4527,6 +6226,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.backupdr_v1.BackupDRClient.TestIamPermissions", + extra={ + "serviceName": "google.cloud.backupdr.v1.BackupDR", + "rpcName": "TestIamPermissions", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = BackupDRRestTransport._TestIamPermissions._get_response( self._host, @@ -4547,6 +6273,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.backupdr_v1.BackupDRAsyncClient.TestIamPermissions", + extra={ + "serviceName": "google.cloud.backupdr.v1.BackupDR", + "rpcName": "TestIamPermissions", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property @@ -4588,7 +6335,7 @@ 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. @@ -4598,13 +6345,16 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. """ http_options = ( _BaseBackupDRRestTransport._BaseCancelOperation._get_http_options() ) + request, metadata = self._interceptor.pre_cancel_operation( request, metadata ) @@ -4627,6 +6377,33 @@ def __call__( ) ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.backupdr_v1.BackupDRClient.CancelOperation", + extra={ + "serviceName": "google.cloud.backupdr.v1.BackupDR", + "rpcName": "CancelOperation", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = BackupDRRestTransport._CancelOperation._get_response( self._host, @@ -4683,7 +6460,7 @@ 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. @@ -4693,13 +6470,16 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. """ http_options = ( _BaseBackupDRRestTransport._BaseDeleteOperation._get_http_options() ) + request, metadata = self._interceptor.pre_delete_operation( request, metadata ) @@ -4716,6 +6496,33 @@ def __call__( ) ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.backupdr_v1.BackupDRClient.DeleteOperation", + extra={ + "serviceName": "google.cloud.backupdr.v1.BackupDR", + "rpcName": "DeleteOperation", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = BackupDRRestTransport._DeleteOperation._get_response( self._host, @@ -4769,7 +6576,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.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. @@ -4779,8 +6586,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be 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. @@ -4789,6 +6598,7 @@ def __call__( http_options = ( _BaseBackupDRRestTransport._BaseGetOperation._get_http_options() ) + request, metadata = self._interceptor.pre_get_operation(request, metadata) transcoded_request = ( _BaseBackupDRRestTransport._BaseGetOperation._get_transcoded_request( @@ -4803,6 +6613,33 @@ def __call__( ) ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.backupdr_v1.BackupDRClient.GetOperation", + extra={ + "serviceName": "google.cloud.backupdr.v1.BackupDR", + "rpcName": "GetOperation", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = BackupDRRestTransport._GetOperation._get_response( self._host, @@ -4822,6 +6659,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.backupdr_v1.BackupDRAsyncClient.GetOperation", + extra={ + "serviceName": "google.cloud.backupdr.v1.BackupDR", + "rpcName": "GetOperation", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property @@ -4862,7 +6720,7 @@ def __call__( *, 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. @@ -4872,8 +6730,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of 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. @@ -4882,6 +6742,7 @@ def __call__( http_options = ( _BaseBackupDRRestTransport._BaseListOperations._get_http_options() ) + request, metadata = self._interceptor.pre_list_operations(request, metadata) transcoded_request = ( _BaseBackupDRRestTransport._BaseListOperations._get_transcoded_request( @@ -4896,6 +6757,33 @@ def __call__( ) ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.backupdr_v1.BackupDRClient.ListOperations", + extra={ + "serviceName": "google.cloud.backupdr.v1.BackupDR", + "rpcName": "ListOperations", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = BackupDRRestTransport._ListOperations._get_response( self._host, @@ -4915,6 +6803,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.backupdr_v1.BackupDRAsyncClient.ListOperations", + extra={ + "serviceName": "google.cloud.backupdr.v1.BackupDR", + "rpcName": "ListOperations", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property diff --git a/packages/google-cloud-backupdr/samples/generated_samples/snippet_metadata_google.cloud.backupdr.v1.json b/packages/google-cloud-backupdr/samples/generated_samples/snippet_metadata_google.cloud.backupdr.v1.json index 4164339aa8cf..6faf9c3034f0 100644 --- a/packages/google-cloud-backupdr/samples/generated_samples/snippet_metadata_google.cloud.backupdr.v1.json +++ b/packages/google-cloud-backupdr/samples/generated_samples/snippet_metadata_google.cloud.backupdr.v1.json @@ -8,7 +8,7 @@ ], "language": "PYTHON", "name": "google-cloud-backupdr", - "version": "0.1.6" + "version": "0.1.0" }, "snippets": [ { @@ -55,7 +55,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -143,7 +143,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -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.api_core.operation_async.AsyncOperation", @@ -1479,7 +1479,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -1560,7 +1560,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.backupdr_v1.services.backup_dr.pagers.FetchUsableBackupVaultsAsyncPager", @@ -1640,7 +1640,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.backupdr_v1.services.backup_dr.pagers.FetchUsableBackupVaultsPager", @@ -1721,7 +1721,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.backupdr_v1.types.BackupPlanAssociation", @@ -1801,7 +1801,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.backupdr_v1.types.BackupPlanAssociation", @@ -1882,7 +1882,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.backupdr_v1.types.BackupPlan", @@ -1962,7 +1962,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.backupdr_v1.types.BackupPlan", @@ -2043,7 +2043,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.backupdr_v1.types.BackupVault", @@ -2123,7 +2123,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.backupdr_v1.types.BackupVault", @@ -2204,7 +2204,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.backupdr_v1.types.Backup", @@ -2284,7 +2284,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.backupdr_v1.types.Backup", @@ -2365,7 +2365,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.backupdr_v1.types.DataSource", @@ -2445,7 +2445,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.backupdr_v1.types.DataSource", @@ -2526,7 +2526,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.backupdr_v1.types.ManagementServer", @@ -2606,7 +2606,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.backupdr_v1.types.ManagementServer", @@ -2687,7 +2687,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.backupdr_v1.services.backup_dr.pagers.ListBackupPlanAssociationsAsyncPager", @@ -2767,7 +2767,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.backupdr_v1.services.backup_dr.pagers.ListBackupPlanAssociationsPager", @@ -2848,7 +2848,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.backupdr_v1.services.backup_dr.pagers.ListBackupPlansAsyncPager", @@ -2928,7 +2928,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.backupdr_v1.services.backup_dr.pagers.ListBackupPlansPager", @@ -3009,7 +3009,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.backupdr_v1.services.backup_dr.pagers.ListBackupVaultsAsyncPager", @@ -3089,7 +3089,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.backupdr_v1.services.backup_dr.pagers.ListBackupVaultsPager", @@ -3170,7 +3170,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.backupdr_v1.services.backup_dr.pagers.ListBackupsAsyncPager", @@ -3250,7 +3250,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.backupdr_v1.services.backup_dr.pagers.ListBackupsPager", @@ -3331,7 +3331,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.backupdr_v1.services.backup_dr.pagers.ListDataSourcesAsyncPager", @@ -3411,7 +3411,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.backupdr_v1.services.backup_dr.pagers.ListDataSourcesPager", @@ -3492,7 +3492,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.backupdr_v1.services.backup_dr.pagers.ListManagementServersAsyncPager", @@ -3572,7 +3572,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.backupdr_v1.services.backup_dr.pagers.ListManagementServersPager", @@ -3653,7 +3653,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -3733,7 +3733,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -3818,7 +3818,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -3902,7 +3902,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -3987,7 +3987,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -4071,7 +4071,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -4156,7 +4156,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -4240,7 +4240,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -4325,7 +4325,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -4409,7 +4409,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-backupdr/tests/unit/gapic/backupdr_v1/test_backup_dr.py b/packages/google-cloud-backupdr/tests/unit/gapic/backupdr_v1/test_backup_dr.py index 2a0ff4a24856..80493a625975 100644 --- a/packages/google-cloud-backupdr/tests/unit/gapic/backupdr_v1/test_backup_dr.py +++ b/packages/google-cloud-backupdr/tests/unit/gapic/backupdr_v1/test_backup_dr.py @@ -12027,6 +12027,7 @@ def test_list_management_servers_rest_required_fields( response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.list_management_servers(request) @@ -12082,6 +12083,7 @@ def test_list_management_servers_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.list_management_servers(**mock_args) @@ -12281,6 +12283,7 @@ def test_get_management_server_rest_required_fields( response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.get_management_server(request) @@ -12328,6 +12331,7 @@ def test_get_management_server_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.get_management_server(**mock_args) @@ -12482,6 +12486,7 @@ def test_create_management_server_rest_required_fields( response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.create_management_server(request) @@ -12547,6 +12552,7 @@ def test_create_management_server_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.create_management_server(**mock_args) @@ -12688,6 +12694,7 @@ def test_delete_management_server_rest_required_fields( response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.delete_management_server(request) @@ -12733,6 +12740,7 @@ def test_delete_management_server_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.delete_management_server(**mock_args) @@ -12885,6 +12893,7 @@ def test_create_backup_vault_rest_required_fields( response_value._content = json_return_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_vault(request) @@ -12951,6 +12960,7 @@ def test_create_backup_vault_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = json_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_vault(**mock_args) @@ -13098,6 +13108,7 @@ def test_list_backup_vaults_rest_required_fields( response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.list_backup_vaults(request) @@ -13154,6 +13165,7 @@ def test_list_backup_vaults_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.list_backup_vaults(**mock_args) @@ -13362,6 +13374,7 @@ def test_fetch_usable_backup_vaults_rest_required_fields( response_value._content = json_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_usable_backup_vaults(request) @@ -13417,6 +13430,7 @@ def test_fetch_usable_backup_vaults_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = 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_usable_backup_vaults(**mock_args) @@ -13615,6 +13629,7 @@ def test_get_backup_vault_rest_required_fields( response_value._content = json_return_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_vault(request) @@ -13662,6 +13677,7 @@ def test_get_backup_vault_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = json_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_vault(**mock_args) @@ -13803,6 +13819,7 @@ def test_update_backup_vault_rest_required_fields( response_value._content = json_return_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_vault(request) @@ -13866,6 +13883,7 @@ def test_update_backup_vault_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = json_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_vault(**mock_args) @@ -14013,6 +14031,7 @@ def test_delete_backup_vault_rest_required_fields( response_value._content = json_return_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_vault(request) @@ -14069,6 +14088,7 @@ def test_delete_backup_vault_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = json_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_vault(**mock_args) @@ -14211,6 +14231,7 @@ def test_list_data_sources_rest_required_fields( response_value._content = json_return_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_sources(request) @@ -14268,6 +14289,7 @@ def test_list_data_sources_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.list_data_sources(**mock_args) @@ -14464,6 +14486,7 @@ def test_get_data_source_rest_required_fields( response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.get_data_source(request) @@ -14511,6 +14534,7 @@ def test_get_data_source_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.get_data_source(**mock_args) @@ -14651,6 +14675,7 @@ def test_update_data_source_rest_required_fields( response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.update_data_source(request) @@ -14713,6 +14738,7 @@ def test_update_data_source_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.update_data_source(**mock_args) @@ -14853,6 +14879,7 @@ def test_list_backups_rest_required_fields(request_type=backupvault.ListBackupsR response_value._content = json_return_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) @@ -14911,6 +14938,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) @@ -15105,6 +15133,7 @@ def test_get_backup_rest_required_fields(request_type=backupvault.GetBackupReque response_value._content = json_return_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) @@ -15152,6 +15181,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) @@ -15287,6 +15317,7 @@ def test_update_backup_rest_required_fields( response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.update_backup(request) @@ -15348,6 +15379,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) @@ -15483,6 +15515,7 @@ def test_delete_backup_rest_required_fields( response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.delete_backup(request) @@ -15528,6 +15561,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) @@ -15661,6 +15695,7 @@ def test_restore_backup_rest_required_fields( response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.restore_backup(request) @@ -15706,6 +15741,7 @@ def test_restore_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.restore_backup(**mock_args) @@ -15857,6 +15893,7 @@ def test_create_backup_plan_rest_required_fields( response_value._content = json_return_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_plan(request) @@ -15922,6 +15959,7 @@ def test_create_backup_plan_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = json_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_plan(**mock_args) @@ -16055,6 +16093,7 @@ def test_get_backup_plan_rest_required_fields( response_value._content = json_return_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_plan(request) @@ -16102,6 +16141,7 @@ def test_get_backup_plan_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = json_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_plan(**mock_args) @@ -16244,6 +16284,7 @@ def test_list_backup_plans_rest_required_fields( response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.list_backup_plans(request) @@ -16299,6 +16340,7 @@ def test_list_backup_plans_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.list_backup_plans(**mock_args) @@ -16500,6 +16542,7 @@ def test_delete_backup_plan_rest_required_fields( response_value._content = json_return_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_plan(request) @@ -16545,6 +16588,7 @@ def test_delete_backup_plan_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = json_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_plan(**mock_args) @@ -16703,6 +16747,7 @@ def test_create_backup_plan_association_rest_required_fields( response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.create_backup_plan_association(request) @@ -16772,6 +16817,7 @@ def test_create_backup_plan_association_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.create_backup_plan_association(**mock_args) @@ -16912,6 +16958,7 @@ def test_get_backup_plan_association_rest_required_fields( response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.get_backup_plan_association(request) @@ -16959,6 +17006,7 @@ def test_get_backup_plan_association_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.get_backup_plan_association(**mock_args) @@ -17105,6 +17153,7 @@ def test_list_backup_plan_associations_rest_required_fields( response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.list_backup_plan_associations(request) @@ -17163,6 +17212,7 @@ def test_list_backup_plan_associations_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.list_backup_plan_associations(**mock_args) @@ -17368,6 +17418,7 @@ def test_delete_backup_plan_association_rest_required_fields( response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.delete_backup_plan_association(request) @@ -17415,6 +17466,7 @@ def test_delete_backup_plan_association_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.delete_backup_plan_association(**mock_args) @@ -17552,6 +17604,7 @@ def test_trigger_backup_rest_required_fields( response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.trigger_backup(request) @@ -17606,6 +17659,7 @@ def test_trigger_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.trigger_backup(**mock_args) @@ -19168,6 +19222,7 @@ def test_list_management_servers_rest_bad_request( response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.list_management_servers(request) @@ -19204,6 +19259,7 @@ def test_list_management_servers_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.list_management_servers(request) # Establish that the response is the type that we expect. @@ -19243,6 +19299,7 @@ def test_list_management_servers_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = backupdr.ListManagementServersResponse.to_json( backupdr.ListManagementServersResponse() ) @@ -19291,6 +19348,7 @@ def test_get_management_server_rest_bad_request( response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.get_management_server(request) @@ -19335,6 +19393,7 @@ def test_get_management_server_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.get_management_server(request) # Establish that the response is the type that we expect. @@ -19380,6 +19439,7 @@ def test_get_management_server_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = backupdr.ManagementServer.to_json(backupdr.ManagementServer()) req.return_value.content = return_value @@ -19424,6 +19484,7 @@ def test_create_management_server_rest_bad_request( response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.create_management_server(request) @@ -19545,6 +19606,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.create_management_server(request) # Establish that the response is the type that we expect. @@ -19584,6 +19646,7 @@ def test_create_management_server_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = json_format.MessageToJson(operations_pb2.Operation()) req.return_value.content = return_value @@ -19630,6 +19693,7 @@ def test_delete_management_server_rest_bad_request( response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.delete_management_server(request) @@ -19662,6 +19726,7 @@ def test_delete_management_server_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.delete_management_server(request) # Establish that the response is the type that we expect. @@ -19701,6 +19766,7 @@ def test_delete_management_server_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = json_format.MessageToJson(operations_pb2.Operation()) req.return_value.content = return_value @@ -19745,6 +19811,7 @@ def test_create_backup_vault_rest_bad_request( response_value.status_code = 400 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_vault(request) @@ -19860,6 +19927,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_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_vault(request) # Establish that the response is the type that we expect. @@ -19899,6 +19967,7 @@ def test_create_backup_vault_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = json_format.MessageToJson(operations_pb2.Operation()) req.return_value.content = return_value @@ -19943,6 +20012,7 @@ def test_list_backup_vaults_rest_bad_request( response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.list_backup_vaults(request) @@ -19979,6 +20049,7 @@ def test_list_backup_vaults_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.list_backup_vaults(request) # Establish that the response is the type that we expect. @@ -20018,6 +20089,7 @@ def test_list_backup_vaults_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = backupvault.ListBackupVaultsResponse.to_json( backupvault.ListBackupVaultsResponse() ) @@ -20064,6 +20136,7 @@ def test_fetch_usable_backup_vaults_rest_bad_request( response_value.status_code = 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_usable_backup_vaults(request) @@ -20100,6 +20173,7 @@ def test_fetch_usable_backup_vaults_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_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_usable_backup_vaults(request) # Establish that the response is the type that we expect. @@ -20139,6 +20213,7 @@ def test_fetch_usable_backup_vaults_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = backupvault.FetchUsableBackupVaultsResponse.to_json( backupvault.FetchUsableBackupVaultsResponse() ) @@ -20185,6 +20260,7 @@ def test_get_backup_vault_rest_bad_request( response_value.status_code = 400 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_vault(request) @@ -20229,6 +20305,7 @@ def test_get_backup_vault_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_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_vault(request) # Establish that the response is the type that we expect. @@ -20279,6 +20356,7 @@ def test_get_backup_vault_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = backupvault.BackupVault.to_json(backupvault.BackupVault()) req.return_value.content = return_value @@ -20327,6 +20405,7 @@ def test_update_backup_vault_rest_bad_request( response_value.status_code = 400 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_vault(request) @@ -20446,6 +20525,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_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_vault(request) # Establish that the response is the type that we expect. @@ -20485,6 +20565,7 @@ def test_update_backup_vault_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = json_format.MessageToJson(operations_pb2.Operation()) req.return_value.content = return_value @@ -20529,6 +20610,7 @@ def test_delete_backup_vault_rest_bad_request( response_value.status_code = 400 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_vault(request) @@ -20559,6 +20641,7 @@ def test_delete_backup_vault_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_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_vault(request) # Establish that the response is the type that we expect. @@ -20598,6 +20681,7 @@ def test_delete_backup_vault_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = json_format.MessageToJson(operations_pb2.Operation()) req.return_value.content = return_value @@ -20642,6 +20726,7 @@ def test_list_data_sources_rest_bad_request( response_value.status_code = 400 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_sources(request) @@ -20678,6 +20763,7 @@ def test_list_data_sources_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.list_data_sources(request) # Establish that the response is the type that we expect. @@ -20717,6 +20803,7 @@ def test_list_data_sources_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = backupvault.ListDataSourcesResponse.to_json( backupvault.ListDataSourcesResponse() ) @@ -20765,6 +20852,7 @@ def test_get_data_source_rest_bad_request( response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.get_data_source(request) @@ -20807,6 +20895,7 @@ def test_get_data_source_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.get_data_source(request) # Establish that the response is the type that we expect. @@ -20850,6 +20939,7 @@ def test_get_data_source_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = backupvault.DataSource.to_json(backupvault.DataSource()) req.return_value.content = return_value @@ -20898,6 +20988,7 @@ def test_update_data_source_rest_bad_request( response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.update_data_source(request) @@ -21063,6 +21154,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_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_source(request) # Establish that the response is the type that we expect. @@ -21102,6 +21194,7 @@ def test_update_data_source_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = json_format.MessageToJson(operations_pb2.Operation()) req.return_value.content = return_value @@ -21146,6 +21239,7 @@ def test_list_backups_rest_bad_request(request_type=backupvault.ListBackupsReque response_value.status_code = 400 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) @@ -21184,6 +21278,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. @@ -21221,6 +21316,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 = backupvault.ListBackupsResponse.to_json( backupvault.ListBackupsResponse() ) @@ -21267,6 +21363,7 @@ def test_get_backup_rest_bad_request(request_type=backupvault.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) @@ -21309,6 +21406,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. @@ -21350,6 +21448,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 = backupvault.Backup.to_json(backupvault.Backup()) req.return_value.content = return_value @@ -21396,6 +21495,7 @@ def test_update_backup_rest_bad_request(request_type=backupvault.UpdateBackupReq response_value.status_code = 400 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) @@ -21638,6 +21738,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_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. @@ -21677,6 +21778,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 @@ -21721,6 +21823,7 @@ def test_delete_backup_rest_bad_request(request_type=backupvault.DeleteBackupReq response_value.status_code = 400 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) @@ -21753,6 +21856,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. @@ -21792,6 +21896,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 @@ -21836,6 +21941,7 @@ def test_restore_backup_rest_bad_request(request_type=backupvault.RestoreBackupR response_value.status_code = 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_backup(request) @@ -21868,6 +21974,7 @@ def test_restore_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.restore_backup(request) # Establish that the response is the type that we expect. @@ -21907,6 +22014,7 @@ def test_restore_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 @@ -21951,6 +22059,7 @@ def test_create_backup_plan_rest_bad_request( response_value.status_code = 400 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_plan(request) @@ -22079,6 +22188,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_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_plan(request) # Establish that the response is the type that we expect. @@ -22118,6 +22228,7 @@ def test_create_backup_plan_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = json_format.MessageToJson(operations_pb2.Operation()) req.return_value.content = return_value @@ -22160,6 +22271,7 @@ def test_get_backup_plan_rest_bad_request(request_type=backupplan.GetBackupPlanR response_value.status_code = 400 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_plan(request) @@ -22201,6 +22313,7 @@ def test_get_backup_plan_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_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_plan(request) # Establish that the response is the type that we expect. @@ -22245,6 +22358,7 @@ def test_get_backup_plan_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = backupplan.BackupPlan.to_json(backupplan.BackupPlan()) req.return_value.content = return_value @@ -22289,6 +22403,7 @@ def test_list_backup_plans_rest_bad_request( response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.list_backup_plans(request) @@ -22325,6 +22440,7 @@ def test_list_backup_plans_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.list_backup_plans(request) # Establish that the response is the type that we expect. @@ -22364,6 +22480,7 @@ def test_list_backup_plans_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = backupplan.ListBackupPlansResponse.to_json( backupplan.ListBackupPlansResponse() ) @@ -22410,6 +22527,7 @@ def test_delete_backup_plan_rest_bad_request( response_value.status_code = 400 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_plan(request) @@ -22440,6 +22558,7 @@ def test_delete_backup_plan_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_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_plan(request) # Establish that the response is the type that we expect. @@ -22479,6 +22598,7 @@ def test_delete_backup_plan_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = json_format.MessageToJson(operations_pb2.Operation()) req.return_value.content = return_value @@ -22523,6 +22643,7 @@ def test_create_backup_plan_association_rest_bad_request( response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.create_backup_plan_association(request) @@ -22651,6 +22772,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_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_plan_association(request) # Establish that the response is the type that we expect. @@ -22690,6 +22812,7 @@ def test_create_backup_plan_association_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = json_format.MessageToJson(operations_pb2.Operation()) req.return_value.content = return_value @@ -22736,6 +22859,7 @@ def test_get_backup_plan_association_rest_bad_request( response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.get_backup_plan_association(request) @@ -22778,6 +22902,7 @@ def test_get_backup_plan_association_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.get_backup_plan_association(request) # Establish that the response is the type that we expect. @@ -22821,6 +22946,7 @@ def test_get_backup_plan_association_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = backupplanassociation.BackupPlanAssociation.to_json( backupplanassociation.BackupPlanAssociation() ) @@ -22867,6 +22993,7 @@ def test_list_backup_plan_associations_rest_bad_request( response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.list_backup_plan_associations(request) @@ -22905,6 +23032,7 @@ def test_list_backup_plan_associations_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.list_backup_plan_associations(request) # Establish that the response is the type that we expect. @@ -22944,6 +23072,7 @@ def test_list_backup_plan_associations_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = backupplanassociation.ListBackupPlanAssociationsResponse.to_json( backupplanassociation.ListBackupPlanAssociationsResponse() ) @@ -22992,6 +23121,7 @@ def test_delete_backup_plan_association_rest_bad_request( response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.delete_backup_plan_association(request) @@ -23024,6 +23154,7 @@ def test_delete_backup_plan_association_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.delete_backup_plan_association(request) # Establish that the response is the type that we expect. @@ -23063,6 +23194,7 @@ def test_delete_backup_plan_association_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = json_format.MessageToJson(operations_pb2.Operation()) req.return_value.content = return_value @@ -23109,6 +23241,7 @@ def test_trigger_backup_rest_bad_request( response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.trigger_backup(request) @@ -23141,6 +23274,7 @@ def test_trigger_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.trigger_backup(request) # Establish that the response is the type that we expect. @@ -23180,6 +23314,7 @@ def test_trigger_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 @@ -23224,6 +23359,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) @@ -23254,6 +23390,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) @@ -23282,6 +23419,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) @@ -23312,6 +23450,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) @@ -23343,6 +23482,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) @@ -23375,6 +23515,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) @@ -23406,6 +23547,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) @@ -23438,6 +23580,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) @@ -23469,6 +23612,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) @@ -23501,6 +23645,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) @@ -23531,6 +23676,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) @@ -23561,6 +23707,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) @@ -23591,6 +23738,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) @@ -23621,6 +23769,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) @@ -23651,6 +23800,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) @@ -23681,6 +23831,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) @@ -23711,6 +23862,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) @@ -23741,6 +23893,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-bare-metal-solution/google/cloud/bare_metal_solution/gapic_version.py b/packages/google-cloud-bare-metal-solution/google/cloud/bare_metal_solution/gapic_version.py index 02874f69f4e5..558c8aab67c5 100644 --- a/packages/google-cloud-bare-metal-solution/google/cloud/bare_metal_solution/gapic_version.py +++ b/packages/google-cloud-bare-metal-solution/google/cloud/bare_metal_solution/gapic_version.py @@ -13,4 +13,4 @@ # See the License for the specific language governing permissions and # limitations under the License. # -__version__ = "1.8.1" # {x-release-please-version} +__version__ = "0.0.0" # {x-release-please-version} diff --git a/packages/google-cloud-bare-metal-solution/google/cloud/bare_metal_solution_v2/gapic_version.py b/packages/google-cloud-bare-metal-solution/google/cloud/bare_metal_solution_v2/gapic_version.py index 02874f69f4e5..558c8aab67c5 100644 --- a/packages/google-cloud-bare-metal-solution/google/cloud/bare_metal_solution_v2/gapic_version.py +++ b/packages/google-cloud-bare-metal-solution/google/cloud/bare_metal_solution_v2/gapic_version.py @@ -13,4 +13,4 @@ # See the License for the specific language governing permissions and # limitations under the License. # -__version__ = "1.8.1" # {x-release-please-version} +__version__ = "0.0.0" # {x-release-please-version} diff --git a/packages/google-cloud-bare-metal-solution/google/cloud/bare_metal_solution_v2/services/bare_metal_solution/async_client.py b/packages/google-cloud-bare-metal-solution/google/cloud/bare_metal_solution_v2/services/bare_metal_solution/async_client.py index bd5e97f4610e..36b967234fe9 100644 --- a/packages/google-cloud-bare-metal-solution/google/cloud/bare_metal_solution_v2/services/bare_metal_solution/async_client.py +++ b/packages/google-cloud-bare-metal-solution/google/cloud/bare_metal_solution_v2/services/bare_metal_solution/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, @@ -75,6 +76,15 @@ from .transports.base import DEFAULT_CLIENT_INFO, BareMetalSolutionTransport from .transports.grpc_asyncio import BareMetalSolutionGrpcAsyncIOTransport +try: + from google.api_core import client_logging # type: ignore + + CLIENT_LOGGING_SUPPORTED = True # pragma: NO COVER +except ImportError: # pragma: NO COVER + CLIENT_LOGGING_SUPPORTED = False + +_LOGGER = std_logging.getLogger(__name__) + class BareMetalSolutionAsyncClient: """Performs management operations on Bare Metal Solution servers. @@ -349,6 +359,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.baremetalsolution_v2.BareMetalSolutionAsyncClient`.", + extra={ + "serviceName": "google.cloud.baremetalsolution.v2.BareMetalSolution", + "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.baremetalsolution.v2.BareMetalSolution", + "credentialsType": None, + }, + ) + async def list_instances( self, request: Optional[Union[instance.ListInstancesRequest, dict]] = None, @@ -356,7 +388,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"""List servers in a given project and location. @@ -401,8 +433,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.bare_metal_solution_v2.services.bare_metal_solution.pagers.ListInstancesAsyncPager: @@ -477,7 +511,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]]] = (), ) -> instance.Instance: r"""Get details about a single server. @@ -519,8 +553,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.bare_metal_solution_v2.types.Instance: @@ -580,7 +616,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"""Update details of a single server. @@ -638,8 +674,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: @@ -716,7 +754,7 @@ async def rename_instance( new_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]]] = (), ) -> instance.Instance: r"""RenameInstance sets a new name for an instance. Use with caution, previous names become immediately @@ -769,8 +807,10 @@ async def sample_rename_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.bare_metal_solution_v2.types.Instance: @@ -831,7 +871,7 @@ async def reset_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"""Perform an ungraceful, hard reset on a server. Equivalent to shutting the power off and then turning it @@ -878,8 +918,10 @@ async def sample_reset_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: @@ -951,7 +993,7 @@ async def start_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"""Starts a server that was shutdown. @@ -996,8 +1038,10 @@ async def sample_start_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: @@ -1069,7 +1113,7 @@ async def stop_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"""Stop a running server. @@ -1114,8 +1158,10 @@ async def sample_stop_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: @@ -1189,7 +1235,7 @@ async def enable_interactive_serial_console( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation_async.AsyncOperation: r"""Enable the interactive serial console feature on an instance. @@ -1236,8 +1282,10 @@ async def sample_enable_interactive_serial_console(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.api_core.operation_async.AsyncOperation: @@ -1311,7 +1359,7 @@ async def disable_interactive_serial_console( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation_async.AsyncOperation: r"""Disable the interactive serial console feature on an instance. @@ -1358,8 +1406,10 @@ async def sample_disable_interactive_serial_console(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.api_core.operation_async.AsyncOperation: @@ -1432,7 +1482,7 @@ async def detach_lun( lun: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation_async.AsyncOperation: r"""Detach LUN from Instance. @@ -1484,8 +1534,10 @@ async def sample_detach_lun(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.api_core.operation_async.AsyncOperation: @@ -1559,7 +1611,7 @@ async def list_ssh_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.ListSSHKeysAsyncPager: r"""Lists the public SSH keys registered for the specified project. These SSH keys are used only for the @@ -1607,8 +1659,10 @@ async def sample_list_ssh_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.bare_metal_solution_v2.services.bare_metal_solution.pagers.ListSSHKeysAsyncPager: @@ -1685,7 +1739,7 @@ async def create_ssh_key( ssh_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]]] = (), ) -> gcb_ssh_key.SSHKey: r"""Register a public SSH key in the specified project for use with the interactive serial console feature. @@ -1745,8 +1799,10 @@ async def sample_create_ssh_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.bare_metal_solution_v2.types.SSHKey: @@ -1811,7 +1867,7 @@ async def delete_ssh_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]]] = (), ) -> None: r"""Deletes a public SSH key registered in the specified project. @@ -1854,8 +1910,10 @@ async def sample_delete_ssh_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`. """ # Create or coerce a protobuf request object. # - Quick check: If we got a request object, we should *not* have @@ -1907,7 +1965,7 @@ async def list_volumes( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListVolumesAsyncPager: r"""List storage volumes in a given project and location. @@ -1952,8 +2010,10 @@ async def sample_list_volumes(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.bare_metal_solution_v2.services.bare_metal_solution.pagers.ListVolumesAsyncPager: @@ -2028,7 +2088,7 @@ async def get_volume( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> volume.Volume: r"""Get details of a single storage volume. @@ -2070,8 +2130,10 @@ async def sample_get_volume(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.bare_metal_solution_v2.types.Volume: @@ -2131,7 +2193,7 @@ async def update_volume( update_mask: Optional[field_mask_pb2.FieldMask] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation_async.AsyncOperation: r"""Update details of a single storage volume. @@ -2189,8 +2251,10 @@ async def sample_update_volume(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.api_core.operation_async.AsyncOperation: @@ -2267,7 +2331,7 @@ async def rename_volume( new_volume_id: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> volume.Volume: r"""RenameVolume sets a new name for a volume. Use with caution, previous names become immediately @@ -2320,8 +2384,10 @@ async def sample_rename_volume(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.bare_metal_solution_v2.types.Volume: @@ -2382,7 +2448,7 @@ async def evict_volume( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation_async.AsyncOperation: r"""Skips volume's cooloff and deletes it now. Volume must be in cooloff state. @@ -2429,8 +2495,10 @@ async def sample_evict_volume(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.api_core.operation_async.AsyncOperation: @@ -2510,7 +2578,7 @@ async def resize_volume( size_gib: Optional[int] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation_async.AsyncOperation: r"""Emergency Volume resize. @@ -2560,8 +2628,10 @@ async def sample_resize_volume(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.api_core.operation_async.AsyncOperation: @@ -2635,7 +2705,7 @@ async def list_networks( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListNetworksAsyncPager: r"""List network in a given project and location. @@ -2680,8 +2750,10 @@ async def sample_list_networks(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.bare_metal_solution_v2.services.bare_metal_solution.pagers.ListNetworksAsyncPager: @@ -2756,7 +2828,7 @@ async def list_network_usage( location: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> network.ListNetworkUsageResponse: r"""List all Networks (and used IPs for each Network) in the vendor account associated with the specified @@ -2801,8 +2873,10 @@ async def sample_list_network_usage(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.bare_metal_solution_v2.types.ListNetworkUsageResponse: @@ -2861,7 +2935,7 @@ async 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.Network: r"""Get details of a single network. @@ -2903,8 +2977,10 @@ async def sample_get_network(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.bare_metal_solution_v2.types.Network: @@ -2964,7 +3040,7 @@ async def update_network( update_mask: Optional[field_mask_pb2.FieldMask] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation_async.AsyncOperation: r"""Update details of a single network. @@ -3022,8 +3098,10 @@ async def sample_update_network(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.api_core.operation_async.AsyncOperation: @@ -3102,7 +3180,7 @@ async def create_volume_snapshot( volume_snapshot: Optional[gcb_volume_snapshot.VolumeSnapshot] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> gcb_volume_snapshot.VolumeSnapshot: r"""Takes a snapshot of a boot volume. Returns INVALID_ARGUMENT if called for a non-boot volume. @@ -3150,8 +3228,10 @@ async def sample_create_volume_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.cloud.bare_metal_solution_v2.types.VolumeSnapshot: @@ -3216,7 +3296,7 @@ async def restore_volume_snapshot( volume_snapshot: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation_async.AsyncOperation: r"""Uses the specified snapshot to restore its parent volume. Returns INVALID_ARGUMENT if called for a non-boot volume. @@ -3266,8 +3346,10 @@ async def sample_restore_volume_snapshot(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.api_core.operation_async.AsyncOperation: @@ -3344,7 +3426,7 @@ async def delete_volume_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]]] = (), ) -> None: r"""Deletes a volume snapshot. Returns INVALID_ARGUMENT if called for a non-boot volume. @@ -3386,8 +3468,10 @@ async def sample_delete_volume_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`. """ # Create or coerce a protobuf request object. # - Quick check: If we got a request object, we should *not* have @@ -3439,7 +3523,7 @@ async def get_volume_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]]] = (), ) -> volume_snapshot.VolumeSnapshot: r"""Returns the specified snapshot resource. Returns INVALID_ARGUMENT if called for a non-boot volume. @@ -3482,8 +3566,10 @@ async def sample_get_volume_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.cloud.bare_metal_solution_v2.types.VolumeSnapshot: @@ -3546,7 +3632,7 @@ async def list_volume_snapshots( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListVolumeSnapshotsAsyncPager: r"""Retrieves the list of snapshots for the specified volume. Returns a response with an empty list of @@ -3593,8 +3679,10 @@ async def sample_list_volume_snapshots(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.bare_metal_solution_v2.services.bare_metal_solution.pagers.ListVolumeSnapshotsAsyncPager: @@ -3669,7 +3757,7 @@ async def get_lun( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> lun.Lun: r"""Get details of a single storage logical unit number(LUN). @@ -3712,8 +3800,10 @@ async def sample_get_lun(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.bare_metal_solution_v2.types.Lun: @@ -3772,7 +3862,7 @@ async def list_luns( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListLunsAsyncPager: r"""List storage volume luns for given storage volume. @@ -3817,8 +3907,10 @@ async def sample_list_luns(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.bare_metal_solution_v2.services.bare_metal_solution.pagers.ListLunsAsyncPager: @@ -3893,7 +3985,7 @@ async def evict_lun( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation_async.AsyncOperation: r"""Skips lun's cooloff and deletes it now. Lun must be in cooloff state. @@ -3940,8 +4032,10 @@ async def sample_evict_lun(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.api_core.operation_async.AsyncOperation: @@ -4020,7 +4114,7 @@ async def get_nfs_share( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> nfs_share.NfsShare: r"""Get details of a single NFS share. @@ -4062,8 +4156,10 @@ async def sample_get_nfs_share(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.bare_metal_solution_v2.types.NfsShare: @@ -4122,7 +4218,7 @@ async def list_nfs_shares( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListNfsSharesAsyncPager: r"""List NFS shares. @@ -4167,8 +4263,10 @@ async def sample_list_nfs_shares(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.bare_metal_solution_v2.services.bare_metal_solution.pagers.ListNfsSharesAsyncPager: @@ -4244,7 +4342,7 @@ async def update_nfs_share( update_mask: Optional[field_mask_pb2.FieldMask] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation_async.AsyncOperation: r"""Update details of a single NFS share. @@ -4301,8 +4399,10 @@ async def sample_update_nfs_share(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.api_core.operation_async.AsyncOperation: @@ -4379,7 +4479,7 @@ async def create_nfs_share( nfs_share: Optional[gcb_nfs_share.NfsShare] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation_async.AsyncOperation: r"""Create an NFS share. @@ -4431,8 +4531,10 @@ async def sample_create_nfs_share(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.api_core.operation_async.AsyncOperation: @@ -4507,7 +4609,7 @@ async def rename_nfs_share( new_nfsshare_id: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> nfs_share.NfsShare: r"""RenameNfsShare sets a new name for an nfsshare. Use with caution, previous names become immediately @@ -4560,8 +4662,10 @@ async def sample_rename_nfs_share(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.bare_metal_solution_v2.types.NfsShare: @@ -4622,7 +4726,7 @@ async def delete_nfs_share( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation_async.AsyncOperation: r"""Delete an NFS share. The underlying volume is automatically deleted. @@ -4670,8 +4774,10 @@ async def sample_delete_nfs_share(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.api_core.operation_async.AsyncOperation: @@ -4752,7 +4858,7 @@ async def list_provisioning_quotas( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListProvisioningQuotasAsyncPager: r"""List the budget details to provision resources on a given project. @@ -4798,8 +4904,10 @@ async def sample_list_provisioning_quotas(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.bare_metal_solution_v2.services.bare_metal_solution.pagers.ListProvisioningQuotasAsyncPager: @@ -4877,7 +4985,7 @@ async def submit_provisioning_config( provisioning_config: Optional[provisioning.ProvisioningConfig] = None, retry: OptionalRetry = 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.SubmitProvisioningConfigResponse: r"""Submit a provisiong configuration for a given project. @@ -4929,8 +5037,10 @@ async def sample_submit_provisioning_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.bare_metal_solution_v2.types.SubmitProvisioningConfigResponse: @@ -4995,7 +5105,7 @@ async def get_provisioning_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]]] = (), ) -> provisioning.ProvisioningConfig: r"""Get ProvisioningConfig by name. @@ -5038,8 +5148,10 @@ async def sample_get_provisioning_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.bare_metal_solution_v2.types.ProvisioningConfig: @@ -5101,7 +5213,7 @@ async def create_provisioning_config( provisioning_config: Optional[provisioning.ProvisioningConfig] = None, retry: OptionalRetry = 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.ProvisioningConfig: r"""Create new ProvisioningConfig. @@ -5152,8 +5264,10 @@ async def sample_create_provisioning_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.bare_metal_solution_v2.types.ProvisioningConfig: @@ -5217,7 +5331,7 @@ async def update_provisioning_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]]] = (), ) -> provisioning.ProvisioningConfig: r"""Update existing ProvisioningConfig. @@ -5267,8 +5381,10 @@ async def sample_update_provisioning_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.bare_metal_solution_v2.types.ProvisioningConfig: @@ -5332,7 +5448,7 @@ async def rename_network( new_network_id: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> network.Network: r"""RenameNetwork sets a new name for a network. Use with caution, previous names become immediately @@ -5385,8 +5501,10 @@ async def sample_rename_network(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.bare_metal_solution_v2.types.Network: @@ -5447,7 +5565,7 @@ async def list_os_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.ListOSImagesAsyncPager: r"""Retrieves the list of OS images which are currently approved. @@ -5493,8 +5611,10 @@ async def sample_list_os_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.bare_metal_solution_v2.services.bare_metal_solution.pagers.ListOSImagesAsyncPager: @@ -5568,7 +5688,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. @@ -5579,8 +5699,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. @@ -5621,7 +5743,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. @@ -5632,8 +5754,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-bare-metal-solution/google/cloud/bare_metal_solution_v2/services/bare_metal_solution/client.py b/packages/google-cloud-bare-metal-solution/google/cloud/bare_metal_solution_v2/services/bare_metal_solution/client.py index 60f10dbb0d74..8c0b957907e4 100644 --- a/packages/google-cloud-bare-metal-solution/google/cloud/bare_metal_solution_v2/services/bare_metal_solution/client.py +++ b/packages/google-cloud-bare-metal-solution/google/cloud/bare_metal_solution_v2/services/bare_metal_solution/client.py @@ -14,6 +14,7 @@ # limitations under the License. # from collections import OrderedDict +import logging as std_logging import os import re from typing import ( @@ -48,6 +49,15 @@ except AttributeError: # pragma: NO COVER OptionalRetry = Union[retries.Retry, object, None] # type: ignore +try: + from google.api_core import client_logging # type: ignore + + CLIENT_LOGGING_SUPPORTED = True # pragma: NO COVER +except ImportError: # pragma: NO COVER + CLIENT_LOGGING_SUPPORTED = False + +_LOGGER = std_logging.getLogger(__name__) + from google.api_core import operation # type: ignore from google.api_core import operation_async # type: ignore from google.cloud.location import locations_pb2 # type: ignore @@ -951,6 +961,10 @@ def __init__( # Initialize the universe domain validation. self._is_universe_domain_valid = False + if CLIENT_LOGGING_SUPPORTED: # pragma: NO COVER + # Setup logging. + client_logging.initialize_logging() + api_key_value = getattr(self._client_options, "api_key", None) if api_key_value and credentials: raise ValueError( @@ -1017,6 +1031,29 @@ def __init__( api_audience=self._client_options.api_audience, ) + if "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.baremetalsolution_v2.BareMetalSolutionClient`.", + extra={ + "serviceName": "google.cloud.baremetalsolution.v2.BareMetalSolution", + "universeDomain": getattr( + self._transport._credentials, "universe_domain", "" + ), + "credentialsType": f"{type(self._transport._credentials).__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.baremetalsolution.v2.BareMetalSolution", + "credentialsType": None, + }, + ) + def list_instances( self, request: Optional[Union[instance.ListInstancesRequest, dict]] = None, @@ -1024,7 +1061,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"""List servers in a given project and location. @@ -1069,8 +1106,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.bare_metal_solution_v2.services.bare_metal_solution.pagers.ListInstancesPager: @@ -1142,7 +1181,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]]] = (), ) -> instance.Instance: r"""Get details about a single server. @@ -1184,8 +1223,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.bare_metal_solution_v2.types.Instance: @@ -1242,7 +1283,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"""Update details of a single server. @@ -1300,8 +1341,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: @@ -1375,7 +1418,7 @@ def rename_instance( new_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]]] = (), ) -> instance.Instance: r"""RenameInstance sets a new name for an instance. Use with caution, previous names become immediately @@ -1428,8 +1471,10 @@ def sample_rename_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.bare_metal_solution_v2.types.Instance: @@ -1487,7 +1532,7 @@ def reset_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"""Perform an ungraceful, hard reset on a server. Equivalent to shutting the power off and then turning it @@ -1534,8 +1579,10 @@ def sample_reset_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: @@ -1604,7 +1651,7 @@ def start_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"""Starts a server that was shutdown. @@ -1649,8 +1696,10 @@ def sample_start_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: @@ -1719,7 +1768,7 @@ def stop_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"""Stop a running server. @@ -1764,8 +1813,10 @@ def sample_stop_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: @@ -1836,7 +1887,7 @@ def enable_interactive_serial_console( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation.Operation: r"""Enable the interactive serial console feature on an instance. @@ -1883,8 +1934,10 @@ def sample_enable_interactive_serial_console(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.api_core.operation.Operation: @@ -1957,7 +2010,7 @@ def disable_interactive_serial_console( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation.Operation: r"""Disable the interactive serial console feature on an instance. @@ -2004,8 +2057,10 @@ def sample_disable_interactive_serial_console(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.api_core.operation.Operation: @@ -2077,7 +2132,7 @@ def detach_lun( lun: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation.Operation: r"""Detach LUN from Instance. @@ -2129,8 +2184,10 @@ def sample_detach_lun(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.api_core.operation.Operation: @@ -2201,7 +2258,7 @@ def list_ssh_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.ListSSHKeysPager: r"""Lists the public SSH keys registered for the specified project. These SSH keys are used only for the @@ -2249,8 +2306,10 @@ def sample_list_ssh_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.bare_metal_solution_v2.services.bare_metal_solution.pagers.ListSSHKeysPager: @@ -2324,7 +2383,7 @@ def create_ssh_key( ssh_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]]] = (), ) -> gcb_ssh_key.SSHKey: r"""Register a public SSH key in the specified project for use with the interactive serial console feature. @@ -2384,8 +2443,10 @@ def sample_create_ssh_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.bare_metal_solution_v2.types.SSHKey: @@ -2447,7 +2508,7 @@ def delete_ssh_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]]] = (), ) -> None: r"""Deletes a public SSH key registered in the specified project. @@ -2490,8 +2551,10 @@ def sample_delete_ssh_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`. """ # Create or coerce a protobuf request object. # - Quick check: If we got a request object, we should *not* have @@ -2540,7 +2603,7 @@ def list_volumes( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListVolumesPager: r"""List storage volumes in a given project and location. @@ -2585,8 +2648,10 @@ def sample_list_volumes(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.bare_metal_solution_v2.services.bare_metal_solution.pagers.ListVolumesPager: @@ -2658,7 +2723,7 @@ def get_volume( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> volume.Volume: r"""Get details of a single storage volume. @@ -2700,8 +2765,10 @@ def sample_get_volume(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.bare_metal_solution_v2.types.Volume: @@ -2758,7 +2825,7 @@ def update_volume( update_mask: Optional[field_mask_pb2.FieldMask] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation.Operation: r"""Update details of a single storage volume. @@ -2816,8 +2883,10 @@ def sample_update_volume(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.api_core.operation.Operation: @@ -2891,7 +2960,7 @@ def rename_volume( new_volume_id: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> volume.Volume: r"""RenameVolume sets a new name for a volume. Use with caution, previous names become immediately @@ -2944,8 +3013,10 @@ def sample_rename_volume(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.bare_metal_solution_v2.types.Volume: @@ -3003,7 +3074,7 @@ def evict_volume( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation.Operation: r"""Skips volume's cooloff and deletes it now. Volume must be in cooloff state. @@ -3050,8 +3121,10 @@ def sample_evict_volume(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.api_core.operation.Operation: @@ -3128,7 +3201,7 @@ def resize_volume( size_gib: Optional[int] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation.Operation: r"""Emergency Volume resize. @@ -3178,8 +3251,10 @@ def sample_resize_volume(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.api_core.operation.Operation: @@ -3250,7 +3325,7 @@ def list_networks( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListNetworksPager: r"""List network in a given project and location. @@ -3295,8 +3370,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.cloud.bare_metal_solution_v2.services.bare_metal_solution.pagers.ListNetworksPager: @@ -3368,7 +3445,7 @@ def list_network_usage( location: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> network.ListNetworkUsageResponse: r"""List all Networks (and used IPs for each Network) in the vendor account associated with the specified @@ -3413,8 +3490,10 @@ def sample_list_network_usage(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.bare_metal_solution_v2.types.ListNetworkUsageResponse: @@ -3470,7 +3549,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.Network: r"""Get details of a single network. @@ -3512,8 +3591,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.cloud.bare_metal_solution_v2.types.Network: @@ -3570,7 +3651,7 @@ def update_network( update_mask: Optional[field_mask_pb2.FieldMask] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation.Operation: r"""Update details of a single network. @@ -3628,8 +3709,10 @@ def sample_update_network(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.api_core.operation.Operation: @@ -3705,7 +3788,7 @@ def create_volume_snapshot( volume_snapshot: Optional[gcb_volume_snapshot.VolumeSnapshot] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> gcb_volume_snapshot.VolumeSnapshot: r"""Takes a snapshot of a boot volume. Returns INVALID_ARGUMENT if called for a non-boot volume. @@ -3753,8 +3836,10 @@ def sample_create_volume_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.cloud.bare_metal_solution_v2.types.VolumeSnapshot: @@ -3816,7 +3901,7 @@ def restore_volume_snapshot( volume_snapshot: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation.Operation: r"""Uses the specified snapshot to restore its parent volume. Returns INVALID_ARGUMENT if called for a non-boot volume. @@ -3866,8 +3951,10 @@ def sample_restore_volume_snapshot(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.api_core.operation.Operation: @@ -3941,7 +4028,7 @@ def delete_volume_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]]] = (), ) -> None: r"""Deletes a volume snapshot. Returns INVALID_ARGUMENT if called for a non-boot volume. @@ -3983,8 +4070,10 @@ def sample_delete_volume_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`. """ # Create or coerce a protobuf request object. # - Quick check: If we got a request object, we should *not* have @@ -4033,7 +4122,7 @@ def get_volume_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]]] = (), ) -> volume_snapshot.VolumeSnapshot: r"""Returns the specified snapshot resource. Returns INVALID_ARGUMENT if called for a non-boot volume. @@ -4076,8 +4165,10 @@ def sample_get_volume_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.cloud.bare_metal_solution_v2.types.VolumeSnapshot: @@ -4137,7 +4228,7 @@ def list_volume_snapshots( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListVolumeSnapshotsPager: r"""Retrieves the list of snapshots for the specified volume. Returns a response with an empty list of @@ -4184,8 +4275,10 @@ def sample_list_volume_snapshots(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.bare_metal_solution_v2.services.bare_metal_solution.pagers.ListVolumeSnapshotsPager: @@ -4257,7 +4350,7 @@ def get_lun( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> lun.Lun: r"""Get details of a single storage logical unit number(LUN). @@ -4300,8 +4393,10 @@ def sample_get_lun(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.bare_metal_solution_v2.types.Lun: @@ -4359,7 +4454,7 @@ def list_luns( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListLunsPager: r"""List storage volume luns for given storage volume. @@ -4404,8 +4499,10 @@ def sample_list_luns(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.bare_metal_solution_v2.services.bare_metal_solution.pagers.ListLunsPager: @@ -4477,7 +4574,7 @@ def evict_lun( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation.Operation: r"""Skips lun's cooloff and deletes it now. Lun must be in cooloff state. @@ -4524,8 +4621,10 @@ def sample_evict_lun(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.api_core.operation.Operation: @@ -4601,7 +4700,7 @@ def get_nfs_share( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> nfs_share.NfsShare: r"""Get details of a single NFS share. @@ -4643,8 +4742,10 @@ def sample_get_nfs_share(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.bare_metal_solution_v2.types.NfsShare: @@ -4700,7 +4801,7 @@ def list_nfs_shares( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListNfsSharesPager: r"""List NFS shares. @@ -4745,8 +4846,10 @@ def sample_list_nfs_shares(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.bare_metal_solution_v2.services.bare_metal_solution.pagers.ListNfsSharesPager: @@ -4819,7 +4922,7 @@ def update_nfs_share( update_mask: Optional[field_mask_pb2.FieldMask] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation.Operation: r"""Update details of a single NFS share. @@ -4876,8 +4979,10 @@ def sample_update_nfs_share(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.api_core.operation.Operation: @@ -4951,7 +5056,7 @@ def create_nfs_share( nfs_share: Optional[gcb_nfs_share.NfsShare] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation.Operation: r"""Create an NFS share. @@ -5003,8 +5108,10 @@ def sample_create_nfs_share(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.api_core.operation.Operation: @@ -5076,7 +5183,7 @@ def rename_nfs_share( new_nfsshare_id: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> nfs_share.NfsShare: r"""RenameNfsShare sets a new name for an nfsshare. Use with caution, previous names become immediately @@ -5129,8 +5236,10 @@ def sample_rename_nfs_share(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.bare_metal_solution_v2.types.NfsShare: @@ -5188,7 +5297,7 @@ def delete_nfs_share( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation.Operation: r"""Delete an NFS share. The underlying volume is automatically deleted. @@ -5236,8 +5345,10 @@ def sample_delete_nfs_share(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.api_core.operation.Operation: @@ -5315,7 +5426,7 @@ def list_provisioning_quotas( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListProvisioningQuotasPager: r"""List the budget details to provision resources on a given project. @@ -5361,8 +5472,10 @@ def sample_list_provisioning_quotas(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.bare_metal_solution_v2.services.bare_metal_solution.pagers.ListProvisioningQuotasPager: @@ -5437,7 +5550,7 @@ def submit_provisioning_config( provisioning_config: Optional[provisioning.ProvisioningConfig] = None, retry: OptionalRetry = 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.SubmitProvisioningConfigResponse: r"""Submit a provisiong configuration for a given project. @@ -5489,8 +5602,10 @@ def sample_submit_provisioning_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.bare_metal_solution_v2.types.SubmitProvisioningConfigResponse: @@ -5554,7 +5669,7 @@ def get_provisioning_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]]] = (), ) -> provisioning.ProvisioningConfig: r"""Get ProvisioningConfig by name. @@ -5597,8 +5712,10 @@ def sample_get_provisioning_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.bare_metal_solution_v2.types.ProvisioningConfig: @@ -5657,7 +5774,7 @@ def create_provisioning_config( provisioning_config: Optional[provisioning.ProvisioningConfig] = None, retry: OptionalRetry = 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.ProvisioningConfig: r"""Create new ProvisioningConfig. @@ -5708,8 +5825,10 @@ def sample_create_provisioning_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.bare_metal_solution_v2.types.ProvisioningConfig: @@ -5772,7 +5891,7 @@ def update_provisioning_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]]] = (), ) -> provisioning.ProvisioningConfig: r"""Update existing ProvisioningConfig. @@ -5822,8 +5941,10 @@ def sample_update_provisioning_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.bare_metal_solution_v2.types.ProvisioningConfig: @@ -5886,7 +6007,7 @@ def rename_network( new_network_id: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> network.Network: r"""RenameNetwork sets a new name for a network. Use with caution, previous names become immediately @@ -5939,8 +6060,10 @@ def sample_rename_network(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.bare_metal_solution_v2.types.Network: @@ -5998,7 +6121,7 @@ def list_os_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.ListOSImagesPager: r"""Retrieves the list of OS images which are currently approved. @@ -6044,8 +6167,10 @@ def sample_list_os_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.bare_metal_solution_v2.services.bare_metal_solution.pagers.ListOSImagesPager: @@ -6129,7 +6254,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. @@ -6140,8 +6265,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. @@ -6182,7 +6309,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. @@ -6193,8 +6320,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-bare-metal-solution/google/cloud/bare_metal_solution_v2/services/bare_metal_solution/pagers.py b/packages/google-cloud-bare-metal-solution/google/cloud/bare_metal_solution_v2/services/bare_metal_solution/pagers.py index 14f0892005d6..2ebdf0429a50 100644 --- a/packages/google-cloud-bare-metal-solution/google/cloud/bare_metal_solution_v2/services/bare_metal_solution/pagers.py +++ b/packages/google-cloud-bare-metal-solution/google/cloud/bare_metal_solution_v2/services/bare_metal_solution/pagers.py @@ -77,7 +77,7 @@ def __init__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiate the pager. @@ -91,8 +91,10 @@ def __init__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. """ self._method = method self._request = instance.ListInstancesRequest(request) @@ -151,7 +153,7 @@ def __init__( *, retry: OptionalAsyncRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiates the pager. @@ -165,8 +167,10 @@ def __init__( retry (google.api_core.retry.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. """ self._method = method self._request = instance.ListInstancesRequest(request) @@ -229,7 +233,7 @@ def __init__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiate the pager. @@ -243,8 +247,10 @@ def __init__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. """ self._method = method self._request = ssh_key.ListSSHKeysRequest(request) @@ -303,7 +309,7 @@ def __init__( *, retry: OptionalAsyncRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiates the pager. @@ -317,8 +323,10 @@ def __init__( retry (google.api_core.retry.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. """ self._method = method self._request = ssh_key.ListSSHKeysRequest(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 = volume.ListVolumesRequest(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 = volume.ListVolumesRequest(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 = network.ListNetworksRequest(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 = network.ListNetworksRequest(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 = volume_snapshot.ListVolumeSnapshotsRequest(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 = volume_snapshot.ListVolumeSnapshotsRequest(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 = lun.ListLunsRequest(request) @@ -911,7 +933,7 @@ def __init__( *, retry: OptionalAsyncRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiates the pager. @@ -925,8 +947,10 @@ def __init__( retry (google.api_core.retry.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. """ self._method = method self._request = lun.ListLunsRequest(request) @@ -989,7 +1013,7 @@ def __init__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiate the pager. @@ -1003,8 +1027,10 @@ def __init__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. """ self._method = method self._request = nfs_share.ListNfsSharesRequest(request) @@ -1063,7 +1089,7 @@ def __init__( *, retry: OptionalAsyncRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiates the pager. @@ -1077,8 +1103,10 @@ def __init__( retry (google.api_core.retry.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. """ self._method = method self._request = nfs_share.ListNfsSharesRequest(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 = provisioning.ListProvisioningQuotasRequest(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 = provisioning.ListProvisioningQuotasRequest(request) @@ -1293,7 +1325,7 @@ def __init__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiate the pager. @@ -1307,8 +1339,10 @@ def __init__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. """ self._method = method self._request = osimage.ListOSImagesRequest(request) @@ -1367,7 +1401,7 @@ def __init__( *, retry: OptionalAsyncRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiates the pager. @@ -1381,8 +1415,10 @@ def __init__( retry (google.api_core.retry.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. """ self._method = method self._request = osimage.ListOSImagesRequest(request) diff --git a/packages/google-cloud-bare-metal-solution/google/cloud/bare_metal_solution_v2/services/bare_metal_solution/transports/grpc.py b/packages/google-cloud-bare-metal-solution/google/cloud/bare_metal_solution_v2/services/bare_metal_solution/transports/grpc.py index 5a1bd83d8513..1d54a836a144 100644 --- a/packages/google-cloud-bare-metal-solution/google/cloud/bare_metal_solution_v2/services/bare_metal_solution/transports/grpc.py +++ b/packages/google-cloud-bare-metal-solution/google/cloud/bare_metal_solution_v2/services/bare_metal_solution/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.bare_metal_solution_v2.types import nfs_share as gcb_nfs_share from google.cloud.bare_metal_solution_v2.types import ( @@ -46,6 +52,81 @@ from .base import DEFAULT_CLIENT_INFO, BareMetalSolutionTransport +try: + from google.api_core import client_logging # 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.baremetalsolution.v2.BareMetalSolution", + "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.baremetalsolution.v2.BareMetalSolution", + "rpcName": client_call_details.method, + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class BareMetalSolutionGrpcTransport(BareMetalSolutionTransport): """gRPC backend transport for BareMetalSolution. @@ -208,7 +289,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 @@ -272,7 +358,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 @@ -296,7 +384,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.baremetalsolution.v2.BareMetalSolution/ListInstances", request_serializer=instance.ListInstancesRequest.serialize, response_deserializer=instance.ListInstancesResponse.deserialize, @@ -322,7 +410,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.baremetalsolution.v2.BareMetalSolution/GetInstance", request_serializer=instance.GetInstanceRequest.serialize, response_deserializer=instance.Instance.deserialize, @@ -348,7 +436,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.baremetalsolution.v2.BareMetalSolution/UpdateInstance", request_serializer=gcb_instance.UpdateInstanceRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -376,7 +464,7 @@ def rename_instance( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "rename_instance" not in self._stubs: - self._stubs["rename_instance"] = self.grpc_channel.unary_unary( + self._stubs["rename_instance"] = self._logged_channel.unary_unary( "/google.cloud.baremetalsolution.v2.BareMetalSolution/RenameInstance", request_serializer=instance.RenameInstanceRequest.serialize, response_deserializer=instance.Instance.deserialize, @@ -404,7 +492,7 @@ def reset_instance( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "reset_instance" not in self._stubs: - self._stubs["reset_instance"] = self.grpc_channel.unary_unary( + self._stubs["reset_instance"] = self._logged_channel.unary_unary( "/google.cloud.baremetalsolution.v2.BareMetalSolution/ResetInstance", request_serializer=instance.ResetInstanceRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -430,7 +518,7 @@ def start_instance( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "start_instance" not in self._stubs: - self._stubs["start_instance"] = self.grpc_channel.unary_unary( + self._stubs["start_instance"] = self._logged_channel.unary_unary( "/google.cloud.baremetalsolution.v2.BareMetalSolution/StartInstance", request_serializer=instance.StartInstanceRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -456,7 +544,7 @@ def stop_instance( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "stop_instance" not in self._stubs: - self._stubs["stop_instance"] = self.grpc_channel.unary_unary( + self._stubs["stop_instance"] = self._logged_channel.unary_unary( "/google.cloud.baremetalsolution.v2.BareMetalSolution/StopInstance", request_serializer=instance.StopInstanceRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -488,7 +576,7 @@ def enable_interactive_serial_console( if "enable_interactive_serial_console" not in self._stubs: self._stubs[ "enable_interactive_serial_console" - ] = self.grpc_channel.unary_unary( + ] = self._logged_channel.unary_unary( "/google.cloud.baremetalsolution.v2.BareMetalSolution/EnableInteractiveSerialConsole", request_serializer=instance.EnableInteractiveSerialConsoleRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -520,7 +608,7 @@ def disable_interactive_serial_console( if "disable_interactive_serial_console" not in self._stubs: self._stubs[ "disable_interactive_serial_console" - ] = self.grpc_channel.unary_unary( + ] = self._logged_channel.unary_unary( "/google.cloud.baremetalsolution.v2.BareMetalSolution/DisableInteractiveSerialConsole", request_serializer=instance.DisableInteractiveSerialConsoleRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -546,7 +634,7 @@ def detach_lun( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "detach_lun" not in self._stubs: - self._stubs["detach_lun"] = self.grpc_channel.unary_unary( + self._stubs["detach_lun"] = self._logged_channel.unary_unary( "/google.cloud.baremetalsolution.v2.BareMetalSolution/DetachLun", request_serializer=gcb_instance.DetachLunRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -574,7 +662,7 @@ def list_ssh_keys( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_ssh_keys" not in self._stubs: - self._stubs["list_ssh_keys"] = self.grpc_channel.unary_unary( + self._stubs["list_ssh_keys"] = self._logged_channel.unary_unary( "/google.cloud.baremetalsolution.v2.BareMetalSolution/ListSSHKeys", request_serializer=ssh_key.ListSSHKeysRequest.serialize, response_deserializer=ssh_key.ListSSHKeysResponse.deserialize, @@ -601,7 +689,7 @@ def create_ssh_key( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_ssh_key" not in self._stubs: - self._stubs["create_ssh_key"] = self.grpc_channel.unary_unary( + self._stubs["create_ssh_key"] = self._logged_channel.unary_unary( "/google.cloud.baremetalsolution.v2.BareMetalSolution/CreateSSHKey", request_serializer=gcb_ssh_key.CreateSSHKeyRequest.serialize, response_deserializer=gcb_ssh_key.SSHKey.deserialize, @@ -628,7 +716,7 @@ def delete_ssh_key( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_ssh_key" not in self._stubs: - self._stubs["delete_ssh_key"] = self.grpc_channel.unary_unary( + self._stubs["delete_ssh_key"] = self._logged_channel.unary_unary( "/google.cloud.baremetalsolution.v2.BareMetalSolution/DeleteSSHKey", request_serializer=ssh_key.DeleteSSHKeyRequest.serialize, response_deserializer=empty_pb2.Empty.FromString, @@ -654,7 +742,7 @@ def list_volumes( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_volumes" not in self._stubs: - self._stubs["list_volumes"] = self.grpc_channel.unary_unary( + self._stubs["list_volumes"] = self._logged_channel.unary_unary( "/google.cloud.baremetalsolution.v2.BareMetalSolution/ListVolumes", request_serializer=volume.ListVolumesRequest.serialize, response_deserializer=volume.ListVolumesResponse.deserialize, @@ -678,7 +766,7 @@ def get_volume(self) -> Callable[[volume.GetVolumeRequest], volume.Volume]: # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_volume" not in self._stubs: - self._stubs["get_volume"] = self.grpc_channel.unary_unary( + self._stubs["get_volume"] = self._logged_channel.unary_unary( "/google.cloud.baremetalsolution.v2.BareMetalSolution/GetVolume", request_serializer=volume.GetVolumeRequest.serialize, response_deserializer=volume.Volume.deserialize, @@ -704,7 +792,7 @@ def update_volume( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_volume" not in self._stubs: - self._stubs["update_volume"] = self.grpc_channel.unary_unary( + self._stubs["update_volume"] = self._logged_channel.unary_unary( "/google.cloud.baremetalsolution.v2.BareMetalSolution/UpdateVolume", request_serializer=gcb_volume.UpdateVolumeRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -730,7 +818,7 @@ def rename_volume(self) -> Callable[[volume.RenameVolumeRequest], volume.Volume] # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "rename_volume" not in self._stubs: - self._stubs["rename_volume"] = self.grpc_channel.unary_unary( + self._stubs["rename_volume"] = self._logged_channel.unary_unary( "/google.cloud.baremetalsolution.v2.BareMetalSolution/RenameVolume", request_serializer=volume.RenameVolumeRequest.serialize, response_deserializer=volume.Volume.deserialize, @@ -757,7 +845,7 @@ def evict_volume( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "evict_volume" not in self._stubs: - self._stubs["evict_volume"] = self.grpc_channel.unary_unary( + self._stubs["evict_volume"] = self._logged_channel.unary_unary( "/google.cloud.baremetalsolution.v2.BareMetalSolution/EvictVolume", request_serializer=volume.EvictVolumeRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -783,7 +871,7 @@ def resize_volume( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "resize_volume" not in self._stubs: - self._stubs["resize_volume"] = self.grpc_channel.unary_unary( + self._stubs["resize_volume"] = self._logged_channel.unary_unary( "/google.cloud.baremetalsolution.v2.BareMetalSolution/ResizeVolume", request_serializer=gcb_volume.ResizeVolumeRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -809,7 +897,7 @@ def list_networks( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_networks" not in self._stubs: - self._stubs["list_networks"] = self.grpc_channel.unary_unary( + self._stubs["list_networks"] = self._logged_channel.unary_unary( "/google.cloud.baremetalsolution.v2.BareMetalSolution/ListNetworks", request_serializer=network.ListNetworksRequest.serialize, response_deserializer=network.ListNetworksResponse.deserialize, @@ -837,7 +925,7 @@ def list_network_usage( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_network_usage" not in self._stubs: - self._stubs["list_network_usage"] = self.grpc_channel.unary_unary( + self._stubs["list_network_usage"] = self._logged_channel.unary_unary( "/google.cloud.baremetalsolution.v2.BareMetalSolution/ListNetworkUsage", request_serializer=network.ListNetworkUsageRequest.serialize, response_deserializer=network.ListNetworkUsageResponse.deserialize, @@ -861,7 +949,7 @@ def get_network(self) -> Callable[[network.GetNetworkRequest], network.Network]: # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_network" not in self._stubs: - self._stubs["get_network"] = self.grpc_channel.unary_unary( + self._stubs["get_network"] = self._logged_channel.unary_unary( "/google.cloud.baremetalsolution.v2.BareMetalSolution/GetNetwork", request_serializer=network.GetNetworkRequest.serialize, response_deserializer=network.Network.deserialize, @@ -887,7 +975,7 @@ def update_network( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_network" not in self._stubs: - self._stubs["update_network"] = self.grpc_channel.unary_unary( + self._stubs["update_network"] = self._logged_channel.unary_unary( "/google.cloud.baremetalsolution.v2.BareMetalSolution/UpdateNetwork", request_serializer=gcb_network.UpdateNetworkRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -917,7 +1005,7 @@ def create_volume_snapshot( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_volume_snapshot" not in self._stubs: - self._stubs["create_volume_snapshot"] = self.grpc_channel.unary_unary( + self._stubs["create_volume_snapshot"] = self._logged_channel.unary_unary( "/google.cloud.baremetalsolution.v2.BareMetalSolution/CreateVolumeSnapshot", request_serializer=gcb_volume_snapshot.CreateVolumeSnapshotRequest.serialize, response_deserializer=gcb_volume_snapshot.VolumeSnapshot.deserialize, @@ -946,7 +1034,7 @@ def restore_volume_snapshot( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "restore_volume_snapshot" not in self._stubs: - self._stubs["restore_volume_snapshot"] = self.grpc_channel.unary_unary( + self._stubs["restore_volume_snapshot"] = self._logged_channel.unary_unary( "/google.cloud.baremetalsolution.v2.BareMetalSolution/RestoreVolumeSnapshot", request_serializer=gcb_volume_snapshot.RestoreVolumeSnapshotRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -973,7 +1061,7 @@ def delete_volume_snapshot( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_volume_snapshot" not in self._stubs: - self._stubs["delete_volume_snapshot"] = self.grpc_channel.unary_unary( + self._stubs["delete_volume_snapshot"] = self._logged_channel.unary_unary( "/google.cloud.baremetalsolution.v2.BareMetalSolution/DeleteVolumeSnapshot", request_serializer=volume_snapshot.DeleteVolumeSnapshotRequest.serialize, response_deserializer=empty_pb2.Empty.FromString, @@ -1002,7 +1090,7 @@ def get_volume_snapshot( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_volume_snapshot" not in self._stubs: - self._stubs["get_volume_snapshot"] = self.grpc_channel.unary_unary( + self._stubs["get_volume_snapshot"] = self._logged_channel.unary_unary( "/google.cloud.baremetalsolution.v2.BareMetalSolution/GetVolumeSnapshot", request_serializer=volume_snapshot.GetVolumeSnapshotRequest.serialize, response_deserializer=volume_snapshot.VolumeSnapshot.deserialize, @@ -1033,7 +1121,7 @@ def list_volume_snapshots( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_volume_snapshots" not in self._stubs: - self._stubs["list_volume_snapshots"] = self.grpc_channel.unary_unary( + self._stubs["list_volume_snapshots"] = self._logged_channel.unary_unary( "/google.cloud.baremetalsolution.v2.BareMetalSolution/ListVolumeSnapshots", request_serializer=volume_snapshot.ListVolumeSnapshotsRequest.serialize, response_deserializer=volume_snapshot.ListVolumeSnapshotsResponse.deserialize, @@ -1058,7 +1146,7 @@ def get_lun(self) -> Callable[[lun.GetLunRequest], lun.Lun]: # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_lun" not in self._stubs: - self._stubs["get_lun"] = self.grpc_channel.unary_unary( + self._stubs["get_lun"] = self._logged_channel.unary_unary( "/google.cloud.baremetalsolution.v2.BareMetalSolution/GetLun", request_serializer=lun.GetLunRequest.serialize, response_deserializer=lun.Lun.deserialize, @@ -1082,7 +1170,7 @@ def list_luns(self) -> Callable[[lun.ListLunsRequest], lun.ListLunsResponse]: # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_luns" not in self._stubs: - self._stubs["list_luns"] = self.grpc_channel.unary_unary( + self._stubs["list_luns"] = self._logged_channel.unary_unary( "/google.cloud.baremetalsolution.v2.BareMetalSolution/ListLuns", request_serializer=lun.ListLunsRequest.serialize, response_deserializer=lun.ListLunsResponse.deserialize, @@ -1107,7 +1195,7 @@ def evict_lun(self) -> Callable[[lun.EvictLunRequest], operations_pb2.Operation] # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "evict_lun" not in self._stubs: - self._stubs["evict_lun"] = self.grpc_channel.unary_unary( + self._stubs["evict_lun"] = self._logged_channel.unary_unary( "/google.cloud.baremetalsolution.v2.BareMetalSolution/EvictLun", request_serializer=lun.EvictLunRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -1133,7 +1221,7 @@ def get_nfs_share( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_nfs_share" not in self._stubs: - self._stubs["get_nfs_share"] = self.grpc_channel.unary_unary( + self._stubs["get_nfs_share"] = self._logged_channel.unary_unary( "/google.cloud.baremetalsolution.v2.BareMetalSolution/GetNfsShare", request_serializer=nfs_share.GetNfsShareRequest.serialize, response_deserializer=nfs_share.NfsShare.deserialize, @@ -1159,7 +1247,7 @@ def list_nfs_shares( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_nfs_shares" not in self._stubs: - self._stubs["list_nfs_shares"] = self.grpc_channel.unary_unary( + self._stubs["list_nfs_shares"] = self._logged_channel.unary_unary( "/google.cloud.baremetalsolution.v2.BareMetalSolution/ListNfsShares", request_serializer=nfs_share.ListNfsSharesRequest.serialize, response_deserializer=nfs_share.ListNfsSharesResponse.deserialize, @@ -1185,7 +1273,7 @@ def update_nfs_share( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_nfs_share" not in self._stubs: - self._stubs["update_nfs_share"] = self.grpc_channel.unary_unary( + self._stubs["update_nfs_share"] = self._logged_channel.unary_unary( "/google.cloud.baremetalsolution.v2.BareMetalSolution/UpdateNfsShare", request_serializer=gcb_nfs_share.UpdateNfsShareRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -1211,7 +1299,7 @@ def create_nfs_share( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_nfs_share" not in self._stubs: - self._stubs["create_nfs_share"] = self.grpc_channel.unary_unary( + self._stubs["create_nfs_share"] = self._logged_channel.unary_unary( "/google.cloud.baremetalsolution.v2.BareMetalSolution/CreateNfsShare", request_serializer=gcb_nfs_share.CreateNfsShareRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -1239,7 +1327,7 @@ def rename_nfs_share( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "rename_nfs_share" not in self._stubs: - self._stubs["rename_nfs_share"] = self.grpc_channel.unary_unary( + self._stubs["rename_nfs_share"] = self._logged_channel.unary_unary( "/google.cloud.baremetalsolution.v2.BareMetalSolution/RenameNfsShare", request_serializer=nfs_share.RenameNfsShareRequest.serialize, response_deserializer=nfs_share.NfsShare.deserialize, @@ -1266,7 +1354,7 @@ def delete_nfs_share( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_nfs_share" not in self._stubs: - self._stubs["delete_nfs_share"] = self.grpc_channel.unary_unary( + self._stubs["delete_nfs_share"] = self._logged_channel.unary_unary( "/google.cloud.baremetalsolution.v2.BareMetalSolution/DeleteNfsShare", request_serializer=nfs_share.DeleteNfsShareRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -1296,7 +1384,7 @@ def list_provisioning_quotas( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_provisioning_quotas" not in self._stubs: - self._stubs["list_provisioning_quotas"] = self.grpc_channel.unary_unary( + self._stubs["list_provisioning_quotas"] = self._logged_channel.unary_unary( "/google.cloud.baremetalsolution.v2.BareMetalSolution/ListProvisioningQuotas", request_serializer=provisioning.ListProvisioningQuotasRequest.serialize, response_deserializer=provisioning.ListProvisioningQuotasResponse.deserialize, @@ -1326,7 +1414,9 @@ def submit_provisioning_config( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "submit_provisioning_config" not in self._stubs: - self._stubs["submit_provisioning_config"] = self.grpc_channel.unary_unary( + self._stubs[ + "submit_provisioning_config" + ] = self._logged_channel.unary_unary( "/google.cloud.baremetalsolution.v2.BareMetalSolution/SubmitProvisioningConfig", request_serializer=provisioning.SubmitProvisioningConfigRequest.serialize, response_deserializer=provisioning.SubmitProvisioningConfigResponse.deserialize, @@ -1354,7 +1444,7 @@ def get_provisioning_config( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_provisioning_config" not in self._stubs: - self._stubs["get_provisioning_config"] = self.grpc_channel.unary_unary( + self._stubs["get_provisioning_config"] = self._logged_channel.unary_unary( "/google.cloud.baremetalsolution.v2.BareMetalSolution/GetProvisioningConfig", request_serializer=provisioning.GetProvisioningConfigRequest.serialize, response_deserializer=provisioning.ProvisioningConfig.deserialize, @@ -1382,7 +1472,9 @@ def create_provisioning_config( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_provisioning_config" not in self._stubs: - self._stubs["create_provisioning_config"] = self.grpc_channel.unary_unary( + self._stubs[ + "create_provisioning_config" + ] = self._logged_channel.unary_unary( "/google.cloud.baremetalsolution.v2.BareMetalSolution/CreateProvisioningConfig", request_serializer=provisioning.CreateProvisioningConfigRequest.serialize, response_deserializer=provisioning.ProvisioningConfig.deserialize, @@ -1410,7 +1502,9 @@ def update_provisioning_config( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_provisioning_config" not in self._stubs: - self._stubs["update_provisioning_config"] = self.grpc_channel.unary_unary( + self._stubs[ + "update_provisioning_config" + ] = self._logged_channel.unary_unary( "/google.cloud.baremetalsolution.v2.BareMetalSolution/UpdateProvisioningConfig", request_serializer=provisioning.UpdateProvisioningConfigRequest.serialize, response_deserializer=provisioning.ProvisioningConfig.deserialize, @@ -1438,7 +1532,7 @@ def rename_network( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "rename_network" not in self._stubs: - self._stubs["rename_network"] = self.grpc_channel.unary_unary( + self._stubs["rename_network"] = self._logged_channel.unary_unary( "/google.cloud.baremetalsolution.v2.BareMetalSolution/RenameNetwork", request_serializer=network.RenameNetworkRequest.serialize, response_deserializer=network.Network.deserialize, @@ -1465,7 +1559,7 @@ def list_os_images( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_os_images" not in self._stubs: - self._stubs["list_os_images"] = self.grpc_channel.unary_unary( + self._stubs["list_os_images"] = self._logged_channel.unary_unary( "/google.cloud.baremetalsolution.v2.BareMetalSolution/ListOSImages", request_serializer=osimage.ListOSImagesRequest.serialize, response_deserializer=osimage.ListOSImagesResponse.deserialize, @@ -1473,7 +1567,7 @@ def list_os_images( return self._stubs["list_os_images"] def close(self): - self.grpc_channel.close() + self._logged_channel.close() @property def list_locations( @@ -1487,7 +1581,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, @@ -1504,7 +1598,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-bare-metal-solution/google/cloud/bare_metal_solution_v2/services/bare_metal_solution/transports/grpc_asyncio.py b/packages/google-cloud-bare-metal-solution/google/cloud/bare_metal_solution_v2/services/bare_metal_solution/transports/grpc_asyncio.py index 6765b538349f..a4d17ad60aa9 100644 --- a/packages/google-cloud-bare-metal-solution/google/cloud/bare_metal_solution_v2/services/bare_metal_solution/transports/grpc_asyncio.py +++ b/packages/google-cloud-bare-metal-solution/google/cloud/bare_metal_solution_v2/services/bare_metal_solution/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.bare_metal_solution_v2.types import nfs_share as gcb_nfs_share from google.cloud.bare_metal_solution_v2.types import ( @@ -50,6 +56,82 @@ from .base import DEFAULT_CLIENT_INFO, BareMetalSolutionTransport from .grpc import BareMetalSolutionGrpcTransport +try: + from google.api_core import client_logging # 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.baremetalsolution.v2.BareMetalSolution", + "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.baremetalsolution.v2.BareMetalSolution", + "rpcName": str(client_call_details.method), + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class BareMetalSolutionGrpcAsyncIOTransport(BareMetalSolutionTransport): """gRPC AsyncIO backend transport for BareMetalSolution. @@ -255,10 +337,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 @@ -281,7 +366,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. @@ -308,7 +393,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.baremetalsolution.v2.BareMetalSolution/ListInstances", request_serializer=instance.ListInstancesRequest.serialize, response_deserializer=instance.ListInstancesResponse.deserialize, @@ -334,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.baremetalsolution.v2.BareMetalSolution/GetInstance", request_serializer=instance.GetInstanceRequest.serialize, response_deserializer=instance.Instance.deserialize, @@ -362,7 +447,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.baremetalsolution.v2.BareMetalSolution/UpdateInstance", request_serializer=gcb_instance.UpdateInstanceRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -390,7 +475,7 @@ def rename_instance( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "rename_instance" not in self._stubs: - self._stubs["rename_instance"] = self.grpc_channel.unary_unary( + self._stubs["rename_instance"] = self._logged_channel.unary_unary( "/google.cloud.baremetalsolution.v2.BareMetalSolution/RenameInstance", request_serializer=instance.RenameInstanceRequest.serialize, response_deserializer=instance.Instance.deserialize, @@ -418,7 +503,7 @@ def reset_instance( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "reset_instance" not in self._stubs: - self._stubs["reset_instance"] = self.grpc_channel.unary_unary( + self._stubs["reset_instance"] = self._logged_channel.unary_unary( "/google.cloud.baremetalsolution.v2.BareMetalSolution/ResetInstance", request_serializer=instance.ResetInstanceRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -444,7 +529,7 @@ def start_instance( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "start_instance" not in self._stubs: - self._stubs["start_instance"] = self.grpc_channel.unary_unary( + self._stubs["start_instance"] = self._logged_channel.unary_unary( "/google.cloud.baremetalsolution.v2.BareMetalSolution/StartInstance", request_serializer=instance.StartInstanceRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -470,7 +555,7 @@ def stop_instance( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "stop_instance" not in self._stubs: - self._stubs["stop_instance"] = self.grpc_channel.unary_unary( + self._stubs["stop_instance"] = self._logged_channel.unary_unary( "/google.cloud.baremetalsolution.v2.BareMetalSolution/StopInstance", request_serializer=instance.StopInstanceRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -503,7 +588,7 @@ def enable_interactive_serial_console( if "enable_interactive_serial_console" not in self._stubs: self._stubs[ "enable_interactive_serial_console" - ] = self.grpc_channel.unary_unary( + ] = self._logged_channel.unary_unary( "/google.cloud.baremetalsolution.v2.BareMetalSolution/EnableInteractiveSerialConsole", request_serializer=instance.EnableInteractiveSerialConsoleRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -536,7 +621,7 @@ def disable_interactive_serial_console( if "disable_interactive_serial_console" not in self._stubs: self._stubs[ "disable_interactive_serial_console" - ] = self.grpc_channel.unary_unary( + ] = self._logged_channel.unary_unary( "/google.cloud.baremetalsolution.v2.BareMetalSolution/DisableInteractiveSerialConsole", request_serializer=instance.DisableInteractiveSerialConsoleRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -562,7 +647,7 @@ def detach_lun( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "detach_lun" not in self._stubs: - self._stubs["detach_lun"] = self.grpc_channel.unary_unary( + self._stubs["detach_lun"] = self._logged_channel.unary_unary( "/google.cloud.baremetalsolution.v2.BareMetalSolution/DetachLun", request_serializer=gcb_instance.DetachLunRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -590,7 +675,7 @@ def list_ssh_keys( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_ssh_keys" not in self._stubs: - self._stubs["list_ssh_keys"] = self.grpc_channel.unary_unary( + self._stubs["list_ssh_keys"] = self._logged_channel.unary_unary( "/google.cloud.baremetalsolution.v2.BareMetalSolution/ListSSHKeys", request_serializer=ssh_key.ListSSHKeysRequest.serialize, response_deserializer=ssh_key.ListSSHKeysResponse.deserialize, @@ -617,7 +702,7 @@ def create_ssh_key( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_ssh_key" not in self._stubs: - self._stubs["create_ssh_key"] = self.grpc_channel.unary_unary( + self._stubs["create_ssh_key"] = self._logged_channel.unary_unary( "/google.cloud.baremetalsolution.v2.BareMetalSolution/CreateSSHKey", request_serializer=gcb_ssh_key.CreateSSHKeyRequest.serialize, response_deserializer=gcb_ssh_key.SSHKey.deserialize, @@ -644,7 +729,7 @@ def delete_ssh_key( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_ssh_key" not in self._stubs: - self._stubs["delete_ssh_key"] = self.grpc_channel.unary_unary( + self._stubs["delete_ssh_key"] = self._logged_channel.unary_unary( "/google.cloud.baremetalsolution.v2.BareMetalSolution/DeleteSSHKey", request_serializer=ssh_key.DeleteSSHKeyRequest.serialize, response_deserializer=empty_pb2.Empty.FromString, @@ -670,7 +755,7 @@ def list_volumes( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_volumes" not in self._stubs: - self._stubs["list_volumes"] = self.grpc_channel.unary_unary( + self._stubs["list_volumes"] = self._logged_channel.unary_unary( "/google.cloud.baremetalsolution.v2.BareMetalSolution/ListVolumes", request_serializer=volume.ListVolumesRequest.serialize, response_deserializer=volume.ListVolumesResponse.deserialize, @@ -696,7 +781,7 @@ def get_volume( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_volume" not in self._stubs: - self._stubs["get_volume"] = self.grpc_channel.unary_unary( + self._stubs["get_volume"] = self._logged_channel.unary_unary( "/google.cloud.baremetalsolution.v2.BareMetalSolution/GetVolume", request_serializer=volume.GetVolumeRequest.serialize, response_deserializer=volume.Volume.deserialize, @@ -724,7 +809,7 @@ def update_volume( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_volume" not in self._stubs: - self._stubs["update_volume"] = self.grpc_channel.unary_unary( + self._stubs["update_volume"] = self._logged_channel.unary_unary( "/google.cloud.baremetalsolution.v2.BareMetalSolution/UpdateVolume", request_serializer=gcb_volume.UpdateVolumeRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -752,7 +837,7 @@ def rename_volume( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "rename_volume" not in self._stubs: - self._stubs["rename_volume"] = self.grpc_channel.unary_unary( + self._stubs["rename_volume"] = self._logged_channel.unary_unary( "/google.cloud.baremetalsolution.v2.BareMetalSolution/RenameVolume", request_serializer=volume.RenameVolumeRequest.serialize, response_deserializer=volume.Volume.deserialize, @@ -779,7 +864,7 @@ def evict_volume( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "evict_volume" not in self._stubs: - self._stubs["evict_volume"] = self.grpc_channel.unary_unary( + self._stubs["evict_volume"] = self._logged_channel.unary_unary( "/google.cloud.baremetalsolution.v2.BareMetalSolution/EvictVolume", request_serializer=volume.EvictVolumeRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -807,7 +892,7 @@ def resize_volume( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "resize_volume" not in self._stubs: - self._stubs["resize_volume"] = self.grpc_channel.unary_unary( + self._stubs["resize_volume"] = self._logged_channel.unary_unary( "/google.cloud.baremetalsolution.v2.BareMetalSolution/ResizeVolume", request_serializer=gcb_volume.ResizeVolumeRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -835,7 +920,7 @@ def list_networks( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_networks" not in self._stubs: - self._stubs["list_networks"] = self.grpc_channel.unary_unary( + self._stubs["list_networks"] = self._logged_channel.unary_unary( "/google.cloud.baremetalsolution.v2.BareMetalSolution/ListNetworks", request_serializer=network.ListNetworksRequest.serialize, response_deserializer=network.ListNetworksResponse.deserialize, @@ -865,7 +950,7 @@ def list_network_usage( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_network_usage" not in self._stubs: - self._stubs["list_network_usage"] = self.grpc_channel.unary_unary( + self._stubs["list_network_usage"] = self._logged_channel.unary_unary( "/google.cloud.baremetalsolution.v2.BareMetalSolution/ListNetworkUsage", request_serializer=network.ListNetworkUsageRequest.serialize, response_deserializer=network.ListNetworkUsageResponse.deserialize, @@ -891,7 +976,7 @@ def get_network( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_network" not in self._stubs: - self._stubs["get_network"] = self.grpc_channel.unary_unary( + self._stubs["get_network"] = self._logged_channel.unary_unary( "/google.cloud.baremetalsolution.v2.BareMetalSolution/GetNetwork", request_serializer=network.GetNetworkRequest.serialize, response_deserializer=network.Network.deserialize, @@ -919,7 +1004,7 @@ def update_network( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_network" not in self._stubs: - self._stubs["update_network"] = self.grpc_channel.unary_unary( + self._stubs["update_network"] = self._logged_channel.unary_unary( "/google.cloud.baremetalsolution.v2.BareMetalSolution/UpdateNetwork", request_serializer=gcb_network.UpdateNetworkRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -949,7 +1034,7 @@ def create_volume_snapshot( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_volume_snapshot" not in self._stubs: - self._stubs["create_volume_snapshot"] = self.grpc_channel.unary_unary( + self._stubs["create_volume_snapshot"] = self._logged_channel.unary_unary( "/google.cloud.baremetalsolution.v2.BareMetalSolution/CreateVolumeSnapshot", request_serializer=gcb_volume_snapshot.CreateVolumeSnapshotRequest.serialize, response_deserializer=gcb_volume_snapshot.VolumeSnapshot.deserialize, @@ -979,7 +1064,7 @@ def restore_volume_snapshot( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "restore_volume_snapshot" not in self._stubs: - self._stubs["restore_volume_snapshot"] = self.grpc_channel.unary_unary( + self._stubs["restore_volume_snapshot"] = self._logged_channel.unary_unary( "/google.cloud.baremetalsolution.v2.BareMetalSolution/RestoreVolumeSnapshot", request_serializer=gcb_volume_snapshot.RestoreVolumeSnapshotRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -1008,7 +1093,7 @@ def delete_volume_snapshot( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_volume_snapshot" not in self._stubs: - self._stubs["delete_volume_snapshot"] = self.grpc_channel.unary_unary( + self._stubs["delete_volume_snapshot"] = self._logged_channel.unary_unary( "/google.cloud.baremetalsolution.v2.BareMetalSolution/DeleteVolumeSnapshot", request_serializer=volume_snapshot.DeleteVolumeSnapshotRequest.serialize, response_deserializer=empty_pb2.Empty.FromString, @@ -1038,7 +1123,7 @@ def get_volume_snapshot( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_volume_snapshot" not in self._stubs: - self._stubs["get_volume_snapshot"] = self.grpc_channel.unary_unary( + self._stubs["get_volume_snapshot"] = self._logged_channel.unary_unary( "/google.cloud.baremetalsolution.v2.BareMetalSolution/GetVolumeSnapshot", request_serializer=volume_snapshot.GetVolumeSnapshotRequest.serialize, response_deserializer=volume_snapshot.VolumeSnapshot.deserialize, @@ -1069,7 +1154,7 @@ def list_volume_snapshots( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_volume_snapshots" not in self._stubs: - self._stubs["list_volume_snapshots"] = self.grpc_channel.unary_unary( + self._stubs["list_volume_snapshots"] = self._logged_channel.unary_unary( "/google.cloud.baremetalsolution.v2.BareMetalSolution/ListVolumeSnapshots", request_serializer=volume_snapshot.ListVolumeSnapshotsRequest.serialize, response_deserializer=volume_snapshot.ListVolumeSnapshotsResponse.deserialize, @@ -1094,7 +1179,7 @@ def get_lun(self) -> Callable[[lun.GetLunRequest], Awaitable[lun.Lun]]: # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_lun" not in self._stubs: - self._stubs["get_lun"] = self.grpc_channel.unary_unary( + self._stubs["get_lun"] = self._logged_channel.unary_unary( "/google.cloud.baremetalsolution.v2.BareMetalSolution/GetLun", request_serializer=lun.GetLunRequest.serialize, response_deserializer=lun.Lun.deserialize, @@ -1120,7 +1205,7 @@ def list_luns( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_luns" not in self._stubs: - self._stubs["list_luns"] = self.grpc_channel.unary_unary( + self._stubs["list_luns"] = self._logged_channel.unary_unary( "/google.cloud.baremetalsolution.v2.BareMetalSolution/ListLuns", request_serializer=lun.ListLunsRequest.serialize, response_deserializer=lun.ListLunsResponse.deserialize, @@ -1147,7 +1232,7 @@ def evict_lun( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "evict_lun" not in self._stubs: - self._stubs["evict_lun"] = self.grpc_channel.unary_unary( + self._stubs["evict_lun"] = self._logged_channel.unary_unary( "/google.cloud.baremetalsolution.v2.BareMetalSolution/EvictLun", request_serializer=lun.EvictLunRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -1173,7 +1258,7 @@ def get_nfs_share( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_nfs_share" not in self._stubs: - self._stubs["get_nfs_share"] = self.grpc_channel.unary_unary( + self._stubs["get_nfs_share"] = self._logged_channel.unary_unary( "/google.cloud.baremetalsolution.v2.BareMetalSolution/GetNfsShare", request_serializer=nfs_share.GetNfsShareRequest.serialize, response_deserializer=nfs_share.NfsShare.deserialize, @@ -1201,7 +1286,7 @@ def list_nfs_shares( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_nfs_shares" not in self._stubs: - self._stubs["list_nfs_shares"] = self.grpc_channel.unary_unary( + self._stubs["list_nfs_shares"] = self._logged_channel.unary_unary( "/google.cloud.baremetalsolution.v2.BareMetalSolution/ListNfsShares", request_serializer=nfs_share.ListNfsSharesRequest.serialize, response_deserializer=nfs_share.ListNfsSharesResponse.deserialize, @@ -1229,7 +1314,7 @@ def update_nfs_share( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_nfs_share" not in self._stubs: - self._stubs["update_nfs_share"] = self.grpc_channel.unary_unary( + self._stubs["update_nfs_share"] = self._logged_channel.unary_unary( "/google.cloud.baremetalsolution.v2.BareMetalSolution/UpdateNfsShare", request_serializer=gcb_nfs_share.UpdateNfsShareRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -1257,7 +1342,7 @@ def create_nfs_share( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_nfs_share" not in self._stubs: - self._stubs["create_nfs_share"] = self.grpc_channel.unary_unary( + self._stubs["create_nfs_share"] = self._logged_channel.unary_unary( "/google.cloud.baremetalsolution.v2.BareMetalSolution/CreateNfsShare", request_serializer=gcb_nfs_share.CreateNfsShareRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -1285,7 +1370,7 @@ def rename_nfs_share( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "rename_nfs_share" not in self._stubs: - self._stubs["rename_nfs_share"] = self.grpc_channel.unary_unary( + self._stubs["rename_nfs_share"] = self._logged_channel.unary_unary( "/google.cloud.baremetalsolution.v2.BareMetalSolution/RenameNfsShare", request_serializer=nfs_share.RenameNfsShareRequest.serialize, response_deserializer=nfs_share.NfsShare.deserialize, @@ -1314,7 +1399,7 @@ def delete_nfs_share( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_nfs_share" not in self._stubs: - self._stubs["delete_nfs_share"] = self.grpc_channel.unary_unary( + self._stubs["delete_nfs_share"] = self._logged_channel.unary_unary( "/google.cloud.baremetalsolution.v2.BareMetalSolution/DeleteNfsShare", request_serializer=nfs_share.DeleteNfsShareRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -1344,7 +1429,7 @@ def list_provisioning_quotas( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_provisioning_quotas" not in self._stubs: - self._stubs["list_provisioning_quotas"] = self.grpc_channel.unary_unary( + self._stubs["list_provisioning_quotas"] = self._logged_channel.unary_unary( "/google.cloud.baremetalsolution.v2.BareMetalSolution/ListProvisioningQuotas", request_serializer=provisioning.ListProvisioningQuotasRequest.serialize, response_deserializer=provisioning.ListProvisioningQuotasResponse.deserialize, @@ -1374,7 +1459,9 @@ def submit_provisioning_config( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "submit_provisioning_config" not in self._stubs: - self._stubs["submit_provisioning_config"] = self.grpc_channel.unary_unary( + self._stubs[ + "submit_provisioning_config" + ] = self._logged_channel.unary_unary( "/google.cloud.baremetalsolution.v2.BareMetalSolution/SubmitProvisioningConfig", request_serializer=provisioning.SubmitProvisioningConfigRequest.serialize, response_deserializer=provisioning.SubmitProvisioningConfigResponse.deserialize, @@ -1403,7 +1490,7 @@ def get_provisioning_config( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_provisioning_config" not in self._stubs: - self._stubs["get_provisioning_config"] = self.grpc_channel.unary_unary( + self._stubs["get_provisioning_config"] = self._logged_channel.unary_unary( "/google.cloud.baremetalsolution.v2.BareMetalSolution/GetProvisioningConfig", request_serializer=provisioning.GetProvisioningConfigRequest.serialize, response_deserializer=provisioning.ProvisioningConfig.deserialize, @@ -1432,7 +1519,9 @@ def create_provisioning_config( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_provisioning_config" not in self._stubs: - self._stubs["create_provisioning_config"] = self.grpc_channel.unary_unary( + self._stubs[ + "create_provisioning_config" + ] = self._logged_channel.unary_unary( "/google.cloud.baremetalsolution.v2.BareMetalSolution/CreateProvisioningConfig", request_serializer=provisioning.CreateProvisioningConfigRequest.serialize, response_deserializer=provisioning.ProvisioningConfig.deserialize, @@ -1461,7 +1550,9 @@ def update_provisioning_config( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_provisioning_config" not in self._stubs: - self._stubs["update_provisioning_config"] = self.grpc_channel.unary_unary( + self._stubs[ + "update_provisioning_config" + ] = self._logged_channel.unary_unary( "/google.cloud.baremetalsolution.v2.BareMetalSolution/UpdateProvisioningConfig", request_serializer=provisioning.UpdateProvisioningConfigRequest.serialize, response_deserializer=provisioning.ProvisioningConfig.deserialize, @@ -1489,7 +1580,7 @@ def rename_network( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "rename_network" not in self._stubs: - self._stubs["rename_network"] = self.grpc_channel.unary_unary( + self._stubs["rename_network"] = self._logged_channel.unary_unary( "/google.cloud.baremetalsolution.v2.BareMetalSolution/RenameNetwork", request_serializer=network.RenameNetworkRequest.serialize, response_deserializer=network.Network.deserialize, @@ -1518,7 +1609,7 @@ def list_os_images( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_os_images" not in self._stubs: - self._stubs["list_os_images"] = self.grpc_channel.unary_unary( + self._stubs["list_os_images"] = self._logged_channel.unary_unary( "/google.cloud.baremetalsolution.v2.BareMetalSolution/ListOSImages", request_serializer=osimage.ListOSImagesRequest.serialize, response_deserializer=osimage.ListOSImagesResponse.deserialize, @@ -1766,7 +1857,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: @@ -1784,7 +1875,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, @@ -1801,7 +1892,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-bare-metal-solution/google/cloud/bare_metal_solution_v2/services/bare_metal_solution/transports/rest.py b/packages/google-cloud-bare-metal-solution/google/cloud/bare_metal_solution_v2/services/bare_metal_solution/transports/rest.py index af19b2213524..9f1bd00eefd2 100644 --- a/packages/google-cloud-bare-metal-solution/google/cloud/bare_metal_solution_v2/services/bare_metal_solution/transports/rest.py +++ b/packages/google-cloud-bare-metal-solution/google/cloud/bare_metal_solution_v2/services/bare_metal_solution/transports/rest.py @@ -13,9 +13,9 @@ # See the License for the specific language governing permissions and # limitations under the License. # - import dataclasses import json # type: ignore +import logging from typing import Any, Callable, Dict, List, Optional, Sequence, Tuple, Union import warnings @@ -57,6 +57,14 @@ except AttributeError: # pragma: NO COVER OptionalRetry = Union[retries.Retry, object, None] # type: ignore +try: + from google.api_core import client_logging # type: ignore + + CLIENT_LOGGING_SUPPORTED = True # pragma: NO COVER +except ImportError: # pragma: NO COVER + CLIENT_LOGGING_SUPPORTED = False + +_LOGGER = logging.getLogger(__name__) DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo( gapic_version=BASE_DEFAULT_CLIENT_INFO.gapic_version, @@ -433,8 +441,10 @@ def post_update_volume(self, response): def pre_create_nfs_share( self, request: gcb_nfs_share.CreateNfsShareRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[gcb_nfs_share.CreateNfsShareRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + gcb_nfs_share.CreateNfsShareRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for create_nfs_share Override in a subclass to manipulate the request or metadata @@ -456,8 +466,11 @@ def post_create_nfs_share( def pre_create_provisioning_config( self, request: provisioning.CreateProvisioningConfigRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[provisioning.CreateProvisioningConfigRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + provisioning.CreateProvisioningConfigRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for create_provisioning_config Override in a subclass to manipulate the request or metadata @@ -479,8 +492,10 @@ def post_create_provisioning_config( def pre_create_ssh_key( self, request: gcb_ssh_key.CreateSSHKeyRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[gcb_ssh_key.CreateSSHKeyRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + gcb_ssh_key.CreateSSHKeyRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for create_ssh_key Override in a subclass to manipulate the request or metadata @@ -500,9 +515,10 @@ def post_create_ssh_key(self, response: gcb_ssh_key.SSHKey) -> gcb_ssh_key.SSHKe def pre_create_volume_snapshot( self, request: gcb_volume_snapshot.CreateVolumeSnapshotRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ - gcb_volume_snapshot.CreateVolumeSnapshotRequest, Sequence[Tuple[str, str]] + gcb_volume_snapshot.CreateVolumeSnapshotRequest, + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for create_volume_snapshot @@ -525,8 +541,10 @@ def post_create_volume_snapshot( def pre_delete_nfs_share( self, request: nfs_share.DeleteNfsShareRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[nfs_share.DeleteNfsShareRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + nfs_share.DeleteNfsShareRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for delete_nfs_share Override in a subclass to manipulate the request or metadata @@ -546,8 +564,10 @@ def post_delete_nfs_share( return response def pre_delete_ssh_key( - self, request: ssh_key.DeleteSSHKeyRequest, metadata: Sequence[Tuple[str, str]] - ) -> Tuple[ssh_key.DeleteSSHKeyRequest, Sequence[Tuple[str, str]]]: + self, + request: ssh_key.DeleteSSHKeyRequest, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ssh_key.DeleteSSHKeyRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for delete_ssh_key Override in a subclass to manipulate the request or metadata @@ -558,8 +578,11 @@ def pre_delete_ssh_key( def pre_delete_volume_snapshot( self, request: volume_snapshot.DeleteVolumeSnapshotRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[volume_snapshot.DeleteVolumeSnapshotRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + volume_snapshot.DeleteVolumeSnapshotRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for delete_volume_snapshot Override in a subclass to manipulate the request or metadata @@ -570,8 +593,8 @@ def pre_delete_volume_snapshot( def pre_detach_lun( self, request: gcb_instance.DetachLunRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[gcb_instance.DetachLunRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[gcb_instance.DetachLunRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for detach_lun Override in a subclass to manipulate the request or metadata @@ -593,9 +616,10 @@ def post_detach_lun( def pre_disable_interactive_serial_console( self, request: instance.DisableInteractiveSerialConsoleRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ - instance.DisableInteractiveSerialConsoleRequest, Sequence[Tuple[str, str]] + instance.DisableInteractiveSerialConsoleRequest, + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for disable_interactive_serial_console @@ -618,9 +642,10 @@ def post_disable_interactive_serial_console( def pre_enable_interactive_serial_console( self, request: instance.EnableInteractiveSerialConsoleRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ - instance.EnableInteractiveSerialConsoleRequest, Sequence[Tuple[str, str]] + instance.EnableInteractiveSerialConsoleRequest, + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for enable_interactive_serial_console @@ -641,8 +666,10 @@ def post_enable_interactive_serial_console( return response def pre_evict_lun( - self, request: lun.EvictLunRequest, metadata: Sequence[Tuple[str, str]] - ) -> Tuple[lun.EvictLunRequest, Sequence[Tuple[str, str]]]: + self, + request: lun.EvictLunRequest, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[lun.EvictLunRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for evict_lun Override in a subclass to manipulate the request or metadata @@ -662,8 +689,10 @@ def post_evict_lun( return response def pre_evict_volume( - self, request: volume.EvictVolumeRequest, metadata: Sequence[Tuple[str, str]] - ) -> Tuple[volume.EvictVolumeRequest, Sequence[Tuple[str, str]]]: + self, + request: volume.EvictVolumeRequest, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[volume.EvictVolumeRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for evict_volume Override in a subclass to manipulate the request or metadata @@ -683,8 +712,10 @@ def post_evict_volume( return response def pre_get_instance( - self, request: instance.GetInstanceRequest, metadata: Sequence[Tuple[str, str]] - ) -> Tuple[instance.GetInstanceRequest, Sequence[Tuple[str, str]]]: + self, + request: instance.GetInstanceRequest, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[instance.GetInstanceRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for get_instance Override in a subclass to manipulate the request or metadata @@ -702,8 +733,10 @@ def post_get_instance(self, response: instance.Instance) -> instance.Instance: return response def pre_get_lun( - self, request: lun.GetLunRequest, metadata: Sequence[Tuple[str, str]] - ) -> Tuple[lun.GetLunRequest, Sequence[Tuple[str, str]]]: + self, + request: lun.GetLunRequest, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[lun.GetLunRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for get_lun Override in a subclass to manipulate the request or metadata @@ -721,8 +754,10 @@ def post_get_lun(self, response: lun.Lun) -> lun.Lun: return response def pre_get_network( - self, request: network.GetNetworkRequest, metadata: Sequence[Tuple[str, str]] - ) -> Tuple[network.GetNetworkRequest, Sequence[Tuple[str, str]]]: + self, + request: network.GetNetworkRequest, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[network.GetNetworkRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for get_network Override in a subclass to manipulate the request or metadata @@ -740,8 +775,10 @@ def post_get_network(self, response: network.Network) -> network.Network: return response def pre_get_nfs_share( - self, request: nfs_share.GetNfsShareRequest, metadata: Sequence[Tuple[str, str]] - ) -> Tuple[nfs_share.GetNfsShareRequest, Sequence[Tuple[str, str]]]: + self, + request: nfs_share.GetNfsShareRequest, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[nfs_share.GetNfsShareRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for get_nfs_share Override in a subclass to manipulate the request or metadata @@ -761,8 +798,11 @@ def post_get_nfs_share(self, response: nfs_share.NfsShare) -> nfs_share.NfsShare def pre_get_provisioning_config( self, request: provisioning.GetProvisioningConfigRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[provisioning.GetProvisioningConfigRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + provisioning.GetProvisioningConfigRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for get_provisioning_config Override in a subclass to manipulate the request or metadata @@ -782,8 +822,10 @@ def post_get_provisioning_config( return response def pre_get_volume( - self, request: volume.GetVolumeRequest, metadata: Sequence[Tuple[str, str]] - ) -> Tuple[volume.GetVolumeRequest, Sequence[Tuple[str, str]]]: + self, + request: volume.GetVolumeRequest, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[volume.GetVolumeRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for get_volume Override in a subclass to manipulate the request or metadata @@ -803,8 +845,11 @@ def post_get_volume(self, response: volume.Volume) -> volume.Volume: def pre_get_volume_snapshot( self, request: volume_snapshot.GetVolumeSnapshotRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[volume_snapshot.GetVolumeSnapshotRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + volume_snapshot.GetVolumeSnapshotRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for get_volume_snapshot Override in a subclass to manipulate the request or metadata @@ -826,8 +871,8 @@ def post_get_volume_snapshot( def pre_list_instances( self, request: instance.ListInstancesRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[instance.ListInstancesRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[instance.ListInstancesRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for list_instances Override in a subclass to manipulate the request or metadata @@ -847,8 +892,10 @@ def post_list_instances( return response def pre_list_luns( - self, request: lun.ListLunsRequest, metadata: Sequence[Tuple[str, str]] - ) -> Tuple[lun.ListLunsRequest, Sequence[Tuple[str, str]]]: + self, + request: lun.ListLunsRequest, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[lun.ListLunsRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for list_luns Override in a subclass to manipulate the request or metadata @@ -866,8 +913,10 @@ def post_list_luns(self, response: lun.ListLunsResponse) -> lun.ListLunsResponse return response def pre_list_networks( - self, request: network.ListNetworksRequest, metadata: Sequence[Tuple[str, str]] - ) -> Tuple[network.ListNetworksRequest, Sequence[Tuple[str, str]]]: + self, + request: network.ListNetworksRequest, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[network.ListNetworksRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for list_networks Override in a subclass to manipulate the request or metadata @@ -889,8 +938,10 @@ def post_list_networks( def pre_list_network_usage( self, request: network.ListNetworkUsageRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[network.ListNetworkUsageRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + network.ListNetworkUsageRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for list_network_usage Override in a subclass to manipulate the request or metadata @@ -912,8 +963,8 @@ def post_list_network_usage( def pre_list_nfs_shares( self, request: nfs_share.ListNfsSharesRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[nfs_share.ListNfsSharesRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[nfs_share.ListNfsSharesRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for list_nfs_shares Override in a subclass to manipulate the request or metadata @@ -933,8 +984,10 @@ def post_list_nfs_shares( return response def pre_list_os_images( - self, request: osimage.ListOSImagesRequest, metadata: Sequence[Tuple[str, str]] - ) -> Tuple[osimage.ListOSImagesRequest, Sequence[Tuple[str, str]]]: + self, + request: osimage.ListOSImagesRequest, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[osimage.ListOSImagesRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for list_os_images Override in a subclass to manipulate the request or metadata @@ -956,8 +1009,11 @@ def post_list_os_images( def pre_list_provisioning_quotas( self, request: provisioning.ListProvisioningQuotasRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[provisioning.ListProvisioningQuotasRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + provisioning.ListProvisioningQuotasRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for list_provisioning_quotas Override in a subclass to manipulate the request or metadata @@ -977,8 +1033,10 @@ def post_list_provisioning_quotas( return response def pre_list_ssh_keys( - self, request: ssh_key.ListSSHKeysRequest, metadata: Sequence[Tuple[str, str]] - ) -> Tuple[ssh_key.ListSSHKeysRequest, Sequence[Tuple[str, str]]]: + self, + request: ssh_key.ListSSHKeysRequest, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ssh_key.ListSSHKeysRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for list_ssh_keys Override in a subclass to manipulate the request or metadata @@ -998,8 +1056,10 @@ def post_list_ssh_keys( return response def pre_list_volumes( - self, request: volume.ListVolumesRequest, metadata: Sequence[Tuple[str, str]] - ) -> Tuple[volume.ListVolumesRequest, Sequence[Tuple[str, str]]]: + self, + request: volume.ListVolumesRequest, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[volume.ListVolumesRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for list_volumes Override in a subclass to manipulate the request or metadata @@ -1021,8 +1081,11 @@ def post_list_volumes( def pre_list_volume_snapshots( self, request: volume_snapshot.ListVolumeSnapshotsRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[volume_snapshot.ListVolumeSnapshotsRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + volume_snapshot.ListVolumeSnapshotsRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for list_volume_snapshots Override in a subclass to manipulate the request or metadata @@ -1044,8 +1107,8 @@ def post_list_volume_snapshots( def pre_rename_instance( self, request: instance.RenameInstanceRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[instance.RenameInstanceRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[instance.RenameInstanceRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for rename_instance Override in a subclass to manipulate the request or metadata @@ -1063,8 +1126,10 @@ def post_rename_instance(self, response: instance.Instance) -> instance.Instance return response def pre_rename_network( - self, request: network.RenameNetworkRequest, metadata: Sequence[Tuple[str, str]] - ) -> Tuple[network.RenameNetworkRequest, Sequence[Tuple[str, str]]]: + self, + request: network.RenameNetworkRequest, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[network.RenameNetworkRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for rename_network Override in a subclass to manipulate the request or metadata @@ -1084,8 +1149,10 @@ def post_rename_network(self, response: network.Network) -> network.Network: def pre_rename_nfs_share( self, request: nfs_share.RenameNfsShareRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[nfs_share.RenameNfsShareRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + nfs_share.RenameNfsShareRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for rename_nfs_share Override in a subclass to manipulate the request or metadata @@ -1103,8 +1170,10 @@ def post_rename_nfs_share(self, response: nfs_share.NfsShare) -> nfs_share.NfsSh return response def pre_rename_volume( - self, request: volume.RenameVolumeRequest, metadata: Sequence[Tuple[str, str]] - ) -> Tuple[volume.RenameVolumeRequest, Sequence[Tuple[str, str]]]: + self, + request: volume.RenameVolumeRequest, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[volume.RenameVolumeRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for rename_volume Override in a subclass to manipulate the request or metadata @@ -1124,8 +1193,8 @@ def post_rename_volume(self, response: volume.Volume) -> volume.Volume: def pre_reset_instance( self, request: instance.ResetInstanceRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[instance.ResetInstanceRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[instance.ResetInstanceRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for reset_instance Override in a subclass to manipulate the request or metadata @@ -1147,8 +1216,8 @@ def post_reset_instance( def pre_resize_volume( self, request: gcb_volume.ResizeVolumeRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[gcb_volume.ResizeVolumeRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[gcb_volume.ResizeVolumeRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for resize_volume Override in a subclass to manipulate the request or metadata @@ -1170,9 +1239,10 @@ def post_resize_volume( def pre_restore_volume_snapshot( self, request: gcb_volume_snapshot.RestoreVolumeSnapshotRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ - gcb_volume_snapshot.RestoreVolumeSnapshotRequest, Sequence[Tuple[str, str]] + gcb_volume_snapshot.RestoreVolumeSnapshotRequest, + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for restore_volume_snapshot @@ -1195,8 +1265,8 @@ def post_restore_volume_snapshot( def pre_start_instance( self, request: instance.StartInstanceRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[instance.StartInstanceRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[instance.StartInstanceRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for start_instance Override in a subclass to manipulate the request or metadata @@ -1216,8 +1286,10 @@ def post_start_instance( return response def pre_stop_instance( - self, request: instance.StopInstanceRequest, metadata: Sequence[Tuple[str, str]] - ) -> Tuple[instance.StopInstanceRequest, Sequence[Tuple[str, str]]]: + self, + request: instance.StopInstanceRequest, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[instance.StopInstanceRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for stop_instance Override in a subclass to manipulate the request or metadata @@ -1239,8 +1311,11 @@ def post_stop_instance( def pre_submit_provisioning_config( self, request: provisioning.SubmitProvisioningConfigRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[provisioning.SubmitProvisioningConfigRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + provisioning.SubmitProvisioningConfigRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for submit_provisioning_config Override in a subclass to manipulate the request or metadata @@ -1262,8 +1337,10 @@ def post_submit_provisioning_config( def pre_update_instance( self, request: gcb_instance.UpdateInstanceRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[gcb_instance.UpdateInstanceRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + gcb_instance.UpdateInstanceRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for update_instance Override in a subclass to manipulate the request or metadata @@ -1285,8 +1362,10 @@ def post_update_instance( def pre_update_network( self, request: gcb_network.UpdateNetworkRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[gcb_network.UpdateNetworkRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + gcb_network.UpdateNetworkRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for update_network Override in a subclass to manipulate the request or metadata @@ -1308,8 +1387,10 @@ def post_update_network( def pre_update_nfs_share( self, request: gcb_nfs_share.UpdateNfsShareRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[gcb_nfs_share.UpdateNfsShareRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + gcb_nfs_share.UpdateNfsShareRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for update_nfs_share Override in a subclass to manipulate the request or metadata @@ -1331,8 +1412,11 @@ def post_update_nfs_share( def pre_update_provisioning_config( self, request: provisioning.UpdateProvisioningConfigRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[provisioning.UpdateProvisioningConfigRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + provisioning.UpdateProvisioningConfigRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for update_provisioning_config Override in a subclass to manipulate the request or metadata @@ -1354,8 +1438,8 @@ def post_update_provisioning_config( def pre_update_volume( self, request: gcb_volume.UpdateVolumeRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[gcb_volume.UpdateVolumeRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[gcb_volume.UpdateVolumeRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for update_volume Override in a subclass to manipulate the request or metadata @@ -1377,8 +1461,10 @@ def post_update_volume( 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 @@ -1400,8 +1486,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 @@ -1579,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]]] = (), ) -> operations_pb2.Operation: r"""Call the create nfs share method over HTTP. @@ -1589,8 +1677,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.operations_pb2.Operation: @@ -1603,6 +1693,7 @@ def __call__( http_options = ( _BaseBareMetalSolutionRestTransport._BaseCreateNfsShare._get_http_options() ) + request, metadata = self._interceptor.pre_create_nfs_share( request, metadata ) @@ -1619,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 = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.baremetalsolution_v2.BareMetalSolutionClient.CreateNfsShare", + extra={ + "serviceName": "google.cloud.baremetalsolution.v2.BareMetalSolution", + "rpcName": "CreateNfsShare", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = BareMetalSolutionRestTransport._CreateNfsShare._get_response( self._host, @@ -1638,7 +1756,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_nfs_share(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = json_format.MessageToJson(resp) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.baremetalsolution_v2.BareMetalSolutionClient.create_nfs_share", + extra={ + "serviceName": "google.cloud.baremetalsolution.v2.BareMetalSolution", + "rpcName": "CreateNfsShare", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _CreateProvisioningConfig( @@ -1677,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]]] = (), ) -> provisioning.ProvisioningConfig: r"""Call the create provisioning config method over HTTP. @@ -1688,8 +1828,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each 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.ProvisioningConfig: @@ -1699,6 +1841,7 @@ def __call__( http_options = ( _BaseBareMetalSolutionRestTransport._BaseCreateProvisioningConfig._get_http_options() ) + request, metadata = self._interceptor.pre_create_provisioning_config( request, metadata ) @@ -1715,6 +1858,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.baremetalsolution_v2.BareMetalSolutionClient.CreateProvisioningConfig", + extra={ + "serviceName": "google.cloud.baremetalsolution.v2.BareMetalSolution", + "rpcName": "CreateProvisioningConfig", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ( BareMetalSolutionRestTransport._CreateProvisioningConfig._get_response( @@ -1738,7 +1908,29 @@ def __call__( pb_resp = provisioning.ProvisioningConfig.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_create_provisioning_config(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = provisioning.ProvisioningConfig.to_json(response) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.baremetalsolution_v2.BareMetalSolutionClient.create_provisioning_config", + extra={ + "serviceName": "google.cloud.baremetalsolution.v2.BareMetalSolution", + "rpcName": "CreateProvisioningConfig", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _CreateSSHKey( @@ -1776,7 +1968,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> gcb_ssh_key.SSHKey: r"""Call the create ssh key method over HTTP. @@ -1787,8 +1979,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.gcb_ssh_key.SSHKey: @@ -1800,6 +1994,7 @@ def __call__( http_options = ( _BaseBareMetalSolutionRestTransport._BaseCreateSSHKey._get_http_options() ) + request, metadata = self._interceptor.pre_create_ssh_key(request, metadata) transcoded_request = _BaseBareMetalSolutionRestTransport._BaseCreateSSHKey._get_transcoded_request( http_options, request @@ -1814,6 +2009,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.baremetalsolution_v2.BareMetalSolutionClient.CreateSSHKey", + extra={ + "serviceName": "google.cloud.baremetalsolution.v2.BareMetalSolution", + "rpcName": "CreateSSHKey", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = BareMetalSolutionRestTransport._CreateSSHKey._get_response( self._host, @@ -1835,7 +2057,29 @@ def __call__( pb_resp = gcb_ssh_key.SSHKey.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_create_ssh_key(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = gcb_ssh_key.SSHKey.to_json(response) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.baremetalsolution_v2.BareMetalSolutionClient.create_ssh_key", + extra={ + "serviceName": "google.cloud.baremetalsolution.v2.BareMetalSolution", + "rpcName": "CreateSSHKey", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _CreateVolumeSnapshot( @@ -1874,7 +2118,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> gcb_volume_snapshot.VolumeSnapshot: r"""Call the create volume snapshot method over HTTP. @@ -1885,8 +2129,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.gcb_volume_snapshot.VolumeSnapshot: @@ -1898,6 +2144,7 @@ def __call__( http_options = ( _BaseBareMetalSolutionRestTransport._BaseCreateVolumeSnapshot._get_http_options() ) + request, metadata = self._interceptor.pre_create_volume_snapshot( request, metadata ) @@ -1914,6 +2161,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.baremetalsolution_v2.BareMetalSolutionClient.CreateVolumeSnapshot", + extra={ + "serviceName": "google.cloud.baremetalsolution.v2.BareMetalSolution", + "rpcName": "CreateVolumeSnapshot", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ( BareMetalSolutionRestTransport._CreateVolumeSnapshot._get_response( @@ -1937,7 +2211,31 @@ def __call__( pb_resp = gcb_volume_snapshot.VolumeSnapshot.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_create_volume_snapshot(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = gcb_volume_snapshot.VolumeSnapshot.to_json( + response + ) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.baremetalsolution_v2.BareMetalSolutionClient.create_volume_snapshot", + extra={ + "serviceName": "google.cloud.baremetalsolution.v2.BareMetalSolution", + "rpcName": "CreateVolumeSnapshot", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _DeleteNfsShare( @@ -1975,7 +2273,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.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 nfs share method over HTTP. @@ -1985,8 +2283,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.operations_pb2.Operation: @@ -1999,6 +2299,7 @@ def __call__( http_options = ( _BaseBareMetalSolutionRestTransport._BaseDeleteNfsShare._get_http_options() ) + request, metadata = self._interceptor.pre_delete_nfs_share( request, metadata ) @@ -2011,6 +2312,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.baremetalsolution_v2.BareMetalSolutionClient.DeleteNfsShare", + extra={ + "serviceName": "google.cloud.baremetalsolution.v2.BareMetalSolution", + "rpcName": "DeleteNfsShare", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = BareMetalSolutionRestTransport._DeleteNfsShare._get_response( self._host, @@ -2029,7 +2357,29 @@ def __call__( # Return the response resp = operations_pb2.Operation() json_format.Parse(response.content, resp, ignore_unknown_fields=True) + resp = self._interceptor.post_delete_nfs_share(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = json_format.MessageToJson(resp) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.baremetalsolution_v2.BareMetalSolutionClient.delete_nfs_share", + extra={ + "serviceName": "google.cloud.baremetalsolution.v2.BareMetalSolution", + "rpcName": "DeleteNfsShare", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _DeleteSSHKey( @@ -2066,7 +2416,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ): r"""Call the delete ssh key method over HTTP. @@ -2077,13 +2427,16 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. """ http_options = ( _BaseBareMetalSolutionRestTransport._BaseDeleteSSHKey._get_http_options() ) + request, metadata = self._interceptor.pre_delete_ssh_key(request, metadata) transcoded_request = _BaseBareMetalSolutionRestTransport._BaseDeleteSSHKey._get_transcoded_request( http_options, request @@ -2094,6 +2447,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.baremetalsolution_v2.BareMetalSolutionClient.DeleteSSHKey", + extra={ + "serviceName": "google.cloud.baremetalsolution.v2.BareMetalSolution", + "rpcName": "DeleteSSHKey", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = BareMetalSolutionRestTransport._DeleteSSHKey._get_response( self._host, @@ -2144,7 +2524,7 @@ 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 volume snapshot method over HTTP. @@ -2155,13 +2535,16 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. """ http_options = ( _BaseBareMetalSolutionRestTransport._BaseDeleteVolumeSnapshot._get_http_options() ) + request, metadata = self._interceptor.pre_delete_volume_snapshot( request, metadata ) @@ -2174,6 +2557,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.baremetalsolution_v2.BareMetalSolutionClient.DeleteVolumeSnapshot", + extra={ + "serviceName": "google.cloud.baremetalsolution.v2.BareMetalSolution", + "rpcName": "DeleteVolumeSnapshot", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ( BareMetalSolutionRestTransport._DeleteVolumeSnapshot._get_response( @@ -2226,7 +2636,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Call the detach lun method over HTTP. @@ -2237,8 +2647,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.operations_pb2.Operation: @@ -2251,6 +2663,7 @@ def __call__( http_options = ( _BaseBareMetalSolutionRestTransport._BaseDetachLun._get_http_options() ) + request, metadata = self._interceptor.pre_detach_lun(request, metadata) transcoded_request = _BaseBareMetalSolutionRestTransport._BaseDetachLun._get_transcoded_request( http_options, request @@ -2265,6 +2678,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.baremetalsolution_v2.BareMetalSolutionClient.DetachLun", + extra={ + "serviceName": "google.cloud.baremetalsolution.v2.BareMetalSolution", + "rpcName": "DetachLun", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = BareMetalSolutionRestTransport._DetachLun._get_response( self._host, @@ -2284,7 +2724,29 @@ def __call__( # Return the response resp = operations_pb2.Operation() json_format.Parse(response.content, resp, ignore_unknown_fields=True) + resp = self._interceptor.post_detach_lun(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = json_format.MessageToJson(resp) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.baremetalsolution_v2.BareMetalSolutionClient.detach_lun", + extra={ + "serviceName": "google.cloud.baremetalsolution.v2.BareMetalSolution", + "rpcName": "DetachLun", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _DisableInteractiveSerialConsole( @@ -2325,7 +2787,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Call the disable interactive serial console method over HTTP. @@ -2337,8 +2799,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.operations_pb2.Operation: @@ -2351,6 +2815,7 @@ def __call__( http_options = ( _BaseBareMetalSolutionRestTransport._BaseDisableInteractiveSerialConsole._get_http_options() ) + ( request, metadata, @@ -2370,6 +2835,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.baremetalsolution_v2.BareMetalSolutionClient.DisableInteractiveSerialConsole", + extra={ + "serviceName": "google.cloud.baremetalsolution.v2.BareMetalSolution", + "rpcName": "DisableInteractiveSerialConsole", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = BareMetalSolutionRestTransport._DisableInteractiveSerialConsole._get_response( self._host, @@ -2389,7 +2881,29 @@ def __call__( # Return the response resp = operations_pb2.Operation() json_format.Parse(response.content, resp, ignore_unknown_fields=True) + resp = self._interceptor.post_disable_interactive_serial_console(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = json_format.MessageToJson(resp) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.baremetalsolution_v2.BareMetalSolutionClient.disable_interactive_serial_console", + extra={ + "serviceName": "google.cloud.baremetalsolution.v2.BareMetalSolution", + "rpcName": "DisableInteractiveSerialConsole", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _EnableInteractiveSerialConsole( @@ -2428,7 +2942,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Call the enable interactive serial console method over HTTP. @@ -2440,8 +2954,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.operations_pb2.Operation: @@ -2454,6 +2970,7 @@ def __call__( http_options = ( _BaseBareMetalSolutionRestTransport._BaseEnableInteractiveSerialConsole._get_http_options() ) + request, metadata = self._interceptor.pre_enable_interactive_serial_console( request, metadata ) @@ -2470,6 +2987,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.baremetalsolution_v2.BareMetalSolutionClient.EnableInteractiveSerialConsole", + extra={ + "serviceName": "google.cloud.baremetalsolution.v2.BareMetalSolution", + "rpcName": "EnableInteractiveSerialConsole", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = BareMetalSolutionRestTransport._EnableInteractiveSerialConsole._get_response( self._host, @@ -2489,7 +3033,29 @@ def __call__( # Return the response resp = operations_pb2.Operation() json_format.Parse(response.content, resp, ignore_unknown_fields=True) + resp = self._interceptor.post_enable_interactive_serial_console(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = json_format.MessageToJson(resp) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.baremetalsolution_v2.BareMetalSolutionClient.enable_interactive_serial_console", + extra={ + "serviceName": "google.cloud.baremetalsolution.v2.BareMetalSolution", + "rpcName": "EnableInteractiveSerialConsole", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _EvictLun( @@ -2527,7 +3093,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Call the evict lun method over HTTP. @@ -2538,8 +3104,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.operations_pb2.Operation: @@ -2552,6 +3120,7 @@ def __call__( http_options = ( _BaseBareMetalSolutionRestTransport._BaseEvictLun._get_http_options() ) + request, metadata = self._interceptor.pre_evict_lun(request, metadata) transcoded_request = _BaseBareMetalSolutionRestTransport._BaseEvictLun._get_transcoded_request( http_options, request @@ -2566,6 +3135,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.baremetalsolution_v2.BareMetalSolutionClient.EvictLun", + extra={ + "serviceName": "google.cloud.baremetalsolution.v2.BareMetalSolution", + "rpcName": "EvictLun", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = BareMetalSolutionRestTransport._EvictLun._get_response( self._host, @@ -2585,7 +3181,29 @@ def __call__( # Return the response resp = operations_pb2.Operation() json_format.Parse(response.content, resp, ignore_unknown_fields=True) + resp = self._interceptor.post_evict_lun(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = json_format.MessageToJson(resp) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.baremetalsolution_v2.BareMetalSolutionClient.evict_lun", + extra={ + "serviceName": "google.cloud.baremetalsolution.v2.BareMetalSolution", + "rpcName": "EvictLun", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _EvictVolume( @@ -2623,7 +3241,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Call the evict volume method over HTTP. @@ -2634,8 +3252,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.operations_pb2.Operation: @@ -2648,6 +3268,7 @@ def __call__( http_options = ( _BaseBareMetalSolutionRestTransport._BaseEvictVolume._get_http_options() ) + request, metadata = self._interceptor.pre_evict_volume(request, metadata) transcoded_request = _BaseBareMetalSolutionRestTransport._BaseEvictVolume._get_transcoded_request( http_options, request @@ -2662,6 +3283,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.baremetalsolution_v2.BareMetalSolutionClient.EvictVolume", + extra={ + "serviceName": "google.cloud.baremetalsolution.v2.BareMetalSolution", + "rpcName": "EvictVolume", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = BareMetalSolutionRestTransport._EvictVolume._get_response( self._host, @@ -2681,7 +3329,29 @@ def __call__( # Return the response resp = operations_pb2.Operation() json_format.Parse(response.content, resp, ignore_unknown_fields=True) + resp = self._interceptor.post_evict_volume(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = json_format.MessageToJson(resp) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.baremetalsolution_v2.BareMetalSolutionClient.evict_volume", + extra={ + "serviceName": "google.cloud.baremetalsolution.v2.BareMetalSolution", + "rpcName": "EvictVolume", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _GetInstance( @@ -2718,7 +3388,7 @@ 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. @@ -2729,8 +3399,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each 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: @@ -2740,6 +3412,7 @@ def __call__( http_options = ( _BaseBareMetalSolutionRestTransport._BaseGetInstance._get_http_options() ) + request, metadata = self._interceptor.pre_get_instance(request, metadata) transcoded_request = _BaseBareMetalSolutionRestTransport._BaseGetInstance._get_transcoded_request( http_options, request @@ -2750,6 +3423,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.baremetalsolution_v2.BareMetalSolutionClient.GetInstance", + extra={ + "serviceName": "google.cloud.baremetalsolution.v2.BareMetalSolution", + "rpcName": "GetInstance", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = BareMetalSolutionRestTransport._GetInstance._get_response( self._host, @@ -2770,7 +3470,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.cloud.baremetalsolution_v2.BareMetalSolutionClient.get_instance", + extra={ + "serviceName": "google.cloud.baremetalsolution.v2.BareMetalSolution", + "rpcName": "GetInstance", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _GetLun( @@ -2807,7 +3529,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> lun.Lun: r"""Call the get lun method over HTTP. @@ -2818,8 +3540,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.lun.Lun: @@ -2831,6 +3555,7 @@ def __call__( http_options = ( _BaseBareMetalSolutionRestTransport._BaseGetLun._get_http_options() ) + request, metadata = self._interceptor.pre_get_lun(request, metadata) transcoded_request = ( _BaseBareMetalSolutionRestTransport._BaseGetLun._get_transcoded_request( @@ -2845,6 +3570,33 @@ def __call__( ) ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.baremetalsolution_v2.BareMetalSolutionClient.GetLun", + extra={ + "serviceName": "google.cloud.baremetalsolution.v2.BareMetalSolution", + "rpcName": "GetLun", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = BareMetalSolutionRestTransport._GetLun._get_response( self._host, @@ -2865,7 +3617,29 @@ def __call__( pb_resp = lun.Lun.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_lun(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = lun.Lun.to_json(response) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.baremetalsolution_v2.BareMetalSolutionClient.get_lun", + extra={ + "serviceName": "google.cloud.baremetalsolution.v2.BareMetalSolution", + "rpcName": "GetLun", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _GetNetwork( @@ -2902,7 +3676,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> network.Network: r"""Call the get network method over HTTP. @@ -2913,8 +3687,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.network.Network: @@ -2924,6 +3700,7 @@ def __call__( http_options = ( _BaseBareMetalSolutionRestTransport._BaseGetNetwork._get_http_options() ) + request, metadata = self._interceptor.pre_get_network(request, metadata) transcoded_request = _BaseBareMetalSolutionRestTransport._BaseGetNetwork._get_transcoded_request( http_options, request @@ -2934,6 +3711,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.baremetalsolution_v2.BareMetalSolutionClient.GetNetwork", + extra={ + "serviceName": "google.cloud.baremetalsolution.v2.BareMetalSolution", + "rpcName": "GetNetwork", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = BareMetalSolutionRestTransport._GetNetwork._get_response( self._host, @@ -2954,7 +3758,29 @@ def __call__( pb_resp = network.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.Network.to_json(response) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.baremetalsolution_v2.BareMetalSolutionClient.get_network", + extra={ + "serviceName": "google.cloud.baremetalsolution.v2.BareMetalSolution", + "rpcName": "GetNetwork", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _GetNfsShare( @@ -2991,7 +3817,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> nfs_share.NfsShare: r"""Call the get nfs share method over HTTP. @@ -3002,8 +3828,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.nfs_share.NfsShare: @@ -3013,6 +3841,7 @@ def __call__( http_options = ( _BaseBareMetalSolutionRestTransport._BaseGetNfsShare._get_http_options() ) + request, metadata = self._interceptor.pre_get_nfs_share(request, metadata) transcoded_request = _BaseBareMetalSolutionRestTransport._BaseGetNfsShare._get_transcoded_request( http_options, request @@ -3023,6 +3852,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.baremetalsolution_v2.BareMetalSolutionClient.GetNfsShare", + extra={ + "serviceName": "google.cloud.baremetalsolution.v2.BareMetalSolution", + "rpcName": "GetNfsShare", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = BareMetalSolutionRestTransport._GetNfsShare._get_response( self._host, @@ -3043,7 +3899,29 @@ def __call__( pb_resp = nfs_share.NfsShare.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_nfs_share(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = nfs_share.NfsShare.to_json(response) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.baremetalsolution_v2.BareMetalSolutionClient.get_nfs_share", + extra={ + "serviceName": "google.cloud.baremetalsolution.v2.BareMetalSolution", + "rpcName": "GetNfsShare", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _GetProvisioningConfig( @@ -3081,7 +3959,7 @@ 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.ProvisioningConfig: r"""Call the get provisioning config method over HTTP. @@ -3091,8 +3969,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each 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.ProvisioningConfig: @@ -3102,6 +3982,7 @@ def __call__( http_options = ( _BaseBareMetalSolutionRestTransport._BaseGetProvisioningConfig._get_http_options() ) + request, metadata = self._interceptor.pre_get_provisioning_config( request, metadata ) @@ -3114,6 +3995,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.baremetalsolution_v2.BareMetalSolutionClient.GetProvisioningConfig", + extra={ + "serviceName": "google.cloud.baremetalsolution.v2.BareMetalSolution", + "rpcName": "GetProvisioningConfig", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ( BareMetalSolutionRestTransport._GetProvisioningConfig._get_response( @@ -3136,7 +4044,29 @@ def __call__( pb_resp = provisioning.ProvisioningConfig.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_provisioning_config(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = provisioning.ProvisioningConfig.to_json(response) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.baremetalsolution_v2.BareMetalSolutionClient.get_provisioning_config", + extra={ + "serviceName": "google.cloud.baremetalsolution.v2.BareMetalSolution", + "rpcName": "GetProvisioningConfig", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _GetVolume( @@ -3173,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]]] = (), ) -> volume.Volume: r"""Call the get volume method over HTTP. @@ -3184,8 +4114,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.volume.Volume: @@ -3195,6 +4127,7 @@ def __call__( http_options = ( _BaseBareMetalSolutionRestTransport._BaseGetVolume._get_http_options() ) + request, metadata = self._interceptor.pre_get_volume(request, metadata) transcoded_request = _BaseBareMetalSolutionRestTransport._BaseGetVolume._get_transcoded_request( http_options, request @@ -3205,6 +4138,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.baremetalsolution_v2.BareMetalSolutionClient.GetVolume", + extra={ + "serviceName": "google.cloud.baremetalsolution.v2.BareMetalSolution", + "rpcName": "GetVolume", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = BareMetalSolutionRestTransport._GetVolume._get_response( self._host, @@ -3225,7 +4185,29 @@ def __call__( pb_resp = volume.Volume.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_volume(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = volume.Volume.to_json(response) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.baremetalsolution_v2.BareMetalSolutionClient.get_volume", + extra={ + "serviceName": "google.cloud.baremetalsolution.v2.BareMetalSolution", + "rpcName": "GetVolume", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _GetVolumeSnapshot( @@ -3263,7 +4245,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> volume_snapshot.VolumeSnapshot: r"""Call the get volume snapshot method over HTTP. @@ -3274,8 +4256,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.volume_snapshot.VolumeSnapshot: @@ -3287,6 +4271,7 @@ def __call__( http_options = ( _BaseBareMetalSolutionRestTransport._BaseGetVolumeSnapshot._get_http_options() ) + request, metadata = self._interceptor.pre_get_volume_snapshot( request, metadata ) @@ -3299,6 +4284,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.baremetalsolution_v2.BareMetalSolutionClient.GetVolumeSnapshot", + extra={ + "serviceName": "google.cloud.baremetalsolution.v2.BareMetalSolution", + "rpcName": "GetVolumeSnapshot", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = BareMetalSolutionRestTransport._GetVolumeSnapshot._get_response( self._host, @@ -3319,7 +4331,29 @@ def __call__( pb_resp = volume_snapshot.VolumeSnapshot.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_volume_snapshot(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = volume_snapshot.VolumeSnapshot.to_json(response) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.baremetalsolution_v2.BareMetalSolutionClient.get_volume_snapshot", + extra={ + "serviceName": "google.cloud.baremetalsolution.v2.BareMetalSolution", + "rpcName": "GetVolumeSnapshot", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ListInstances( @@ -3357,7 +4391,7 @@ 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.ListInstancesResponse: r"""Call the list instances method over HTTP. @@ -3368,8 +4402,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each 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.ListInstancesResponse: @@ -3381,6 +4417,7 @@ def __call__( http_options = ( _BaseBareMetalSolutionRestTransport._BaseListInstances._get_http_options() ) + request, metadata = self._interceptor.pre_list_instances(request, metadata) transcoded_request = _BaseBareMetalSolutionRestTransport._BaseListInstances._get_transcoded_request( http_options, request @@ -3391,6 +4428,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.baremetalsolution_v2.BareMetalSolutionClient.ListInstances", + extra={ + "serviceName": "google.cloud.baremetalsolution.v2.BareMetalSolution", + "rpcName": "ListInstances", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = BareMetalSolutionRestTransport._ListInstances._get_response( self._host, @@ -3411,7 +4475,29 @@ def __call__( pb_resp = instance.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 = instance.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.baremetalsolution_v2.BareMetalSolutionClient.list_instances", + extra={ + "serviceName": "google.cloud.baremetalsolution.v2.BareMetalSolution", + "rpcName": "ListInstances", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ListLuns( @@ -3448,7 +4534,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> lun.ListLunsResponse: r"""Call the list luns method over HTTP. @@ -3459,8 +4545,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.lun.ListLunsResponse: @@ -3472,6 +4560,7 @@ def __call__( http_options = ( _BaseBareMetalSolutionRestTransport._BaseListLuns._get_http_options() ) + request, metadata = self._interceptor.pre_list_luns(request, metadata) transcoded_request = _BaseBareMetalSolutionRestTransport._BaseListLuns._get_transcoded_request( http_options, request @@ -3482,6 +4571,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.baremetalsolution_v2.BareMetalSolutionClient.ListLuns", + extra={ + "serviceName": "google.cloud.baremetalsolution.v2.BareMetalSolution", + "rpcName": "ListLuns", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = BareMetalSolutionRestTransport._ListLuns._get_response( self._host, @@ -3502,7 +4618,29 @@ def __call__( pb_resp = lun.ListLunsResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_luns(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = lun.ListLunsResponse.to_json(response) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.baremetalsolution_v2.BareMetalSolutionClient.list_luns", + extra={ + "serviceName": "google.cloud.baremetalsolution.v2.BareMetalSolution", + "rpcName": "ListLuns", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ListNetworks( @@ -3539,7 +4677,7 @@ 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.ListNetworksResponse: r"""Call the list networks method over HTTP. @@ -3550,8 +4688,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each 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.ListNetworksResponse: @@ -3563,6 +4703,7 @@ def __call__( http_options = ( _BaseBareMetalSolutionRestTransport._BaseListNetworks._get_http_options() ) + request, metadata = self._interceptor.pre_list_networks(request, metadata) transcoded_request = _BaseBareMetalSolutionRestTransport._BaseListNetworks._get_transcoded_request( http_options, request @@ -3573,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.cloud.baremetalsolution_v2.BareMetalSolutionClient.ListNetworks", + extra={ + "serviceName": "google.cloud.baremetalsolution.v2.BareMetalSolution", + "rpcName": "ListNetworks", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = BareMetalSolutionRestTransport._ListNetworks._get_response( self._host, @@ -3593,7 +4761,29 @@ def __call__( pb_resp = network.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.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.cloud.baremetalsolution_v2.BareMetalSolutionClient.list_networks", + extra={ + "serviceName": "google.cloud.baremetalsolution.v2.BareMetalSolution", + "rpcName": "ListNetworks", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ListNetworkUsage( @@ -3631,7 +4821,7 @@ 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.ListNetworkUsageResponse: r"""Call the list network usage method over HTTP. @@ -3641,8 +4831,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each 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.ListNetworkUsageResponse: @@ -3652,6 +4844,7 @@ def __call__( http_options = ( _BaseBareMetalSolutionRestTransport._BaseListNetworkUsage._get_http_options() ) + request, metadata = self._interceptor.pre_list_network_usage( request, metadata ) @@ -3664,6 +4857,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.baremetalsolution_v2.BareMetalSolutionClient.ListNetworkUsage", + extra={ + "serviceName": "google.cloud.baremetalsolution.v2.BareMetalSolution", + "rpcName": "ListNetworkUsage", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = BareMetalSolutionRestTransport._ListNetworkUsage._get_response( self._host, @@ -3684,7 +4904,31 @@ def __call__( pb_resp = network.ListNetworkUsageResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_network_usage(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = network.ListNetworkUsageResponse.to_json( + response + ) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.baremetalsolution_v2.BareMetalSolutionClient.list_network_usage", + extra={ + "serviceName": "google.cloud.baremetalsolution.v2.BareMetalSolution", + "rpcName": "ListNetworkUsage", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ListNfsShares( @@ -3722,7 +4966,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> nfs_share.ListNfsSharesResponse: r"""Call the list nfs shares method over HTTP. @@ -3733,8 +4977,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.nfs_share.ListNfsSharesResponse: @@ -3746,6 +4992,7 @@ def __call__( http_options = ( _BaseBareMetalSolutionRestTransport._BaseListNfsShares._get_http_options() ) + request, metadata = self._interceptor.pre_list_nfs_shares(request, metadata) transcoded_request = _BaseBareMetalSolutionRestTransport._BaseListNfsShares._get_transcoded_request( http_options, request @@ -3756,6 +5003,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.baremetalsolution_v2.BareMetalSolutionClient.ListNfsShares", + extra={ + "serviceName": "google.cloud.baremetalsolution.v2.BareMetalSolution", + "rpcName": "ListNfsShares", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = BareMetalSolutionRestTransport._ListNfsShares._get_response( self._host, @@ -3776,7 +5050,29 @@ def __call__( pb_resp = nfs_share.ListNfsSharesResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_nfs_shares(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = nfs_share.ListNfsSharesResponse.to_json(response) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.baremetalsolution_v2.BareMetalSolutionClient.list_nfs_shares", + extra={ + "serviceName": "google.cloud.baremetalsolution.v2.BareMetalSolution", + "rpcName": "ListNfsShares", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ListOSImages( @@ -3813,7 +5109,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> osimage.ListOSImagesResponse: r"""Call the list os images method over HTTP. @@ -3824,8 +5120,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.osimage.ListOSImagesResponse: @@ -3837,6 +5135,7 @@ def __call__( http_options = ( _BaseBareMetalSolutionRestTransport._BaseListOSImages._get_http_options() ) + request, metadata = self._interceptor.pre_list_os_images(request, metadata) transcoded_request = _BaseBareMetalSolutionRestTransport._BaseListOSImages._get_transcoded_request( http_options, request @@ -3847,6 +5146,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.baremetalsolution_v2.BareMetalSolutionClient.ListOSImages", + extra={ + "serviceName": "google.cloud.baremetalsolution.v2.BareMetalSolution", + "rpcName": "ListOSImages", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = BareMetalSolutionRestTransport._ListOSImages._get_response( self._host, @@ -3867,7 +5193,29 @@ def __call__( pb_resp = osimage.ListOSImagesResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_os_images(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = osimage.ListOSImagesResponse.to_json(response) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.baremetalsolution_v2.BareMetalSolutionClient.list_os_images", + extra={ + "serviceName": "google.cloud.baremetalsolution.v2.BareMetalSolution", + "rpcName": "ListOSImages", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ListProvisioningQuotas( @@ -3905,7 +5253,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> provisioning.ListProvisioningQuotasResponse: r"""Call the list provisioning quotas method over HTTP. @@ -3916,8 +5264,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each 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.ListProvisioningQuotasResponse: @@ -3929,6 +5279,7 @@ def __call__( http_options = ( _BaseBareMetalSolutionRestTransport._BaseListProvisioningQuotas._get_http_options() ) + request, metadata = self._interceptor.pre_list_provisioning_quotas( request, metadata ) @@ -3941,6 +5292,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.baremetalsolution_v2.BareMetalSolutionClient.ListProvisioningQuotas", + extra={ + "serviceName": "google.cloud.baremetalsolution.v2.BareMetalSolution", + "rpcName": "ListProvisioningQuotas", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ( BareMetalSolutionRestTransport._ListProvisioningQuotas._get_response( @@ -3963,7 +5341,31 @@ def __call__( pb_resp = provisioning.ListProvisioningQuotasResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_provisioning_quotas(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = ( + provisioning.ListProvisioningQuotasResponse.to_json(response) + ) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.baremetalsolution_v2.BareMetalSolutionClient.list_provisioning_quotas", + extra={ + "serviceName": "google.cloud.baremetalsolution.v2.BareMetalSolution", + "rpcName": "ListProvisioningQuotas", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ListSSHKeys( @@ -4000,7 +5402,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> ssh_key.ListSSHKeysResponse: r"""Call the list ssh keys method over HTTP. @@ -4011,8 +5413,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.ssh_key.ListSSHKeysResponse: @@ -4022,6 +5426,7 @@ def __call__( http_options = ( _BaseBareMetalSolutionRestTransport._BaseListSSHKeys._get_http_options() ) + request, metadata = self._interceptor.pre_list_ssh_keys(request, metadata) transcoded_request = _BaseBareMetalSolutionRestTransport._BaseListSSHKeys._get_transcoded_request( http_options, request @@ -4032,6 +5437,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.baremetalsolution_v2.BareMetalSolutionClient.ListSSHKeys", + extra={ + "serviceName": "google.cloud.baremetalsolution.v2.BareMetalSolution", + "rpcName": "ListSSHKeys", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = BareMetalSolutionRestTransport._ListSSHKeys._get_response( self._host, @@ -4052,7 +5484,29 @@ def __call__( pb_resp = ssh_key.ListSSHKeysResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_ssh_keys(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = ssh_key.ListSSHKeysResponse.to_json(response) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.baremetalsolution_v2.BareMetalSolutionClient.list_ssh_keys", + extra={ + "serviceName": "google.cloud.baremetalsolution.v2.BareMetalSolution", + "rpcName": "ListSSHKeys", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ListVolumes( @@ -4089,7 +5543,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> volume.ListVolumesResponse: r"""Call the list volumes method over HTTP. @@ -4100,8 +5554,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.volume.ListVolumesResponse: @@ -4113,6 +5569,7 @@ def __call__( http_options = ( _BaseBareMetalSolutionRestTransport._BaseListVolumes._get_http_options() ) + request, metadata = self._interceptor.pre_list_volumes(request, metadata) transcoded_request = _BaseBareMetalSolutionRestTransport._BaseListVolumes._get_transcoded_request( http_options, request @@ -4123,6 +5580,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.baremetalsolution_v2.BareMetalSolutionClient.ListVolumes", + extra={ + "serviceName": "google.cloud.baremetalsolution.v2.BareMetalSolution", + "rpcName": "ListVolumes", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = BareMetalSolutionRestTransport._ListVolumes._get_response( self._host, @@ -4143,7 +5627,29 @@ def __call__( pb_resp = volume.ListVolumesResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_volumes(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = volume.ListVolumesResponse.to_json(response) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.baremetalsolution_v2.BareMetalSolutionClient.list_volumes", + extra={ + "serviceName": "google.cloud.baremetalsolution.v2.BareMetalSolution", + "rpcName": "ListVolumes", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ListVolumeSnapshots( @@ -4181,7 +5687,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> volume_snapshot.ListVolumeSnapshotsResponse: r"""Call the list volume snapshots method over HTTP. @@ -4192,8 +5698,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.volume_snapshot.ListVolumeSnapshotsResponse: @@ -4205,6 +5713,7 @@ def __call__( http_options = ( _BaseBareMetalSolutionRestTransport._BaseListVolumeSnapshots._get_http_options() ) + request, metadata = self._interceptor.pre_list_volume_snapshots( request, metadata ) @@ -4217,6 +5726,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.baremetalsolution_v2.BareMetalSolutionClient.ListVolumeSnapshots", + extra={ + "serviceName": "google.cloud.baremetalsolution.v2.BareMetalSolution", + "rpcName": "ListVolumeSnapshots", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ( BareMetalSolutionRestTransport._ListVolumeSnapshots._get_response( @@ -4239,7 +5775,31 @@ def __call__( pb_resp = volume_snapshot.ListVolumeSnapshotsResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_volume_snapshots(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = ( + volume_snapshot.ListVolumeSnapshotsResponse.to_json(response) + ) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.baremetalsolution_v2.BareMetalSolutionClient.list_volume_snapshots", + extra={ + "serviceName": "google.cloud.baremetalsolution.v2.BareMetalSolution", + "rpcName": "ListVolumeSnapshots", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _RenameInstance( @@ -4278,7 +5838,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> instance.Instance: r"""Call the rename instance method over HTTP. @@ -4289,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: ~.instance.Instance: @@ -4300,6 +5862,7 @@ def __call__( http_options = ( _BaseBareMetalSolutionRestTransport._BaseRenameInstance._get_http_options() ) + request, metadata = self._interceptor.pre_rename_instance(request, metadata) transcoded_request = _BaseBareMetalSolutionRestTransport._BaseRenameInstance._get_transcoded_request( http_options, request @@ -4314,6 +5877,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.baremetalsolution_v2.BareMetalSolutionClient.RenameInstance", + extra={ + "serviceName": "google.cloud.baremetalsolution.v2.BareMetalSolution", + "rpcName": "RenameInstance", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = BareMetalSolutionRestTransport._RenameInstance._get_response( self._host, @@ -4335,7 +5925,29 @@ def __call__( pb_resp = instance.Instance.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_rename_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.cloud.baremetalsolution_v2.BareMetalSolutionClient.rename_instance", + extra={ + "serviceName": "google.cloud.baremetalsolution.v2.BareMetalSolution", + "rpcName": "RenameInstance", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _RenameNetwork( @@ -4374,7 +5986,7 @@ 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.Network: r"""Call the rename network method over HTTP. @@ -4385,8 +5997,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.network.Network: @@ -4396,6 +6010,7 @@ def __call__( http_options = ( _BaseBareMetalSolutionRestTransport._BaseRenameNetwork._get_http_options() ) + request, metadata = self._interceptor.pre_rename_network(request, metadata) transcoded_request = _BaseBareMetalSolutionRestTransport._BaseRenameNetwork._get_transcoded_request( http_options, request @@ -4410,6 +6025,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.baremetalsolution_v2.BareMetalSolutionClient.RenameNetwork", + extra={ + "serviceName": "google.cloud.baremetalsolution.v2.BareMetalSolution", + "rpcName": "RenameNetwork", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = BareMetalSolutionRestTransport._RenameNetwork._get_response( self._host, @@ -4431,7 +6073,29 @@ def __call__( pb_resp = network.Network.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_rename_network(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = network.Network.to_json(response) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.baremetalsolution_v2.BareMetalSolutionClient.rename_network", + extra={ + "serviceName": "google.cloud.baremetalsolution.v2.BareMetalSolution", + "rpcName": "RenameNetwork", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _RenameNfsShare( @@ -4470,7 +6134,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> nfs_share.NfsShare: r"""Call the rename nfs share method over HTTP. @@ -4481,8 +6145,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.nfs_share.NfsShare: @@ -4492,6 +6158,7 @@ def __call__( http_options = ( _BaseBareMetalSolutionRestTransport._BaseRenameNfsShare._get_http_options() ) + request, metadata = self._interceptor.pre_rename_nfs_share( request, metadata ) @@ -4508,6 +6175,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.baremetalsolution_v2.BareMetalSolutionClient.RenameNfsShare", + extra={ + "serviceName": "google.cloud.baremetalsolution.v2.BareMetalSolution", + "rpcName": "RenameNfsShare", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = BareMetalSolutionRestTransport._RenameNfsShare._get_response( self._host, @@ -4529,7 +6223,29 @@ def __call__( pb_resp = nfs_share.NfsShare.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_rename_nfs_share(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = nfs_share.NfsShare.to_json(response) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.baremetalsolution_v2.BareMetalSolutionClient.rename_nfs_share", + extra={ + "serviceName": "google.cloud.baremetalsolution.v2.BareMetalSolution", + "rpcName": "RenameNfsShare", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _RenameVolume( @@ -4567,7 +6283,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> volume.Volume: r"""Call the rename volume method over HTTP. @@ -4578,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: ~.volume.Volume: @@ -4589,6 +6307,7 @@ def __call__( http_options = ( _BaseBareMetalSolutionRestTransport._BaseRenameVolume._get_http_options() ) + request, metadata = self._interceptor.pre_rename_volume(request, metadata) transcoded_request = _BaseBareMetalSolutionRestTransport._BaseRenameVolume._get_transcoded_request( http_options, request @@ -4603,6 +6322,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.baremetalsolution_v2.BareMetalSolutionClient.RenameVolume", + extra={ + "serviceName": "google.cloud.baremetalsolution.v2.BareMetalSolution", + "rpcName": "RenameVolume", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = BareMetalSolutionRestTransport._RenameVolume._get_response( self._host, @@ -4624,7 +6370,29 @@ def __call__( pb_resp = volume.Volume.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_rename_volume(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = volume.Volume.to_json(response) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.baremetalsolution_v2.BareMetalSolutionClient.rename_volume", + extra={ + "serviceName": "google.cloud.baremetalsolution.v2.BareMetalSolution", + "rpcName": "RenameVolume", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ResetInstance( @@ -4663,7 +6431,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Call the reset instance method over HTTP. @@ -4673,8 +6441,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.operations_pb2.Operation: @@ -4687,6 +6457,7 @@ def __call__( http_options = ( _BaseBareMetalSolutionRestTransport._BaseResetInstance._get_http_options() ) + request, metadata = self._interceptor.pre_reset_instance(request, metadata) transcoded_request = _BaseBareMetalSolutionRestTransport._BaseResetInstance._get_transcoded_request( http_options, request @@ -4701,6 +6472,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.baremetalsolution_v2.BareMetalSolutionClient.ResetInstance", + extra={ + "serviceName": "google.cloud.baremetalsolution.v2.BareMetalSolution", + "rpcName": "ResetInstance", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = BareMetalSolutionRestTransport._ResetInstance._get_response( self._host, @@ -4720,7 +6518,29 @@ def __call__( # Return the response resp = operations_pb2.Operation() json_format.Parse(response.content, resp, ignore_unknown_fields=True) + resp = self._interceptor.post_reset_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.baremetalsolution_v2.BareMetalSolutionClient.reset_instance", + extra={ + "serviceName": "google.cloud.baremetalsolution.v2.BareMetalSolution", + "rpcName": "ResetInstance", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ResizeVolume( @@ -4758,7 +6578,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Call the resize volume method over HTTP. @@ -4768,8 +6588,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.operations_pb2.Operation: @@ -4782,6 +6604,7 @@ def __call__( http_options = ( _BaseBareMetalSolutionRestTransport._BaseResizeVolume._get_http_options() ) + request, metadata = self._interceptor.pre_resize_volume(request, metadata) transcoded_request = _BaseBareMetalSolutionRestTransport._BaseResizeVolume._get_transcoded_request( http_options, request @@ -4796,6 +6619,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.baremetalsolution_v2.BareMetalSolutionClient.ResizeVolume", + extra={ + "serviceName": "google.cloud.baremetalsolution.v2.BareMetalSolution", + "rpcName": "ResizeVolume", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = BareMetalSolutionRestTransport._ResizeVolume._get_response( self._host, @@ -4815,7 +6665,29 @@ def __call__( # Return the response resp = operations_pb2.Operation() json_format.Parse(response.content, resp, ignore_unknown_fields=True) + resp = self._interceptor.post_resize_volume(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = json_format.MessageToJson(resp) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.baremetalsolution_v2.BareMetalSolutionClient.resize_volume", + extra={ + "serviceName": "google.cloud.baremetalsolution.v2.BareMetalSolution", + "rpcName": "ResizeVolume", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _RestoreVolumeSnapshot( @@ -4854,7 +6726,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.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 volume snapshot method over HTTP. @@ -4865,8 +6737,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.operations_pb2.Operation: @@ -4879,6 +6753,7 @@ def __call__( http_options = ( _BaseBareMetalSolutionRestTransport._BaseRestoreVolumeSnapshot._get_http_options() ) + request, metadata = self._interceptor.pre_restore_volume_snapshot( request, metadata ) @@ -4895,6 +6770,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.baremetalsolution_v2.BareMetalSolutionClient.RestoreVolumeSnapshot", + extra={ + "serviceName": "google.cloud.baremetalsolution.v2.BareMetalSolution", + "rpcName": "RestoreVolumeSnapshot", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ( BareMetalSolutionRestTransport._RestoreVolumeSnapshot._get_response( @@ -4916,7 +6818,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_volume_snapshot(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = json_format.MessageToJson(resp) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.baremetalsolution_v2.BareMetalSolutionClient.restore_volume_snapshot", + extra={ + "serviceName": "google.cloud.baremetalsolution.v2.BareMetalSolution", + "rpcName": "RestoreVolumeSnapshot", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _StartInstance( @@ -4955,7 +6879,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Call the start instance method over HTTP. @@ -4965,8 +6889,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.operations_pb2.Operation: @@ -4979,6 +6905,7 @@ def __call__( http_options = ( _BaseBareMetalSolutionRestTransport._BaseStartInstance._get_http_options() ) + request, metadata = self._interceptor.pre_start_instance(request, metadata) transcoded_request = _BaseBareMetalSolutionRestTransport._BaseStartInstance._get_transcoded_request( http_options, request @@ -4993,6 +6920,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.baremetalsolution_v2.BareMetalSolutionClient.StartInstance", + extra={ + "serviceName": "google.cloud.baremetalsolution.v2.BareMetalSolution", + "rpcName": "StartInstance", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = BareMetalSolutionRestTransport._StartInstance._get_response( self._host, @@ -5012,7 +6966,29 @@ def __call__( # Return the response resp = operations_pb2.Operation() json_format.Parse(response.content, resp, ignore_unknown_fields=True) + resp = self._interceptor.post_start_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.baremetalsolution_v2.BareMetalSolutionClient.start_instance", + extra={ + "serviceName": "google.cloud.baremetalsolution.v2.BareMetalSolution", + "rpcName": "StartInstance", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _StopInstance( @@ -5050,7 +7026,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Call the stop instance method over HTTP. @@ -5060,8 +7036,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.operations_pb2.Operation: @@ -5074,6 +7052,7 @@ def __call__( http_options = ( _BaseBareMetalSolutionRestTransport._BaseStopInstance._get_http_options() ) + request, metadata = self._interceptor.pre_stop_instance(request, metadata) transcoded_request = _BaseBareMetalSolutionRestTransport._BaseStopInstance._get_transcoded_request( http_options, request @@ -5088,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.baremetalsolution_v2.BareMetalSolutionClient.StopInstance", + extra={ + "serviceName": "google.cloud.baremetalsolution.v2.BareMetalSolution", + "rpcName": "StopInstance", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = BareMetalSolutionRestTransport._StopInstance._get_response( self._host, @@ -5107,7 +7113,29 @@ def __call__( # Return the response resp = operations_pb2.Operation() json_format.Parse(response.content, resp, ignore_unknown_fields=True) + resp = self._interceptor.post_stop_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.baremetalsolution_v2.BareMetalSolutionClient.stop_instance", + extra={ + "serviceName": "google.cloud.baremetalsolution.v2.BareMetalSolution", + "rpcName": "StopInstance", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _SubmitProvisioningConfig( @@ -5146,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]]] = (), ) -> provisioning.SubmitProvisioningConfigResponse: r"""Call the submit provisioning config method over HTTP. @@ -5157,8 +7185,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each 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.SubmitProvisioningConfigResponse: @@ -5170,6 +7200,7 @@ def __call__( http_options = ( _BaseBareMetalSolutionRestTransport._BaseSubmitProvisioningConfig._get_http_options() ) + request, metadata = self._interceptor.pre_submit_provisioning_config( request, metadata ) @@ -5186,6 +7217,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.baremetalsolution_v2.BareMetalSolutionClient.SubmitProvisioningConfig", + extra={ + "serviceName": "google.cloud.baremetalsolution.v2.BareMetalSolution", + "rpcName": "SubmitProvisioningConfig", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ( BareMetalSolutionRestTransport._SubmitProvisioningConfig._get_response( @@ -5209,7 +7267,31 @@ def __call__( pb_resp = provisioning.SubmitProvisioningConfigResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_submit_provisioning_config(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = ( + provisioning.SubmitProvisioningConfigResponse.to_json(response) + ) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.baremetalsolution_v2.BareMetalSolutionClient.submit_provisioning_config", + extra={ + "serviceName": "google.cloud.baremetalsolution.v2.BareMetalSolution", + "rpcName": "SubmitProvisioningConfig", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _UpdateInstance( @@ -5248,7 +7330,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.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. @@ -5259,8 +7341,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.operations_pb2.Operation: @@ -5273,6 +7357,7 @@ def __call__( http_options = ( _BaseBareMetalSolutionRestTransport._BaseUpdateInstance._get_http_options() ) + request, metadata = self._interceptor.pre_update_instance(request, metadata) transcoded_request = _BaseBareMetalSolutionRestTransport._BaseUpdateInstance._get_transcoded_request( http_options, request @@ -5287,6 +7372,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.baremetalsolution_v2.BareMetalSolutionClient.UpdateInstance", + extra={ + "serviceName": "google.cloud.baremetalsolution.v2.BareMetalSolution", + "rpcName": "UpdateInstance", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = BareMetalSolutionRestTransport._UpdateInstance._get_response( self._host, @@ -5306,7 +7418,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.baremetalsolution_v2.BareMetalSolutionClient.update_instance", + extra={ + "serviceName": "google.cloud.baremetalsolution.v2.BareMetalSolution", + "rpcName": "UpdateInstance", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _UpdateNetwork( @@ -5345,7 +7479,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Call the update network method over HTTP. @@ -5356,8 +7490,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.operations_pb2.Operation: @@ -5370,6 +7506,7 @@ def __call__( http_options = ( _BaseBareMetalSolutionRestTransport._BaseUpdateNetwork._get_http_options() ) + request, metadata = self._interceptor.pre_update_network(request, metadata) transcoded_request = _BaseBareMetalSolutionRestTransport._BaseUpdateNetwork._get_transcoded_request( http_options, request @@ -5384,6 +7521,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.baremetalsolution_v2.BareMetalSolutionClient.UpdateNetwork", + extra={ + "serviceName": "google.cloud.baremetalsolution.v2.BareMetalSolution", + "rpcName": "UpdateNetwork", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = BareMetalSolutionRestTransport._UpdateNetwork._get_response( self._host, @@ -5403,7 +7567,29 @@ def __call__( # Return the response resp = operations_pb2.Operation() json_format.Parse(response.content, resp, ignore_unknown_fields=True) + resp = self._interceptor.post_update_network(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = json_format.MessageToJson(resp) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.baremetalsolution_v2.BareMetalSolutionClient.update_network", + extra={ + "serviceName": "google.cloud.baremetalsolution.v2.BareMetalSolution", + "rpcName": "UpdateNetwork", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _UpdateNfsShare( @@ -5442,7 +7628,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.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 nfs share method over HTTP. @@ -5453,8 +7639,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.operations_pb2.Operation: @@ -5467,6 +7655,7 @@ def __call__( http_options = ( _BaseBareMetalSolutionRestTransport._BaseUpdateNfsShare._get_http_options() ) + request, metadata = self._interceptor.pre_update_nfs_share( request, metadata ) @@ -5483,6 +7672,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.baremetalsolution_v2.BareMetalSolutionClient.UpdateNfsShare", + extra={ + "serviceName": "google.cloud.baremetalsolution.v2.BareMetalSolution", + "rpcName": "UpdateNfsShare", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = BareMetalSolutionRestTransport._UpdateNfsShare._get_response( self._host, @@ -5502,7 +7718,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_nfs_share(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = json_format.MessageToJson(resp) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.baremetalsolution_v2.BareMetalSolutionClient.update_nfs_share", + extra={ + "serviceName": "google.cloud.baremetalsolution.v2.BareMetalSolution", + "rpcName": "UpdateNfsShare", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _UpdateProvisioningConfig( @@ -5541,7 +7779,7 @@ 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.ProvisioningConfig: r"""Call the update provisioning config method over HTTP. @@ -5553,8 +7791,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each 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.ProvisioningConfig: @@ -5564,6 +7804,7 @@ def __call__( http_options = ( _BaseBareMetalSolutionRestTransport._BaseUpdateProvisioningConfig._get_http_options() ) + request, metadata = self._interceptor.pre_update_provisioning_config( request, metadata ) @@ -5580,6 +7821,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.baremetalsolution_v2.BareMetalSolutionClient.UpdateProvisioningConfig", + extra={ + "serviceName": "google.cloud.baremetalsolution.v2.BareMetalSolution", + "rpcName": "UpdateProvisioningConfig", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ( BareMetalSolutionRestTransport._UpdateProvisioningConfig._get_response( @@ -5603,7 +7871,29 @@ def __call__( pb_resp = provisioning.ProvisioningConfig.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_update_provisioning_config(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = provisioning.ProvisioningConfig.to_json(response) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.baremetalsolution_v2.BareMetalSolutionClient.update_provisioning_config", + extra={ + "serviceName": "google.cloud.baremetalsolution.v2.BareMetalSolution", + "rpcName": "UpdateProvisioningConfig", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _UpdateVolume( @@ -5641,7 +7931,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.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 volume method over HTTP. @@ -5651,8 +7941,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.operations_pb2.Operation: @@ -5665,6 +7957,7 @@ def __call__( http_options = ( _BaseBareMetalSolutionRestTransport._BaseUpdateVolume._get_http_options() ) + request, metadata = self._interceptor.pre_update_volume(request, metadata) transcoded_request = _BaseBareMetalSolutionRestTransport._BaseUpdateVolume._get_transcoded_request( http_options, request @@ -5679,6 +7972,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.baremetalsolution_v2.BareMetalSolutionClient.UpdateVolume", + extra={ + "serviceName": "google.cloud.baremetalsolution.v2.BareMetalSolution", + "rpcName": "UpdateVolume", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = BareMetalSolutionRestTransport._UpdateVolume._get_response( self._host, @@ -5698,7 +8018,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_volume(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = json_format.MessageToJson(resp) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.baremetalsolution_v2.BareMetalSolutionClient.update_volume", + extra={ + "serviceName": "google.cloud.baremetalsolution.v2.BareMetalSolution", + "rpcName": "UpdateVolume", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp @property @@ -6105,7 +8447,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> locations_pb2.Location: r"""Call the get location method over HTTP. @@ -6115,8 +8457,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each 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. @@ -6125,6 +8469,7 @@ def __call__( http_options = ( _BaseBareMetalSolutionRestTransport._BaseGetLocation._get_http_options() ) + request, metadata = self._interceptor.pre_get_location(request, metadata) transcoded_request = _BaseBareMetalSolutionRestTransport._BaseGetLocation._get_transcoded_request( http_options, request @@ -6135,6 +8480,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.baremetalsolution_v2.BareMetalSolutionClient.GetLocation", + extra={ + "serviceName": "google.cloud.baremetalsolution.v2.BareMetalSolution", + "rpcName": "GetLocation", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = BareMetalSolutionRestTransport._GetLocation._get_response( self._host, @@ -6154,6 +8526,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.baremetalsolution_v2.BareMetalSolutionAsyncClient.GetLocation", + extra={ + "serviceName": "google.cloud.baremetalsolution.v2.BareMetalSolution", + "rpcName": "GetLocation", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property @@ -6195,7 +8588,7 @@ 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. @@ -6205,8 +8598,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each 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. @@ -6215,6 +8610,7 @@ def __call__( http_options = ( _BaseBareMetalSolutionRestTransport._BaseListLocations._get_http_options() ) + request, metadata = self._interceptor.pre_list_locations(request, metadata) transcoded_request = _BaseBareMetalSolutionRestTransport._BaseListLocations._get_transcoded_request( http_options, request @@ -6225,6 +8621,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.baremetalsolution_v2.BareMetalSolutionClient.ListLocations", + extra={ + "serviceName": "google.cloud.baremetalsolution.v2.BareMetalSolution", + "rpcName": "ListLocations", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = BareMetalSolutionRestTransport._ListLocations._get_response( self._host, @@ -6244,6 +8667,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.baremetalsolution_v2.BareMetalSolutionAsyncClient.ListLocations", + extra={ + "serviceName": "google.cloud.baremetalsolution.v2.BareMetalSolution", + "rpcName": "ListLocations", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property diff --git a/packages/google-cloud-bare-metal-solution/samples/generated_samples/snippet_metadata_google.cloud.baremetalsolution.v2.json b/packages/google-cloud-bare-metal-solution/samples/generated_samples/snippet_metadata_google.cloud.baremetalsolution.v2.json index a1ea0708b18d..2e341fc16178 100644 --- a/packages/google-cloud-bare-metal-solution/samples/generated_samples/snippet_metadata_google.cloud.baremetalsolution.v2.json +++ b/packages/google-cloud-bare-metal-solution/samples/generated_samples/snippet_metadata_google.cloud.baremetalsolution.v2.json @@ -8,7 +8,7 @@ ], "language": "PYTHON", "name": "google-cloud-bare-metal-solution", - "version": "1.8.1" + "version": "0.1.0" }, "snippets": [ { @@ -51,7 +51,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -135,7 +135,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -220,7 +220,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.bare_metal_solution_v2.types.ProvisioningConfig", @@ -304,7 +304,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.bare_metal_solution_v2.types.ProvisioningConfig", @@ -393,7 +393,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.bare_metal_solution_v2.types.SSHKey", @@ -481,7 +481,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.bare_metal_solution_v2.types.SSHKey", @@ -566,7 +566,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.bare_metal_solution_v2.types.VolumeSnapshot", @@ -650,7 +650,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.bare_metal_solution_v2.types.VolumeSnapshot", @@ -731,7 +731,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -811,7 +811,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -892,7 +892,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "shortName": "delete_ssh_key" @@ -969,7 +969,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "shortName": "delete_ssh_key" @@ -1047,7 +1047,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "shortName": "delete_volume_snapshot" @@ -1124,7 +1124,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "shortName": "delete_volume_snapshot" @@ -1206,7 +1206,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -1290,7 +1290,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -1371,7 +1371,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -1451,7 +1451,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -1532,7 +1532,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -1612,7 +1612,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -1693,7 +1693,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -1773,7 +1773,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -1854,7 +1854,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -1934,7 +1934,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -2015,7 +2015,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.bare_metal_solution_v2.types.Instance", @@ -2095,7 +2095,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.bare_metal_solution_v2.types.Instance", @@ -2176,7 +2176,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.bare_metal_solution_v2.types.Lun", @@ -2256,7 +2256,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.bare_metal_solution_v2.types.Lun", @@ -2337,7 +2337,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.bare_metal_solution_v2.types.Network", @@ -2417,7 +2417,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.bare_metal_solution_v2.types.Network", @@ -2498,7 +2498,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.bare_metal_solution_v2.types.NfsShare", @@ -2578,7 +2578,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.bare_metal_solution_v2.types.NfsShare", @@ -2659,7 +2659,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.bare_metal_solution_v2.types.ProvisioningConfig", @@ -2739,7 +2739,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.bare_metal_solution_v2.types.ProvisioningConfig", @@ -2820,7 +2820,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.bare_metal_solution_v2.types.VolumeSnapshot", @@ -2900,7 +2900,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.bare_metal_solution_v2.types.VolumeSnapshot", @@ -2981,7 +2981,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.bare_metal_solution_v2.types.Volume", @@ -3061,7 +3061,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.bare_metal_solution_v2.types.Volume", @@ -3142,7 +3142,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.bare_metal_solution_v2.services.bare_metal_solution.pagers.ListInstancesAsyncPager", @@ -3222,7 +3222,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.bare_metal_solution_v2.services.bare_metal_solution.pagers.ListInstancesPager", @@ -3303,7 +3303,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.bare_metal_solution_v2.services.bare_metal_solution.pagers.ListLunsAsyncPager", @@ -3383,7 +3383,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.bare_metal_solution_v2.services.bare_metal_solution.pagers.ListLunsPager", @@ -3464,7 +3464,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.bare_metal_solution_v2.types.ListNetworkUsageResponse", @@ -3544,7 +3544,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.bare_metal_solution_v2.types.ListNetworkUsageResponse", @@ -3625,7 +3625,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.bare_metal_solution_v2.services.bare_metal_solution.pagers.ListNetworksAsyncPager", @@ -3705,7 +3705,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.bare_metal_solution_v2.services.bare_metal_solution.pagers.ListNetworksPager", @@ -3786,7 +3786,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.bare_metal_solution_v2.services.bare_metal_solution.pagers.ListNfsSharesAsyncPager", @@ -3866,7 +3866,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.bare_metal_solution_v2.services.bare_metal_solution.pagers.ListNfsSharesPager", @@ -3947,7 +3947,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.bare_metal_solution_v2.services.bare_metal_solution.pagers.ListOSImagesAsyncPager", @@ -4027,7 +4027,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.bare_metal_solution_v2.services.bare_metal_solution.pagers.ListOSImagesPager", @@ -4108,7 +4108,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.bare_metal_solution_v2.services.bare_metal_solution.pagers.ListProvisioningQuotasAsyncPager", @@ -4188,7 +4188,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.bare_metal_solution_v2.services.bare_metal_solution.pagers.ListProvisioningQuotasPager", @@ -4269,7 +4269,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.bare_metal_solution_v2.services.bare_metal_solution.pagers.ListSSHKeysAsyncPager", @@ -4349,7 +4349,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.bare_metal_solution_v2.services.bare_metal_solution.pagers.ListSSHKeysPager", @@ -4430,7 +4430,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.bare_metal_solution_v2.services.bare_metal_solution.pagers.ListVolumeSnapshotsAsyncPager", @@ -4510,7 +4510,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.bare_metal_solution_v2.services.bare_metal_solution.pagers.ListVolumeSnapshotsPager", @@ -4591,7 +4591,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.bare_metal_solution_v2.services.bare_metal_solution.pagers.ListVolumesAsyncPager", @@ -4671,7 +4671,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.bare_metal_solution_v2.services.bare_metal_solution.pagers.ListVolumesPager", @@ -4756,7 +4756,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.bare_metal_solution_v2.types.Instance", @@ -4840,7 +4840,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.bare_metal_solution_v2.types.Instance", @@ -4925,7 +4925,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.bare_metal_solution_v2.types.Network", @@ -5009,7 +5009,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.bare_metal_solution_v2.types.Network", @@ -5094,7 +5094,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.bare_metal_solution_v2.types.NfsShare", @@ -5178,7 +5178,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.bare_metal_solution_v2.types.NfsShare", @@ -5263,7 +5263,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.bare_metal_solution_v2.types.Volume", @@ -5347,7 +5347,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.bare_metal_solution_v2.types.Volume", @@ -5428,7 +5428,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -5508,7 +5508,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -5593,7 +5593,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -5677,7 +5677,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -5758,7 +5758,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -5838,7 +5838,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -5919,7 +5919,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -5999,7 +5999,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -6080,7 +6080,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -6160,7 +6160,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -6245,7 +6245,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.bare_metal_solution_v2.types.SubmitProvisioningConfigResponse", @@ -6329,7 +6329,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.bare_metal_solution_v2.types.SubmitProvisioningConfigResponse", @@ -6414,7 +6414,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -6498,7 +6498,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -6583,7 +6583,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -6667,7 +6667,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -6752,7 +6752,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -6836,7 +6836,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -6921,7 +6921,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.bare_metal_solution_v2.types.ProvisioningConfig", @@ -7005,7 +7005,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.bare_metal_solution_v2.types.ProvisioningConfig", @@ -7090,7 +7090,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -7174,7 +7174,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-bare-metal-solution/tests/unit/gapic/bare_metal_solution_v2/test_bare_metal_solution.py b/packages/google-cloud-bare-metal-solution/tests/unit/gapic/bare_metal_solution_v2/test_bare_metal_solution.py index 08d3d0b5e4ed..58c31864500f 100644 --- a/packages/google-cloud-bare-metal-solution/tests/unit/gapic/bare_metal_solution_v2/test_bare_metal_solution.py +++ b/packages/google-cloud-bare-metal-solution/tests/unit/gapic/bare_metal_solution_v2/test_bare_metal_solution.py @@ -18272,6 +18272,7 @@ def test_list_instances_rest_required_fields( response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.list_instances(request) @@ -18326,6 +18327,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) @@ -18515,6 +18517,7 @@ def test_get_instance_rest_required_fields(request_type=instance.GetInstanceRequ response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.get_instance(request) @@ -18562,6 +18565,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) @@ -18691,6 +18695,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) @@ -18737,6 +18742,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) @@ -18874,6 +18880,7 @@ def test_rename_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.rename_instance(request) @@ -18930,6 +18937,7 @@ def test_rename_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.rename_instance(**mock_args) @@ -19064,6 +19072,7 @@ def test_reset_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.reset_instance(request) @@ -19109,6 +19118,7 @@ def test_reset_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.reset_instance(**mock_args) @@ -19242,6 +19252,7 @@ def test_start_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.start_instance(request) @@ -19287,6 +19298,7 @@ def test_start_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.start_instance(**mock_args) @@ -19418,6 +19430,7 @@ def test_stop_instance_rest_required_fields(request_type=instance.StopInstanceRe response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.stop_instance(request) @@ -19463,6 +19476,7 @@ def test_stop_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.stop_instance(**mock_args) @@ -19601,6 +19615,7 @@ def test_enable_interactive_serial_console_rest_required_fields( response_value._content = json_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_interactive_serial_console(request) @@ -19648,6 +19663,7 @@ def test_enable_interactive_serial_console_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = 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_interactive_serial_console(**mock_args) @@ -19788,6 +19804,7 @@ def test_disable_interactive_serial_console_rest_required_fields( response_value._content = json_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_interactive_serial_console(request) @@ -19835,6 +19852,7 @@ def test_disable_interactive_serial_console_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = 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_interactive_serial_console(**mock_args) @@ -19972,6 +19990,7 @@ def test_detach_lun_rest_required_fields(request_type=gcb_instance.DetachLunRequ response_value._content = json_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_lun(request) @@ -20026,6 +20045,7 @@ def test_detach_lun_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = 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_lun(**mock_args) @@ -20163,6 +20183,7 @@ def test_list_ssh_keys_rest_required_fields(request_type=ssh_key.ListSSHKeysRequ response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.list_ssh_keys(request) @@ -20216,6 +20237,7 @@ def test_list_ssh_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_ssh_keys(**mock_args) @@ -20417,6 +20439,7 @@ def test_create_ssh_key_rest_required_fields( response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.create_ssh_key(request) @@ -20479,6 +20502,7 @@ def test_create_ssh_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_ssh_key(**mock_args) @@ -20606,6 +20630,7 @@ def test_delete_ssh_key_rest_required_fields(request_type=ssh_key.DeleteSSHKeyRe response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.delete_ssh_key(request) @@ -20649,6 +20674,7 @@ def test_delete_ssh_key_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_ssh_key(**mock_args) @@ -20785,6 +20811,7 @@ def test_list_volumes_rest_required_fields(request_type=volume.ListVolumesReques response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.list_volumes(request) @@ -20839,6 +20866,7 @@ def test_list_volumes_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.list_volumes(**mock_args) @@ -21028,6 +21056,7 @@ def test_get_volume_rest_required_fields(request_type=volume.GetVolumeRequest): response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.get_volume(request) @@ -21073,6 +21102,7 @@ def test_get_volume_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.get_volume(**mock_args) @@ -21202,6 +21232,7 @@ def test_update_volume_rest_required_fields( response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.update_volume(request) @@ -21248,6 +21279,7 @@ def test_update_volume_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.update_volume(**mock_args) @@ -21383,6 +21415,7 @@ def test_rename_volume_rest_required_fields(request_type=volume.RenameVolumeRequ response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.rename_volume(request) @@ -21437,6 +21470,7 @@ def test_rename_volume_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.rename_volume(**mock_args) @@ -21569,6 +21603,7 @@ def test_evict_volume_rest_required_fields(request_type=volume.EvictVolumeReques response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.evict_volume(request) @@ -21612,6 +21647,7 @@ def test_evict_volume_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.evict_volume(**mock_args) @@ -21745,6 +21781,7 @@ def test_resize_volume_rest_required_fields( response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.resize_volume(request) @@ -21791,6 +21828,7 @@ def test_resize_volume_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.resize_volume(**mock_args) @@ -21929,6 +21967,7 @@ def test_list_networks_rest_required_fields(request_type=network.ListNetworksReq response_value._content = json_return_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) @@ -21983,6 +22022,7 @@ def test_list_networks_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.list_networks(**mock_args) @@ -22178,6 +22218,7 @@ def test_list_network_usage_rest_required_fields( response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.list_network_usage(request) @@ -22223,6 +22264,7 @@ def test_list_network_usage_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.list_network_usage(**mock_args) @@ -22352,6 +22394,7 @@ def test_get_network_rest_required_fields(request_type=network.GetNetworkRequest response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.get_network(request) @@ -22397,6 +22440,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) @@ -22526,6 +22570,7 @@ def test_update_network_rest_required_fields( response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.update_network(request) @@ -22572,6 +22617,7 @@ def test_update_network_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.update_network(**mock_args) @@ -22710,6 +22756,7 @@ def test_create_volume_snapshot_rest_required_fields( response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.create_volume_snapshot(request) @@ -22766,6 +22813,7 @@ def test_create_volume_snapshot_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.create_volume_snapshot(**mock_args) @@ -22905,6 +22953,7 @@ def test_restore_volume_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.restore_volume_snapshot(request) @@ -22950,6 +22999,7 @@ def test_restore_volume_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.restore_volume_snapshot(**mock_args) @@ -23083,6 +23133,7 @@ def test_delete_volume_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.delete_volume_snapshot(request) @@ -23128,6 +23179,7 @@ def test_delete_volume_snapshot_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_volume_snapshot(**mock_args) @@ -23263,6 +23315,7 @@ def test_get_volume_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_volume_snapshot(request) @@ -23310,6 +23363,7 @@ def test_get_volume_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_volume_snapshot(**mock_args) @@ -23453,6 +23507,7 @@ def test_list_volume_snapshots_rest_required_fields( response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.list_volume_snapshots(request) @@ -23508,6 +23563,7 @@ def test_list_volume_snapshots_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.list_volume_snapshots(**mock_args) @@ -23702,6 +23758,7 @@ def test_get_lun_rest_required_fields(request_type=lun.GetLunRequest): response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.get_lun(request) @@ -23749,6 +23806,7 @@ def test_get_lun_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.get_lun(**mock_args) @@ -23885,6 +23943,7 @@ def test_list_luns_rest_required_fields(request_type=lun.ListLunsRequest): response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.list_luns(request) @@ -23940,6 +23999,7 @@ def test_list_luns_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.list_luns(**mock_args) @@ -24134,6 +24194,7 @@ def test_evict_lun_rest_required_fields(request_type=lun.EvictLunRequest): response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.evict_lun(request) @@ -24179,6 +24240,7 @@ def test_evict_lun_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.evict_lun(**mock_args) @@ -24308,6 +24370,7 @@ def test_get_nfs_share_rest_required_fields(request_type=nfs_share.GetNfsShareRe response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.get_nfs_share(request) @@ -24355,6 +24418,7 @@ def test_get_nfs_share_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.get_nfs_share(**mock_args) @@ -24493,6 +24557,7 @@ def test_list_nfs_shares_rest_required_fields( response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.list_nfs_shares(request) @@ -24547,6 +24612,7 @@ def test_list_nfs_shares_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.list_nfs_shares(**mock_args) @@ -24739,6 +24805,7 @@ def test_update_nfs_share_rest_required_fields( response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.update_nfs_share(request) @@ -24787,6 +24854,7 @@ def test_update_nfs_share_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.update_nfs_share(**mock_args) @@ -24923,6 +24991,7 @@ def test_create_nfs_share_rest_required_fields( response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.create_nfs_share(request) @@ -24975,6 +25044,7 @@ def test_create_nfs_share_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.create_nfs_share(**mock_args) @@ -25113,6 +25183,7 @@ def test_rename_nfs_share_rest_required_fields( response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.rename_nfs_share(request) @@ -25169,6 +25240,7 @@ def test_rename_nfs_share_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.rename_nfs_share(**mock_args) @@ -25304,6 +25376,7 @@ def test_delete_nfs_share_rest_required_fields( response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.delete_nfs_share(request) @@ -25349,6 +25422,7 @@ def test_delete_nfs_share_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.delete_nfs_share(**mock_args) @@ -25491,6 +25565,7 @@ def test_list_provisioning_quotas_rest_required_fields( response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.list_provisioning_quotas(request) @@ -25544,6 +25619,7 @@ def test_list_provisioning_quotas_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.list_provisioning_quotas(**mock_args) @@ -25746,6 +25822,7 @@ def test_submit_provisioning_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.submit_provisioning_config(request) @@ -25800,6 +25877,7 @@ def test_submit_provisioning_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.submit_provisioning_config(**mock_args) @@ -25937,6 +26015,7 @@ def test_get_provisioning_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_provisioning_config(request) @@ -25984,6 +26063,7 @@ def test_get_provisioning_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_provisioning_config(**mock_args) @@ -26123,6 +26203,7 @@ def test_create_provisioning_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_provisioning_config(request) @@ -26177,6 +26258,7 @@ def test_create_provisioning_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_provisioning_config(**mock_args) @@ -26317,6 +26399,7 @@ def test_update_provisioning_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_provisioning_config(request) @@ -26380,6 +26463,7 @@ def test_update_provisioning_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_provisioning_config(**mock_args) @@ -26515,6 +26599,7 @@ def test_rename_network_rest_required_fields(request_type=network.RenameNetworkR response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.rename_network(request) @@ -26569,6 +26654,7 @@ def test_rename_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.rename_network(**mock_args) @@ -26706,6 +26792,7 @@ def test_list_os_images_rest_required_fields(request_type=osimage.ListOSImagesRe response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.list_os_images(request) @@ -26759,6 +26846,7 @@ def test_list_os_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_os_images(**mock_args) @@ -29262,6 +29350,7 @@ def test_list_instances_rest_bad_request(request_type=instance.ListInstancesRequ response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.list_instances(request) @@ -29298,6 +29387,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. @@ -29337,6 +29427,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 = instance.ListInstancesResponse.to_json( instance.ListInstancesResponse() ) @@ -29381,6 +29472,7 @@ def test_get_instance_rest_bad_request(request_type=instance.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) @@ -29427,6 +29519,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. @@ -29476,6 +29569,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 @@ -29522,6 +29616,7 @@ def test_update_instance_rest_bad_request( response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.update_instance(request) @@ -29750,6 +29845,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_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. @@ -29791,6 +29887,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 @@ -29833,6 +29930,7 @@ def test_rename_instance_rest_bad_request(request_type=instance.RenameInstanceRe response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.rename_instance(request) @@ -29879,6 +29977,7 @@ def test_rename_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.rename_instance(request) # Establish that the response is the type that we expect. @@ -29928,6 +30027,7 @@ def test_rename_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 @@ -29970,6 +30070,7 @@ def test_reset_instance_rest_bad_request(request_type=instance.ResetInstanceRequ response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.reset_instance(request) @@ -30000,6 +30101,7 @@ def test_reset_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.reset_instance(request) # Establish that the response is the type that we expect. @@ -30039,6 +30141,7 @@ def test_reset_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 @@ -30081,6 +30184,7 @@ def test_start_instance_rest_bad_request(request_type=instance.StartInstanceRequ response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.start_instance(request) @@ -30111,6 +30215,7 @@ def test_start_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.start_instance(request) # Establish that the response is the type that we expect. @@ -30150,6 +30255,7 @@ def test_start_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 @@ -30192,6 +30298,7 @@ def test_stop_instance_rest_bad_request(request_type=instance.StopInstanceReques response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.stop_instance(request) @@ -30222,6 +30329,7 @@ def test_stop_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.stop_instance(request) # Establish that the response is the type that we expect. @@ -30261,6 +30369,7 @@ def test_stop_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 @@ -30305,6 +30414,7 @@ def test_enable_interactive_serial_console_rest_bad_request( response_value.status_code = 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_interactive_serial_console(request) @@ -30335,6 +30445,7 @@ def test_enable_interactive_serial_console_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_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_interactive_serial_console(request) # Establish that the response is the type that we expect. @@ -30378,6 +30489,7 @@ def test_enable_interactive_serial_console_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = json_format.MessageToJson(operations_pb2.Operation()) req.return_value.content = return_value @@ -30422,6 +30534,7 @@ def test_disable_interactive_serial_console_rest_bad_request( response_value.status_code = 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_interactive_serial_console(request) @@ -30452,6 +30565,7 @@ def test_disable_interactive_serial_console_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_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_interactive_serial_console(request) # Establish that the response is the type that we expect. @@ -30495,6 +30609,7 @@ def test_disable_interactive_serial_console_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = json_format.MessageToJson(operations_pb2.Operation()) req.return_value.content = return_value @@ -30537,6 +30652,7 @@ def test_detach_lun_rest_bad_request(request_type=gcb_instance.DetachLunRequest) response_value.status_code = 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_lun(request) @@ -30567,6 +30683,7 @@ def test_detach_lun_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_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_lun(request) # Establish that the response is the type that we expect. @@ -30606,6 +30723,7 @@ def test_detach_lun_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = json_format.MessageToJson(operations_pb2.Operation()) req.return_value.content = return_value @@ -30648,6 +30766,7 @@ def test_list_ssh_keys_rest_bad_request(request_type=ssh_key.ListSSHKeysRequest) response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.list_ssh_keys(request) @@ -30683,6 +30802,7 @@ def test_list_ssh_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_ssh_keys(request) # Establish that the response is the type that we expect. @@ -30721,6 +30841,7 @@ def test_list_ssh_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 = ssh_key.ListSSHKeysResponse.to_json( ssh_key.ListSSHKeysResponse() ) @@ -30765,6 +30886,7 @@ def test_create_ssh_key_rest_bad_request(request_type=gcb_ssh_key.CreateSSHKeyRe response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.create_ssh_key(request) @@ -30869,6 +30991,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.create_ssh_key(request) # Establish that the response is the type that we expect. @@ -30910,6 +31033,7 @@ def test_create_ssh_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 = gcb_ssh_key.SSHKey.to_json(gcb_ssh_key.SSHKey()) req.return_value.content = return_value @@ -30952,6 +31076,7 @@ def test_delete_ssh_key_rest_bad_request(request_type=ssh_key.DeleteSSHKeyReques response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.delete_ssh_key(request) @@ -30982,6 +31107,7 @@ def test_delete_ssh_key_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_ssh_key(request) # Establish that the response is the type that we expect. @@ -31016,6 +31142,7 @@ def test_delete_ssh_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"} request = ssh_key.DeleteSSHKeyRequest() metadata = [ @@ -31054,6 +31181,7 @@ def test_list_volumes_rest_bad_request(request_type=volume.ListVolumesRequest): response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.list_volumes(request) @@ -31090,6 +31218,7 @@ def test_list_volumes_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.list_volumes(request) # Establish that the response is the type that we expect. @@ -31129,6 +31258,7 @@ def test_list_volumes_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = volume.ListVolumesResponse.to_json(volume.ListVolumesResponse()) req.return_value.content = return_value @@ -31171,6 +31301,7 @@ def test_get_volume_rest_bad_request(request_type=volume.GetVolumeRequest): response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.get_volume(request) @@ -31226,6 +31357,7 @@ def test_get_volume_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.get_volume(request) # Establish that the response is the type that we expect. @@ -31290,6 +31422,7 @@ def test_get_volume_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = volume.Volume.to_json(volume.Volume()) req.return_value.content = return_value @@ -31334,6 +31467,7 @@ def test_update_volume_rest_bad_request(request_type=gcb_volume.UpdateVolumeRequ response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.update_volume(request) @@ -31464,6 +31598,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.update_volume(request) # Establish that the response is the type that we expect. @@ -31503,6 +31638,7 @@ def test_update_volume_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = json_format.MessageToJson(operations_pb2.Operation()) req.return_value.content = return_value @@ -31545,6 +31681,7 @@ def test_rename_volume_rest_bad_request(request_type=volume.RenameVolumeRequest) response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.rename_volume(request) @@ -31600,6 +31737,7 @@ def test_rename_volume_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.rename_volume(request) # Establish that the response is the type that we expect. @@ -31664,6 +31802,7 @@ def test_rename_volume_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = volume.Volume.to_json(volume.Volume()) req.return_value.content = return_value @@ -31706,6 +31845,7 @@ def test_evict_volume_rest_bad_request(request_type=volume.EvictVolumeRequest): response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.evict_volume(request) @@ -31736,6 +31876,7 @@ def test_evict_volume_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.evict_volume(request) # Establish that the response is the type that we expect. @@ -31775,6 +31916,7 @@ def test_evict_volume_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = json_format.MessageToJson(operations_pb2.Operation()) req.return_value.content = return_value @@ -31817,6 +31959,7 @@ def test_resize_volume_rest_bad_request(request_type=gcb_volume.ResizeVolumeRequ response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.resize_volume(request) @@ -31847,6 +31990,7 @@ def test_resize_volume_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.resize_volume(request) # Establish that the response is the type that we expect. @@ -31886,6 +32030,7 @@ def test_resize_volume_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = json_format.MessageToJson(operations_pb2.Operation()) req.return_value.content = return_value @@ -31928,6 +32073,7 @@ def test_list_networks_rest_bad_request(request_type=network.ListNetworksRequest response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.list_networks(request) @@ -31964,6 +32110,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. @@ -32003,6 +32150,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.ListNetworksResponse.to_json( network.ListNetworksResponse() ) @@ -32049,6 +32197,7 @@ def test_list_network_usage_rest_bad_request( response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.list_network_usage(request) @@ -32082,6 +32231,7 @@ def test_list_network_usage_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.list_network_usage(request) # Establish that the response is the type that we expect. @@ -32121,6 +32271,7 @@ def test_list_network_usage_rest_interceptors(null_interceptor): req.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.ListNetworkUsageResponse.to_json( network.ListNetworkUsageResponse() ) @@ -32165,6 +32316,7 @@ def test_get_network_rest_bad_request(request_type=network.GetNetworkRequest): response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.get_network(request) @@ -32211,6 +32363,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. @@ -32260,6 +32413,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.Network.to_json(network.Network()) req.return_value.content = return_value @@ -32304,6 +32458,7 @@ def test_update_network_rest_bad_request(request_type=gcb_network.UpdateNetworkR response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.update_network(request) @@ -32449,6 +32604,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.update_network(request) # Establish that the response is the type that we expect. @@ -32490,6 +32646,7 @@ def test_update_network_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = json_format.MessageToJson(operations_pb2.Operation()) req.return_value.content = return_value @@ -32534,6 +32691,7 @@ def test_create_volume_snapshot_rest_bad_request( response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.create_volume_snapshot(request) @@ -32650,6 +32808,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.create_volume_snapshot(request) # Establish that the response is the type that we expect. @@ -32694,6 +32853,7 @@ def test_create_volume_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 = gcb_volume_snapshot.VolumeSnapshot.to_json( gcb_volume_snapshot.VolumeSnapshot() ) @@ -32742,6 +32902,7 @@ def test_restore_volume_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.restore_volume_snapshot(request) @@ -32774,6 +32935,7 @@ def test_restore_volume_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.restore_volume_snapshot(request) # Establish that the response is the type that we expect. @@ -32815,6 +32977,7 @@ def test_restore_volume_snapshot_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = json_format.MessageToJson(operations_pb2.Operation()) req.return_value.content = return_value @@ -32861,6 +33024,7 @@ def test_delete_volume_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.delete_volume_snapshot(request) @@ -32893,6 +33057,7 @@ def test_delete_volume_snapshot_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_volume_snapshot(request) # Establish that the response is the type that we expect. @@ -32929,6 +33094,7 @@ def test_delete_volume_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"} request = volume_snapshot.DeleteVolumeSnapshotRequest() metadata = [ @@ -32971,6 +33137,7 @@ def test_get_volume_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_volume_snapshot(request) @@ -33012,6 +33179,7 @@ def test_get_volume_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_volume_snapshot(request) # Establish that the response is the type that we expect. @@ -33056,6 +33224,7 @@ def test_get_volume_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 = volume_snapshot.VolumeSnapshot.to_json( volume_snapshot.VolumeSnapshot() ) @@ -33102,6 +33271,7 @@ def test_list_volume_snapshots_rest_bad_request( response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.list_volume_snapshots(request) @@ -33138,6 +33308,7 @@ def test_list_volume_snapshots_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.list_volume_snapshots(request) # Establish that the response is the type that we expect. @@ -33179,6 +33350,7 @@ def test_list_volume_snapshots_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = volume_snapshot.ListVolumeSnapshotsResponse.to_json( volume_snapshot.ListVolumeSnapshotsResponse() ) @@ -33225,6 +33397,7 @@ def test_get_lun_rest_bad_request(request_type=lun.GetLunRequest): response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.get_lun(request) @@ -33272,6 +33445,7 @@ def test_get_lun_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.get_lun(request) # Establish that the response is the type that we expect. @@ -33320,6 +33494,7 @@ def test_get_lun_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = lun.Lun.to_json(lun.Lun()) req.return_value.content = return_value @@ -33362,6 +33537,7 @@ def test_list_luns_rest_bad_request(request_type=lun.ListLunsRequest): response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.list_luns(request) @@ -33398,6 +33574,7 @@ def test_list_luns_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.list_luns(request) # Establish that the response is the type that we expect. @@ -33437,6 +33614,7 @@ def test_list_luns_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = lun.ListLunsResponse.to_json(lun.ListLunsResponse()) req.return_value.content = return_value @@ -33481,6 +33659,7 @@ def test_evict_lun_rest_bad_request(request_type=lun.EvictLunRequest): response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.evict_lun(request) @@ -33513,6 +33692,7 @@ def test_evict_lun_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.evict_lun(request) # Establish that the response is the type that we expect. @@ -33552,6 +33732,7 @@ def test_evict_lun_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = json_format.MessageToJson(operations_pb2.Operation()) req.return_value.content = return_value @@ -33594,6 +33775,7 @@ def test_get_nfs_share_rest_bad_request(request_type=nfs_share.GetNfsShareReques response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.get_nfs_share(request) @@ -33635,6 +33817,7 @@ def test_get_nfs_share_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.get_nfs_share(request) # Establish that the response is the type that we expect. @@ -33679,6 +33862,7 @@ def test_get_nfs_share_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = nfs_share.NfsShare.to_json(nfs_share.NfsShare()) req.return_value.content = return_value @@ -33721,6 +33905,7 @@ def test_list_nfs_shares_rest_bad_request(request_type=nfs_share.ListNfsSharesRe response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.list_nfs_shares(request) @@ -33757,6 +33942,7 @@ def test_list_nfs_shares_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.list_nfs_shares(request) # Establish that the response is the type that we expect. @@ -33796,6 +33982,7 @@ def test_list_nfs_shares_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = nfs_share.ListNfsSharesResponse.to_json( nfs_share.ListNfsSharesResponse() ) @@ -33844,6 +34031,7 @@ def test_update_nfs_share_rest_bad_request( response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.update_nfs_share(request) @@ -33965,6 +34153,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.update_nfs_share(request) # Establish that the response is the type that we expect. @@ -34006,6 +34195,7 @@ def test_update_nfs_share_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = json_format.MessageToJson(operations_pb2.Operation()) req.return_value.content = return_value @@ -34050,6 +34240,7 @@ def test_create_nfs_share_rest_bad_request( response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.create_nfs_share(request) @@ -34169,6 +34360,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.create_nfs_share(request) # Establish that the response is the type that we expect. @@ -34210,6 +34402,7 @@ def test_create_nfs_share_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = json_format.MessageToJson(operations_pb2.Operation()) req.return_value.content = return_value @@ -34254,6 +34447,7 @@ def test_rename_nfs_share_rest_bad_request( response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.rename_nfs_share(request) @@ -34295,6 +34489,7 @@ def test_rename_nfs_share_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.rename_nfs_share(request) # Establish that the response is the type that we expect. @@ -34341,6 +34536,7 @@ def test_rename_nfs_share_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = nfs_share.NfsShare.to_json(nfs_share.NfsShare()) req.return_value.content = return_value @@ -34385,6 +34581,7 @@ def test_delete_nfs_share_rest_bad_request( response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.delete_nfs_share(request) @@ -34415,6 +34612,7 @@ def test_delete_nfs_share_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.delete_nfs_share(request) # Establish that the response is the type that we expect. @@ -34456,6 +34654,7 @@ def test_delete_nfs_share_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = json_format.MessageToJson(operations_pb2.Operation()) req.return_value.content = return_value @@ -34500,6 +34699,7 @@ def test_list_provisioning_quotas_rest_bad_request( response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.list_provisioning_quotas(request) @@ -34535,6 +34735,7 @@ def test_list_provisioning_quotas_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.list_provisioning_quotas(request) # Establish that the response is the type that we expect. @@ -34575,6 +34776,7 @@ def test_list_provisioning_quotas_rest_interceptors(null_interceptor): req.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.ListProvisioningQuotasResponse.to_json( provisioning.ListProvisioningQuotasResponse() ) @@ -34621,6 +34823,7 @@ def test_submit_provisioning_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.submit_provisioning_config(request) @@ -34654,6 +34857,7 @@ def test_submit_provisioning_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.submit_provisioning_config(request) # Establish that the response is the type that we expect. @@ -34693,6 +34897,7 @@ def test_submit_provisioning_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 = provisioning.SubmitProvisioningConfigResponse.to_json( provisioning.SubmitProvisioningConfigResponse() ) @@ -34741,6 +34946,7 @@ def test_get_provisioning_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_provisioning_config(request) @@ -34787,6 +34993,7 @@ def test_get_provisioning_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_provisioning_config(request) # Establish that the response is the type that we expect. @@ -34836,6 +35043,7 @@ def test_get_provisioning_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 = provisioning.ProvisioningConfig.to_json( provisioning.ProvisioningConfig() ) @@ -34882,6 +35090,7 @@ def test_create_provisioning_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_provisioning_config(request) @@ -35086,6 +35295,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.create_provisioning_config(request) # Establish that the response is the type that we expect. @@ -35135,6 +35345,7 @@ def test_create_provisioning_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 = provisioning.ProvisioningConfig.to_json( provisioning.ProvisioningConfig() ) @@ -35185,6 +35396,7 @@ def test_update_provisioning_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_provisioning_config(request) @@ -35393,6 +35605,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.update_provisioning_config(request) # Establish that the response is the type that we expect. @@ -35442,6 +35655,7 @@ def test_update_provisioning_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 = provisioning.ProvisioningConfig.to_json( provisioning.ProvisioningConfig() ) @@ -35486,6 +35700,7 @@ def test_rename_network_rest_bad_request(request_type=network.RenameNetworkReque response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.rename_network(request) @@ -35532,6 +35747,7 @@ def test_rename_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.rename_network(request) # Establish that the response is the type that we expect. @@ -35581,6 +35797,7 @@ def test_rename_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.Network.to_json(network.Network()) req.return_value.content = return_value @@ -35623,6 +35840,7 @@ def test_list_os_images_rest_bad_request(request_type=osimage.ListOSImagesReques response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.list_os_images(request) @@ -35658,6 +35876,7 @@ def test_list_os_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_os_images(request) # Establish that the response is the type that we expect. @@ -35696,6 +35915,7 @@ def test_list_os_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 = osimage.ListOSImagesResponse.to_json( osimage.ListOSImagesResponse() ) @@ -35742,6 +35962,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) @@ -35772,6 +35993,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) @@ -35800,6 +36022,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) @@ -35830,6 +36053,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-beyondcorp-appconnections/google/cloud/beyondcorp_appconnections/gapic_version.py b/packages/google-cloud-beyondcorp-appconnections/google/cloud/beyondcorp_appconnections/gapic_version.py index 9b19e5f10e00..558c8aab67c5 100644 --- a/packages/google-cloud-beyondcorp-appconnections/google/cloud/beyondcorp_appconnections/gapic_version.py +++ b/packages/google-cloud-beyondcorp-appconnections/google/cloud/beyondcorp_appconnections/gapic_version.py @@ -13,4 +13,4 @@ # See the License for the specific language governing permissions and # limitations under the License. # -__version__ = "0.4.13" # {x-release-please-version} +__version__ = "0.0.0" # {x-release-please-version} diff --git a/packages/google-cloud-beyondcorp-appconnections/google/cloud/beyondcorp_appconnections_v1/gapic_version.py b/packages/google-cloud-beyondcorp-appconnections/google/cloud/beyondcorp_appconnections_v1/gapic_version.py index 9b19e5f10e00..558c8aab67c5 100644 --- a/packages/google-cloud-beyondcorp-appconnections/google/cloud/beyondcorp_appconnections_v1/gapic_version.py +++ b/packages/google-cloud-beyondcorp-appconnections/google/cloud/beyondcorp_appconnections_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.13" # {x-release-please-version} +__version__ = "0.0.0" # {x-release-please-version} diff --git a/packages/google-cloud-beyondcorp-appconnections/google/cloud/beyondcorp_appconnections_v1/services/app_connections_service/async_client.py b/packages/google-cloud-beyondcorp-appconnections/google/cloud/beyondcorp_appconnections_v1/services/app_connections_service/async_client.py index d56b47eaf811..8376eb91773f 100644 --- a/packages/google-cloud-beyondcorp-appconnections/google/cloud/beyondcorp_appconnections_v1/services/app_connections_service/async_client.py +++ b/packages/google-cloud-beyondcorp-appconnections/google/cloud/beyondcorp_appconnections_v1/services/app_connections_service/async_client.py @@ -14,6 +14,7 @@ # limitations under the License. # from collections import OrderedDict +import logging as std_logging import re from typing import ( Callable, @@ -61,6 +62,15 @@ from .transports.base import DEFAULT_CLIENT_INFO, AppConnectionsServiceTransport from .transports.grpc_asyncio import AppConnectionsServiceGrpcAsyncIOTransport +try: + from google.api_core import client_logging # type: ignore + + CLIENT_LOGGING_SUPPORTED = True # pragma: NO COVER +except ImportError: # pragma: NO COVER + CLIENT_LOGGING_SUPPORTED = False + +_LOGGER = std_logging.getLogger(__name__) + class AppConnectionsServiceAsyncClient: """API Overview: @@ -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.cloud.beyondcorp.appconnections_v1.AppConnectionsServiceAsyncClient`.", + extra={ + "serviceName": "google.cloud.beyondcorp.appconnections.v1.AppConnectionsService", + "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.beyondcorp.appconnections.v1.AppConnectionsService", + "credentialsType": None, + }, + ) + async def list_app_connections( self, request: Optional[ @@ -305,7 +337,7 @@ async def list_app_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.ListAppConnectionsAsyncPager: r"""Lists AppConnections in a given project and location. @@ -351,8 +383,10 @@ async def sample_list_app_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.beyondcorp_appconnections_v1.services.app_connections_service.pagers.ListAppConnectionsAsyncPager: @@ -429,7 +463,7 @@ async def get_app_connection( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> app_connections_service.AppConnection: r"""Gets details of a single AppConnection. @@ -473,8 +507,10 @@ async def sample_get_app_connection(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.beyondcorp_appconnections_v1.types.AppConnection: @@ -545,7 +581,7 @@ async def create_app_connection( app_connection_id: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation_async.AsyncOperation: r"""Creates a new AppConnection in a given project and location. @@ -620,8 +656,10 @@ async def sample_create_app_connection(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.api_core.operation_async.AsyncOperation: @@ -703,7 +741,7 @@ async def update_app_connection( update_mask: Optional[field_mask_pb2.FieldMask] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation_async.AsyncOperation: r"""Updates the parameters of a single AppConnection. @@ -772,8 +810,10 @@ async def sample_update_app_connection(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.api_core.operation_async.AsyncOperation: @@ -854,7 +894,7 @@ async def delete_app_connection( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation_async.AsyncOperation: r"""Deletes a single AppConnection. @@ -902,8 +942,10 @@ async def sample_delete_app_connection(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.api_core.operation_async.AsyncOperation: @@ -984,7 +1026,7 @@ async def resolve_app_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.ResolveAppConnectionsAsyncPager: r"""Resolves AppConnections details for a given AppConnector. An internal method called by a connector @@ -1033,8 +1075,10 @@ async def sample_resolve_app_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.beyondcorp_appconnections_v1.services.app_connections_service.pagers.ResolveAppConnectionsAsyncPager: @@ -1110,7 +1154,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. @@ -1121,8 +1165,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. @@ -1163,7 +1209,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. @@ -1174,8 +1220,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. @@ -1216,7 +1264,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. @@ -1232,8 +1280,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 """ @@ -1270,7 +1320,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. @@ -1285,8 +1335,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 """ @@ -1323,7 +1375,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. @@ -1336,8 +1388,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. @@ -1442,7 +1496,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. @@ -1456,8 +1510,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. @@ -1562,7 +1618,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. @@ -1577,8 +1633,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. @@ -1622,7 +1680,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. @@ -1633,8 +1691,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. @@ -1675,7 +1735,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. @@ -1686,8 +1746,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-beyondcorp-appconnections/google/cloud/beyondcorp_appconnections_v1/services/app_connections_service/client.py b/packages/google-cloud-beyondcorp-appconnections/google/cloud/beyondcorp_appconnections_v1/services/app_connections_service/client.py index ffdcb843d0ff..cd3d48686fe8 100644 --- a/packages/google-cloud-beyondcorp-appconnections/google/cloud/beyondcorp_appconnections_v1/services/app_connections_service/client.py +++ b/packages/google-cloud-beyondcorp-appconnections/google/cloud/beyondcorp_appconnections_v1/services/app_connections_service/client.py @@ -14,6 +14,7 @@ # limitations under the License. # from collections import OrderedDict +import logging as std_logging import os import re from typing import ( @@ -48,6 +49,15 @@ except AttributeError: # pragma: NO COVER OptionalRetry = Union[retries.Retry, object, None] # type: ignore +try: + from google.api_core import client_logging # type: ignore + + CLIENT_LOGGING_SUPPORTED = True # pragma: NO COVER +except ImportError: # pragma: NO COVER + CLIENT_LOGGING_SUPPORTED = False + +_LOGGER = std_logging.getLogger(__name__) + from google.api_core import operation # type: ignore from google.api_core import operation_async # type: ignore from google.cloud.location import locations_pb2 # type: ignore @@ -656,6 +666,10 @@ def __init__( # Initialize the universe domain validation. self._is_universe_domain_valid = False + if CLIENT_LOGGING_SUPPORTED: # pragma: NO COVER + # Setup logging. + client_logging.initialize_logging() + api_key_value = getattr(self._client_options, "api_key", None) if api_key_value and credentials: raise ValueError( @@ -722,6 +736,29 @@ def __init__( api_audience=self._client_options.api_audience, ) + if "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.beyondcorp.appconnections_v1.AppConnectionsServiceClient`.", + extra={ + "serviceName": "google.cloud.beyondcorp.appconnections.v1.AppConnectionsService", + "universeDomain": getattr( + self._transport._credentials, "universe_domain", "" + ), + "credentialsType": f"{type(self._transport._credentials).__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.beyondcorp.appconnections.v1.AppConnectionsService", + "credentialsType": None, + }, + ) + def list_app_connections( self, request: Optional[ @@ -731,7 +768,7 @@ def list_app_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.ListAppConnectionsPager: r"""Lists AppConnections in a given project and location. @@ -777,8 +814,10 @@ def sample_list_app_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.beyondcorp_appconnections_v1.services.app_connections_service.pagers.ListAppConnectionsPager: @@ -852,7 +891,7 @@ def get_app_connection( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> app_connections_service.AppConnection: r"""Gets details of a single AppConnection. @@ -896,8 +935,10 @@ def sample_get_app_connection(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.beyondcorp_appconnections_v1.types.AppConnection: @@ -965,7 +1006,7 @@ def create_app_connection( app_connection_id: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation.Operation: r"""Creates a new AppConnection in a given project and location. @@ -1040,8 +1081,10 @@ def sample_create_app_connection(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.api_core.operation.Operation: @@ -1120,7 +1163,7 @@ def update_app_connection( update_mask: Optional[field_mask_pb2.FieldMask] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation.Operation: r"""Updates the parameters of a single AppConnection. @@ -1189,8 +1232,10 @@ def sample_update_app_connection(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.api_core.operation.Operation: @@ -1268,7 +1313,7 @@ def delete_app_connection( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation.Operation: r"""Deletes a single AppConnection. @@ -1316,8 +1361,10 @@ def sample_delete_app_connection(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.api_core.operation.Operation: @@ -1395,7 +1442,7 @@ def resolve_app_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.ResolveAppConnectionsPager: r"""Resolves AppConnections details for a given AppConnector. An internal method called by a connector @@ -1444,8 +1491,10 @@ def sample_resolve_app_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.beyondcorp_appconnections_v1.services.app_connections_service.pagers.ResolveAppConnectionsPager: @@ -1531,7 +1580,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. @@ -1542,8 +1591,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. @@ -1584,7 +1635,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. @@ -1595,8 +1646,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. @@ -1637,7 +1690,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. @@ -1653,8 +1706,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 """ @@ -1691,7 +1746,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. @@ -1706,8 +1761,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 """ @@ -1744,7 +1801,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. @@ -1757,8 +1814,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. @@ -1863,7 +1922,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. @@ -1877,8 +1936,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. @@ -1983,7 +2044,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. @@ -1998,8 +2059,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. @@ -2041,7 +2104,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. @@ -2052,8 +2115,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. @@ -2094,7 +2159,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. @@ -2105,8 +2170,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-beyondcorp-appconnections/google/cloud/beyondcorp_appconnections_v1/services/app_connections_service/pagers.py b/packages/google-cloud-beyondcorp-appconnections/google/cloud/beyondcorp_appconnections_v1/services/app_connections_service/pagers.py index 46653bcf5a24..4e348d80f642 100644 --- a/packages/google-cloud-beyondcorp-appconnections/google/cloud/beyondcorp_appconnections_v1/services/app_connections_service/pagers.py +++ b/packages/google-cloud-beyondcorp-appconnections/google/cloud/beyondcorp_appconnections_v1/services/app_connections_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 = app_connections_service.ListAppConnectionsRequest(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 = app_connections_service.ListAppConnectionsRequest(request) @@ -223,7 +227,7 @@ def __init__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiate the pager. @@ -237,8 +241,10 @@ def __init__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. """ self._method = method self._request = app_connections_service.ResolveAppConnectionsRequest(request) @@ -303,7 +309,7 @@ def __init__( *, retry: OptionalAsyncRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiates the pager. @@ -317,8 +323,10 @@ def __init__( retry (google.api_core.retry.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. """ self._method = method self._request = app_connections_service.ResolveAppConnectionsRequest(request) diff --git a/packages/google-cloud-beyondcorp-appconnections/google/cloud/beyondcorp_appconnections_v1/services/app_connections_service/transports/grpc.py b/packages/google-cloud-beyondcorp-appconnections/google/cloud/beyondcorp_appconnections_v1/services/app_connections_service/transports/grpc.py index 9b8a18fc2a7f..43e510a91ca6 100644 --- a/packages/google-cloud-beyondcorp-appconnections/google/cloud/beyondcorp_appconnections_v1/services/app_connections_service/transports/grpc.py +++ b/packages/google-cloud-beyondcorp-appconnections/google/cloud/beyondcorp_appconnections_v1/services/app_connections_service/transports/grpc.py @@ -13,6 +13,9 @@ # See the License for the specific language governing permissions and # limitations under the License. # +import json +import logging as std_logging +import pickle from typing import Callable, Dict, Optional, Sequence, Tuple, Union import warnings @@ -24,12 +27,90 @@ from google.iam.v1 import iam_policy_pb2 # type: ignore from google.iam.v1 import policy_pb2 # type: ignore from google.longrunning import operations_pb2 # type: ignore +from google.protobuf.json_format import MessageToJson +import google.protobuf.message import grpc # type: ignore +import proto # type: ignore from google.cloud.beyondcorp_appconnections_v1.types import app_connections_service from .base import DEFAULT_CLIENT_INFO, AppConnectionsServiceTransport +try: + from google.api_core import client_logging # 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.beyondcorp.appconnections.v1.AppConnectionsService", + "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.beyondcorp.appconnections.v1.AppConnectionsService", + "rpcName": client_call_details.method, + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class AppConnectionsServiceGrpcTransport(AppConnectionsServiceTransport): """gRPC backend transport for AppConnectionsService. @@ -197,7 +278,12 @@ def __init__( ], ) - # Wrap messages. This must be done after self._grpc_channel exists + self._interceptor = _LoggingClientInterceptor() + self._logged_channel = grpc.intercept_channel( + self._grpc_channel, self._interceptor + ) + + # Wrap messages. This must be done after self._logged_channel exists self._prep_wrapped_messages(client_info) @classmethod @@ -261,7 +347,9 @@ def operations_client(self) -> operations_v1.OperationsClient: """ # Quick check: Only create a new client if we do not already have one. if self._operations_client is None: - self._operations_client = operations_v1.OperationsClient(self.grpc_channel) + self._operations_client = operations_v1.OperationsClient( + self._logged_channel + ) # Return the client from cache. return self._operations_client @@ -288,7 +376,7 @@ def list_app_connections( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_app_connections" not in self._stubs: - self._stubs["list_app_connections"] = self.grpc_channel.unary_unary( + self._stubs["list_app_connections"] = self._logged_channel.unary_unary( "/google.cloud.beyondcorp.appconnections.v1.AppConnectionsService/ListAppConnections", request_serializer=app_connections_service.ListAppConnectionsRequest.serialize, response_deserializer=app_connections_service.ListAppConnectionsResponse.deserialize, @@ -317,7 +405,7 @@ def get_app_connection( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_app_connection" not in self._stubs: - self._stubs["get_app_connection"] = self.grpc_channel.unary_unary( + self._stubs["get_app_connection"] = self._logged_channel.unary_unary( "/google.cloud.beyondcorp.appconnections.v1.AppConnectionsService/GetAppConnection", request_serializer=app_connections_service.GetAppConnectionRequest.serialize, response_deserializer=app_connections_service.AppConnection.deserialize, @@ -346,7 +434,7 @@ def create_app_connection( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_app_connection" not in self._stubs: - self._stubs["create_app_connection"] = self.grpc_channel.unary_unary( + self._stubs["create_app_connection"] = self._logged_channel.unary_unary( "/google.cloud.beyondcorp.appconnections.v1.AppConnectionsService/CreateAppConnection", request_serializer=app_connections_service.CreateAppConnectionRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -374,7 +462,7 @@ def update_app_connection( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_app_connection" not in self._stubs: - self._stubs["update_app_connection"] = self.grpc_channel.unary_unary( + self._stubs["update_app_connection"] = self._logged_channel.unary_unary( "/google.cloud.beyondcorp.appconnections.v1.AppConnectionsService/UpdateAppConnection", request_serializer=app_connections_service.UpdateAppConnectionRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -402,7 +490,7 @@ def delete_app_connection( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_app_connection" not in self._stubs: - self._stubs["delete_app_connection"] = self.grpc_channel.unary_unary( + self._stubs["delete_app_connection"] = self._logged_channel.unary_unary( "/google.cloud.beyondcorp.appconnections.v1.AppConnectionsService/DeleteAppConnection", request_serializer=app_connections_service.DeleteAppConnectionRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -433,7 +521,7 @@ def resolve_app_connections( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "resolve_app_connections" not in self._stubs: - self._stubs["resolve_app_connections"] = self.grpc_channel.unary_unary( + self._stubs["resolve_app_connections"] = self._logged_channel.unary_unary( "/google.cloud.beyondcorp.appconnections.v1.AppConnectionsService/ResolveAppConnections", request_serializer=app_connections_service.ResolveAppConnectionsRequest.serialize, response_deserializer=app_connections_service.ResolveAppConnectionsResponse.deserialize, @@ -441,7 +529,7 @@ def resolve_app_connections( return self._stubs["resolve_app_connections"] def close(self): - self.grpc_channel.close() + self._logged_channel.close() @property def delete_operation( @@ -453,7 +541,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, @@ -470,7 +558,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, @@ -487,7 +575,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, @@ -506,7 +594,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, @@ -525,7 +613,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, @@ -542,7 +630,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, @@ -567,7 +655,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, @@ -593,7 +681,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, @@ -622,7 +710,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-beyondcorp-appconnections/google/cloud/beyondcorp_appconnections_v1/services/app_connections_service/transports/grpc_asyncio.py b/packages/google-cloud-beyondcorp-appconnections/google/cloud/beyondcorp_appconnections_v1/services/app_connections_service/transports/grpc_asyncio.py index 4453771a8f28..4a6719d4dc47 100644 --- a/packages/google-cloud-beyondcorp-appconnections/google/cloud/beyondcorp_appconnections_v1/services/app_connections_service/transports/grpc_asyncio.py +++ b/packages/google-cloud-beyondcorp-appconnections/google/cloud/beyondcorp_appconnections_v1/services/app_connections_service/transports/grpc_asyncio.py @@ -14,6 +14,9 @@ # limitations under the License. # import inspect +import json +import logging as std_logging +import pickle from typing import Awaitable, Callable, Dict, Optional, Sequence, Tuple, Union import warnings @@ -26,14 +29,93 @@ from google.iam.v1 import iam_policy_pb2 # type: ignore from google.iam.v1 import policy_pb2 # type: ignore from google.longrunning import operations_pb2 # type: ignore +from google.protobuf.json_format import MessageToJson +import google.protobuf.message import grpc # type: ignore from grpc.experimental import aio # type: ignore +import proto # type: ignore from google.cloud.beyondcorp_appconnections_v1.types import app_connections_service from .base import DEFAULT_CLIENT_INFO, AppConnectionsServiceTransport from .grpc import AppConnectionsServiceGrpcTransport +try: + from google.api_core import client_logging # 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.beyondcorp.appconnections.v1.AppConnectionsService", + "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.beyondcorp.appconnections.v1.AppConnectionsService", + "rpcName": str(client_call_details.method), + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class AppConnectionsServiceGrpcAsyncIOTransport(AppConnectionsServiceTransport): """gRPC AsyncIO backend transport for AppConnectionsService. @@ -244,10 +326,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 operations_client(self) -> operations_v1.OperationsAsyncClient: # Quick check: Only create a new client if we do not already have one. if self._operations_client is None: self._operations_client = operations_v1.OperationsAsyncClient( - self.grpc_channel + self._logged_channel ) # Return the client from cache. @@ -298,7 +383,7 @@ def list_app_connections( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_app_connections" not in self._stubs: - self._stubs["list_app_connections"] = self.grpc_channel.unary_unary( + self._stubs["list_app_connections"] = self._logged_channel.unary_unary( "/google.cloud.beyondcorp.appconnections.v1.AppConnectionsService/ListAppConnections", request_serializer=app_connections_service.ListAppConnectionsRequest.serialize, response_deserializer=app_connections_service.ListAppConnectionsResponse.deserialize, @@ -327,7 +412,7 @@ def get_app_connection( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_app_connection" not in self._stubs: - self._stubs["get_app_connection"] = self.grpc_channel.unary_unary( + self._stubs["get_app_connection"] = self._logged_channel.unary_unary( "/google.cloud.beyondcorp.appconnections.v1.AppConnectionsService/GetAppConnection", request_serializer=app_connections_service.GetAppConnectionRequest.serialize, response_deserializer=app_connections_service.AppConnection.deserialize, @@ -357,7 +442,7 @@ def create_app_connection( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_app_connection" not in self._stubs: - self._stubs["create_app_connection"] = self.grpc_channel.unary_unary( + self._stubs["create_app_connection"] = self._logged_channel.unary_unary( "/google.cloud.beyondcorp.appconnections.v1.AppConnectionsService/CreateAppConnection", request_serializer=app_connections_service.CreateAppConnectionRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -386,7 +471,7 @@ def update_app_connection( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_app_connection" not in self._stubs: - self._stubs["update_app_connection"] = self.grpc_channel.unary_unary( + self._stubs["update_app_connection"] = self._logged_channel.unary_unary( "/google.cloud.beyondcorp.appconnections.v1.AppConnectionsService/UpdateAppConnection", request_serializer=app_connections_service.UpdateAppConnectionRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -415,7 +500,7 @@ def delete_app_connection( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_app_connection" not in self._stubs: - self._stubs["delete_app_connection"] = self.grpc_channel.unary_unary( + self._stubs["delete_app_connection"] = self._logged_channel.unary_unary( "/google.cloud.beyondcorp.appconnections.v1.AppConnectionsService/DeleteAppConnection", request_serializer=app_connections_service.DeleteAppConnectionRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -446,7 +531,7 @@ def resolve_app_connections( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "resolve_app_connections" not in self._stubs: - self._stubs["resolve_app_connections"] = self.grpc_channel.unary_unary( + self._stubs["resolve_app_connections"] = self._logged_channel.unary_unary( "/google.cloud.beyondcorp.appconnections.v1.AppConnectionsService/ResolveAppConnections", request_serializer=app_connections_service.ResolveAppConnectionsRequest.serialize, response_deserializer=app_connections_service.ResolveAppConnectionsResponse.deserialize, @@ -539,7 +624,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: @@ -555,7 +640,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, @@ -572,7 +657,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, @@ -589,7 +674,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, @@ -608,7 +693,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, @@ -627,7 +712,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, @@ -644,7 +729,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, @@ -669,7 +754,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, @@ -695,7 +780,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, @@ -724,7 +809,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-beyondcorp-appconnections/google/cloud/beyondcorp_appconnections_v1/services/app_connections_service/transports/rest.py b/packages/google-cloud-beyondcorp-appconnections/google/cloud/beyondcorp_appconnections_v1/services/app_connections_service/transports/rest.py index 1ced34c3355d..f592e2460673 100644 --- a/packages/google-cloud-beyondcorp-appconnections/google/cloud/beyondcorp_appconnections_v1/services/app_connections_service/transports/rest.py +++ b/packages/google-cloud-beyondcorp-appconnections/google/cloud/beyondcorp_appconnections_v1/services/app_connections_service/transports/rest.py @@ -13,9 +13,9 @@ # See the License for the specific language governing permissions and # limitations under the License. # - import dataclasses import json # type: ignore +import logging from typing import Any, Callable, Dict, List, Optional, Sequence, Tuple, Union import warnings @@ -41,6 +41,14 @@ except AttributeError: # pragma: NO COVER OptionalRetry = Union[retries.Retry, object, None] # type: ignore +try: + from google.api_core import client_logging # type: ignore + + CLIENT_LOGGING_SUPPORTED = True # pragma: NO COVER +except ImportError: # pragma: NO COVER + CLIENT_LOGGING_SUPPORTED = False + +_LOGGER = logging.getLogger(__name__) DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo( gapic_version=BASE_DEFAULT_CLIENT_INFO.gapic_version, @@ -121,9 +129,10 @@ def post_update_app_connection(self, response): def pre_create_app_connection( self, request: app_connections_service.CreateAppConnectionRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ - app_connections_service.CreateAppConnectionRequest, Sequence[Tuple[str, str]] + app_connections_service.CreateAppConnectionRequest, + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for create_app_connection @@ -146,9 +155,10 @@ def post_create_app_connection( def pre_delete_app_connection( self, request: app_connections_service.DeleteAppConnectionRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ - app_connections_service.DeleteAppConnectionRequest, Sequence[Tuple[str, str]] + app_connections_service.DeleteAppConnectionRequest, + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for delete_app_connection @@ -171,9 +181,10 @@ def post_delete_app_connection( def pre_get_app_connection( self, request: app_connections_service.GetAppConnectionRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ - app_connections_service.GetAppConnectionRequest, Sequence[Tuple[str, str]] + app_connections_service.GetAppConnectionRequest, + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for get_app_connection @@ -196,9 +207,10 @@ def post_get_app_connection( def pre_list_app_connections( self, request: app_connections_service.ListAppConnectionsRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ - app_connections_service.ListAppConnectionsRequest, Sequence[Tuple[str, str]] + app_connections_service.ListAppConnectionsRequest, + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for list_app_connections @@ -221,9 +233,10 @@ def post_list_app_connections( def pre_resolve_app_connections( self, request: app_connections_service.ResolveAppConnectionsRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ - app_connections_service.ResolveAppConnectionsRequest, Sequence[Tuple[str, str]] + app_connections_service.ResolveAppConnectionsRequest, + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for resolve_app_connections @@ -246,9 +259,10 @@ def post_resolve_app_connections( def pre_update_app_connection( self, request: app_connections_service.UpdateAppConnectionRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ - app_connections_service.UpdateAppConnectionRequest, Sequence[Tuple[str, str]] + app_connections_service.UpdateAppConnectionRequest, + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for update_app_connection @@ -271,8 +285,10 @@ def post_update_app_connection( 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 @@ -294,8 +310,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 @@ -317,8 +335,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 @@ -338,8 +358,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 @@ -359,8 +381,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 @@ -382,8 +407,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 @@ -403,8 +430,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 @@ -424,8 +453,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 @@ -447,8 +478,10 @@ def post_get_operation( def pre_list_operations( self, request: operations_pb2.ListOperationsRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[operations_pb2.ListOperationsRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + operations_pb2.ListOperationsRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for list_operations Override in a subclass to manipulate the request or metadata @@ -657,7 +690,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Call the create app connection method over HTTP. @@ -668,8 +701,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.operations_pb2.Operation: @@ -682,6 +717,7 @@ def __call__( http_options = ( _BaseAppConnectionsServiceRestTransport._BaseCreateAppConnection._get_http_options() ) + request, metadata = self._interceptor.pre_create_app_connection( request, metadata ) @@ -698,6 +734,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.beyondcorp.appconnections_v1.AppConnectionsServiceClient.CreateAppConnection", + extra={ + "serviceName": "google.cloud.beyondcorp.appconnections.v1.AppConnectionsService", + "rpcName": "CreateAppConnection", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ( AppConnectionsServiceRestTransport._CreateAppConnection._get_response( @@ -719,7 +782,29 @@ def __call__( # Return the response resp = operations_pb2.Operation() json_format.Parse(response.content, resp, ignore_unknown_fields=True) + resp = self._interceptor.post_create_app_connection(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = json_format.MessageToJson(resp) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.beyondcorp.appconnections_v1.AppConnectionsServiceClient.create_app_connection", + extra={ + "serviceName": "google.cloud.beyondcorp.appconnections.v1.AppConnectionsService", + "rpcName": "CreateAppConnection", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _DeleteAppConnection( @@ -757,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]]] = (), ) -> operations_pb2.Operation: r"""Call the delete app connection method over HTTP. @@ -768,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: ~.operations_pb2.Operation: @@ -782,6 +869,7 @@ def __call__( http_options = ( _BaseAppConnectionsServiceRestTransport._BaseDeleteAppConnection._get_http_options() ) + request, metadata = self._interceptor.pre_delete_app_connection( request, metadata ) @@ -794,6 +882,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.beyondcorp.appconnections_v1.AppConnectionsServiceClient.DeleteAppConnection", + extra={ + "serviceName": "google.cloud.beyondcorp.appconnections.v1.AppConnectionsService", + "rpcName": "DeleteAppConnection", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ( AppConnectionsServiceRestTransport._DeleteAppConnection._get_response( @@ -814,7 +929,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_app_connection(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = json_format.MessageToJson(resp) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.beyondcorp.appconnections_v1.AppConnectionsServiceClient.delete_app_connection", + extra={ + "serviceName": "google.cloud.beyondcorp.appconnections.v1.AppConnectionsService", + "rpcName": "DeleteAppConnection", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _GetAppConnection( @@ -852,7 +989,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> app_connections_service.AppConnection: r"""Call the get app connection method over HTTP. @@ -863,8 +1000,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.app_connections_service.AppConnection: @@ -882,6 +1021,7 @@ def __call__( http_options = ( _BaseAppConnectionsServiceRestTransport._BaseGetAppConnection._get_http_options() ) + request, metadata = self._interceptor.pre_get_app_connection( request, metadata ) @@ -894,6 +1034,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.beyondcorp.appconnections_v1.AppConnectionsServiceClient.GetAppConnection", + extra={ + "serviceName": "google.cloud.beyondcorp.appconnections.v1.AppConnectionsService", + "rpcName": "GetAppConnection", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ( AppConnectionsServiceRestTransport._GetAppConnection._get_response( @@ -916,7 +1083,31 @@ def __call__( pb_resp = app_connections_service.AppConnection.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_app_connection(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = app_connections_service.AppConnection.to_json( + response + ) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.beyondcorp.appconnections_v1.AppConnectionsServiceClient.get_app_connection", + extra={ + "serviceName": "google.cloud.beyondcorp.appconnections.v1.AppConnectionsService", + "rpcName": "GetAppConnection", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ListAppConnections( @@ -954,7 +1145,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> app_connections_service.ListAppConnectionsResponse: r"""Call the list app connections method over HTTP. @@ -965,8 +1156,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.app_connections_service.ListAppConnectionsResponse: @@ -978,6 +1171,7 @@ def __call__( http_options = ( _BaseAppConnectionsServiceRestTransport._BaseListAppConnections._get_http_options() ) + request, metadata = self._interceptor.pre_list_app_connections( request, metadata ) @@ -990,6 +1184,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.beyondcorp.appconnections_v1.AppConnectionsServiceClient.ListAppConnections", + extra={ + "serviceName": "google.cloud.beyondcorp.appconnections.v1.AppConnectionsService", + "rpcName": "ListAppConnections", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ( AppConnectionsServiceRestTransport._ListAppConnections._get_response( @@ -1012,7 +1233,33 @@ def __call__( pb_resp = app_connections_service.ListAppConnectionsResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_app_connections(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = ( + app_connections_service.ListAppConnectionsResponse.to_json( + response + ) + ) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.beyondcorp.appconnections_v1.AppConnectionsServiceClient.list_app_connections", + extra={ + "serviceName": "google.cloud.beyondcorp.appconnections.v1.AppConnectionsService", + "rpcName": "ListAppConnections", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ResolveAppConnections( @@ -1050,7 +1297,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> app_connections_service.ResolveAppConnectionsResponse: r"""Call the resolve app connections method over HTTP. @@ -1061,8 +1308,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.app_connections_service.ResolveAppConnectionsResponse: @@ -1074,6 +1323,7 @@ def __call__( http_options = ( _BaseAppConnectionsServiceRestTransport._BaseResolveAppConnections._get_http_options() ) + request, metadata = self._interceptor.pre_resolve_app_connections( request, metadata ) @@ -1086,6 +1336,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.beyondcorp.appconnections_v1.AppConnectionsServiceClient.ResolveAppConnections", + extra={ + "serviceName": "google.cloud.beyondcorp.appconnections.v1.AppConnectionsService", + "rpcName": "ResolveAppConnections", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ( AppConnectionsServiceRestTransport._ResolveAppConnections._get_response( @@ -1108,7 +1385,33 @@ def __call__( pb_resp = app_connections_service.ResolveAppConnectionsResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_resolve_app_connections(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = ( + app_connections_service.ResolveAppConnectionsResponse.to_json( + response + ) + ) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.beyondcorp.appconnections_v1.AppConnectionsServiceClient.resolve_app_connections", + extra={ + "serviceName": "google.cloud.beyondcorp.appconnections.v1.AppConnectionsService", + "rpcName": "ResolveAppConnections", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _UpdateAppConnection( @@ -1147,7 +1450,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Call the update app connection method over HTTP. @@ -1158,8 +1461,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.operations_pb2.Operation: @@ -1172,6 +1477,7 @@ def __call__( http_options = ( _BaseAppConnectionsServiceRestTransport._BaseUpdateAppConnection._get_http_options() ) + request, metadata = self._interceptor.pre_update_app_connection( request, metadata ) @@ -1188,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.beyondcorp.appconnections_v1.AppConnectionsServiceClient.UpdateAppConnection", + extra={ + "serviceName": "google.cloud.beyondcorp.appconnections.v1.AppConnectionsService", + "rpcName": "UpdateAppConnection", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ( AppConnectionsServiceRestTransport._UpdateAppConnection._get_response( @@ -1209,7 +1542,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_app_connection(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = json_format.MessageToJson(resp) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.beyondcorp.appconnections_v1.AppConnectionsServiceClient.update_app_connection", + extra={ + "serviceName": "google.cloud.beyondcorp.appconnections.v1.AppConnectionsService", + "rpcName": "UpdateAppConnection", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp @property @@ -1314,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]]] = (), ) -> locations_pb2.Location: r"""Call the get location method over HTTP. @@ -1324,8 +1679,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each 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. @@ -1334,6 +1691,7 @@ def __call__( http_options = ( _BaseAppConnectionsServiceRestTransport._BaseGetLocation._get_http_options() ) + request, metadata = self._interceptor.pre_get_location(request, metadata) transcoded_request = _BaseAppConnectionsServiceRestTransport._BaseGetLocation._get_transcoded_request( http_options, request @@ -1344,6 +1702,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.beyondcorp.appconnections_v1.AppConnectionsServiceClient.GetLocation", + extra={ + "serviceName": "google.cloud.beyondcorp.appconnections.v1.AppConnectionsService", + "rpcName": "GetLocation", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = AppConnectionsServiceRestTransport._GetLocation._get_response( self._host, @@ -1363,6 +1748,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.beyondcorp.appconnections_v1.AppConnectionsServiceAsyncClient.GetLocation", + extra={ + "serviceName": "google.cloud.beyondcorp.appconnections.v1.AppConnectionsService", + "rpcName": "GetLocation", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property @@ -1404,7 +1810,7 @@ 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. @@ -1414,8 +1820,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each 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. @@ -1424,6 +1832,7 @@ def __call__( http_options = ( _BaseAppConnectionsServiceRestTransport._BaseListLocations._get_http_options() ) + request, metadata = self._interceptor.pre_list_locations(request, metadata) transcoded_request = _BaseAppConnectionsServiceRestTransport._BaseListLocations._get_transcoded_request( http_options, request @@ -1434,6 +1843,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.beyondcorp.appconnections_v1.AppConnectionsServiceClient.ListLocations", + extra={ + "serviceName": "google.cloud.beyondcorp.appconnections.v1.AppConnectionsService", + "rpcName": "ListLocations", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = AppConnectionsServiceRestTransport._ListLocations._get_response( self._host, @@ -1453,6 +1889,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.beyondcorp.appconnections_v1.AppConnectionsServiceAsyncClient.ListLocations", + extra={ + "serviceName": "google.cloud.beyondcorp.appconnections.v1.AppConnectionsService", + "rpcName": "ListLocations", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property @@ -1494,7 +1951,7 @@ 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. @@ -1504,8 +1961,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each 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. @@ -1514,6 +1973,7 @@ def __call__( http_options = ( _BaseAppConnectionsServiceRestTransport._BaseGetIamPolicy._get_http_options() ) + request, metadata = self._interceptor.pre_get_iam_policy(request, metadata) transcoded_request = _BaseAppConnectionsServiceRestTransport._BaseGetIamPolicy._get_transcoded_request( http_options, request @@ -1524,6 +1984,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.beyondcorp.appconnections_v1.AppConnectionsServiceClient.GetIamPolicy", + extra={ + "serviceName": "google.cloud.beyondcorp.appconnections.v1.AppConnectionsService", + "rpcName": "GetIamPolicy", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = AppConnectionsServiceRestTransport._GetIamPolicy._get_response( self._host, @@ -1543,6 +2030,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.beyondcorp.appconnections_v1.AppConnectionsServiceAsyncClient.GetIamPolicy", + extra={ + "serviceName": "google.cloud.beyondcorp.appconnections.v1.AppConnectionsService", + "rpcName": "GetIamPolicy", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property @@ -1585,7 +2093,7 @@ 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. @@ -1595,8 +2103,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each 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. @@ -1605,6 +2115,7 @@ def __call__( http_options = ( _BaseAppConnectionsServiceRestTransport._BaseSetIamPolicy._get_http_options() ) + request, metadata = self._interceptor.pre_set_iam_policy(request, metadata) transcoded_request = _BaseAppConnectionsServiceRestTransport._BaseSetIamPolicy._get_transcoded_request( http_options, request @@ -1619,6 +2130,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.beyondcorp.appconnections_v1.AppConnectionsServiceClient.SetIamPolicy", + extra={ + "serviceName": "google.cloud.beyondcorp.appconnections.v1.AppConnectionsService", + "rpcName": "SetIamPolicy", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = AppConnectionsServiceRestTransport._SetIamPolicy._get_response( self._host, @@ -1639,6 +2177,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.beyondcorp.appconnections_v1.AppConnectionsServiceAsyncClient.SetIamPolicy", + extra={ + "serviceName": "google.cloud.beyondcorp.appconnections.v1.AppConnectionsService", + "rpcName": "SetIamPolicy", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property @@ -1681,7 +2240,7 @@ 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. @@ -1691,8 +2250,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each 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. @@ -1701,6 +2262,7 @@ def __call__( http_options = ( _BaseAppConnectionsServiceRestTransport._BaseTestIamPermissions._get_http_options() ) + request, metadata = self._interceptor.pre_test_iam_permissions( request, metadata ) @@ -1717,6 +2279,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.beyondcorp.appconnections_v1.AppConnectionsServiceClient.TestIamPermissions", + extra={ + "serviceName": "google.cloud.beyondcorp.appconnections.v1.AppConnectionsService", + "rpcName": "TestIamPermissions", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ( AppConnectionsServiceRestTransport._TestIamPermissions._get_response( @@ -1739,6 +2328,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.beyondcorp.appconnections_v1.AppConnectionsServiceAsyncClient.TestIamPermissions", + extra={ + "serviceName": "google.cloud.beyondcorp.appconnections.v1.AppConnectionsService", + "rpcName": "TestIamPermissions", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property @@ -1781,7 +2391,7 @@ 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. @@ -1791,13 +2401,16 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. """ http_options = ( _BaseAppConnectionsServiceRestTransport._BaseCancelOperation._get_http_options() ) + request, metadata = self._interceptor.pre_cancel_operation( request, metadata ) @@ -1814,6 +2427,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.beyondcorp.appconnections_v1.AppConnectionsServiceClient.CancelOperation", + extra={ + "serviceName": "google.cloud.beyondcorp.appconnections.v1.AppConnectionsService", + "rpcName": "CancelOperation", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ( AppConnectionsServiceRestTransport._CancelOperation._get_response( @@ -1873,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]]] = (), ) -> None: r"""Call the delete operation method over HTTP. @@ -1883,13 +2523,16 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. """ http_options = ( _BaseAppConnectionsServiceRestTransport._BaseDeleteOperation._get_http_options() ) + request, metadata = self._interceptor.pre_delete_operation( request, metadata ) @@ -1902,6 +2545,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.beyondcorp.appconnections_v1.AppConnectionsServiceClient.DeleteOperation", + extra={ + "serviceName": "google.cloud.beyondcorp.appconnections.v1.AppConnectionsService", + "rpcName": "DeleteOperation", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ( AppConnectionsServiceRestTransport._DeleteOperation._get_response( @@ -1960,7 +2630,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Call the get operation method over HTTP. @@ -1970,8 +2640,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be 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. @@ -1980,6 +2652,7 @@ def __call__( http_options = ( _BaseAppConnectionsServiceRestTransport._BaseGetOperation._get_http_options() ) + request, metadata = self._interceptor.pre_get_operation(request, metadata) transcoded_request = _BaseAppConnectionsServiceRestTransport._BaseGetOperation._get_transcoded_request( http_options, request @@ -1990,6 +2663,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.beyondcorp.appconnections_v1.AppConnectionsServiceClient.GetOperation", + extra={ + "serviceName": "google.cloud.beyondcorp.appconnections.v1.AppConnectionsService", + "rpcName": "GetOperation", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = AppConnectionsServiceRestTransport._GetOperation._get_response( self._host, @@ -2009,6 +2709,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.beyondcorp.appconnections_v1.AppConnectionsServiceAsyncClient.GetOperation", + extra={ + "serviceName": "google.cloud.beyondcorp.appconnections.v1.AppConnectionsService", + "rpcName": "GetOperation", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property @@ -2050,7 +2771,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.ListOperationsResponse: r"""Call the list operations method over HTTP. @@ -2060,8 +2781,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of 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. @@ -2070,6 +2793,7 @@ def __call__( http_options = ( _BaseAppConnectionsServiceRestTransport._BaseListOperations._get_http_options() ) + request, metadata = self._interceptor.pre_list_operations(request, metadata) transcoded_request = _BaseAppConnectionsServiceRestTransport._BaseListOperations._get_transcoded_request( http_options, request @@ -2080,6 +2804,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.beyondcorp.appconnections_v1.AppConnectionsServiceClient.ListOperations", + extra={ + "serviceName": "google.cloud.beyondcorp.appconnections.v1.AppConnectionsService", + "rpcName": "ListOperations", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = AppConnectionsServiceRestTransport._ListOperations._get_response( self._host, @@ -2099,6 +2850,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.beyondcorp.appconnections_v1.AppConnectionsServiceAsyncClient.ListOperations", + extra={ + "serviceName": "google.cloud.beyondcorp.appconnections.v1.AppConnectionsService", + "rpcName": "ListOperations", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property diff --git a/packages/google-cloud-beyondcorp-appconnections/samples/generated_samples/snippet_metadata_google.cloud.beyondcorp.appconnections.v1.json b/packages/google-cloud-beyondcorp-appconnections/samples/generated_samples/snippet_metadata_google.cloud.beyondcorp.appconnections.v1.json index 2409ab52fa34..f730a69adfa5 100644 --- a/packages/google-cloud-beyondcorp-appconnections/samples/generated_samples/snippet_metadata_google.cloud.beyondcorp.appconnections.v1.json +++ b/packages/google-cloud-beyondcorp-appconnections/samples/generated_samples/snippet_metadata_google.cloud.beyondcorp.appconnections.v1.json @@ -8,7 +8,7 @@ ], "language": "PYTHON", "name": "google-cloud-beyondcorp-appconnections", - "version": "0.4.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.beyondcorp_appconnections_v1.types.AppConnection", @@ -465,7 +465,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.beyondcorp_appconnections_v1.types.AppConnection", @@ -546,7 +546,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.beyondcorp_appconnections_v1.services.app_connections_service.pagers.ListAppConnectionsAsyncPager", @@ -626,7 +626,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.beyondcorp_appconnections_v1.services.app_connections_service.pagers.ListAppConnectionsPager", @@ -707,7 +707,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.beyondcorp_appconnections_v1.services.app_connections_service.pagers.ResolveAppConnectionsAsyncPager", @@ -787,7 +787,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.beyondcorp_appconnections_v1.services.app_connections_service.pagers.ResolveAppConnectionsPager", @@ -872,7 +872,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -956,7 +956,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", diff --git a/packages/google-cloud-beyondcorp-appconnections/tests/unit/gapic/beyondcorp_appconnections_v1/test_app_connections_service.py b/packages/google-cloud-beyondcorp-appconnections/tests/unit/gapic/beyondcorp_appconnections_v1/test_app_connections_service.py index 94266beb90a2..7b90d9885d57 100644 --- a/packages/google-cloud-beyondcorp-appconnections/tests/unit/gapic/beyondcorp_appconnections_v1/test_app_connections_service.py +++ b/packages/google-cloud-beyondcorp-appconnections/tests/unit/gapic/beyondcorp_appconnections_v1/test_app_connections_service.py @@ -3818,6 +3818,7 @@ def test_list_app_connections_rest_required_fields( response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.list_app_connections(request) @@ -3875,6 +3876,7 @@ def test_list_app_connections_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.list_app_connections(**mock_args) @@ -4076,6 +4078,7 @@ def test_get_app_connection_rest_required_fields( response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.get_app_connection(request) @@ -4123,6 +4126,7 @@ def test_get_app_connection_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.get_app_connection(**mock_args) @@ -4269,6 +4273,7 @@ def test_create_app_connection_rest_required_fields( response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.create_app_connection(request) @@ -4328,6 +4333,7 @@ def test_create_app_connection_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.create_app_connection(**mock_args) @@ -4472,6 +4478,7 @@ def test_update_app_connection_rest_required_fields( response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.update_app_connection(request) @@ -4535,6 +4542,7 @@ def test_update_app_connection_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.update_app_connection(**mock_args) @@ -4680,6 +4688,7 @@ def test_delete_app_connection_rest_required_fields( response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.delete_app_connection(request) @@ -4733,6 +4742,7 @@ def test_delete_app_connection_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.delete_app_connection(**mock_args) @@ -4886,6 +4896,7 @@ def test_resolve_app_connections_rest_required_fields( response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.resolve_app_connections(request) @@ -4953,6 +4964,7 @@ def test_resolve_app_connections_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.resolve_app_connections(**mock_args) @@ -5513,6 +5525,7 @@ def test_list_app_connections_rest_bad_request( response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.list_app_connections(request) @@ -5551,6 +5564,7 @@ def test_list_app_connections_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.list_app_connections(request) # Establish that the response is the type that we expect. @@ -5592,6 +5606,7 @@ def test_list_app_connections_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = app_connections_service.ListAppConnectionsResponse.to_json( app_connections_service.ListAppConnectionsResponse() ) @@ -5638,6 +5653,7 @@ def test_get_app_connection_rest_bad_request( response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.get_app_connection(request) @@ -5678,6 +5694,7 @@ def test_get_app_connection_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.get_app_connection(request) # Establish that the response is the type that we expect. @@ -5723,6 +5740,7 @@ def test_get_app_connection_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = app_connections_service.AppConnection.to_json( app_connections_service.AppConnection() ) @@ -5769,6 +5787,7 @@ def test_create_app_connection_rest_bad_request( response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.create_app_connection(request) @@ -5886,6 +5905,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.create_app_connection(request) # Establish that the response is the type that we expect. @@ -5927,6 +5947,7 @@ def test_create_app_connection_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = json_format.MessageToJson(operations_pb2.Operation()) req.return_value.content = return_value @@ -5975,6 +5996,7 @@ def test_update_app_connection_rest_bad_request( response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.update_app_connection(request) @@ -6096,6 +6118,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.update_app_connection(request) # Establish that the response is the type that we expect. @@ -6137,6 +6160,7 @@ def test_update_app_connection_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = json_format.MessageToJson(operations_pb2.Operation()) req.return_value.content = return_value @@ -6181,6 +6205,7 @@ def test_delete_app_connection_rest_bad_request( response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.delete_app_connection(request) @@ -6211,6 +6236,7 @@ def test_delete_app_connection_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.delete_app_connection(request) # Establish that the response is the type that we expect. @@ -6252,6 +6278,7 @@ def test_delete_app_connection_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = json_format.MessageToJson(operations_pb2.Operation()) req.return_value.content = return_value @@ -6296,6 +6323,7 @@ def test_resolve_app_connections_rest_bad_request( response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.resolve_app_connections(request) @@ -6334,6 +6362,7 @@ def test_resolve_app_connections_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.resolve_app_connections(request) # Establish that the response is the type that we expect. @@ -6375,6 +6404,7 @@ def test_resolve_app_connections_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = app_connections_service.ResolveAppConnectionsResponse.to_json( app_connections_service.ResolveAppConnectionsResponse() ) @@ -6421,6 +6451,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) @@ -6451,6 +6482,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) @@ -6479,6 +6511,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) @@ -6509,6 +6542,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) @@ -6540,6 +6574,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) @@ -6572,6 +6607,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) @@ -6603,6 +6639,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) @@ -6635,6 +6672,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) @@ -6666,6 +6704,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) @@ -6698,6 +6737,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) @@ -6728,6 +6768,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) @@ -6758,6 +6799,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) @@ -6788,6 +6830,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) @@ -6818,6 +6861,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) @@ -6848,6 +6892,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) @@ -6878,6 +6923,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) @@ -6908,6 +6954,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) @@ -6938,6 +6985,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-beyondcorp-appconnectors/google/cloud/beyondcorp_appconnectors/gapic_version.py b/packages/google-cloud-beyondcorp-appconnectors/google/cloud/beyondcorp_appconnectors/gapic_version.py index 9b19e5f10e00..558c8aab67c5 100644 --- a/packages/google-cloud-beyondcorp-appconnectors/google/cloud/beyondcorp_appconnectors/gapic_version.py +++ b/packages/google-cloud-beyondcorp-appconnectors/google/cloud/beyondcorp_appconnectors/gapic_version.py @@ -13,4 +13,4 @@ # See the License for the specific language governing permissions and # limitations under the License. # -__version__ = "0.4.13" # {x-release-please-version} +__version__ = "0.0.0" # {x-release-please-version} diff --git a/packages/google-cloud-beyondcorp-appconnectors/google/cloud/beyondcorp_appconnectors_v1/gapic_version.py b/packages/google-cloud-beyondcorp-appconnectors/google/cloud/beyondcorp_appconnectors_v1/gapic_version.py index 9b19e5f10e00..558c8aab67c5 100644 --- a/packages/google-cloud-beyondcorp-appconnectors/google/cloud/beyondcorp_appconnectors_v1/gapic_version.py +++ b/packages/google-cloud-beyondcorp-appconnectors/google/cloud/beyondcorp_appconnectors_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.13" # {x-release-please-version} +__version__ = "0.0.0" # {x-release-please-version} diff --git a/packages/google-cloud-beyondcorp-appconnectors/google/cloud/beyondcorp_appconnectors_v1/services/app_connectors_service/async_client.py b/packages/google-cloud-beyondcorp-appconnectors/google/cloud/beyondcorp_appconnectors_v1/services/app_connectors_service/async_client.py index d4e2a2a3add7..4136983386c7 100644 --- a/packages/google-cloud-beyondcorp-appconnectors/google/cloud/beyondcorp_appconnectors_v1/services/app_connectors_service/async_client.py +++ b/packages/google-cloud-beyondcorp-appconnectors/google/cloud/beyondcorp_appconnectors_v1/services/app_connectors_service/async_client.py @@ -14,6 +14,7 @@ # limitations under the License. # from collections import OrderedDict +import logging as std_logging import re from typing import ( Callable, @@ -65,6 +66,15 @@ from .transports.base import DEFAULT_CLIENT_INFO, AppConnectorsServiceTransport from .transports.grpc_asyncio import AppConnectorsServiceGrpcAsyncIOTransport +try: + from google.api_core import client_logging # type: ignore + + CLIENT_LOGGING_SUPPORTED = True # pragma: NO COVER +except ImportError: # pragma: NO COVER + CLIENT_LOGGING_SUPPORTED = False + +_LOGGER = std_logging.getLogger(__name__) + class AppConnectorsServiceAsyncClient: """API Overview: @@ -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.beyondcorp.appconnectors_v1.AppConnectorsServiceAsyncClient`.", + extra={ + "serviceName": "google.cloud.beyondcorp.appconnectors.v1.AppConnectorsService", + "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.beyondcorp.appconnectors.v1.AppConnectorsService", + "credentialsType": None, + }, + ) + async def list_app_connectors( self, request: Optional[ @@ -299,7 +331,7 @@ async def list_app_connectors( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListAppConnectorsAsyncPager: r"""Lists AppConnectors in a given project and location. @@ -345,8 +377,10 @@ async def sample_list_app_connectors(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.beyondcorp_appconnectors_v1.services.app_connectors_service.pagers.ListAppConnectorsAsyncPager: @@ -423,7 +457,7 @@ async def get_app_connector( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> app_connectors_service.AppConnector: r"""Gets details of a single AppConnector. @@ -467,8 +501,10 @@ async def sample_get_app_connector(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.beyondcorp_appconnectors_v1.types.AppConnector: @@ -541,7 +577,7 @@ async def create_app_connector( app_connector_id: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation_async.AsyncOperation: r"""Creates a new AppConnector in a given project and location. @@ -613,8 +649,10 @@ async def sample_create_app_connector(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.api_core.operation_async.AsyncOperation: @@ -697,7 +735,7 @@ async def update_app_connector( update_mask: Optional[field_mask_pb2.FieldMask] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, 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 AppConnector. @@ -760,8 +798,10 @@ async def sample_update_app_connector(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.api_core.operation_async.AsyncOperation: @@ -843,7 +883,7 @@ async def delete_app_connector( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation_async.AsyncOperation: r"""Deletes a single AppConnector. @@ -891,8 +931,10 @@ async def sample_delete_app_connector(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.api_core.operation_async.AsyncOperation: @@ -974,7 +1016,7 @@ async def report_status( resource_info: Optional[gcba_resource_info.ResourceInfo] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation_async.AsyncOperation: r"""Report status for a given connector. @@ -1032,8 +1074,10 @@ async def sample_report_status(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.api_core.operation_async.AsyncOperation: @@ -1112,7 +1156,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. @@ -1123,8 +1167,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. @@ -1165,7 +1211,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. @@ -1176,8 +1222,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. @@ -1218,7 +1266,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. @@ -1234,8 +1282,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 """ @@ -1272,7 +1322,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. @@ -1287,8 +1337,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 """ @@ -1325,7 +1377,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. @@ -1338,8 +1390,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. @@ -1444,7 +1498,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. @@ -1458,8 +1512,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. @@ -1564,7 +1620,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. @@ -1579,8 +1635,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. @@ -1624,7 +1682,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. @@ -1635,8 +1693,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. @@ -1677,7 +1737,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. @@ -1688,8 +1748,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-beyondcorp-appconnectors/google/cloud/beyondcorp_appconnectors_v1/services/app_connectors_service/client.py b/packages/google-cloud-beyondcorp-appconnectors/google/cloud/beyondcorp_appconnectors_v1/services/app_connectors_service/client.py index 58ab8fef2955..b5329c0c274e 100644 --- a/packages/google-cloud-beyondcorp-appconnectors/google/cloud/beyondcorp_appconnectors_v1/services/app_connectors_service/client.py +++ b/packages/google-cloud-beyondcorp-appconnectors/google/cloud/beyondcorp_appconnectors_v1/services/app_connectors_service/client.py @@ -14,6 +14,7 @@ # limitations under the License. # from collections import OrderedDict +import logging as std_logging import os import re from typing import ( @@ -48,6 +49,15 @@ except AttributeError: # pragma: NO COVER OptionalRetry = Union[retries.Retry, object, None] # type: ignore +try: + from google.api_core import client_logging # type: ignore + + CLIENT_LOGGING_SUPPORTED = True # pragma: NO COVER +except ImportError: # pragma: NO COVER + CLIENT_LOGGING_SUPPORTED = False + +_LOGGER = std_logging.getLogger(__name__) + from google.api_core import operation # type: ignore from google.api_core import operation_async # type: ignore from google.cloud.location import locations_pb2 # type: ignore @@ -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.cloud.beyondcorp.appconnectors_v1.AppConnectorsServiceClient`.", + extra={ + "serviceName": "google.cloud.beyondcorp.appconnectors.v1.AppConnectorsService", + "universeDomain": getattr( + self._transport._credentials, "universe_domain", "" + ), + "credentialsType": f"{type(self._transport._credentials).__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.beyondcorp.appconnectors.v1.AppConnectorsService", + "credentialsType": None, + }, + ) + def list_app_connectors( self, request: Optional[ @@ -687,7 +724,7 @@ def list_app_connectors( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListAppConnectorsPager: r"""Lists AppConnectors in a given project and location. @@ -733,8 +770,10 @@ def sample_list_app_connectors(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.beyondcorp_appconnectors_v1.services.app_connectors_service.pagers.ListAppConnectorsPager: @@ -808,7 +847,7 @@ def get_app_connector( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> app_connectors_service.AppConnector: r"""Gets details of a single AppConnector. @@ -852,8 +891,10 @@ def sample_get_app_connector(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.beyondcorp_appconnectors_v1.types.AppConnector: @@ -923,7 +964,7 @@ def create_app_connector( app_connector_id: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation.Operation: r"""Creates a new AppConnector in a given project and location. @@ -995,8 +1036,10 @@ def sample_create_app_connector(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.api_core.operation.Operation: @@ -1076,7 +1119,7 @@ def update_app_connector( update_mask: Optional[field_mask_pb2.FieldMask] = None, retry: OptionalRetry = gapic_v1.method.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 AppConnector. @@ -1139,8 +1182,10 @@ def sample_update_app_connector(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.api_core.operation.Operation: @@ -1219,7 +1264,7 @@ def delete_app_connector( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation.Operation: r"""Deletes a single AppConnector. @@ -1267,8 +1312,10 @@ def sample_delete_app_connector(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.api_core.operation.Operation: @@ -1347,7 +1394,7 @@ def report_status( resource_info: Optional[gcba_resource_info.ResourceInfo] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation.Operation: r"""Report status for a given connector. @@ -1405,8 +1452,10 @@ def sample_report_status(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.api_core.operation.Operation: @@ -1495,7 +1544,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. @@ -1506,8 +1555,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. @@ -1548,7 +1599,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. @@ -1559,8 +1610,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. @@ -1601,7 +1654,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. @@ -1617,8 +1670,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 """ @@ -1655,7 +1710,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. @@ -1670,8 +1725,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 """ @@ -1708,7 +1765,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. @@ -1721,8 +1778,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. @@ -1827,7 +1886,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. @@ -1841,8 +1900,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. @@ -1947,7 +2008,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. @@ -1962,8 +2023,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. @@ -2005,7 +2068,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. @@ -2016,8 +2079,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. @@ -2058,7 +2123,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. @@ -2069,8 +2134,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-beyondcorp-appconnectors/google/cloud/beyondcorp_appconnectors_v1/services/app_connectors_service/pagers.py b/packages/google-cloud-beyondcorp-appconnectors/google/cloud/beyondcorp_appconnectors_v1/services/app_connectors_service/pagers.py index 4f69d67f725e..a340b32c15ca 100644 --- a/packages/google-cloud-beyondcorp-appconnectors/google/cloud/beyondcorp_appconnectors_v1/services/app_connectors_service/pagers.py +++ b/packages/google-cloud-beyondcorp-appconnectors/google/cloud/beyondcorp_appconnectors_v1/services/app_connectors_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 = app_connectors_service.ListAppConnectorsRequest(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 = app_connectors_service.ListAppConnectorsRequest(request) diff --git a/packages/google-cloud-beyondcorp-appconnectors/google/cloud/beyondcorp_appconnectors_v1/services/app_connectors_service/transports/grpc.py b/packages/google-cloud-beyondcorp-appconnectors/google/cloud/beyondcorp_appconnectors_v1/services/app_connectors_service/transports/grpc.py index 78204b6c75e3..171389a41121 100644 --- a/packages/google-cloud-beyondcorp-appconnectors/google/cloud/beyondcorp_appconnectors_v1/services/app_connectors_service/transports/grpc.py +++ b/packages/google-cloud-beyondcorp-appconnectors/google/cloud/beyondcorp_appconnectors_v1/services/app_connectors_service/transports/grpc.py @@ -13,6 +13,9 @@ # See the License for the specific language governing permissions and # limitations under the License. # +import json +import logging as std_logging +import pickle from typing import Callable, Dict, Optional, Sequence, Tuple, Union import warnings @@ -24,12 +27,90 @@ from google.iam.v1 import iam_policy_pb2 # type: ignore from google.iam.v1 import policy_pb2 # type: ignore from google.longrunning import operations_pb2 # type: ignore +from google.protobuf.json_format import MessageToJson +import google.protobuf.message import grpc # type: ignore +import proto # type: ignore from google.cloud.beyondcorp_appconnectors_v1.types import app_connectors_service from .base import DEFAULT_CLIENT_INFO, AppConnectorsServiceTransport +try: + from google.api_core import client_logging # 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.beyondcorp.appconnectors.v1.AppConnectorsService", + "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.beyondcorp.appconnectors.v1.AppConnectorsService", + "rpcName": client_call_details.method, + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class AppConnectorsServiceGrpcTransport(AppConnectorsServiceTransport): """gRPC backend transport for AppConnectorsService. @@ -197,7 +278,12 @@ def __init__( ], ) - # Wrap messages. This must be done after self._grpc_channel exists + self._interceptor = _LoggingClientInterceptor() + self._logged_channel = grpc.intercept_channel( + self._grpc_channel, self._interceptor + ) + + # Wrap messages. This must be done after self._logged_channel exists self._prep_wrapped_messages(client_info) @classmethod @@ -261,7 +347,9 @@ def operations_client(self) -> operations_v1.OperationsClient: """ # Quick check: Only create a new client if we do not already have one. if self._operations_client is None: - self._operations_client = operations_v1.OperationsClient(self.grpc_channel) + self._operations_client = operations_v1.OperationsClient( + self._logged_channel + ) # Return the client from cache. return self._operations_client @@ -288,7 +376,7 @@ def list_app_connectors( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_app_connectors" not in self._stubs: - self._stubs["list_app_connectors"] = self.grpc_channel.unary_unary( + self._stubs["list_app_connectors"] = self._logged_channel.unary_unary( "/google.cloud.beyondcorp.appconnectors.v1.AppConnectorsService/ListAppConnectors", request_serializer=app_connectors_service.ListAppConnectorsRequest.serialize, response_deserializer=app_connectors_service.ListAppConnectorsResponse.deserialize, @@ -317,7 +405,7 @@ def get_app_connector( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_app_connector" not in self._stubs: - self._stubs["get_app_connector"] = self.grpc_channel.unary_unary( + self._stubs["get_app_connector"] = self._logged_channel.unary_unary( "/google.cloud.beyondcorp.appconnectors.v1.AppConnectorsService/GetAppConnector", request_serializer=app_connectors_service.GetAppConnectorRequest.serialize, response_deserializer=app_connectors_service.AppConnector.deserialize, @@ -346,7 +434,7 @@ def create_app_connector( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_app_connector" not in self._stubs: - self._stubs["create_app_connector"] = self.grpc_channel.unary_unary( + self._stubs["create_app_connector"] = self._logged_channel.unary_unary( "/google.cloud.beyondcorp.appconnectors.v1.AppConnectorsService/CreateAppConnector", request_serializer=app_connectors_service.CreateAppConnectorRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -374,7 +462,7 @@ def update_app_connector( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_app_connector" not in self._stubs: - self._stubs["update_app_connector"] = self.grpc_channel.unary_unary( + self._stubs["update_app_connector"] = self._logged_channel.unary_unary( "/google.cloud.beyondcorp.appconnectors.v1.AppConnectorsService/UpdateAppConnector", request_serializer=app_connectors_service.UpdateAppConnectorRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -402,7 +490,7 @@ def delete_app_connector( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_app_connector" not in self._stubs: - self._stubs["delete_app_connector"] = self.grpc_channel.unary_unary( + self._stubs["delete_app_connector"] = self._logged_channel.unary_unary( "/google.cloud.beyondcorp.appconnectors.v1.AppConnectorsService/DeleteAppConnector", request_serializer=app_connectors_service.DeleteAppConnectorRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -430,7 +518,7 @@ def report_status( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "report_status" not in self._stubs: - self._stubs["report_status"] = self.grpc_channel.unary_unary( + self._stubs["report_status"] = self._logged_channel.unary_unary( "/google.cloud.beyondcorp.appconnectors.v1.AppConnectorsService/ReportStatus", request_serializer=app_connectors_service.ReportStatusRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -438,7 +526,7 @@ def report_status( return self._stubs["report_status"] def close(self): - self.grpc_channel.close() + self._logged_channel.close() @property def delete_operation( @@ -450,7 +538,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, @@ -467,7 +555,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, @@ -484,7 +572,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, @@ -503,7 +591,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, @@ -522,7 +610,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, @@ -539,7 +627,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, @@ -564,7 +652,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, @@ -590,7 +678,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, @@ -619,7 +707,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-beyondcorp-appconnectors/google/cloud/beyondcorp_appconnectors_v1/services/app_connectors_service/transports/grpc_asyncio.py b/packages/google-cloud-beyondcorp-appconnectors/google/cloud/beyondcorp_appconnectors_v1/services/app_connectors_service/transports/grpc_asyncio.py index 9c6c8d7dc0f6..4e6d8fa5571b 100644 --- a/packages/google-cloud-beyondcorp-appconnectors/google/cloud/beyondcorp_appconnectors_v1/services/app_connectors_service/transports/grpc_asyncio.py +++ b/packages/google-cloud-beyondcorp-appconnectors/google/cloud/beyondcorp_appconnectors_v1/services/app_connectors_service/transports/grpc_asyncio.py @@ -14,6 +14,9 @@ # limitations under the License. # import inspect +import json +import logging as std_logging +import pickle from typing import Awaitable, Callable, Dict, Optional, Sequence, Tuple, Union import warnings @@ -26,14 +29,93 @@ from google.iam.v1 import iam_policy_pb2 # type: ignore from google.iam.v1 import policy_pb2 # type: ignore from google.longrunning import operations_pb2 # type: ignore +from google.protobuf.json_format import MessageToJson +import google.protobuf.message import grpc # type: ignore from grpc.experimental import aio # type: ignore +import proto # type: ignore from google.cloud.beyondcorp_appconnectors_v1.types import app_connectors_service from .base import DEFAULT_CLIENT_INFO, AppConnectorsServiceTransport from .grpc import AppConnectorsServiceGrpcTransport +try: + from google.api_core import client_logging # 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.beyondcorp.appconnectors.v1.AppConnectorsService", + "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.beyondcorp.appconnectors.v1.AppConnectorsService", + "rpcName": str(client_call_details.method), + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class AppConnectorsServiceGrpcAsyncIOTransport(AppConnectorsServiceTransport): """gRPC AsyncIO backend transport for AppConnectorsService. @@ -244,10 +326,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 operations_client(self) -> operations_v1.OperationsAsyncClient: # Quick check: Only create a new client if we do not already have one. if self._operations_client is None: self._operations_client = operations_v1.OperationsAsyncClient( - self.grpc_channel + self._logged_channel ) # Return the client from cache. @@ -298,7 +383,7 @@ def list_app_connectors( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_app_connectors" not in self._stubs: - self._stubs["list_app_connectors"] = self.grpc_channel.unary_unary( + self._stubs["list_app_connectors"] = self._logged_channel.unary_unary( "/google.cloud.beyondcorp.appconnectors.v1.AppConnectorsService/ListAppConnectors", request_serializer=app_connectors_service.ListAppConnectorsRequest.serialize, response_deserializer=app_connectors_service.ListAppConnectorsResponse.deserialize, @@ -327,7 +412,7 @@ def get_app_connector( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_app_connector" not in self._stubs: - self._stubs["get_app_connector"] = self.grpc_channel.unary_unary( + self._stubs["get_app_connector"] = self._logged_channel.unary_unary( "/google.cloud.beyondcorp.appconnectors.v1.AppConnectorsService/GetAppConnector", request_serializer=app_connectors_service.GetAppConnectorRequest.serialize, response_deserializer=app_connectors_service.AppConnector.deserialize, @@ -357,7 +442,7 @@ def create_app_connector( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_app_connector" not in self._stubs: - self._stubs["create_app_connector"] = self.grpc_channel.unary_unary( + self._stubs["create_app_connector"] = self._logged_channel.unary_unary( "/google.cloud.beyondcorp.appconnectors.v1.AppConnectorsService/CreateAppConnector", request_serializer=app_connectors_service.CreateAppConnectorRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -386,7 +471,7 @@ def update_app_connector( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_app_connector" not in self._stubs: - self._stubs["update_app_connector"] = self.grpc_channel.unary_unary( + self._stubs["update_app_connector"] = self._logged_channel.unary_unary( "/google.cloud.beyondcorp.appconnectors.v1.AppConnectorsService/UpdateAppConnector", request_serializer=app_connectors_service.UpdateAppConnectorRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -415,7 +500,7 @@ def delete_app_connector( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_app_connector" not in self._stubs: - self._stubs["delete_app_connector"] = self.grpc_channel.unary_unary( + self._stubs["delete_app_connector"] = self._logged_channel.unary_unary( "/google.cloud.beyondcorp.appconnectors.v1.AppConnectorsService/DeleteAppConnector", request_serializer=app_connectors_service.DeleteAppConnectorRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -444,7 +529,7 @@ def report_status( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "report_status" not in self._stubs: - self._stubs["report_status"] = self.grpc_channel.unary_unary( + self._stubs["report_status"] = self._logged_channel.unary_unary( "/google.cloud.beyondcorp.appconnectors.v1.AppConnectorsService/ReportStatus", request_serializer=app_connectors_service.ReportStatusRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -537,7 +622,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: @@ -553,7 +638,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, @@ -570,7 +655,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, @@ -587,7 +672,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, @@ -606,7 +691,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, @@ -625,7 +710,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, @@ -642,7 +727,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, @@ -667,7 +752,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, @@ -693,7 +778,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, @@ -722,7 +807,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-beyondcorp-appconnectors/google/cloud/beyondcorp_appconnectors_v1/services/app_connectors_service/transports/rest.py b/packages/google-cloud-beyondcorp-appconnectors/google/cloud/beyondcorp_appconnectors_v1/services/app_connectors_service/transports/rest.py index 1deebc1dc293..90f909703fd7 100644 --- a/packages/google-cloud-beyondcorp-appconnectors/google/cloud/beyondcorp_appconnectors_v1/services/app_connectors_service/transports/rest.py +++ b/packages/google-cloud-beyondcorp-appconnectors/google/cloud/beyondcorp_appconnectors_v1/services/app_connectors_service/transports/rest.py @@ -13,9 +13,9 @@ # See the License for the specific language governing permissions and # limitations under the License. # - import dataclasses import json # type: ignore +import logging from typing import Any, Callable, Dict, List, Optional, Sequence, Tuple, Union import warnings @@ -41,6 +41,14 @@ except AttributeError: # pragma: NO COVER OptionalRetry = Union[retries.Retry, object, None] # type: ignore +try: + from google.api_core import client_logging # type: ignore + + CLIENT_LOGGING_SUPPORTED = True # pragma: NO COVER +except ImportError: # pragma: NO COVER + CLIENT_LOGGING_SUPPORTED = False + +_LOGGER = logging.getLogger(__name__) DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo( gapic_version=BASE_DEFAULT_CLIENT_INFO.gapic_version, @@ -121,9 +129,10 @@ def post_update_app_connector(self, response): def pre_create_app_connector( self, request: app_connectors_service.CreateAppConnectorRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ - app_connectors_service.CreateAppConnectorRequest, Sequence[Tuple[str, str]] + app_connectors_service.CreateAppConnectorRequest, + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for create_app_connector @@ -146,9 +155,10 @@ def post_create_app_connector( def pre_delete_app_connector( self, request: app_connectors_service.DeleteAppConnectorRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ - app_connectors_service.DeleteAppConnectorRequest, Sequence[Tuple[str, str]] + app_connectors_service.DeleteAppConnectorRequest, + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for delete_app_connector @@ -171,9 +181,10 @@ def post_delete_app_connector( def pre_get_app_connector( self, request: app_connectors_service.GetAppConnectorRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ - app_connectors_service.GetAppConnectorRequest, Sequence[Tuple[str, str]] + app_connectors_service.GetAppConnectorRequest, + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for get_app_connector @@ -196,9 +207,10 @@ def post_get_app_connector( def pre_list_app_connectors( self, request: app_connectors_service.ListAppConnectorsRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ - app_connectors_service.ListAppConnectorsRequest, Sequence[Tuple[str, str]] + app_connectors_service.ListAppConnectorsRequest, + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for list_app_connectors @@ -221,8 +233,11 @@ def post_list_app_connectors( def pre_report_status( self, request: app_connectors_service.ReportStatusRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[app_connectors_service.ReportStatusRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + app_connectors_service.ReportStatusRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for report_status Override in a subclass to manipulate the request or metadata @@ -244,9 +259,10 @@ def post_report_status( def pre_update_app_connector( self, request: app_connectors_service.UpdateAppConnectorRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ - app_connectors_service.UpdateAppConnectorRequest, Sequence[Tuple[str, str]] + app_connectors_service.UpdateAppConnectorRequest, + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for update_app_connector @@ -269,8 +285,10 @@ def post_update_app_connector( 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 @@ -292,8 +310,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 @@ -315,8 +335,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 @@ -336,8 +358,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 @@ -357,8 +381,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 @@ -380,8 +407,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 @@ -401,8 +430,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 @@ -422,8 +453,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 @@ -445,8 +478,10 @@ def post_get_operation( def pre_list_operations( self, request: operations_pb2.ListOperationsRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[operations_pb2.ListOperationsRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + operations_pb2.ListOperationsRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for list_operations Override in a subclass to manipulate the request or metadata @@ -655,7 +690,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Call the create app connector method over HTTP. @@ -666,8 +701,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.operations_pb2.Operation: @@ -680,6 +717,7 @@ def __call__( http_options = ( _BaseAppConnectorsServiceRestTransport._BaseCreateAppConnector._get_http_options() ) + request, metadata = self._interceptor.pre_create_app_connector( request, metadata ) @@ -696,6 +734,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.beyondcorp.appconnectors_v1.AppConnectorsServiceClient.CreateAppConnector", + extra={ + "serviceName": "google.cloud.beyondcorp.appconnectors.v1.AppConnectorsService", + "rpcName": "CreateAppConnector", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ( AppConnectorsServiceRestTransport._CreateAppConnector._get_response( @@ -717,7 +782,29 @@ def __call__( # Return the response resp = operations_pb2.Operation() json_format.Parse(response.content, resp, ignore_unknown_fields=True) + resp = self._interceptor.post_create_app_connector(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = json_format.MessageToJson(resp) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.beyondcorp.appconnectors_v1.AppConnectorsServiceClient.create_app_connector", + extra={ + "serviceName": "google.cloud.beyondcorp.appconnectors.v1.AppConnectorsService", + "rpcName": "CreateAppConnector", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _DeleteAppConnector( @@ -755,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]]] = (), ) -> operations_pb2.Operation: r"""Call the delete app connector method over HTTP. @@ -766,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: ~.operations_pb2.Operation: @@ -780,6 +869,7 @@ def __call__( http_options = ( _BaseAppConnectorsServiceRestTransport._BaseDeleteAppConnector._get_http_options() ) + request, metadata = self._interceptor.pre_delete_app_connector( request, metadata ) @@ -792,6 +882,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.beyondcorp.appconnectors_v1.AppConnectorsServiceClient.DeleteAppConnector", + extra={ + "serviceName": "google.cloud.beyondcorp.appconnectors.v1.AppConnectorsService", + "rpcName": "DeleteAppConnector", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ( AppConnectorsServiceRestTransport._DeleteAppConnector._get_response( @@ -812,7 +929,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_app_connector(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = json_format.MessageToJson(resp) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.beyondcorp.appconnectors_v1.AppConnectorsServiceClient.delete_app_connector", + extra={ + "serviceName": "google.cloud.beyondcorp.appconnectors.v1.AppConnectorsService", + "rpcName": "DeleteAppConnector", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _GetAppConnector( @@ -850,7 +989,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> app_connectors_service.AppConnector: r"""Call the get app connector method over HTTP. @@ -861,8 +1000,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.app_connectors_service.AppConnector: @@ -882,6 +1023,7 @@ def __call__( http_options = ( _BaseAppConnectorsServiceRestTransport._BaseGetAppConnector._get_http_options() ) + request, metadata = self._interceptor.pre_get_app_connector( request, metadata ) @@ -894,6 +1036,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.beyondcorp.appconnectors_v1.AppConnectorsServiceClient.GetAppConnector", + extra={ + "serviceName": "google.cloud.beyondcorp.appconnectors.v1.AppConnectorsService", + "rpcName": "GetAppConnector", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = AppConnectorsServiceRestTransport._GetAppConnector._get_response( self._host, @@ -914,7 +1083,31 @@ def __call__( pb_resp = app_connectors_service.AppConnector.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_app_connector(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = app_connectors_service.AppConnector.to_json( + response + ) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.beyondcorp.appconnectors_v1.AppConnectorsServiceClient.get_app_connector", + extra={ + "serviceName": "google.cloud.beyondcorp.appconnectors.v1.AppConnectorsService", + "rpcName": "GetAppConnector", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ListAppConnectors( @@ -952,7 +1145,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> app_connectors_service.ListAppConnectorsResponse: r"""Call the list app connectors method over HTTP. @@ -963,8 +1156,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.app_connectors_service.ListAppConnectorsResponse: @@ -976,6 +1171,7 @@ def __call__( http_options = ( _BaseAppConnectorsServiceRestTransport._BaseListAppConnectors._get_http_options() ) + request, metadata = self._interceptor.pre_list_app_connectors( request, metadata ) @@ -988,6 +1184,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.beyondcorp.appconnectors_v1.AppConnectorsServiceClient.ListAppConnectors", + extra={ + "serviceName": "google.cloud.beyondcorp.appconnectors.v1.AppConnectorsService", + "rpcName": "ListAppConnectors", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ( AppConnectorsServiceRestTransport._ListAppConnectors._get_response( @@ -1010,7 +1233,33 @@ def __call__( pb_resp = app_connectors_service.ListAppConnectorsResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_app_connectors(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = ( + app_connectors_service.ListAppConnectorsResponse.to_json( + response + ) + ) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.beyondcorp.appconnectors_v1.AppConnectorsServiceClient.list_app_connectors", + extra={ + "serviceName": "google.cloud.beyondcorp.appconnectors.v1.AppConnectorsService", + "rpcName": "ListAppConnectors", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ReportStatus( @@ -1049,7 +1298,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Call the report status method over HTTP. @@ -1059,8 +1308,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.operations_pb2.Operation: @@ -1073,6 +1324,7 @@ def __call__( http_options = ( _BaseAppConnectorsServiceRestTransport._BaseReportStatus._get_http_options() ) + request, metadata = self._interceptor.pre_report_status(request, metadata) transcoded_request = _BaseAppConnectorsServiceRestTransport._BaseReportStatus._get_transcoded_request( http_options, request @@ -1087,6 +1339,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.beyondcorp.appconnectors_v1.AppConnectorsServiceClient.ReportStatus", + extra={ + "serviceName": "google.cloud.beyondcorp.appconnectors.v1.AppConnectorsService", + "rpcName": "ReportStatus", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = AppConnectorsServiceRestTransport._ReportStatus._get_response( self._host, @@ -1106,7 +1385,29 @@ def __call__( # Return the response resp = operations_pb2.Operation() json_format.Parse(response.content, resp, ignore_unknown_fields=True) + resp = self._interceptor.post_report_status(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = json_format.MessageToJson(resp) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.beyondcorp.appconnectors_v1.AppConnectorsServiceClient.report_status", + extra={ + "serviceName": "google.cloud.beyondcorp.appconnectors.v1.AppConnectorsService", + "rpcName": "ReportStatus", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _UpdateAppConnector( @@ -1145,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 update app connector method over HTTP. @@ -1156,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: @@ -1170,6 +1473,7 @@ def __call__( http_options = ( _BaseAppConnectorsServiceRestTransport._BaseUpdateAppConnector._get_http_options() ) + request, metadata = self._interceptor.pre_update_app_connector( request, metadata ) @@ -1186,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.beyondcorp.appconnectors_v1.AppConnectorsServiceClient.UpdateAppConnector", + extra={ + "serviceName": "google.cloud.beyondcorp.appconnectors.v1.AppConnectorsService", + "rpcName": "UpdateAppConnector", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ( AppConnectorsServiceRestTransport._UpdateAppConnector._get_response( @@ -1207,7 +1538,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_app_connector(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = json_format.MessageToJson(resp) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.beyondcorp.appconnectors_v1.AppConnectorsServiceClient.update_app_connector", + extra={ + "serviceName": "google.cloud.beyondcorp.appconnectors.v1.AppConnectorsService", + "rpcName": "UpdateAppConnector", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp @property @@ -1311,7 +1664,7 @@ 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. @@ -1321,8 +1674,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each 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. @@ -1331,6 +1686,7 @@ def __call__( http_options = ( _BaseAppConnectorsServiceRestTransport._BaseGetLocation._get_http_options() ) + request, metadata = self._interceptor.pre_get_location(request, metadata) transcoded_request = _BaseAppConnectorsServiceRestTransport._BaseGetLocation._get_transcoded_request( http_options, request @@ -1341,6 +1697,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.beyondcorp.appconnectors_v1.AppConnectorsServiceClient.GetLocation", + extra={ + "serviceName": "google.cloud.beyondcorp.appconnectors.v1.AppConnectorsService", + "rpcName": "GetLocation", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = AppConnectorsServiceRestTransport._GetLocation._get_response( self._host, @@ -1360,6 +1743,27 @@ def __call__( resp = locations_pb2.Location() resp = json_format.Parse(content, resp) resp = self._interceptor.post_get_location(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = json_format.MessageToJson(resp) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.beyondcorp.appconnectors_v1.AppConnectorsServiceAsyncClient.GetLocation", + extra={ + "serviceName": "google.cloud.beyondcorp.appconnectors.v1.AppConnectorsService", + "rpcName": "GetLocation", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property @@ -1401,7 +1805,7 @@ 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. @@ -1411,8 +1815,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each 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. @@ -1421,6 +1827,7 @@ def __call__( http_options = ( _BaseAppConnectorsServiceRestTransport._BaseListLocations._get_http_options() ) + request, metadata = self._interceptor.pre_list_locations(request, metadata) transcoded_request = _BaseAppConnectorsServiceRestTransport._BaseListLocations._get_transcoded_request( http_options, request @@ -1431,6 +1838,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.beyondcorp.appconnectors_v1.AppConnectorsServiceClient.ListLocations", + extra={ + "serviceName": "google.cloud.beyondcorp.appconnectors.v1.AppConnectorsService", + "rpcName": "ListLocations", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = AppConnectorsServiceRestTransport._ListLocations._get_response( self._host, @@ -1450,6 +1884,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.beyondcorp.appconnectors_v1.AppConnectorsServiceAsyncClient.ListLocations", + extra={ + "serviceName": "google.cloud.beyondcorp.appconnectors.v1.AppConnectorsService", + "rpcName": "ListLocations", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property @@ -1491,7 +1946,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> policy_pb2.Policy: r"""Call the get iam policy method over HTTP. @@ -1501,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: policy_pb2.Policy: Response from GetIamPolicy method. @@ -1511,6 +1968,7 @@ def __call__( http_options = ( _BaseAppConnectorsServiceRestTransport._BaseGetIamPolicy._get_http_options() ) + request, metadata = self._interceptor.pre_get_iam_policy(request, metadata) transcoded_request = _BaseAppConnectorsServiceRestTransport._BaseGetIamPolicy._get_transcoded_request( http_options, request @@ -1521,6 +1979,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.beyondcorp.appconnectors_v1.AppConnectorsServiceClient.GetIamPolicy", + extra={ + "serviceName": "google.cloud.beyondcorp.appconnectors.v1.AppConnectorsService", + "rpcName": "GetIamPolicy", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = AppConnectorsServiceRestTransport._GetIamPolicy._get_response( self._host, @@ -1540,6 +2025,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.beyondcorp.appconnectors_v1.AppConnectorsServiceAsyncClient.GetIamPolicy", + extra={ + "serviceName": "google.cloud.beyondcorp.appconnectors.v1.AppConnectorsService", + "rpcName": "GetIamPolicy", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property @@ -1582,7 +2088,7 @@ 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. @@ -1592,8 +2098,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each 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. @@ -1602,6 +2110,7 @@ def __call__( http_options = ( _BaseAppConnectorsServiceRestTransport._BaseSetIamPolicy._get_http_options() ) + request, metadata = self._interceptor.pre_set_iam_policy(request, metadata) transcoded_request = _BaseAppConnectorsServiceRestTransport._BaseSetIamPolicy._get_transcoded_request( http_options, request @@ -1616,6 +2125,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.beyondcorp.appconnectors_v1.AppConnectorsServiceClient.SetIamPolicy", + extra={ + "serviceName": "google.cloud.beyondcorp.appconnectors.v1.AppConnectorsService", + "rpcName": "SetIamPolicy", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = AppConnectorsServiceRestTransport._SetIamPolicy._get_response( self._host, @@ -1636,6 +2172,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.beyondcorp.appconnectors_v1.AppConnectorsServiceAsyncClient.SetIamPolicy", + extra={ + "serviceName": "google.cloud.beyondcorp.appconnectors.v1.AppConnectorsService", + "rpcName": "SetIamPolicy", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property @@ -1678,7 +2235,7 @@ 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. @@ -1688,8 +2245,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: iam_policy_pb2.TestIamPermissionsResponse: Response from TestIamPermissions method. @@ -1698,6 +2257,7 @@ def __call__( http_options = ( _BaseAppConnectorsServiceRestTransport._BaseTestIamPermissions._get_http_options() ) + request, metadata = self._interceptor.pre_test_iam_permissions( request, metadata ) @@ -1714,6 +2274,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.beyondcorp.appconnectors_v1.AppConnectorsServiceClient.TestIamPermissions", + extra={ + "serviceName": "google.cloud.beyondcorp.appconnectors.v1.AppConnectorsService", + "rpcName": "TestIamPermissions", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ( AppConnectorsServiceRestTransport._TestIamPermissions._get_response( @@ -1736,6 +2323,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.beyondcorp.appconnectors_v1.AppConnectorsServiceAsyncClient.TestIamPermissions", + extra={ + "serviceName": "google.cloud.beyondcorp.appconnectors.v1.AppConnectorsService", + "rpcName": "TestIamPermissions", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property @@ -1778,7 +2386,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> None: r"""Call the cancel operation method over HTTP. @@ -1788,13 +2396,16 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. """ http_options = ( _BaseAppConnectorsServiceRestTransport._BaseCancelOperation._get_http_options() ) + request, metadata = self._interceptor.pre_cancel_operation( request, metadata ) @@ -1811,6 +2422,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.beyondcorp.appconnectors_v1.AppConnectorsServiceClient.CancelOperation", + extra={ + "serviceName": "google.cloud.beyondcorp.appconnectors.v1.AppConnectorsService", + "rpcName": "CancelOperation", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = AppConnectorsServiceRestTransport._CancelOperation._get_response( self._host, @@ -1868,7 +2506,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> None: r"""Call the delete operation method over HTTP. @@ -1878,13 +2516,16 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. """ http_options = ( _BaseAppConnectorsServiceRestTransport._BaseDeleteOperation._get_http_options() ) + request, metadata = self._interceptor.pre_delete_operation( request, metadata ) @@ -1897,6 +2538,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.beyondcorp.appconnectors_v1.AppConnectorsServiceClient.DeleteOperation", + extra={ + "serviceName": "google.cloud.beyondcorp.appconnectors.v1.AppConnectorsService", + "rpcName": "DeleteOperation", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = AppConnectorsServiceRestTransport._DeleteOperation._get_response( self._host, @@ -1953,7 +2621,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.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. @@ -1963,8 +2631,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: operations_pb2.Operation: Response from GetOperation method. @@ -1973,6 +2643,7 @@ def __call__( http_options = ( _BaseAppConnectorsServiceRestTransport._BaseGetOperation._get_http_options() ) + request, metadata = self._interceptor.pre_get_operation(request, metadata) transcoded_request = _BaseAppConnectorsServiceRestTransport._BaseGetOperation._get_transcoded_request( http_options, request @@ -1983,6 +2654,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.beyondcorp.appconnectors_v1.AppConnectorsServiceClient.GetOperation", + extra={ + "serviceName": "google.cloud.beyondcorp.appconnectors.v1.AppConnectorsService", + "rpcName": "GetOperation", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = AppConnectorsServiceRestTransport._GetOperation._get_response( self._host, @@ -2002,6 +2700,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.beyondcorp.appconnectors_v1.AppConnectorsServiceAsyncClient.GetOperation", + extra={ + "serviceName": "google.cloud.beyondcorp.appconnectors.v1.AppConnectorsService", + "rpcName": "GetOperation", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property @@ -2043,7 +2762,7 @@ def __call__( *, 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. @@ -2053,8 +2772,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of 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. @@ -2063,6 +2784,7 @@ def __call__( http_options = ( _BaseAppConnectorsServiceRestTransport._BaseListOperations._get_http_options() ) + request, metadata = self._interceptor.pre_list_operations(request, metadata) transcoded_request = _BaseAppConnectorsServiceRestTransport._BaseListOperations._get_transcoded_request( http_options, request @@ -2073,6 +2795,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.beyondcorp.appconnectors_v1.AppConnectorsServiceClient.ListOperations", + extra={ + "serviceName": "google.cloud.beyondcorp.appconnectors.v1.AppConnectorsService", + "rpcName": "ListOperations", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = AppConnectorsServiceRestTransport._ListOperations._get_response( self._host, @@ -2092,6 +2841,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.beyondcorp.appconnectors_v1.AppConnectorsServiceAsyncClient.ListOperations", + extra={ + "serviceName": "google.cloud.beyondcorp.appconnectors.v1.AppConnectorsService", + "rpcName": "ListOperations", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property diff --git a/packages/google-cloud-beyondcorp-appconnectors/samples/generated_samples/snippet_metadata_google.cloud.beyondcorp.appconnectors.v1.json b/packages/google-cloud-beyondcorp-appconnectors/samples/generated_samples/snippet_metadata_google.cloud.beyondcorp.appconnectors.v1.json index 4c4360126238..e1535607b299 100644 --- a/packages/google-cloud-beyondcorp-appconnectors/samples/generated_samples/snippet_metadata_google.cloud.beyondcorp.appconnectors.v1.json +++ b/packages/google-cloud-beyondcorp-appconnectors/samples/generated_samples/snippet_metadata_google.cloud.beyondcorp.appconnectors.v1.json @@ -8,7 +8,7 @@ ], "language": "PYTHON", "name": "google-cloud-beyondcorp-appconnectors", - "version": "0.4.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.beyondcorp_appconnectors_v1.types.AppConnector", @@ -465,7 +465,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.beyondcorp_appconnectors_v1.types.AppConnector", @@ -546,7 +546,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.beyondcorp_appconnectors_v1.services.app_connectors_service.pagers.ListAppConnectorsAsyncPager", @@ -626,7 +626,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.beyondcorp_appconnectors_v1.services.app_connectors_service.pagers.ListAppConnectorsPager", @@ -711,7 +711,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -795,7 +795,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -880,7 +880,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -964,7 +964,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-beyondcorp-appconnectors/tests/unit/gapic/beyondcorp_appconnectors_v1/test_app_connectors_service.py b/packages/google-cloud-beyondcorp-appconnectors/tests/unit/gapic/beyondcorp_appconnectors_v1/test_app_connectors_service.py index 3813dd6c1eab..61c3b29bd2c4 100644 --- a/packages/google-cloud-beyondcorp-appconnectors/tests/unit/gapic/beyondcorp_appconnectors_v1/test_app_connectors_service.py +++ b/packages/google-cloud-beyondcorp-appconnectors/tests/unit/gapic/beyondcorp_appconnectors_v1/test_app_connectors_service.py @@ -3581,6 +3581,7 @@ def test_list_app_connectors_rest_required_fields( response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.list_app_connectors(request) @@ -3636,6 +3637,7 @@ def test_list_app_connectors_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.list_app_connectors(**mock_args) @@ -3833,6 +3835,7 @@ def test_get_app_connector_rest_required_fields( response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.get_app_connector(request) @@ -3880,6 +3883,7 @@ def test_get_app_connector_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.get_app_connector(**mock_args) @@ -4025,6 +4029,7 @@ def test_create_app_connector_rest_required_fields( response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.create_app_connector(request) @@ -4084,6 +4089,7 @@ def test_create_app_connector_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.create_app_connector(**mock_args) @@ -4226,6 +4232,7 @@ def test_update_app_connector_rest_required_fields( response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.update_app_connector(request) @@ -4288,6 +4295,7 @@ def test_update_app_connector_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.update_app_connector(**mock_args) @@ -4432,6 +4440,7 @@ def test_delete_app_connector_rest_required_fields( response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.delete_app_connector(request) @@ -4485,6 +4494,7 @@ def test_delete_app_connector_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.delete_app_connector(**mock_args) @@ -4618,6 +4628,7 @@ def test_report_status_rest_required_fields( response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.report_status(request) @@ -4672,6 +4683,7 @@ def test_report_status_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.report_status(**mock_args) @@ -5154,6 +5166,7 @@ def test_list_app_connectors_rest_bad_request( response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.list_app_connectors(request) @@ -5190,6 +5203,7 @@ def test_list_app_connectors_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.list_app_connectors(request) # Establish that the response is the type that we expect. @@ -5231,6 +5245,7 @@ def test_list_app_connectors_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = app_connectors_service.ListAppConnectorsResponse.to_json( app_connectors_service.ListAppConnectorsResponse() ) @@ -5277,6 +5292,7 @@ def test_get_app_connector_rest_bad_request( response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.get_app_connector(request) @@ -5315,6 +5331,7 @@ def test_get_app_connector_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.get_app_connector(request) # Establish that the response is the type that we expect. @@ -5358,6 +5375,7 @@ def test_get_app_connector_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = app_connectors_service.AppConnector.to_json( app_connectors_service.AppConnector() ) @@ -5404,6 +5422,7 @@ def test_create_app_connector_rest_bad_request( response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.create_app_connector(request) @@ -5523,6 +5542,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.create_app_connector(request) # Establish that the response is the type that we expect. @@ -5564,6 +5584,7 @@ def test_create_app_connector_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = json_format.MessageToJson(operations_pb2.Operation()) req.return_value.content = return_value @@ -5612,6 +5633,7 @@ def test_update_app_connector_rest_bad_request( response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.update_app_connector(request) @@ -5735,6 +5757,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.update_app_connector(request) # Establish that the response is the type that we expect. @@ -5776,6 +5799,7 @@ def test_update_app_connector_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = json_format.MessageToJson(operations_pb2.Operation()) req.return_value.content = return_value @@ -5820,6 +5844,7 @@ def test_delete_app_connector_rest_bad_request( response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.delete_app_connector(request) @@ -5850,6 +5875,7 @@ def test_delete_app_connector_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.delete_app_connector(request) # Establish that the response is the type that we expect. @@ -5891,6 +5917,7 @@ def test_delete_app_connector_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = json_format.MessageToJson(operations_pb2.Operation()) req.return_value.content = return_value @@ -5937,6 +5964,7 @@ def test_report_status_rest_bad_request( response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.report_status(request) @@ -5969,6 +5997,7 @@ def test_report_status_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.report_status(request) # Establish that the response is the type that we expect. @@ -6010,6 +6039,7 @@ def test_report_status_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = json_format.MessageToJson(operations_pb2.Operation()) req.return_value.content = return_value @@ -6054,6 +6084,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) @@ -6084,6 +6115,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) @@ -6112,6 +6144,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) @@ -6142,6 +6175,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) @@ -6173,6 +6207,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) @@ -6205,6 +6240,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) @@ -6236,6 +6272,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) @@ -6268,6 +6305,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) @@ -6299,6 +6337,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) @@ -6331,6 +6370,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) @@ -6361,6 +6401,7 @@ def test_cancel_operation_rest_bad_request( response_value.status_code = 400 response_value.request = Request() req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.cancel_operation(request) @@ -6391,6 +6432,7 @@ def test_cancel_operation_rest(request_type): response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.cancel_operation(request) @@ -6421,6 +6463,7 @@ def test_delete_operation_rest_bad_request( response_value.status_code = 400 response_value.request = Request() req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.delete_operation(request) @@ -6451,6 +6494,7 @@ def test_delete_operation_rest(request_type): response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.delete_operation(request) @@ -6481,6 +6525,7 @@ def test_get_operation_rest_bad_request( response_value.status_code = 400 response_value.request = Request() req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.get_operation(request) @@ -6511,6 +6556,7 @@ def test_get_operation_rest(request_type): response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.get_operation(request) @@ -6541,6 +6587,7 @@ def test_list_operations_rest_bad_request( response_value.status_code = 400 response_value.request = Request() req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.list_operations(request) @@ -6571,6 +6618,7 @@ def test_list_operations_rest(request_type): response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.list_operations(request) diff --git a/packages/google-cloud-beyondcorp-appgateways/google/cloud/beyondcorp_appgateways/gapic_version.py b/packages/google-cloud-beyondcorp-appgateways/google/cloud/beyondcorp_appgateways/gapic_version.py index 9b19e5f10e00..558c8aab67c5 100644 --- a/packages/google-cloud-beyondcorp-appgateways/google/cloud/beyondcorp_appgateways/gapic_version.py +++ b/packages/google-cloud-beyondcorp-appgateways/google/cloud/beyondcorp_appgateways/gapic_version.py @@ -13,4 +13,4 @@ # See the License for the specific language governing permissions and # limitations under the License. # -__version__ = "0.4.13" # {x-release-please-version} +__version__ = "0.0.0" # {x-release-please-version} diff --git a/packages/google-cloud-beyondcorp-appgateways/google/cloud/beyondcorp_appgateways_v1/gapic_version.py b/packages/google-cloud-beyondcorp-appgateways/google/cloud/beyondcorp_appgateways_v1/gapic_version.py index 9b19e5f10e00..558c8aab67c5 100644 --- a/packages/google-cloud-beyondcorp-appgateways/google/cloud/beyondcorp_appgateways_v1/gapic_version.py +++ b/packages/google-cloud-beyondcorp-appgateways/google/cloud/beyondcorp_appgateways_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.13" # {x-release-please-version} +__version__ = "0.0.0" # {x-release-please-version} diff --git a/packages/google-cloud-beyondcorp-appgateways/google/cloud/beyondcorp_appgateways_v1/services/app_gateways_service/async_client.py b/packages/google-cloud-beyondcorp-appgateways/google/cloud/beyondcorp_appgateways_v1/services/app_gateways_service/async_client.py index f68abbebc165..7b75a140520e 100644 --- a/packages/google-cloud-beyondcorp-appgateways/google/cloud/beyondcorp_appgateways_v1/services/app_gateways_service/async_client.py +++ b/packages/google-cloud-beyondcorp-appgateways/google/cloud/beyondcorp_appgateways_v1/services/app_gateways_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, AppGatewaysServiceTransport from .transports.grpc_asyncio import AppGatewaysServiceGrpcAsyncIOTransport +try: + from google.api_core import client_logging # type: ignore + + CLIENT_LOGGING_SUPPORTED = True # pragma: NO COVER +except ImportError: # pragma: NO COVER + CLIENT_LOGGING_SUPPORTED = False + +_LOGGER = std_logging.getLogger(__name__) + class AppGatewaysServiceAsyncClient: """API Overview: @@ -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.beyondcorp.appgateways_v1.AppGatewaysServiceAsyncClient`.", + extra={ + "serviceName": "google.cloud.beyondcorp.appgateways.v1.AppGatewaysService", + "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.beyondcorp.appgateways.v1.AppGatewaysService", + "credentialsType": None, + }, + ) + async def list_app_gateways( self, request: Optional[ @@ -292,7 +324,7 @@ async def list_app_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.ListAppGatewaysAsyncPager: r"""Lists AppGateways in a given project and location. @@ -338,8 +370,10 @@ async def sample_list_app_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.beyondcorp_appgateways_v1.services.app_gateways_service.pagers.ListAppGatewaysAsyncPager: @@ -416,7 +450,7 @@ async def get_app_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]]] = (), ) -> app_gateways_service.AppGateway: r"""Gets details of a single AppGateway. @@ -460,8 +494,10 @@ async def sample_get_app_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.beyondcorp_appgateways_v1.types.AppGateway: @@ -532,7 +568,7 @@ async def create_app_gateway( app_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 AppGateway in a given project and location. @@ -606,8 +642,10 @@ async def sample_create_app_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: @@ -687,7 +725,7 @@ async def delete_app_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 AppGateway. @@ -735,8 +773,10 @@ async def sample_delete_app_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: @@ -814,7 +854,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. @@ -825,8 +865,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. @@ -867,7 +909,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. @@ -878,8 +920,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. @@ -920,7 +964,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. @@ -936,8 +980,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 """ @@ -974,7 +1020,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. @@ -989,8 +1035,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 """ @@ -1027,7 +1075,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. @@ -1040,8 +1088,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. @@ -1146,7 +1196,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. @@ -1160,8 +1210,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. @@ -1266,7 +1318,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. @@ -1281,8 +1333,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. @@ -1326,7 +1380,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. @@ -1337,8 +1391,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. @@ -1379,7 +1435,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. @@ -1390,8 +1446,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-beyondcorp-appgateways/google/cloud/beyondcorp_appgateways_v1/services/app_gateways_service/client.py b/packages/google-cloud-beyondcorp-appgateways/google/cloud/beyondcorp_appgateways_v1/services/app_gateways_service/client.py index 8b20ee88a3b8..9cd3540fb6ae 100644 --- a/packages/google-cloud-beyondcorp-appgateways/google/cloud/beyondcorp_appgateways_v1/services/app_gateways_service/client.py +++ b/packages/google-cloud-beyondcorp-appgateways/google/cloud/beyondcorp_appgateways_v1/services/app_gateways_service/client.py @@ -14,6 +14,7 @@ # limitations under the License. # from collections import OrderedDict +import logging as std_logging import os import re from typing import ( @@ -48,6 +49,15 @@ except AttributeError: # pragma: NO COVER OptionalRetry = Union[retries.Retry, object, None] # type: ignore +try: + from google.api_core import client_logging # type: ignore + + CLIENT_LOGGING_SUPPORTED = True # pragma: NO COVER +except ImportError: # pragma: NO COVER + CLIENT_LOGGING_SUPPORTED = False + +_LOGGER = std_logging.getLogger(__name__) + from google.api_core import operation # type: ignore from google.api_core import operation_async # type: ignore from google.cloud.location import locations_pb2 # type: ignore @@ -607,6 +617,10 @@ def __init__( # Initialize the universe domain validation. self._is_universe_domain_valid = False + if CLIENT_LOGGING_SUPPORTED: # pragma: NO COVER + # Setup logging. + client_logging.initialize_logging() + api_key_value = getattr(self._client_options, "api_key", None) if api_key_value and credentials: raise ValueError( @@ -673,6 +687,29 @@ def __init__( api_audience=self._client_options.api_audience, ) + if "async" not in str(self._transport): + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + std_logging.DEBUG + ): # pragma: NO COVER + _LOGGER.debug( + "Created client `google.cloud.beyondcorp.appgateways_v1.AppGatewaysServiceClient`.", + extra={ + "serviceName": "google.cloud.beyondcorp.appgateways.v1.AppGatewaysService", + "universeDomain": getattr( + self._transport._credentials, "universe_domain", "" + ), + "credentialsType": f"{type(self._transport._credentials).__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.beyondcorp.appgateways.v1.AppGatewaysService", + "credentialsType": None, + }, + ) + def list_app_gateways( self, request: Optional[ @@ -682,7 +719,7 @@ def list_app_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.ListAppGatewaysPager: r"""Lists AppGateways in a given project and location. @@ -728,8 +765,10 @@ def sample_list_app_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.beyondcorp_appgateways_v1.services.app_gateways_service.pagers.ListAppGatewaysPager: @@ -803,7 +842,7 @@ def get_app_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]]] = (), ) -> app_gateways_service.AppGateway: r"""Gets details of a single AppGateway. @@ -847,8 +886,10 @@ def sample_get_app_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.beyondcorp_appgateways_v1.types.AppGateway: @@ -916,7 +957,7 @@ def create_app_gateway( app_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 AppGateway in a given project and location. @@ -990,8 +1031,10 @@ def sample_create_app_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: @@ -1068,7 +1111,7 @@ def delete_app_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 AppGateway. @@ -1116,8 +1159,10 @@ def sample_delete_app_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: @@ -1205,7 +1250,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. @@ -1216,8 +1261,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. @@ -1258,7 +1305,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. @@ -1269,8 +1316,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. @@ -1311,7 +1360,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. @@ -1327,8 +1376,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 """ @@ -1365,7 +1416,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. @@ -1380,8 +1431,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 """ @@ -1418,7 +1471,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. @@ -1431,8 +1484,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. @@ -1537,7 +1592,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. @@ -1551,8 +1606,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. @@ -1657,7 +1714,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. @@ -1672,8 +1729,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. @@ -1715,7 +1774,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. @@ -1726,8 +1785,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. @@ -1768,7 +1829,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. @@ -1779,8 +1840,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-beyondcorp-appgateways/google/cloud/beyondcorp_appgateways_v1/services/app_gateways_service/pagers.py b/packages/google-cloud-beyondcorp-appgateways/google/cloud/beyondcorp_appgateways_v1/services/app_gateways_service/pagers.py index 46c515325a56..44825d33067c 100644 --- a/packages/google-cloud-beyondcorp-appgateways/google/cloud/beyondcorp_appgateways_v1/services/app_gateways_service/pagers.py +++ b/packages/google-cloud-beyondcorp-appgateways/google/cloud/beyondcorp_appgateways_v1/services/app_gateways_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 = app_gateways_service.ListAppGatewaysRequest(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 = app_gateways_service.ListAppGatewaysRequest(request) diff --git a/packages/google-cloud-beyondcorp-appgateways/google/cloud/beyondcorp_appgateways_v1/services/app_gateways_service/transports/grpc.py b/packages/google-cloud-beyondcorp-appgateways/google/cloud/beyondcorp_appgateways_v1/services/app_gateways_service/transports/grpc.py index 2d7187f9f96b..c004bdabaad9 100644 --- a/packages/google-cloud-beyondcorp-appgateways/google/cloud/beyondcorp_appgateways_v1/services/app_gateways_service/transports/grpc.py +++ b/packages/google-cloud-beyondcorp-appgateways/google/cloud/beyondcorp_appgateways_v1/services/app_gateways_service/transports/grpc.py @@ -13,6 +13,9 @@ # See the License for the specific language governing permissions and # limitations under the License. # +import json +import logging as std_logging +import pickle from typing import Callable, Dict, Optional, Sequence, Tuple, Union import warnings @@ -24,12 +27,90 @@ from google.iam.v1 import iam_policy_pb2 # type: ignore from google.iam.v1 import policy_pb2 # type: ignore from google.longrunning import operations_pb2 # type: ignore +from google.protobuf.json_format import MessageToJson +import google.protobuf.message import grpc # type: ignore +import proto # type: ignore from google.cloud.beyondcorp_appgateways_v1.types import app_gateways_service from .base import DEFAULT_CLIENT_INFO, AppGatewaysServiceTransport +try: + from google.api_core import client_logging # 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.beyondcorp.appgateways.v1.AppGatewaysService", + "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.beyondcorp.appgateways.v1.AppGatewaysService", + "rpcName": client_call_details.method, + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class AppGatewaysServiceGrpcTransport(AppGatewaysServiceTransport): """gRPC backend transport for AppGatewaysService. @@ -197,7 +278,12 @@ def __init__( ], ) - # Wrap messages. This must be done after self._grpc_channel exists + self._interceptor = _LoggingClientInterceptor() + self._logged_channel = grpc.intercept_channel( + self._grpc_channel, self._interceptor + ) + + # Wrap messages. This must be done after self._logged_channel exists self._prep_wrapped_messages(client_info) @classmethod @@ -261,7 +347,9 @@ def operations_client(self) -> operations_v1.OperationsClient: """ # Quick check: Only create a new client if we do not already have one. if self._operations_client is None: - self._operations_client = operations_v1.OperationsClient(self.grpc_channel) + self._operations_client = operations_v1.OperationsClient( + self._logged_channel + ) # Return the client from cache. return self._operations_client @@ -288,7 +376,7 @@ def list_app_gateways( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_app_gateways" not in self._stubs: - self._stubs["list_app_gateways"] = self.grpc_channel.unary_unary( + self._stubs["list_app_gateways"] = self._logged_channel.unary_unary( "/google.cloud.beyondcorp.appgateways.v1.AppGatewaysService/ListAppGateways", request_serializer=app_gateways_service.ListAppGatewaysRequest.serialize, response_deserializer=app_gateways_service.ListAppGatewaysResponse.deserialize, @@ -316,7 +404,7 @@ def get_app_gateway( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_app_gateway" not in self._stubs: - self._stubs["get_app_gateway"] = self.grpc_channel.unary_unary( + self._stubs["get_app_gateway"] = self._logged_channel.unary_unary( "/google.cloud.beyondcorp.appgateways.v1.AppGatewaysService/GetAppGateway", request_serializer=app_gateways_service.GetAppGatewayRequest.serialize, response_deserializer=app_gateways_service.AppGateway.deserialize, @@ -345,7 +433,7 @@ def create_app_gateway( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_app_gateway" not in self._stubs: - self._stubs["create_app_gateway"] = self.grpc_channel.unary_unary( + self._stubs["create_app_gateway"] = self._logged_channel.unary_unary( "/google.cloud.beyondcorp.appgateways.v1.AppGatewaysService/CreateAppGateway", request_serializer=app_gateways_service.CreateAppGatewayRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -373,7 +461,7 @@ def delete_app_gateway( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_app_gateway" not in self._stubs: - self._stubs["delete_app_gateway"] = self.grpc_channel.unary_unary( + self._stubs["delete_app_gateway"] = self._logged_channel.unary_unary( "/google.cloud.beyondcorp.appgateways.v1.AppGatewaysService/DeleteAppGateway", request_serializer=app_gateways_service.DeleteAppGatewayRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -381,7 +469,7 @@ def delete_app_gateway( return self._stubs["delete_app_gateway"] def close(self): - self.grpc_channel.close() + self._logged_channel.close() @property def delete_operation( @@ -393,7 +481,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, @@ -410,7 +498,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 +515,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 +534,7 @@ def list_operations( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_operations" not in self._stubs: - self._stubs["list_operations"] = self.grpc_channel.unary_unary( + self._stubs["list_operations"] = self._logged_channel.unary_unary( "/google.longrunning.Operations/ListOperations", request_serializer=operations_pb2.ListOperationsRequest.SerializeToString, response_deserializer=operations_pb2.ListOperationsResponse.FromString, @@ -465,7 +553,7 @@ def list_locations( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_locations" not in self._stubs: - self._stubs["list_locations"] = self.grpc_channel.unary_unary( + self._stubs["list_locations"] = self._logged_channel.unary_unary( "/google.cloud.location.Locations/ListLocations", request_serializer=locations_pb2.ListLocationsRequest.SerializeToString, response_deserializer=locations_pb2.ListLocationsResponse.FromString, @@ -482,7 +570,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, @@ -507,7 +595,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, @@ -533,7 +621,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, @@ -562,7 +650,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-beyondcorp-appgateways/google/cloud/beyondcorp_appgateways_v1/services/app_gateways_service/transports/grpc_asyncio.py b/packages/google-cloud-beyondcorp-appgateways/google/cloud/beyondcorp_appgateways_v1/services/app_gateways_service/transports/grpc_asyncio.py index fe0a3cd3a256..0a19b3914c02 100644 --- a/packages/google-cloud-beyondcorp-appgateways/google/cloud/beyondcorp_appgateways_v1/services/app_gateways_service/transports/grpc_asyncio.py +++ b/packages/google-cloud-beyondcorp-appgateways/google/cloud/beyondcorp_appgateways_v1/services/app_gateways_service/transports/grpc_asyncio.py @@ -14,6 +14,9 @@ # limitations under the License. # import inspect +import json +import logging as std_logging +import pickle from typing import Awaitable, Callable, Dict, Optional, Sequence, Tuple, Union import warnings @@ -26,14 +29,93 @@ from google.iam.v1 import iam_policy_pb2 # type: ignore from google.iam.v1 import policy_pb2 # type: ignore from google.longrunning import operations_pb2 # type: ignore +from google.protobuf.json_format import MessageToJson +import google.protobuf.message import grpc # type: ignore from grpc.experimental import aio # type: ignore +import proto # type: ignore from google.cloud.beyondcorp_appgateways_v1.types import app_gateways_service from .base import DEFAULT_CLIENT_INFO, AppGatewaysServiceTransport from .grpc import AppGatewaysServiceGrpcTransport +try: + from google.api_core import client_logging # 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.beyondcorp.appgateways.v1.AppGatewaysService", + "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.beyondcorp.appgateways.v1.AppGatewaysService", + "rpcName": str(client_call_details.method), + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class AppGatewaysServiceGrpcAsyncIOTransport(AppGatewaysServiceTransport): """gRPC AsyncIO backend transport for AppGatewaysService. @@ -244,10 +326,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 operations_client(self) -> operations_v1.OperationsAsyncClient: # Quick check: Only create a new client if we do not already have one. if self._operations_client is None: self._operations_client = operations_v1.OperationsAsyncClient( - self.grpc_channel + self._logged_channel ) # Return the client from cache. @@ -298,7 +383,7 @@ def list_app_gateways( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_app_gateways" not in self._stubs: - self._stubs["list_app_gateways"] = self.grpc_channel.unary_unary( + self._stubs["list_app_gateways"] = self._logged_channel.unary_unary( "/google.cloud.beyondcorp.appgateways.v1.AppGatewaysService/ListAppGateways", request_serializer=app_gateways_service.ListAppGatewaysRequest.serialize, response_deserializer=app_gateways_service.ListAppGatewaysResponse.deserialize, @@ -327,7 +412,7 @@ def get_app_gateway( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_app_gateway" not in self._stubs: - self._stubs["get_app_gateway"] = self.grpc_channel.unary_unary( + self._stubs["get_app_gateway"] = self._logged_channel.unary_unary( "/google.cloud.beyondcorp.appgateways.v1.AppGatewaysService/GetAppGateway", request_serializer=app_gateways_service.GetAppGatewayRequest.serialize, response_deserializer=app_gateways_service.AppGateway.deserialize, @@ -357,7 +442,7 @@ def create_app_gateway( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_app_gateway" not in self._stubs: - self._stubs["create_app_gateway"] = self.grpc_channel.unary_unary( + self._stubs["create_app_gateway"] = self._logged_channel.unary_unary( "/google.cloud.beyondcorp.appgateways.v1.AppGatewaysService/CreateAppGateway", request_serializer=app_gateways_service.CreateAppGatewayRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -386,7 +471,7 @@ def delete_app_gateway( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_app_gateway" not in self._stubs: - self._stubs["delete_app_gateway"] = self.grpc_channel.unary_unary( + self._stubs["delete_app_gateway"] = self._logged_channel.unary_unary( "/google.cloud.beyondcorp.appgateways.v1.AppGatewaysService/DeleteAppGateway", request_serializer=app_gateways_service.DeleteAppGatewayRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -469,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: @@ -485,7 +570,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, @@ -502,7 +587,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, @@ -519,7 +604,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, @@ -538,7 +623,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, @@ -557,7 +642,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, @@ -574,7 +659,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, @@ -599,7 +684,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, @@ -625,7 +710,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, @@ -654,7 +739,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-beyondcorp-appgateways/google/cloud/beyondcorp_appgateways_v1/services/app_gateways_service/transports/rest.py b/packages/google-cloud-beyondcorp-appgateways/google/cloud/beyondcorp_appgateways_v1/services/app_gateways_service/transports/rest.py index a79e8f80c138..205bfe62be7c 100644 --- a/packages/google-cloud-beyondcorp-appgateways/google/cloud/beyondcorp_appgateways_v1/services/app_gateways_service/transports/rest.py +++ b/packages/google-cloud-beyondcorp-appgateways/google/cloud/beyondcorp_appgateways_v1/services/app_gateways_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, @@ -105,8 +113,11 @@ def post_list_app_gateways(self, response): def pre_create_app_gateway( self, request: app_gateways_service.CreateAppGatewayRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[app_gateways_service.CreateAppGatewayRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + app_gateways_service.CreateAppGatewayRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for create_app_gateway Override in a subclass to manipulate the request or metadata @@ -128,8 +139,11 @@ def post_create_app_gateway( def pre_delete_app_gateway( self, request: app_gateways_service.DeleteAppGatewayRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[app_gateways_service.DeleteAppGatewayRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + app_gateways_service.DeleteAppGatewayRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for delete_app_gateway Override in a subclass to manipulate the request or metadata @@ -151,8 +165,11 @@ def post_delete_app_gateway( def pre_get_app_gateway( self, request: app_gateways_service.GetAppGatewayRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[app_gateways_service.GetAppGatewayRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + app_gateways_service.GetAppGatewayRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for get_app_gateway Override in a subclass to manipulate the request or metadata @@ -174,8 +191,11 @@ def post_get_app_gateway( def pre_list_app_gateways( self, request: app_gateways_service.ListAppGatewaysRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[app_gateways_service.ListAppGatewaysRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + app_gateways_service.ListAppGatewaysRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for list_app_gateways Override in a subclass to manipulate the request or metadata @@ -197,8 +217,10 @@ def post_list_app_gateways( 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 @@ -220,8 +242,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 @@ -243,8 +267,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 @@ -264,8 +290,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 @@ -285,8 +313,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 @@ -308,8 +339,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 @@ -329,8 +362,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 @@ -350,8 +385,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 @@ -373,8 +410,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 @@ -583,7 +622,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Call the create app gateway method over HTTP. @@ -594,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: ~.operations_pb2.Operation: @@ -608,6 +649,7 @@ def __call__( http_options = ( _BaseAppGatewaysServiceRestTransport._BaseCreateAppGateway._get_http_options() ) + request, metadata = self._interceptor.pre_create_app_gateway( request, metadata ) @@ -624,6 +666,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.beyondcorp.appgateways_v1.AppGatewaysServiceClient.CreateAppGateway", + extra={ + "serviceName": "google.cloud.beyondcorp.appgateways.v1.AppGatewaysService", + "rpcName": "CreateAppGateway", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = AppGatewaysServiceRestTransport._CreateAppGateway._get_response( self._host, @@ -643,7 +712,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_app_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.beyondcorp.appgateways_v1.AppGatewaysServiceClient.create_app_gateway", + extra={ + "serviceName": "google.cloud.beyondcorp.appgateways.v1.AppGatewaysService", + "rpcName": "CreateAppGateway", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _DeleteAppGateway( @@ -681,7 +772,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Call the delete app gateway method over HTTP. @@ -692,8 +783,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.operations_pb2.Operation: @@ -706,6 +799,7 @@ def __call__( http_options = ( _BaseAppGatewaysServiceRestTransport._BaseDeleteAppGateway._get_http_options() ) + request, metadata = self._interceptor.pre_delete_app_gateway( request, metadata ) @@ -718,6 +812,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.beyondcorp.appgateways_v1.AppGatewaysServiceClient.DeleteAppGateway", + extra={ + "serviceName": "google.cloud.beyondcorp.appgateways.v1.AppGatewaysService", + "rpcName": "DeleteAppGateway", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = AppGatewaysServiceRestTransport._DeleteAppGateway._get_response( self._host, @@ -736,7 +857,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_app_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.beyondcorp.appgateways_v1.AppGatewaysServiceClient.delete_app_gateway", + extra={ + "serviceName": "google.cloud.beyondcorp.appgateways.v1.AppGatewaysService", + "rpcName": "DeleteAppGateway", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _GetAppGateway( @@ -774,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]]] = (), ) -> app_gateways_service.AppGateway: r"""Call the get app gateway method over HTTP. @@ -785,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: ~.app_gateways_service.AppGateway: @@ -804,6 +949,7 @@ def __call__( http_options = ( _BaseAppGatewaysServiceRestTransport._BaseGetAppGateway._get_http_options() ) + request, metadata = self._interceptor.pre_get_app_gateway(request, metadata) transcoded_request = _BaseAppGatewaysServiceRestTransport._BaseGetAppGateway._get_transcoded_request( http_options, request @@ -814,6 +960,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.beyondcorp.appgateways_v1.AppGatewaysServiceClient.GetAppGateway", + extra={ + "serviceName": "google.cloud.beyondcorp.appgateways.v1.AppGatewaysService", + "rpcName": "GetAppGateway", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = AppGatewaysServiceRestTransport._GetAppGateway._get_response( self._host, @@ -834,7 +1007,29 @@ def __call__( pb_resp = app_gateways_service.AppGateway.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_app_gateway(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = app_gateways_service.AppGateway.to_json(response) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.beyondcorp.appgateways_v1.AppGatewaysServiceClient.get_app_gateway", + extra={ + "serviceName": "google.cloud.beyondcorp.appgateways.v1.AppGatewaysService", + "rpcName": "GetAppGateway", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ListAppGateways( @@ -872,7 +1067,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> app_gateways_service.ListAppGatewaysResponse: r"""Call the list app gateways method over HTTP. @@ -883,8 +1078,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.app_gateways_service.ListAppGatewaysResponse: @@ -896,6 +1093,7 @@ def __call__( http_options = ( _BaseAppGatewaysServiceRestTransport._BaseListAppGateways._get_http_options() ) + request, metadata = self._interceptor.pre_list_app_gateways( request, metadata ) @@ -908,6 +1106,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.beyondcorp.appgateways_v1.AppGatewaysServiceClient.ListAppGateways", + extra={ + "serviceName": "google.cloud.beyondcorp.appgateways.v1.AppGatewaysService", + "rpcName": "ListAppGateways", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = AppGatewaysServiceRestTransport._ListAppGateways._get_response( self._host, @@ -928,7 +1153,31 @@ def __call__( pb_resp = app_gateways_service.ListAppGatewaysResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_app_gateways(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = ( + app_gateways_service.ListAppGatewaysResponse.to_json(response) + ) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.beyondcorp.appgateways_v1.AppGatewaysServiceClient.list_app_gateways", + extra={ + "serviceName": "google.cloud.beyondcorp.appgateways.v1.AppGatewaysService", + "rpcName": "ListAppGateways", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp @property @@ -1011,7 +1260,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> locations_pb2.Location: r"""Call the get location method over HTTP. @@ -1021,8 +1270,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each 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. @@ -1031,6 +1282,7 @@ def __call__( http_options = ( _BaseAppGatewaysServiceRestTransport._BaseGetLocation._get_http_options() ) + request, metadata = self._interceptor.pre_get_location(request, metadata) transcoded_request = _BaseAppGatewaysServiceRestTransport._BaseGetLocation._get_transcoded_request( http_options, request @@ -1041,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.beyondcorp.appgateways_v1.AppGatewaysServiceClient.GetLocation", + extra={ + "serviceName": "google.cloud.beyondcorp.appgateways.v1.AppGatewaysService", + "rpcName": "GetLocation", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = AppGatewaysServiceRestTransport._GetLocation._get_response( self._host, @@ -1060,6 +1339,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.beyondcorp.appgateways_v1.AppGatewaysServiceAsyncClient.GetLocation", + extra={ + "serviceName": "google.cloud.beyondcorp.appgateways.v1.AppGatewaysService", + "rpcName": "GetLocation", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property @@ -1101,7 +1401,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> locations_pb2.ListLocationsResponse: r"""Call the list locations method over HTTP. @@ -1111,8 +1411,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each 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. @@ -1121,6 +1423,7 @@ def __call__( http_options = ( _BaseAppGatewaysServiceRestTransport._BaseListLocations._get_http_options() ) + request, metadata = self._interceptor.pre_list_locations(request, metadata) transcoded_request = _BaseAppGatewaysServiceRestTransport._BaseListLocations._get_transcoded_request( http_options, request @@ -1131,6 +1434,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.beyondcorp.appgateways_v1.AppGatewaysServiceClient.ListLocations", + extra={ + "serviceName": "google.cloud.beyondcorp.appgateways.v1.AppGatewaysService", + "rpcName": "ListLocations", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = AppGatewaysServiceRestTransport._ListLocations._get_response( self._host, @@ -1150,6 +1480,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.beyondcorp.appgateways_v1.AppGatewaysServiceAsyncClient.ListLocations", + extra={ + "serviceName": "google.cloud.beyondcorp.appgateways.v1.AppGatewaysService", + "rpcName": "ListLocations", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property @@ -1191,7 +1542,7 @@ 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. @@ -1201,8 +1552,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: policy_pb2.Policy: Response from GetIamPolicy method. @@ -1211,6 +1564,7 @@ def __call__( http_options = ( _BaseAppGatewaysServiceRestTransport._BaseGetIamPolicy._get_http_options() ) + request, metadata = self._interceptor.pre_get_iam_policy(request, metadata) transcoded_request = _BaseAppGatewaysServiceRestTransport._BaseGetIamPolicy._get_transcoded_request( http_options, request @@ -1221,6 +1575,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.beyondcorp.appgateways_v1.AppGatewaysServiceClient.GetIamPolicy", + extra={ + "serviceName": "google.cloud.beyondcorp.appgateways.v1.AppGatewaysService", + "rpcName": "GetIamPolicy", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = AppGatewaysServiceRestTransport._GetIamPolicy._get_response( self._host, @@ -1240,6 +1621,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.beyondcorp.appgateways_v1.AppGatewaysServiceAsyncClient.GetIamPolicy", + extra={ + "serviceName": "google.cloud.beyondcorp.appgateways.v1.AppGatewaysService", + "rpcName": "GetIamPolicy", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property @@ -1282,7 +1684,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> policy_pb2.Policy: r"""Call the set iam policy method over HTTP. @@ -1292,8 +1694,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each 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. @@ -1302,6 +1706,7 @@ def __call__( http_options = ( _BaseAppGatewaysServiceRestTransport._BaseSetIamPolicy._get_http_options() ) + request, metadata = self._interceptor.pre_set_iam_policy(request, metadata) transcoded_request = _BaseAppGatewaysServiceRestTransport._BaseSetIamPolicy._get_transcoded_request( http_options, request @@ -1316,6 +1721,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.beyondcorp.appgateways_v1.AppGatewaysServiceClient.SetIamPolicy", + extra={ + "serviceName": "google.cloud.beyondcorp.appgateways.v1.AppGatewaysService", + "rpcName": "SetIamPolicy", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = AppGatewaysServiceRestTransport._SetIamPolicy._get_response( self._host, @@ -1336,6 +1768,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.beyondcorp.appgateways_v1.AppGatewaysServiceAsyncClient.SetIamPolicy", + extra={ + "serviceName": "google.cloud.beyondcorp.appgateways.v1.AppGatewaysService", + "rpcName": "SetIamPolicy", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property @@ -1378,7 +1831,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> iam_policy_pb2.TestIamPermissionsResponse: r"""Call the test iam permissions method over HTTP. @@ -1388,8 +1841,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each 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. @@ -1398,6 +1853,7 @@ def __call__( http_options = ( _BaseAppGatewaysServiceRestTransport._BaseTestIamPermissions._get_http_options() ) + request, metadata = self._interceptor.pre_test_iam_permissions( request, metadata ) @@ -1414,6 +1870,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.beyondcorp.appgateways_v1.AppGatewaysServiceClient.TestIamPermissions", + extra={ + "serviceName": "google.cloud.beyondcorp.appgateways.v1.AppGatewaysService", + "rpcName": "TestIamPermissions", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ( AppGatewaysServiceRestTransport._TestIamPermissions._get_response( @@ -1436,6 +1919,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.beyondcorp.appgateways_v1.AppGatewaysServiceAsyncClient.TestIamPermissions", + extra={ + "serviceName": "google.cloud.beyondcorp.appgateways.v1.AppGatewaysService", + "rpcName": "TestIamPermissions", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property @@ -1478,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]]] = (), ) -> None: r"""Call the cancel operation method over HTTP. @@ -1488,13 +1992,16 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. """ http_options = ( _BaseAppGatewaysServiceRestTransport._BaseCancelOperation._get_http_options() ) + request, metadata = self._interceptor.pre_cancel_operation( request, metadata ) @@ -1511,6 +2018,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.beyondcorp.appgateways_v1.AppGatewaysServiceClient.CancelOperation", + extra={ + "serviceName": "google.cloud.beyondcorp.appgateways.v1.AppGatewaysService", + "rpcName": "CancelOperation", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = AppGatewaysServiceRestTransport._CancelOperation._get_response( self._host, @@ -1568,7 +2102,7 @@ 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. @@ -1578,13 +2112,16 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. """ http_options = ( _BaseAppGatewaysServiceRestTransport._BaseDeleteOperation._get_http_options() ) + request, metadata = self._interceptor.pre_delete_operation( request, metadata ) @@ -1597,6 +2134,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.beyondcorp.appgateways_v1.AppGatewaysServiceClient.DeleteOperation", + extra={ + "serviceName": "google.cloud.beyondcorp.appgateways.v1.AppGatewaysService", + "rpcName": "DeleteOperation", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = AppGatewaysServiceRestTransport._DeleteOperation._get_response( self._host, @@ -1653,7 +2217,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.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. @@ -1663,8 +2227,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be 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. @@ -1673,6 +2239,7 @@ def __call__( http_options = ( _BaseAppGatewaysServiceRestTransport._BaseGetOperation._get_http_options() ) + request, metadata = self._interceptor.pre_get_operation(request, metadata) transcoded_request = _BaseAppGatewaysServiceRestTransport._BaseGetOperation._get_transcoded_request( http_options, request @@ -1683,6 +2250,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.beyondcorp.appgateways_v1.AppGatewaysServiceClient.GetOperation", + extra={ + "serviceName": "google.cloud.beyondcorp.appgateways.v1.AppGatewaysService", + "rpcName": "GetOperation", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = AppGatewaysServiceRestTransport._GetOperation._get_response( self._host, @@ -1702,6 +2296,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.beyondcorp.appgateways_v1.AppGatewaysServiceAsyncClient.GetOperation", + extra={ + "serviceName": "google.cloud.beyondcorp.appgateways.v1.AppGatewaysService", + "rpcName": "GetOperation", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property @@ -1743,7 +2358,7 @@ def __call__( *, 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. @@ -1753,8 +2368,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of 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. @@ -1763,6 +2380,7 @@ def __call__( http_options = ( _BaseAppGatewaysServiceRestTransport._BaseListOperations._get_http_options() ) + request, metadata = self._interceptor.pre_list_operations(request, metadata) transcoded_request = _BaseAppGatewaysServiceRestTransport._BaseListOperations._get_transcoded_request( http_options, request @@ -1773,6 +2391,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.beyondcorp.appgateways_v1.AppGatewaysServiceClient.ListOperations", + extra={ + "serviceName": "google.cloud.beyondcorp.appgateways.v1.AppGatewaysService", + "rpcName": "ListOperations", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = AppGatewaysServiceRestTransport._ListOperations._get_response( self._host, @@ -1792,6 +2437,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.beyondcorp.appgateways_v1.AppGatewaysServiceAsyncClient.ListOperations", + extra={ + "serviceName": "google.cloud.beyondcorp.appgateways.v1.AppGatewaysService", + "rpcName": "ListOperations", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property diff --git a/packages/google-cloud-beyondcorp-appgateways/samples/generated_samples/snippet_metadata_google.cloud.beyondcorp.appgateways.v1.json b/packages/google-cloud-beyondcorp-appgateways/samples/generated_samples/snippet_metadata_google.cloud.beyondcorp.appgateways.v1.json index ed4543c0a53d..0b3067b40e2b 100644 --- a/packages/google-cloud-beyondcorp-appgateways/samples/generated_samples/snippet_metadata_google.cloud.beyondcorp.appgateways.v1.json +++ b/packages/google-cloud-beyondcorp-appgateways/samples/generated_samples/snippet_metadata_google.cloud.beyondcorp.appgateways.v1.json @@ -8,7 +8,7 @@ ], "language": "PYTHON", "name": "google-cloud-beyondcorp-appgateways", - "version": "0.4.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.beyondcorp_appgateways_v1.types.AppGateway", @@ -465,7 +465,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.beyondcorp_appgateways_v1.types.AppGateway", @@ -546,7 +546,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.beyondcorp_appgateways_v1.services.app_gateways_service.pagers.ListAppGatewaysAsyncPager", @@ -626,7 +626,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.beyondcorp_appgateways_v1.services.app_gateways_service.pagers.ListAppGatewaysPager", diff --git a/packages/google-cloud-beyondcorp-appgateways/tests/unit/gapic/beyondcorp_appgateways_v1/test_app_gateways_service.py b/packages/google-cloud-beyondcorp-appgateways/tests/unit/gapic/beyondcorp_appgateways_v1/test_app_gateways_service.py index f115c48d43da..f7561524c54c 100644 --- a/packages/google-cloud-beyondcorp-appgateways/tests/unit/gapic/beyondcorp_appgateways_v1/test_app_gateways_service.py +++ b/packages/google-cloud-beyondcorp-appgateways/tests/unit/gapic/beyondcorp_appgateways_v1/test_app_gateways_service.py @@ -2853,6 +2853,7 @@ def test_list_app_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_app_gateways(request) @@ -2908,6 +2909,7 @@ def test_list_app_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_app_gateways(**mock_args) @@ -3102,6 +3104,7 @@ def test_get_app_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.get_app_gateway(request) @@ -3149,6 +3152,7 @@ def test_get_app_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_app_gateway(**mock_args) @@ -3294,6 +3298,7 @@ def test_create_app_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_app_gateway(request) @@ -3353,6 +3358,7 @@ def test_create_app_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_app_gateway(**mock_args) @@ -3498,6 +3504,7 @@ def test_delete_app_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_app_gateway(request) @@ -3551,6 +3558,7 @@ def test_delete_app_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_app_gateway(**mock_args) @@ -3935,6 +3943,7 @@ def test_list_app_gateways_rest_bad_request( response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.list_app_gateways(request) @@ -3971,6 +3980,7 @@ def test_list_app_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_app_gateways(request) # Establish that the response is the type that we expect. @@ -4012,6 +4022,7 @@ def test_list_app_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 = app_gateways_service.ListAppGatewaysResponse.to_json( app_gateways_service.ListAppGatewaysResponse() ) @@ -4058,6 +4069,7 @@ def test_get_app_gateway_rest_bad_request( response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.get_app_gateway(request) @@ -4099,6 +4111,7 @@ def test_get_app_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_app_gateway(request) # Establish that the response is the type that we expect. @@ -4147,6 +4160,7 @@ def test_get_app_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 = app_gateways_service.AppGateway.to_json( app_gateways_service.AppGateway() ) @@ -4193,6 +4207,7 @@ def test_create_app_gateway_rest_bad_request( response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.create_app_gateway(request) @@ -4303,6 +4318,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.create_app_gateway(request) # Establish that the response is the type that we expect. @@ -4344,6 +4360,7 @@ def test_create_app_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 @@ -4388,6 +4405,7 @@ def test_delete_app_gateway_rest_bad_request( response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.delete_app_gateway(request) @@ -4418,6 +4436,7 @@ def test_delete_app_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_app_gateway(request) # Establish that the response is the type that we expect. @@ -4459,6 +4478,7 @@ def test_delete_app_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 @@ -4503,6 +4523,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) @@ -4533,6 +4554,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) @@ -4561,6 +4583,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) @@ -4591,6 +4614,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) @@ -4622,6 +4646,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) @@ -4654,6 +4679,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) @@ -4685,6 +4711,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) @@ -4717,6 +4744,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) @@ -4748,6 +4776,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) @@ -4780,6 +4809,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) @@ -4810,6 +4840,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) @@ -4840,6 +4871,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) @@ -4870,6 +4902,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) @@ -4900,6 +4933,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) @@ -4930,6 +4964,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) @@ -4960,6 +4995,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) @@ -4990,6 +5026,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) @@ -5020,6 +5057,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-beyondcorp-clientconnectorservices/google/cloud/beyondcorp_clientconnectorservices/gapic_version.py b/packages/google-cloud-beyondcorp-clientconnectorservices/google/cloud/beyondcorp_clientconnectorservices/gapic_version.py index 9b19e5f10e00..558c8aab67c5 100644 --- a/packages/google-cloud-beyondcorp-clientconnectorservices/google/cloud/beyondcorp_clientconnectorservices/gapic_version.py +++ b/packages/google-cloud-beyondcorp-clientconnectorservices/google/cloud/beyondcorp_clientconnectorservices/gapic_version.py @@ -13,4 +13,4 @@ # See the License for the specific language governing permissions and # limitations under the License. # -__version__ = "0.4.13" # {x-release-please-version} +__version__ = "0.0.0" # {x-release-please-version} diff --git a/packages/google-cloud-beyondcorp-clientconnectorservices/google/cloud/beyondcorp_clientconnectorservices_v1/gapic_version.py b/packages/google-cloud-beyondcorp-clientconnectorservices/google/cloud/beyondcorp_clientconnectorservices_v1/gapic_version.py index 9b19e5f10e00..558c8aab67c5 100644 --- a/packages/google-cloud-beyondcorp-clientconnectorservices/google/cloud/beyondcorp_clientconnectorservices_v1/gapic_version.py +++ b/packages/google-cloud-beyondcorp-clientconnectorservices/google/cloud/beyondcorp_clientconnectorservices_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.13" # {x-release-please-version} +__version__ = "0.0.0" # {x-release-please-version} diff --git a/packages/google-cloud-beyondcorp-clientconnectorservices/google/cloud/beyondcorp_clientconnectorservices_v1/services/client_connector_services_service/async_client.py b/packages/google-cloud-beyondcorp-clientconnectorservices/google/cloud/beyondcorp_clientconnectorservices_v1/services/client_connector_services_service/async_client.py index 25bc17f97f79..1319545610b6 100644 --- a/packages/google-cloud-beyondcorp-clientconnectorservices/google/cloud/beyondcorp_clientconnectorservices_v1/services/client_connector_services_service/async_client.py +++ b/packages/google-cloud-beyondcorp-clientconnectorservices/google/cloud/beyondcorp_clientconnectorservices_v1/services/client_connector_services_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.grpc_asyncio import ClientConnectorServicesServiceGrpcAsyncIOTransport +try: + from google.api_core import client_logging # type: ignore + + CLIENT_LOGGING_SUPPORTED = True # pragma: NO COVER +except ImportError: # pragma: NO COVER + CLIENT_LOGGING_SUPPORTED = False + +_LOGGER = std_logging.getLogger(__name__) + class ClientConnectorServicesServiceAsyncClient: """API Overview: @@ -300,6 +310,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.beyondcorp.clientconnectorservices_v1.ClientConnectorServicesServiceAsyncClient`.", + extra={ + "serviceName": "google.cloud.beyondcorp.clientconnectorservices.v1.ClientConnectorServicesService", + "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.beyondcorp.clientconnectorservices.v1.ClientConnectorServicesService", + "credentialsType": None, + }, + ) + async def list_client_connector_services( self, request: Optional[ @@ -312,7 +344,7 @@ async def list_client_connector_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.ListClientConnectorServicesAsyncPager: r"""Lists ClientConnectorServices in a given project and location. @@ -358,8 +390,10 @@ async def sample_list_client_connector_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.beyondcorp_clientconnectorservices_v1.services.client_connector_services_service.pagers.ListClientConnectorServicesAsyncPager: @@ -445,7 +479,7 @@ async def get_client_connector_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]]] = (), ) -> client_connector_services_service.ClientConnectorService: r"""Gets details of a single ClientConnectorService. @@ -487,8 +521,10 @@ async def sample_get_client_connector_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.beyondcorp_clientconnectorservices_v1.types.ClientConnectorService: @@ -564,7 +600,7 @@ async def create_client_connector_service( client_connector_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 new ClientConnectorService in a given project and location. @@ -639,8 +675,10 @@ async def sample_create_client_connector_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: @@ -733,7 +771,7 @@ async def update_client_connector_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 the parameters of a single ClientConnectorService. @@ -801,8 +839,10 @@ async def sample_update_client_connector_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: @@ -895,7 +935,7 @@ async def delete_client_connector_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 single ClientConnectorService. @@ -941,8 +981,10 @@ async def sample_delete_client_connector_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: @@ -1027,7 +1069,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. @@ -1038,8 +1080,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. @@ -1080,7 +1124,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. @@ -1091,8 +1135,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. @@ -1133,7 +1179,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. @@ -1149,8 +1195,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 """ @@ -1187,7 +1235,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. @@ -1202,8 +1250,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 """ @@ -1240,7 +1290,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. @@ -1253,8 +1303,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. @@ -1359,7 +1411,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. @@ -1373,8 +1425,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. @@ -1479,7 +1533,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. @@ -1494,8 +1548,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. @@ -1539,7 +1595,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. @@ -1550,8 +1606,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. @@ -1592,7 +1650,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. @@ -1603,8 +1661,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-beyondcorp-clientconnectorservices/google/cloud/beyondcorp_clientconnectorservices_v1/services/client_connector_services_service/client.py b/packages/google-cloud-beyondcorp-clientconnectorservices/google/cloud/beyondcorp_clientconnectorservices_v1/services/client_connector_services_service/client.py index b84831bdbecf..e9c5bdcdd8ef 100644 --- a/packages/google-cloud-beyondcorp-clientconnectorservices/google/cloud/beyondcorp_clientconnectorservices_v1/services/client_connector_services_service/client.py +++ b/packages/google-cloud-beyondcorp-clientconnectorservices/google/cloud/beyondcorp_clientconnectorservices_v1/services/client_connector_services_service/client.py @@ -14,6 +14,7 @@ # limitations under the License. # from collections import OrderedDict +import logging as std_logging import os import re from typing import ( @@ -50,6 +51,15 @@ except AttributeError: # pragma: NO COVER OptionalRetry = Union[retries.Retry, object, None] # type: ignore +try: + from google.api_core import client_logging # type: ignore + + CLIENT_LOGGING_SUPPORTED = True # pragma: NO COVER +except ImportError: # pragma: NO COVER + CLIENT_LOGGING_SUPPORTED = False + +_LOGGER = std_logging.getLogger(__name__) + from google.api_core import operation # type: ignore from google.api_core import operation_async # type: ignore from google.cloud.location import locations_pb2 # type: ignore @@ -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( @@ -692,6 +706,29 @@ def __init__( api_audience=self._client_options.api_audience, ) + if "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.beyondcorp.clientconnectorservices_v1.ClientConnectorServicesServiceClient`.", + extra={ + "serviceName": "google.cloud.beyondcorp.clientconnectorservices.v1.ClientConnectorServicesService", + "universeDomain": getattr( + self._transport._credentials, "universe_domain", "" + ), + "credentialsType": f"{type(self._transport._credentials).__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.beyondcorp.clientconnectorservices.v1.ClientConnectorServicesService", + "credentialsType": None, + }, + ) + def list_client_connector_services( self, request: Optional[ @@ -704,7 +741,7 @@ def list_client_connector_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.ListClientConnectorServicesPager: r"""Lists ClientConnectorServices in a given project and location. @@ -750,8 +787,10 @@ def sample_list_client_connector_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.beyondcorp_clientconnectorservices_v1.services.client_connector_services_service.pagers.ListClientConnectorServicesPager: @@ -836,7 +875,7 @@ def get_client_connector_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]]] = (), ) -> client_connector_services_service.ClientConnectorService: r"""Gets details of a single ClientConnectorService. @@ -878,8 +917,10 @@ def sample_get_client_connector_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.beyondcorp_clientconnectorservices_v1.types.ClientConnectorService: @@ -954,7 +995,7 @@ def create_client_connector_service( client_connector_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 new ClientConnectorService in a given project and location. @@ -1029,8 +1070,10 @@ def sample_create_client_connector_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: @@ -1122,7 +1165,7 @@ def update_client_connector_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 the parameters of a single ClientConnectorService. @@ -1190,8 +1233,10 @@ def sample_update_client_connector_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: @@ -1283,7 +1328,7 @@ def delete_client_connector_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 single ClientConnectorService. @@ -1329,8 +1374,10 @@ def sample_delete_client_connector_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: @@ -1427,7 +1474,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. @@ -1438,8 +1485,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. @@ -1480,7 +1529,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. @@ -1491,8 +1540,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. @@ -1533,7 +1584,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. @@ -1549,8 +1600,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 """ @@ -1587,7 +1640,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. @@ -1602,8 +1655,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 """ @@ -1640,7 +1695,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. @@ -1653,8 +1708,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. @@ -1759,7 +1816,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. @@ -1773,8 +1830,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. @@ -1879,7 +1938,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. @@ -1894,8 +1953,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. @@ -1937,7 +1998,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. @@ -1948,8 +2009,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. @@ -1990,7 +2053,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. @@ -2001,8 +2064,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-beyondcorp-clientconnectorservices/google/cloud/beyondcorp_clientconnectorservices_v1/services/client_connector_services_service/pagers.py b/packages/google-cloud-beyondcorp-clientconnectorservices/google/cloud/beyondcorp_clientconnectorservices_v1/services/client_connector_services_service/pagers.py index 3c7be62bb138..108596ab3eb6 100644 --- a/packages/google-cloud-beyondcorp-clientconnectorservices/google/cloud/beyondcorp_clientconnectorservices_v1/services/client_connector_services_service/pagers.py +++ b/packages/google-cloud-beyondcorp-clientconnectorservices/google/cloud/beyondcorp_clientconnectorservices_v1/services/client_connector_services_service/pagers.py @@ -71,7 +71,7 @@ def __init__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiate the pager. @@ -85,8 +85,10 @@ def __init__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. """ self._method = method self._request = ( @@ -160,7 +162,7 @@ def __init__( *, retry: OptionalAsyncRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiates the pager. @@ -174,8 +176,10 @@ def __init__( retry (google.api_core.retry.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of 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-beyondcorp-clientconnectorservices/google/cloud/beyondcorp_clientconnectorservices_v1/services/client_connector_services_service/transports/grpc.py b/packages/google-cloud-beyondcorp-clientconnectorservices/google/cloud/beyondcorp_clientconnectorservices_v1/services/client_connector_services_service/transports/grpc.py index 040f99240ea6..4d9c03caac5f 100644 --- a/packages/google-cloud-beyondcorp-clientconnectorservices/google/cloud/beyondcorp_clientconnectorservices_v1/services/client_connector_services_service/transports/grpc.py +++ b/packages/google-cloud-beyondcorp-clientconnectorservices/google/cloud/beyondcorp_clientconnectorservices_v1/services/client_connector_services_service/transports/grpc.py @@ -13,6 +13,9 @@ # See the License for the specific language governing permissions and # limitations under the License. # +import json +import logging as std_logging +import pickle from typing import Callable, Dict, Optional, Sequence, Tuple, Union import warnings @@ -24,7 +27,10 @@ from google.iam.v1 import iam_policy_pb2 # type: ignore from google.iam.v1 import policy_pb2 # type: ignore from google.longrunning import operations_pb2 # type: ignore +from google.protobuf.json_format import MessageToJson +import google.protobuf.message import grpc # type: ignore +import proto # type: ignore from google.cloud.beyondcorp_clientconnectorservices_v1.types import ( client_connector_services_service, @@ -32,6 +38,81 @@ from .base import DEFAULT_CLIENT_INFO, ClientConnectorServicesServiceTransport +try: + from google.api_core import client_logging # 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.beyondcorp.clientconnectorservices.v1.ClientConnectorServicesService", + "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.beyondcorp.clientconnectorservices.v1.ClientConnectorServicesService", + "rpcName": client_call_details.method, + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class ClientConnectorServicesServiceGrpcTransport( ClientConnectorServicesServiceTransport @@ -198,7 +279,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,9 @@ def operations_client(self) -> operations_v1.OperationsClient: """ # Quick check: Only create a new client if we do not already have one. if self._operations_client is None: - self._operations_client = operations_v1.OperationsClient(self.grpc_channel) + self._operations_client = operations_v1.OperationsClient( + self._logged_channel + ) # Return the client from cache. return self._operations_client @@ -292,7 +380,7 @@ def list_client_connector_services( if "list_client_connector_services" not in self._stubs: self._stubs[ "list_client_connector_services" - ] = self.grpc_channel.unary_unary( + ] = self._logged_channel.unary_unary( "/google.cloud.beyondcorp.clientconnectorservices.v1.ClientConnectorServicesService/ListClientConnectorServices", request_serializer=client_connector_services_service.ListClientConnectorServicesRequest.serialize, response_deserializer=client_connector_services_service.ListClientConnectorServicesResponse.deserialize, @@ -321,7 +409,9 @@ def get_client_connector_service( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_client_connector_service" not in self._stubs: - self._stubs["get_client_connector_service"] = self.grpc_channel.unary_unary( + self._stubs[ + "get_client_connector_service" + ] = self._logged_channel.unary_unary( "/google.cloud.beyondcorp.clientconnectorservices.v1.ClientConnectorServicesService/GetClientConnectorService", request_serializer=client_connector_services_service.GetClientConnectorServiceRequest.serialize, response_deserializer=client_connector_services_service.ClientConnectorService.deserialize, @@ -354,7 +444,7 @@ def create_client_connector_service( if "create_client_connector_service" not in self._stubs: self._stubs[ "create_client_connector_service" - ] = self.grpc_channel.unary_unary( + ] = self._logged_channel.unary_unary( "/google.cloud.beyondcorp.clientconnectorservices.v1.ClientConnectorServicesService/CreateClientConnectorService", request_serializer=client_connector_services_service.CreateClientConnectorServiceRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -387,7 +477,7 @@ def update_client_connector_service( if "update_client_connector_service" not in self._stubs: self._stubs[ "update_client_connector_service" - ] = self.grpc_channel.unary_unary( + ] = self._logged_channel.unary_unary( "/google.cloud.beyondcorp.clientconnectorservices.v1.ClientConnectorServicesService/UpdateClientConnectorService", request_serializer=client_connector_services_service.UpdateClientConnectorServiceRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -419,7 +509,7 @@ def delete_client_connector_service( if "delete_client_connector_service" not in self._stubs: self._stubs[ "delete_client_connector_service" - ] = self.grpc_channel.unary_unary( + ] = self._logged_channel.unary_unary( "/google.cloud.beyondcorp.clientconnectorservices.v1.ClientConnectorServicesService/DeleteClientConnectorService", request_serializer=client_connector_services_service.DeleteClientConnectorServiceRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -427,7 +517,7 @@ def delete_client_connector_service( return self._stubs["delete_client_connector_service"] def close(self): - self.grpc_channel.close() + self._logged_channel.close() @property def delete_operation( @@ -439,7 +529,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, @@ -456,7 +546,7 @@ def cancel_operation( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "cancel_operation" not in self._stubs: - self._stubs["cancel_operation"] = self.grpc_channel.unary_unary( + self._stubs["cancel_operation"] = self._logged_channel.unary_unary( "/google.longrunning.Operations/CancelOperation", request_serializer=operations_pb2.CancelOperationRequest.SerializeToString, response_deserializer=None, @@ -473,7 +563,7 @@ def get_operation( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_operation" not in self._stubs: - self._stubs["get_operation"] = self.grpc_channel.unary_unary( + self._stubs["get_operation"] = self._logged_channel.unary_unary( "/google.longrunning.Operations/GetOperation", request_serializer=operations_pb2.GetOperationRequest.SerializeToString, response_deserializer=operations_pb2.Operation.FromString, @@ -492,7 +582,7 @@ def list_operations( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_operations" not in self._stubs: - self._stubs["list_operations"] = self.grpc_channel.unary_unary( + self._stubs["list_operations"] = self._logged_channel.unary_unary( "/google.longrunning.Operations/ListOperations", request_serializer=operations_pb2.ListOperationsRequest.SerializeToString, response_deserializer=operations_pb2.ListOperationsResponse.FromString, @@ -511,7 +601,7 @@ def list_locations( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_locations" not in self._stubs: - self._stubs["list_locations"] = self.grpc_channel.unary_unary( + self._stubs["list_locations"] = self._logged_channel.unary_unary( "/google.cloud.location.Locations/ListLocations", request_serializer=locations_pb2.ListLocationsRequest.SerializeToString, response_deserializer=locations_pb2.ListLocationsResponse.FromString, @@ -528,7 +618,7 @@ def get_location( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_location" not in self._stubs: - self._stubs["get_location"] = self.grpc_channel.unary_unary( + self._stubs["get_location"] = self._logged_channel.unary_unary( "/google.cloud.location.Locations/GetLocation", request_serializer=locations_pb2.GetLocationRequest.SerializeToString, response_deserializer=locations_pb2.Location.FromString, @@ -553,7 +643,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, @@ -579,7 +669,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, @@ -608,7 +698,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-beyondcorp-clientconnectorservices/google/cloud/beyondcorp_clientconnectorservices_v1/services/client_connector_services_service/transports/grpc_asyncio.py b/packages/google-cloud-beyondcorp-clientconnectorservices/google/cloud/beyondcorp_clientconnectorservices_v1/services/client_connector_services_service/transports/grpc_asyncio.py index b7c8d6b6103d..7e706aa687db 100644 --- a/packages/google-cloud-beyondcorp-clientconnectorservices/google/cloud/beyondcorp_clientconnectorservices_v1/services/client_connector_services_service/transports/grpc_asyncio.py +++ b/packages/google-cloud-beyondcorp-clientconnectorservices/google/cloud/beyondcorp_clientconnectorservices_v1/services/client_connector_services_service/transports/grpc_asyncio.py @@ -14,6 +14,9 @@ # limitations under the License. # import inspect +import json +import logging as std_logging +import pickle from typing import Awaitable, Callable, Dict, Optional, Sequence, Tuple, Union import warnings @@ -26,8 +29,11 @@ from google.iam.v1 import iam_policy_pb2 # type: ignore from google.iam.v1 import policy_pb2 # type: ignore from google.longrunning import operations_pb2 # type: ignore +from google.protobuf.json_format import MessageToJson +import google.protobuf.message import grpc # type: ignore from grpc.experimental import aio # type: ignore +import proto # type: ignore from google.cloud.beyondcorp_clientconnectorservices_v1.types import ( client_connector_services_service, @@ -36,6 +42,82 @@ from .base import DEFAULT_CLIENT_INFO, ClientConnectorServicesServiceTransport from .grpc import ClientConnectorServicesServiceGrpcTransport +try: + from google.api_core import client_logging # 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.beyondcorp.clientconnectorservices.v1.ClientConnectorServicesService", + "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.beyondcorp.clientconnectorservices.v1.ClientConnectorServicesService", + "rpcName": str(client_call_details.method), + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class ClientConnectorServicesServiceGrpcAsyncIOTransport( ClientConnectorServicesServiceTransport @@ -245,10 +327,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 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. @@ -304,7 +389,7 @@ def list_client_connector_services( if "list_client_connector_services" not in self._stubs: self._stubs[ "list_client_connector_services" - ] = self.grpc_channel.unary_unary( + ] = self._logged_channel.unary_unary( "/google.cloud.beyondcorp.clientconnectorservices.v1.ClientConnectorServicesService/ListClientConnectorServices", request_serializer=client_connector_services_service.ListClientConnectorServicesRequest.serialize, response_deserializer=client_connector_services_service.ListClientConnectorServicesResponse.deserialize, @@ -333,7 +418,9 @@ def get_client_connector_service( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_client_connector_service" not in self._stubs: - self._stubs["get_client_connector_service"] = self.grpc_channel.unary_unary( + self._stubs[ + "get_client_connector_service" + ] = self._logged_channel.unary_unary( "/google.cloud.beyondcorp.clientconnectorservices.v1.ClientConnectorServicesService/GetClientConnectorService", request_serializer=client_connector_services_service.GetClientConnectorServiceRequest.serialize, response_deserializer=client_connector_services_service.ClientConnectorService.deserialize, @@ -366,7 +453,7 @@ def create_client_connector_service( if "create_client_connector_service" not in self._stubs: self._stubs[ "create_client_connector_service" - ] = self.grpc_channel.unary_unary( + ] = self._logged_channel.unary_unary( "/google.cloud.beyondcorp.clientconnectorservices.v1.ClientConnectorServicesService/CreateClientConnectorService", request_serializer=client_connector_services_service.CreateClientConnectorServiceRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -399,7 +486,7 @@ def update_client_connector_service( if "update_client_connector_service" not in self._stubs: self._stubs[ "update_client_connector_service" - ] = self.grpc_channel.unary_unary( + ] = self._logged_channel.unary_unary( "/google.cloud.beyondcorp.clientconnectorservices.v1.ClientConnectorServicesService/UpdateClientConnectorService", request_serializer=client_connector_services_service.UpdateClientConnectorServiceRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -431,7 +518,7 @@ def delete_client_connector_service( if "delete_client_connector_service" not in self._stubs: self._stubs[ "delete_client_connector_service" - ] = self.grpc_channel.unary_unary( + ] = self._logged_channel.unary_unary( "/google.cloud.beyondcorp.clientconnectorservices.v1.ClientConnectorServicesService/DeleteClientConnectorService", request_serializer=client_connector_services_service.DeleteClientConnectorServiceRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -519,7 +606,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: @@ -535,7 +622,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, @@ -552,7 +639,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, @@ -569,7 +656,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, @@ -588,7 +675,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, @@ -607,7 +694,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, @@ -624,7 +711,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, @@ -649,7 +736,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, @@ -675,7 +762,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, @@ -704,7 +791,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-beyondcorp-clientconnectorservices/google/cloud/beyondcorp_clientconnectorservices_v1/services/client_connector_services_service/transports/rest.py b/packages/google-cloud-beyondcorp-clientconnectorservices/google/cloud/beyondcorp_clientconnectorservices_v1/services/client_connector_services_service/transports/rest.py index 736b43a334d7..faeb3df59682 100644 --- a/packages/google-cloud-beyondcorp-clientconnectorservices/google/cloud/beyondcorp_clientconnectorservices_v1/services/client_connector_services_service/transports/rest.py +++ b/packages/google-cloud-beyondcorp-clientconnectorservices/google/cloud/beyondcorp_clientconnectorservices_v1/services/client_connector_services_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, @@ -115,10 +123,10 @@ def post_update_client_connector_service(self, response): def pre_create_client_connector_service( self, request: client_connector_services_service.CreateClientConnectorServiceRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ client_connector_services_service.CreateClientConnectorServiceRequest, - Sequence[Tuple[str, str]], + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for create_client_connector_service @@ -141,10 +149,10 @@ def post_create_client_connector_service( def pre_delete_client_connector_service( self, request: client_connector_services_service.DeleteClientConnectorServiceRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ client_connector_services_service.DeleteClientConnectorServiceRequest, - Sequence[Tuple[str, str]], + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for delete_client_connector_service @@ -167,10 +175,10 @@ def post_delete_client_connector_service( def pre_get_client_connector_service( self, request: client_connector_services_service.GetClientConnectorServiceRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ client_connector_services_service.GetClientConnectorServiceRequest, - Sequence[Tuple[str, str]], + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for get_client_connector_service @@ -193,10 +201,10 @@ def post_get_client_connector_service( def pre_list_client_connector_services( self, request: client_connector_services_service.ListClientConnectorServicesRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ client_connector_services_service.ListClientConnectorServicesRequest, - Sequence[Tuple[str, str]], + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for list_client_connector_services @@ -220,10 +228,10 @@ def post_list_client_connector_services( def pre_update_client_connector_service( self, request: client_connector_services_service.UpdateClientConnectorServiceRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ client_connector_services_service.UpdateClientConnectorServiceRequest, - Sequence[Tuple[str, str]], + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for update_client_connector_service @@ -246,8 +254,10 @@ def post_update_client_connector_service( 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 @@ -269,8 +279,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 @@ -292,8 +304,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 @@ -313,8 +327,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 @@ -334,8 +350,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 @@ -357,8 +376,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 @@ -378,8 +399,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 @@ -399,8 +422,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 @@ -422,8 +447,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 @@ -635,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 create client connector service method over HTTP. @@ -647,8 +674,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.operations_pb2.Operation: @@ -661,6 +690,7 @@ def __call__( http_options = ( _BaseClientConnectorServicesServiceRestTransport._BaseCreateClientConnectorService._get_http_options() ) + request, metadata = self._interceptor.pre_create_client_connector_service( request, metadata ) @@ -677,6 +707,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.beyondcorp.clientconnectorservices_v1.ClientConnectorServicesServiceClient.CreateClientConnectorService", + extra={ + "serviceName": "google.cloud.beyondcorp.clientconnectorservices.v1.ClientConnectorServicesService", + "rpcName": "CreateClientConnectorService", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ClientConnectorServicesServiceRestTransport._CreateClientConnectorService._get_response( self._host, @@ -696,7 +753,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_client_connector_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.beyondcorp.clientconnectorservices_v1.ClientConnectorServicesServiceClient.create_client_connector_service", + extra={ + "serviceName": "google.cloud.beyondcorp.clientconnectorservices.v1.ClientConnectorServicesService", + "rpcName": "CreateClientConnectorService", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _DeleteClientConnectorService( @@ -736,7 +815,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.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 client connector service method over HTTP. @@ -748,8 +827,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.operations_pb2.Operation: @@ -762,6 +843,7 @@ def __call__( http_options = ( _BaseClientConnectorServicesServiceRestTransport._BaseDeleteClientConnectorService._get_http_options() ) + request, metadata = self._interceptor.pre_delete_client_connector_service( request, metadata ) @@ -774,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 = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.beyondcorp.clientconnectorservices_v1.ClientConnectorServicesServiceClient.DeleteClientConnectorService", + extra={ + "serviceName": "google.cloud.beyondcorp.clientconnectorservices.v1.ClientConnectorServicesService", + "rpcName": "DeleteClientConnectorService", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ClientConnectorServicesServiceRestTransport._DeleteClientConnectorService._get_response( self._host, @@ -792,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_delete_client_connector_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.beyondcorp.clientconnectorservices_v1.ClientConnectorServicesServiceClient.delete_client_connector_service", + extra={ + "serviceName": "google.cloud.beyondcorp.clientconnectorservices.v1.ClientConnectorServicesService", + "rpcName": "DeleteClientConnectorService", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _GetClientConnectorService( @@ -832,7 +963,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> client_connector_services_service.ClientConnectorService: r"""Call the get client connector service method over HTTP. @@ -844,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: ~.client_connector_services_service.ClientConnectorService: @@ -857,6 +990,7 @@ def __call__( http_options = ( _BaseClientConnectorServicesServiceRestTransport._BaseGetClientConnectorService._get_http_options() ) + request, metadata = self._interceptor.pre_get_client_connector_service( request, metadata ) @@ -869,6 +1003,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.beyondcorp.clientconnectorservices_v1.ClientConnectorServicesServiceClient.GetClientConnectorService", + extra={ + "serviceName": "google.cloud.beyondcorp.clientconnectorservices.v1.ClientConnectorServicesService", + "rpcName": "GetClientConnectorService", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ClientConnectorServicesServiceRestTransport._GetClientConnectorService._get_response( self._host, @@ -889,7 +1050,31 @@ def __call__( pb_resp = client_connector_services_service.ClientConnectorService.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_client_connector_service(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = client_connector_services_service.ClientConnectorService.to_json( + response + ) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.beyondcorp.clientconnectorservices_v1.ClientConnectorServicesServiceClient.get_client_connector_service", + extra={ + "serviceName": "google.cloud.beyondcorp.clientconnectorservices.v1.ClientConnectorServicesService", + "rpcName": "GetClientConnectorService", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ListClientConnectorServices( @@ -929,7 +1114,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> client_connector_services_service.ListClientConnectorServicesResponse: r"""Call the list client connector services method over HTTP. @@ -941,8 +1126,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.client_connector_services_service.ListClientConnectorServicesResponse: @@ -954,6 +1141,7 @@ def __call__( http_options = ( _BaseClientConnectorServicesServiceRestTransport._BaseListClientConnectorServices._get_http_options() ) + request, metadata = self._interceptor.pre_list_client_connector_services( request, metadata ) @@ -966,6 +1154,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.beyondcorp.clientconnectorservices_v1.ClientConnectorServicesServiceClient.ListClientConnectorServices", + extra={ + "serviceName": "google.cloud.beyondcorp.clientconnectorservices.v1.ClientConnectorServicesService", + "rpcName": "ListClientConnectorServices", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ClientConnectorServicesServiceRestTransport._ListClientConnectorServices._get_response( self._host, @@ -990,7 +1205,31 @@ def __call__( ) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_client_connector_services(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = client_connector_services_service.ListClientConnectorServicesResponse.to_json( + response + ) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.beyondcorp.clientconnectorservices_v1.ClientConnectorServicesServiceClient.list_client_connector_services", + extra={ + "serviceName": "google.cloud.beyondcorp.clientconnectorservices.v1.ClientConnectorServicesService", + "rpcName": "ListClientConnectorServices", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _UpdateClientConnectorService( @@ -1031,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]]] = (), ) -> operations_pb2.Operation: r"""Call the update client connector service method over HTTP. @@ -1043,8 +1282,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.operations_pb2.Operation: @@ -1057,6 +1298,7 @@ def __call__( http_options = ( _BaseClientConnectorServicesServiceRestTransport._BaseUpdateClientConnectorService._get_http_options() ) + request, metadata = self._interceptor.pre_update_client_connector_service( request, metadata ) @@ -1073,6 +1315,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.beyondcorp.clientconnectorservices_v1.ClientConnectorServicesServiceClient.UpdateClientConnectorService", + extra={ + "serviceName": "google.cloud.beyondcorp.clientconnectorservices.v1.ClientConnectorServicesService", + "rpcName": "UpdateClientConnectorService", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ClientConnectorServicesServiceRestTransport._UpdateClientConnectorService._get_response( self._host, @@ -1092,7 +1361,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_client_connector_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.beyondcorp.clientconnectorservices_v1.ClientConnectorServicesServiceClient.update_client_connector_service", + extra={ + "serviceName": "google.cloud.beyondcorp.clientconnectorservices.v1.ClientConnectorServicesService", + "rpcName": "UpdateClientConnectorService", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp @property @@ -1189,7 +1480,7 @@ 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. @@ -1199,8 +1490,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each 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. @@ -1209,6 +1502,7 @@ def __call__( http_options = ( _BaseClientConnectorServicesServiceRestTransport._BaseGetLocation._get_http_options() ) + request, metadata = self._interceptor.pre_get_location(request, metadata) transcoded_request = _BaseClientConnectorServicesServiceRestTransport._BaseGetLocation._get_transcoded_request( http_options, request @@ -1219,6 +1513,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.beyondcorp.clientconnectorservices_v1.ClientConnectorServicesServiceClient.GetLocation", + extra={ + "serviceName": "google.cloud.beyondcorp.clientconnectorservices.v1.ClientConnectorServicesService", + "rpcName": "GetLocation", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ( ClientConnectorServicesServiceRestTransport._GetLocation._get_response( @@ -1240,6 +1561,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.beyondcorp.clientconnectorservices_v1.ClientConnectorServicesServiceAsyncClient.GetLocation", + extra={ + "serviceName": "google.cloud.beyondcorp.clientconnectorservices.v1.ClientConnectorServicesService", + "rpcName": "GetLocation", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property @@ -1281,7 +1623,7 @@ 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. @@ -1291,8 +1633,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: locations_pb2.ListLocationsResponse: Response from ListLocations method. @@ -1301,6 +1645,7 @@ def __call__( http_options = ( _BaseClientConnectorServicesServiceRestTransport._BaseListLocations._get_http_options() ) + request, metadata = self._interceptor.pre_list_locations(request, metadata) transcoded_request = _BaseClientConnectorServicesServiceRestTransport._BaseListLocations._get_transcoded_request( http_options, request @@ -1311,6 +1656,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.beyondcorp.clientconnectorservices_v1.ClientConnectorServicesServiceClient.ListLocations", + extra={ + "serviceName": "google.cloud.beyondcorp.clientconnectorservices.v1.ClientConnectorServicesService", + "rpcName": "ListLocations", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ClientConnectorServicesServiceRestTransport._ListLocations._get_response( self._host, @@ -1330,6 +1702,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.beyondcorp.clientconnectorservices_v1.ClientConnectorServicesServiceAsyncClient.ListLocations", + extra={ + "serviceName": "google.cloud.beyondcorp.clientconnectorservices.v1.ClientConnectorServicesService", + "rpcName": "ListLocations", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property @@ -1371,7 +1764,7 @@ 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. @@ -1381,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: policy_pb2.Policy: Response from GetIamPolicy method. @@ -1391,6 +1786,7 @@ def __call__( http_options = ( _BaseClientConnectorServicesServiceRestTransport._BaseGetIamPolicy._get_http_options() ) + request, metadata = self._interceptor.pre_get_iam_policy(request, metadata) transcoded_request = _BaseClientConnectorServicesServiceRestTransport._BaseGetIamPolicy._get_transcoded_request( http_options, request @@ -1401,6 +1797,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.beyondcorp.clientconnectorservices_v1.ClientConnectorServicesServiceClient.GetIamPolicy", + extra={ + "serviceName": "google.cloud.beyondcorp.clientconnectorservices.v1.ClientConnectorServicesService", + "rpcName": "GetIamPolicy", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ( ClientConnectorServicesServiceRestTransport._GetIamPolicy._get_response( @@ -1422,6 +1845,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.beyondcorp.clientconnectorservices_v1.ClientConnectorServicesServiceAsyncClient.GetIamPolicy", + extra={ + "serviceName": "google.cloud.beyondcorp.clientconnectorservices.v1.ClientConnectorServicesService", + "rpcName": "GetIamPolicy", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property @@ -1464,7 +1908,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> policy_pb2.Policy: r"""Call the set iam policy method over HTTP. @@ -1474,8 +1918,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each 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. @@ -1484,6 +1930,7 @@ def __call__( http_options = ( _BaseClientConnectorServicesServiceRestTransport._BaseSetIamPolicy._get_http_options() ) + request, metadata = self._interceptor.pre_set_iam_policy(request, metadata) transcoded_request = _BaseClientConnectorServicesServiceRestTransport._BaseSetIamPolicy._get_transcoded_request( http_options, request @@ -1498,6 +1945,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.beyondcorp.clientconnectorservices_v1.ClientConnectorServicesServiceClient.SetIamPolicy", + extra={ + "serviceName": "google.cloud.beyondcorp.clientconnectorservices.v1.ClientConnectorServicesService", + "rpcName": "SetIamPolicy", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ( ClientConnectorServicesServiceRestTransport._SetIamPolicy._get_response( @@ -1520,6 +1994,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.beyondcorp.clientconnectorservices_v1.ClientConnectorServicesServiceAsyncClient.SetIamPolicy", + extra={ + "serviceName": "google.cloud.beyondcorp.clientconnectorservices.v1.ClientConnectorServicesService", + "rpcName": "SetIamPolicy", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property @@ -1564,7 +2059,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> iam_policy_pb2.TestIamPermissionsResponse: r"""Call the test iam permissions method over HTTP. @@ -1574,8 +2069,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: iam_policy_pb2.TestIamPermissionsResponse: Response from TestIamPermissions method. @@ -1584,6 +2081,7 @@ def __call__( http_options = ( _BaseClientConnectorServicesServiceRestTransport._BaseTestIamPermissions._get_http_options() ) + request, metadata = self._interceptor.pre_test_iam_permissions( request, metadata ) @@ -1600,6 +2098,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.beyondcorp.clientconnectorservices_v1.ClientConnectorServicesServiceClient.TestIamPermissions", + extra={ + "serviceName": "google.cloud.beyondcorp.clientconnectorservices.v1.ClientConnectorServicesService", + "rpcName": "TestIamPermissions", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ClientConnectorServicesServiceRestTransport._TestIamPermissions._get_response( self._host, @@ -1620,6 +2145,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.beyondcorp.clientconnectorservices_v1.ClientConnectorServicesServiceAsyncClient.TestIamPermissions", + extra={ + "serviceName": "google.cloud.beyondcorp.clientconnectorservices.v1.ClientConnectorServicesService", + "rpcName": "TestIamPermissions", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property @@ -1662,7 +2208,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> None: r"""Call the cancel operation method over HTTP. @@ -1672,13 +2218,16 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. """ http_options = ( _BaseClientConnectorServicesServiceRestTransport._BaseCancelOperation._get_http_options() ) + request, metadata = self._interceptor.pre_cancel_operation( request, metadata ) @@ -1695,6 +2244,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.beyondcorp.clientconnectorservices_v1.ClientConnectorServicesServiceClient.CancelOperation", + extra={ + "serviceName": "google.cloud.beyondcorp.clientconnectorservices.v1.ClientConnectorServicesService", + "rpcName": "CancelOperation", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ClientConnectorServicesServiceRestTransport._CancelOperation._get_response( self._host, @@ -1752,7 +2328,7 @@ 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. @@ -1762,13 +2338,16 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. """ http_options = ( _BaseClientConnectorServicesServiceRestTransport._BaseDeleteOperation._get_http_options() ) + request, metadata = self._interceptor.pre_delete_operation( request, metadata ) @@ -1781,6 +2360,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.beyondcorp.clientconnectorservices_v1.ClientConnectorServicesServiceClient.DeleteOperation", + extra={ + "serviceName": "google.cloud.beyondcorp.clientconnectorservices.v1.ClientConnectorServicesService", + "rpcName": "DeleteOperation", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ClientConnectorServicesServiceRestTransport._DeleteOperation._get_response( self._host, @@ -1837,7 +2443,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Call the get operation method over HTTP. @@ -1847,8 +2453,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be 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. @@ -1857,6 +2465,7 @@ def __call__( http_options = ( _BaseClientConnectorServicesServiceRestTransport._BaseGetOperation._get_http_options() ) + request, metadata = self._interceptor.pre_get_operation(request, metadata) transcoded_request = _BaseClientConnectorServicesServiceRestTransport._BaseGetOperation._get_transcoded_request( http_options, request @@ -1867,6 +2476,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.beyondcorp.clientconnectorservices_v1.ClientConnectorServicesServiceClient.GetOperation", + extra={ + "serviceName": "google.cloud.beyondcorp.clientconnectorservices.v1.ClientConnectorServicesService", + "rpcName": "GetOperation", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ( ClientConnectorServicesServiceRestTransport._GetOperation._get_response( @@ -1888,6 +2524,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.beyondcorp.clientconnectorservices_v1.ClientConnectorServicesServiceAsyncClient.GetOperation", + extra={ + "serviceName": "google.cloud.beyondcorp.clientconnectorservices.v1.ClientConnectorServicesService", + "rpcName": "GetOperation", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property @@ -1929,7 +2586,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.ListOperationsResponse: r"""Call the list operations method over HTTP. @@ -1939,8 +2596,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of 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. @@ -1949,6 +2608,7 @@ def __call__( http_options = ( _BaseClientConnectorServicesServiceRestTransport._BaseListOperations._get_http_options() ) + request, metadata = self._interceptor.pre_list_operations(request, metadata) transcoded_request = _BaseClientConnectorServicesServiceRestTransport._BaseListOperations._get_transcoded_request( http_options, request @@ -1959,6 +2619,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.beyondcorp.clientconnectorservices_v1.ClientConnectorServicesServiceClient.ListOperations", + extra={ + "serviceName": "google.cloud.beyondcorp.clientconnectorservices.v1.ClientConnectorServicesService", + "rpcName": "ListOperations", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ClientConnectorServicesServiceRestTransport._ListOperations._get_response( self._host, @@ -1978,6 +2665,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.beyondcorp.clientconnectorservices_v1.ClientConnectorServicesServiceAsyncClient.ListOperations", + extra={ + "serviceName": "google.cloud.beyondcorp.clientconnectorservices.v1.ClientConnectorServicesService", + "rpcName": "ListOperations", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property diff --git a/packages/google-cloud-beyondcorp-clientconnectorservices/samples/generated_samples/snippet_metadata_google.cloud.beyondcorp.clientconnectorservices.v1.json b/packages/google-cloud-beyondcorp-clientconnectorservices/samples/generated_samples/snippet_metadata_google.cloud.beyondcorp.clientconnectorservices.v1.json index eaf0d4846226..e2e2d8f829d9 100644 --- a/packages/google-cloud-beyondcorp-clientconnectorservices/samples/generated_samples/snippet_metadata_google.cloud.beyondcorp.clientconnectorservices.v1.json +++ b/packages/google-cloud-beyondcorp-clientconnectorservices/samples/generated_samples/snippet_metadata_google.cloud.beyondcorp.clientconnectorservices.v1.json @@ -8,7 +8,7 @@ ], "language": "PYTHON", "name": "google-cloud-beyondcorp-clientconnectorservices", - "version": "0.4.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.beyondcorp_clientconnectorservices_v1.types.ClientConnectorService", @@ -465,7 +465,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.beyondcorp_clientconnectorservices_v1.types.ClientConnectorService", @@ -546,7 +546,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.beyondcorp_clientconnectorservices_v1.services.client_connector_services_service.pagers.ListClientConnectorServicesAsyncPager", @@ -626,7 +626,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.beyondcorp_clientconnectorservices_v1.services.client_connector_services_service.pagers.ListClientConnectorServicesPager", @@ -711,7 +711,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -795,7 +795,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", diff --git a/packages/google-cloud-beyondcorp-clientconnectorservices/tests/unit/gapic/beyondcorp_clientconnectorservices_v1/test_client_connector_services_service.py b/packages/google-cloud-beyondcorp-clientconnectorservices/tests/unit/gapic/beyondcorp_clientconnectorservices_v1/test_client_connector_services_service.py index dbef79a4e165..648e3254fba7 100644 --- a/packages/google-cloud-beyondcorp-clientconnectorservices/tests/unit/gapic/beyondcorp_clientconnectorservices_v1/test_client_connector_services_service.py +++ b/packages/google-cloud-beyondcorp-clientconnectorservices/tests/unit/gapic/beyondcorp_clientconnectorservices_v1/test_client_connector_services_service.py @@ -3343,6 +3343,7 @@ def test_list_client_connector_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_client_connector_services(request) @@ -3406,6 +3407,7 @@ def test_list_client_connector_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_client_connector_services(**mock_args) @@ -3615,6 +3617,7 @@ def test_get_client_connector_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_client_connector_service(request) @@ -3664,6 +3667,7 @@ def test_get_client_connector_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_client_connector_service(**mock_args) @@ -3810,6 +3814,7 @@ def test_create_client_connector_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_client_connector_service(request) @@ -3873,6 +3878,7 @@ def test_create_client_connector_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_client_connector_service(**mock_args) @@ -4019,6 +4025,7 @@ def test_update_client_connector_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_client_connector_service(request) @@ -4086,6 +4093,7 @@ def test_update_client_connector_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_client_connector_service(**mock_args) @@ -4233,6 +4241,7 @@ def test_delete_client_connector_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_client_connector_service(request) @@ -4288,6 +4297,7 @@ def test_delete_client_connector_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_client_connector_service(**mock_args) @@ -4744,6 +4754,7 @@ def test_list_client_connector_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_client_connector_services(request) @@ -4786,6 +4797,7 @@ def test_list_client_connector_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_client_connector_services(request) # Establish that the response is the type that we expect. @@ -4831,6 +4843,7 @@ def test_list_client_connector_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 = client_connector_services_service.ListClientConnectorServicesResponse.to_json( client_connector_services_service.ListClientConnectorServicesResponse() ) @@ -4881,6 +4894,7 @@ def test_get_client_connector_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_client_connector_service(request) @@ -4922,6 +4936,7 @@ def test_get_client_connector_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_client_connector_service(request) # Establish that the response is the type that we expect. @@ -4973,6 +4988,7 @@ def test_get_client_connector_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 = client_connector_services_service.ClientConnectorService.to_json( client_connector_services_service.ClientConnectorService() ) @@ -5019,6 +5035,7 @@ def test_create_client_connector_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_client_connector_service(request) @@ -5136,6 +5153,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.create_client_connector_service(request) # Establish that the response is the type that we expect. @@ -5181,6 +5199,7 @@ def test_create_client_connector_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 @@ -5231,6 +5250,7 @@ def test_update_client_connector_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_client_connector_service(request) @@ -5352,6 +5372,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.update_client_connector_service(request) # Establish that the response is the type that we expect. @@ -5397,6 +5418,7 @@ def test_update_client_connector_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 @@ -5445,6 +5467,7 @@ def test_delete_client_connector_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_client_connector_service(request) @@ -5477,6 +5500,7 @@ def test_delete_client_connector_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_client_connector_service(request) # Establish that the response is the type that we expect. @@ -5522,6 +5546,7 @@ def test_delete_client_connector_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 @@ -5568,6 +5593,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) @@ -5598,6 +5624,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) @@ -5626,6 +5653,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) @@ -5656,6 +5684,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) @@ -5687,6 +5716,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) @@ -5719,6 +5749,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) @@ -5750,6 +5781,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) @@ -5782,6 +5814,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) @@ -5813,6 +5846,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) @@ -5845,6 +5879,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) @@ -5875,6 +5910,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) @@ -5905,6 +5941,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) @@ -5935,6 +5972,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) @@ -5965,6 +6003,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) @@ -5995,6 +6034,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) @@ -6025,6 +6065,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) @@ -6055,6 +6096,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) @@ -6085,6 +6127,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-beyondcorp-clientgateways/google/cloud/beyondcorp_clientgateways/gapic_version.py b/packages/google-cloud-beyondcorp-clientgateways/google/cloud/beyondcorp_clientgateways/gapic_version.py index db2ef16a95a4..558c8aab67c5 100644 --- a/packages/google-cloud-beyondcorp-clientgateways/google/cloud/beyondcorp_clientgateways/gapic_version.py +++ b/packages/google-cloud-beyondcorp-clientgateways/google/cloud/beyondcorp_clientgateways/gapic_version.py @@ -13,4 +13,4 @@ # See the License for the specific language governing permissions and # limitations under the License. # -__version__ = "0.4.12" # {x-release-please-version} +__version__ = "0.0.0" # {x-release-please-version} diff --git a/packages/google-cloud-beyondcorp-clientgateways/google/cloud/beyondcorp_clientgateways_v1/gapic_version.py b/packages/google-cloud-beyondcorp-clientgateways/google/cloud/beyondcorp_clientgateways_v1/gapic_version.py index db2ef16a95a4..558c8aab67c5 100644 --- a/packages/google-cloud-beyondcorp-clientgateways/google/cloud/beyondcorp_clientgateways_v1/gapic_version.py +++ b/packages/google-cloud-beyondcorp-clientgateways/google/cloud/beyondcorp_clientgateways_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.12" # {x-release-please-version} +__version__ = "0.0.0" # {x-release-please-version} diff --git a/packages/google-cloud-beyondcorp-clientgateways/google/cloud/beyondcorp_clientgateways_v1/services/client_gateways_service/async_client.py b/packages/google-cloud-beyondcorp-clientgateways/google/cloud/beyondcorp_clientgateways_v1/services/client_gateways_service/async_client.py index 19f33359750d..aea553eee6d2 100644 --- a/packages/google-cloud-beyondcorp-clientgateways/google/cloud/beyondcorp_clientgateways_v1/services/client_gateways_service/async_client.py +++ b/packages/google-cloud-beyondcorp-clientgateways/google/cloud/beyondcorp_clientgateways_v1/services/client_gateways_service/async_client.py @@ -14,6 +14,7 @@ # limitations under the License. # from collections import OrderedDict +import logging as std_logging import re from typing import ( Callable, @@ -60,6 +61,15 @@ from .transports.base import DEFAULT_CLIENT_INFO, ClientGatewaysServiceTransport from .transports.grpc_asyncio import ClientGatewaysServiceGrpcAsyncIOTransport +try: + from google.api_core import client_logging # type: ignore + + CLIENT_LOGGING_SUPPORTED = True # pragma: NO COVER +except ImportError: # pragma: NO COVER + CLIENT_LOGGING_SUPPORTED = False + +_LOGGER = std_logging.getLogger(__name__) + class ClientGatewaysServiceAsyncClient: """API Overview: @@ -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.beyondcorp.clientgateways_v1.ClientGatewaysServiceAsyncClient`.", + extra={ + "serviceName": "google.cloud.beyondcorp.clientgateways.v1.ClientGatewaysService", + "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.beyondcorp.clientgateways.v1.ClientGatewaysService", + "credentialsType": None, + }, + ) + async def list_client_gateways( self, request: Optional[ @@ -293,7 +325,7 @@ async def list_client_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.ListClientGatewaysAsyncPager: r"""Lists ClientGateways in a given project and location. @@ -338,8 +370,10 @@ async def sample_list_client_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.beyondcorp_clientgateways_v1.services.client_gateways_service.pagers.ListClientGatewaysAsyncPager: @@ -416,7 +450,7 @@ async def get_client_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]]] = (), ) -> client_gateways_service.ClientGateway: r"""Gets details of a single ClientGateway. @@ -457,8 +491,10 @@ async def sample_get_client_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.beyondcorp_clientgateways_v1.types.ClientGateway: @@ -523,7 +559,7 @@ async def create_client_gateway( client_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 ClientGateway in a given project and location. @@ -589,8 +625,10 @@ async def sample_create_client_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: @@ -668,7 +706,7 @@ async def delete_client_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 ClientGateway. @@ -713,8 +751,10 @@ async def sample_delete_client_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: @@ -792,7 +832,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. @@ -803,8 +843,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. @@ -845,7 +887,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. @@ -856,8 +898,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. @@ -898,7 +942,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. @@ -914,8 +958,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 """ @@ -952,7 +998,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. @@ -967,8 +1013,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 """ @@ -1005,7 +1053,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. @@ -1018,8 +1066,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. @@ -1124,7 +1174,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. @@ -1138,8 +1188,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. @@ -1244,7 +1296,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. @@ -1259,8 +1311,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. @@ -1304,7 +1358,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. @@ -1315,8 +1369,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. @@ -1357,7 +1413,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. @@ -1368,8 +1424,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-beyondcorp-clientgateways/google/cloud/beyondcorp_clientgateways_v1/services/client_gateways_service/client.py b/packages/google-cloud-beyondcorp-clientgateways/google/cloud/beyondcorp_clientgateways_v1/services/client_gateways_service/client.py index 32db262535ce..77f599cd2635 100644 --- a/packages/google-cloud-beyondcorp-clientgateways/google/cloud/beyondcorp_clientgateways_v1/services/client_gateways_service/client.py +++ b/packages/google-cloud-beyondcorp-clientgateways/google/cloud/beyondcorp_clientgateways_v1/services/client_gateways_service/client.py @@ -14,6 +14,7 @@ # limitations under the License. # from collections import OrderedDict +import logging as std_logging import os import re from typing import ( @@ -48,6 +49,15 @@ except AttributeError: # pragma: NO COVER OptionalRetry = Union[retries.Retry, object, None] # type: ignore +try: + from google.api_core import client_logging # type: ignore + + CLIENT_LOGGING_SUPPORTED = True # pragma: NO COVER +except ImportError: # pragma: NO COVER + CLIENT_LOGGING_SUPPORTED = False + +_LOGGER = std_logging.getLogger(__name__) + from google.api_core import operation # type: ignore from google.api_core import operation_async # type: ignore from google.cloud.location import locations_pb2 # type: ignore @@ -606,6 +616,10 @@ def __init__( # Initialize the universe domain validation. self._is_universe_domain_valid = False + if CLIENT_LOGGING_SUPPORTED: # pragma: NO COVER + # Setup logging. + client_logging.initialize_logging() + api_key_value = getattr(self._client_options, "api_key", None) if api_key_value and credentials: raise ValueError( @@ -672,6 +686,29 @@ def __init__( api_audience=self._client_options.api_audience, ) + if "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.beyondcorp.clientgateways_v1.ClientGatewaysServiceClient`.", + extra={ + "serviceName": "google.cloud.beyondcorp.clientgateways.v1.ClientGatewaysService", + "universeDomain": getattr( + self._transport._credentials, "universe_domain", "" + ), + "credentialsType": f"{type(self._transport._credentials).__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.beyondcorp.clientgateways.v1.ClientGatewaysService", + "credentialsType": None, + }, + ) + def list_client_gateways( self, request: Optional[ @@ -681,7 +718,7 @@ def list_client_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.ListClientGatewaysPager: r"""Lists ClientGateways in a given project and location. @@ -726,8 +763,10 @@ def sample_list_client_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.beyondcorp_clientgateways_v1.services.client_gateways_service.pagers.ListClientGatewaysPager: @@ -801,7 +840,7 @@ def get_client_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]]] = (), ) -> client_gateways_service.ClientGateway: r"""Gets details of a single ClientGateway. @@ -842,8 +881,10 @@ def sample_get_client_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.beyondcorp_clientgateways_v1.types.ClientGateway: @@ -905,7 +946,7 @@ def create_client_gateway( client_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 ClientGateway in a given project and location. @@ -971,8 +1012,10 @@ def sample_create_client_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: @@ -1047,7 +1090,7 @@ def delete_client_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 ClientGateway. @@ -1092,8 +1135,10 @@ def sample_delete_client_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: @@ -1181,7 +1226,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. @@ -1192,8 +1237,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. @@ -1234,7 +1281,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. @@ -1245,8 +1292,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. @@ -1287,7 +1336,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. @@ -1303,8 +1352,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 """ @@ -1341,7 +1392,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. @@ -1356,8 +1407,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 """ @@ -1394,7 +1447,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. @@ -1407,8 +1460,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. @@ -1513,7 +1568,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. @@ -1527,8 +1582,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. @@ -1633,7 +1690,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. @@ -1648,8 +1705,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. @@ -1691,7 +1750,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. @@ -1702,8 +1761,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. @@ -1744,7 +1805,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. @@ -1755,8 +1816,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-beyondcorp-clientgateways/google/cloud/beyondcorp_clientgateways_v1/services/client_gateways_service/pagers.py b/packages/google-cloud-beyondcorp-clientgateways/google/cloud/beyondcorp_clientgateways_v1/services/client_gateways_service/pagers.py index f4579281bd0e..439bd5014e9d 100644 --- a/packages/google-cloud-beyondcorp-clientgateways/google/cloud/beyondcorp_clientgateways_v1/services/client_gateways_service/pagers.py +++ b/packages/google-cloud-beyondcorp-clientgateways/google/cloud/beyondcorp_clientgateways_v1/services/client_gateways_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 = client_gateways_service.ListClientGatewaysRequest(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 = client_gateways_service.ListClientGatewaysRequest(request) diff --git a/packages/google-cloud-beyondcorp-clientgateways/google/cloud/beyondcorp_clientgateways_v1/services/client_gateways_service/transports/grpc.py b/packages/google-cloud-beyondcorp-clientgateways/google/cloud/beyondcorp_clientgateways_v1/services/client_gateways_service/transports/grpc.py index 4de26e1595e7..9cebb29bc835 100644 --- a/packages/google-cloud-beyondcorp-clientgateways/google/cloud/beyondcorp_clientgateways_v1/services/client_gateways_service/transports/grpc.py +++ b/packages/google-cloud-beyondcorp-clientgateways/google/cloud/beyondcorp_clientgateways_v1/services/client_gateways_service/transports/grpc.py @@ -13,6 +13,9 @@ # See the License for the specific language governing permissions and # limitations under the License. # +import json +import logging as std_logging +import pickle from typing import Callable, Dict, Optional, Sequence, Tuple, Union import warnings @@ -24,12 +27,90 @@ from google.iam.v1 import iam_policy_pb2 # type: ignore from google.iam.v1 import policy_pb2 # type: ignore from google.longrunning import operations_pb2 # type: ignore +from google.protobuf.json_format import MessageToJson +import google.protobuf.message import grpc # type: ignore +import proto # type: ignore from google.cloud.beyondcorp_clientgateways_v1.types import client_gateways_service from .base import DEFAULT_CLIENT_INFO, ClientGatewaysServiceTransport +try: + from google.api_core import client_logging # 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.beyondcorp.clientgateways.v1.ClientGatewaysService", + "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.beyondcorp.clientgateways.v1.ClientGatewaysService", + "rpcName": client_call_details.method, + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class ClientGatewaysServiceGrpcTransport(ClientGatewaysServiceTransport): """gRPC backend transport for ClientGatewaysService. @@ -194,7 +275,12 @@ def __init__( ], ) - # Wrap messages. This must be done after self._grpc_channel exists + self._interceptor = _LoggingClientInterceptor() + self._logged_channel = grpc.intercept_channel( + self._grpc_channel, self._interceptor + ) + + # Wrap messages. This must be done after self._logged_channel exists self._prep_wrapped_messages(client_info) @classmethod @@ -258,7 +344,9 @@ def operations_client(self) -> operations_v1.OperationsClient: """ # Quick check: Only create a new client if we do not already have one. if self._operations_client is None: - self._operations_client = operations_v1.OperationsClient(self.grpc_channel) + self._operations_client = operations_v1.OperationsClient( + self._logged_channel + ) # Return the client from cache. return self._operations_client @@ -285,7 +373,7 @@ def list_client_gateways( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_client_gateways" not in self._stubs: - self._stubs["list_client_gateways"] = self.grpc_channel.unary_unary( + self._stubs["list_client_gateways"] = self._logged_channel.unary_unary( "/google.cloud.beyondcorp.clientgateways.v1.ClientGatewaysService/ListClientGateways", request_serializer=client_gateways_service.ListClientGatewaysRequest.serialize, response_deserializer=client_gateways_service.ListClientGatewaysResponse.deserialize, @@ -314,7 +402,7 @@ def get_client_gateway( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_client_gateway" not in self._stubs: - self._stubs["get_client_gateway"] = self.grpc_channel.unary_unary( + self._stubs["get_client_gateway"] = self._logged_channel.unary_unary( "/google.cloud.beyondcorp.clientgateways.v1.ClientGatewaysService/GetClientGateway", request_serializer=client_gateways_service.GetClientGatewayRequest.serialize, response_deserializer=client_gateways_service.ClientGateway.deserialize, @@ -343,7 +431,7 @@ def create_client_gateway( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_client_gateway" not in self._stubs: - self._stubs["create_client_gateway"] = self.grpc_channel.unary_unary( + self._stubs["create_client_gateway"] = self._logged_channel.unary_unary( "/google.cloud.beyondcorp.clientgateways.v1.ClientGatewaysService/CreateClientGateway", request_serializer=client_gateways_service.CreateClientGatewayRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -371,7 +459,7 @@ def delete_client_gateway( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_client_gateway" not in self._stubs: - self._stubs["delete_client_gateway"] = self.grpc_channel.unary_unary( + self._stubs["delete_client_gateway"] = self._logged_channel.unary_unary( "/google.cloud.beyondcorp.clientgateways.v1.ClientGatewaysService/DeleteClientGateway", request_serializer=client_gateways_service.DeleteClientGatewayRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -379,7 +467,7 @@ def delete_client_gateway( return self._stubs["delete_client_gateway"] def close(self): - self.grpc_channel.close() + self._logged_channel.close() @property def delete_operation( @@ -391,7 +479,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, @@ -408,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, @@ -425,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, @@ -444,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, @@ -463,7 +551,7 @@ def list_locations( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_locations" not in self._stubs: - self._stubs["list_locations"] = self.grpc_channel.unary_unary( + self._stubs["list_locations"] = self._logged_channel.unary_unary( "/google.cloud.location.Locations/ListLocations", request_serializer=locations_pb2.ListLocationsRequest.SerializeToString, response_deserializer=locations_pb2.ListLocationsResponse.FromString, @@ -480,7 +568,7 @@ def get_location( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_location" not in self._stubs: - self._stubs["get_location"] = self.grpc_channel.unary_unary( + self._stubs["get_location"] = self._logged_channel.unary_unary( "/google.cloud.location.Locations/GetLocation", request_serializer=locations_pb2.GetLocationRequest.SerializeToString, response_deserializer=locations_pb2.Location.FromString, @@ -505,7 +593,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, @@ -531,7 +619,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, @@ -560,7 +648,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-beyondcorp-clientgateways/google/cloud/beyondcorp_clientgateways_v1/services/client_gateways_service/transports/grpc_asyncio.py b/packages/google-cloud-beyondcorp-clientgateways/google/cloud/beyondcorp_clientgateways_v1/services/client_gateways_service/transports/grpc_asyncio.py index 683996d5c3f8..54186495d9c8 100644 --- a/packages/google-cloud-beyondcorp-clientgateways/google/cloud/beyondcorp_clientgateways_v1/services/client_gateways_service/transports/grpc_asyncio.py +++ b/packages/google-cloud-beyondcorp-clientgateways/google/cloud/beyondcorp_clientgateways_v1/services/client_gateways_service/transports/grpc_asyncio.py @@ -14,6 +14,9 @@ # limitations under the License. # import inspect +import json +import logging as std_logging +import pickle from typing import Awaitable, Callable, Dict, Optional, Sequence, Tuple, Union import warnings @@ -26,14 +29,93 @@ from google.iam.v1 import iam_policy_pb2 # type: ignore from google.iam.v1 import policy_pb2 # type: ignore from google.longrunning import operations_pb2 # type: ignore +from google.protobuf.json_format import MessageToJson +import google.protobuf.message import grpc # type: ignore from grpc.experimental import aio # type: ignore +import proto # type: ignore from google.cloud.beyondcorp_clientgateways_v1.types import client_gateways_service from .base import DEFAULT_CLIENT_INFO, ClientGatewaysServiceTransport from .grpc import ClientGatewaysServiceGrpcTransport +try: + from google.api_core import client_logging # 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.beyondcorp.clientgateways.v1.ClientGatewaysService", + "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.beyondcorp.clientgateways.v1.ClientGatewaysService", + "rpcName": str(client_call_details.method), + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class ClientGatewaysServiceGrpcAsyncIOTransport(ClientGatewaysServiceTransport): """gRPC AsyncIO backend transport for ClientGatewaysService. @@ -241,10 +323,13 @@ def __init__( ], ) - # Wrap messages. This must be done after self._grpc_channel exists + self._interceptor = _LoggingClientAIOInterceptor() + self._grpc_channel._unary_unary_interceptors.append(self._interceptor) + self._logged_channel = self._grpc_channel self._wrap_with_kind = ( "kind" in inspect.signature(gapic_v1.method_async.wrap_method).parameters ) + # Wrap messages. This must be done after self._logged_channel exists self._prep_wrapped_messages(client_info) @property @@ -267,7 +352,7 @@ def operations_client(self) -> operations_v1.OperationsAsyncClient: # Quick check: Only create a new client if we do not already have one. if self._operations_client is None: self._operations_client = operations_v1.OperationsAsyncClient( - self.grpc_channel + self._logged_channel ) # Return the client from cache. @@ -295,7 +380,7 @@ def list_client_gateways( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_client_gateways" not in self._stubs: - self._stubs["list_client_gateways"] = self.grpc_channel.unary_unary( + self._stubs["list_client_gateways"] = self._logged_channel.unary_unary( "/google.cloud.beyondcorp.clientgateways.v1.ClientGatewaysService/ListClientGateways", request_serializer=client_gateways_service.ListClientGatewaysRequest.serialize, response_deserializer=client_gateways_service.ListClientGatewaysResponse.deserialize, @@ -324,7 +409,7 @@ def get_client_gateway( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_client_gateway" not in self._stubs: - self._stubs["get_client_gateway"] = self.grpc_channel.unary_unary( + self._stubs["get_client_gateway"] = self._logged_channel.unary_unary( "/google.cloud.beyondcorp.clientgateways.v1.ClientGatewaysService/GetClientGateway", request_serializer=client_gateways_service.GetClientGatewayRequest.serialize, response_deserializer=client_gateways_service.ClientGateway.deserialize, @@ -354,7 +439,7 @@ def create_client_gateway( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_client_gateway" not in self._stubs: - self._stubs["create_client_gateway"] = self.grpc_channel.unary_unary( + self._stubs["create_client_gateway"] = self._logged_channel.unary_unary( "/google.cloud.beyondcorp.clientgateways.v1.ClientGatewaysService/CreateClientGateway", request_serializer=client_gateways_service.CreateClientGatewayRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -383,7 +468,7 @@ def delete_client_gateway( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_client_gateway" not in self._stubs: - self._stubs["delete_client_gateway"] = self.grpc_channel.unary_unary( + self._stubs["delete_client_gateway"] = self._logged_channel.unary_unary( "/google.cloud.beyondcorp.clientgateways.v1.ClientGatewaysService/DeleteClientGateway", request_serializer=client_gateways_service.DeleteClientGatewayRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -466,7 +551,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: @@ -482,7 +567,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, @@ -499,7 +584,7 @@ def cancel_operation( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "cancel_operation" not in self._stubs: - self._stubs["cancel_operation"] = self.grpc_channel.unary_unary( + self._stubs["cancel_operation"] = self._logged_channel.unary_unary( "/google.longrunning.Operations/CancelOperation", request_serializer=operations_pb2.CancelOperationRequest.SerializeToString, response_deserializer=None, @@ -516,7 +601,7 @@ def get_operation( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_operation" not in self._stubs: - self._stubs["get_operation"] = self.grpc_channel.unary_unary( + self._stubs["get_operation"] = self._logged_channel.unary_unary( "/google.longrunning.Operations/GetOperation", request_serializer=operations_pb2.GetOperationRequest.SerializeToString, response_deserializer=operations_pb2.Operation.FromString, @@ -535,7 +620,7 @@ def list_operations( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_operations" not in self._stubs: - self._stubs["list_operations"] = self.grpc_channel.unary_unary( + self._stubs["list_operations"] = self._logged_channel.unary_unary( "/google.longrunning.Operations/ListOperations", request_serializer=operations_pb2.ListOperationsRequest.SerializeToString, response_deserializer=operations_pb2.ListOperationsResponse.FromString, @@ -554,7 +639,7 @@ def list_locations( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_locations" not in self._stubs: - self._stubs["list_locations"] = self.grpc_channel.unary_unary( + self._stubs["list_locations"] = self._logged_channel.unary_unary( "/google.cloud.location.Locations/ListLocations", request_serializer=locations_pb2.ListLocationsRequest.SerializeToString, response_deserializer=locations_pb2.ListLocationsResponse.FromString, @@ -571,7 +656,7 @@ def get_location( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_location" not in self._stubs: - self._stubs["get_location"] = self.grpc_channel.unary_unary( + self._stubs["get_location"] = self._logged_channel.unary_unary( "/google.cloud.location.Locations/GetLocation", request_serializer=locations_pb2.GetLocationRequest.SerializeToString, response_deserializer=locations_pb2.Location.FromString, @@ -596,7 +681,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, @@ -622,7 +707,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, @@ -651,7 +736,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-beyondcorp-clientgateways/google/cloud/beyondcorp_clientgateways_v1/services/client_gateways_service/transports/rest.py b/packages/google-cloud-beyondcorp-clientgateways/google/cloud/beyondcorp_clientgateways_v1/services/client_gateways_service/transports/rest.py index edf3c9e649f1..c343432dc4f9 100644 --- a/packages/google-cloud-beyondcorp-clientgateways/google/cloud/beyondcorp_clientgateways_v1/services/client_gateways_service/transports/rest.py +++ b/packages/google-cloud-beyondcorp-clientgateways/google/cloud/beyondcorp_clientgateways_v1/services/client_gateways_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, @@ -105,9 +113,10 @@ def post_list_client_gateways(self, response): def pre_create_client_gateway( self, request: client_gateways_service.CreateClientGatewayRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ - client_gateways_service.CreateClientGatewayRequest, Sequence[Tuple[str, str]] + client_gateways_service.CreateClientGatewayRequest, + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for create_client_gateway @@ -130,9 +139,10 @@ def post_create_client_gateway( def pre_delete_client_gateway( self, request: client_gateways_service.DeleteClientGatewayRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ - client_gateways_service.DeleteClientGatewayRequest, Sequence[Tuple[str, str]] + client_gateways_service.DeleteClientGatewayRequest, + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for delete_client_gateway @@ -155,9 +165,10 @@ def post_delete_client_gateway( def pre_get_client_gateway( self, request: client_gateways_service.GetClientGatewayRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ - client_gateways_service.GetClientGatewayRequest, Sequence[Tuple[str, str]] + client_gateways_service.GetClientGatewayRequest, + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for get_client_gateway @@ -180,9 +191,10 @@ def post_get_client_gateway( def pre_list_client_gateways( self, request: client_gateways_service.ListClientGatewaysRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ - client_gateways_service.ListClientGatewaysRequest, Sequence[Tuple[str, str]] + client_gateways_service.ListClientGatewaysRequest, + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for list_client_gateways @@ -205,8 +217,10 @@ def post_list_client_gateways( 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 @@ -228,8 +242,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 @@ -251,8 +267,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 @@ -272,8 +290,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 @@ -293,8 +313,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 @@ -316,8 +339,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 @@ -337,8 +362,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 @@ -358,8 +385,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 @@ -381,8 +410,10 @@ def post_get_operation( def pre_list_operations( self, request: operations_pb2.ListOperationsRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[operations_pb2.ListOperationsRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + operations_pb2.ListOperationsRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for list_operations Override in a subclass to manipulate the request or metadata @@ -588,7 +619,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Call the create client gateway method over HTTP. @@ -598,8 +629,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.operations_pb2.Operation: @@ -612,6 +645,7 @@ def __call__( http_options = ( _BaseClientGatewaysServiceRestTransport._BaseCreateClientGateway._get_http_options() ) + request, metadata = self._interceptor.pre_create_client_gateway( request, metadata ) @@ -628,6 +662,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.beyondcorp.clientgateways_v1.ClientGatewaysServiceClient.CreateClientGateway", + extra={ + "serviceName": "google.cloud.beyondcorp.clientgateways.v1.ClientGatewaysService", + "rpcName": "CreateClientGateway", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ( ClientGatewaysServiceRestTransport._CreateClientGateway._get_response( @@ -649,7 +710,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_client_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.beyondcorp.clientgateways_v1.ClientGatewaysServiceClient.create_client_gateway", + extra={ + "serviceName": "google.cloud.beyondcorp.clientgateways.v1.ClientGatewaysService", + "rpcName": "CreateClientGateway", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _DeleteClientGateway( @@ -687,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]]] = (), ) -> operations_pb2.Operation: r"""Call the delete client gateway method over HTTP. @@ -697,8 +780,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.operations_pb2.Operation: @@ -711,6 +796,7 @@ def __call__( http_options = ( _BaseClientGatewaysServiceRestTransport._BaseDeleteClientGateway._get_http_options() ) + request, metadata = self._interceptor.pre_delete_client_gateway( request, metadata ) @@ -723,6 +809,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.beyondcorp.clientgateways_v1.ClientGatewaysServiceClient.DeleteClientGateway", + extra={ + "serviceName": "google.cloud.beyondcorp.clientgateways.v1.ClientGatewaysService", + "rpcName": "DeleteClientGateway", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ( ClientGatewaysServiceRestTransport._DeleteClientGateway._get_response( @@ -743,7 +856,29 @@ def __call__( # Return the response resp = operations_pb2.Operation() json_format.Parse(response.content, resp, ignore_unknown_fields=True) + resp = self._interceptor.post_delete_client_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.beyondcorp.clientgateways_v1.ClientGatewaysServiceClient.delete_client_gateway", + extra={ + "serviceName": "google.cloud.beyondcorp.clientgateways.v1.ClientGatewaysService", + "rpcName": "DeleteClientGateway", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _GetClientGateway( @@ -781,7 +916,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> client_gateways_service.ClientGateway: r"""Call the get client gateway method over HTTP. @@ -791,8 +926,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.client_gateways_service.ClientGateway: @@ -804,6 +941,7 @@ def __call__( http_options = ( _BaseClientGatewaysServiceRestTransport._BaseGetClientGateway._get_http_options() ) + request, metadata = self._interceptor.pre_get_client_gateway( request, metadata ) @@ -816,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.cloud.beyondcorp.clientgateways_v1.ClientGatewaysServiceClient.GetClientGateway", + extra={ + "serviceName": "google.cloud.beyondcorp.clientgateways.v1.ClientGatewaysService", + "rpcName": "GetClientGateway", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ( ClientGatewaysServiceRestTransport._GetClientGateway._get_response( @@ -838,7 +1003,31 @@ def __call__( pb_resp = client_gateways_service.ClientGateway.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_client_gateway(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = client_gateways_service.ClientGateway.to_json( + response + ) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.beyondcorp.clientgateways_v1.ClientGatewaysServiceClient.get_client_gateway", + extra={ + "serviceName": "google.cloud.beyondcorp.clientgateways.v1.ClientGatewaysService", + "rpcName": "GetClientGateway", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ListClientGateways( @@ -876,7 +1065,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> client_gateways_service.ListClientGatewaysResponse: r"""Call the list client gateways method over HTTP. @@ -887,8 +1076,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.client_gateways_service.ListClientGatewaysResponse: @@ -900,6 +1091,7 @@ def __call__( http_options = ( _BaseClientGatewaysServiceRestTransport._BaseListClientGateways._get_http_options() ) + request, metadata = self._interceptor.pre_list_client_gateways( request, metadata ) @@ -912,6 +1104,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.beyondcorp.clientgateways_v1.ClientGatewaysServiceClient.ListClientGateways", + extra={ + "serviceName": "google.cloud.beyondcorp.clientgateways.v1.ClientGatewaysService", + "rpcName": "ListClientGateways", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ( ClientGatewaysServiceRestTransport._ListClientGateways._get_response( @@ -934,7 +1153,33 @@ def __call__( pb_resp = client_gateways_service.ListClientGatewaysResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_client_gateways(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = ( + client_gateways_service.ListClientGatewaysResponse.to_json( + response + ) + ) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.beyondcorp.clientgateways_v1.ClientGatewaysServiceClient.list_client_gateways", + extra={ + "serviceName": "google.cloud.beyondcorp.clientgateways.v1.ClientGatewaysService", + "rpcName": "ListClientGateways", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp @property @@ -1018,7 +1263,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> locations_pb2.Location: r"""Call the get location method over HTTP. @@ -1028,8 +1273,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each 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. @@ -1038,6 +1285,7 @@ def __call__( http_options = ( _BaseClientGatewaysServiceRestTransport._BaseGetLocation._get_http_options() ) + request, metadata = self._interceptor.pre_get_location(request, metadata) transcoded_request = _BaseClientGatewaysServiceRestTransport._BaseGetLocation._get_transcoded_request( http_options, request @@ -1048,6 +1296,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.beyondcorp.clientgateways_v1.ClientGatewaysServiceClient.GetLocation", + extra={ + "serviceName": "google.cloud.beyondcorp.clientgateways.v1.ClientGatewaysService", + "rpcName": "GetLocation", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ClientGatewaysServiceRestTransport._GetLocation._get_response( self._host, @@ -1067,6 +1342,27 @@ def __call__( resp = locations_pb2.Location() resp = json_format.Parse(content, resp) resp = self._interceptor.post_get_location(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = json_format.MessageToJson(resp) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.beyondcorp.clientgateways_v1.ClientGatewaysServiceAsyncClient.GetLocation", + extra={ + "serviceName": "google.cloud.beyondcorp.clientgateways.v1.ClientGatewaysService", + "rpcName": "GetLocation", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property @@ -1108,7 +1404,7 @@ 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. @@ -1118,8 +1414,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: locations_pb2.ListLocationsResponse: Response from ListLocations method. @@ -1128,6 +1426,7 @@ def __call__( http_options = ( _BaseClientGatewaysServiceRestTransport._BaseListLocations._get_http_options() ) + request, metadata = self._interceptor.pre_list_locations(request, metadata) transcoded_request = _BaseClientGatewaysServiceRestTransport._BaseListLocations._get_transcoded_request( http_options, request @@ -1138,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 = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.beyondcorp.clientgateways_v1.ClientGatewaysServiceClient.ListLocations", + extra={ + "serviceName": "google.cloud.beyondcorp.clientgateways.v1.ClientGatewaysService", + "rpcName": "ListLocations", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ClientGatewaysServiceRestTransport._ListLocations._get_response( self._host, @@ -1157,6 +1483,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.beyondcorp.clientgateways_v1.ClientGatewaysServiceAsyncClient.ListLocations", + extra={ + "serviceName": "google.cloud.beyondcorp.clientgateways.v1.ClientGatewaysService", + "rpcName": "ListLocations", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property @@ -1198,7 +1545,7 @@ 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. @@ -1208,8 +1555,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each 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. @@ -1218,6 +1567,7 @@ def __call__( http_options = ( _BaseClientGatewaysServiceRestTransport._BaseGetIamPolicy._get_http_options() ) + request, metadata = self._interceptor.pre_get_iam_policy(request, metadata) transcoded_request = _BaseClientGatewaysServiceRestTransport._BaseGetIamPolicy._get_transcoded_request( http_options, request @@ -1228,6 +1578,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.beyondcorp.clientgateways_v1.ClientGatewaysServiceClient.GetIamPolicy", + extra={ + "serviceName": "google.cloud.beyondcorp.clientgateways.v1.ClientGatewaysService", + "rpcName": "GetIamPolicy", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ClientGatewaysServiceRestTransport._GetIamPolicy._get_response( self._host, @@ -1247,6 +1624,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.beyondcorp.clientgateways_v1.ClientGatewaysServiceAsyncClient.GetIamPolicy", + extra={ + "serviceName": "google.cloud.beyondcorp.clientgateways.v1.ClientGatewaysService", + "rpcName": "GetIamPolicy", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property @@ -1289,7 +1687,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> policy_pb2.Policy: r"""Call the set iam policy method over HTTP. @@ -1299,8 +1697,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each 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. @@ -1309,6 +1709,7 @@ def __call__( http_options = ( _BaseClientGatewaysServiceRestTransport._BaseSetIamPolicy._get_http_options() ) + request, metadata = self._interceptor.pre_set_iam_policy(request, metadata) transcoded_request = _BaseClientGatewaysServiceRestTransport._BaseSetIamPolicy._get_transcoded_request( http_options, request @@ -1323,6 +1724,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.beyondcorp.clientgateways_v1.ClientGatewaysServiceClient.SetIamPolicy", + extra={ + "serviceName": "google.cloud.beyondcorp.clientgateways.v1.ClientGatewaysService", + "rpcName": "SetIamPolicy", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ClientGatewaysServiceRestTransport._SetIamPolicy._get_response( self._host, @@ -1343,6 +1771,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.beyondcorp.clientgateways_v1.ClientGatewaysServiceAsyncClient.SetIamPolicy", + extra={ + "serviceName": "google.cloud.beyondcorp.clientgateways.v1.ClientGatewaysService", + "rpcName": "SetIamPolicy", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property @@ -1385,7 +1834,7 @@ 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. @@ -1395,8 +1844,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: iam_policy_pb2.TestIamPermissionsResponse: Response from TestIamPermissions method. @@ -1405,6 +1856,7 @@ def __call__( http_options = ( _BaseClientGatewaysServiceRestTransport._BaseTestIamPermissions._get_http_options() ) + request, metadata = self._interceptor.pre_test_iam_permissions( request, metadata ) @@ -1421,6 +1873,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.beyondcorp.clientgateways_v1.ClientGatewaysServiceClient.TestIamPermissions", + extra={ + "serviceName": "google.cloud.beyondcorp.clientgateways.v1.ClientGatewaysService", + "rpcName": "TestIamPermissions", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ( ClientGatewaysServiceRestTransport._TestIamPermissions._get_response( @@ -1443,6 +1922,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.beyondcorp.clientgateways_v1.ClientGatewaysServiceAsyncClient.TestIamPermissions", + extra={ + "serviceName": "google.cloud.beyondcorp.clientgateways.v1.ClientGatewaysService", + "rpcName": "TestIamPermissions", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property @@ -1485,7 +1985,7 @@ 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. @@ -1495,13 +1995,16 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. """ http_options = ( _BaseClientGatewaysServiceRestTransport._BaseCancelOperation._get_http_options() ) + request, metadata = self._interceptor.pre_cancel_operation( request, metadata ) @@ -1518,6 +2021,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.beyondcorp.clientgateways_v1.ClientGatewaysServiceClient.CancelOperation", + extra={ + "serviceName": "google.cloud.beyondcorp.clientgateways.v1.ClientGatewaysService", + "rpcName": "CancelOperation", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ( ClientGatewaysServiceRestTransport._CancelOperation._get_response( @@ -1577,7 +2107,7 @@ 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. @@ -1587,13 +2117,16 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. """ http_options = ( _BaseClientGatewaysServiceRestTransport._BaseDeleteOperation._get_http_options() ) + request, metadata = self._interceptor.pre_delete_operation( request, metadata ) @@ -1606,6 +2139,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.beyondcorp.clientgateways_v1.ClientGatewaysServiceClient.DeleteOperation", + extra={ + "serviceName": "google.cloud.beyondcorp.clientgateways.v1.ClientGatewaysService", + "rpcName": "DeleteOperation", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ( ClientGatewaysServiceRestTransport._DeleteOperation._get_response( @@ -1664,7 +2224,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Call the get operation method over HTTP. @@ -1674,8 +2234,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: operations_pb2.Operation: Response from GetOperation method. @@ -1684,6 +2246,7 @@ def __call__( http_options = ( _BaseClientGatewaysServiceRestTransport._BaseGetOperation._get_http_options() ) + request, metadata = self._interceptor.pre_get_operation(request, metadata) transcoded_request = _BaseClientGatewaysServiceRestTransport._BaseGetOperation._get_transcoded_request( http_options, request @@ -1694,6 +2257,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.beyondcorp.clientgateways_v1.ClientGatewaysServiceClient.GetOperation", + extra={ + "serviceName": "google.cloud.beyondcorp.clientgateways.v1.ClientGatewaysService", + "rpcName": "GetOperation", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ClientGatewaysServiceRestTransport._GetOperation._get_response( self._host, @@ -1713,6 +2303,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.beyondcorp.clientgateways_v1.ClientGatewaysServiceAsyncClient.GetOperation", + extra={ + "serviceName": "google.cloud.beyondcorp.clientgateways.v1.ClientGatewaysService", + "rpcName": "GetOperation", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property @@ -1754,7 +2365,7 @@ def __call__( *, 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. @@ -1764,8 +2375,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: operations_pb2.ListOperationsResponse: Response from ListOperations method. @@ -1774,6 +2387,7 @@ def __call__( http_options = ( _BaseClientGatewaysServiceRestTransport._BaseListOperations._get_http_options() ) + request, metadata = self._interceptor.pre_list_operations(request, metadata) transcoded_request = _BaseClientGatewaysServiceRestTransport._BaseListOperations._get_transcoded_request( http_options, request @@ -1784,6 +2398,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.beyondcorp.clientgateways_v1.ClientGatewaysServiceClient.ListOperations", + extra={ + "serviceName": "google.cloud.beyondcorp.clientgateways.v1.ClientGatewaysService", + "rpcName": "ListOperations", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ClientGatewaysServiceRestTransport._ListOperations._get_response( self._host, @@ -1803,6 +2444,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.beyondcorp.clientgateways_v1.ClientGatewaysServiceAsyncClient.ListOperations", + extra={ + "serviceName": "google.cloud.beyondcorp.clientgateways.v1.ClientGatewaysService", + "rpcName": "ListOperations", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property diff --git a/packages/google-cloud-beyondcorp-clientgateways/samples/generated_samples/snippet_metadata_google.cloud.beyondcorp.clientgateways.v1.json b/packages/google-cloud-beyondcorp-clientgateways/samples/generated_samples/snippet_metadata_google.cloud.beyondcorp.clientgateways.v1.json index 477a6153540f..1aa87eed26ed 100644 --- a/packages/google-cloud-beyondcorp-clientgateways/samples/generated_samples/snippet_metadata_google.cloud.beyondcorp.clientgateways.v1.json +++ b/packages/google-cloud-beyondcorp-clientgateways/samples/generated_samples/snippet_metadata_google.cloud.beyondcorp.clientgateways.v1.json @@ -8,7 +8,7 @@ ], "language": "PYTHON", "name": "google-cloud-beyondcorp-clientgateways", - "version": "0.4.12" + "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.beyondcorp_clientgateways_v1.types.ClientGateway", @@ -465,7 +465,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.beyondcorp_clientgateways_v1.types.ClientGateway", @@ -546,7 +546,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.beyondcorp_clientgateways_v1.services.client_gateways_service.pagers.ListClientGatewaysAsyncPager", @@ -626,7 +626,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.beyondcorp_clientgateways_v1.services.client_gateways_service.pagers.ListClientGatewaysPager", diff --git a/packages/google-cloud-beyondcorp-clientgateways/tests/unit/gapic/beyondcorp_clientgateways_v1/test_client_gateways_service.py b/packages/google-cloud-beyondcorp-clientgateways/tests/unit/gapic/beyondcorp_clientgateways_v1/test_client_gateways_service.py index 269a04e975e5..fb82008584b3 100644 --- a/packages/google-cloud-beyondcorp-clientgateways/tests/unit/gapic/beyondcorp_clientgateways_v1/test_client_gateways_service.py +++ b/packages/google-cloud-beyondcorp-clientgateways/tests/unit/gapic/beyondcorp_clientgateways_v1/test_client_gateways_service.py @@ -2887,6 +2887,7 @@ def test_list_client_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_client_gateways(request) @@ -2944,6 +2945,7 @@ def test_list_client_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_client_gateways(**mock_args) @@ -3145,6 +3147,7 @@ def test_get_client_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.get_client_gateway(request) @@ -3192,6 +3195,7 @@ def test_get_client_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_client_gateway(**mock_args) @@ -3338,6 +3342,7 @@ def test_create_client_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_client_gateway(request) @@ -3397,6 +3402,7 @@ def test_create_client_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_client_gateway(**mock_args) @@ -3543,6 +3549,7 @@ def test_delete_client_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_client_gateway(request) @@ -3596,6 +3603,7 @@ def test_delete_client_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_client_gateway(**mock_args) @@ -3981,6 +3989,7 @@ def test_list_client_gateways_rest_bad_request( response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.list_client_gateways(request) @@ -4019,6 +4028,7 @@ def test_list_client_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_client_gateways(request) # Establish that the response is the type that we expect. @@ -4060,6 +4070,7 @@ def test_list_client_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 = client_gateways_service.ListClientGatewaysResponse.to_json( client_gateways_service.ListClientGatewaysResponse() ) @@ -4106,6 +4117,7 @@ def test_get_client_gateway_rest_bad_request( response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.get_client_gateway(request) @@ -4144,6 +4156,7 @@ def test_get_client_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_client_gateway(request) # Establish that the response is the type that we expect. @@ -4187,6 +4200,7 @@ def test_get_client_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 = client_gateways_service.ClientGateway.to_json( client_gateways_service.ClientGateway() ) @@ -4233,6 +4247,7 @@ def test_create_client_gateway_rest_bad_request( response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.create_client_gateway(request) @@ -4340,6 +4355,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.create_client_gateway(request) # Establish that the response is the type that we expect. @@ -4381,6 +4397,7 @@ def test_create_client_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 @@ -4425,6 +4442,7 @@ def test_delete_client_gateway_rest_bad_request( response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.delete_client_gateway(request) @@ -4455,6 +4473,7 @@ def test_delete_client_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_client_gateway(request) # Establish that the response is the type that we expect. @@ -4496,6 +4515,7 @@ def test_delete_client_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 @@ -4540,6 +4560,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) @@ -4570,6 +4591,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) @@ -4598,6 +4620,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) @@ -4628,6 +4651,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) @@ -4659,6 +4683,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) @@ -4691,6 +4716,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) @@ -4722,6 +4748,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) @@ -4754,6 +4781,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) @@ -4785,6 +4813,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) @@ -4817,6 +4846,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) @@ -4847,6 +4877,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) @@ -4877,6 +4908,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) @@ -4907,6 +4939,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) @@ -4937,6 +4970,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) @@ -4967,6 +5001,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) @@ -4997,6 +5032,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) @@ -5027,6 +5063,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) @@ -5057,6 +5094,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-bigquery-analyticshub/google/cloud/bigquery_analyticshub/gapic_version.py b/packages/google-cloud-bigquery-analyticshub/google/cloud/bigquery_analyticshub/gapic_version.py index 9b19e5f10e00..558c8aab67c5 100644 --- a/packages/google-cloud-bigquery-analyticshub/google/cloud/bigquery_analyticshub/gapic_version.py +++ b/packages/google-cloud-bigquery-analyticshub/google/cloud/bigquery_analyticshub/gapic_version.py @@ -13,4 +13,4 @@ # See the License for the specific language governing permissions and # limitations under the License. # -__version__ = "0.4.13" # {x-release-please-version} +__version__ = "0.0.0" # {x-release-please-version} diff --git a/packages/google-cloud-bigquery-analyticshub/google/cloud/bigquery_analyticshub_v1/gapic_version.py b/packages/google-cloud-bigquery-analyticshub/google/cloud/bigquery_analyticshub_v1/gapic_version.py index 9b19e5f10e00..558c8aab67c5 100644 --- a/packages/google-cloud-bigquery-analyticshub/google/cloud/bigquery_analyticshub_v1/gapic_version.py +++ b/packages/google-cloud-bigquery-analyticshub/google/cloud/bigquery_analyticshub_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.13" # {x-release-please-version} +__version__ = "0.0.0" # {x-release-please-version} diff --git a/packages/google-cloud-bigquery-analyticshub/google/cloud/bigquery_analyticshub_v1/services/analytics_hub_service/async_client.py b/packages/google-cloud-bigquery-analyticshub/google/cloud/bigquery_analyticshub_v1/services/analytics_hub_service/async_client.py index b75e593f1449..f4c84a1d5cb1 100644 --- a/packages/google-cloud-bigquery-analyticshub/google/cloud/bigquery_analyticshub_v1/services/analytics_hub_service/async_client.py +++ b/packages/google-cloud-bigquery-analyticshub/google/cloud/bigquery_analyticshub_v1/services/analytics_hub_service/async_client.py @@ -14,6 +14,7 @@ # limitations under the License. # from collections import OrderedDict +import logging as std_logging import re from typing import ( Callable, @@ -58,6 +59,15 @@ from .transports.base import DEFAULT_CLIENT_INFO, AnalyticsHubServiceTransport from .transports.grpc_asyncio import AnalyticsHubServiceGrpcAsyncIOTransport +try: + from google.api_core import client_logging # type: ignore + + CLIENT_LOGGING_SUPPORTED = True # pragma: NO COVER +except ImportError: # pragma: NO COVER + CLIENT_LOGGING_SUPPORTED = False + +_LOGGER = std_logging.getLogger(__name__) + class AnalyticsHubServiceAsyncClient: """The ``AnalyticsHubService`` API facilitates data sharing within and @@ -286,6 +296,28 @@ def __init__( client_info=client_info, ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + std_logging.DEBUG + ): # pragma: NO COVER + _LOGGER.debug( + "Created client `google.cloud.bigquery.analyticshub_v1.AnalyticsHubServiceAsyncClient`.", + extra={ + "serviceName": "google.cloud.bigquery.analyticshub.v1.AnalyticsHubService", + "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.bigquery.analyticshub.v1.AnalyticsHubService", + "credentialsType": None, + }, + ) + async def list_data_exchanges( self, request: Optional[Union[analyticshub.ListDataExchangesRequest, dict]] = None, @@ -293,7 +325,7 @@ async def list_data_exchanges( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListDataExchangesAsyncPager: r"""Lists all data exchanges in a given project and location. @@ -339,8 +371,10 @@ async def sample_list_data_exchanges(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.bigquery_analyticshub_v1.services.analytics_hub_service.pagers.ListDataExchangesAsyncPager: @@ -415,7 +449,7 @@ async def list_org_data_exchanges( organization: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListOrgDataExchangesAsyncPager: r"""Lists all data exchanges from projects in a given organization and location. @@ -463,8 +497,10 @@ async def sample_list_org_data_exchanges(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.bigquery_analyticshub_v1.services.analytics_hub_service.pagers.ListOrgDataExchangesAsyncPager: @@ -543,7 +579,7 @@ async def get_data_exchange( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> analyticshub.DataExchange: r"""Gets the details of a data exchange. @@ -586,8 +622,10 @@ async def sample_get_data_exchange(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.bigquery_analyticshub_v1.types.DataExchange: @@ -652,7 +690,7 @@ async def create_data_exchange( data_exchange: Optional[analyticshub.DataExchange] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> analyticshub.DataExchange: r"""Creates a new data exchange. @@ -707,8 +745,10 @@ async def sample_create_data_exchange(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.bigquery_analyticshub_v1.types.DataExchange: @@ -775,7 +815,7 @@ async def update_data_exchange( update_mask: Optional[field_mask_pb2.FieldMask] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> analyticshub.DataExchange: r"""Updates an existing data exchange. @@ -830,8 +870,10 @@ async def sample_update_data_exchange(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.bigquery_analyticshub_v1.types.DataExchange: @@ -899,7 +941,7 @@ async def delete_data_exchange( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> None: r"""Deletes an existing data exchange. @@ -940,8 +982,10 @@ async def sample_delete_data_exchange(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. """ # Create or coerce a protobuf request object. # - Quick check: If we got a request object, we should *not* have @@ -993,7 +1037,7 @@ async def list_listings( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListListingsAsyncPager: r"""Lists all listings in a given project and location. @@ -1038,8 +1082,10 @@ async def sample_list_listings(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.bigquery_analyticshub_v1.services.analytics_hub_service.pagers.ListListingsAsyncPager: @@ -1114,7 +1160,7 @@ async def get_listing( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> analyticshub.Listing: r"""Gets the details of a listing. @@ -1157,8 +1203,10 @@ async def sample_get_listing(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.bigquery_analyticshub_v1.types.Listing: @@ -1224,7 +1272,7 @@ async def create_listing( listing: Optional[analyticshub.Listing] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> analyticshub.Listing: r"""Creates a new listing. @@ -1277,8 +1325,10 @@ async def sample_create_listing(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.bigquery_analyticshub_v1.types.Listing: @@ -1346,7 +1396,7 @@ async def update_listing( update_mask: Optional[field_mask_pb2.FieldMask] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> analyticshub.Listing: r"""Updates an existing listing. @@ -1399,8 +1449,10 @@ async def sample_update_listing(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.bigquery_analyticshub_v1.types.Listing: @@ -1469,7 +1521,7 @@ async def delete_listing( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.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 listing. @@ -1509,8 +1561,10 @@ async def sample_delete_listing(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. """ # Create or coerce a protobuf request object. # - Quick check: If we got a request object, we should *not* have @@ -1562,7 +1616,7 @@ async def subscribe_listing( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> analyticshub.SubscribeListingResponse: r"""Subscribes to a listing. @@ -1618,8 +1672,10 @@ async def sample_subscribe_listing(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.bigquery_analyticshub_v1.types.SubscribeListingResponse: @@ -1682,7 +1738,7 @@ async def subscribe_data_exchange( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, 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 Subscription to a Data Exchange. This is a long-running operation as it will create one or more @@ -1734,8 +1790,10 @@ async def sample_subscribe_data_exchange(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.api_core.operation_async.AsyncOperation: @@ -1808,7 +1866,7 @@ async def refresh_subscription( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation_async.AsyncOperation: r"""Refreshes a Subscription to a Data Exchange. A Data Exchange can become stale when a publisher adds or @@ -1860,8 +1918,10 @@ async def sample_refresh_subscription(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.api_core.operation_async.AsyncOperation: @@ -1933,7 +1993,7 @@ async def get_subscription( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> analyticshub.Subscription: r"""Gets the details of a Subscription. @@ -1977,8 +2037,10 @@ async def sample_get_subscription(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.bigquery_analyticshub_v1.types.Subscription: @@ -2042,7 +2104,7 @@ async def list_subscriptions( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListSubscriptionsAsyncPager: r"""Lists all subscriptions in a given project and location. @@ -2088,8 +2150,10 @@ async def sample_list_subscriptions(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.bigquery_analyticshub_v1.services.analytics_hub_service.pagers.ListSubscriptionsAsyncPager: @@ -2166,7 +2230,7 @@ async def list_shared_resource_subscriptions( resource: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListSharedResourceSubscriptionsAsyncPager: r"""Lists all subscriptions on a given Data Exchange or Listing. @@ -2216,8 +2280,10 @@ async def sample_list_shared_resource_subscriptions(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.bigquery_analyticshub_v1.services.analytics_hub_service.pagers.ListSharedResourceSubscriptionsAsyncPager: @@ -2292,7 +2358,7 @@ async def revoke_subscription( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> analyticshub.RevokeSubscriptionResponse: r"""Revokes a given subscription. @@ -2336,8 +2402,10 @@ async def sample_revoke_subscription(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.bigquery_analyticshub_v1.types.RevokeSubscriptionResponse: @@ -2398,7 +2466,7 @@ async def delete_subscription( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation_async.AsyncOperation: r"""Deletes a subscription. @@ -2446,8 +2514,10 @@ async def sample_delete_subscription(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.api_core.operation_async.AsyncOperation: @@ -2525,7 +2595,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. @@ -2562,8 +2632,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: @@ -2639,7 +2711,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 policy. @@ -2676,8 +2748,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: @@ -2753,7 +2827,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"""Returns the permissions that a caller has. @@ -2791,8 +2865,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: diff --git a/packages/google-cloud-bigquery-analyticshub/google/cloud/bigquery_analyticshub_v1/services/analytics_hub_service/client.py b/packages/google-cloud-bigquery-analyticshub/google/cloud/bigquery_analyticshub_v1/services/analytics_hub_service/client.py index 3d2fd8b3bbe1..461824a6bd4f 100644 --- a/packages/google-cloud-bigquery-analyticshub/google/cloud/bigquery_analyticshub_v1/services/analytics_hub_service/client.py +++ b/packages/google-cloud-bigquery-analyticshub/google/cloud/bigquery_analyticshub_v1/services/analytics_hub_service/client.py @@ -14,6 +14,7 @@ # limitations under the License. # from collections import OrderedDict +import logging as std_logging import os import re from typing import ( @@ -48,6 +49,15 @@ except AttributeError: # pragma: NO COVER OptionalRetry = Union[retries.Retry, object, None] # type: ignore +try: + from google.api_core import client_logging # type: ignore + + CLIENT_LOGGING_SUPPORTED = True # pragma: NO COVER +except ImportError: # pragma: NO COVER + CLIENT_LOGGING_SUPPORTED = False + +_LOGGER = std_logging.getLogger(__name__) + from google.api_core import operation # type: ignore from google.api_core import operation_async # type: ignore from google.iam.v1 import iam_policy_pb2 # type: ignore @@ -681,6 +691,10 @@ def __init__( # Initialize the universe domain validation. self._is_universe_domain_valid = False + if CLIENT_LOGGING_SUPPORTED: # pragma: NO COVER + # Setup logging. + client_logging.initialize_logging() + api_key_value = getattr(self._client_options, "api_key", None) if api_key_value and credentials: raise ValueError( @@ -747,6 +761,29 @@ def __init__( api_audience=self._client_options.api_audience, ) + if "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.bigquery.analyticshub_v1.AnalyticsHubServiceClient`.", + extra={ + "serviceName": "google.cloud.bigquery.analyticshub.v1.AnalyticsHubService", + "universeDomain": getattr( + self._transport._credentials, "universe_domain", "" + ), + "credentialsType": f"{type(self._transport._credentials).__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.bigquery.analyticshub.v1.AnalyticsHubService", + "credentialsType": None, + }, + ) + def list_data_exchanges( self, request: Optional[Union[analyticshub.ListDataExchangesRequest, dict]] = None, @@ -754,7 +791,7 @@ def list_data_exchanges( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListDataExchangesPager: r"""Lists all data exchanges in a given project and location. @@ -800,8 +837,10 @@ def sample_list_data_exchanges(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.bigquery_analyticshub_v1.services.analytics_hub_service.pagers.ListDataExchangesPager: @@ -873,7 +912,7 @@ def list_org_data_exchanges( organization: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListOrgDataExchangesPager: r"""Lists all data exchanges from projects in a given organization and location. @@ -921,8 +960,10 @@ def sample_list_org_data_exchanges(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.bigquery_analyticshub_v1.services.analytics_hub_service.pagers.ListOrgDataExchangesPager: @@ -998,7 +1039,7 @@ def get_data_exchange( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> analyticshub.DataExchange: r"""Gets the details of a data exchange. @@ -1041,8 +1082,10 @@ def sample_get_data_exchange(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.bigquery_analyticshub_v1.types.DataExchange: @@ -1104,7 +1147,7 @@ def create_data_exchange( data_exchange: Optional[analyticshub.DataExchange] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> analyticshub.DataExchange: r"""Creates a new data exchange. @@ -1159,8 +1202,10 @@ def sample_create_data_exchange(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.bigquery_analyticshub_v1.types.DataExchange: @@ -1224,7 +1269,7 @@ def update_data_exchange( update_mask: Optional[field_mask_pb2.FieldMask] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> analyticshub.DataExchange: r"""Updates an existing data exchange. @@ -1279,8 +1324,10 @@ def sample_update_data_exchange(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.bigquery_analyticshub_v1.types.DataExchange: @@ -1345,7 +1392,7 @@ def delete_data_exchange( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> None: r"""Deletes an existing data exchange. @@ -1386,8 +1433,10 @@ def sample_delete_data_exchange(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. """ # Create or coerce a protobuf request object. # - Quick check: If we got a request object, we should *not* have @@ -1436,7 +1485,7 @@ def list_listings( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListListingsPager: r"""Lists all listings in a given project and location. @@ -1481,8 +1530,10 @@ def sample_list_listings(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.bigquery_analyticshub_v1.services.analytics_hub_service.pagers.ListListingsPager: @@ -1554,7 +1605,7 @@ def get_listing( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> analyticshub.Listing: r"""Gets the details of a listing. @@ -1597,8 +1648,10 @@ def sample_get_listing(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.bigquery_analyticshub_v1.types.Listing: @@ -1661,7 +1714,7 @@ def create_listing( listing: Optional[analyticshub.Listing] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> analyticshub.Listing: r"""Creates a new listing. @@ -1714,8 +1767,10 @@ def sample_create_listing(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.bigquery_analyticshub_v1.types.Listing: @@ -1780,7 +1835,7 @@ def update_listing( update_mask: Optional[field_mask_pb2.FieldMask] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> analyticshub.Listing: r"""Updates an existing listing. @@ -1833,8 +1888,10 @@ def sample_update_listing(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.bigquery_analyticshub_v1.types.Listing: @@ -1900,7 +1957,7 @@ def delete_listing( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.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 listing. @@ -1940,8 +1997,10 @@ def sample_delete_listing(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. """ # Create or coerce a protobuf request object. # - Quick check: If we got a request object, we should *not* have @@ -1990,7 +2049,7 @@ def subscribe_listing( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> analyticshub.SubscribeListingResponse: r"""Subscribes to a listing. @@ -2046,8 +2105,10 @@ def sample_subscribe_listing(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.bigquery_analyticshub_v1.types.SubscribeListingResponse: @@ -2107,7 +2168,7 @@ def subscribe_data_exchange( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.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 Subscription to a Data Exchange. This is a long-running operation as it will create one or more @@ -2159,8 +2220,10 @@ def sample_subscribe_data_exchange(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.api_core.operation.Operation: @@ -2230,7 +2293,7 @@ def refresh_subscription( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation.Operation: r"""Refreshes a Subscription to a Data Exchange. A Data Exchange can become stale when a publisher adds or @@ -2282,8 +2345,10 @@ def sample_refresh_subscription(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.api_core.operation.Operation: @@ -2352,7 +2417,7 @@ def get_subscription( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> analyticshub.Subscription: r"""Gets the details of a Subscription. @@ -2396,8 +2461,10 @@ def sample_get_subscription(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.bigquery_analyticshub_v1.types.Subscription: @@ -2458,7 +2525,7 @@ def list_subscriptions( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListSubscriptionsPager: r"""Lists all subscriptions in a given project and location. @@ -2504,8 +2571,10 @@ def sample_list_subscriptions(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.bigquery_analyticshub_v1.services.analytics_hub_service.pagers.ListSubscriptionsPager: @@ -2579,7 +2648,7 @@ def list_shared_resource_subscriptions( resource: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListSharedResourceSubscriptionsPager: r"""Lists all subscriptions on a given Data Exchange or Listing. @@ -2629,8 +2698,10 @@ def sample_list_shared_resource_subscriptions(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.bigquery_analyticshub_v1.services.analytics_hub_service.pagers.ListSharedResourceSubscriptionsPager: @@ -2704,7 +2775,7 @@ def revoke_subscription( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> analyticshub.RevokeSubscriptionResponse: r"""Revokes a given subscription. @@ -2748,8 +2819,10 @@ def sample_revoke_subscription(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.bigquery_analyticshub_v1.types.RevokeSubscriptionResponse: @@ -2807,7 +2880,7 @@ def delete_subscription( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation.Operation: r"""Deletes a subscription. @@ -2855,8 +2928,10 @@ def sample_delete_subscription(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.api_core.operation.Operation: @@ -2931,7 +3006,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. @@ -2968,8 +3043,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: @@ -3044,7 +3121,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 policy. @@ -3081,8 +3158,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: @@ -3157,7 +3236,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"""Returns the permissions that a caller has. @@ -3195,8 +3274,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: diff --git a/packages/google-cloud-bigquery-analyticshub/google/cloud/bigquery_analyticshub_v1/services/analytics_hub_service/pagers.py b/packages/google-cloud-bigquery-analyticshub/google/cloud/bigquery_analyticshub_v1/services/analytics_hub_service/pagers.py index 6273d6371509..d1b7423f7e27 100644 --- a/packages/google-cloud-bigquery-analyticshub/google/cloud/bigquery_analyticshub_v1/services/analytics_hub_service/pagers.py +++ b/packages/google-cloud-bigquery-analyticshub/google/cloud/bigquery_analyticshub_v1/services/analytics_hub_service/pagers.py @@ -67,7 +67,7 @@ def __init__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiate the pager. @@ -81,8 +81,10 @@ def __init__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. """ self._method = method self._request = analyticshub.ListDataExchangesRequest(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 = analyticshub.ListDataExchangesRequest(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 = analyticshub.ListOrgDataExchangesRequest(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 = analyticshub.ListOrgDataExchangesRequest(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 = analyticshub.ListListingsRequest(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 = analyticshub.ListListingsRequest(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 = analyticshub.ListSubscriptionsRequest(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 = analyticshub.ListSubscriptionsRequest(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 = analyticshub.ListSharedResourceSubscriptionsRequest(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 = analyticshub.ListSharedResourceSubscriptionsRequest(request) diff --git a/packages/google-cloud-bigquery-analyticshub/google/cloud/bigquery_analyticshub_v1/services/analytics_hub_service/transports/grpc.py b/packages/google-cloud-bigquery-analyticshub/google/cloud/bigquery_analyticshub_v1/services/analytics_hub_service/transports/grpc.py index 7fcc428b9366..b0d6a2969dcf 100644 --- a/packages/google-cloud-bigquery-analyticshub/google/cloud/bigquery_analyticshub_v1/services/analytics_hub_service/transports/grpc.py +++ b/packages/google-cloud-bigquery-analyticshub/google/cloud/bigquery_analyticshub_v1/services/analytics_hub_service/transports/grpc.py @@ -13,6 +13,9 @@ # See the License for the specific language governing permissions and # limitations under the License. # +import json +import logging as std_logging +import pickle from typing import Callable, Dict, Optional, Sequence, Tuple, Union import warnings @@ -24,12 +27,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.bigquery_analyticshub_v1.types import analyticshub from .base import DEFAULT_CLIENT_INFO, AnalyticsHubServiceTransport +try: + from google.api_core import client_logging # 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.bigquery.analyticshub.v1.AnalyticsHubService", + "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.bigquery.analyticshub.v1.AnalyticsHubService", + "rpcName": client_call_details.method, + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class AnalyticsHubServiceGrpcTransport(AnalyticsHubServiceTransport): """gRPC backend transport for AnalyticsHubService. @@ -190,7 +271,12 @@ def __init__( ], ) - # Wrap messages. This must be done after self._grpc_channel exists + self._interceptor = _LoggingClientInterceptor() + self._logged_channel = grpc.intercept_channel( + self._grpc_channel, self._interceptor + ) + + # Wrap messages. This must be done after self._logged_channel exists self._prep_wrapped_messages(client_info) @classmethod @@ -254,7 +340,9 @@ def operations_client(self) -> operations_v1.OperationsClient: """ # Quick check: Only create a new client if we do not already have one. if self._operations_client is None: - self._operations_client = operations_v1.OperationsClient(self.grpc_channel) + self._operations_client = operations_v1.OperationsClient( + self._logged_channel + ) # Return the client from cache. return self._operations_client @@ -281,7 +369,7 @@ def list_data_exchanges( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_data_exchanges" not in self._stubs: - self._stubs["list_data_exchanges"] = self.grpc_channel.unary_unary( + self._stubs["list_data_exchanges"] = self._logged_channel.unary_unary( "/google.cloud.bigquery.analyticshub.v1.AnalyticsHubService/ListDataExchanges", request_serializer=analyticshub.ListDataExchangesRequest.serialize, response_deserializer=analyticshub.ListDataExchangesResponse.deserialize, @@ -311,7 +399,7 @@ def list_org_data_exchanges( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_org_data_exchanges" not in self._stubs: - self._stubs["list_org_data_exchanges"] = self.grpc_channel.unary_unary( + self._stubs["list_org_data_exchanges"] = self._logged_channel.unary_unary( "/google.cloud.bigquery.analyticshub.v1.AnalyticsHubService/ListOrgDataExchanges", request_serializer=analyticshub.ListOrgDataExchangesRequest.serialize, response_deserializer=analyticshub.ListOrgDataExchangesResponse.deserialize, @@ -337,7 +425,7 @@ def get_data_exchange( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_data_exchange" not in self._stubs: - self._stubs["get_data_exchange"] = self.grpc_channel.unary_unary( + self._stubs["get_data_exchange"] = self._logged_channel.unary_unary( "/google.cloud.bigquery.analyticshub.v1.AnalyticsHubService/GetDataExchange", request_serializer=analyticshub.GetDataExchangeRequest.serialize, response_deserializer=analyticshub.DataExchange.deserialize, @@ -363,7 +451,7 @@ def create_data_exchange( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_data_exchange" not in self._stubs: - self._stubs["create_data_exchange"] = self.grpc_channel.unary_unary( + self._stubs["create_data_exchange"] = self._logged_channel.unary_unary( "/google.cloud.bigquery.analyticshub.v1.AnalyticsHubService/CreateDataExchange", request_serializer=analyticshub.CreateDataExchangeRequest.serialize, response_deserializer=analyticshub.DataExchange.deserialize, @@ -389,7 +477,7 @@ def update_data_exchange( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_data_exchange" not in self._stubs: - self._stubs["update_data_exchange"] = self.grpc_channel.unary_unary( + self._stubs["update_data_exchange"] = self._logged_channel.unary_unary( "/google.cloud.bigquery.analyticshub.v1.AnalyticsHubService/UpdateDataExchange", request_serializer=analyticshub.UpdateDataExchangeRequest.serialize, response_deserializer=analyticshub.DataExchange.deserialize, @@ -415,7 +503,7 @@ def delete_data_exchange( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_data_exchange" not in self._stubs: - self._stubs["delete_data_exchange"] = self.grpc_channel.unary_unary( + self._stubs["delete_data_exchange"] = self._logged_channel.unary_unary( "/google.cloud.bigquery.analyticshub.v1.AnalyticsHubService/DeleteDataExchange", request_serializer=analyticshub.DeleteDataExchangeRequest.serialize, response_deserializer=empty_pb2.Empty.FromString, @@ -443,7 +531,7 @@ def list_listings( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_listings" not in self._stubs: - self._stubs["list_listings"] = self.grpc_channel.unary_unary( + self._stubs["list_listings"] = self._logged_channel.unary_unary( "/google.cloud.bigquery.analyticshub.v1.AnalyticsHubService/ListListings", request_serializer=analyticshub.ListListingsRequest.serialize, response_deserializer=analyticshub.ListListingsResponse.deserialize, @@ -469,7 +557,7 @@ def get_listing( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_listing" not in self._stubs: - self._stubs["get_listing"] = self.grpc_channel.unary_unary( + self._stubs["get_listing"] = self._logged_channel.unary_unary( "/google.cloud.bigquery.analyticshub.v1.AnalyticsHubService/GetListing", request_serializer=analyticshub.GetListingRequest.serialize, response_deserializer=analyticshub.Listing.deserialize, @@ -495,7 +583,7 @@ def create_listing( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_listing" not in self._stubs: - self._stubs["create_listing"] = self.grpc_channel.unary_unary( + self._stubs["create_listing"] = self._logged_channel.unary_unary( "/google.cloud.bigquery.analyticshub.v1.AnalyticsHubService/CreateListing", request_serializer=analyticshub.CreateListingRequest.serialize, response_deserializer=analyticshub.Listing.deserialize, @@ -521,7 +609,7 @@ def update_listing( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_listing" not in self._stubs: - self._stubs["update_listing"] = self.grpc_channel.unary_unary( + self._stubs["update_listing"] = self._logged_channel.unary_unary( "/google.cloud.bigquery.analyticshub.v1.AnalyticsHubService/UpdateListing", request_serializer=analyticshub.UpdateListingRequest.serialize, response_deserializer=analyticshub.Listing.deserialize, @@ -547,7 +635,7 @@ def delete_listing( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_listing" not in self._stubs: - self._stubs["delete_listing"] = self.grpc_channel.unary_unary( + self._stubs["delete_listing"] = self._logged_channel.unary_unary( "/google.cloud.bigquery.analyticshub.v1.AnalyticsHubService/DeleteListing", request_serializer=analyticshub.DeleteListingRequest.serialize, response_deserializer=empty_pb2.Empty.FromString, @@ -581,7 +669,7 @@ def subscribe_listing( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "subscribe_listing" not in self._stubs: - self._stubs["subscribe_listing"] = self.grpc_channel.unary_unary( + self._stubs["subscribe_listing"] = self._logged_channel.unary_unary( "/google.cloud.bigquery.analyticshub.v1.AnalyticsHubService/SubscribeListing", request_serializer=analyticshub.SubscribeListingRequest.serialize, response_deserializer=analyticshub.SubscribeListingResponse.deserialize, @@ -611,7 +699,7 @@ def subscribe_data_exchange( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "subscribe_data_exchange" not in self._stubs: - self._stubs["subscribe_data_exchange"] = self.grpc_channel.unary_unary( + self._stubs["subscribe_data_exchange"] = self._logged_channel.unary_unary( "/google.cloud.bigquery.analyticshub.v1.AnalyticsHubService/SubscribeDataExchange", request_serializer=analyticshub.SubscribeDataExchangeRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -640,7 +728,7 @@ def refresh_subscription( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "refresh_subscription" not in self._stubs: - self._stubs["refresh_subscription"] = self.grpc_channel.unary_unary( + self._stubs["refresh_subscription"] = self._logged_channel.unary_unary( "/google.cloud.bigquery.analyticshub.v1.AnalyticsHubService/RefreshSubscription", request_serializer=analyticshub.RefreshSubscriptionRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -666,7 +754,7 @@ def get_subscription( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_subscription" not in self._stubs: - self._stubs["get_subscription"] = self.grpc_channel.unary_unary( + self._stubs["get_subscription"] = self._logged_channel.unary_unary( "/google.cloud.bigquery.analyticshub.v1.AnalyticsHubService/GetSubscription", request_serializer=analyticshub.GetSubscriptionRequest.serialize, response_deserializer=analyticshub.Subscription.deserialize, @@ -695,7 +783,7 @@ def list_subscriptions( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_subscriptions" not in self._stubs: - self._stubs["list_subscriptions"] = self.grpc_channel.unary_unary( + self._stubs["list_subscriptions"] = self._logged_channel.unary_unary( "/google.cloud.bigquery.analyticshub.v1.AnalyticsHubService/ListSubscriptions", request_serializer=analyticshub.ListSubscriptionsRequest.serialize, response_deserializer=analyticshub.ListSubscriptionsResponse.deserialize, @@ -728,7 +816,7 @@ def list_shared_resource_subscriptions( if "list_shared_resource_subscriptions" not in self._stubs: self._stubs[ "list_shared_resource_subscriptions" - ] = self.grpc_channel.unary_unary( + ] = self._logged_channel.unary_unary( "/google.cloud.bigquery.analyticshub.v1.AnalyticsHubService/ListSharedResourceSubscriptions", request_serializer=analyticshub.ListSharedResourceSubscriptionsRequest.serialize, response_deserializer=analyticshub.ListSharedResourceSubscriptionsResponse.deserialize, @@ -757,7 +845,7 @@ def revoke_subscription( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "revoke_subscription" not in self._stubs: - self._stubs["revoke_subscription"] = self.grpc_channel.unary_unary( + self._stubs["revoke_subscription"] = self._logged_channel.unary_unary( "/google.cloud.bigquery.analyticshub.v1.AnalyticsHubService/RevokeSubscription", request_serializer=analyticshub.RevokeSubscriptionRequest.serialize, response_deserializer=analyticshub.RevokeSubscriptionResponse.deserialize, @@ -783,7 +871,7 @@ def delete_subscription( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_subscription" not in self._stubs: - self._stubs["delete_subscription"] = self.grpc_channel.unary_unary( + self._stubs["delete_subscription"] = self._logged_channel.unary_unary( "/google.cloud.bigquery.analyticshub.v1.AnalyticsHubService/DeleteSubscription", request_serializer=analyticshub.DeleteSubscriptionRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -809,7 +897,7 @@ def get_iam_policy( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_iam_policy" not in self._stubs: - self._stubs["get_iam_policy"] = self.grpc_channel.unary_unary( + self._stubs["get_iam_policy"] = self._logged_channel.unary_unary( "/google.cloud.bigquery.analyticshub.v1.AnalyticsHubService/GetIamPolicy", request_serializer=iam_policy_pb2.GetIamPolicyRequest.SerializeToString, response_deserializer=policy_pb2.Policy.FromString, @@ -835,7 +923,7 @@ def set_iam_policy( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "set_iam_policy" not in self._stubs: - self._stubs["set_iam_policy"] = self.grpc_channel.unary_unary( + self._stubs["set_iam_policy"] = self._logged_channel.unary_unary( "/google.cloud.bigquery.analyticshub.v1.AnalyticsHubService/SetIamPolicy", request_serializer=iam_policy_pb2.SetIamPolicyRequest.SerializeToString, response_deserializer=policy_pb2.Policy.FromString, @@ -864,7 +952,7 @@ def test_iam_permissions( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "test_iam_permissions" not in self._stubs: - self._stubs["test_iam_permissions"] = self.grpc_channel.unary_unary( + self._stubs["test_iam_permissions"] = self._logged_channel.unary_unary( "/google.cloud.bigquery.analyticshub.v1.AnalyticsHubService/TestIamPermissions", request_serializer=iam_policy_pb2.TestIamPermissionsRequest.SerializeToString, response_deserializer=iam_policy_pb2.TestIamPermissionsResponse.FromString, @@ -872,7 +960,7 @@ def test_iam_permissions( return self._stubs["test_iam_permissions"] def close(self): - self.grpc_channel.close() + self._logged_channel.close() @property def kind(self) -> str: diff --git a/packages/google-cloud-bigquery-analyticshub/google/cloud/bigquery_analyticshub_v1/services/analytics_hub_service/transports/grpc_asyncio.py b/packages/google-cloud-bigquery-analyticshub/google/cloud/bigquery_analyticshub_v1/services/analytics_hub_service/transports/grpc_asyncio.py index 2a3a0df379bc..128d1c0bb26e 100644 --- a/packages/google-cloud-bigquery-analyticshub/google/cloud/bigquery_analyticshub_v1/services/analytics_hub_service/transports/grpc_asyncio.py +++ b/packages/google-cloud-bigquery-analyticshub/google/cloud/bigquery_analyticshub_v1/services/analytics_hub_service/transports/grpc_asyncio.py @@ -14,6 +14,9 @@ # limitations under the License. # import inspect +import json +import logging as std_logging +import pickle from typing import Awaitable, Callable, Dict, Optional, Sequence, Tuple, Union import warnings @@ -26,14 +29,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.bigquery_analyticshub_v1.types import analyticshub from .base import DEFAULT_CLIENT_INFO, AnalyticsHubServiceTransport from .grpc import AnalyticsHubServiceGrpcTransport +try: + from google.api_core import client_logging # 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.bigquery.analyticshub.v1.AnalyticsHubService", + "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.bigquery.analyticshub.v1.AnalyticsHubService", + "rpcName": str(client_call_details.method), + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class AnalyticsHubServiceGrpcAsyncIOTransport(AnalyticsHubServiceTransport): """gRPC AsyncIO backend transport for AnalyticsHubService. @@ -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. @@ -292,7 +377,7 @@ def list_data_exchanges( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_data_exchanges" not in self._stubs: - self._stubs["list_data_exchanges"] = self.grpc_channel.unary_unary( + self._stubs["list_data_exchanges"] = self._logged_channel.unary_unary( "/google.cloud.bigquery.analyticshub.v1.AnalyticsHubService/ListDataExchanges", request_serializer=analyticshub.ListDataExchangesRequest.serialize, response_deserializer=analyticshub.ListDataExchangesResponse.deserialize, @@ -322,7 +407,7 @@ def list_org_data_exchanges( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_org_data_exchanges" not in self._stubs: - self._stubs["list_org_data_exchanges"] = self.grpc_channel.unary_unary( + self._stubs["list_org_data_exchanges"] = self._logged_channel.unary_unary( "/google.cloud.bigquery.analyticshub.v1.AnalyticsHubService/ListOrgDataExchanges", request_serializer=analyticshub.ListOrgDataExchangesRequest.serialize, response_deserializer=analyticshub.ListOrgDataExchangesResponse.deserialize, @@ -350,7 +435,7 @@ def get_data_exchange( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_data_exchange" not in self._stubs: - self._stubs["get_data_exchange"] = self.grpc_channel.unary_unary( + self._stubs["get_data_exchange"] = self._logged_channel.unary_unary( "/google.cloud.bigquery.analyticshub.v1.AnalyticsHubService/GetDataExchange", request_serializer=analyticshub.GetDataExchangeRequest.serialize, response_deserializer=analyticshub.DataExchange.deserialize, @@ -378,7 +463,7 @@ def create_data_exchange( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_data_exchange" not in self._stubs: - self._stubs["create_data_exchange"] = self.grpc_channel.unary_unary( + self._stubs["create_data_exchange"] = self._logged_channel.unary_unary( "/google.cloud.bigquery.analyticshub.v1.AnalyticsHubService/CreateDataExchange", request_serializer=analyticshub.CreateDataExchangeRequest.serialize, response_deserializer=analyticshub.DataExchange.deserialize, @@ -406,7 +491,7 @@ def update_data_exchange( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_data_exchange" not in self._stubs: - self._stubs["update_data_exchange"] = self.grpc_channel.unary_unary( + self._stubs["update_data_exchange"] = self._logged_channel.unary_unary( "/google.cloud.bigquery.analyticshub.v1.AnalyticsHubService/UpdateDataExchange", request_serializer=analyticshub.UpdateDataExchangeRequest.serialize, response_deserializer=analyticshub.DataExchange.deserialize, @@ -432,7 +517,7 @@ def delete_data_exchange( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_data_exchange" not in self._stubs: - self._stubs["delete_data_exchange"] = self.grpc_channel.unary_unary( + self._stubs["delete_data_exchange"] = self._logged_channel.unary_unary( "/google.cloud.bigquery.analyticshub.v1.AnalyticsHubService/DeleteDataExchange", request_serializer=analyticshub.DeleteDataExchangeRequest.serialize, response_deserializer=empty_pb2.Empty.FromString, @@ -460,7 +545,7 @@ def list_listings( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_listings" not in self._stubs: - self._stubs["list_listings"] = self.grpc_channel.unary_unary( + self._stubs["list_listings"] = self._logged_channel.unary_unary( "/google.cloud.bigquery.analyticshub.v1.AnalyticsHubService/ListListings", request_serializer=analyticshub.ListListingsRequest.serialize, response_deserializer=analyticshub.ListListingsResponse.deserialize, @@ -486,7 +571,7 @@ def get_listing( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_listing" not in self._stubs: - self._stubs["get_listing"] = self.grpc_channel.unary_unary( + self._stubs["get_listing"] = self._logged_channel.unary_unary( "/google.cloud.bigquery.analyticshub.v1.AnalyticsHubService/GetListing", request_serializer=analyticshub.GetListingRequest.serialize, response_deserializer=analyticshub.Listing.deserialize, @@ -512,7 +597,7 @@ def create_listing( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_listing" not in self._stubs: - self._stubs["create_listing"] = self.grpc_channel.unary_unary( + self._stubs["create_listing"] = self._logged_channel.unary_unary( "/google.cloud.bigquery.analyticshub.v1.AnalyticsHubService/CreateListing", request_serializer=analyticshub.CreateListingRequest.serialize, response_deserializer=analyticshub.Listing.deserialize, @@ -538,7 +623,7 @@ def update_listing( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_listing" not in self._stubs: - self._stubs["update_listing"] = self.grpc_channel.unary_unary( + self._stubs["update_listing"] = self._logged_channel.unary_unary( "/google.cloud.bigquery.analyticshub.v1.AnalyticsHubService/UpdateListing", request_serializer=analyticshub.UpdateListingRequest.serialize, response_deserializer=analyticshub.Listing.deserialize, @@ -564,7 +649,7 @@ def delete_listing( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_listing" not in self._stubs: - self._stubs["delete_listing"] = self.grpc_channel.unary_unary( + self._stubs["delete_listing"] = self._logged_channel.unary_unary( "/google.cloud.bigquery.analyticshub.v1.AnalyticsHubService/DeleteListing", request_serializer=analyticshub.DeleteListingRequest.serialize, response_deserializer=empty_pb2.Empty.FromString, @@ -599,7 +684,7 @@ def subscribe_listing( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "subscribe_listing" not in self._stubs: - self._stubs["subscribe_listing"] = self.grpc_channel.unary_unary( + self._stubs["subscribe_listing"] = self._logged_channel.unary_unary( "/google.cloud.bigquery.analyticshub.v1.AnalyticsHubService/SubscribeListing", request_serializer=analyticshub.SubscribeListingRequest.serialize, response_deserializer=analyticshub.SubscribeListingResponse.deserialize, @@ -629,7 +714,7 @@ def subscribe_data_exchange( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "subscribe_data_exchange" not in self._stubs: - self._stubs["subscribe_data_exchange"] = self.grpc_channel.unary_unary( + self._stubs["subscribe_data_exchange"] = self._logged_channel.unary_unary( "/google.cloud.bigquery.analyticshub.v1.AnalyticsHubService/SubscribeDataExchange", request_serializer=analyticshub.SubscribeDataExchangeRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -660,7 +745,7 @@ def refresh_subscription( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "refresh_subscription" not in self._stubs: - self._stubs["refresh_subscription"] = self.grpc_channel.unary_unary( + self._stubs["refresh_subscription"] = self._logged_channel.unary_unary( "/google.cloud.bigquery.analyticshub.v1.AnalyticsHubService/RefreshSubscription", request_serializer=analyticshub.RefreshSubscriptionRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -688,7 +773,7 @@ def get_subscription( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_subscription" not in self._stubs: - self._stubs["get_subscription"] = self.grpc_channel.unary_unary( + self._stubs["get_subscription"] = self._logged_channel.unary_unary( "/google.cloud.bigquery.analyticshub.v1.AnalyticsHubService/GetSubscription", request_serializer=analyticshub.GetSubscriptionRequest.serialize, response_deserializer=analyticshub.Subscription.deserialize, @@ -718,7 +803,7 @@ def list_subscriptions( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_subscriptions" not in self._stubs: - self._stubs["list_subscriptions"] = self.grpc_channel.unary_unary( + self._stubs["list_subscriptions"] = self._logged_channel.unary_unary( "/google.cloud.bigquery.analyticshub.v1.AnalyticsHubService/ListSubscriptions", request_serializer=analyticshub.ListSubscriptionsRequest.serialize, response_deserializer=analyticshub.ListSubscriptionsResponse.deserialize, @@ -751,7 +836,7 @@ def list_shared_resource_subscriptions( if "list_shared_resource_subscriptions" not in self._stubs: self._stubs[ "list_shared_resource_subscriptions" - ] = self.grpc_channel.unary_unary( + ] = self._logged_channel.unary_unary( "/google.cloud.bigquery.analyticshub.v1.AnalyticsHubService/ListSharedResourceSubscriptions", request_serializer=analyticshub.ListSharedResourceSubscriptionsRequest.serialize, response_deserializer=analyticshub.ListSharedResourceSubscriptionsResponse.deserialize, @@ -780,7 +865,7 @@ def revoke_subscription( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "revoke_subscription" not in self._stubs: - self._stubs["revoke_subscription"] = self.grpc_channel.unary_unary( + self._stubs["revoke_subscription"] = self._logged_channel.unary_unary( "/google.cloud.bigquery.analyticshub.v1.AnalyticsHubService/RevokeSubscription", request_serializer=analyticshub.RevokeSubscriptionRequest.serialize, response_deserializer=analyticshub.RevokeSubscriptionResponse.deserialize, @@ -808,7 +893,7 @@ def delete_subscription( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_subscription" not in self._stubs: - self._stubs["delete_subscription"] = self.grpc_channel.unary_unary( + self._stubs["delete_subscription"] = self._logged_channel.unary_unary( "/google.cloud.bigquery.analyticshub.v1.AnalyticsHubService/DeleteSubscription", request_serializer=analyticshub.DeleteSubscriptionRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -834,7 +919,7 @@ def get_iam_policy( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_iam_policy" not in self._stubs: - self._stubs["get_iam_policy"] = self.grpc_channel.unary_unary( + self._stubs["get_iam_policy"] = self._logged_channel.unary_unary( "/google.cloud.bigquery.analyticshub.v1.AnalyticsHubService/GetIamPolicy", request_serializer=iam_policy_pb2.GetIamPolicyRequest.SerializeToString, response_deserializer=policy_pb2.Policy.FromString, @@ -860,7 +945,7 @@ def set_iam_policy( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "set_iam_policy" not in self._stubs: - self._stubs["set_iam_policy"] = self.grpc_channel.unary_unary( + self._stubs["set_iam_policy"] = self._logged_channel.unary_unary( "/google.cloud.bigquery.analyticshub.v1.AnalyticsHubService/SetIamPolicy", request_serializer=iam_policy_pb2.SetIamPolicyRequest.SerializeToString, response_deserializer=policy_pb2.Policy.FromString, @@ -889,7 +974,7 @@ def test_iam_permissions( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "test_iam_permissions" not in self._stubs: - self._stubs["test_iam_permissions"] = self.grpc_channel.unary_unary( + self._stubs["test_iam_permissions"] = self._logged_channel.unary_unary( "/google.cloud.bigquery.analyticshub.v1.AnalyticsHubService/TestIamPermissions", request_serializer=iam_policy_pb2.TestIamPermissionsRequest.SerializeToString, response_deserializer=iam_policy_pb2.TestIamPermissionsResponse.FromString, @@ -1017,7 +1102,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-bigquery-analyticshub/samples/generated_samples/snippet_metadata_google.cloud.bigquery.analyticshub.v1.json b/packages/google-cloud-bigquery-analyticshub/samples/generated_samples/snippet_metadata_google.cloud.bigquery.analyticshub.v1.json index 37e294320dde..7d9e59976e72 100644 --- a/packages/google-cloud-bigquery-analyticshub/samples/generated_samples/snippet_metadata_google.cloud.bigquery.analyticshub.v1.json +++ b/packages/google-cloud-bigquery-analyticshub/samples/generated_samples/snippet_metadata_google.cloud.bigquery.analyticshub.v1.json @@ -8,7 +8,7 @@ ], "language": "PYTHON", "name": "google-cloud-bigquery-analyticshub", - "version": "0.4.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.cloud.bigquery_analyticshub_v1.types.DataExchange", @@ -135,7 +135,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.bigquery_analyticshub_v1.types.DataExchange", @@ -220,7 +220,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.bigquery_analyticshub_v1.types.Listing", @@ -304,7 +304,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.bigquery_analyticshub_v1.types.Listing", @@ -385,7 +385,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "shortName": "delete_data_exchange" @@ -462,7 +462,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "shortName": "delete_data_exchange" @@ -540,7 +540,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "shortName": "delete_listing" @@ -617,7 +617,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "shortName": "delete_listing" @@ -695,7 +695,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -775,7 +775,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -856,7 +856,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.bigquery_analyticshub_v1.types.DataExchange", @@ -936,7 +936,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.bigquery_analyticshub_v1.types.DataExchange", @@ -1013,7 +1013,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.iam.v1.policy_pb2.Policy", @@ -1089,7 +1089,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.iam.v1.policy_pb2.Policy", @@ -1170,7 +1170,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.bigquery_analyticshub_v1.types.Listing", @@ -1250,7 +1250,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.bigquery_analyticshub_v1.types.Listing", @@ -1331,7 +1331,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.bigquery_analyticshub_v1.types.Subscription", @@ -1411,7 +1411,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.bigquery_analyticshub_v1.types.Subscription", @@ -1492,7 +1492,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.bigquery_analyticshub_v1.services.analytics_hub_service.pagers.ListDataExchangesAsyncPager", @@ -1572,7 +1572,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.bigquery_analyticshub_v1.services.analytics_hub_service.pagers.ListDataExchangesPager", @@ -1653,7 +1653,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.bigquery_analyticshub_v1.services.analytics_hub_service.pagers.ListListingsAsyncPager", @@ -1733,7 +1733,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.bigquery_analyticshub_v1.services.analytics_hub_service.pagers.ListListingsPager", @@ -1814,7 +1814,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.bigquery_analyticshub_v1.services.analytics_hub_service.pagers.ListOrgDataExchangesAsyncPager", @@ -1894,7 +1894,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.bigquery_analyticshub_v1.services.analytics_hub_service.pagers.ListOrgDataExchangesPager", @@ -1975,7 +1975,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.bigquery_analyticshub_v1.services.analytics_hub_service.pagers.ListSharedResourceSubscriptionsAsyncPager", @@ -2055,7 +2055,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.bigquery_analyticshub_v1.services.analytics_hub_service.pagers.ListSharedResourceSubscriptionsPager", @@ -2136,7 +2136,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.bigquery_analyticshub_v1.services.analytics_hub_service.pagers.ListSubscriptionsAsyncPager", @@ -2216,7 +2216,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.bigquery_analyticshub_v1.services.analytics_hub_service.pagers.ListSubscriptionsPager", @@ -2297,7 +2297,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -2377,7 +2377,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -2458,7 +2458,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.bigquery_analyticshub_v1.types.RevokeSubscriptionResponse", @@ -2538,7 +2538,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.bigquery_analyticshub_v1.types.RevokeSubscriptionResponse", @@ -2615,7 +2615,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.iam.v1.policy_pb2.Policy", @@ -2691,7 +2691,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.iam.v1.policy_pb2.Policy", @@ -2772,7 +2772,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -2852,7 +2852,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -2933,7 +2933,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.bigquery_analyticshub_v1.types.SubscribeListingResponse", @@ -3013,7 +3013,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.bigquery_analyticshub_v1.types.SubscribeListingResponse", @@ -3090,7 +3090,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.iam.v1.iam_policy_pb2.TestIamPermissionsResponse", @@ -3166,7 +3166,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.iam.v1.iam_policy_pb2.TestIamPermissionsResponse", @@ -3251,7 +3251,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.bigquery_analyticshub_v1.types.DataExchange", @@ -3335,7 +3335,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.bigquery_analyticshub_v1.types.DataExchange", @@ -3420,7 +3420,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.bigquery_analyticshub_v1.types.Listing", @@ -3504,7 +3504,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.bigquery_analyticshub_v1.types.Listing", diff --git a/packages/google-cloud-bigquery-biglake/google/cloud/bigquery_biglake/gapic_version.py b/packages/google-cloud-bigquery-biglake/google/cloud/bigquery_biglake/gapic_version.py index 5feceb32bedf..558c8aab67c5 100644 --- a/packages/google-cloud-bigquery-biglake/google/cloud/bigquery_biglake/gapic_version.py +++ b/packages/google-cloud-bigquery-biglake/google/cloud/bigquery_biglake/gapic_version.py @@ -13,4 +13,4 @@ # See the License for the specific language governing permissions and # limitations under the License. # -__version__ = "0.4.11" # {x-release-please-version} +__version__ = "0.0.0" # {x-release-please-version} diff --git a/packages/google-cloud-bigquery-biglake/google/cloud/bigquery_biglake_v1/gapic_version.py b/packages/google-cloud-bigquery-biglake/google/cloud/bigquery_biglake_v1/gapic_version.py index 5feceb32bedf..558c8aab67c5 100644 --- a/packages/google-cloud-bigquery-biglake/google/cloud/bigquery_biglake_v1/gapic_version.py +++ b/packages/google-cloud-bigquery-biglake/google/cloud/bigquery_biglake_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.11" # {x-release-please-version} +__version__ = "0.0.0" # {x-release-please-version} diff --git a/packages/google-cloud-bigquery-biglake/google/cloud/bigquery_biglake_v1/services/metastore_service/async_client.py b/packages/google-cloud-bigquery-biglake/google/cloud/bigquery_biglake_v1/services/metastore_service/async_client.py index 9976660fe3a9..67232cf24daa 100644 --- a/packages/google-cloud-bigquery-biglake/google/cloud/bigquery_biglake_v1/services/metastore_service/async_client.py +++ b/packages/google-cloud-bigquery-biglake/google/cloud/bigquery_biglake_v1/services/metastore_service/async_client.py @@ -14,6 +14,7 @@ # limitations under the License. # from collections import OrderedDict +import logging as std_logging import re from typing import ( Callable, @@ -52,6 +53,15 @@ from .transports.base import DEFAULT_CLIENT_INFO, MetastoreServiceTransport from .transports.grpc_asyncio import MetastoreServiceGrpcAsyncIOTransport +try: + from google.api_core import client_logging # type: ignore + + CLIENT_LOGGING_SUPPORTED = True # pragma: NO COVER +except ImportError: # pragma: NO COVER + CLIENT_LOGGING_SUPPORTED = False + +_LOGGER = std_logging.getLogger(__name__) + class MetastoreServiceAsyncClient: """BigLake Metastore is a serverless, highly available, multi-tenant @@ -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.bigquery.biglake_v1.MetastoreServiceAsyncClient`.", + extra={ + "serviceName": "google.cloud.bigquery.biglake.v1.MetastoreService", + "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.bigquery.biglake.v1.MetastoreService", + "credentialsType": None, + }, + ) + async def create_catalog( self, request: Optional[Union[metastore.CreateCatalogRequest, dict]] = None, @@ -283,7 +315,7 @@ async def create_catalog( catalog_id: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> metastore.Catalog: r"""Creates a new catalog. @@ -345,8 +377,10 @@ async def sample_create_catalog(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.bigquery_biglake_v1.types.Catalog: @@ -411,7 +445,7 @@ async def delete_catalog( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> metastore.Catalog: r"""Deletes an existing catalog specified by the catalog ID. @@ -456,8 +490,10 @@ async def sample_delete_catalog(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.bigquery_biglake_v1.types.Catalog: @@ -518,7 +554,7 @@ async def get_catalog( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> metastore.Catalog: r"""Gets the catalog specified by the resource name. @@ -562,8 +598,10 @@ async def sample_get_catalog(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.bigquery_biglake_v1.types.Catalog: @@ -624,7 +662,7 @@ async def list_catalogs( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListCatalogsAsyncPager: r"""List all catalogs in a specified project. @@ -670,8 +708,10 @@ async def sample_list_catalogs(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.bigquery_biglake_v1.services.metastore_service.pagers.ListCatalogsAsyncPager: @@ -748,7 +788,7 @@ async def create_database( database_id: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> metastore.Database: r"""Creates a new database. @@ -810,8 +850,10 @@ async def sample_create_database(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.bigquery_biglake_v1.types.Database: @@ -874,7 +916,7 @@ async def delete_database( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> metastore.Database: r"""Deletes an existing database specified by the database ID. @@ -919,8 +961,10 @@ async def sample_delete_database(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.bigquery_biglake_v1.types.Database: @@ -980,7 +1024,7 @@ async def update_database( update_mask: Optional[field_mask_pb2.FieldMask] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> metastore.Database: r"""Updates an existing database specified by the database ID. @@ -1038,8 +1082,10 @@ async def sample_update_database(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.bigquery_biglake_v1.types.Database: @@ -1102,7 +1148,7 @@ async def get_database( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> metastore.Database: r"""Gets the database specified by the resource name. @@ -1146,8 +1192,10 @@ async def sample_get_database(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.bigquery_biglake_v1.types.Database: @@ -1206,7 +1254,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"""List all databases in a specified catalog. @@ -1252,8 +1300,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.bigquery_biglake_v1.services.metastore_service.pagers.ListDatabasesAsyncPager: @@ -1330,7 +1380,7 @@ async def create_table( table_id: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> metastore.Table: r"""Creates a new table. @@ -1391,8 +1441,10 @@ async def sample_create_table(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.bigquery_biglake_v1.types.Table: @@ -1455,7 +1507,7 @@ async def delete_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]]] = (), ) -> metastore.Table: r"""Deletes an existing table specified by the table ID. @@ -1499,8 +1551,10 @@ async def sample_delete_table(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.bigquery_biglake_v1.types.Table: @@ -1560,7 +1614,7 @@ async def update_table( update_mask: Optional[field_mask_pb2.FieldMask] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> metastore.Table: r"""Updates an existing table specified by the table ID. @@ -1617,8 +1671,10 @@ async def sample_update_table(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.bigquery_biglake_v1.types.Table: @@ -1682,7 +1738,7 @@ async def rename_table( new_name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> metastore.Table: r"""Renames an existing table specified by the table ID. @@ -1736,8 +1792,10 @@ async def sample_rename_table(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.bigquery_biglake_v1.types.Table: @@ -1798,7 +1856,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]]] = (), ) -> metastore.Table: r"""Gets the table specified by the resource name. @@ -1842,8 +1900,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.cloud.bigquery_biglake_v1.types.Table: @@ -1902,7 +1962,7 @@ async def list_tables( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListTablesAsyncPager: r"""List all tables in a specified database. @@ -1948,8 +2008,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.cloud.bigquery_biglake_v1.services.metastore_service.pagers.ListTablesAsyncPager: diff --git a/packages/google-cloud-bigquery-biglake/google/cloud/bigquery_biglake_v1/services/metastore_service/client.py b/packages/google-cloud-bigquery-biglake/google/cloud/bigquery_biglake_v1/services/metastore_service/client.py index fa45ceafe1e3..6d2a4f2dfda5 100644 --- a/packages/google-cloud-bigquery-biglake/google/cloud/bigquery_biglake_v1/services/metastore_service/client.py +++ b/packages/google-cloud-bigquery-biglake/google/cloud/bigquery_biglake_v1/services/metastore_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 @@ -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( @@ -710,6 +724,29 @@ def __init__( api_audience=self._client_options.api_audience, ) + if "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.bigquery.biglake_v1.MetastoreServiceClient`.", + extra={ + "serviceName": "google.cloud.bigquery.biglake.v1.MetastoreService", + "universeDomain": getattr( + self._transport._credentials, "universe_domain", "" + ), + "credentialsType": f"{type(self._transport._credentials).__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.bigquery.biglake.v1.MetastoreService", + "credentialsType": None, + }, + ) + def create_catalog( self, request: Optional[Union[metastore.CreateCatalogRequest, dict]] = None, @@ -719,7 +756,7 @@ def create_catalog( catalog_id: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> metastore.Catalog: r"""Creates a new catalog. @@ -781,8 +818,10 @@ def sample_create_catalog(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.bigquery_biglake_v1.types.Catalog: @@ -844,7 +883,7 @@ def delete_catalog( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> metastore.Catalog: r"""Deletes an existing catalog specified by the catalog ID. @@ -889,8 +928,10 @@ def sample_delete_catalog(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.bigquery_biglake_v1.types.Catalog: @@ -948,7 +989,7 @@ def get_catalog( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> metastore.Catalog: r"""Gets the catalog specified by the resource name. @@ -992,8 +1033,10 @@ def sample_get_catalog(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.bigquery_biglake_v1.types.Catalog: @@ -1051,7 +1094,7 @@ def list_catalogs( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListCatalogsPager: r"""List all catalogs in a specified project. @@ -1097,8 +1140,10 @@ def sample_list_catalogs(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.bigquery_biglake_v1.services.metastore_service.pagers.ListCatalogsPager: @@ -1172,7 +1217,7 @@ def create_database( database_id: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> metastore.Database: r"""Creates a new database. @@ -1234,8 +1279,10 @@ def sample_create_database(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.bigquery_biglake_v1.types.Database: @@ -1295,7 +1342,7 @@ def delete_database( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> metastore.Database: r"""Deletes an existing database specified by the database ID. @@ -1340,8 +1387,10 @@ def sample_delete_database(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.bigquery_biglake_v1.types.Database: @@ -1398,7 +1447,7 @@ def update_database( update_mask: Optional[field_mask_pb2.FieldMask] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> metastore.Database: r"""Updates an existing database specified by the database ID. @@ -1456,8 +1505,10 @@ def sample_update_database(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.bigquery_biglake_v1.types.Database: @@ -1517,7 +1568,7 @@ def get_database( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> metastore.Database: r"""Gets the database specified by the resource name. @@ -1561,8 +1612,10 @@ def sample_get_database(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.bigquery_biglake_v1.types.Database: @@ -1618,7 +1671,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"""List all databases in a specified catalog. @@ -1664,8 +1717,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.bigquery_biglake_v1.services.metastore_service.pagers.ListDatabasesPager: @@ -1739,7 +1794,7 @@ def create_table( table_id: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> metastore.Table: r"""Creates a new table. @@ -1800,8 +1855,10 @@ def sample_create_table(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.bigquery_biglake_v1.types.Table: @@ -1861,7 +1918,7 @@ def delete_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]]] = (), ) -> metastore.Table: r"""Deletes an existing table specified by the table ID. @@ -1905,8 +1962,10 @@ def sample_delete_table(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.bigquery_biglake_v1.types.Table: @@ -1963,7 +2022,7 @@ def update_table( update_mask: Optional[field_mask_pb2.FieldMask] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> metastore.Table: r"""Updates an existing table specified by the table ID. @@ -2020,8 +2079,10 @@ def sample_update_table(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.bigquery_biglake_v1.types.Table: @@ -2082,7 +2143,7 @@ def rename_table( new_name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> metastore.Table: r"""Renames an existing table specified by the table ID. @@ -2136,8 +2197,10 @@ def sample_rename_table(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.bigquery_biglake_v1.types.Table: @@ -2195,7 +2258,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]]] = (), ) -> metastore.Table: r"""Gets the table specified by the resource name. @@ -2239,8 +2302,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.cloud.bigquery_biglake_v1.types.Table: @@ -2296,7 +2361,7 @@ def list_tables( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListTablesPager: r"""List all tables in a specified database. @@ -2342,8 +2407,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.cloud.bigquery_biglake_v1.services.metastore_service.pagers.ListTablesPager: diff --git a/packages/google-cloud-bigquery-biglake/google/cloud/bigquery_biglake_v1/services/metastore_service/pagers.py b/packages/google-cloud-bigquery-biglake/google/cloud/bigquery_biglake_v1/services/metastore_service/pagers.py index 5de822b72d1e..cae3b5c1239a 100644 --- a/packages/google-cloud-bigquery-biglake/google/cloud/bigquery_biglake_v1/services/metastore_service/pagers.py +++ b/packages/google-cloud-bigquery-biglake/google/cloud/bigquery_biglake_v1/services/metastore_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 = metastore.ListCatalogsRequest(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 = metastore.ListCatalogsRequest(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 = metastore.ListDatabasesRequest(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 = metastore.ListDatabasesRequest(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 = metastore.ListTablesRequest(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 = metastore.ListTablesRequest(request) diff --git a/packages/google-cloud-bigquery-biglake/google/cloud/bigquery_biglake_v1/services/metastore_service/transports/grpc.py b/packages/google-cloud-bigquery-biglake/google/cloud/bigquery_biglake_v1/services/metastore_service/transports/grpc.py index dadc3c6f2f22..85380c6e5392 100644 --- a/packages/google-cloud-bigquery-biglake/google/cloud/bigquery_biglake_v1/services/metastore_service/transports/grpc.py +++ b/packages/google-cloud-bigquery-biglake/google/cloud/bigquery_biglake_v1/services/metastore_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.bigquery_biglake_v1.types import metastore from .base import DEFAULT_CLIENT_INFO, MetastoreServiceTransport +try: + from google.api_core import client_logging # 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.bigquery.biglake.v1.MetastoreService", + "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.bigquery.biglake.v1.MetastoreService", + "rpcName": client_call_details.method, + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class MetastoreServiceGrpcTransport(MetastoreServiceTransport): """gRPC backend transport for MetastoreService. @@ -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 @@ -263,7 +349,7 @@ def create_catalog( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_catalog" not in self._stubs: - self._stubs["create_catalog"] = self.grpc_channel.unary_unary( + self._stubs["create_catalog"] = self._logged_channel.unary_unary( "/google.cloud.bigquery.biglake.v1.MetastoreService/CreateCatalog", request_serializer=metastore.CreateCatalogRequest.serialize, response_deserializer=metastore.Catalog.deserialize, @@ -290,7 +376,7 @@ def delete_catalog( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_catalog" not in self._stubs: - self._stubs["delete_catalog"] = self.grpc_channel.unary_unary( + self._stubs["delete_catalog"] = self._logged_channel.unary_unary( "/google.cloud.bigquery.biglake.v1.MetastoreService/DeleteCatalog", request_serializer=metastore.DeleteCatalogRequest.serialize, response_deserializer=metastore.Catalog.deserialize, @@ -314,7 +400,7 @@ def get_catalog(self) -> Callable[[metastore.GetCatalogRequest], metastore.Catal # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_catalog" not in self._stubs: - self._stubs["get_catalog"] = self.grpc_channel.unary_unary( + self._stubs["get_catalog"] = self._logged_channel.unary_unary( "/google.cloud.bigquery.biglake.v1.MetastoreService/GetCatalog", request_serializer=metastore.GetCatalogRequest.serialize, response_deserializer=metastore.Catalog.deserialize, @@ -340,7 +426,7 @@ def list_catalogs( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_catalogs" not in self._stubs: - self._stubs["list_catalogs"] = self.grpc_channel.unary_unary( + self._stubs["list_catalogs"] = self._logged_channel.unary_unary( "/google.cloud.bigquery.biglake.v1.MetastoreService/ListCatalogs", request_serializer=metastore.ListCatalogsRequest.serialize, response_deserializer=metastore.ListCatalogsResponse.deserialize, @@ -366,7 +452,7 @@ def create_database( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_database" not in self._stubs: - self._stubs["create_database"] = self.grpc_channel.unary_unary( + self._stubs["create_database"] = self._logged_channel.unary_unary( "/google.cloud.bigquery.biglake.v1.MetastoreService/CreateDatabase", request_serializer=metastore.CreateDatabaseRequest.serialize, response_deserializer=metastore.Database.deserialize, @@ -393,7 +479,7 @@ def delete_database( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_database" not in self._stubs: - self._stubs["delete_database"] = self.grpc_channel.unary_unary( + self._stubs["delete_database"] = self._logged_channel.unary_unary( "/google.cloud.bigquery.biglake.v1.MetastoreService/DeleteDatabase", request_serializer=metastore.DeleteDatabaseRequest.serialize, response_deserializer=metastore.Database.deserialize, @@ -420,7 +506,7 @@ def update_database( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_database" not in self._stubs: - self._stubs["update_database"] = self.grpc_channel.unary_unary( + self._stubs["update_database"] = self._logged_channel.unary_unary( "/google.cloud.bigquery.biglake.v1.MetastoreService/UpdateDatabase", request_serializer=metastore.UpdateDatabaseRequest.serialize, response_deserializer=metastore.Database.deserialize, @@ -446,7 +532,7 @@ def get_database( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_database" not in self._stubs: - self._stubs["get_database"] = self.grpc_channel.unary_unary( + self._stubs["get_database"] = self._logged_channel.unary_unary( "/google.cloud.bigquery.biglake.v1.MetastoreService/GetDatabase", request_serializer=metastore.GetDatabaseRequest.serialize, response_deserializer=metastore.Database.deserialize, @@ -472,7 +558,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.bigquery.biglake.v1.MetastoreService/ListDatabases", request_serializer=metastore.ListDatabasesRequest.serialize, response_deserializer=metastore.ListDatabasesResponse.deserialize, @@ -496,7 +582,7 @@ def create_table(self) -> Callable[[metastore.CreateTableRequest], metastore.Tab # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_table" not in self._stubs: - self._stubs["create_table"] = self.grpc_channel.unary_unary( + self._stubs["create_table"] = self._logged_channel.unary_unary( "/google.cloud.bigquery.biglake.v1.MetastoreService/CreateTable", request_serializer=metastore.CreateTableRequest.serialize, response_deserializer=metastore.Table.deserialize, @@ -520,7 +606,7 @@ def delete_table(self) -> Callable[[metastore.DeleteTableRequest], metastore.Tab # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_table" not in self._stubs: - self._stubs["delete_table"] = self.grpc_channel.unary_unary( + self._stubs["delete_table"] = self._logged_channel.unary_unary( "/google.cloud.bigquery.biglake.v1.MetastoreService/DeleteTable", request_serializer=metastore.DeleteTableRequest.serialize, response_deserializer=metastore.Table.deserialize, @@ -544,7 +630,7 @@ def update_table(self) -> Callable[[metastore.UpdateTableRequest], metastore.Tab # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_table" not in self._stubs: - self._stubs["update_table"] = self.grpc_channel.unary_unary( + self._stubs["update_table"] = self._logged_channel.unary_unary( "/google.cloud.bigquery.biglake.v1.MetastoreService/UpdateTable", request_serializer=metastore.UpdateTableRequest.serialize, response_deserializer=metastore.Table.deserialize, @@ -568,7 +654,7 @@ def rename_table(self) -> Callable[[metastore.RenameTableRequest], metastore.Tab # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "rename_table" not in self._stubs: - self._stubs["rename_table"] = self.grpc_channel.unary_unary( + self._stubs["rename_table"] = self._logged_channel.unary_unary( "/google.cloud.bigquery.biglake.v1.MetastoreService/RenameTable", request_serializer=metastore.RenameTableRequest.serialize, response_deserializer=metastore.Table.deserialize, @@ -592,7 +678,7 @@ def get_table(self) -> Callable[[metastore.GetTableRequest], metastore.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.cloud.bigquery.biglake.v1.MetastoreService/GetTable", request_serializer=metastore.GetTableRequest.serialize, response_deserializer=metastore.Table.deserialize, @@ -618,7 +704,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.cloud.bigquery.biglake.v1.MetastoreService/ListTables", request_serializer=metastore.ListTablesRequest.serialize, response_deserializer=metastore.ListTablesResponse.deserialize, @@ -626,7 +712,7 @@ def list_tables( return self._stubs["list_tables"] def close(self): - self.grpc_channel.close() + self._logged_channel.close() @property def kind(self) -> str: diff --git a/packages/google-cloud-bigquery-biglake/google/cloud/bigquery_biglake_v1/services/metastore_service/transports/grpc_asyncio.py b/packages/google-cloud-bigquery-biglake/google/cloud/bigquery_biglake_v1/services/metastore_service/transports/grpc_asyncio.py index 988304bdcc6a..c649796cf503 100644 --- a/packages/google-cloud-bigquery-biglake/google/cloud/bigquery_biglake_v1/services/metastore_service/transports/grpc_asyncio.py +++ b/packages/google-cloud-bigquery-biglake/google/cloud/bigquery_biglake_v1/services/metastore_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.bigquery_biglake_v1.types import metastore from .base import DEFAULT_CLIENT_INFO, MetastoreServiceTransport from .grpc import MetastoreServiceGrpcTransport +try: + from google.api_core import client_logging # 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.bigquery.biglake.v1.MetastoreService", + "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.bigquery.biglake.v1.MetastoreService", + "rpcName": str(client_call_details.method), + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class MetastoreServiceGrpcAsyncIOTransport(MetastoreServiceTransport): """gRPC AsyncIO backend transport for MetastoreService. @@ -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 @@ -271,7 +356,7 @@ def create_catalog( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_catalog" not in self._stubs: - self._stubs["create_catalog"] = self.grpc_channel.unary_unary( + self._stubs["create_catalog"] = self._logged_channel.unary_unary( "/google.cloud.bigquery.biglake.v1.MetastoreService/CreateCatalog", request_serializer=metastore.CreateCatalogRequest.serialize, response_deserializer=metastore.Catalog.deserialize, @@ -298,7 +383,7 @@ def delete_catalog( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_catalog" not in self._stubs: - self._stubs["delete_catalog"] = self.grpc_channel.unary_unary( + self._stubs["delete_catalog"] = self._logged_channel.unary_unary( "/google.cloud.bigquery.biglake.v1.MetastoreService/DeleteCatalog", request_serializer=metastore.DeleteCatalogRequest.serialize, response_deserializer=metastore.Catalog.deserialize, @@ -324,7 +409,7 @@ def get_catalog( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_catalog" not in self._stubs: - self._stubs["get_catalog"] = self.grpc_channel.unary_unary( + self._stubs["get_catalog"] = self._logged_channel.unary_unary( "/google.cloud.bigquery.biglake.v1.MetastoreService/GetCatalog", request_serializer=metastore.GetCatalogRequest.serialize, response_deserializer=metastore.Catalog.deserialize, @@ -352,7 +437,7 @@ def list_catalogs( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_catalogs" not in self._stubs: - self._stubs["list_catalogs"] = self.grpc_channel.unary_unary( + self._stubs["list_catalogs"] = self._logged_channel.unary_unary( "/google.cloud.bigquery.biglake.v1.MetastoreService/ListCatalogs", request_serializer=metastore.ListCatalogsRequest.serialize, response_deserializer=metastore.ListCatalogsResponse.deserialize, @@ -378,7 +463,7 @@ def create_database( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_database" not in self._stubs: - self._stubs["create_database"] = self.grpc_channel.unary_unary( + self._stubs["create_database"] = self._logged_channel.unary_unary( "/google.cloud.bigquery.biglake.v1.MetastoreService/CreateDatabase", request_serializer=metastore.CreateDatabaseRequest.serialize, response_deserializer=metastore.Database.deserialize, @@ -405,7 +490,7 @@ def delete_database( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_database" not in self._stubs: - self._stubs["delete_database"] = self.grpc_channel.unary_unary( + self._stubs["delete_database"] = self._logged_channel.unary_unary( "/google.cloud.bigquery.biglake.v1.MetastoreService/DeleteDatabase", request_serializer=metastore.DeleteDatabaseRequest.serialize, response_deserializer=metastore.Database.deserialize, @@ -432,7 +517,7 @@ def update_database( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_database" not in self._stubs: - self._stubs["update_database"] = self.grpc_channel.unary_unary( + self._stubs["update_database"] = self._logged_channel.unary_unary( "/google.cloud.bigquery.biglake.v1.MetastoreService/UpdateDatabase", request_serializer=metastore.UpdateDatabaseRequest.serialize, response_deserializer=metastore.Database.deserialize, @@ -458,7 +543,7 @@ def get_database( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_database" not in self._stubs: - self._stubs["get_database"] = self.grpc_channel.unary_unary( + self._stubs["get_database"] = self._logged_channel.unary_unary( "/google.cloud.bigquery.biglake.v1.MetastoreService/GetDatabase", request_serializer=metastore.GetDatabaseRequest.serialize, response_deserializer=metastore.Database.deserialize, @@ -486,7 +571,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.bigquery.biglake.v1.MetastoreService/ListDatabases", request_serializer=metastore.ListDatabasesRequest.serialize, response_deserializer=metastore.ListDatabasesResponse.deserialize, @@ -512,7 +597,7 @@ def create_table( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_table" not in self._stubs: - self._stubs["create_table"] = self.grpc_channel.unary_unary( + self._stubs["create_table"] = self._logged_channel.unary_unary( "/google.cloud.bigquery.biglake.v1.MetastoreService/CreateTable", request_serializer=metastore.CreateTableRequest.serialize, response_deserializer=metastore.Table.deserialize, @@ -538,7 +623,7 @@ def delete_table( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_table" not in self._stubs: - self._stubs["delete_table"] = self.grpc_channel.unary_unary( + self._stubs["delete_table"] = self._logged_channel.unary_unary( "/google.cloud.bigquery.biglake.v1.MetastoreService/DeleteTable", request_serializer=metastore.DeleteTableRequest.serialize, response_deserializer=metastore.Table.deserialize, @@ -564,7 +649,7 @@ def update_table( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_table" not in self._stubs: - self._stubs["update_table"] = self.grpc_channel.unary_unary( + self._stubs["update_table"] = self._logged_channel.unary_unary( "/google.cloud.bigquery.biglake.v1.MetastoreService/UpdateTable", request_serializer=metastore.UpdateTableRequest.serialize, response_deserializer=metastore.Table.deserialize, @@ -590,7 +675,7 @@ def rename_table( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "rename_table" not in self._stubs: - self._stubs["rename_table"] = self.grpc_channel.unary_unary( + self._stubs["rename_table"] = self._logged_channel.unary_unary( "/google.cloud.bigquery.biglake.v1.MetastoreService/RenameTable", request_serializer=metastore.RenameTableRequest.serialize, response_deserializer=metastore.Table.deserialize, @@ -616,7 +701,7 @@ def get_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.cloud.bigquery.biglake.v1.MetastoreService/GetTable", request_serializer=metastore.GetTableRequest.serialize, response_deserializer=metastore.Table.deserialize, @@ -644,7 +729,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.cloud.bigquery.biglake.v1.MetastoreService/ListTables", request_serializer=metastore.ListTablesRequest.serialize, response_deserializer=metastore.ListTablesResponse.deserialize, @@ -737,7 +822,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-bigquery-biglake/google/cloud/bigquery_biglake_v1/services/metastore_service/transports/rest.py b/packages/google-cloud-bigquery-biglake/google/cloud/bigquery_biglake_v1/services/metastore_service/transports/rest.py index b08d8351375c..699d40de7fa9 100644 --- a/packages/google-cloud-bigquery-biglake/google/cloud/bigquery_biglake_v1/services/metastore_service/transports/rest.py +++ b/packages/google-cloud-bigquery-biglake/google/cloud/bigquery_biglake_v1/services/metastore_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, @@ -189,8 +197,8 @@ def post_update_table(self, response): def pre_create_catalog( self, request: metastore.CreateCatalogRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[metastore.CreateCatalogRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[metastore.CreateCatalogRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for create_catalog Override in a subclass to manipulate the request or metadata @@ -210,8 +218,10 @@ def post_create_catalog(self, response: metastore.Catalog) -> metastore.Catalog: def pre_create_database( self, request: metastore.CreateDatabaseRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[metastore.CreateDatabaseRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + metastore.CreateDatabaseRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for create_database Override in a subclass to manipulate the request or metadata @@ -229,8 +239,10 @@ def post_create_database(self, response: metastore.Database) -> metastore.Databa return response def pre_create_table( - self, request: metastore.CreateTableRequest, metadata: Sequence[Tuple[str, str]] - ) -> Tuple[metastore.CreateTableRequest, Sequence[Tuple[str, str]]]: + self, + request: metastore.CreateTableRequest, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[metastore.CreateTableRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for create_table Override in a subclass to manipulate the request or metadata @@ -250,8 +262,8 @@ def post_create_table(self, response: metastore.Table) -> metastore.Table: def pre_delete_catalog( self, request: metastore.DeleteCatalogRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[metastore.DeleteCatalogRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[metastore.DeleteCatalogRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for delete_catalog Override in a subclass to manipulate the request or metadata @@ -271,8 +283,10 @@ def post_delete_catalog(self, response: metastore.Catalog) -> metastore.Catalog: def pre_delete_database( self, request: metastore.DeleteDatabaseRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[metastore.DeleteDatabaseRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + metastore.DeleteDatabaseRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for delete_database Override in a subclass to manipulate the request or metadata @@ -290,8 +304,10 @@ def post_delete_database(self, response: metastore.Database) -> metastore.Databa return response def pre_delete_table( - self, request: metastore.DeleteTableRequest, metadata: Sequence[Tuple[str, str]] - ) -> Tuple[metastore.DeleteTableRequest, Sequence[Tuple[str, str]]]: + self, + request: metastore.DeleteTableRequest, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[metastore.DeleteTableRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for delete_table Override in a subclass to manipulate the request or metadata @@ -309,8 +325,10 @@ def post_delete_table(self, response: metastore.Table) -> metastore.Table: return response def pre_get_catalog( - self, request: metastore.GetCatalogRequest, metadata: Sequence[Tuple[str, str]] - ) -> Tuple[metastore.GetCatalogRequest, Sequence[Tuple[str, str]]]: + self, + request: metastore.GetCatalogRequest, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[metastore.GetCatalogRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for get_catalog Override in a subclass to manipulate the request or metadata @@ -328,8 +346,10 @@ def post_get_catalog(self, response: metastore.Catalog) -> metastore.Catalog: return response def pre_get_database( - self, request: metastore.GetDatabaseRequest, metadata: Sequence[Tuple[str, str]] - ) -> Tuple[metastore.GetDatabaseRequest, Sequence[Tuple[str, str]]]: + self, + request: metastore.GetDatabaseRequest, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[metastore.GetDatabaseRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for get_database Override in a subclass to manipulate the request or metadata @@ -347,8 +367,10 @@ def post_get_database(self, response: metastore.Database) -> metastore.Database: return response def pre_get_table( - self, request: metastore.GetTableRequest, metadata: Sequence[Tuple[str, str]] - ) -> Tuple[metastore.GetTableRequest, Sequence[Tuple[str, str]]]: + self, + request: metastore.GetTableRequest, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[metastore.GetTableRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for get_table Override in a subclass to manipulate the request or metadata @@ -368,8 +390,8 @@ def post_get_table(self, response: metastore.Table) -> metastore.Table: def pre_list_catalogs( self, request: metastore.ListCatalogsRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[metastore.ListCatalogsRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[metastore.ListCatalogsRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for list_catalogs Override in a subclass to manipulate the request or metadata @@ -391,8 +413,8 @@ def post_list_catalogs( def pre_list_databases( self, request: metastore.ListDatabasesRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[metastore.ListDatabasesRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[metastore.ListDatabasesRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for list_databases Override in a subclass to manipulate the request or metadata @@ -412,8 +434,10 @@ def post_list_databases( return response def pre_list_tables( - self, request: metastore.ListTablesRequest, metadata: Sequence[Tuple[str, str]] - ) -> Tuple[metastore.ListTablesRequest, Sequence[Tuple[str, str]]]: + self, + request: metastore.ListTablesRequest, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[metastore.ListTablesRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for list_tables Override in a subclass to manipulate the request or metadata @@ -433,8 +457,10 @@ def post_list_tables( return response def pre_rename_table( - self, request: metastore.RenameTableRequest, metadata: Sequence[Tuple[str, str]] - ) -> Tuple[metastore.RenameTableRequest, Sequence[Tuple[str, str]]]: + self, + request: metastore.RenameTableRequest, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[metastore.RenameTableRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for rename_table Override in a subclass to manipulate the request or metadata @@ -454,8 +480,10 @@ def post_rename_table(self, response: metastore.Table) -> metastore.Table: def pre_update_database( self, request: metastore.UpdateDatabaseRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[metastore.UpdateDatabaseRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + metastore.UpdateDatabaseRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for update_database Override in a subclass to manipulate the request or metadata @@ -473,8 +501,10 @@ def post_update_database(self, response: metastore.Database) -> metastore.Databa return response def pre_update_table( - self, request: metastore.UpdateTableRequest, metadata: Sequence[Tuple[str, str]] - ) -> Tuple[metastore.UpdateTableRequest, Sequence[Tuple[str, str]]]: + self, + request: metastore.UpdateTableRequest, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[metastore.UpdateTableRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for update_table Override in a subclass to manipulate the request or metadata @@ -623,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]]] = (), ) -> metastore.Catalog: r"""Call the create catalog method over HTTP. @@ -634,8 +664,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.metastore.Catalog: @@ -647,6 +679,7 @@ def __call__( http_options = ( _BaseMetastoreServiceRestTransport._BaseCreateCatalog._get_http_options() ) + request, metadata = self._interceptor.pre_create_catalog(request, metadata) transcoded_request = _BaseMetastoreServiceRestTransport._BaseCreateCatalog._get_transcoded_request( http_options, request @@ -661,6 +694,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.bigquery.biglake_v1.MetastoreServiceClient.CreateCatalog", + extra={ + "serviceName": "google.cloud.bigquery.biglake.v1.MetastoreService", + "rpcName": "CreateCatalog", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = MetastoreServiceRestTransport._CreateCatalog._get_response( self._host, @@ -682,7 +742,29 @@ def __call__( pb_resp = metastore.Catalog.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_create_catalog(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = metastore.Catalog.to_json(response) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.bigquery.biglake_v1.MetastoreServiceClient.create_catalog", + extra={ + "serviceName": "google.cloud.bigquery.biglake.v1.MetastoreService", + "rpcName": "CreateCatalog", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _CreateDatabase( @@ -720,7 +802,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> metastore.Database: r"""Call the create database method over HTTP. @@ -731,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: ~.metastore.Database: @@ -742,6 +826,7 @@ def __call__( http_options = ( _BaseMetastoreServiceRestTransport._BaseCreateDatabase._get_http_options() ) + request, metadata = self._interceptor.pre_create_database(request, metadata) transcoded_request = _BaseMetastoreServiceRestTransport._BaseCreateDatabase._get_transcoded_request( http_options, request @@ -756,6 +841,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.bigquery.biglake_v1.MetastoreServiceClient.CreateDatabase", + extra={ + "serviceName": "google.cloud.bigquery.biglake.v1.MetastoreService", + "rpcName": "CreateDatabase", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = MetastoreServiceRestTransport._CreateDatabase._get_response( self._host, @@ -777,7 +889,29 @@ def __call__( pb_resp = metastore.Database.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_create_database(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = metastore.Database.to_json(response) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.bigquery.biglake_v1.MetastoreServiceClient.create_database", + extra={ + "serviceName": "google.cloud.bigquery.biglake.v1.MetastoreService", + "rpcName": "CreateDatabase", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _CreateTable( @@ -815,7 +949,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> metastore.Table: r"""Call the create table method over HTTP. @@ -826,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: ~.metastore.Table: @@ -837,6 +973,7 @@ def __call__( http_options = ( _BaseMetastoreServiceRestTransport._BaseCreateTable._get_http_options() ) + request, metadata = self._interceptor.pre_create_table(request, metadata) transcoded_request = _BaseMetastoreServiceRestTransport._BaseCreateTable._get_transcoded_request( http_options, request @@ -851,6 +988,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.bigquery.biglake_v1.MetastoreServiceClient.CreateTable", + extra={ + "serviceName": "google.cloud.bigquery.biglake.v1.MetastoreService", + "rpcName": "CreateTable", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = MetastoreServiceRestTransport._CreateTable._get_response( self._host, @@ -872,7 +1036,29 @@ def __call__( pb_resp = metastore.Table.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_create_table(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = metastore.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.cloud.bigquery.biglake_v1.MetastoreServiceClient.create_table", + extra={ + "serviceName": "google.cloud.bigquery.biglake.v1.MetastoreService", + "rpcName": "CreateTable", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _DeleteCatalog( @@ -909,7 +1095,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> metastore.Catalog: r"""Call the delete catalog method over HTTP. @@ -920,8 +1106,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.metastore.Catalog: @@ -933,6 +1121,7 @@ def __call__( http_options = ( _BaseMetastoreServiceRestTransport._BaseDeleteCatalog._get_http_options() ) + request, metadata = self._interceptor.pre_delete_catalog(request, metadata) transcoded_request = _BaseMetastoreServiceRestTransport._BaseDeleteCatalog._get_transcoded_request( http_options, request @@ -943,6 +1132,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.bigquery.biglake_v1.MetastoreServiceClient.DeleteCatalog", + extra={ + "serviceName": "google.cloud.bigquery.biglake.v1.MetastoreService", + "rpcName": "DeleteCatalog", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = MetastoreServiceRestTransport._DeleteCatalog._get_response( self._host, @@ -963,7 +1179,29 @@ def __call__( pb_resp = metastore.Catalog.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_delete_catalog(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = metastore.Catalog.to_json(response) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.bigquery.biglake_v1.MetastoreServiceClient.delete_catalog", + extra={ + "serviceName": "google.cloud.bigquery.biglake.v1.MetastoreService", + "rpcName": "DeleteCatalog", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _DeleteDatabase( @@ -1000,7 +1238,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> metastore.Database: r"""Call the delete database method over HTTP. @@ -1011,8 +1249,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.metastore.Database: @@ -1022,6 +1262,7 @@ def __call__( http_options = ( _BaseMetastoreServiceRestTransport._BaseDeleteDatabase._get_http_options() ) + request, metadata = self._interceptor.pre_delete_database(request, metadata) transcoded_request = _BaseMetastoreServiceRestTransport._BaseDeleteDatabase._get_transcoded_request( http_options, request @@ -1032,6 +1273,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.bigquery.biglake_v1.MetastoreServiceClient.DeleteDatabase", + extra={ + "serviceName": "google.cloud.bigquery.biglake.v1.MetastoreService", + "rpcName": "DeleteDatabase", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = MetastoreServiceRestTransport._DeleteDatabase._get_response( self._host, @@ -1052,7 +1320,29 @@ def __call__( pb_resp = metastore.Database.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_delete_database(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = metastore.Database.to_json(response) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.bigquery.biglake_v1.MetastoreServiceClient.delete_database", + extra={ + "serviceName": "google.cloud.bigquery.biglake.v1.MetastoreService", + "rpcName": "DeleteDatabase", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _DeleteTable( @@ -1089,7 +1379,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> metastore.Table: r"""Call the delete table method over HTTP. @@ -1100,8 +1390,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.metastore.Table: @@ -1111,6 +1403,7 @@ def __call__( http_options = ( _BaseMetastoreServiceRestTransport._BaseDeleteTable._get_http_options() ) + request, metadata = self._interceptor.pre_delete_table(request, metadata) transcoded_request = _BaseMetastoreServiceRestTransport._BaseDeleteTable._get_transcoded_request( http_options, request @@ -1121,6 +1414,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.bigquery.biglake_v1.MetastoreServiceClient.DeleteTable", + extra={ + "serviceName": "google.cloud.bigquery.biglake.v1.MetastoreService", + "rpcName": "DeleteTable", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = MetastoreServiceRestTransport._DeleteTable._get_response( self._host, @@ -1141,7 +1461,29 @@ def __call__( pb_resp = metastore.Table.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_delete_table(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = metastore.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.cloud.bigquery.biglake_v1.MetastoreServiceClient.delete_table", + extra={ + "serviceName": "google.cloud.bigquery.biglake.v1.MetastoreService", + "rpcName": "DeleteTable", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _GetCatalog( @@ -1178,7 +1520,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> metastore.Catalog: r"""Call the get catalog method over HTTP. @@ -1189,8 +1531,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.metastore.Catalog: @@ -1202,6 +1546,7 @@ def __call__( http_options = ( _BaseMetastoreServiceRestTransport._BaseGetCatalog._get_http_options() ) + request, metadata = self._interceptor.pre_get_catalog(request, metadata) transcoded_request = _BaseMetastoreServiceRestTransport._BaseGetCatalog._get_transcoded_request( http_options, request @@ -1212,6 +1557,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.bigquery.biglake_v1.MetastoreServiceClient.GetCatalog", + extra={ + "serviceName": "google.cloud.bigquery.biglake.v1.MetastoreService", + "rpcName": "GetCatalog", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = MetastoreServiceRestTransport._GetCatalog._get_response( self._host, @@ -1232,7 +1604,29 @@ def __call__( pb_resp = metastore.Catalog.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_catalog(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = metastore.Catalog.to_json(response) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.bigquery.biglake_v1.MetastoreServiceClient.get_catalog", + extra={ + "serviceName": "google.cloud.bigquery.biglake.v1.MetastoreService", + "rpcName": "GetCatalog", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _GetDatabase( @@ -1269,7 +1663,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> metastore.Database: r"""Call the get database method over HTTP. @@ -1280,8 +1674,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.metastore.Database: @@ -1291,6 +1687,7 @@ def __call__( http_options = ( _BaseMetastoreServiceRestTransport._BaseGetDatabase._get_http_options() ) + request, metadata = self._interceptor.pre_get_database(request, metadata) transcoded_request = _BaseMetastoreServiceRestTransport._BaseGetDatabase._get_transcoded_request( http_options, request @@ -1301,6 +1698,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.bigquery.biglake_v1.MetastoreServiceClient.GetDatabase", + extra={ + "serviceName": "google.cloud.bigquery.biglake.v1.MetastoreService", + "rpcName": "GetDatabase", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = MetastoreServiceRestTransport._GetDatabase._get_response( self._host, @@ -1321,7 +1745,29 @@ def __call__( pb_resp = metastore.Database.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_database(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = metastore.Database.to_json(response) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.bigquery.biglake_v1.MetastoreServiceClient.get_database", + extra={ + "serviceName": "google.cloud.bigquery.biglake.v1.MetastoreService", + "rpcName": "GetDatabase", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _GetTable( @@ -1358,7 +1804,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> metastore.Table: r"""Call the get table method over HTTP. @@ -1369,8 +1815,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.metastore.Table: @@ -1380,6 +1828,7 @@ def __call__( http_options = ( _BaseMetastoreServiceRestTransport._BaseGetTable._get_http_options() ) + request, metadata = self._interceptor.pre_get_table(request, metadata) transcoded_request = _BaseMetastoreServiceRestTransport._BaseGetTable._get_transcoded_request( http_options, request @@ -1392,6 +1841,33 @@ def __call__( ) ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.bigquery.biglake_v1.MetastoreServiceClient.GetTable", + extra={ + "serviceName": "google.cloud.bigquery.biglake.v1.MetastoreService", + "rpcName": "GetTable", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = MetastoreServiceRestTransport._GetTable._get_response( self._host, @@ -1412,7 +1888,29 @@ def __call__( pb_resp = metastore.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 = metastore.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.cloud.bigquery.biglake_v1.MetastoreServiceClient.get_table", + extra={ + "serviceName": "google.cloud.bigquery.biglake.v1.MetastoreService", + "rpcName": "GetTable", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ListCatalogs( @@ -1449,7 +1947,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> metastore.ListCatalogsResponse: r"""Call the list catalogs method over HTTP. @@ -1460,8 +1958,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.metastore.ListCatalogsResponse: @@ -1473,6 +1973,7 @@ def __call__( http_options = ( _BaseMetastoreServiceRestTransport._BaseListCatalogs._get_http_options() ) + request, metadata = self._interceptor.pre_list_catalogs(request, metadata) transcoded_request = _BaseMetastoreServiceRestTransport._BaseListCatalogs._get_transcoded_request( http_options, request @@ -1483,6 +1984,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.bigquery.biglake_v1.MetastoreServiceClient.ListCatalogs", + extra={ + "serviceName": "google.cloud.bigquery.biglake.v1.MetastoreService", + "rpcName": "ListCatalogs", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = MetastoreServiceRestTransport._ListCatalogs._get_response( self._host, @@ -1503,7 +2031,29 @@ def __call__( pb_resp = metastore.ListCatalogsResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_catalogs(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = metastore.ListCatalogsResponse.to_json(response) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.bigquery.biglake_v1.MetastoreServiceClient.list_catalogs", + extra={ + "serviceName": "google.cloud.bigquery.biglake.v1.MetastoreService", + "rpcName": "ListCatalogs", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ListDatabases( @@ -1540,7 +2090,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> metastore.ListDatabasesResponse: r"""Call the list databases method over HTTP. @@ -1551,8 +2101,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.metastore.ListDatabasesResponse: @@ -1564,6 +2116,7 @@ def __call__( http_options = ( _BaseMetastoreServiceRestTransport._BaseListDatabases._get_http_options() ) + request, metadata = self._interceptor.pre_list_databases(request, metadata) transcoded_request = _BaseMetastoreServiceRestTransport._BaseListDatabases._get_transcoded_request( http_options, request @@ -1574,6 +2127,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.bigquery.biglake_v1.MetastoreServiceClient.ListDatabases", + extra={ + "serviceName": "google.cloud.bigquery.biglake.v1.MetastoreService", + "rpcName": "ListDatabases", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = MetastoreServiceRestTransport._ListDatabases._get_response( self._host, @@ -1594,7 +2174,29 @@ def __call__( pb_resp = metastore.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 = metastore.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.bigquery.biglake_v1.MetastoreServiceClient.list_databases", + extra={ + "serviceName": "google.cloud.bigquery.biglake.v1.MetastoreService", + "rpcName": "ListDatabases", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ListTables( @@ -1631,7 +2233,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> metastore.ListTablesResponse: r"""Call the list tables method over HTTP. @@ -1642,8 +2244,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.metastore.ListTablesResponse: @@ -1655,6 +2259,7 @@ def __call__( http_options = ( _BaseMetastoreServiceRestTransport._BaseListTables._get_http_options() ) + request, metadata = self._interceptor.pre_list_tables(request, metadata) transcoded_request = _BaseMetastoreServiceRestTransport._BaseListTables._get_transcoded_request( http_options, request @@ -1665,6 +2270,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.bigquery.biglake_v1.MetastoreServiceClient.ListTables", + extra={ + "serviceName": "google.cloud.bigquery.biglake.v1.MetastoreService", + "rpcName": "ListTables", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = MetastoreServiceRestTransport._ListTables._get_response( self._host, @@ -1685,7 +2317,29 @@ def __call__( pb_resp = metastore.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 = metastore.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.cloud.bigquery.biglake_v1.MetastoreServiceClient.list_tables", + extra={ + "serviceName": "google.cloud.bigquery.biglake.v1.MetastoreService", + "rpcName": "ListTables", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _RenameTable( @@ -1723,7 +2377,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> metastore.Table: r"""Call the rename table method over HTTP. @@ -1734,8 +2388,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.metastore.Table: @@ -1745,6 +2401,7 @@ def __call__( http_options = ( _BaseMetastoreServiceRestTransport._BaseRenameTable._get_http_options() ) + request, metadata = self._interceptor.pre_rename_table(request, metadata) transcoded_request = _BaseMetastoreServiceRestTransport._BaseRenameTable._get_transcoded_request( http_options, request @@ -1759,6 +2416,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.bigquery.biglake_v1.MetastoreServiceClient.RenameTable", + extra={ + "serviceName": "google.cloud.bigquery.biglake.v1.MetastoreService", + "rpcName": "RenameTable", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = MetastoreServiceRestTransport._RenameTable._get_response( self._host, @@ -1780,7 +2464,29 @@ def __call__( pb_resp = metastore.Table.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_rename_table(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = metastore.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.cloud.bigquery.biglake_v1.MetastoreServiceClient.rename_table", + extra={ + "serviceName": "google.cloud.bigquery.biglake.v1.MetastoreService", + "rpcName": "RenameTable", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _UpdateDatabase( @@ -1818,7 +2524,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> metastore.Database: r"""Call the update database method over HTTP. @@ -1829,8 +2535,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.metastore.Database: @@ -1840,6 +2548,7 @@ def __call__( http_options = ( _BaseMetastoreServiceRestTransport._BaseUpdateDatabase._get_http_options() ) + request, metadata = self._interceptor.pre_update_database(request, metadata) transcoded_request = _BaseMetastoreServiceRestTransport._BaseUpdateDatabase._get_transcoded_request( http_options, request @@ -1854,6 +2563,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.bigquery.biglake_v1.MetastoreServiceClient.UpdateDatabase", + extra={ + "serviceName": "google.cloud.bigquery.biglake.v1.MetastoreService", + "rpcName": "UpdateDatabase", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = MetastoreServiceRestTransport._UpdateDatabase._get_response( self._host, @@ -1875,7 +2611,29 @@ def __call__( pb_resp = metastore.Database.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_update_database(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = metastore.Database.to_json(response) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.bigquery.biglake_v1.MetastoreServiceClient.update_database", + extra={ + "serviceName": "google.cloud.bigquery.biglake.v1.MetastoreService", + "rpcName": "UpdateDatabase", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _UpdateTable( @@ -1913,7 +2671,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> metastore.Table: r"""Call the update table method over HTTP. @@ -1924,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: ~.metastore.Table: @@ -1935,6 +2695,7 @@ def __call__( http_options = ( _BaseMetastoreServiceRestTransport._BaseUpdateTable._get_http_options() ) + request, metadata = self._interceptor.pre_update_table(request, metadata) transcoded_request = _BaseMetastoreServiceRestTransport._BaseUpdateTable._get_transcoded_request( http_options, request @@ -1949,6 +2710,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.bigquery.biglake_v1.MetastoreServiceClient.UpdateTable", + extra={ + "serviceName": "google.cloud.bigquery.biglake.v1.MetastoreService", + "rpcName": "UpdateTable", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = MetastoreServiceRestTransport._UpdateTable._get_response( self._host, @@ -1970,7 +2758,29 @@ def __call__( pb_resp = metastore.Table.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_update_table(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = metastore.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.cloud.bigquery.biglake_v1.MetastoreServiceClient.update_table", + extra={ + "serviceName": "google.cloud.bigquery.biglake.v1.MetastoreService", + "rpcName": "UpdateTable", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp @property diff --git a/packages/google-cloud-bigquery-biglake/google/cloud/bigquery_biglake_v1alpha1/gapic_version.py b/packages/google-cloud-bigquery-biglake/google/cloud/bigquery_biglake_v1alpha1/gapic_version.py index 5feceb32bedf..558c8aab67c5 100644 --- a/packages/google-cloud-bigquery-biglake/google/cloud/bigquery_biglake_v1alpha1/gapic_version.py +++ b/packages/google-cloud-bigquery-biglake/google/cloud/bigquery_biglake_v1alpha1/gapic_version.py @@ -13,4 +13,4 @@ # See the License for the specific language governing permissions and # limitations under the License. # -__version__ = "0.4.11" # {x-release-please-version} +__version__ = "0.0.0" # {x-release-please-version} diff --git a/packages/google-cloud-bigquery-biglake/google/cloud/bigquery_biglake_v1alpha1/services/metastore_service/async_client.py b/packages/google-cloud-bigquery-biglake/google/cloud/bigquery_biglake_v1alpha1/services/metastore_service/async_client.py index 740fef82f9d2..e728a4494fbb 100644 --- a/packages/google-cloud-bigquery-biglake/google/cloud/bigquery_biglake_v1alpha1/services/metastore_service/async_client.py +++ b/packages/google-cloud-bigquery-biglake/google/cloud/bigquery_biglake_v1alpha1/services/metastore_service/async_client.py @@ -14,6 +14,7 @@ # limitations under the License. # from collections import OrderedDict +import logging as std_logging import re from typing import ( Callable, @@ -52,6 +53,15 @@ from .transports.base import DEFAULT_CLIENT_INFO, MetastoreServiceTransport from .transports.grpc_asyncio import MetastoreServiceGrpcAsyncIOTransport +try: + from google.api_core import client_logging # type: ignore + + CLIENT_LOGGING_SUPPORTED = True # pragma: NO COVER +except ImportError: # pragma: NO COVER + CLIENT_LOGGING_SUPPORTED = False + +_LOGGER = std_logging.getLogger(__name__) + class MetastoreServiceAsyncClient: """BigLake Metastore is a serverless, highly available, multi-tenant @@ -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.bigquery.biglake_v1alpha1.MetastoreServiceAsyncClient`.", + extra={ + "serviceName": "google.cloud.bigquery.biglake.v1alpha1.MetastoreService", + "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.bigquery.biglake.v1alpha1.MetastoreService", + "credentialsType": None, + }, + ) + async def create_catalog( self, request: Optional[Union[metastore.CreateCatalogRequest, dict]] = None, @@ -285,7 +317,7 @@ async def create_catalog( catalog_id: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> metastore.Catalog: r"""Creates a new catalog. @@ -347,8 +379,10 @@ async def sample_create_catalog(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.bigquery_biglake_v1alpha1.types.Catalog: @@ -413,7 +447,7 @@ async def delete_catalog( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> metastore.Catalog: r"""Deletes an existing catalog specified by the catalog ID. @@ -458,8 +492,10 @@ async def sample_delete_catalog(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.bigquery_biglake_v1alpha1.types.Catalog: @@ -520,7 +556,7 @@ async def get_catalog( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> metastore.Catalog: r"""Gets the catalog specified by the resource name. @@ -564,8 +600,10 @@ async def sample_get_catalog(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.bigquery_biglake_v1alpha1.types.Catalog: @@ -626,7 +664,7 @@ async def list_catalogs( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListCatalogsAsyncPager: r"""List all catalogs in a specified project. @@ -672,8 +710,10 @@ async def sample_list_catalogs(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.bigquery_biglake_v1alpha1.services.metastore_service.pagers.ListCatalogsAsyncPager: @@ -750,7 +790,7 @@ async def create_database( database_id: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> metastore.Database: r"""Creates a new database. @@ -812,8 +852,10 @@ async def sample_create_database(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.bigquery_biglake_v1alpha1.types.Database: @@ -876,7 +918,7 @@ async def delete_database( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> metastore.Database: r"""Deletes an existing database specified by the database ID. @@ -921,8 +963,10 @@ async def sample_delete_database(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.bigquery_biglake_v1alpha1.types.Database: @@ -982,7 +1026,7 @@ async def update_database( update_mask: Optional[field_mask_pb2.FieldMask] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> metastore.Database: r"""Updates an existing database specified by the database ID. @@ -1040,8 +1084,10 @@ async def sample_update_database(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.bigquery_biglake_v1alpha1.types.Database: @@ -1104,7 +1150,7 @@ async def get_database( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> metastore.Database: r"""Gets the database specified by the resource name. @@ -1148,8 +1194,10 @@ async def sample_get_database(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.bigquery_biglake_v1alpha1.types.Database: @@ -1208,7 +1256,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"""List all databases in a specified catalog. @@ -1254,8 +1302,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.bigquery_biglake_v1alpha1.services.metastore_service.pagers.ListDatabasesAsyncPager: @@ -1332,7 +1382,7 @@ async def create_table( table_id: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> metastore.Table: r"""Creates a new table. @@ -1393,8 +1443,10 @@ async def sample_create_table(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.bigquery_biglake_v1alpha1.types.Table: @@ -1457,7 +1509,7 @@ async def delete_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]]] = (), ) -> metastore.Table: r"""Deletes an existing table specified by the table ID. @@ -1501,8 +1553,10 @@ async def sample_delete_table(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.bigquery_biglake_v1alpha1.types.Table: @@ -1562,7 +1616,7 @@ async def update_table( update_mask: Optional[field_mask_pb2.FieldMask] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> metastore.Table: r"""Updates an existing table specified by the table ID. @@ -1619,8 +1673,10 @@ async def sample_update_table(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.bigquery_biglake_v1alpha1.types.Table: @@ -1684,7 +1740,7 @@ async def rename_table( new_name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> metastore.Table: r"""Renames an existing table specified by the table ID. @@ -1738,8 +1794,10 @@ async def sample_rename_table(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.bigquery_biglake_v1alpha1.types.Table: @@ -1800,7 +1858,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]]] = (), ) -> metastore.Table: r"""Gets the table specified by the resource name. @@ -1844,8 +1902,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.cloud.bigquery_biglake_v1alpha1.types.Table: @@ -1904,7 +1964,7 @@ async def list_tables( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListTablesAsyncPager: r"""List all tables in a specified database. @@ -1950,8 +2010,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.cloud.bigquery_biglake_v1alpha1.services.metastore_service.pagers.ListTablesAsyncPager: @@ -2027,7 +2089,7 @@ async def create_lock( lock: Optional[metastore.Lock] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> metastore.Lock: r"""Creates a new lock. @@ -2083,8 +2145,10 @@ async def sample_create_lock(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.bigquery_biglake_v1alpha1.types.Lock: @@ -2145,7 +2209,7 @@ async def delete_lock( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> None: r"""Deletes an existing lock specified by the lock ID. @@ -2186,8 +2250,10 @@ async def sample_delete_lock(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. """ # Create or coerce a protobuf request object. # - Quick check: If we got a request object, we should *not* have @@ -2239,7 +2305,7 @@ async def check_lock( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> metastore.Lock: r"""Checks the state of a lock specified by the lock ID. @@ -2283,8 +2349,10 @@ async def sample_check_lock(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.bigquery_biglake_v1alpha1.types.Lock: @@ -2343,7 +2411,7 @@ async def list_locks( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListLocksAsyncPager: r"""List all locks in a specified database. @@ -2389,8 +2457,10 @@ async def sample_list_locks(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.bigquery_biglake_v1alpha1.services.metastore_service.pagers.ListLocksAsyncPager: diff --git a/packages/google-cloud-bigquery-biglake/google/cloud/bigquery_biglake_v1alpha1/services/metastore_service/client.py b/packages/google-cloud-bigquery-biglake/google/cloud/bigquery_biglake_v1alpha1/services/metastore_service/client.py index 74e3fad5eb61..6e86c94fde80 100644 --- a/packages/google-cloud-bigquery-biglake/google/cloud/bigquery_biglake_v1alpha1/services/metastore_service/client.py +++ b/packages/google-cloud-bigquery-biglake/google/cloud/bigquery_biglake_v1alpha1/services/metastore_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 @@ -670,6 +680,10 @@ def __init__( # Initialize the universe domain validation. self._is_universe_domain_valid = False + if CLIENT_LOGGING_SUPPORTED: # pragma: NO COVER + # Setup logging. + client_logging.initialize_logging() + api_key_value = getattr(self._client_options, "api_key", None) if api_key_value and credentials: raise ValueError( @@ -736,6 +750,29 @@ def __init__( api_audience=self._client_options.api_audience, ) + if "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.bigquery.biglake_v1alpha1.MetastoreServiceClient`.", + extra={ + "serviceName": "google.cloud.bigquery.biglake.v1alpha1.MetastoreService", + "universeDomain": getattr( + self._transport._credentials, "universe_domain", "" + ), + "credentialsType": f"{type(self._transport._credentials).__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.bigquery.biglake.v1alpha1.MetastoreService", + "credentialsType": None, + }, + ) + def create_catalog( self, request: Optional[Union[metastore.CreateCatalogRequest, dict]] = None, @@ -745,7 +782,7 @@ def create_catalog( catalog_id: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> metastore.Catalog: r"""Creates a new catalog. @@ -807,8 +844,10 @@ def sample_create_catalog(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.bigquery_biglake_v1alpha1.types.Catalog: @@ -870,7 +909,7 @@ def delete_catalog( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> metastore.Catalog: r"""Deletes an existing catalog specified by the catalog ID. @@ -915,8 +954,10 @@ def sample_delete_catalog(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.bigquery_biglake_v1alpha1.types.Catalog: @@ -974,7 +1015,7 @@ def get_catalog( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> metastore.Catalog: r"""Gets the catalog specified by the resource name. @@ -1018,8 +1059,10 @@ def sample_get_catalog(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.bigquery_biglake_v1alpha1.types.Catalog: @@ -1077,7 +1120,7 @@ def list_catalogs( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListCatalogsPager: r"""List all catalogs in a specified project. @@ -1123,8 +1166,10 @@ def sample_list_catalogs(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.bigquery_biglake_v1alpha1.services.metastore_service.pagers.ListCatalogsPager: @@ -1198,7 +1243,7 @@ def create_database( database_id: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> metastore.Database: r"""Creates a new database. @@ -1260,8 +1305,10 @@ def sample_create_database(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.bigquery_biglake_v1alpha1.types.Database: @@ -1321,7 +1368,7 @@ def delete_database( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> metastore.Database: r"""Deletes an existing database specified by the database ID. @@ -1366,8 +1413,10 @@ def sample_delete_database(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.bigquery_biglake_v1alpha1.types.Database: @@ -1424,7 +1473,7 @@ def update_database( update_mask: Optional[field_mask_pb2.FieldMask] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> metastore.Database: r"""Updates an existing database specified by the database ID. @@ -1482,8 +1531,10 @@ def sample_update_database(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.bigquery_biglake_v1alpha1.types.Database: @@ -1543,7 +1594,7 @@ def get_database( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> metastore.Database: r"""Gets the database specified by the resource name. @@ -1587,8 +1638,10 @@ def sample_get_database(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.bigquery_biglake_v1alpha1.types.Database: @@ -1644,7 +1697,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"""List all databases in a specified catalog. @@ -1690,8 +1743,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.bigquery_biglake_v1alpha1.services.metastore_service.pagers.ListDatabasesPager: @@ -1765,7 +1820,7 @@ def create_table( table_id: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> metastore.Table: r"""Creates a new table. @@ -1826,8 +1881,10 @@ def sample_create_table(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.bigquery_biglake_v1alpha1.types.Table: @@ -1887,7 +1944,7 @@ def delete_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]]] = (), ) -> metastore.Table: r"""Deletes an existing table specified by the table ID. @@ -1931,8 +1988,10 @@ def sample_delete_table(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.bigquery_biglake_v1alpha1.types.Table: @@ -1989,7 +2048,7 @@ def update_table( update_mask: Optional[field_mask_pb2.FieldMask] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> metastore.Table: r"""Updates an existing table specified by the table ID. @@ -2046,8 +2105,10 @@ def sample_update_table(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.bigquery_biglake_v1alpha1.types.Table: @@ -2108,7 +2169,7 @@ def rename_table( new_name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> metastore.Table: r"""Renames an existing table specified by the table ID. @@ -2162,8 +2223,10 @@ def sample_rename_table(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.bigquery_biglake_v1alpha1.types.Table: @@ -2221,7 +2284,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]]] = (), ) -> metastore.Table: r"""Gets the table specified by the resource name. @@ -2265,8 +2328,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.cloud.bigquery_biglake_v1alpha1.types.Table: @@ -2322,7 +2387,7 @@ def list_tables( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListTablesPager: r"""List all tables in a specified database. @@ -2368,8 +2433,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.cloud.bigquery_biglake_v1alpha1.services.metastore_service.pagers.ListTablesPager: @@ -2442,7 +2509,7 @@ def create_lock( lock: Optional[metastore.Lock] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> metastore.Lock: r"""Creates a new lock. @@ -2498,8 +2565,10 @@ def sample_create_lock(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.bigquery_biglake_v1alpha1.types.Lock: @@ -2557,7 +2626,7 @@ def delete_lock( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> None: r"""Deletes an existing lock specified by the lock ID. @@ -2598,8 +2667,10 @@ def sample_delete_lock(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. """ # Create or coerce a protobuf request object. # - Quick check: If we got a request object, we should *not* have @@ -2648,7 +2719,7 @@ def check_lock( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> metastore.Lock: r"""Checks the state of a lock specified by the lock ID. @@ -2692,8 +2763,10 @@ def sample_check_lock(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.bigquery_biglake_v1alpha1.types.Lock: @@ -2749,7 +2822,7 @@ def list_locks( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListLocksPager: r"""List all locks in a specified database. @@ -2795,8 +2868,10 @@ def sample_list_locks(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.bigquery_biglake_v1alpha1.services.metastore_service.pagers.ListLocksPager: diff --git a/packages/google-cloud-bigquery-biglake/google/cloud/bigquery_biglake_v1alpha1/services/metastore_service/pagers.py b/packages/google-cloud-bigquery-biglake/google/cloud/bigquery_biglake_v1alpha1/services/metastore_service/pagers.py index ebf9e298d4c1..3b972d4c4740 100644 --- a/packages/google-cloud-bigquery-biglake/google/cloud/bigquery_biglake_v1alpha1/services/metastore_service/pagers.py +++ b/packages/google-cloud-bigquery-biglake/google/cloud/bigquery_biglake_v1alpha1/services/metastore_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 = metastore.ListCatalogsRequest(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 = metastore.ListCatalogsRequest(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 = metastore.ListDatabasesRequest(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 = metastore.ListDatabasesRequest(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 = metastore.ListTablesRequest(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 = metastore.ListTablesRequest(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 = metastore.ListLocksRequest(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 = metastore.ListLocksRequest(request) diff --git a/packages/google-cloud-bigquery-biglake/google/cloud/bigquery_biglake_v1alpha1/services/metastore_service/transports/grpc.py b/packages/google-cloud-bigquery-biglake/google/cloud/bigquery_biglake_v1alpha1/services/metastore_service/transports/grpc.py index d42b056ea2b5..f63da7c05cea 100644 --- a/packages/google-cloud-bigquery-biglake/google/cloud/bigquery_biglake_v1alpha1/services/metastore_service/transports/grpc.py +++ b/packages/google-cloud-bigquery-biglake/google/cloud/bigquery_biglake_v1alpha1/services/metastore_service/transports/grpc.py @@ -13,6 +13,9 @@ # See the License for the specific language governing permissions and # limitations under the License. # +import json +import logging as std_logging +import pickle from typing import Callable, Dict, Optional, Sequence, Tuple, Union import warnings @@ -21,12 +24,90 @@ from google.auth import credentials as ga_credentials # type: ignore from google.auth.transport.grpc import SslCredentials # type: ignore from google.protobuf import empty_pb2 # type: ignore +from google.protobuf.json_format import MessageToJson +import google.protobuf.message import grpc # type: ignore +import proto # type: ignore from google.cloud.bigquery_biglake_v1alpha1.types import metastore from .base import DEFAULT_CLIENT_INFO, MetastoreServiceTransport +try: + from google.api_core import client_logging # 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.bigquery.biglake.v1alpha1.MetastoreService", + "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.bigquery.biglake.v1alpha1.MetastoreService", + "rpcName": client_call_details.method, + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class MetastoreServiceGrpcTransport(MetastoreServiceTransport): """gRPC backend transport for MetastoreService. @@ -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 @@ -264,7 +350,7 @@ def create_catalog( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_catalog" not in self._stubs: - self._stubs["create_catalog"] = self.grpc_channel.unary_unary( + self._stubs["create_catalog"] = self._logged_channel.unary_unary( "/google.cloud.bigquery.biglake.v1alpha1.MetastoreService/CreateCatalog", request_serializer=metastore.CreateCatalogRequest.serialize, response_deserializer=metastore.Catalog.deserialize, @@ -291,7 +377,7 @@ def delete_catalog( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_catalog" not in self._stubs: - self._stubs["delete_catalog"] = self.grpc_channel.unary_unary( + self._stubs["delete_catalog"] = self._logged_channel.unary_unary( "/google.cloud.bigquery.biglake.v1alpha1.MetastoreService/DeleteCatalog", request_serializer=metastore.DeleteCatalogRequest.serialize, response_deserializer=metastore.Catalog.deserialize, @@ -315,7 +401,7 @@ def get_catalog(self) -> Callable[[metastore.GetCatalogRequest], metastore.Catal # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_catalog" not in self._stubs: - self._stubs["get_catalog"] = self.grpc_channel.unary_unary( + self._stubs["get_catalog"] = self._logged_channel.unary_unary( "/google.cloud.bigquery.biglake.v1alpha1.MetastoreService/GetCatalog", request_serializer=metastore.GetCatalogRequest.serialize, response_deserializer=metastore.Catalog.deserialize, @@ -341,7 +427,7 @@ def list_catalogs( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_catalogs" not in self._stubs: - self._stubs["list_catalogs"] = self.grpc_channel.unary_unary( + self._stubs["list_catalogs"] = self._logged_channel.unary_unary( "/google.cloud.bigquery.biglake.v1alpha1.MetastoreService/ListCatalogs", request_serializer=metastore.ListCatalogsRequest.serialize, response_deserializer=metastore.ListCatalogsResponse.deserialize, @@ -367,7 +453,7 @@ def create_database( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_database" not in self._stubs: - self._stubs["create_database"] = self.grpc_channel.unary_unary( + self._stubs["create_database"] = self._logged_channel.unary_unary( "/google.cloud.bigquery.biglake.v1alpha1.MetastoreService/CreateDatabase", request_serializer=metastore.CreateDatabaseRequest.serialize, response_deserializer=metastore.Database.deserialize, @@ -394,7 +480,7 @@ def delete_database( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_database" not in self._stubs: - self._stubs["delete_database"] = self.grpc_channel.unary_unary( + self._stubs["delete_database"] = self._logged_channel.unary_unary( "/google.cloud.bigquery.biglake.v1alpha1.MetastoreService/DeleteDatabase", request_serializer=metastore.DeleteDatabaseRequest.serialize, response_deserializer=metastore.Database.deserialize, @@ -421,7 +507,7 @@ def update_database( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_database" not in self._stubs: - self._stubs["update_database"] = self.grpc_channel.unary_unary( + self._stubs["update_database"] = self._logged_channel.unary_unary( "/google.cloud.bigquery.biglake.v1alpha1.MetastoreService/UpdateDatabase", request_serializer=metastore.UpdateDatabaseRequest.serialize, response_deserializer=metastore.Database.deserialize, @@ -447,7 +533,7 @@ def get_database( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_database" not in self._stubs: - self._stubs["get_database"] = self.grpc_channel.unary_unary( + self._stubs["get_database"] = self._logged_channel.unary_unary( "/google.cloud.bigquery.biglake.v1alpha1.MetastoreService/GetDatabase", request_serializer=metastore.GetDatabaseRequest.serialize, response_deserializer=metastore.Database.deserialize, @@ -473,7 +559,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.bigquery.biglake.v1alpha1.MetastoreService/ListDatabases", request_serializer=metastore.ListDatabasesRequest.serialize, response_deserializer=metastore.ListDatabasesResponse.deserialize, @@ -497,7 +583,7 @@ def create_table(self) -> Callable[[metastore.CreateTableRequest], metastore.Tab # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_table" not in self._stubs: - self._stubs["create_table"] = self.grpc_channel.unary_unary( + self._stubs["create_table"] = self._logged_channel.unary_unary( "/google.cloud.bigquery.biglake.v1alpha1.MetastoreService/CreateTable", request_serializer=metastore.CreateTableRequest.serialize, response_deserializer=metastore.Table.deserialize, @@ -521,7 +607,7 @@ def delete_table(self) -> Callable[[metastore.DeleteTableRequest], metastore.Tab # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_table" not in self._stubs: - self._stubs["delete_table"] = self.grpc_channel.unary_unary( + self._stubs["delete_table"] = self._logged_channel.unary_unary( "/google.cloud.bigquery.biglake.v1alpha1.MetastoreService/DeleteTable", request_serializer=metastore.DeleteTableRequest.serialize, response_deserializer=metastore.Table.deserialize, @@ -545,7 +631,7 @@ def update_table(self) -> Callable[[metastore.UpdateTableRequest], metastore.Tab # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_table" not in self._stubs: - self._stubs["update_table"] = self.grpc_channel.unary_unary( + self._stubs["update_table"] = self._logged_channel.unary_unary( "/google.cloud.bigquery.biglake.v1alpha1.MetastoreService/UpdateTable", request_serializer=metastore.UpdateTableRequest.serialize, response_deserializer=metastore.Table.deserialize, @@ -569,7 +655,7 @@ def rename_table(self) -> Callable[[metastore.RenameTableRequest], metastore.Tab # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "rename_table" not in self._stubs: - self._stubs["rename_table"] = self.grpc_channel.unary_unary( + self._stubs["rename_table"] = self._logged_channel.unary_unary( "/google.cloud.bigquery.biglake.v1alpha1.MetastoreService/RenameTable", request_serializer=metastore.RenameTableRequest.serialize, response_deserializer=metastore.Table.deserialize, @@ -593,7 +679,7 @@ def get_table(self) -> Callable[[metastore.GetTableRequest], metastore.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.cloud.bigquery.biglake.v1alpha1.MetastoreService/GetTable", request_serializer=metastore.GetTableRequest.serialize, response_deserializer=metastore.Table.deserialize, @@ -619,7 +705,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.cloud.bigquery.biglake.v1alpha1.MetastoreService/ListTables", request_serializer=metastore.ListTablesRequest.serialize, response_deserializer=metastore.ListTablesResponse.deserialize, @@ -643,7 +729,7 @@ def create_lock(self) -> Callable[[metastore.CreateLockRequest], metastore.Lock] # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_lock" not in self._stubs: - self._stubs["create_lock"] = self.grpc_channel.unary_unary( + self._stubs["create_lock"] = self._logged_channel.unary_unary( "/google.cloud.bigquery.biglake.v1alpha1.MetastoreService/CreateLock", request_serializer=metastore.CreateLockRequest.serialize, response_deserializer=metastore.Lock.deserialize, @@ -667,7 +753,7 @@ def delete_lock(self) -> Callable[[metastore.DeleteLockRequest], empty_pb2.Empty # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_lock" not in self._stubs: - self._stubs["delete_lock"] = self.grpc_channel.unary_unary( + self._stubs["delete_lock"] = self._logged_channel.unary_unary( "/google.cloud.bigquery.biglake.v1alpha1.MetastoreService/DeleteLock", request_serializer=metastore.DeleteLockRequest.serialize, response_deserializer=empty_pb2.Empty.FromString, @@ -691,7 +777,7 @@ def check_lock(self) -> Callable[[metastore.CheckLockRequest], metastore.Lock]: # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "check_lock" not in self._stubs: - self._stubs["check_lock"] = self.grpc_channel.unary_unary( + self._stubs["check_lock"] = self._logged_channel.unary_unary( "/google.cloud.bigquery.biglake.v1alpha1.MetastoreService/CheckLock", request_serializer=metastore.CheckLockRequest.serialize, response_deserializer=metastore.Lock.deserialize, @@ -717,7 +803,7 @@ def list_locks( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_locks" not in self._stubs: - self._stubs["list_locks"] = self.grpc_channel.unary_unary( + self._stubs["list_locks"] = self._logged_channel.unary_unary( "/google.cloud.bigquery.biglake.v1alpha1.MetastoreService/ListLocks", request_serializer=metastore.ListLocksRequest.serialize, response_deserializer=metastore.ListLocksResponse.deserialize, @@ -725,7 +811,7 @@ def list_locks( return self._stubs["list_locks"] def close(self): - self.grpc_channel.close() + self._logged_channel.close() @property def kind(self) -> str: diff --git a/packages/google-cloud-bigquery-biglake/google/cloud/bigquery_biglake_v1alpha1/services/metastore_service/transports/grpc_asyncio.py b/packages/google-cloud-bigquery-biglake/google/cloud/bigquery_biglake_v1alpha1/services/metastore_service/transports/grpc_asyncio.py index de395ad6e158..9b8e2904c97a 100644 --- a/packages/google-cloud-bigquery-biglake/google/cloud/bigquery_biglake_v1alpha1/services/metastore_service/transports/grpc_asyncio.py +++ b/packages/google-cloud-bigquery-biglake/google/cloud/bigquery_biglake_v1alpha1/services/metastore_service/transports/grpc_asyncio.py @@ -14,6 +14,9 @@ # limitations under the License. # import inspect +import json +import logging as std_logging +import pickle from typing import Awaitable, Callable, Dict, Optional, Sequence, Tuple, Union import warnings @@ -23,14 +26,93 @@ from google.auth import credentials as ga_credentials # type: ignore from google.auth.transport.grpc import SslCredentials # type: ignore from google.protobuf import empty_pb2 # type: ignore +from google.protobuf.json_format import MessageToJson +import google.protobuf.message import grpc # type: ignore from grpc.experimental import aio # type: ignore +import proto # type: ignore from google.cloud.bigquery_biglake_v1alpha1.types import metastore from .base import DEFAULT_CLIENT_INFO, MetastoreServiceTransport from .grpc import MetastoreServiceGrpcTransport +try: + from google.api_core import client_logging # 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.bigquery.biglake.v1alpha1.MetastoreService", + "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.bigquery.biglake.v1alpha1.MetastoreService", + "rpcName": str(client_call_details.method), + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class MetastoreServiceGrpcAsyncIOTransport(MetastoreServiceTransport): """gRPC AsyncIO backend transport for MetastoreService. @@ -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 @@ -272,7 +357,7 @@ def create_catalog( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_catalog" not in self._stubs: - self._stubs["create_catalog"] = self.grpc_channel.unary_unary( + self._stubs["create_catalog"] = self._logged_channel.unary_unary( "/google.cloud.bigquery.biglake.v1alpha1.MetastoreService/CreateCatalog", request_serializer=metastore.CreateCatalogRequest.serialize, response_deserializer=metastore.Catalog.deserialize, @@ -299,7 +384,7 @@ def delete_catalog( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_catalog" not in self._stubs: - self._stubs["delete_catalog"] = self.grpc_channel.unary_unary( + self._stubs["delete_catalog"] = self._logged_channel.unary_unary( "/google.cloud.bigquery.biglake.v1alpha1.MetastoreService/DeleteCatalog", request_serializer=metastore.DeleteCatalogRequest.serialize, response_deserializer=metastore.Catalog.deserialize, @@ -325,7 +410,7 @@ def get_catalog( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_catalog" not in self._stubs: - self._stubs["get_catalog"] = self.grpc_channel.unary_unary( + self._stubs["get_catalog"] = self._logged_channel.unary_unary( "/google.cloud.bigquery.biglake.v1alpha1.MetastoreService/GetCatalog", request_serializer=metastore.GetCatalogRequest.serialize, response_deserializer=metastore.Catalog.deserialize, @@ -353,7 +438,7 @@ def list_catalogs( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_catalogs" not in self._stubs: - self._stubs["list_catalogs"] = self.grpc_channel.unary_unary( + self._stubs["list_catalogs"] = self._logged_channel.unary_unary( "/google.cloud.bigquery.biglake.v1alpha1.MetastoreService/ListCatalogs", request_serializer=metastore.ListCatalogsRequest.serialize, response_deserializer=metastore.ListCatalogsResponse.deserialize, @@ -379,7 +464,7 @@ def create_database( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_database" not in self._stubs: - self._stubs["create_database"] = self.grpc_channel.unary_unary( + self._stubs["create_database"] = self._logged_channel.unary_unary( "/google.cloud.bigquery.biglake.v1alpha1.MetastoreService/CreateDatabase", request_serializer=metastore.CreateDatabaseRequest.serialize, response_deserializer=metastore.Database.deserialize, @@ -406,7 +491,7 @@ def delete_database( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_database" not in self._stubs: - self._stubs["delete_database"] = self.grpc_channel.unary_unary( + self._stubs["delete_database"] = self._logged_channel.unary_unary( "/google.cloud.bigquery.biglake.v1alpha1.MetastoreService/DeleteDatabase", request_serializer=metastore.DeleteDatabaseRequest.serialize, response_deserializer=metastore.Database.deserialize, @@ -433,7 +518,7 @@ def update_database( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_database" not in self._stubs: - self._stubs["update_database"] = self.grpc_channel.unary_unary( + self._stubs["update_database"] = self._logged_channel.unary_unary( "/google.cloud.bigquery.biglake.v1alpha1.MetastoreService/UpdateDatabase", request_serializer=metastore.UpdateDatabaseRequest.serialize, response_deserializer=metastore.Database.deserialize, @@ -459,7 +544,7 @@ def get_database( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_database" not in self._stubs: - self._stubs["get_database"] = self.grpc_channel.unary_unary( + self._stubs["get_database"] = self._logged_channel.unary_unary( "/google.cloud.bigquery.biglake.v1alpha1.MetastoreService/GetDatabase", request_serializer=metastore.GetDatabaseRequest.serialize, response_deserializer=metastore.Database.deserialize, @@ -487,7 +572,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.bigquery.biglake.v1alpha1.MetastoreService/ListDatabases", request_serializer=metastore.ListDatabasesRequest.serialize, response_deserializer=metastore.ListDatabasesResponse.deserialize, @@ -513,7 +598,7 @@ def create_table( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_table" not in self._stubs: - self._stubs["create_table"] = self.grpc_channel.unary_unary( + self._stubs["create_table"] = self._logged_channel.unary_unary( "/google.cloud.bigquery.biglake.v1alpha1.MetastoreService/CreateTable", request_serializer=metastore.CreateTableRequest.serialize, response_deserializer=metastore.Table.deserialize, @@ -539,7 +624,7 @@ def delete_table( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_table" not in self._stubs: - self._stubs["delete_table"] = self.grpc_channel.unary_unary( + self._stubs["delete_table"] = self._logged_channel.unary_unary( "/google.cloud.bigquery.biglake.v1alpha1.MetastoreService/DeleteTable", request_serializer=metastore.DeleteTableRequest.serialize, response_deserializer=metastore.Table.deserialize, @@ -565,7 +650,7 @@ def update_table( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_table" not in self._stubs: - self._stubs["update_table"] = self.grpc_channel.unary_unary( + self._stubs["update_table"] = self._logged_channel.unary_unary( "/google.cloud.bigquery.biglake.v1alpha1.MetastoreService/UpdateTable", request_serializer=metastore.UpdateTableRequest.serialize, response_deserializer=metastore.Table.deserialize, @@ -591,7 +676,7 @@ def rename_table( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "rename_table" not in self._stubs: - self._stubs["rename_table"] = self.grpc_channel.unary_unary( + self._stubs["rename_table"] = self._logged_channel.unary_unary( "/google.cloud.bigquery.biglake.v1alpha1.MetastoreService/RenameTable", request_serializer=metastore.RenameTableRequest.serialize, response_deserializer=metastore.Table.deserialize, @@ -617,7 +702,7 @@ def get_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.cloud.bigquery.biglake.v1alpha1.MetastoreService/GetTable", request_serializer=metastore.GetTableRequest.serialize, response_deserializer=metastore.Table.deserialize, @@ -645,7 +730,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.cloud.bigquery.biglake.v1alpha1.MetastoreService/ListTables", request_serializer=metastore.ListTablesRequest.serialize, response_deserializer=metastore.ListTablesResponse.deserialize, @@ -671,7 +756,7 @@ def create_lock( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_lock" not in self._stubs: - self._stubs["create_lock"] = self.grpc_channel.unary_unary( + self._stubs["create_lock"] = self._logged_channel.unary_unary( "/google.cloud.bigquery.biglake.v1alpha1.MetastoreService/CreateLock", request_serializer=metastore.CreateLockRequest.serialize, response_deserializer=metastore.Lock.deserialize, @@ -697,7 +782,7 @@ def delete_lock( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_lock" not in self._stubs: - self._stubs["delete_lock"] = self.grpc_channel.unary_unary( + self._stubs["delete_lock"] = self._logged_channel.unary_unary( "/google.cloud.bigquery.biglake.v1alpha1.MetastoreService/DeleteLock", request_serializer=metastore.DeleteLockRequest.serialize, response_deserializer=empty_pb2.Empty.FromString, @@ -723,7 +808,7 @@ def check_lock( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "check_lock" not in self._stubs: - self._stubs["check_lock"] = self.grpc_channel.unary_unary( + self._stubs["check_lock"] = self._logged_channel.unary_unary( "/google.cloud.bigquery.biglake.v1alpha1.MetastoreService/CheckLock", request_serializer=metastore.CheckLockRequest.serialize, response_deserializer=metastore.Lock.deserialize, @@ -749,7 +834,7 @@ def list_locks( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_locks" not in self._stubs: - self._stubs["list_locks"] = self.grpc_channel.unary_unary( + self._stubs["list_locks"] = self._logged_channel.unary_unary( "/google.cloud.bigquery.biglake.v1alpha1.MetastoreService/ListLocks", request_serializer=metastore.ListLocksRequest.serialize, response_deserializer=metastore.ListLocksResponse.deserialize, @@ -862,7 +947,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-bigquery-biglake/google/cloud/bigquery_biglake_v1alpha1/services/metastore_service/transports/rest.py b/packages/google-cloud-bigquery-biglake/google/cloud/bigquery_biglake_v1alpha1/services/metastore_service/transports/rest.py index d888ececb18d..ec8ae6129f57 100644 --- a/packages/google-cloud-bigquery-biglake/google/cloud/bigquery_biglake_v1alpha1/services/metastore_service/transports/rest.py +++ b/packages/google-cloud-bigquery-biglake/google/cloud/bigquery_biglake_v1alpha1/services/metastore_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, @@ -216,8 +224,10 @@ def post_update_table(self, response): """ def pre_check_lock( - self, request: metastore.CheckLockRequest, metadata: Sequence[Tuple[str, str]] - ) -> Tuple[metastore.CheckLockRequest, Sequence[Tuple[str, str]]]: + self, + request: metastore.CheckLockRequest, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[metastore.CheckLockRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for check_lock Override in a subclass to manipulate the request or metadata @@ -237,8 +247,8 @@ def post_check_lock(self, response: metastore.Lock) -> metastore.Lock: def pre_create_catalog( self, request: metastore.CreateCatalogRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[metastore.CreateCatalogRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[metastore.CreateCatalogRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for create_catalog Override in a subclass to manipulate the request or metadata @@ -258,8 +268,10 @@ def post_create_catalog(self, response: metastore.Catalog) -> metastore.Catalog: def pre_create_database( self, request: metastore.CreateDatabaseRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[metastore.CreateDatabaseRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + metastore.CreateDatabaseRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for create_database Override in a subclass to manipulate the request or metadata @@ -277,8 +289,10 @@ def post_create_database(self, response: metastore.Database) -> metastore.Databa return response def pre_create_lock( - self, request: metastore.CreateLockRequest, metadata: Sequence[Tuple[str, str]] - ) -> Tuple[metastore.CreateLockRequest, Sequence[Tuple[str, str]]]: + self, + request: metastore.CreateLockRequest, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[metastore.CreateLockRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for create_lock Override in a subclass to manipulate the request or metadata @@ -296,8 +310,10 @@ def post_create_lock(self, response: metastore.Lock) -> metastore.Lock: return response def pre_create_table( - self, request: metastore.CreateTableRequest, metadata: Sequence[Tuple[str, str]] - ) -> Tuple[metastore.CreateTableRequest, Sequence[Tuple[str, str]]]: + self, + request: metastore.CreateTableRequest, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[metastore.CreateTableRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for create_table Override in a subclass to manipulate the request or metadata @@ -317,8 +333,8 @@ def post_create_table(self, response: metastore.Table) -> metastore.Table: def pre_delete_catalog( self, request: metastore.DeleteCatalogRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[metastore.DeleteCatalogRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[metastore.DeleteCatalogRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for delete_catalog Override in a subclass to manipulate the request or metadata @@ -338,8 +354,10 @@ def post_delete_catalog(self, response: metastore.Catalog) -> metastore.Catalog: def pre_delete_database( self, request: metastore.DeleteDatabaseRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[metastore.DeleteDatabaseRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + metastore.DeleteDatabaseRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for delete_database Override in a subclass to manipulate the request or metadata @@ -357,8 +375,10 @@ def post_delete_database(self, response: metastore.Database) -> metastore.Databa return response def pre_delete_lock( - self, request: metastore.DeleteLockRequest, metadata: Sequence[Tuple[str, str]] - ) -> Tuple[metastore.DeleteLockRequest, Sequence[Tuple[str, str]]]: + self, + request: metastore.DeleteLockRequest, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[metastore.DeleteLockRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for delete_lock Override in a subclass to manipulate the request or metadata @@ -367,8 +387,10 @@ def pre_delete_lock( return request, metadata def pre_delete_table( - self, request: metastore.DeleteTableRequest, metadata: Sequence[Tuple[str, str]] - ) -> Tuple[metastore.DeleteTableRequest, Sequence[Tuple[str, str]]]: + self, + request: metastore.DeleteTableRequest, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[metastore.DeleteTableRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for delete_table Override in a subclass to manipulate the request or metadata @@ -386,8 +408,10 @@ def post_delete_table(self, response: metastore.Table) -> metastore.Table: return response def pre_get_catalog( - self, request: metastore.GetCatalogRequest, metadata: Sequence[Tuple[str, str]] - ) -> Tuple[metastore.GetCatalogRequest, Sequence[Tuple[str, str]]]: + self, + request: metastore.GetCatalogRequest, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[metastore.GetCatalogRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for get_catalog Override in a subclass to manipulate the request or metadata @@ -405,8 +429,10 @@ def post_get_catalog(self, response: metastore.Catalog) -> metastore.Catalog: return response def pre_get_database( - self, request: metastore.GetDatabaseRequest, metadata: Sequence[Tuple[str, str]] - ) -> Tuple[metastore.GetDatabaseRequest, Sequence[Tuple[str, str]]]: + self, + request: metastore.GetDatabaseRequest, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[metastore.GetDatabaseRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for get_database Override in a subclass to manipulate the request or metadata @@ -424,8 +450,10 @@ def post_get_database(self, response: metastore.Database) -> metastore.Database: return response def pre_get_table( - self, request: metastore.GetTableRequest, metadata: Sequence[Tuple[str, str]] - ) -> Tuple[metastore.GetTableRequest, Sequence[Tuple[str, str]]]: + self, + request: metastore.GetTableRequest, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[metastore.GetTableRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for get_table Override in a subclass to manipulate the request or metadata @@ -445,8 +473,8 @@ def post_get_table(self, response: metastore.Table) -> metastore.Table: def pre_list_catalogs( self, request: metastore.ListCatalogsRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[metastore.ListCatalogsRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[metastore.ListCatalogsRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for list_catalogs Override in a subclass to manipulate the request or metadata @@ -468,8 +496,8 @@ def post_list_catalogs( def pre_list_databases( self, request: metastore.ListDatabasesRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[metastore.ListDatabasesRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[metastore.ListDatabasesRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for list_databases Override in a subclass to manipulate the request or metadata @@ -489,8 +517,10 @@ def post_list_databases( return response def pre_list_locks( - self, request: metastore.ListLocksRequest, metadata: Sequence[Tuple[str, str]] - ) -> Tuple[metastore.ListLocksRequest, Sequence[Tuple[str, str]]]: + self, + request: metastore.ListLocksRequest, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[metastore.ListLocksRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for list_locks Override in a subclass to manipulate the request or metadata @@ -510,8 +540,10 @@ def post_list_locks( return response def pre_list_tables( - self, request: metastore.ListTablesRequest, metadata: Sequence[Tuple[str, str]] - ) -> Tuple[metastore.ListTablesRequest, Sequence[Tuple[str, str]]]: + self, + request: metastore.ListTablesRequest, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[metastore.ListTablesRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for list_tables Override in a subclass to manipulate the request or metadata @@ -531,8 +563,10 @@ def post_list_tables( return response def pre_rename_table( - self, request: metastore.RenameTableRequest, metadata: Sequence[Tuple[str, str]] - ) -> Tuple[metastore.RenameTableRequest, Sequence[Tuple[str, str]]]: + self, + request: metastore.RenameTableRequest, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[metastore.RenameTableRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for rename_table Override in a subclass to manipulate the request or metadata @@ -552,8 +586,10 @@ def post_rename_table(self, response: metastore.Table) -> metastore.Table: def pre_update_database( self, request: metastore.UpdateDatabaseRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[metastore.UpdateDatabaseRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + metastore.UpdateDatabaseRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for update_database Override in a subclass to manipulate the request or metadata @@ -571,8 +607,10 @@ def post_update_database(self, response: metastore.Database) -> metastore.Databa return response def pre_update_table( - self, request: metastore.UpdateTableRequest, metadata: Sequence[Tuple[str, str]] - ) -> Tuple[metastore.UpdateTableRequest, Sequence[Tuple[str, str]]]: + self, + request: metastore.UpdateTableRequest, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[metastore.UpdateTableRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for update_table Override in a subclass to manipulate the request or metadata @@ -721,7 +759,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> metastore.Lock: r"""Call the check lock method over HTTP. @@ -732,8 +770,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.metastore.Lock: @@ -743,6 +783,7 @@ def __call__( http_options = ( _BaseMetastoreServiceRestTransport._BaseCheckLock._get_http_options() ) + request, metadata = self._interceptor.pre_check_lock(request, metadata) transcoded_request = _BaseMetastoreServiceRestTransport._BaseCheckLock._get_transcoded_request( http_options, request @@ -757,6 +798,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.bigquery.biglake_v1alpha1.MetastoreServiceClient.CheckLock", + extra={ + "serviceName": "google.cloud.bigquery.biglake.v1alpha1.MetastoreService", + "rpcName": "CheckLock", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = MetastoreServiceRestTransport._CheckLock._get_response( self._host, @@ -778,7 +846,29 @@ def __call__( pb_resp = metastore.Lock.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_check_lock(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = metastore.Lock.to_json(response) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.bigquery.biglake_v1alpha1.MetastoreServiceClient.check_lock", + extra={ + "serviceName": "google.cloud.bigquery.biglake.v1alpha1.MetastoreService", + "rpcName": "CheckLock", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _CreateCatalog( @@ -816,7 +906,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> metastore.Catalog: r"""Call the create catalog method over HTTP. @@ -827,8 +917,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.metastore.Catalog: @@ -840,6 +932,7 @@ def __call__( http_options = ( _BaseMetastoreServiceRestTransport._BaseCreateCatalog._get_http_options() ) + request, metadata = self._interceptor.pre_create_catalog(request, metadata) transcoded_request = _BaseMetastoreServiceRestTransport._BaseCreateCatalog._get_transcoded_request( http_options, request @@ -854,6 +947,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.bigquery.biglake_v1alpha1.MetastoreServiceClient.CreateCatalog", + extra={ + "serviceName": "google.cloud.bigquery.biglake.v1alpha1.MetastoreService", + "rpcName": "CreateCatalog", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = MetastoreServiceRestTransport._CreateCatalog._get_response( self._host, @@ -875,7 +995,29 @@ def __call__( pb_resp = metastore.Catalog.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_create_catalog(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = metastore.Catalog.to_json(response) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.bigquery.biglake_v1alpha1.MetastoreServiceClient.create_catalog", + extra={ + "serviceName": "google.cloud.bigquery.biglake.v1alpha1.MetastoreService", + "rpcName": "CreateCatalog", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _CreateDatabase( @@ -913,7 +1055,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> metastore.Database: r"""Call the create database method over HTTP. @@ -924,8 +1066,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.metastore.Database: @@ -935,6 +1079,7 @@ def __call__( http_options = ( _BaseMetastoreServiceRestTransport._BaseCreateDatabase._get_http_options() ) + request, metadata = self._interceptor.pre_create_database(request, metadata) transcoded_request = _BaseMetastoreServiceRestTransport._BaseCreateDatabase._get_transcoded_request( http_options, request @@ -949,6 +1094,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.bigquery.biglake_v1alpha1.MetastoreServiceClient.CreateDatabase", + extra={ + "serviceName": "google.cloud.bigquery.biglake.v1alpha1.MetastoreService", + "rpcName": "CreateDatabase", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = MetastoreServiceRestTransport._CreateDatabase._get_response( self._host, @@ -970,7 +1142,29 @@ def __call__( pb_resp = metastore.Database.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_create_database(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = metastore.Database.to_json(response) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.bigquery.biglake_v1alpha1.MetastoreServiceClient.create_database", + extra={ + "serviceName": "google.cloud.bigquery.biglake.v1alpha1.MetastoreService", + "rpcName": "CreateDatabase", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _CreateLock( @@ -1008,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]]] = (), ) -> metastore.Lock: r"""Call the create lock method over HTTP. @@ -1019,8 +1213,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.metastore.Lock: @@ -1030,6 +1226,7 @@ def __call__( http_options = ( _BaseMetastoreServiceRestTransport._BaseCreateLock._get_http_options() ) + request, metadata = self._interceptor.pre_create_lock(request, metadata) transcoded_request = _BaseMetastoreServiceRestTransport._BaseCreateLock._get_transcoded_request( http_options, request @@ -1044,6 +1241,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.bigquery.biglake_v1alpha1.MetastoreServiceClient.CreateLock", + extra={ + "serviceName": "google.cloud.bigquery.biglake.v1alpha1.MetastoreService", + "rpcName": "CreateLock", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = MetastoreServiceRestTransport._CreateLock._get_response( self._host, @@ -1065,7 +1289,29 @@ def __call__( pb_resp = metastore.Lock.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_create_lock(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = metastore.Lock.to_json(response) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.bigquery.biglake_v1alpha1.MetastoreServiceClient.create_lock", + extra={ + "serviceName": "google.cloud.bigquery.biglake.v1alpha1.MetastoreService", + "rpcName": "CreateLock", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _CreateTable( @@ -1103,7 +1349,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> metastore.Table: r"""Call the create table method over HTTP. @@ -1114,8 +1360,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.metastore.Table: @@ -1125,6 +1373,7 @@ def __call__( http_options = ( _BaseMetastoreServiceRestTransport._BaseCreateTable._get_http_options() ) + request, metadata = self._interceptor.pre_create_table(request, metadata) transcoded_request = _BaseMetastoreServiceRestTransport._BaseCreateTable._get_transcoded_request( http_options, request @@ -1139,6 +1388,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.bigquery.biglake_v1alpha1.MetastoreServiceClient.CreateTable", + extra={ + "serviceName": "google.cloud.bigquery.biglake.v1alpha1.MetastoreService", + "rpcName": "CreateTable", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = MetastoreServiceRestTransport._CreateTable._get_response( self._host, @@ -1160,7 +1436,29 @@ def __call__( pb_resp = metastore.Table.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_create_table(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = metastore.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.cloud.bigquery.biglake_v1alpha1.MetastoreServiceClient.create_table", + extra={ + "serviceName": "google.cloud.bigquery.biglake.v1alpha1.MetastoreService", + "rpcName": "CreateTable", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _DeleteCatalog( @@ -1197,7 +1495,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> metastore.Catalog: r"""Call the delete catalog method over HTTP. @@ -1208,8 +1506,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.metastore.Catalog: @@ -1221,6 +1521,7 @@ def __call__( http_options = ( _BaseMetastoreServiceRestTransport._BaseDeleteCatalog._get_http_options() ) + request, metadata = self._interceptor.pre_delete_catalog(request, metadata) transcoded_request = _BaseMetastoreServiceRestTransport._BaseDeleteCatalog._get_transcoded_request( http_options, request @@ -1231,6 +1532,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.bigquery.biglake_v1alpha1.MetastoreServiceClient.DeleteCatalog", + extra={ + "serviceName": "google.cloud.bigquery.biglake.v1alpha1.MetastoreService", + "rpcName": "DeleteCatalog", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = MetastoreServiceRestTransport._DeleteCatalog._get_response( self._host, @@ -1251,7 +1579,29 @@ def __call__( pb_resp = metastore.Catalog.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_delete_catalog(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = metastore.Catalog.to_json(response) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.bigquery.biglake_v1alpha1.MetastoreServiceClient.delete_catalog", + extra={ + "serviceName": "google.cloud.bigquery.biglake.v1alpha1.MetastoreService", + "rpcName": "DeleteCatalog", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _DeleteDatabase( @@ -1288,7 +1638,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> metastore.Database: r"""Call the delete database method over HTTP. @@ -1299,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: ~.metastore.Database: @@ -1310,6 +1662,7 @@ def __call__( http_options = ( _BaseMetastoreServiceRestTransport._BaseDeleteDatabase._get_http_options() ) + request, metadata = self._interceptor.pre_delete_database(request, metadata) transcoded_request = _BaseMetastoreServiceRestTransport._BaseDeleteDatabase._get_transcoded_request( http_options, request @@ -1320,6 +1673,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.bigquery.biglake_v1alpha1.MetastoreServiceClient.DeleteDatabase", + extra={ + "serviceName": "google.cloud.bigquery.biglake.v1alpha1.MetastoreService", + "rpcName": "DeleteDatabase", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = MetastoreServiceRestTransport._DeleteDatabase._get_response( self._host, @@ -1340,7 +1720,29 @@ def __call__( pb_resp = metastore.Database.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_delete_database(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = metastore.Database.to_json(response) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.bigquery.biglake_v1alpha1.MetastoreServiceClient.delete_database", + extra={ + "serviceName": "google.cloud.bigquery.biglake.v1alpha1.MetastoreService", + "rpcName": "DeleteDatabase", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _DeleteLock( @@ -1377,7 +1779,7 @@ 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 lock method over HTTP. @@ -1388,13 +1790,16 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. """ http_options = ( _BaseMetastoreServiceRestTransport._BaseDeleteLock._get_http_options() ) + request, metadata = self._interceptor.pre_delete_lock(request, metadata) transcoded_request = _BaseMetastoreServiceRestTransport._BaseDeleteLock._get_transcoded_request( http_options, request @@ -1405,6 +1810,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.bigquery.biglake_v1alpha1.MetastoreServiceClient.DeleteLock", + extra={ + "serviceName": "google.cloud.bigquery.biglake.v1alpha1.MetastoreService", + "rpcName": "DeleteLock", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = MetastoreServiceRestTransport._DeleteLock._get_response( self._host, @@ -1454,7 +1886,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> metastore.Table: r"""Call the delete table method over HTTP. @@ -1465,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: ~.metastore.Table: @@ -1476,6 +1910,7 @@ def __call__( http_options = ( _BaseMetastoreServiceRestTransport._BaseDeleteTable._get_http_options() ) + request, metadata = self._interceptor.pre_delete_table(request, metadata) transcoded_request = _BaseMetastoreServiceRestTransport._BaseDeleteTable._get_transcoded_request( http_options, request @@ -1486,6 +1921,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.bigquery.biglake_v1alpha1.MetastoreServiceClient.DeleteTable", + extra={ + "serviceName": "google.cloud.bigquery.biglake.v1alpha1.MetastoreService", + "rpcName": "DeleteTable", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = MetastoreServiceRestTransport._DeleteTable._get_response( self._host, @@ -1506,7 +1968,29 @@ def __call__( pb_resp = metastore.Table.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_delete_table(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = metastore.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.cloud.bigquery.biglake_v1alpha1.MetastoreServiceClient.delete_table", + extra={ + "serviceName": "google.cloud.bigquery.biglake.v1alpha1.MetastoreService", + "rpcName": "DeleteTable", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _GetCatalog( @@ -1543,7 +2027,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> metastore.Catalog: r"""Call the get catalog method over HTTP. @@ -1554,8 +2038,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.metastore.Catalog: @@ -1567,6 +2053,7 @@ def __call__( http_options = ( _BaseMetastoreServiceRestTransport._BaseGetCatalog._get_http_options() ) + request, metadata = self._interceptor.pre_get_catalog(request, metadata) transcoded_request = _BaseMetastoreServiceRestTransport._BaseGetCatalog._get_transcoded_request( http_options, request @@ -1577,6 +2064,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.bigquery.biglake_v1alpha1.MetastoreServiceClient.GetCatalog", + extra={ + "serviceName": "google.cloud.bigquery.biglake.v1alpha1.MetastoreService", + "rpcName": "GetCatalog", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = MetastoreServiceRestTransport._GetCatalog._get_response( self._host, @@ -1597,7 +2111,29 @@ def __call__( pb_resp = metastore.Catalog.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_catalog(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = metastore.Catalog.to_json(response) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.bigquery.biglake_v1alpha1.MetastoreServiceClient.get_catalog", + extra={ + "serviceName": "google.cloud.bigquery.biglake.v1alpha1.MetastoreService", + "rpcName": "GetCatalog", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _GetDatabase( @@ -1634,7 +2170,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> metastore.Database: r"""Call the get database method over HTTP. @@ -1645,8 +2181,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.metastore.Database: @@ -1656,6 +2194,7 @@ def __call__( http_options = ( _BaseMetastoreServiceRestTransport._BaseGetDatabase._get_http_options() ) + request, metadata = self._interceptor.pre_get_database(request, metadata) transcoded_request = _BaseMetastoreServiceRestTransport._BaseGetDatabase._get_transcoded_request( http_options, request @@ -1666,6 +2205,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.bigquery.biglake_v1alpha1.MetastoreServiceClient.GetDatabase", + extra={ + "serviceName": "google.cloud.bigquery.biglake.v1alpha1.MetastoreService", + "rpcName": "GetDatabase", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = MetastoreServiceRestTransport._GetDatabase._get_response( self._host, @@ -1686,7 +2252,29 @@ def __call__( pb_resp = metastore.Database.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_database(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = metastore.Database.to_json(response) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.bigquery.biglake_v1alpha1.MetastoreServiceClient.get_database", + extra={ + "serviceName": "google.cloud.bigquery.biglake.v1alpha1.MetastoreService", + "rpcName": "GetDatabase", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _GetTable( @@ -1723,7 +2311,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> metastore.Table: r"""Call the get table method over HTTP. @@ -1734,8 +2322,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.metastore.Table: @@ -1745,6 +2335,7 @@ def __call__( http_options = ( _BaseMetastoreServiceRestTransport._BaseGetTable._get_http_options() ) + request, metadata = self._interceptor.pre_get_table(request, metadata) transcoded_request = _BaseMetastoreServiceRestTransport._BaseGetTable._get_transcoded_request( http_options, request @@ -1757,6 +2348,33 @@ def __call__( ) ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.bigquery.biglake_v1alpha1.MetastoreServiceClient.GetTable", + extra={ + "serviceName": "google.cloud.bigquery.biglake.v1alpha1.MetastoreService", + "rpcName": "GetTable", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = MetastoreServiceRestTransport._GetTable._get_response( self._host, @@ -1777,7 +2395,29 @@ def __call__( pb_resp = metastore.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 = metastore.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.cloud.bigquery.biglake_v1alpha1.MetastoreServiceClient.get_table", + extra={ + "serviceName": "google.cloud.bigquery.biglake.v1alpha1.MetastoreService", + "rpcName": "GetTable", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ListCatalogs( @@ -1814,7 +2454,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> metastore.ListCatalogsResponse: r"""Call the list catalogs method over HTTP. @@ -1825,8 +2465,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.metastore.ListCatalogsResponse: @@ -1838,6 +2480,7 @@ def __call__( http_options = ( _BaseMetastoreServiceRestTransport._BaseListCatalogs._get_http_options() ) + request, metadata = self._interceptor.pre_list_catalogs(request, metadata) transcoded_request = _BaseMetastoreServiceRestTransport._BaseListCatalogs._get_transcoded_request( http_options, request @@ -1848,6 +2491,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.bigquery.biglake_v1alpha1.MetastoreServiceClient.ListCatalogs", + extra={ + "serviceName": "google.cloud.bigquery.biglake.v1alpha1.MetastoreService", + "rpcName": "ListCatalogs", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = MetastoreServiceRestTransport._ListCatalogs._get_response( self._host, @@ -1868,7 +2538,29 @@ def __call__( pb_resp = metastore.ListCatalogsResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_catalogs(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = metastore.ListCatalogsResponse.to_json(response) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.bigquery.biglake_v1alpha1.MetastoreServiceClient.list_catalogs", + extra={ + "serviceName": "google.cloud.bigquery.biglake.v1alpha1.MetastoreService", + "rpcName": "ListCatalogs", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ListDatabases( @@ -1905,7 +2597,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> metastore.ListDatabasesResponse: r"""Call the list databases method over HTTP. @@ -1916,8 +2608,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.metastore.ListDatabasesResponse: @@ -1929,6 +2623,7 @@ def __call__( http_options = ( _BaseMetastoreServiceRestTransport._BaseListDatabases._get_http_options() ) + request, metadata = self._interceptor.pre_list_databases(request, metadata) transcoded_request = _BaseMetastoreServiceRestTransport._BaseListDatabases._get_transcoded_request( http_options, request @@ -1939,6 +2634,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.bigquery.biglake_v1alpha1.MetastoreServiceClient.ListDatabases", + extra={ + "serviceName": "google.cloud.bigquery.biglake.v1alpha1.MetastoreService", + "rpcName": "ListDatabases", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = MetastoreServiceRestTransport._ListDatabases._get_response( self._host, @@ -1959,7 +2681,29 @@ def __call__( pb_resp = metastore.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 = metastore.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.bigquery.biglake_v1alpha1.MetastoreServiceClient.list_databases", + extra={ + "serviceName": "google.cloud.bigquery.biglake.v1alpha1.MetastoreService", + "rpcName": "ListDatabases", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ListLocks( @@ -1996,7 +2740,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> metastore.ListLocksResponse: r"""Call the list locks method over HTTP. @@ -2007,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: ~.metastore.ListLocksResponse: @@ -2020,6 +2766,7 @@ def __call__( http_options = ( _BaseMetastoreServiceRestTransport._BaseListLocks._get_http_options() ) + request, metadata = self._interceptor.pre_list_locks(request, metadata) transcoded_request = _BaseMetastoreServiceRestTransport._BaseListLocks._get_transcoded_request( http_options, request @@ -2030,6 +2777,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.bigquery.biglake_v1alpha1.MetastoreServiceClient.ListLocks", + extra={ + "serviceName": "google.cloud.bigquery.biglake.v1alpha1.MetastoreService", + "rpcName": "ListLocks", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = MetastoreServiceRestTransport._ListLocks._get_response( self._host, @@ -2050,7 +2824,29 @@ def __call__( pb_resp = metastore.ListLocksResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_locks(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = metastore.ListLocksResponse.to_json(response) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.bigquery.biglake_v1alpha1.MetastoreServiceClient.list_locks", + extra={ + "serviceName": "google.cloud.bigquery.biglake.v1alpha1.MetastoreService", + "rpcName": "ListLocks", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ListTables( @@ -2087,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]]] = (), ) -> metastore.ListTablesResponse: r"""Call the list tables method over HTTP. @@ -2098,8 +2894,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.metastore.ListTablesResponse: @@ -2111,6 +2909,7 @@ def __call__( http_options = ( _BaseMetastoreServiceRestTransport._BaseListTables._get_http_options() ) + request, metadata = self._interceptor.pre_list_tables(request, metadata) transcoded_request = _BaseMetastoreServiceRestTransport._BaseListTables._get_transcoded_request( http_options, request @@ -2121,6 +2920,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.bigquery.biglake_v1alpha1.MetastoreServiceClient.ListTables", + extra={ + "serviceName": "google.cloud.bigquery.biglake.v1alpha1.MetastoreService", + "rpcName": "ListTables", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = MetastoreServiceRestTransport._ListTables._get_response( self._host, @@ -2141,7 +2967,29 @@ def __call__( pb_resp = metastore.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 = metastore.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.cloud.bigquery.biglake_v1alpha1.MetastoreServiceClient.list_tables", + extra={ + "serviceName": "google.cloud.bigquery.biglake.v1alpha1.MetastoreService", + "rpcName": "ListTables", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _RenameTable( @@ -2179,7 +3027,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> metastore.Table: r"""Call the rename table method over HTTP. @@ -2190,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: ~.metastore.Table: @@ -2201,6 +3051,7 @@ def __call__( http_options = ( _BaseMetastoreServiceRestTransport._BaseRenameTable._get_http_options() ) + request, metadata = self._interceptor.pre_rename_table(request, metadata) transcoded_request = _BaseMetastoreServiceRestTransport._BaseRenameTable._get_transcoded_request( http_options, request @@ -2215,6 +3066,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.bigquery.biglake_v1alpha1.MetastoreServiceClient.RenameTable", + extra={ + "serviceName": "google.cloud.bigquery.biglake.v1alpha1.MetastoreService", + "rpcName": "RenameTable", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = MetastoreServiceRestTransport._RenameTable._get_response( self._host, @@ -2236,7 +3114,29 @@ def __call__( pb_resp = metastore.Table.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_rename_table(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = metastore.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.cloud.bigquery.biglake_v1alpha1.MetastoreServiceClient.rename_table", + extra={ + "serviceName": "google.cloud.bigquery.biglake.v1alpha1.MetastoreService", + "rpcName": "RenameTable", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _UpdateDatabase( @@ -2274,7 +3174,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> metastore.Database: r"""Call the update database method over HTTP. @@ -2285,8 +3185,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.metastore.Database: @@ -2296,6 +3198,7 @@ def __call__( http_options = ( _BaseMetastoreServiceRestTransport._BaseUpdateDatabase._get_http_options() ) + request, metadata = self._interceptor.pre_update_database(request, metadata) transcoded_request = _BaseMetastoreServiceRestTransport._BaseUpdateDatabase._get_transcoded_request( http_options, request @@ -2310,6 +3213,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.bigquery.biglake_v1alpha1.MetastoreServiceClient.UpdateDatabase", + extra={ + "serviceName": "google.cloud.bigquery.biglake.v1alpha1.MetastoreService", + "rpcName": "UpdateDatabase", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = MetastoreServiceRestTransport._UpdateDatabase._get_response( self._host, @@ -2331,7 +3261,29 @@ def __call__( pb_resp = metastore.Database.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_update_database(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = metastore.Database.to_json(response) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.bigquery.biglake_v1alpha1.MetastoreServiceClient.update_database", + extra={ + "serviceName": "google.cloud.bigquery.biglake.v1alpha1.MetastoreService", + "rpcName": "UpdateDatabase", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _UpdateTable( @@ -2369,7 +3321,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> metastore.Table: r"""Call the update table method over HTTP. @@ -2380,8 +3332,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.metastore.Table: @@ -2391,6 +3345,7 @@ def __call__( http_options = ( _BaseMetastoreServiceRestTransport._BaseUpdateTable._get_http_options() ) + request, metadata = self._interceptor.pre_update_table(request, metadata) transcoded_request = _BaseMetastoreServiceRestTransport._BaseUpdateTable._get_transcoded_request( http_options, request @@ -2405,6 +3360,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.bigquery.biglake_v1alpha1.MetastoreServiceClient.UpdateTable", + extra={ + "serviceName": "google.cloud.bigquery.biglake.v1alpha1.MetastoreService", + "rpcName": "UpdateTable", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = MetastoreServiceRestTransport._UpdateTable._get_response( self._host, @@ -2426,7 +3408,29 @@ def __call__( pb_resp = metastore.Table.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_update_table(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = metastore.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.cloud.bigquery.biglake_v1alpha1.MetastoreServiceClient.update_table", + extra={ + "serviceName": "google.cloud.bigquery.biglake.v1alpha1.MetastoreService", + "rpcName": "UpdateTable", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp @property diff --git a/packages/google-cloud-bigquery-biglake/samples/generated_samples/snippet_metadata_google.cloud.bigquery.biglake.v1.json b/packages/google-cloud-bigquery-biglake/samples/generated_samples/snippet_metadata_google.cloud.bigquery.biglake.v1.json index a32c80dfc1c9..73ac8861a130 100644 --- a/packages/google-cloud-bigquery-biglake/samples/generated_samples/snippet_metadata_google.cloud.bigquery.biglake.v1.json +++ b/packages/google-cloud-bigquery-biglake/samples/generated_samples/snippet_metadata_google.cloud.bigquery.biglake.v1.json @@ -8,7 +8,7 @@ ], "language": "PYTHON", "name": "google-cloud-bigquery-biglake", - "version": "0.4.11" + "version": "0.1.0" }, "snippets": [ { @@ -55,7 +55,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.bigquery_biglake_v1.types.Catalog", @@ -143,7 +143,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.bigquery_biglake_v1.types.Catalog", @@ -232,7 +232,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.bigquery_biglake_v1.types.Database", @@ -320,7 +320,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.bigquery_biglake_v1.types.Database", @@ -409,7 +409,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.bigquery_biglake_v1.types.Table", @@ -497,7 +497,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.bigquery_biglake_v1.types.Table", @@ -578,7 +578,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.bigquery_biglake_v1.types.Catalog", @@ -658,7 +658,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.bigquery_biglake_v1.types.Catalog", @@ -739,7 +739,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.bigquery_biglake_v1.types.Database", @@ -819,7 +819,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.bigquery_biglake_v1.types.Database", @@ -900,7 +900,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.bigquery_biglake_v1.types.Table", @@ -980,7 +980,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.bigquery_biglake_v1.types.Table", @@ -1061,7 +1061,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.bigquery_biglake_v1.types.Catalog", @@ -1141,7 +1141,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.bigquery_biglake_v1.types.Catalog", @@ -1222,7 +1222,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.bigquery_biglake_v1.types.Database", @@ -1302,7 +1302,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.bigquery_biglake_v1.types.Database", @@ -1383,7 +1383,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.bigquery_biglake_v1.types.Table", @@ -1463,7 +1463,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.bigquery_biglake_v1.types.Table", @@ -1544,7 +1544,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.bigquery_biglake_v1.services.metastore_service.pagers.ListCatalogsAsyncPager", @@ -1624,7 +1624,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.bigquery_biglake_v1.services.metastore_service.pagers.ListCatalogsPager", @@ -1705,7 +1705,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.bigquery_biglake_v1.services.metastore_service.pagers.ListDatabasesAsyncPager", @@ -1785,7 +1785,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.bigquery_biglake_v1.services.metastore_service.pagers.ListDatabasesPager", @@ -1866,7 +1866,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.bigquery_biglake_v1.services.metastore_service.pagers.ListTablesAsyncPager", @@ -1946,7 +1946,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.bigquery_biglake_v1.services.metastore_service.pagers.ListTablesPager", @@ -2031,7 +2031,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.bigquery_biglake_v1.types.Table", @@ -2115,7 +2115,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.bigquery_biglake_v1.types.Table", @@ -2200,7 +2200,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.bigquery_biglake_v1.types.Database", @@ -2284,7 +2284,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.bigquery_biglake_v1.types.Database", @@ -2369,7 +2369,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.bigquery_biglake_v1.types.Table", @@ -2453,7 +2453,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.bigquery_biglake_v1.types.Table", diff --git a/packages/google-cloud-bigquery-biglake/samples/generated_samples/snippet_metadata_google.cloud.bigquery.biglake.v1alpha1.json b/packages/google-cloud-bigquery-biglake/samples/generated_samples/snippet_metadata_google.cloud.bigquery.biglake.v1alpha1.json index 9125bc437013..69294cf144a2 100644 --- a/packages/google-cloud-bigquery-biglake/samples/generated_samples/snippet_metadata_google.cloud.bigquery.biglake.v1alpha1.json +++ b/packages/google-cloud-bigquery-biglake/samples/generated_samples/snippet_metadata_google.cloud.bigquery.biglake.v1alpha1.json @@ -8,7 +8,7 @@ ], "language": "PYTHON", "name": "google-cloud-bigquery-biglake", - "version": "0.4.11" + "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.bigquery_biglake_v1alpha1.types.Lock", @@ -127,7 +127,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.bigquery_biglake_v1alpha1.types.Lock", @@ -216,7 +216,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.bigquery_biglake_v1alpha1.types.Catalog", @@ -304,7 +304,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.bigquery_biglake_v1alpha1.types.Catalog", @@ -393,7 +393,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.bigquery_biglake_v1alpha1.types.Database", @@ -481,7 +481,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.bigquery_biglake_v1alpha1.types.Database", @@ -566,7 +566,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.bigquery_biglake_v1alpha1.types.Lock", @@ -650,7 +650,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.bigquery_biglake_v1alpha1.types.Lock", @@ -739,7 +739,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.bigquery_biglake_v1alpha1.types.Table", @@ -827,7 +827,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.bigquery_biglake_v1alpha1.types.Table", @@ -908,7 +908,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.bigquery_biglake_v1alpha1.types.Catalog", @@ -988,7 +988,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.bigquery_biglake_v1alpha1.types.Catalog", @@ -1069,7 +1069,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.bigquery_biglake_v1alpha1.types.Database", @@ -1149,7 +1149,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.bigquery_biglake_v1alpha1.types.Database", @@ -1230,7 +1230,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "shortName": "delete_lock" @@ -1307,7 +1307,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "shortName": "delete_lock" @@ -1385,7 +1385,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.bigquery_biglake_v1alpha1.types.Table", @@ -1465,7 +1465,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.bigquery_biglake_v1alpha1.types.Table", @@ -1546,7 +1546,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.bigquery_biglake_v1alpha1.types.Catalog", @@ -1626,7 +1626,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.bigquery_biglake_v1alpha1.types.Catalog", @@ -1707,7 +1707,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.bigquery_biglake_v1alpha1.types.Database", @@ -1787,7 +1787,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.bigquery_biglake_v1alpha1.types.Database", @@ -1868,7 +1868,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.bigquery_biglake_v1alpha1.types.Table", @@ -1948,7 +1948,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.bigquery_biglake_v1alpha1.types.Table", @@ -2029,7 +2029,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.bigquery_biglake_v1alpha1.services.metastore_service.pagers.ListCatalogsAsyncPager", @@ -2109,7 +2109,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.bigquery_biglake_v1alpha1.services.metastore_service.pagers.ListCatalogsPager", @@ -2190,7 +2190,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.bigquery_biglake_v1alpha1.services.metastore_service.pagers.ListDatabasesAsyncPager", @@ -2270,7 +2270,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.bigquery_biglake_v1alpha1.services.metastore_service.pagers.ListDatabasesPager", @@ -2351,7 +2351,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.bigquery_biglake_v1alpha1.services.metastore_service.pagers.ListLocksAsyncPager", @@ -2431,7 +2431,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.bigquery_biglake_v1alpha1.services.metastore_service.pagers.ListLocksPager", @@ -2512,7 +2512,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.bigquery_biglake_v1alpha1.services.metastore_service.pagers.ListTablesAsyncPager", @@ -2592,7 +2592,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.bigquery_biglake_v1alpha1.services.metastore_service.pagers.ListTablesPager", @@ -2677,7 +2677,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.bigquery_biglake_v1alpha1.types.Table", @@ -2761,7 +2761,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.bigquery_biglake_v1alpha1.types.Table", @@ -2846,7 +2846,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.bigquery_biglake_v1alpha1.types.Database", @@ -2930,7 +2930,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.bigquery_biglake_v1alpha1.types.Database", @@ -3015,7 +3015,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.bigquery_biglake_v1alpha1.types.Table", @@ -3099,7 +3099,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.bigquery_biglake_v1alpha1.types.Table", diff --git a/packages/google-cloud-bigquery-biglake/tests/unit/gapic/bigquery_biglake_v1/test_metastore_service.py b/packages/google-cloud-bigquery-biglake/tests/unit/gapic/bigquery_biglake_v1/test_metastore_service.py index 75a521c0a1f1..798b51c04874 100644 --- a/packages/google-cloud-bigquery-biglake/tests/unit/gapic/bigquery_biglake_v1/test_metastore_service.py +++ b/packages/google-cloud-bigquery-biglake/tests/unit/gapic/bigquery_biglake_v1/test_metastore_service.py @@ -6832,6 +6832,7 @@ def test_create_catalog_rest_required_fields( response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.create_catalog(request) @@ -6894,6 +6895,7 @@ def test_create_catalog_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.create_catalog(**mock_args) @@ -7026,6 +7028,7 @@ def test_delete_catalog_rest_required_fields( response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.delete_catalog(request) @@ -7071,6 +7074,7 @@ def test_delete_catalog_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.delete_catalog(**mock_args) @@ -7199,6 +7203,7 @@ def test_get_catalog_rest_required_fields(request_type=metastore.GetCatalogReque response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.get_catalog(request) @@ -7244,6 +7249,7 @@ def test_get_catalog_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.get_catalog(**mock_args) @@ -7379,6 +7385,7 @@ def test_list_catalogs_rest_required_fields(request_type=metastore.ListCatalogsR response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.list_catalogs(request) @@ -7432,6 +7439,7 @@ def test_list_catalogs_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.list_catalogs(**mock_args) @@ -7633,6 +7641,7 @@ def test_create_database_rest_required_fields( response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.create_database(request) @@ -7701,6 +7710,7 @@ def test_create_database_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.create_database(**mock_args) @@ -7838,6 +7848,7 @@ def test_delete_database_rest_required_fields( response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.delete_database(request) @@ -7885,6 +7896,7 @@ def test_delete_database_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.delete_database(**mock_args) @@ -8014,6 +8026,7 @@ def test_update_database_rest_required_fields( response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.update_database(request) @@ -8068,6 +8081,7 @@ def test_update_database_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.update_database(**mock_args) @@ -8202,6 +8216,7 @@ def test_get_database_rest_required_fields(request_type=metastore.GetDatabaseReq response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.get_database(request) @@ -8249,6 +8264,7 @@ def test_get_database_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.get_database(**mock_args) @@ -8387,6 +8403,7 @@ def test_list_databases_rest_required_fields( response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.list_databases(request) @@ -8442,6 +8459,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) @@ -8644,6 +8662,7 @@ def test_create_table_rest_required_fields(request_type=metastore.CreateTableReq response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.create_table(request) @@ -8712,6 +8731,7 @@ def test_create_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.create_table(**mock_args) @@ -8847,6 +8867,7 @@ def test_delete_table_rest_required_fields(request_type=metastore.DeleteTableReq response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.delete_table(request) @@ -8894,6 +8915,7 @@ def test_delete_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.delete_table(**mock_args) @@ -9021,6 +9043,7 @@ def test_update_table_rest_required_fields(request_type=metastore.UpdateTableReq response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.update_table(request) @@ -9075,6 +9098,7 @@ def test_update_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.update_table(**mock_args) @@ -9214,6 +9238,7 @@ def test_rename_table_rest_required_fields(request_type=metastore.RenameTableReq response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.rename_table(request) @@ -9270,6 +9295,7 @@ def test_rename_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.rename_table(**mock_args) @@ -9400,6 +9426,7 @@ def test_get_table_rest_required_fields(request_type=metastore.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) @@ -9447,6 +9474,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) @@ -9584,6 +9612,7 @@ def test_list_tables_rest_required_fields(request_type=metastore.ListTablesReque response_value._content = json_return_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) @@ -9640,6 +9669,7 @@ def test_list_tables_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.list_tables(**mock_args) @@ -10612,6 +10642,7 @@ def test_create_catalog_rest_bad_request(request_type=metastore.CreateCatalogReq response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.create_catalog(request) @@ -10721,6 +10752,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.create_catalog(request) # Establish that the response is the type that we expect. @@ -10759,6 +10791,7 @@ def test_create_catalog_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = metastore.Catalog.to_json(metastore.Catalog()) req.return_value.content = return_value @@ -10801,6 +10834,7 @@ def test_delete_catalog_rest_bad_request(request_type=metastore.DeleteCatalogReq response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.delete_catalog(request) @@ -10836,6 +10870,7 @@ def test_delete_catalog_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.delete_catalog(request) # Establish that the response is the type that we expect. @@ -10874,6 +10909,7 @@ def test_delete_catalog_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = metastore.Catalog.to_json(metastore.Catalog()) req.return_value.content = return_value @@ -10916,6 +10952,7 @@ def test_get_catalog_rest_bad_request(request_type=metastore.GetCatalogRequest): response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.get_catalog(request) @@ -10951,6 +10988,7 @@ def test_get_catalog_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.get_catalog(request) # Establish that the response is the type that we expect. @@ -10989,6 +11027,7 @@ def test_get_catalog_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = metastore.Catalog.to_json(metastore.Catalog()) req.return_value.content = return_value @@ -11031,6 +11070,7 @@ def test_list_catalogs_rest_bad_request(request_type=metastore.ListCatalogsReque response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.list_catalogs(request) @@ -11066,6 +11106,7 @@ def test_list_catalogs_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.list_catalogs(request) # Establish that the response is the type that we expect. @@ -11104,6 +11145,7 @@ def test_list_catalogs_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = metastore.ListCatalogsResponse.to_json( metastore.ListCatalogsResponse() ) @@ -11148,6 +11190,7 @@ def test_create_database_rest_bad_request(request_type=metastore.CreateDatabaseR response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.create_database(request) @@ -11260,6 +11303,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.create_database(request) # Establish that the response is the type that we expect. @@ -11301,6 +11345,7 @@ def test_create_database_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = metastore.Database.to_json(metastore.Database()) req.return_value.content = return_value @@ -11345,6 +11390,7 @@ def test_delete_database_rest_bad_request(request_type=metastore.DeleteDatabaseR response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.delete_database(request) @@ -11383,6 +11429,7 @@ def test_delete_database_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.delete_database(request) # Establish that the response is the type that we expect. @@ -11424,6 +11471,7 @@ def test_delete_database_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = metastore.Database.to_json(metastore.Database()) req.return_value.content = return_value @@ -11470,6 +11518,7 @@ def test_update_database_rest_bad_request(request_type=metastore.UpdateDatabaseR response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.update_database(request) @@ -11586,6 +11635,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.update_database(request) # Establish that the response is the type that we expect. @@ -11627,6 +11677,7 @@ def test_update_database_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = metastore.Database.to_json(metastore.Database()) req.return_value.content = return_value @@ -11671,6 +11722,7 @@ def test_get_database_rest_bad_request(request_type=metastore.GetDatabaseRequest response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.get_database(request) @@ -11709,6 +11761,7 @@ def test_get_database_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.get_database(request) # Establish that the response is the type that we expect. @@ -11748,6 +11801,7 @@ def test_get_database_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = metastore.Database.to_json(metastore.Database()) req.return_value.content = return_value @@ -11790,6 +11844,7 @@ def test_list_databases_rest_bad_request(request_type=metastore.ListDatabasesReq response_value.status_code = 400 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) @@ -11825,6 +11880,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. @@ -11863,6 +11919,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 = metastore.ListDatabasesResponse.to_json( metastore.ListDatabasesResponse() ) @@ -11909,6 +11966,7 @@ def test_create_table_rest_bad_request(request_type=metastore.CreateTableRequest response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.create_table(request) @@ -12034,6 +12092,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.create_table(request) # Establish that the response is the type that we expect. @@ -12074,6 +12133,7 @@ def test_create_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 = metastore.Table.to_json(metastore.Table()) req.return_value.content = return_value @@ -12118,6 +12178,7 @@ def test_delete_table_rest_bad_request(request_type=metastore.DeleteTableRequest response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.delete_table(request) @@ -12157,6 +12218,7 @@ def test_delete_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.delete_table(request) # Establish that the response is the type that we expect. @@ -12197,6 +12259,7 @@ def test_delete_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 = metastore.Table.to_json(metastore.Table()) req.return_value.content = return_value @@ -12243,6 +12306,7 @@ def test_update_table_rest_bad_request(request_type=metastore.UpdateTableRequest response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.update_table(request) @@ -12370,6 +12434,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.update_table(request) # Establish that the response is the type that we expect. @@ -12410,6 +12475,7 @@ def test_update_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 = metastore.Table.to_json(metastore.Table()) req.return_value.content = return_value @@ -12454,6 +12520,7 @@ def test_rename_table_rest_bad_request(request_type=metastore.RenameTableRequest response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.rename_table(request) @@ -12493,6 +12560,7 @@ def test_rename_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.rename_table(request) # Establish that the response is the type that we expect. @@ -12533,6 +12601,7 @@ def test_rename_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 = metastore.Table.to_json(metastore.Table()) req.return_value.content = return_value @@ -12577,6 +12646,7 @@ def test_get_table_rest_bad_request(request_type=metastore.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) @@ -12616,6 +12686,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. @@ -12656,6 +12727,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 = metastore.Table.to_json(metastore.Table()) req.return_value.content = return_value @@ -12700,6 +12772,7 @@ def test_list_tables_rest_bad_request(request_type=metastore.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) @@ -12737,6 +12810,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. @@ -12775,6 +12849,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 = metastore.ListTablesResponse.to_json( metastore.ListTablesResponse() ) diff --git a/packages/google-cloud-bigquery-biglake/tests/unit/gapic/bigquery_biglake_v1alpha1/test_metastore_service.py b/packages/google-cloud-bigquery-biglake/tests/unit/gapic/bigquery_biglake_v1alpha1/test_metastore_service.py index 68237c0ee58a..d65fbaf8c79f 100644 --- a/packages/google-cloud-bigquery-biglake/tests/unit/gapic/bigquery_biglake_v1alpha1/test_metastore_service.py +++ b/packages/google-cloud-bigquery-biglake/tests/unit/gapic/bigquery_biglake_v1alpha1/test_metastore_service.py @@ -8324,6 +8324,7 @@ def test_create_catalog_rest_required_fields( response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.create_catalog(request) @@ -8386,6 +8387,7 @@ def test_create_catalog_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.create_catalog(**mock_args) @@ -8519,6 +8521,7 @@ def test_delete_catalog_rest_required_fields( response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.delete_catalog(request) @@ -8564,6 +8567,7 @@ def test_delete_catalog_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.delete_catalog(**mock_args) @@ -8693,6 +8697,7 @@ def test_get_catalog_rest_required_fields(request_type=metastore.GetCatalogReque response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.get_catalog(request) @@ -8738,6 +8743,7 @@ def test_get_catalog_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.get_catalog(**mock_args) @@ -8874,6 +8880,7 @@ def test_list_catalogs_rest_required_fields(request_type=metastore.ListCatalogsR response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.list_catalogs(request) @@ -8927,6 +8934,7 @@ def test_list_catalogs_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.list_catalogs(**mock_args) @@ -9129,6 +9137,7 @@ def test_create_database_rest_required_fields( response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.create_database(request) @@ -9197,6 +9206,7 @@ def test_create_database_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.create_database(**mock_args) @@ -9334,6 +9344,7 @@ def test_delete_database_rest_required_fields( response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.delete_database(request) @@ -9381,6 +9392,7 @@ def test_delete_database_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.delete_database(**mock_args) @@ -9510,6 +9522,7 @@ def test_update_database_rest_required_fields( response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.update_database(request) @@ -9564,6 +9577,7 @@ def test_update_database_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.update_database(**mock_args) @@ -9698,6 +9712,7 @@ def test_get_database_rest_required_fields(request_type=metastore.GetDatabaseReq response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.get_database(request) @@ -9745,6 +9760,7 @@ def test_get_database_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.get_database(**mock_args) @@ -9883,6 +9899,7 @@ def test_list_databases_rest_required_fields( response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.list_databases(request) @@ -9938,6 +9955,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) @@ -10140,6 +10158,7 @@ def test_create_table_rest_required_fields(request_type=metastore.CreateTableReq response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.create_table(request) @@ -10208,6 +10227,7 @@ def test_create_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.create_table(**mock_args) @@ -10343,6 +10363,7 @@ def test_delete_table_rest_required_fields(request_type=metastore.DeleteTableReq response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.delete_table(request) @@ -10390,6 +10411,7 @@ def test_delete_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.delete_table(**mock_args) @@ -10517,6 +10539,7 @@ def test_update_table_rest_required_fields(request_type=metastore.UpdateTableReq response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.update_table(request) @@ -10571,6 +10594,7 @@ def test_update_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.update_table(**mock_args) @@ -10710,6 +10734,7 @@ def test_rename_table_rest_required_fields(request_type=metastore.RenameTableReq response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.rename_table(request) @@ -10766,6 +10791,7 @@ def test_rename_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.rename_table(**mock_args) @@ -10896,6 +10922,7 @@ def test_get_table_rest_required_fields(request_type=metastore.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) @@ -10943,6 +10970,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) @@ -11080,6 +11108,7 @@ def test_list_tables_rest_required_fields(request_type=metastore.ListTablesReque response_value._content = json_return_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) @@ -11136,6 +11165,7 @@ def test_list_tables_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.list_tables(**mock_args) @@ -11329,6 +11359,7 @@ def test_create_lock_rest_required_fields(request_type=metastore.CreateLockReque response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.create_lock(request) @@ -11385,6 +11416,7 @@ def test_create_lock_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.create_lock(**mock_args) @@ -11512,6 +11544,7 @@ def test_delete_lock_rest_required_fields(request_type=metastore.DeleteLockReque response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.delete_lock(request) @@ -11557,6 +11590,7 @@ def test_delete_lock_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_lock(**mock_args) @@ -11687,6 +11721,7 @@ def test_check_lock_rest_required_fields(request_type=metastore.CheckLockRequest response_value._content = json_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_lock(request) @@ -11734,6 +11769,7 @@ def test_check_lock_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.check_lock(**mock_args) @@ -11870,6 +11906,7 @@ def test_list_locks_rest_required_fields(request_type=metastore.ListLocksRequest response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.list_locks(request) @@ -11925,6 +11962,7 @@ def test_list_locks_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.list_locks(**mock_args) @@ -13089,6 +13127,7 @@ def test_create_catalog_rest_bad_request(request_type=metastore.CreateCatalogReq response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.create_catalog(request) @@ -13198,6 +13237,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.create_catalog(request) # Establish that the response is the type that we expect. @@ -13236,6 +13276,7 @@ def test_create_catalog_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = metastore.Catalog.to_json(metastore.Catalog()) req.return_value.content = return_value @@ -13278,6 +13319,7 @@ def test_delete_catalog_rest_bad_request(request_type=metastore.DeleteCatalogReq response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.delete_catalog(request) @@ -13313,6 +13355,7 @@ def test_delete_catalog_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.delete_catalog(request) # Establish that the response is the type that we expect. @@ -13351,6 +13394,7 @@ def test_delete_catalog_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = metastore.Catalog.to_json(metastore.Catalog()) req.return_value.content = return_value @@ -13393,6 +13437,7 @@ def test_get_catalog_rest_bad_request(request_type=metastore.GetCatalogRequest): response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.get_catalog(request) @@ -13428,6 +13473,7 @@ def test_get_catalog_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.get_catalog(request) # Establish that the response is the type that we expect. @@ -13466,6 +13512,7 @@ def test_get_catalog_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = metastore.Catalog.to_json(metastore.Catalog()) req.return_value.content = return_value @@ -13508,6 +13555,7 @@ def test_list_catalogs_rest_bad_request(request_type=metastore.ListCatalogsReque response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.list_catalogs(request) @@ -13543,6 +13591,7 @@ def test_list_catalogs_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.list_catalogs(request) # Establish that the response is the type that we expect. @@ -13581,6 +13630,7 @@ def test_list_catalogs_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = metastore.ListCatalogsResponse.to_json( metastore.ListCatalogsResponse() ) @@ -13625,6 +13675,7 @@ def test_create_database_rest_bad_request(request_type=metastore.CreateDatabaseR response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.create_database(request) @@ -13737,6 +13788,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.create_database(request) # Establish that the response is the type that we expect. @@ -13778,6 +13830,7 @@ def test_create_database_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = metastore.Database.to_json(metastore.Database()) req.return_value.content = return_value @@ -13822,6 +13875,7 @@ def test_delete_database_rest_bad_request(request_type=metastore.DeleteDatabaseR response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.delete_database(request) @@ -13860,6 +13914,7 @@ def test_delete_database_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.delete_database(request) # Establish that the response is the type that we expect. @@ -13901,6 +13956,7 @@ def test_delete_database_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = metastore.Database.to_json(metastore.Database()) req.return_value.content = return_value @@ -13947,6 +14003,7 @@ def test_update_database_rest_bad_request(request_type=metastore.UpdateDatabaseR response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.update_database(request) @@ -14063,6 +14120,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.update_database(request) # Establish that the response is the type that we expect. @@ -14104,6 +14162,7 @@ def test_update_database_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = metastore.Database.to_json(metastore.Database()) req.return_value.content = return_value @@ -14148,6 +14207,7 @@ def test_get_database_rest_bad_request(request_type=metastore.GetDatabaseRequest response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.get_database(request) @@ -14186,6 +14246,7 @@ def test_get_database_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.get_database(request) # Establish that the response is the type that we expect. @@ -14225,6 +14286,7 @@ def test_get_database_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = metastore.Database.to_json(metastore.Database()) req.return_value.content = return_value @@ -14267,6 +14329,7 @@ def test_list_databases_rest_bad_request(request_type=metastore.ListDatabasesReq response_value.status_code = 400 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) @@ -14302,6 +14365,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. @@ -14340,6 +14404,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 = metastore.ListDatabasesResponse.to_json( metastore.ListDatabasesResponse() ) @@ -14386,6 +14451,7 @@ def test_create_table_rest_bad_request(request_type=metastore.CreateTableRequest response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.create_table(request) @@ -14511,6 +14577,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.create_table(request) # Establish that the response is the type that we expect. @@ -14551,6 +14618,7 @@ def test_create_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 = metastore.Table.to_json(metastore.Table()) req.return_value.content = return_value @@ -14595,6 +14663,7 @@ def test_delete_table_rest_bad_request(request_type=metastore.DeleteTableRequest response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.delete_table(request) @@ -14634,6 +14703,7 @@ def test_delete_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.delete_table(request) # Establish that the response is the type that we expect. @@ -14674,6 +14744,7 @@ def test_delete_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 = metastore.Table.to_json(metastore.Table()) req.return_value.content = return_value @@ -14720,6 +14791,7 @@ def test_update_table_rest_bad_request(request_type=metastore.UpdateTableRequest response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.update_table(request) @@ -14847,6 +14919,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.update_table(request) # Establish that the response is the type that we expect. @@ -14887,6 +14960,7 @@ def test_update_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 = metastore.Table.to_json(metastore.Table()) req.return_value.content = return_value @@ -14931,6 +15005,7 @@ def test_rename_table_rest_bad_request(request_type=metastore.RenameTableRequest response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.rename_table(request) @@ -14970,6 +15045,7 @@ def test_rename_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.rename_table(request) # Establish that the response is the type that we expect. @@ -15010,6 +15086,7 @@ def test_rename_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 = metastore.Table.to_json(metastore.Table()) req.return_value.content = return_value @@ -15054,6 +15131,7 @@ def test_get_table_rest_bad_request(request_type=metastore.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) @@ -15093,6 +15171,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. @@ -15133,6 +15212,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 = metastore.Table.to_json(metastore.Table()) req.return_value.content = return_value @@ -15177,6 +15257,7 @@ def test_list_tables_rest_bad_request(request_type=metastore.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) @@ -15214,6 +15295,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. @@ -15252,6 +15334,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 = metastore.ListTablesResponse.to_json( metastore.ListTablesResponse() ) @@ -15298,6 +15381,7 @@ def test_create_lock_rest_bad_request(request_type=metastore.CreateLockRequest): response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.create_lock(request) @@ -15412,6 +15496,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.create_lock(request) # Establish that the response is the type that we expect. @@ -15452,6 +15537,7 @@ def test_create_lock_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = metastore.Lock.to_json(metastore.Lock()) req.return_value.content = return_value @@ -15496,6 +15582,7 @@ def test_delete_lock_rest_bad_request(request_type=metastore.DeleteLockRequest): response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.delete_lock(request) @@ -15528,6 +15615,7 @@ def test_delete_lock_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_lock(request) # Establish that the response is the type that we expect. @@ -15562,6 +15650,7 @@ def test_delete_lock_rest_interceptors(null_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 = metastore.DeleteLockRequest() metadata = [ @@ -15602,6 +15691,7 @@ def test_check_lock_rest_bad_request(request_type=metastore.CheckLockRequest): response_value.status_code = 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_lock(request) @@ -15642,6 +15732,7 @@ def test_check_lock_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_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_lock(request) # Establish that the response is the type that we expect. @@ -15682,6 +15773,7 @@ def test_check_lock_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = metastore.Lock.to_json(metastore.Lock()) req.return_value.content = return_value @@ -15726,6 +15818,7 @@ def test_list_locks_rest_bad_request(request_type=metastore.ListLocksRequest): response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.list_locks(request) @@ -15763,6 +15856,7 @@ def test_list_locks_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.list_locks(request) # Establish that the response is the type that we expect. @@ -15801,6 +15895,7 @@ def test_list_locks_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = metastore.ListLocksResponse.to_json( metastore.ListLocksResponse() ) diff --git a/packages/google-cloud-bigquery-connection/google/cloud/bigquery_connection/gapic_version.py b/packages/google-cloud-bigquery-connection/google/cloud/bigquery_connection/gapic_version.py index b6e92d4eebd5..558c8aab67c5 100644 --- a/packages/google-cloud-bigquery-connection/google/cloud/bigquery_connection/gapic_version.py +++ b/packages/google-cloud-bigquery-connection/google/cloud/bigquery_connection/gapic_version.py @@ -13,4 +13,4 @@ # See the License for the specific language governing permissions and # limitations under the License. # -__version__ = "1.16.1" # {x-release-please-version} +__version__ = "0.0.0" # {x-release-please-version} diff --git a/packages/google-cloud-bigquery-connection/google/cloud/bigquery_connection_v1/gapic_version.py b/packages/google-cloud-bigquery-connection/google/cloud/bigquery_connection_v1/gapic_version.py index b6e92d4eebd5..558c8aab67c5 100644 --- a/packages/google-cloud-bigquery-connection/google/cloud/bigquery_connection_v1/gapic_version.py +++ b/packages/google-cloud-bigquery-connection/google/cloud/bigquery_connection_v1/gapic_version.py @@ -13,4 +13,4 @@ # See the License for the specific language governing permissions and # limitations under the License. # -__version__ = "1.16.1" # {x-release-please-version} +__version__ = "0.0.0" # {x-release-please-version} diff --git a/packages/google-cloud-bigquery-connection/google/cloud/bigquery_connection_v1/services/connection_service/async_client.py b/packages/google-cloud-bigquery-connection/google/cloud/bigquery_connection_v1/services/connection_service/async_client.py index 9aef76185375..dd8d371931a5 100644 --- a/packages/google-cloud-bigquery-connection/google/cloud/bigquery_connection_v1/services/connection_service/async_client.py +++ b/packages/google-cloud-bigquery-connection/google/cloud/bigquery_connection_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, @@ -54,6 +55,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: """Manages external data source connections and credentials.""" @@ -267,6 +277,28 @@ def __init__( client_info=client_info, ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + std_logging.DEBUG + ): # pragma: NO COVER + _LOGGER.debug( + "Created client `google.cloud.bigquery.connection_v1.ConnectionServiceAsyncClient`.", + extra={ + "serviceName": "google.cloud.bigquery.connection.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.bigquery.connection.v1.ConnectionService", + "credentialsType": None, + }, + ) + async def create_connection( self, request: Optional[Union[gcbc_connection.CreateConnectionRequest, dict]] = None, @@ -276,7 +308,7 @@ async def create_connection( connection_id: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> gcbc_connection.Connection: r"""Creates a new connection. @@ -332,8 +364,10 @@ async def sample_create_connection(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.bigquery_connection_v1.types.Connection: @@ -399,7 +433,7 @@ async def get_connection( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> connection.Connection: r"""Returns specified connection. @@ -443,8 +477,10 @@ async def sample_get_connection(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.bigquery_connection_v1.types.Connection: @@ -506,7 +542,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"""Returns a list of connections in the given project. @@ -552,8 +588,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.bigquery_connection_v1.services.connection_service.pagers.ListConnectionsAsyncPager: @@ -630,7 +668,7 @@ async def update_connection( update_mask: Optional[field_mask_pb2.FieldMask] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> gcbc_connection.Connection: r"""Updates the specified connection. For security reasons, also resets credential if connection properties @@ -690,8 +728,10 @@ async def sample_update_connection(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.bigquery_connection_v1.types.Connection: @@ -757,7 +797,7 @@ async def delete_connection( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> None: r"""Deletes connection and associated credential. @@ -798,8 +838,10 @@ async def sample_delete_connection(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. """ # Create or coerce a protobuf request object. # - Quick check: If we got a request object, we should *not* have @@ -851,7 +893,7 @@ async def get_iam_policy( resource: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> policy_pb2.Policy: r"""Gets the access control policy for a resource. Returns an empty policy if the resource exists and does @@ -899,8 +941,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: @@ -986,7 +1030,7 @@ async def set_iam_policy( resource: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> policy_pb2.Policy: r"""Sets the access control policy on the specified resource. Replaces any existing policy. @@ -1036,8 +1080,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: @@ -1124,7 +1170,7 @@ async def test_iam_permissions( permissions: Optional[MutableSequence[str]] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> iam_policy_pb2.TestIamPermissionsResponse: r"""Returns permissions that a caller has on the specified resource. If the resource does not exist, this will return an empty set of @@ -1187,8 +1233,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: diff --git a/packages/google-cloud-bigquery-connection/google/cloud/bigquery_connection_v1/services/connection_service/client.py b/packages/google-cloud-bigquery-connection/google/cloud/bigquery_connection_v1/services/connection_service/client.py index f13986e90deb..950ac661c269 100644 --- a/packages/google-cloud-bigquery-connection/google/cloud/bigquery_connection_v1/services/connection_service/client.py +++ b/packages/google-cloud-bigquery-connection/google/cloud/bigquery_connection_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.iam.v1 import iam_policy_pb2 # type: ignore from google.iam.v1 import policy_pb2 # type: ignore from google.protobuf import field_mask_pb2 # type: ignore @@ -633,6 +643,10 @@ def __init__( # Initialize the universe domain validation. self._is_universe_domain_valid = False + if CLIENT_LOGGING_SUPPORTED: # pragma: NO COVER + # Setup logging. + client_logging.initialize_logging() + api_key_value = getattr(self._client_options, "api_key", None) if api_key_value and credentials: raise ValueError( @@ -699,6 +713,29 @@ def __init__( api_audience=self._client_options.api_audience, ) + if "async" not in str(self._transport): + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + std_logging.DEBUG + ): # pragma: NO COVER + _LOGGER.debug( + "Created client `google.cloud.bigquery.connection_v1.ConnectionServiceClient`.", + extra={ + "serviceName": "google.cloud.bigquery.connection.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.bigquery.connection.v1.ConnectionService", + "credentialsType": None, + }, + ) + def create_connection( self, request: Optional[Union[gcbc_connection.CreateConnectionRequest, dict]] = None, @@ -708,7 +745,7 @@ def create_connection( connection_id: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> gcbc_connection.Connection: r"""Creates a new connection. @@ -764,8 +801,10 @@ def sample_create_connection(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.bigquery_connection_v1.types.Connection: @@ -828,7 +867,7 @@ def get_connection( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> connection.Connection: r"""Returns specified connection. @@ -872,8 +911,10 @@ def sample_get_connection(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.bigquery_connection_v1.types.Connection: @@ -932,7 +973,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"""Returns a list of connections in the given project. @@ -978,8 +1019,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.bigquery_connection_v1.services.connection_service.pagers.ListConnectionsPager: @@ -1053,7 +1096,7 @@ def update_connection( update_mask: Optional[field_mask_pb2.FieldMask] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> gcbc_connection.Connection: r"""Updates the specified connection. For security reasons, also resets credential if connection properties @@ -1113,8 +1156,10 @@ def sample_update_connection(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.bigquery_connection_v1.types.Connection: @@ -1177,7 +1222,7 @@ def delete_connection( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> None: r"""Deletes connection and associated credential. @@ -1218,8 +1263,10 @@ def sample_delete_connection(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. """ # Create or coerce a protobuf request object. # - Quick check: If we got a request object, we should *not* have @@ -1268,7 +1315,7 @@ def get_iam_policy( resource: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> policy_pb2.Policy: r"""Gets the access control policy for a resource. Returns an empty policy if the resource exists and does @@ -1316,8 +1363,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: @@ -1404,7 +1453,7 @@ def set_iam_policy( resource: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> policy_pb2.Policy: r"""Sets the access control policy on the specified resource. Replaces any existing policy. @@ -1454,8 +1503,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: @@ -1543,7 +1594,7 @@ def test_iam_permissions( permissions: Optional[MutableSequence[str]] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> iam_policy_pb2.TestIamPermissionsResponse: r"""Returns permissions that a caller has on the specified resource. If the resource does not exist, this will return an empty set of @@ -1606,8 +1657,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: diff --git a/packages/google-cloud-bigquery-connection/google/cloud/bigquery_connection_v1/services/connection_service/pagers.py b/packages/google-cloud-bigquery-connection/google/cloud/bigquery_connection_v1/services/connection_service/pagers.py index fc5612931971..ce93e3a81a97 100644 --- a/packages/google-cloud-bigquery-connection/google/cloud/bigquery_connection_v1/services/connection_service/pagers.py +++ b/packages/google-cloud-bigquery-connection/google/cloud/bigquery_connection_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-bigquery-connection/google/cloud/bigquery_connection_v1/services/connection_service/transports/grpc.py b/packages/google-cloud-bigquery-connection/google/cloud/bigquery_connection_v1/services/connection_service/transports/grpc.py index a5e302bf78bf..f29f9ef4a0e2 100644 --- a/packages/google-cloud-bigquery-connection/google/cloud/bigquery_connection_v1/services/connection_service/transports/grpc.py +++ b/packages/google-cloud-bigquery-connection/google/cloud/bigquery_connection_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 @@ -23,13 +26,91 @@ from google.iam.v1 import iam_policy_pb2 # type: ignore from google.iam.v1 import policy_pb2 # type: ignore from google.protobuf import empty_pb2 # type: ignore +from google.protobuf.json_format import MessageToJson +import google.protobuf.message import grpc # type: ignore +import proto # type: ignore from google.cloud.bigquery_connection_v1.types import connection as gcbc_connection from google.cloud.bigquery_connection_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.bigquery.connection.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.bigquery.connection.v1.ConnectionService", + "rpcName": client_call_details.method, + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class ConnectionServiceGrpcTransport(ConnectionServiceTransport): """gRPC backend transport for ConnectionService. @@ -183,7 +264,12 @@ def __init__( ], ) - # Wrap messages. This must be done after self._grpc_channel exists + self._interceptor = _LoggingClientInterceptor() + self._logged_channel = grpc.intercept_channel( + self._grpc_channel, self._interceptor + ) + + # Wrap messages. This must be done after self._logged_channel exists self._prep_wrapped_messages(client_info) @classmethod @@ -259,7 +345,7 @@ def create_connection( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_connection" not in self._stubs: - self._stubs["create_connection"] = self.grpc_channel.unary_unary( + self._stubs["create_connection"] = self._logged_channel.unary_unary( "/google.cloud.bigquery.connection.v1.ConnectionService/CreateConnection", request_serializer=gcbc_connection.CreateConnectionRequest.serialize, response_deserializer=gcbc_connection.Connection.deserialize, @@ -285,7 +371,7 @@ def get_connection( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_connection" not in self._stubs: - self._stubs["get_connection"] = self.grpc_channel.unary_unary( + self._stubs["get_connection"] = self._logged_channel.unary_unary( "/google.cloud.bigquery.connection.v1.ConnectionService/GetConnection", request_serializer=connection.GetConnectionRequest.serialize, response_deserializer=connection.Connection.deserialize, @@ -313,7 +399,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.bigquery.connection.v1.ConnectionService/ListConnections", request_serializer=connection.ListConnectionsRequest.serialize, response_deserializer=connection.ListConnectionsResponse.deserialize, @@ -343,7 +429,7 @@ def update_connection( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_connection" not in self._stubs: - self._stubs["update_connection"] = self.grpc_channel.unary_unary( + self._stubs["update_connection"] = self._logged_channel.unary_unary( "/google.cloud.bigquery.connection.v1.ConnectionService/UpdateConnection", request_serializer=gcbc_connection.UpdateConnectionRequest.serialize, response_deserializer=gcbc_connection.Connection.deserialize, @@ -369,7 +455,7 @@ def delete_connection( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_connection" not in self._stubs: - self._stubs["delete_connection"] = self.grpc_channel.unary_unary( + self._stubs["delete_connection"] = self._logged_channel.unary_unary( "/google.cloud.bigquery.connection.v1.ConnectionService/DeleteConnection", request_serializer=connection.DeleteConnectionRequest.serialize, response_deserializer=empty_pb2.Empty.FromString, @@ -397,7 +483,7 @@ def get_iam_policy( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_iam_policy" not in self._stubs: - self._stubs["get_iam_policy"] = self.grpc_channel.unary_unary( + self._stubs["get_iam_policy"] = self._logged_channel.unary_unary( "/google.cloud.bigquery.connection.v1.ConnectionService/GetIamPolicy", request_serializer=iam_policy_pb2.GetIamPolicyRequest.SerializeToString, response_deserializer=policy_pb2.Policy.FromString, @@ -427,7 +513,7 @@ def set_iam_policy( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "set_iam_policy" not in self._stubs: - self._stubs["set_iam_policy"] = self.grpc_channel.unary_unary( + self._stubs["set_iam_policy"] = self._logged_channel.unary_unary( "/google.cloud.bigquery.connection.v1.ConnectionService/SetIamPolicy", request_serializer=iam_policy_pb2.SetIamPolicyRequest.SerializeToString, response_deserializer=policy_pb2.Policy.FromString, @@ -463,7 +549,7 @@ def test_iam_permissions( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "test_iam_permissions" not in self._stubs: - self._stubs["test_iam_permissions"] = self.grpc_channel.unary_unary( + self._stubs["test_iam_permissions"] = self._logged_channel.unary_unary( "/google.cloud.bigquery.connection.v1.ConnectionService/TestIamPermissions", request_serializer=iam_policy_pb2.TestIamPermissionsRequest.SerializeToString, response_deserializer=iam_policy_pb2.TestIamPermissionsResponse.FromString, @@ -471,7 +557,7 @@ def test_iam_permissions( return self._stubs["test_iam_permissions"] def close(self): - self.grpc_channel.close() + self._logged_channel.close() @property def kind(self) -> str: diff --git a/packages/google-cloud-bigquery-connection/google/cloud/bigquery_connection_v1/services/connection_service/transports/grpc_asyncio.py b/packages/google-cloud-bigquery-connection/google/cloud/bigquery_connection_v1/services/connection_service/transports/grpc_asyncio.py index dfd1fd679ce2..574be4ce2262 100644 --- a/packages/google-cloud-bigquery-connection/google/cloud/bigquery_connection_v1/services/connection_service/transports/grpc_asyncio.py +++ b/packages/google-cloud-bigquery-connection/google/cloud/bigquery_connection_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 @@ -25,8 +28,11 @@ from google.iam.v1 import iam_policy_pb2 # type: ignore from google.iam.v1 import policy_pb2 # type: ignore from google.protobuf import empty_pb2 # type: ignore +from google.protobuf.json_format import MessageToJson +import google.protobuf.message import grpc # type: ignore from grpc.experimental import aio # type: ignore +import proto # type: ignore from google.cloud.bigquery_connection_v1.types import connection as gcbc_connection from google.cloud.bigquery_connection_v1.types import connection @@ -34,6 +40,82 @@ 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.bigquery.connection.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.bigquery.connection.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. @@ -230,10 +312,13 @@ def __init__( ], ) - # Wrap messages. This must be done after self._grpc_channel exists + self._interceptor = _LoggingClientAIOInterceptor() + self._grpc_channel._unary_unary_interceptors.append(self._interceptor) + self._logged_channel = self._grpc_channel self._wrap_with_kind = ( "kind" in inspect.signature(gapic_v1.method_async.wrap_method).parameters ) + # Wrap messages. This must be done after self._logged_channel exists self._prep_wrapped_messages(client_info) @property @@ -267,7 +352,7 @@ def create_connection( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_connection" not in self._stubs: - self._stubs["create_connection"] = self.grpc_channel.unary_unary( + self._stubs["create_connection"] = self._logged_channel.unary_unary( "/google.cloud.bigquery.connection.v1.ConnectionService/CreateConnection", request_serializer=gcbc_connection.CreateConnectionRequest.serialize, response_deserializer=gcbc_connection.Connection.deserialize, @@ -293,7 +378,7 @@ def get_connection( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_connection" not in self._stubs: - self._stubs["get_connection"] = self.grpc_channel.unary_unary( + self._stubs["get_connection"] = self._logged_channel.unary_unary( "/google.cloud.bigquery.connection.v1.ConnectionService/GetConnection", request_serializer=connection.GetConnectionRequest.serialize, response_deserializer=connection.Connection.deserialize, @@ -322,7 +407,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.bigquery.connection.v1.ConnectionService/ListConnections", request_serializer=connection.ListConnectionsRequest.serialize, response_deserializer=connection.ListConnectionsResponse.deserialize, @@ -352,7 +437,7 @@ def update_connection( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_connection" not in self._stubs: - self._stubs["update_connection"] = self.grpc_channel.unary_unary( + self._stubs["update_connection"] = self._logged_channel.unary_unary( "/google.cloud.bigquery.connection.v1.ConnectionService/UpdateConnection", request_serializer=gcbc_connection.UpdateConnectionRequest.serialize, response_deserializer=gcbc_connection.Connection.deserialize, @@ -378,7 +463,7 @@ def delete_connection( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_connection" not in self._stubs: - self._stubs["delete_connection"] = self.grpc_channel.unary_unary( + self._stubs["delete_connection"] = self._logged_channel.unary_unary( "/google.cloud.bigquery.connection.v1.ConnectionService/DeleteConnection", request_serializer=connection.DeleteConnectionRequest.serialize, response_deserializer=empty_pb2.Empty.FromString, @@ -406,7 +491,7 @@ def get_iam_policy( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_iam_policy" not in self._stubs: - self._stubs["get_iam_policy"] = self.grpc_channel.unary_unary( + self._stubs["get_iam_policy"] = self._logged_channel.unary_unary( "/google.cloud.bigquery.connection.v1.ConnectionService/GetIamPolicy", request_serializer=iam_policy_pb2.GetIamPolicyRequest.SerializeToString, response_deserializer=policy_pb2.Policy.FromString, @@ -436,7 +521,7 @@ def set_iam_policy( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "set_iam_policy" not in self._stubs: - self._stubs["set_iam_policy"] = self.grpc_channel.unary_unary( + self._stubs["set_iam_policy"] = self._logged_channel.unary_unary( "/google.cloud.bigquery.connection.v1.ConnectionService/SetIamPolicy", request_serializer=iam_policy_pb2.SetIamPolicyRequest.SerializeToString, response_deserializer=policy_pb2.Policy.FromString, @@ -472,7 +557,7 @@ def test_iam_permissions( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "test_iam_permissions" not in self._stubs: - self._stubs["test_iam_permissions"] = self.grpc_channel.unary_unary( + self._stubs["test_iam_permissions"] = self._logged_channel.unary_unary( "/google.cloud.bigquery.connection.v1.ConnectionService/TestIamPermissions", request_serializer=iam_policy_pb2.TestIamPermissionsRequest.SerializeToString, response_deserializer=iam_policy_pb2.TestIamPermissionsResponse.FromString, @@ -560,7 +645,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-bigquery-connection/google/cloud/bigquery_connection_v1/services/connection_service/transports/rest.py b/packages/google-cloud-bigquery-connection/google/cloud/bigquery_connection_v1/services/connection_service/transports/rest.py index 917f6acd7f96..2653641a1c2d 100644 --- a/packages/google-cloud-bigquery-connection/google/cloud/bigquery_connection_v1/services/connection_service/transports/rest.py +++ b/packages/google-cloud-bigquery-connection/google/cloud/bigquery_connection_v1/services/connection_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, @@ -133,8 +141,10 @@ def post_update_connection(self, response): def pre_create_connection( self, request: gcbc_connection.CreateConnectionRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[gcbc_connection.CreateConnectionRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + gcbc_connection.CreateConnectionRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for create_connection Override in a subclass to manipulate the request or metadata @@ -156,8 +166,10 @@ def post_create_connection( def pre_delete_connection( self, request: connection.DeleteConnectionRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[connection.DeleteConnectionRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + connection.DeleteConnectionRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for delete_connection Override in a subclass to manipulate the request or metadata @@ -168,8 +180,10 @@ def pre_delete_connection( def pre_get_connection( self, request: connection.GetConnectionRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[connection.GetConnectionRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + connection.GetConnectionRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for get_connection Override in a subclass to manipulate the request or metadata @@ -191,8 +205,10 @@ def post_get_connection( 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 @@ -212,8 +228,10 @@ def post_get_iam_policy(self, response: policy_pb2.Policy) -> policy_pb2.Policy: def pre_list_connections( self, request: connection.ListConnectionsRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[connection.ListConnectionsRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + connection.ListConnectionsRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for list_connections Override in a subclass to manipulate the request or metadata @@ -235,8 +253,10 @@ def post_list_connections( 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 @@ -256,8 +276,11 @@ def post_set_iam_policy(self, response: policy_pb2.Policy) -> policy_pb2.Policy: def pre_test_iam_permissions( self, request: iam_policy_pb2.TestIamPermissionsRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[iam_policy_pb2.TestIamPermissionsRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + iam_policy_pb2.TestIamPermissionsRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for test_iam_permissions Override in a subclass to manipulate the request or metadata @@ -279,8 +302,10 @@ def post_test_iam_permissions( def pre_update_connection( self, request: gcbc_connection.UpdateConnectionRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[gcbc_connection.UpdateConnectionRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + gcbc_connection.UpdateConnectionRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for update_connection Override in a subclass to manipulate the request or metadata @@ -422,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]]] = (), ) -> gcbc_connection.Connection: r"""Call the create connection method over HTTP. @@ -433,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: ~.gcbc_connection.Connection: @@ -447,6 +474,7 @@ def __call__( http_options = ( _BaseConnectionServiceRestTransport._BaseCreateConnection._get_http_options() ) + request, metadata = self._interceptor.pre_create_connection( request, metadata ) @@ -463,6 +491,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.bigquery.connection_v1.ConnectionServiceClient.CreateConnection", + extra={ + "serviceName": "google.cloud.bigquery.connection.v1.ConnectionService", + "rpcName": "CreateConnection", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ConnectionServiceRestTransport._CreateConnection._get_response( self._host, @@ -484,7 +539,29 @@ def __call__( pb_resp = gcbc_connection.Connection.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_create_connection(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = gcbc_connection.Connection.to_json(response) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.bigquery.connection_v1.ConnectionServiceClient.create_connection", + extra={ + "serviceName": "google.cloud.bigquery.connection.v1.ConnectionService", + "rpcName": "CreateConnection", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _DeleteConnection( @@ -522,7 +599,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ): r"""Call the delete connection method over HTTP. @@ -533,13 +610,16 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. """ http_options = ( _BaseConnectionServiceRestTransport._BaseDeleteConnection._get_http_options() ) + request, metadata = self._interceptor.pre_delete_connection( request, metadata ) @@ -552,6 +632,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.bigquery.connection_v1.ConnectionServiceClient.DeleteConnection", + extra={ + "serviceName": "google.cloud.bigquery.connection.v1.ConnectionService", + "rpcName": "DeleteConnection", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ConnectionServiceRestTransport._DeleteConnection._get_response( self._host, @@ -602,7 +709,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> connection.Connection: r"""Call the get connection method over HTTP. @@ -613,8 +720,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.connection.Connection: @@ -627,6 +736,7 @@ def __call__( http_options = ( _BaseConnectionServiceRestTransport._BaseGetConnection._get_http_options() ) + request, metadata = self._interceptor.pre_get_connection(request, metadata) transcoded_request = _BaseConnectionServiceRestTransport._BaseGetConnection._get_transcoded_request( http_options, request @@ -637,6 +747,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.bigquery.connection_v1.ConnectionServiceClient.GetConnection", + extra={ + "serviceName": "google.cloud.bigquery.connection.v1.ConnectionService", + "rpcName": "GetConnection", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ConnectionServiceRestTransport._GetConnection._get_response( self._host, @@ -657,7 +794,29 @@ def __call__( pb_resp = connection.Connection.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_connection(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = connection.Connection.to_json(response) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.bigquery.connection_v1.ConnectionServiceClient.get_connection", + extra={ + "serviceName": "google.cloud.bigquery.connection.v1.ConnectionService", + "rpcName": "GetConnection", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _GetIamPolicy( @@ -695,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]]] = (), ) -> policy_pb2.Policy: r"""Call the get iam policy method over HTTP. @@ -705,8 +864,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.policy_pb2.Policy: @@ -791,6 +952,7 @@ def __call__( http_options = ( _BaseConnectionServiceRestTransport._BaseGetIamPolicy._get_http_options() ) + request, metadata = self._interceptor.pre_get_iam_policy(request, metadata) transcoded_request = _BaseConnectionServiceRestTransport._BaseGetIamPolicy._get_transcoded_request( http_options, request @@ -805,6 +967,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.bigquery.connection_v1.ConnectionServiceClient.GetIamPolicy", + extra={ + "serviceName": "google.cloud.bigquery.connection.v1.ConnectionService", + "rpcName": "GetIamPolicy", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ConnectionServiceRestTransport._GetIamPolicy._get_response( self._host, @@ -826,7 +1015,29 @@ def __call__( pb_resp = resp json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_iam_policy(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = json_format.MessageToJson(resp) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.bigquery.connection_v1.ConnectionServiceClient.get_iam_policy", + extra={ + "serviceName": "google.cloud.bigquery.connection.v1.ConnectionService", + "rpcName": "GetIamPolicy", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ListConnections( @@ -864,7 +1075,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> connection.ListConnectionsResponse: r"""Call the list connections method over HTTP. @@ -875,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: ~.connection.ListConnectionsResponse: @@ -888,6 +1101,7 @@ def __call__( http_options = ( _BaseConnectionServiceRestTransport._BaseListConnections._get_http_options() ) + request, metadata = self._interceptor.pre_list_connections( request, metadata ) @@ -900,6 +1114,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.bigquery.connection_v1.ConnectionServiceClient.ListConnections", + extra={ + "serviceName": "google.cloud.bigquery.connection.v1.ConnectionService", + "rpcName": "ListConnections", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ConnectionServiceRestTransport._ListConnections._get_response( self._host, @@ -920,7 +1161,31 @@ def __call__( pb_resp = connection.ListConnectionsResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_connections(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = connection.ListConnectionsResponse.to_json( + response + ) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.bigquery.connection_v1.ConnectionServiceClient.list_connections", + extra={ + "serviceName": "google.cloud.bigquery.connection.v1.ConnectionService", + "rpcName": "ListConnections", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _SetIamPolicy( @@ -958,7 +1223,7 @@ 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. @@ -968,8 +1233,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.policy_pb2.Policy: @@ -1054,6 +1321,7 @@ def __call__( http_options = ( _BaseConnectionServiceRestTransport._BaseSetIamPolicy._get_http_options() ) + request, metadata = self._interceptor.pre_set_iam_policy(request, metadata) transcoded_request = _BaseConnectionServiceRestTransport._BaseSetIamPolicy._get_transcoded_request( http_options, request @@ -1068,6 +1336,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.bigquery.connection_v1.ConnectionServiceClient.SetIamPolicy", + extra={ + "serviceName": "google.cloud.bigquery.connection.v1.ConnectionService", + "rpcName": "SetIamPolicy", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ConnectionServiceRestTransport._SetIamPolicy._get_response( self._host, @@ -1089,7 +1384,29 @@ def __call__( pb_resp = resp json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_set_iam_policy(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = json_format.MessageToJson(resp) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.bigquery.connection_v1.ConnectionServiceClient.set_iam_policy", + extra={ + "serviceName": "google.cloud.bigquery.connection.v1.ConnectionService", + "rpcName": "SetIamPolicy", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _TestIamPermissions( @@ -1128,7 +1445,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> iam_policy_pb2.TestIamPermissionsResponse: r"""Call the test iam permissions method over HTTP. @@ -1138,8 +1455,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each 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: @@ -1149,6 +1468,7 @@ def __call__( http_options = ( _BaseConnectionServiceRestTransport._BaseTestIamPermissions._get_http_options() ) + request, metadata = self._interceptor.pre_test_iam_permissions( request, metadata ) @@ -1165,6 +1485,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.bigquery.connection_v1.ConnectionServiceClient.TestIamPermissions", + extra={ + "serviceName": "google.cloud.bigquery.connection.v1.ConnectionService", + "rpcName": "TestIamPermissions", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ConnectionServiceRestTransport._TestIamPermissions._get_response( self._host, @@ -1186,7 +1533,29 @@ def __call__( pb_resp = resp json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_test_iam_permissions(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = json_format.MessageToJson(resp) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.bigquery.connection_v1.ConnectionServiceClient.test_iam_permissions", + extra={ + "serviceName": "google.cloud.bigquery.connection.v1.ConnectionService", + "rpcName": "TestIamPermissions", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _UpdateConnection( @@ -1225,7 +1594,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> gcbc_connection.Connection: r"""Call the update connection method over HTTP. @@ -1236,8 +1605,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.gcbc_connection.Connection: @@ -1250,6 +1621,7 @@ def __call__( http_options = ( _BaseConnectionServiceRestTransport._BaseUpdateConnection._get_http_options() ) + request, metadata = self._interceptor.pre_update_connection( request, metadata ) @@ -1266,6 +1638,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.bigquery.connection_v1.ConnectionServiceClient.UpdateConnection", + extra={ + "serviceName": "google.cloud.bigquery.connection.v1.ConnectionService", + "rpcName": "UpdateConnection", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ConnectionServiceRestTransport._UpdateConnection._get_response( self._host, @@ -1287,7 +1686,29 @@ def __call__( pb_resp = gcbc_connection.Connection.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_update_connection(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = gcbc_connection.Connection.to_json(response) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.bigquery.connection_v1.ConnectionServiceClient.update_connection", + extra={ + "serviceName": "google.cloud.bigquery.connection.v1.ConnectionService", + "rpcName": "UpdateConnection", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp @property diff --git a/packages/google-cloud-bigquery-connection/samples/generated_samples/snippet_metadata_google.cloud.bigquery.connection.v1.json b/packages/google-cloud-bigquery-connection/samples/generated_samples/snippet_metadata_google.cloud.bigquery.connection.v1.json index b942d3e38505..a25b5a29d478 100644 --- a/packages/google-cloud-bigquery-connection/samples/generated_samples/snippet_metadata_google.cloud.bigquery.connection.v1.json +++ b/packages/google-cloud-bigquery-connection/samples/generated_samples/snippet_metadata_google.cloud.bigquery.connection.v1.json @@ -8,7 +8,7 @@ ], "language": "PYTHON", "name": "google-cloud-bigquery-connection", - "version": "1.16.1" + "version": "0.1.0" }, "snippets": [ { @@ -55,7 +55,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.bigquery_connection_v1.types.Connection", @@ -143,7 +143,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.bigquery_connection_v1.types.Connection", @@ -224,7 +224,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "shortName": "delete_connection" @@ -301,7 +301,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "shortName": "delete_connection" @@ -379,7 +379,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.bigquery_connection_v1.types.Connection", @@ -459,7 +459,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.bigquery_connection_v1.types.Connection", @@ -540,7 +540,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.iam.v1.policy_pb2.Policy", @@ -620,7 +620,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.iam.v1.policy_pb2.Policy", @@ -701,7 +701,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.bigquery_connection_v1.services.connection_service.pagers.ListConnectionsAsyncPager", @@ -781,7 +781,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.bigquery_connection_v1.services.connection_service.pagers.ListConnectionsPager", @@ -862,7 +862,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.iam.v1.policy_pb2.Policy", @@ -942,7 +942,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.iam.v1.policy_pb2.Policy", @@ -1027,7 +1027,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.iam.v1.iam_policy_pb2.TestIamPermissionsResponse", @@ -1111,7 +1111,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.iam.v1.iam_policy_pb2.TestIamPermissionsResponse", @@ -1200,7 +1200,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.bigquery_connection_v1.types.Connection", @@ -1288,7 +1288,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.bigquery_connection_v1.types.Connection", diff --git a/packages/google-cloud-bigquery-connection/tests/unit/gapic/bigquery_connection_v1/test_connection_service.py b/packages/google-cloud-bigquery-connection/tests/unit/gapic/bigquery_connection_v1/test_connection_service.py index b5db651971ac..32ae31cdab79 100644 --- a/packages/google-cloud-bigquery-connection/tests/unit/gapic/bigquery_connection_v1/test_connection_service.py +++ b/packages/google-cloud-bigquery-connection/tests/unit/gapic/bigquery_connection_v1/test_connection_service.py @@ -4219,6 +4219,7 @@ def test_create_connection_rest_required_fields( response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.create_connection(request) @@ -4274,6 +4275,7 @@ def test_create_connection_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.create_connection(**mock_args) @@ -4407,6 +4409,7 @@ def test_get_connection_rest_required_fields( response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.get_connection(request) @@ -4454,6 +4457,7 @@ def test_get_connection_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.get_connection(**mock_args) @@ -4601,6 +4605,7 @@ def test_list_connections_rest_required_fields( response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.list_connections(request) @@ -4665,6 +4670,7 @@ def test_list_connections_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.list_connections(**mock_args) @@ -4864,6 +4870,7 @@ def test_update_connection_rest_required_fields( response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.update_connection(request) @@ -4922,6 +4929,7 @@ def test_update_connection_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.update_connection(**mock_args) @@ -5054,6 +5062,7 @@ def test_delete_connection_rest_required_fields( response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.delete_connection(request) @@ -5099,6 +5108,7 @@ def test_delete_connection_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_connection(**mock_args) @@ -5229,6 +5239,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) @@ -5274,6 +5285,7 @@ def test_get_iam_policy_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.get_iam_policy(**mock_args) @@ -5404,6 +5416,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) @@ -5457,6 +5470,7 @@ def test_set_iam_policy_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.set_iam_policy(**mock_args) @@ -5595,6 +5609,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) @@ -5649,6 +5664,7 @@ def test_test_iam_permissions_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.test_iam_permissions(**mock_args) @@ -6240,6 +6256,7 @@ def test_create_connection_rest_bad_request( response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.create_connection(request) @@ -6405,6 +6422,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.create_connection(request) # Establish that the response is the type that we expect. @@ -6450,6 +6468,7 @@ def test_create_connection_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = gcbc_connection.Connection.to_json(gcbc_connection.Connection()) req.return_value.content = return_value @@ -6492,6 +6511,7 @@ def test_get_connection_rest_bad_request(request_type=connection.GetConnectionRe response_value.status_code = 400 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(request) @@ -6532,6 +6552,7 @@ def test_get_connection_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.get_connection(request) # Establish that the response is the type that we expect. @@ -6577,6 +6598,7 @@ def test_get_connection_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = connection.Connection.to_json(connection.Connection()) req.return_value.content = return_value @@ -6621,6 +6643,7 @@ def test_list_connections_rest_bad_request( response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.list_connections(request) @@ -6656,6 +6679,7 @@ def test_list_connections_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.list_connections(request) # Establish that the response is the type that we expect. @@ -6696,6 +6720,7 @@ def test_list_connections_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = connection.ListConnectionsResponse.to_json( connection.ListConnectionsResponse() ) @@ -6742,6 +6767,7 @@ def test_update_connection_rest_bad_request( response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.update_connection(request) @@ -6907,6 +6933,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.update_connection(request) # Establish that the response is the type that we expect. @@ -6952,6 +6979,7 @@ def test_update_connection_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = gcbc_connection.Connection.to_json(gcbc_connection.Connection()) req.return_value.content = return_value @@ -6996,6 +7024,7 @@ def test_delete_connection_rest_bad_request( response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.delete_connection(request) @@ -7026,6 +7055,7 @@ def test_delete_connection_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_connection(request) # Establish that the response is the type that we expect. @@ -7062,6 +7092,7 @@ def test_delete_connection_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} request = connection.DeleteConnectionRequest() metadata = [ @@ -7104,6 +7135,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) @@ -7139,6 +7171,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. @@ -7178,6 +7211,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 @@ -7224,6 +7258,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) @@ -7259,6 +7294,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. @@ -7298,6 +7334,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 @@ -7344,6 +7381,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) @@ -7378,6 +7416,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. @@ -7416,6 +7455,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() ) diff --git a/packages/google-cloud-bigquery-data-exchange/google/cloud/bigquery_data_exchange/gapic_version.py b/packages/google-cloud-bigquery-data-exchange/google/cloud/bigquery_data_exchange/gapic_version.py index 35c9af734238..558c8aab67c5 100644 --- a/packages/google-cloud-bigquery-data-exchange/google/cloud/bigquery_data_exchange/gapic_version.py +++ b/packages/google-cloud-bigquery-data-exchange/google/cloud/bigquery_data_exchange/gapic_version.py @@ -13,4 +13,4 @@ # See the License for the specific language governing permissions and # limitations under the License. # -__version__ = "0.5.15" # {x-release-please-version} +__version__ = "0.0.0" # {x-release-please-version} diff --git a/packages/google-cloud-bigquery-data-exchange/google/cloud/bigquery_data_exchange_v1beta1/gapic_version.py b/packages/google-cloud-bigquery-data-exchange/google/cloud/bigquery_data_exchange_v1beta1/gapic_version.py index 35c9af734238..558c8aab67c5 100644 --- a/packages/google-cloud-bigquery-data-exchange/google/cloud/bigquery_data_exchange_v1beta1/gapic_version.py +++ b/packages/google-cloud-bigquery-data-exchange/google/cloud/bigquery_data_exchange_v1beta1/gapic_version.py @@ -13,4 +13,4 @@ # See the License for the specific language governing permissions and # limitations under the License. # -__version__ = "0.5.15" # {x-release-please-version} +__version__ = "0.0.0" # {x-release-please-version} diff --git a/packages/google-cloud-bigquery-data-exchange/google/cloud/bigquery_data_exchange_v1beta1/services/analytics_hub_service/async_client.py b/packages/google-cloud-bigquery-data-exchange/google/cloud/bigquery_data_exchange_v1beta1/services/analytics_hub_service/async_client.py index 458fcc3b47fd..98adc9606344 100644 --- a/packages/google-cloud-bigquery-data-exchange/google/cloud/bigquery_data_exchange_v1beta1/services/analytics_hub_service/async_client.py +++ b/packages/google-cloud-bigquery-data-exchange/google/cloud/bigquery_data_exchange_v1beta1/services/analytics_hub_service/async_client.py @@ -14,6 +14,7 @@ # limitations under the License. # from collections import OrderedDict +import logging as std_logging import re from typing import ( Callable, @@ -56,6 +57,15 @@ from .transports.base import DEFAULT_CLIENT_INFO, AnalyticsHubServiceTransport from .transports.grpc_asyncio import AnalyticsHubServiceGrpcAsyncIOTransport +try: + from google.api_core import client_logging # type: ignore + + CLIENT_LOGGING_SUPPORTED = True # pragma: NO COVER +except ImportError: # pragma: NO COVER + CLIENT_LOGGING_SUPPORTED = False + +_LOGGER = std_logging.getLogger(__name__) + class AnalyticsHubServiceAsyncClient: """The ``AnalyticsHubService`` API facilitates data sharing within and @@ -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.bigquery.dataexchange_v1beta1.AnalyticsHubServiceAsyncClient`.", + extra={ + "serviceName": "google.cloud.bigquery.dataexchange.v1beta1.AnalyticsHubService", + "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.bigquery.dataexchange.v1beta1.AnalyticsHubService", + "credentialsType": None, + }, + ) + async def list_data_exchanges( self, request: Optional[Union[dataexchange.ListDataExchangesRequest, dict]] = None, @@ -285,7 +317,7 @@ async def list_data_exchanges( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListDataExchangesAsyncPager: r"""Lists all data exchanges in a given project and location. @@ -331,8 +363,10 @@ async def sample_list_data_exchanges(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.bigquery_data_exchange_v1beta1.services.analytics_hub_service.pagers.ListDataExchangesAsyncPager: @@ -407,7 +441,7 @@ async def list_org_data_exchanges( organization: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListOrgDataExchangesAsyncPager: r"""Lists all data exchanges from projects in a given organization and location. @@ -455,8 +489,10 @@ async def sample_list_org_data_exchanges(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.bigquery_data_exchange_v1beta1.services.analytics_hub_service.pagers.ListOrgDataExchangesAsyncPager: @@ -535,7 +571,7 @@ async def get_data_exchange( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> dataexchange.DataExchange: r"""Gets the details of a data exchange. @@ -578,8 +614,10 @@ async def sample_get_data_exchange(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.bigquery_data_exchange_v1beta1.types.DataExchange: @@ -644,7 +682,7 @@ async def create_data_exchange( data_exchange: Optional[dataexchange.DataExchange] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> dataexchange.DataExchange: r"""Creates a new data exchange. @@ -699,8 +737,10 @@ async def sample_create_data_exchange(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.bigquery_data_exchange_v1beta1.types.DataExchange: @@ -767,7 +807,7 @@ async def update_data_exchange( update_mask: Optional[field_mask_pb2.FieldMask] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> dataexchange.DataExchange: r"""Updates an existing data exchange. @@ -822,8 +862,10 @@ async def sample_update_data_exchange(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.bigquery_data_exchange_v1beta1.types.DataExchange: @@ -891,7 +933,7 @@ async def delete_data_exchange( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> None: r"""Deletes an existing data exchange. @@ -932,8 +974,10 @@ async def sample_delete_data_exchange(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. """ # Create or coerce a protobuf request object. # - Quick check: If we got a request object, we should *not* have @@ -985,7 +1029,7 @@ async def list_listings( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListListingsAsyncPager: r"""Lists all listings in a given project and location. @@ -1030,8 +1074,10 @@ async def sample_list_listings(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.bigquery_data_exchange_v1beta1.services.analytics_hub_service.pagers.ListListingsAsyncPager: @@ -1106,7 +1152,7 @@ async def get_listing( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> dataexchange.Listing: r"""Gets the details of a listing. @@ -1149,8 +1195,10 @@ async def sample_get_listing(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.bigquery_data_exchange_v1beta1.types.Listing: @@ -1216,7 +1264,7 @@ async def create_listing( listing: Optional[dataexchange.Listing] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> dataexchange.Listing: r"""Creates a new listing. @@ -1269,8 +1317,10 @@ async def sample_create_listing(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.bigquery_data_exchange_v1beta1.types.Listing: @@ -1338,7 +1388,7 @@ async def update_listing( update_mask: Optional[field_mask_pb2.FieldMask] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> dataexchange.Listing: r"""Updates an existing listing. @@ -1391,8 +1441,10 @@ async def sample_update_listing(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.bigquery_data_exchange_v1beta1.types.Listing: @@ -1461,7 +1513,7 @@ async def delete_listing( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.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 listing. @@ -1501,8 +1553,10 @@ async def sample_delete_listing(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. """ # Create or coerce a protobuf request object. # - Quick check: If we got a request object, we should *not* have @@ -1554,7 +1608,7 @@ async def subscribe_listing( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> dataexchange.SubscribeListingResponse: r"""Subscribes to a listing. @@ -1610,8 +1664,10 @@ async def sample_subscribe_listing(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.bigquery_data_exchange_v1beta1.types.SubscribeListingResponse: @@ -1671,7 +1727,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. @@ -1708,8 +1764,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: @@ -1785,7 +1843,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 policy. @@ -1822,8 +1880,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: @@ -1899,7 +1959,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"""Returns the permissions that a caller has. @@ -1937,8 +1997,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: @@ -1984,7 +2046,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. @@ -1995,8 +2057,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. @@ -2037,7 +2101,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. @@ -2048,8 +2112,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-bigquery-data-exchange/google/cloud/bigquery_data_exchange_v1beta1/services/analytics_hub_service/client.py b/packages/google-cloud-bigquery-data-exchange/google/cloud/bigquery_data_exchange_v1beta1/services/analytics_hub_service/client.py index a51abb3756e4..e235ef3e16da 100644 --- a/packages/google-cloud-bigquery-data-exchange/google/cloud/bigquery_data_exchange_v1beta1/services/analytics_hub_service/client.py +++ b/packages/google-cloud-bigquery-data-exchange/google/cloud/bigquery_data_exchange_v1beta1/services/analytics_hub_service/client.py @@ -14,6 +14,7 @@ # limitations under the License. # from collections import OrderedDict +import logging as std_logging import os import re from typing import ( @@ -48,6 +49,15 @@ except AttributeError: # pragma: NO COVER OptionalRetry = Union[retries.Retry, object, None] # type: ignore +try: + from google.api_core import client_logging # type: ignore + + CLIENT_LOGGING_SUPPORTED = True # pragma: NO COVER +except ImportError: # pragma: NO COVER + CLIENT_LOGGING_SUPPORTED = False + +_LOGGER = std_logging.getLogger(__name__) + from google.cloud.location import locations_pb2 # type: ignore from google.iam.v1 import iam_policy_pb2 # type: ignore from google.iam.v1 import policy_pb2 # type: ignore @@ -635,6 +645,10 @@ def __init__( # Initialize the universe domain validation. self._is_universe_domain_valid = False + if CLIENT_LOGGING_SUPPORTED: # pragma: NO COVER + # Setup logging. + client_logging.initialize_logging() + api_key_value = getattr(self._client_options, "api_key", None) if api_key_value and credentials: raise ValueError( @@ -701,6 +715,29 @@ def __init__( api_audience=self._client_options.api_audience, ) + if "async" not in str(self._transport): + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + std_logging.DEBUG + ): # pragma: NO COVER + _LOGGER.debug( + "Created client `google.cloud.bigquery.dataexchange_v1beta1.AnalyticsHubServiceClient`.", + extra={ + "serviceName": "google.cloud.bigquery.dataexchange.v1beta1.AnalyticsHubService", + "universeDomain": getattr( + self._transport._credentials, "universe_domain", "" + ), + "credentialsType": f"{type(self._transport._credentials).__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.bigquery.dataexchange.v1beta1.AnalyticsHubService", + "credentialsType": None, + }, + ) + def list_data_exchanges( self, request: Optional[Union[dataexchange.ListDataExchangesRequest, dict]] = None, @@ -708,7 +745,7 @@ def list_data_exchanges( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListDataExchangesPager: r"""Lists all data exchanges in a given project and location. @@ -754,8 +791,10 @@ def sample_list_data_exchanges(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.bigquery_data_exchange_v1beta1.services.analytics_hub_service.pagers.ListDataExchangesPager: @@ -827,7 +866,7 @@ def list_org_data_exchanges( organization: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListOrgDataExchangesPager: r"""Lists all data exchanges from projects in a given organization and location. @@ -875,8 +914,10 @@ def sample_list_org_data_exchanges(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.bigquery_data_exchange_v1beta1.services.analytics_hub_service.pagers.ListOrgDataExchangesPager: @@ -952,7 +993,7 @@ def get_data_exchange( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> dataexchange.DataExchange: r"""Gets the details of a data exchange. @@ -995,8 +1036,10 @@ def sample_get_data_exchange(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.bigquery_data_exchange_v1beta1.types.DataExchange: @@ -1058,7 +1101,7 @@ def create_data_exchange( data_exchange: Optional[dataexchange.DataExchange] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> dataexchange.DataExchange: r"""Creates a new data exchange. @@ -1113,8 +1156,10 @@ def sample_create_data_exchange(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.bigquery_data_exchange_v1beta1.types.DataExchange: @@ -1178,7 +1223,7 @@ def update_data_exchange( update_mask: Optional[field_mask_pb2.FieldMask] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> dataexchange.DataExchange: r"""Updates an existing data exchange. @@ -1233,8 +1278,10 @@ def sample_update_data_exchange(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.bigquery_data_exchange_v1beta1.types.DataExchange: @@ -1299,7 +1346,7 @@ def delete_data_exchange( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> None: r"""Deletes an existing data exchange. @@ -1340,8 +1387,10 @@ def sample_delete_data_exchange(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. """ # Create or coerce a protobuf request object. # - Quick check: If we got a request object, we should *not* have @@ -1390,7 +1439,7 @@ def list_listings( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListListingsPager: r"""Lists all listings in a given project and location. @@ -1435,8 +1484,10 @@ def sample_list_listings(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.bigquery_data_exchange_v1beta1.services.analytics_hub_service.pagers.ListListingsPager: @@ -1508,7 +1559,7 @@ def get_listing( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> dataexchange.Listing: r"""Gets the details of a listing. @@ -1551,8 +1602,10 @@ def sample_get_listing(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.bigquery_data_exchange_v1beta1.types.Listing: @@ -1615,7 +1668,7 @@ def create_listing( listing: Optional[dataexchange.Listing] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> dataexchange.Listing: r"""Creates a new listing. @@ -1668,8 +1721,10 @@ def sample_create_listing(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.bigquery_data_exchange_v1beta1.types.Listing: @@ -1734,7 +1789,7 @@ def update_listing( update_mask: Optional[field_mask_pb2.FieldMask] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> dataexchange.Listing: r"""Updates an existing listing. @@ -1787,8 +1842,10 @@ def sample_update_listing(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.bigquery_data_exchange_v1beta1.types.Listing: @@ -1854,7 +1911,7 @@ def delete_listing( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.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 listing. @@ -1894,8 +1951,10 @@ def sample_delete_listing(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. """ # Create or coerce a protobuf request object. # - Quick check: If we got a request object, we should *not* have @@ -1944,7 +2003,7 @@ def subscribe_listing( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> dataexchange.SubscribeListingResponse: r"""Subscribes to a listing. @@ -2000,8 +2059,10 @@ def sample_subscribe_listing(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.bigquery_data_exchange_v1beta1.types.SubscribeListingResponse: @@ -2058,7 +2119,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. @@ -2095,8 +2156,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: @@ -2171,7 +2234,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 policy. @@ -2208,8 +2271,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: @@ -2284,7 +2349,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"""Returns the permissions that a caller has. @@ -2322,8 +2387,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: @@ -2381,7 +2448,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. @@ -2392,8 +2459,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. @@ -2434,7 +2503,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. @@ -2445,8 +2514,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-bigquery-data-exchange/google/cloud/bigquery_data_exchange_v1beta1/services/analytics_hub_service/pagers.py b/packages/google-cloud-bigquery-data-exchange/google/cloud/bigquery_data_exchange_v1beta1/services/analytics_hub_service/pagers.py index 8bd5769758a0..0d4d77539ef4 100644 --- a/packages/google-cloud-bigquery-data-exchange/google/cloud/bigquery_data_exchange_v1beta1/services/analytics_hub_service/pagers.py +++ b/packages/google-cloud-bigquery-data-exchange/google/cloud/bigquery_data_exchange_v1beta1/services/analytics_hub_service/pagers.py @@ -67,7 +67,7 @@ def __init__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiate the pager. @@ -81,8 +81,10 @@ def __init__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. """ self._method = method self._request = dataexchange.ListDataExchangesRequest(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 = dataexchange.ListDataExchangesRequest(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 = dataexchange.ListOrgDataExchangesRequest(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 = dataexchange.ListOrgDataExchangesRequest(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 = dataexchange.ListListingsRequest(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 = dataexchange.ListListingsRequest(request) diff --git a/packages/google-cloud-bigquery-data-exchange/google/cloud/bigquery_data_exchange_v1beta1/services/analytics_hub_service/transports/grpc.py b/packages/google-cloud-bigquery-data-exchange/google/cloud/bigquery_data_exchange_v1beta1/services/analytics_hub_service/transports/grpc.py index cc8b142722c5..f395b6452df6 100644 --- a/packages/google-cloud-bigquery-data-exchange/google/cloud/bigquery_data_exchange_v1beta1/services/analytics_hub_service/transports/grpc.py +++ b/packages/google-cloud-bigquery-data-exchange/google/cloud/bigquery_data_exchange_v1beta1/services/analytics_hub_service/transports/grpc.py @@ -13,6 +13,9 @@ # See the License for the specific language governing permissions and # limitations under the License. # +import json +import logging as std_logging +import pickle from typing import Callable, Dict, Optional, Sequence, Tuple, Union import warnings @@ -24,12 +27,90 @@ from google.iam.v1 import iam_policy_pb2 # type: ignore from google.iam.v1 import policy_pb2 # type: ignore from google.protobuf import empty_pb2 # type: ignore +from google.protobuf.json_format import MessageToJson +import google.protobuf.message import grpc # type: ignore +import proto # type: ignore from google.cloud.bigquery_data_exchange_v1beta1.types import dataexchange from .base import DEFAULT_CLIENT_INFO, AnalyticsHubServiceTransport +try: + from google.api_core import client_logging # 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.bigquery.dataexchange.v1beta1.AnalyticsHubService", + "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.bigquery.dataexchange.v1beta1.AnalyticsHubService", + "rpcName": client_call_details.method, + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class AnalyticsHubServiceGrpcTransport(AnalyticsHubServiceTransport): """gRPC backend transport for AnalyticsHubService. @@ -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_data_exchanges( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_data_exchanges" not in self._stubs: - self._stubs["list_data_exchanges"] = self.grpc_channel.unary_unary( + self._stubs["list_data_exchanges"] = self._logged_channel.unary_unary( "/google.cloud.bigquery.dataexchange.v1beta1.AnalyticsHubService/ListDataExchanges", request_serializer=dataexchange.ListDataExchangesRequest.serialize, response_deserializer=dataexchange.ListDataExchangesResponse.deserialize, @@ -296,7 +382,7 @@ def list_org_data_exchanges( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_org_data_exchanges" not in self._stubs: - self._stubs["list_org_data_exchanges"] = self.grpc_channel.unary_unary( + self._stubs["list_org_data_exchanges"] = self._logged_channel.unary_unary( "/google.cloud.bigquery.dataexchange.v1beta1.AnalyticsHubService/ListOrgDataExchanges", request_serializer=dataexchange.ListOrgDataExchangesRequest.serialize, response_deserializer=dataexchange.ListOrgDataExchangesResponse.deserialize, @@ -322,7 +408,7 @@ def get_data_exchange( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_data_exchange" not in self._stubs: - self._stubs["get_data_exchange"] = self.grpc_channel.unary_unary( + self._stubs["get_data_exchange"] = self._logged_channel.unary_unary( "/google.cloud.bigquery.dataexchange.v1beta1.AnalyticsHubService/GetDataExchange", request_serializer=dataexchange.GetDataExchangeRequest.serialize, response_deserializer=dataexchange.DataExchange.deserialize, @@ -348,7 +434,7 @@ def create_data_exchange( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_data_exchange" not in self._stubs: - self._stubs["create_data_exchange"] = self.grpc_channel.unary_unary( + self._stubs["create_data_exchange"] = self._logged_channel.unary_unary( "/google.cloud.bigquery.dataexchange.v1beta1.AnalyticsHubService/CreateDataExchange", request_serializer=dataexchange.CreateDataExchangeRequest.serialize, response_deserializer=dataexchange.DataExchange.deserialize, @@ -374,7 +460,7 @@ def update_data_exchange( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_data_exchange" not in self._stubs: - self._stubs["update_data_exchange"] = self.grpc_channel.unary_unary( + self._stubs["update_data_exchange"] = self._logged_channel.unary_unary( "/google.cloud.bigquery.dataexchange.v1beta1.AnalyticsHubService/UpdateDataExchange", request_serializer=dataexchange.UpdateDataExchangeRequest.serialize, response_deserializer=dataexchange.DataExchange.deserialize, @@ -400,7 +486,7 @@ def delete_data_exchange( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_data_exchange" not in self._stubs: - self._stubs["delete_data_exchange"] = self.grpc_channel.unary_unary( + self._stubs["delete_data_exchange"] = self._logged_channel.unary_unary( "/google.cloud.bigquery.dataexchange.v1beta1.AnalyticsHubService/DeleteDataExchange", request_serializer=dataexchange.DeleteDataExchangeRequest.serialize, response_deserializer=empty_pb2.Empty.FromString, @@ -428,7 +514,7 @@ def list_listings( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_listings" not in self._stubs: - self._stubs["list_listings"] = self.grpc_channel.unary_unary( + self._stubs["list_listings"] = self._logged_channel.unary_unary( "/google.cloud.bigquery.dataexchange.v1beta1.AnalyticsHubService/ListListings", request_serializer=dataexchange.ListListingsRequest.serialize, response_deserializer=dataexchange.ListListingsResponse.deserialize, @@ -454,7 +540,7 @@ def get_listing( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_listing" not in self._stubs: - self._stubs["get_listing"] = self.grpc_channel.unary_unary( + self._stubs["get_listing"] = self._logged_channel.unary_unary( "/google.cloud.bigquery.dataexchange.v1beta1.AnalyticsHubService/GetListing", request_serializer=dataexchange.GetListingRequest.serialize, response_deserializer=dataexchange.Listing.deserialize, @@ -480,7 +566,7 @@ def create_listing( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_listing" not in self._stubs: - self._stubs["create_listing"] = self.grpc_channel.unary_unary( + self._stubs["create_listing"] = self._logged_channel.unary_unary( "/google.cloud.bigquery.dataexchange.v1beta1.AnalyticsHubService/CreateListing", request_serializer=dataexchange.CreateListingRequest.serialize, response_deserializer=dataexchange.Listing.deserialize, @@ -506,7 +592,7 @@ def update_listing( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_listing" not in self._stubs: - self._stubs["update_listing"] = self.grpc_channel.unary_unary( + self._stubs["update_listing"] = self._logged_channel.unary_unary( "/google.cloud.bigquery.dataexchange.v1beta1.AnalyticsHubService/UpdateListing", request_serializer=dataexchange.UpdateListingRequest.serialize, response_deserializer=dataexchange.Listing.deserialize, @@ -532,7 +618,7 @@ def delete_listing( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_listing" not in self._stubs: - self._stubs["delete_listing"] = self.grpc_channel.unary_unary( + self._stubs["delete_listing"] = self._logged_channel.unary_unary( "/google.cloud.bigquery.dataexchange.v1beta1.AnalyticsHubService/DeleteListing", request_serializer=dataexchange.DeleteListingRequest.serialize, response_deserializer=empty_pb2.Empty.FromString, @@ -566,7 +652,7 @@ def subscribe_listing( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "subscribe_listing" not in self._stubs: - self._stubs["subscribe_listing"] = self.grpc_channel.unary_unary( + self._stubs["subscribe_listing"] = self._logged_channel.unary_unary( "/google.cloud.bigquery.dataexchange.v1beta1.AnalyticsHubService/SubscribeListing", request_serializer=dataexchange.SubscribeListingRequest.serialize, response_deserializer=dataexchange.SubscribeListingResponse.deserialize, @@ -592,7 +678,7 @@ def get_iam_policy( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_iam_policy" not in self._stubs: - self._stubs["get_iam_policy"] = self.grpc_channel.unary_unary( + self._stubs["get_iam_policy"] = self._logged_channel.unary_unary( "/google.cloud.bigquery.dataexchange.v1beta1.AnalyticsHubService/GetIamPolicy", request_serializer=iam_policy_pb2.GetIamPolicyRequest.SerializeToString, response_deserializer=policy_pb2.Policy.FromString, @@ -618,7 +704,7 @@ def set_iam_policy( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "set_iam_policy" not in self._stubs: - self._stubs["set_iam_policy"] = self.grpc_channel.unary_unary( + self._stubs["set_iam_policy"] = self._logged_channel.unary_unary( "/google.cloud.bigquery.dataexchange.v1beta1.AnalyticsHubService/SetIamPolicy", request_serializer=iam_policy_pb2.SetIamPolicyRequest.SerializeToString, response_deserializer=policy_pb2.Policy.FromString, @@ -647,7 +733,7 @@ def test_iam_permissions( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "test_iam_permissions" not in self._stubs: - self._stubs["test_iam_permissions"] = self.grpc_channel.unary_unary( + self._stubs["test_iam_permissions"] = self._logged_channel.unary_unary( "/google.cloud.bigquery.dataexchange.v1beta1.AnalyticsHubService/TestIamPermissions", request_serializer=iam_policy_pb2.TestIamPermissionsRequest.SerializeToString, response_deserializer=iam_policy_pb2.TestIamPermissionsResponse.FromString, @@ -655,7 +741,7 @@ def test_iam_permissions( return self._stubs["test_iam_permissions"] def close(self): - self.grpc_channel.close() + self._logged_channel.close() @property def list_locations( @@ -669,7 +755,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, @@ -686,7 +772,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-bigquery-data-exchange/google/cloud/bigquery_data_exchange_v1beta1/services/analytics_hub_service/transports/grpc_asyncio.py b/packages/google-cloud-bigquery-data-exchange/google/cloud/bigquery_data_exchange_v1beta1/services/analytics_hub_service/transports/grpc_asyncio.py index 5aa28f88d7e0..0d67cf2cd905 100644 --- a/packages/google-cloud-bigquery-data-exchange/google/cloud/bigquery_data_exchange_v1beta1/services/analytics_hub_service/transports/grpc_asyncio.py +++ b/packages/google-cloud-bigquery-data-exchange/google/cloud/bigquery_data_exchange_v1beta1/services/analytics_hub_service/transports/grpc_asyncio.py @@ -14,6 +14,9 @@ # limitations under the License. # import inspect +import json +import logging as std_logging +import pickle from typing import Awaitable, Callable, Dict, Optional, Sequence, Tuple, Union import warnings @@ -26,14 +29,93 @@ from google.iam.v1 import iam_policy_pb2 # type: ignore from google.iam.v1 import policy_pb2 # type: ignore from google.protobuf import empty_pb2 # type: ignore +from google.protobuf.json_format import MessageToJson +import google.protobuf.message import grpc # type: ignore from grpc.experimental import aio # type: ignore +import proto # type: ignore from google.cloud.bigquery_data_exchange_v1beta1.types import dataexchange from .base import DEFAULT_CLIENT_INFO, AnalyticsHubServiceTransport from .grpc import AnalyticsHubServiceGrpcTransport +try: + from google.api_core import client_logging # 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.bigquery.dataexchange.v1beta1.AnalyticsHubService", + "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.bigquery.dataexchange.v1beta1.AnalyticsHubService", + "rpcName": str(client_call_details.method), + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class AnalyticsHubServiceGrpcAsyncIOTransport(AnalyticsHubServiceTransport): """gRPC AsyncIO backend transport for AnalyticsHubService. @@ -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 @@ -275,7 +360,7 @@ def list_data_exchanges( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_data_exchanges" not in self._stubs: - self._stubs["list_data_exchanges"] = self.grpc_channel.unary_unary( + self._stubs["list_data_exchanges"] = self._logged_channel.unary_unary( "/google.cloud.bigquery.dataexchange.v1beta1.AnalyticsHubService/ListDataExchanges", request_serializer=dataexchange.ListDataExchangesRequest.serialize, response_deserializer=dataexchange.ListDataExchangesResponse.deserialize, @@ -305,7 +390,7 @@ def list_org_data_exchanges( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_org_data_exchanges" not in self._stubs: - self._stubs["list_org_data_exchanges"] = self.grpc_channel.unary_unary( + self._stubs["list_org_data_exchanges"] = self._logged_channel.unary_unary( "/google.cloud.bigquery.dataexchange.v1beta1.AnalyticsHubService/ListOrgDataExchanges", request_serializer=dataexchange.ListOrgDataExchangesRequest.serialize, response_deserializer=dataexchange.ListOrgDataExchangesResponse.deserialize, @@ -333,7 +418,7 @@ def get_data_exchange( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_data_exchange" not in self._stubs: - self._stubs["get_data_exchange"] = self.grpc_channel.unary_unary( + self._stubs["get_data_exchange"] = self._logged_channel.unary_unary( "/google.cloud.bigquery.dataexchange.v1beta1.AnalyticsHubService/GetDataExchange", request_serializer=dataexchange.GetDataExchangeRequest.serialize, response_deserializer=dataexchange.DataExchange.deserialize, @@ -361,7 +446,7 @@ def create_data_exchange( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_data_exchange" not in self._stubs: - self._stubs["create_data_exchange"] = self.grpc_channel.unary_unary( + self._stubs["create_data_exchange"] = self._logged_channel.unary_unary( "/google.cloud.bigquery.dataexchange.v1beta1.AnalyticsHubService/CreateDataExchange", request_serializer=dataexchange.CreateDataExchangeRequest.serialize, response_deserializer=dataexchange.DataExchange.deserialize, @@ -389,7 +474,7 @@ def update_data_exchange( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_data_exchange" not in self._stubs: - self._stubs["update_data_exchange"] = self.grpc_channel.unary_unary( + self._stubs["update_data_exchange"] = self._logged_channel.unary_unary( "/google.cloud.bigquery.dataexchange.v1beta1.AnalyticsHubService/UpdateDataExchange", request_serializer=dataexchange.UpdateDataExchangeRequest.serialize, response_deserializer=dataexchange.DataExchange.deserialize, @@ -415,7 +500,7 @@ def delete_data_exchange( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_data_exchange" not in self._stubs: - self._stubs["delete_data_exchange"] = self.grpc_channel.unary_unary( + self._stubs["delete_data_exchange"] = self._logged_channel.unary_unary( "/google.cloud.bigquery.dataexchange.v1beta1.AnalyticsHubService/DeleteDataExchange", request_serializer=dataexchange.DeleteDataExchangeRequest.serialize, response_deserializer=empty_pb2.Empty.FromString, @@ -443,7 +528,7 @@ def list_listings( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_listings" not in self._stubs: - self._stubs["list_listings"] = self.grpc_channel.unary_unary( + self._stubs["list_listings"] = self._logged_channel.unary_unary( "/google.cloud.bigquery.dataexchange.v1beta1.AnalyticsHubService/ListListings", request_serializer=dataexchange.ListListingsRequest.serialize, response_deserializer=dataexchange.ListListingsResponse.deserialize, @@ -469,7 +554,7 @@ def get_listing( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_listing" not in self._stubs: - self._stubs["get_listing"] = self.grpc_channel.unary_unary( + self._stubs["get_listing"] = self._logged_channel.unary_unary( "/google.cloud.bigquery.dataexchange.v1beta1.AnalyticsHubService/GetListing", request_serializer=dataexchange.GetListingRequest.serialize, response_deserializer=dataexchange.Listing.deserialize, @@ -495,7 +580,7 @@ def create_listing( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_listing" not in self._stubs: - self._stubs["create_listing"] = self.grpc_channel.unary_unary( + self._stubs["create_listing"] = self._logged_channel.unary_unary( "/google.cloud.bigquery.dataexchange.v1beta1.AnalyticsHubService/CreateListing", request_serializer=dataexchange.CreateListingRequest.serialize, response_deserializer=dataexchange.Listing.deserialize, @@ -521,7 +606,7 @@ def update_listing( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_listing" not in self._stubs: - self._stubs["update_listing"] = self.grpc_channel.unary_unary( + self._stubs["update_listing"] = self._logged_channel.unary_unary( "/google.cloud.bigquery.dataexchange.v1beta1.AnalyticsHubService/UpdateListing", request_serializer=dataexchange.UpdateListingRequest.serialize, response_deserializer=dataexchange.Listing.deserialize, @@ -547,7 +632,7 @@ def delete_listing( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_listing" not in self._stubs: - self._stubs["delete_listing"] = self.grpc_channel.unary_unary( + self._stubs["delete_listing"] = self._logged_channel.unary_unary( "/google.cloud.bigquery.dataexchange.v1beta1.AnalyticsHubService/DeleteListing", request_serializer=dataexchange.DeleteListingRequest.serialize, response_deserializer=empty_pb2.Empty.FromString, @@ -582,7 +667,7 @@ def subscribe_listing( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "subscribe_listing" not in self._stubs: - self._stubs["subscribe_listing"] = self.grpc_channel.unary_unary( + self._stubs["subscribe_listing"] = self._logged_channel.unary_unary( "/google.cloud.bigquery.dataexchange.v1beta1.AnalyticsHubService/SubscribeListing", request_serializer=dataexchange.SubscribeListingRequest.serialize, response_deserializer=dataexchange.SubscribeListingResponse.deserialize, @@ -608,7 +693,7 @@ def get_iam_policy( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_iam_policy" not in self._stubs: - self._stubs["get_iam_policy"] = self.grpc_channel.unary_unary( + self._stubs["get_iam_policy"] = self._logged_channel.unary_unary( "/google.cloud.bigquery.dataexchange.v1beta1.AnalyticsHubService/GetIamPolicy", request_serializer=iam_policy_pb2.GetIamPolicyRequest.SerializeToString, response_deserializer=policy_pb2.Policy.FromString, @@ -634,7 +719,7 @@ def set_iam_policy( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "set_iam_policy" not in self._stubs: - self._stubs["set_iam_policy"] = self.grpc_channel.unary_unary( + self._stubs["set_iam_policy"] = self._logged_channel.unary_unary( "/google.cloud.bigquery.dataexchange.v1beta1.AnalyticsHubService/SetIamPolicy", request_serializer=iam_policy_pb2.SetIamPolicyRequest.SerializeToString, response_deserializer=policy_pb2.Policy.FromString, @@ -663,7 +748,7 @@ def test_iam_permissions( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "test_iam_permissions" not in self._stubs: - self._stubs["test_iam_permissions"] = self.grpc_channel.unary_unary( + self._stubs["test_iam_permissions"] = self._logged_channel.unary_unary( "/google.cloud.bigquery.dataexchange.v1beta1.AnalyticsHubService/TestIamPermissions", request_serializer=iam_policy_pb2.TestIamPermissionsRequest.SerializeToString, response_deserializer=iam_policy_pb2.TestIamPermissionsResponse.FromString, @@ -766,7 +851,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: @@ -784,7 +869,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, @@ -801,7 +886,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-bigquery-data-exchange/samples/generated_samples/snippet_metadata_google.cloud.bigquery.dataexchange.v1beta1.json b/packages/google-cloud-bigquery-data-exchange/samples/generated_samples/snippet_metadata_google.cloud.bigquery.dataexchange.v1beta1.json index 622338e9867c..0103e35cd88a 100644 --- a/packages/google-cloud-bigquery-data-exchange/samples/generated_samples/snippet_metadata_google.cloud.bigquery.dataexchange.v1beta1.json +++ b/packages/google-cloud-bigquery-data-exchange/samples/generated_samples/snippet_metadata_google.cloud.bigquery.dataexchange.v1beta1.json @@ -8,7 +8,7 @@ ], "language": "PYTHON", "name": "google-cloud-bigquery-data-exchange", - "version": "0.5.15" + "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.bigquery_data_exchange_v1beta1.types.DataExchange", @@ -135,7 +135,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.bigquery_data_exchange_v1beta1.types.DataExchange", @@ -220,7 +220,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.bigquery_data_exchange_v1beta1.types.Listing", @@ -304,7 +304,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.bigquery_data_exchange_v1beta1.types.Listing", @@ -385,7 +385,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "shortName": "delete_data_exchange" @@ -462,7 +462,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "shortName": "delete_data_exchange" @@ -540,7 +540,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "shortName": "delete_listing" @@ -617,7 +617,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "shortName": "delete_listing" @@ -695,7 +695,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.bigquery_data_exchange_v1beta1.types.DataExchange", @@ -775,7 +775,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.bigquery_data_exchange_v1beta1.types.DataExchange", @@ -852,7 +852,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.iam.v1.policy_pb2.Policy", @@ -928,7 +928,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.iam.v1.policy_pb2.Policy", @@ -1009,7 +1009,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.bigquery_data_exchange_v1beta1.types.Listing", @@ -1089,7 +1089,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.bigquery_data_exchange_v1beta1.types.Listing", @@ -1170,7 +1170,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.bigquery_data_exchange_v1beta1.services.analytics_hub_service.pagers.ListDataExchangesAsyncPager", @@ -1250,7 +1250,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.bigquery_data_exchange_v1beta1.services.analytics_hub_service.pagers.ListDataExchangesPager", @@ -1331,7 +1331,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.bigquery_data_exchange_v1beta1.services.analytics_hub_service.pagers.ListListingsAsyncPager", @@ -1411,7 +1411,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.bigquery_data_exchange_v1beta1.services.analytics_hub_service.pagers.ListListingsPager", @@ -1492,7 +1492,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.bigquery_data_exchange_v1beta1.services.analytics_hub_service.pagers.ListOrgDataExchangesAsyncPager", @@ -1572,7 +1572,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.bigquery_data_exchange_v1beta1.services.analytics_hub_service.pagers.ListOrgDataExchangesPager", @@ -1649,7 +1649,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.iam.v1.policy_pb2.Policy", @@ -1725,7 +1725,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.iam.v1.policy_pb2.Policy", @@ -1806,7 +1806,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.bigquery_data_exchange_v1beta1.types.SubscribeListingResponse", @@ -1886,7 +1886,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.bigquery_data_exchange_v1beta1.types.SubscribeListingResponse", @@ -1963,7 +1963,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.iam.v1.iam_policy_pb2.TestIamPermissionsResponse", @@ -2039,7 +2039,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.iam.v1.iam_policy_pb2.TestIamPermissionsResponse", @@ -2124,7 +2124,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.bigquery_data_exchange_v1beta1.types.DataExchange", @@ -2208,7 +2208,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.bigquery_data_exchange_v1beta1.types.DataExchange", @@ -2293,7 +2293,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.bigquery_data_exchange_v1beta1.types.Listing", @@ -2377,7 +2377,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.bigquery_data_exchange_v1beta1.types.Listing", diff --git a/packages/google-cloud-bigquery-datapolicies/google/cloud/bigquery_datapolicies/gapic_version.py b/packages/google-cloud-bigquery-datapolicies/google/cloud/bigquery_datapolicies/gapic_version.py index 8ebdaa033b52..558c8aab67c5 100644 --- a/packages/google-cloud-bigquery-datapolicies/google/cloud/bigquery_datapolicies/gapic_version.py +++ b/packages/google-cloud-bigquery-datapolicies/google/cloud/bigquery_datapolicies/gapic_version.py @@ -13,4 +13,4 @@ # See the License for the specific language governing permissions and # limitations under the License. # -__version__ = "0.6.10" # {x-release-please-version} +__version__ = "0.0.0" # {x-release-please-version} diff --git a/packages/google-cloud-bigquery-datapolicies/google/cloud/bigquery_datapolicies_v1/gapic_version.py b/packages/google-cloud-bigquery-datapolicies/google/cloud/bigquery_datapolicies_v1/gapic_version.py index 8ebdaa033b52..558c8aab67c5 100644 --- a/packages/google-cloud-bigquery-datapolicies/google/cloud/bigquery_datapolicies_v1/gapic_version.py +++ b/packages/google-cloud-bigquery-datapolicies/google/cloud/bigquery_datapolicies_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.10" # {x-release-please-version} +__version__ = "0.0.0" # {x-release-please-version} diff --git a/packages/google-cloud-bigquery-datapolicies/google/cloud/bigquery_datapolicies_v1/services/data_policy_service/async_client.py b/packages/google-cloud-bigquery-datapolicies/google/cloud/bigquery_datapolicies_v1/services/data_policy_service/async_client.py index 02ffeb4d3d2c..6c9cdf345c09 100644 --- a/packages/google-cloud-bigquery-datapolicies/google/cloud/bigquery_datapolicies_v1/services/data_policy_service/async_client.py +++ b/packages/google-cloud-bigquery-datapolicies/google/cloud/bigquery_datapolicies_v1/services/data_policy_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, DataPolicyServiceTransport from .transports.grpc_asyncio import DataPolicyServiceGrpcAsyncIOTransport +try: + from google.api_core import client_logging # type: ignore + + CLIENT_LOGGING_SUPPORTED = True # pragma: NO COVER +except ImportError: # pragma: NO COVER + CLIENT_LOGGING_SUPPORTED = False + +_LOGGER = std_logging.getLogger(__name__) + class DataPolicyServiceAsyncClient: """Data Policy Service provides APIs for managing the @@ -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.cloud.bigquery.datapolicies_v1.DataPolicyServiceAsyncClient`.", + extra={ + "serviceName": "google.cloud.bigquery.datapolicies.v1.DataPolicyService", + "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.bigquery.datapolicies.v1.DataPolicyService", + "credentialsType": None, + }, + ) + async def create_data_policy( self, request: Optional[Union[datapolicy.CreateDataPolicyRequest, dict]] = None, @@ -274,7 +306,7 @@ async def create_data_policy( data_policy: Optional[datapolicy.DataPolicy] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> datapolicy.DataPolicy: r"""Creates a new data policy under a project with the given ``dataPolicyId`` (used as the display name), policy tag, and @@ -334,8 +366,10 @@ async def sample_create_data_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.bigquery_datapolicies_v1.types.DataPolicy: @@ -397,7 +431,7 @@ async def update_data_policy( update_mask: Optional[field_mask_pb2.FieldMask] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> datapolicy.DataPolicy: r"""Updates the metadata for an existing data policy. The target data policy can be specified by the resource @@ -463,8 +497,10 @@ async def sample_update_data_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.bigquery_datapolicies_v1.types.DataPolicy: @@ -528,7 +564,7 @@ async def rename_data_policy( new_data_policy_id: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> datapolicy.DataPolicy: r"""Renames the id (display name) of the specified data policy. @@ -580,8 +616,10 @@ async def sample_rename_data_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.bigquery_datapolicies_v1.types.DataPolicy: @@ -642,7 +680,7 @@ async def delete_data_policy( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> None: r"""Deletes the data policy specified by its resource name. @@ -685,8 +723,10 @@ async def sample_delete_data_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`. """ # Create or coerce a protobuf request object. # - Quick check: If we got a request object, we should *not* have @@ -738,7 +778,7 @@ async def get_data_policy( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> datapolicy.DataPolicy: r"""Gets the data policy specified by its resource name. @@ -783,8 +823,10 @@ async def sample_get_data_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.bigquery_datapolicies_v1.types.DataPolicy: @@ -843,7 +885,7 @@ async def list_data_policies( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListDataPoliciesAsyncPager: r"""List all of the data policies in the specified parent project. @@ -890,8 +932,10 @@ async def sample_list_data_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.bigquery_datapolicies_v1.services.data_policy_service.pagers.ListDataPoliciesAsyncPager: @@ -965,7 +1009,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 the specified data policy. @@ -1002,8 +1046,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: @@ -1079,7 +1125,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 policy for the specified data policy. @@ -1116,8 +1162,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: @@ -1193,7 +1241,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"""Returns the caller's permission on the specified data policy resource. @@ -1232,8 +1280,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: diff --git a/packages/google-cloud-bigquery-datapolicies/google/cloud/bigquery_datapolicies_v1/services/data_policy_service/client.py b/packages/google-cloud-bigquery-datapolicies/google/cloud/bigquery_datapolicies_v1/services/data_policy_service/client.py index 33d22df0b8b4..ab428db9b0ed 100644 --- a/packages/google-cloud-bigquery-datapolicies/google/cloud/bigquery_datapolicies_v1/services/data_policy_service/client.py +++ b/packages/google-cloud-bigquery-datapolicies/google/cloud/bigquery_datapolicies_v1/services/data_policy_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.iam.v1 import iam_policy_pb2 # type: ignore from google.iam.v1 import policy_pb2 # type: ignore from google.protobuf import field_mask_pb2 # type: ignore @@ -590,6 +600,10 @@ def __init__( # Initialize the universe domain validation. self._is_universe_domain_valid = False + if CLIENT_LOGGING_SUPPORTED: # pragma: NO COVER + # 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.cloud.bigquery.datapolicies_v1.DataPolicyServiceClient`.", + extra={ + "serviceName": "google.cloud.bigquery.datapolicies.v1.DataPolicyService", + "universeDomain": getattr( + self._transport._credentials, "universe_domain", "" + ), + "credentialsType": f"{type(self._transport._credentials).__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.bigquery.datapolicies.v1.DataPolicyService", + "credentialsType": None, + }, + ) + def create_data_policy( self, request: Optional[Union[datapolicy.CreateDataPolicyRequest, dict]] = None, @@ -664,7 +701,7 @@ def create_data_policy( data_policy: Optional[datapolicy.DataPolicy] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> datapolicy.DataPolicy: r"""Creates a new data policy under a project with the given ``dataPolicyId`` (used as the display name), policy tag, and @@ -724,8 +761,10 @@ def sample_create_data_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.bigquery_datapolicies_v1.types.DataPolicy: @@ -784,7 +823,7 @@ def update_data_policy( update_mask: Optional[field_mask_pb2.FieldMask] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> datapolicy.DataPolicy: r"""Updates the metadata for an existing data policy. The target data policy can be specified by the resource @@ -850,8 +889,10 @@ def sample_update_data_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.bigquery_datapolicies_v1.types.DataPolicy: @@ -912,7 +953,7 @@ def rename_data_policy( new_data_policy_id: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> datapolicy.DataPolicy: r"""Renames the id (display name) of the specified data policy. @@ -964,8 +1005,10 @@ def sample_rename_data_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.bigquery_datapolicies_v1.types.DataPolicy: @@ -1023,7 +1066,7 @@ def delete_data_policy( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> None: r"""Deletes the data policy specified by its resource name. @@ -1066,8 +1109,10 @@ def sample_delete_data_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`. """ # Create or coerce a protobuf request object. # - Quick check: If we got a request object, we should *not* have @@ -1116,7 +1161,7 @@ def get_data_policy( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> datapolicy.DataPolicy: r"""Gets the data policy specified by its resource name. @@ -1161,8 +1206,10 @@ def sample_get_data_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.bigquery_datapolicies_v1.types.DataPolicy: @@ -1218,7 +1265,7 @@ def list_data_policies( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListDataPoliciesPager: r"""List all of the data policies in the specified parent project. @@ -1265,8 +1312,10 @@ def sample_list_data_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.bigquery_datapolicies_v1.services.data_policy_service.pagers.ListDataPoliciesPager: @@ -1337,7 +1386,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 the specified data policy. @@ -1374,8 +1423,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: @@ -1450,7 +1501,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 policy for the specified data policy. @@ -1487,8 +1538,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: @@ -1563,7 +1616,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"""Returns the caller's permission on the specified data policy resource. @@ -1602,8 +1655,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: diff --git a/packages/google-cloud-bigquery-datapolicies/google/cloud/bigquery_datapolicies_v1/services/data_policy_service/pagers.py b/packages/google-cloud-bigquery-datapolicies/google/cloud/bigquery_datapolicies_v1/services/data_policy_service/pagers.py index 1eac42c976e9..e3d5bfa45bc8 100644 --- a/packages/google-cloud-bigquery-datapolicies/google/cloud/bigquery_datapolicies_v1/services/data_policy_service/pagers.py +++ b/packages/google-cloud-bigquery-datapolicies/google/cloud/bigquery_datapolicies_v1/services/data_policy_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 = datapolicy.ListDataPoliciesRequest(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 = datapolicy.ListDataPoliciesRequest(request) diff --git a/packages/google-cloud-bigquery-datapolicies/google/cloud/bigquery_datapolicies_v1/services/data_policy_service/transports/grpc.py b/packages/google-cloud-bigquery-datapolicies/google/cloud/bigquery_datapolicies_v1/services/data_policy_service/transports/grpc.py index 4a8e76e117f8..873a7a0be50b 100644 --- a/packages/google-cloud-bigquery-datapolicies/google/cloud/bigquery_datapolicies_v1/services/data_policy_service/transports/grpc.py +++ b/packages/google-cloud-bigquery-datapolicies/google/cloud/bigquery_datapolicies_v1/services/data_policy_service/transports/grpc.py @@ -13,6 +13,9 @@ # See the License for the specific language governing permissions and # limitations under the License. # +import json +import logging as std_logging +import pickle from typing import Callable, Dict, Optional, Sequence, Tuple, Union import warnings @@ -23,12 +26,90 @@ from google.iam.v1 import iam_policy_pb2 # type: ignore from google.iam.v1 import policy_pb2 # type: ignore from google.protobuf import empty_pb2 # type: ignore +from google.protobuf.json_format import MessageToJson +import google.protobuf.message import grpc # type: ignore +import proto # type: ignore from google.cloud.bigquery_datapolicies_v1.types import datapolicy from .base import DEFAULT_CLIENT_INFO, DataPolicyServiceTransport +try: + from google.api_core import client_logging # 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.bigquery.datapolicies.v1.DataPolicyService", + "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.bigquery.datapolicies.v1.DataPolicyService", + "rpcName": client_call_details.method, + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class DataPolicyServiceGrpcTransport(DataPolicyServiceTransport): """gRPC backend transport for DataPolicyService. @@ -183,7 +264,12 @@ def __init__( ], ) - # Wrap messages. This must be done after self._grpc_channel exists + self._interceptor = _LoggingClientInterceptor() + self._logged_channel = grpc.intercept_channel( + self._grpc_channel, self._interceptor + ) + + # Wrap messages. This must be done after self._logged_channel exists self._prep_wrapped_messages(client_info) @classmethod @@ -259,7 +345,7 @@ def create_data_policy( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_data_policy" not in self._stubs: - self._stubs["create_data_policy"] = self.grpc_channel.unary_unary( + self._stubs["create_data_policy"] = self._logged_channel.unary_unary( "/google.cloud.bigquery.datapolicies.v1.DataPolicyService/CreateDataPolicy", request_serializer=datapolicy.CreateDataPolicyRequest.serialize, response_deserializer=datapolicy.DataPolicy.deserialize, @@ -287,7 +373,7 @@ def update_data_policy( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_data_policy" not in self._stubs: - self._stubs["update_data_policy"] = self.grpc_channel.unary_unary( + self._stubs["update_data_policy"] = self._logged_channel.unary_unary( "/google.cloud.bigquery.datapolicies.v1.DataPolicyService/UpdateDataPolicy", request_serializer=datapolicy.UpdateDataPolicyRequest.serialize, response_deserializer=datapolicy.DataPolicy.deserialize, @@ -314,7 +400,7 @@ def rename_data_policy( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "rename_data_policy" not in self._stubs: - self._stubs["rename_data_policy"] = self.grpc_channel.unary_unary( + self._stubs["rename_data_policy"] = self._logged_channel.unary_unary( "/google.cloud.bigquery.datapolicies.v1.DataPolicyService/RenameDataPolicy", request_serializer=datapolicy.RenameDataPolicyRequest.serialize, response_deserializer=datapolicy.DataPolicy.deserialize, @@ -341,7 +427,7 @@ def delete_data_policy( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_data_policy" not in self._stubs: - self._stubs["delete_data_policy"] = self.grpc_channel.unary_unary( + self._stubs["delete_data_policy"] = self._logged_channel.unary_unary( "/google.cloud.bigquery.datapolicies.v1.DataPolicyService/DeleteDataPolicy", request_serializer=datapolicy.DeleteDataPolicyRequest.serialize, response_deserializer=empty_pb2.Empty.FromString, @@ -367,7 +453,7 @@ def get_data_policy( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_data_policy" not in self._stubs: - self._stubs["get_data_policy"] = self.grpc_channel.unary_unary( + self._stubs["get_data_policy"] = self._logged_channel.unary_unary( "/google.cloud.bigquery.datapolicies.v1.DataPolicyService/GetDataPolicy", request_serializer=datapolicy.GetDataPolicyRequest.serialize, response_deserializer=datapolicy.DataPolicy.deserialize, @@ -396,7 +482,7 @@ def list_data_policies( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_data_policies" not in self._stubs: - self._stubs["list_data_policies"] = self.grpc_channel.unary_unary( + self._stubs["list_data_policies"] = self._logged_channel.unary_unary( "/google.cloud.bigquery.datapolicies.v1.DataPolicyService/ListDataPolicies", request_serializer=datapolicy.ListDataPoliciesRequest.serialize, response_deserializer=datapolicy.ListDataPoliciesResponse.deserialize, @@ -422,7 +508,7 @@ def get_iam_policy( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_iam_policy" not in self._stubs: - self._stubs["get_iam_policy"] = self.grpc_channel.unary_unary( + self._stubs["get_iam_policy"] = self._logged_channel.unary_unary( "/google.cloud.bigquery.datapolicies.v1.DataPolicyService/GetIamPolicy", request_serializer=iam_policy_pb2.GetIamPolicyRequest.SerializeToString, response_deserializer=policy_pb2.Policy.FromString, @@ -448,7 +534,7 @@ def set_iam_policy( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "set_iam_policy" not in self._stubs: - self._stubs["set_iam_policy"] = self.grpc_channel.unary_unary( + self._stubs["set_iam_policy"] = self._logged_channel.unary_unary( "/google.cloud.bigquery.datapolicies.v1.DataPolicyService/SetIamPolicy", request_serializer=iam_policy_pb2.SetIamPolicyRequest.SerializeToString, response_deserializer=policy_pb2.Policy.FromString, @@ -478,7 +564,7 @@ def test_iam_permissions( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "test_iam_permissions" not in self._stubs: - self._stubs["test_iam_permissions"] = self.grpc_channel.unary_unary( + self._stubs["test_iam_permissions"] = self._logged_channel.unary_unary( "/google.cloud.bigquery.datapolicies.v1.DataPolicyService/TestIamPermissions", request_serializer=iam_policy_pb2.TestIamPermissionsRequest.SerializeToString, response_deserializer=iam_policy_pb2.TestIamPermissionsResponse.FromString, @@ -486,7 +572,7 @@ def test_iam_permissions( return self._stubs["test_iam_permissions"] def close(self): - self.grpc_channel.close() + self._logged_channel.close() @property def kind(self) -> str: diff --git a/packages/google-cloud-bigquery-datapolicies/google/cloud/bigquery_datapolicies_v1/services/data_policy_service/transports/grpc_asyncio.py b/packages/google-cloud-bigquery-datapolicies/google/cloud/bigquery_datapolicies_v1/services/data_policy_service/transports/grpc_asyncio.py index fced0c665707..b7318100e71b 100644 --- a/packages/google-cloud-bigquery-datapolicies/google/cloud/bigquery_datapolicies_v1/services/data_policy_service/transports/grpc_asyncio.py +++ b/packages/google-cloud-bigquery-datapolicies/google/cloud/bigquery_datapolicies_v1/services/data_policy_service/transports/grpc_asyncio.py @@ -14,6 +14,9 @@ # limitations under the License. # import inspect +import json +import logging as std_logging +import pickle from typing import Awaitable, Callable, Dict, Optional, Sequence, Tuple, Union import warnings @@ -25,14 +28,93 @@ from google.iam.v1 import iam_policy_pb2 # type: ignore from google.iam.v1 import policy_pb2 # type: ignore from google.protobuf import empty_pb2 # type: ignore +from google.protobuf.json_format import MessageToJson +import google.protobuf.message import grpc # type: ignore from grpc.experimental import aio # type: ignore +import proto # type: ignore from google.cloud.bigquery_datapolicies_v1.types import datapolicy from .base import DEFAULT_CLIENT_INFO, DataPolicyServiceTransport from .grpc import DataPolicyServiceGrpcTransport +try: + from google.api_core import client_logging # 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.bigquery.datapolicies.v1.DataPolicyService", + "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.bigquery.datapolicies.v1.DataPolicyService", + "rpcName": str(client_call_details.method), + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class DataPolicyServiceGrpcAsyncIOTransport(DataPolicyServiceTransport): """gRPC AsyncIO backend transport for DataPolicyService. @@ -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 create_data_policy( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_data_policy" not in self._stubs: - self._stubs["create_data_policy"] = self.grpc_channel.unary_unary( + self._stubs["create_data_policy"] = self._logged_channel.unary_unary( "/google.cloud.bigquery.datapolicies.v1.DataPolicyService/CreateDataPolicy", request_serializer=datapolicy.CreateDataPolicyRequest.serialize, response_deserializer=datapolicy.DataPolicy.deserialize, @@ -299,7 +384,7 @@ def update_data_policy( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_data_policy" not in self._stubs: - self._stubs["update_data_policy"] = self.grpc_channel.unary_unary( + self._stubs["update_data_policy"] = self._logged_channel.unary_unary( "/google.cloud.bigquery.datapolicies.v1.DataPolicyService/UpdateDataPolicy", request_serializer=datapolicy.UpdateDataPolicyRequest.serialize, response_deserializer=datapolicy.DataPolicy.deserialize, @@ -328,7 +413,7 @@ def rename_data_policy( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "rename_data_policy" not in self._stubs: - self._stubs["rename_data_policy"] = self.grpc_channel.unary_unary( + self._stubs["rename_data_policy"] = self._logged_channel.unary_unary( "/google.cloud.bigquery.datapolicies.v1.DataPolicyService/RenameDataPolicy", request_serializer=datapolicy.RenameDataPolicyRequest.serialize, response_deserializer=datapolicy.DataPolicy.deserialize, @@ -355,7 +440,7 @@ def delete_data_policy( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_data_policy" not in self._stubs: - self._stubs["delete_data_policy"] = self.grpc_channel.unary_unary( + self._stubs["delete_data_policy"] = self._logged_channel.unary_unary( "/google.cloud.bigquery.datapolicies.v1.DataPolicyService/DeleteDataPolicy", request_serializer=datapolicy.DeleteDataPolicyRequest.serialize, response_deserializer=empty_pb2.Empty.FromString, @@ -381,7 +466,7 @@ def get_data_policy( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_data_policy" not in self._stubs: - self._stubs["get_data_policy"] = self.grpc_channel.unary_unary( + self._stubs["get_data_policy"] = self._logged_channel.unary_unary( "/google.cloud.bigquery.datapolicies.v1.DataPolicyService/GetDataPolicy", request_serializer=datapolicy.GetDataPolicyRequest.serialize, response_deserializer=datapolicy.DataPolicy.deserialize, @@ -411,7 +496,7 @@ def list_data_policies( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_data_policies" not in self._stubs: - self._stubs["list_data_policies"] = self.grpc_channel.unary_unary( + self._stubs["list_data_policies"] = self._logged_channel.unary_unary( "/google.cloud.bigquery.datapolicies.v1.DataPolicyService/ListDataPolicies", request_serializer=datapolicy.ListDataPoliciesRequest.serialize, response_deserializer=datapolicy.ListDataPoliciesResponse.deserialize, @@ -437,7 +522,7 @@ def get_iam_policy( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_iam_policy" not in self._stubs: - self._stubs["get_iam_policy"] = self.grpc_channel.unary_unary( + self._stubs["get_iam_policy"] = self._logged_channel.unary_unary( "/google.cloud.bigquery.datapolicies.v1.DataPolicyService/GetIamPolicy", request_serializer=iam_policy_pb2.GetIamPolicyRequest.SerializeToString, response_deserializer=policy_pb2.Policy.FromString, @@ -463,7 +548,7 @@ def set_iam_policy( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "set_iam_policy" not in self._stubs: - self._stubs["set_iam_policy"] = self.grpc_channel.unary_unary( + self._stubs["set_iam_policy"] = self._logged_channel.unary_unary( "/google.cloud.bigquery.datapolicies.v1.DataPolicyService/SetIamPolicy", request_serializer=iam_policy_pb2.SetIamPolicyRequest.SerializeToString, response_deserializer=policy_pb2.Policy.FromString, @@ -493,7 +578,7 @@ def test_iam_permissions( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "test_iam_permissions" not in self._stubs: - self._stubs["test_iam_permissions"] = self.grpc_channel.unary_unary( + self._stubs["test_iam_permissions"] = self._logged_channel.unary_unary( "/google.cloud.bigquery.datapolicies.v1.DataPolicyService/TestIamPermissions", request_serializer=iam_policy_pb2.TestIamPermissionsRequest.SerializeToString, response_deserializer=iam_policy_pb2.TestIamPermissionsResponse.FromString, @@ -637,7 +722,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-bigquery-datapolicies/google/cloud/bigquery_datapolicies_v1/services/data_policy_service/transports/rest.py b/packages/google-cloud-bigquery-datapolicies/google/cloud/bigquery_datapolicies_v1/services/data_policy_service/transports/rest.py index 8143dfa5393b..896742a4fce4 100644 --- a/packages/google-cloud-bigquery-datapolicies/google/cloud/bigquery_datapolicies_v1/services/data_policy_service/transports/rest.py +++ b/packages/google-cloud-bigquery-datapolicies/google/cloud/bigquery_datapolicies_v1/services/data_policy_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, @@ -140,8 +148,10 @@ def post_update_data_policy(self, response): def pre_create_data_policy( self, request: datapolicy.CreateDataPolicyRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[datapolicy.CreateDataPolicyRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + datapolicy.CreateDataPolicyRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for create_data_policy Override in a subclass to manipulate the request or metadata @@ -163,8 +173,10 @@ def post_create_data_policy( def pre_delete_data_policy( self, request: datapolicy.DeleteDataPolicyRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[datapolicy.DeleteDataPolicyRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + datapolicy.DeleteDataPolicyRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for delete_data_policy Override in a subclass to manipulate the request or metadata @@ -175,8 +187,10 @@ def pre_delete_data_policy( def pre_get_data_policy( self, request: datapolicy.GetDataPolicyRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[datapolicy.GetDataPolicyRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + datapolicy.GetDataPolicyRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for get_data_policy Override in a subclass to manipulate the request or metadata @@ -198,8 +212,10 @@ def post_get_data_policy( 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 @@ -219,8 +235,10 @@ def post_get_iam_policy(self, response: policy_pb2.Policy) -> policy_pb2.Policy: def pre_list_data_policies( self, request: datapolicy.ListDataPoliciesRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[datapolicy.ListDataPoliciesRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + datapolicy.ListDataPoliciesRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for list_data_policies Override in a subclass to manipulate the request or metadata @@ -242,8 +260,10 @@ def post_list_data_policies( def pre_rename_data_policy( self, request: datapolicy.RenameDataPolicyRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[datapolicy.RenameDataPolicyRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + datapolicy.RenameDataPolicyRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for rename_data_policy Override in a subclass to manipulate the request or metadata @@ -265,8 +285,10 @@ def post_rename_data_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 @@ -286,8 +308,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 @@ -309,8 +334,10 @@ def post_test_iam_permissions( def pre_update_data_policy( self, request: datapolicy.UpdateDataPolicyRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[datapolicy.UpdateDataPolicyRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + datapolicy.UpdateDataPolicyRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for update_data_policy Override in a subclass to manipulate the request or metadata @@ -453,7 +480,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> datapolicy.DataPolicy: r"""Call the create data policy method over HTTP. @@ -464,8 +491,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.datapolicy.DataPolicy: @@ -475,6 +504,7 @@ def __call__( http_options = ( _BaseDataPolicyServiceRestTransport._BaseCreateDataPolicy._get_http_options() ) + request, metadata = self._interceptor.pre_create_data_policy( request, metadata ) @@ -491,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.cloud.bigquery.datapolicies_v1.DataPolicyServiceClient.CreateDataPolicy", + extra={ + "serviceName": "google.cloud.bigquery.datapolicies.v1.DataPolicyService", + "rpcName": "CreateDataPolicy", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = DataPolicyServiceRestTransport._CreateDataPolicy._get_response( self._host, @@ -512,7 +569,29 @@ def __call__( pb_resp = datapolicy.DataPolicy.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_create_data_policy(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = datapolicy.DataPolicy.to_json(response) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.bigquery.datapolicies_v1.DataPolicyServiceClient.create_data_policy", + extra={ + "serviceName": "google.cloud.bigquery.datapolicies.v1.DataPolicyService", + "rpcName": "CreateDataPolicy", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _DeleteDataPolicy( @@ -550,7 +629,7 @@ 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 policy method over HTTP. @@ -561,13 +640,16 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. """ http_options = ( _BaseDataPolicyServiceRestTransport._BaseDeleteDataPolicy._get_http_options() ) + request, metadata = self._interceptor.pre_delete_data_policy( request, metadata ) @@ -580,6 +662,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.bigquery.datapolicies_v1.DataPolicyServiceClient.DeleteDataPolicy", + extra={ + "serviceName": "google.cloud.bigquery.datapolicies.v1.DataPolicyService", + "rpcName": "DeleteDataPolicy", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = DataPolicyServiceRestTransport._DeleteDataPolicy._get_response( self._host, @@ -630,7 +739,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> datapolicy.DataPolicy: r"""Call the get data policy method over HTTP. @@ -641,8 +750,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.datapolicy.DataPolicy: @@ -652,6 +763,7 @@ def __call__( http_options = ( _BaseDataPolicyServiceRestTransport._BaseGetDataPolicy._get_http_options() ) + request, metadata = self._interceptor.pre_get_data_policy(request, metadata) transcoded_request = _BaseDataPolicyServiceRestTransport._BaseGetDataPolicy._get_transcoded_request( http_options, request @@ -662,6 +774,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.bigquery.datapolicies_v1.DataPolicyServiceClient.GetDataPolicy", + extra={ + "serviceName": "google.cloud.bigquery.datapolicies.v1.DataPolicyService", + "rpcName": "GetDataPolicy", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = DataPolicyServiceRestTransport._GetDataPolicy._get_response( self._host, @@ -682,7 +821,29 @@ def __call__( pb_resp = datapolicy.DataPolicy.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_data_policy(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = datapolicy.DataPolicy.to_json(response) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.bigquery.datapolicies_v1.DataPolicyServiceClient.get_data_policy", + extra={ + "serviceName": "google.cloud.bigquery.datapolicies.v1.DataPolicyService", + "rpcName": "GetDataPolicy", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _GetIamPolicy( @@ -720,7 +881,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> policy_pb2.Policy: r"""Call the get iam policy method over HTTP. @@ -730,8 +891,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each 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: @@ -816,6 +979,7 @@ def __call__( http_options = ( _BaseDataPolicyServiceRestTransport._BaseGetIamPolicy._get_http_options() ) + request, metadata = self._interceptor.pre_get_iam_policy(request, metadata) transcoded_request = _BaseDataPolicyServiceRestTransport._BaseGetIamPolicy._get_transcoded_request( http_options, request @@ -830,6 +994,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.bigquery.datapolicies_v1.DataPolicyServiceClient.GetIamPolicy", + extra={ + "serviceName": "google.cloud.bigquery.datapolicies.v1.DataPolicyService", + "rpcName": "GetIamPolicy", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = DataPolicyServiceRestTransport._GetIamPolicy._get_response( self._host, @@ -851,7 +1042,29 @@ def __call__( pb_resp = resp json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_iam_policy(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = json_format.MessageToJson(resp) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.bigquery.datapolicies_v1.DataPolicyServiceClient.get_iam_policy", + extra={ + "serviceName": "google.cloud.bigquery.datapolicies.v1.DataPolicyService", + "rpcName": "GetIamPolicy", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ListDataPolicies( @@ -889,7 +1102,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> datapolicy.ListDataPoliciesResponse: r"""Call the list data policies method over HTTP. @@ -900,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: ~.datapolicy.ListDataPoliciesResponse: @@ -913,6 +1128,7 @@ def __call__( http_options = ( _BaseDataPolicyServiceRestTransport._BaseListDataPolicies._get_http_options() ) + request, metadata = self._interceptor.pre_list_data_policies( request, metadata ) @@ -925,6 +1141,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.bigquery.datapolicies_v1.DataPolicyServiceClient.ListDataPolicies", + extra={ + "serviceName": "google.cloud.bigquery.datapolicies.v1.DataPolicyService", + "rpcName": "ListDataPolicies", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = DataPolicyServiceRestTransport._ListDataPolicies._get_response( self._host, @@ -945,7 +1188,31 @@ def __call__( pb_resp = datapolicy.ListDataPoliciesResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_data_policies(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = datapolicy.ListDataPoliciesResponse.to_json( + response + ) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.bigquery.datapolicies_v1.DataPolicyServiceClient.list_data_policies", + extra={ + "serviceName": "google.cloud.bigquery.datapolicies.v1.DataPolicyService", + "rpcName": "ListDataPolicies", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _RenameDataPolicy( @@ -984,7 +1251,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> datapolicy.DataPolicy: r"""Call the rename data policy method over HTTP. @@ -995,8 +1262,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.datapolicy.DataPolicy: @@ -1006,6 +1275,7 @@ def __call__( http_options = ( _BaseDataPolicyServiceRestTransport._BaseRenameDataPolicy._get_http_options() ) + request, metadata = self._interceptor.pre_rename_data_policy( request, metadata ) @@ -1022,6 +1292,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.bigquery.datapolicies_v1.DataPolicyServiceClient.RenameDataPolicy", + extra={ + "serviceName": "google.cloud.bigquery.datapolicies.v1.DataPolicyService", + "rpcName": "RenameDataPolicy", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = DataPolicyServiceRestTransport._RenameDataPolicy._get_response( self._host, @@ -1043,7 +1340,29 @@ def __call__( pb_resp = datapolicy.DataPolicy.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_rename_data_policy(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = datapolicy.DataPolicy.to_json(response) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.bigquery.datapolicies_v1.DataPolicyServiceClient.rename_data_policy", + extra={ + "serviceName": "google.cloud.bigquery.datapolicies.v1.DataPolicyService", + "rpcName": "RenameDataPolicy", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _SetIamPolicy( @@ -1081,7 +1400,7 @@ 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. @@ -1091,8 +1410,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.policy_pb2.Policy: @@ -1177,6 +1498,7 @@ def __call__( http_options = ( _BaseDataPolicyServiceRestTransport._BaseSetIamPolicy._get_http_options() ) + request, metadata = self._interceptor.pre_set_iam_policy(request, metadata) transcoded_request = _BaseDataPolicyServiceRestTransport._BaseSetIamPolicy._get_transcoded_request( http_options, request @@ -1191,6 +1513,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.bigquery.datapolicies_v1.DataPolicyServiceClient.SetIamPolicy", + extra={ + "serviceName": "google.cloud.bigquery.datapolicies.v1.DataPolicyService", + "rpcName": "SetIamPolicy", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = DataPolicyServiceRestTransport._SetIamPolicy._get_response( self._host, @@ -1212,7 +1561,29 @@ def __call__( pb_resp = resp json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_set_iam_policy(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = json_format.MessageToJson(resp) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.bigquery.datapolicies_v1.DataPolicyServiceClient.set_iam_policy", + extra={ + "serviceName": "google.cloud.bigquery.datapolicies.v1.DataPolicyService", + "rpcName": "SetIamPolicy", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _TestIamPermissions( @@ -1251,7 +1622,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> iam_policy_pb2.TestIamPermissionsResponse: r"""Call the test iam permissions method over HTTP. @@ -1261,8 +1632,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each 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: @@ -1272,6 +1645,7 @@ def __call__( http_options = ( _BaseDataPolicyServiceRestTransport._BaseTestIamPermissions._get_http_options() ) + request, metadata = self._interceptor.pre_test_iam_permissions( request, metadata ) @@ -1288,6 +1662,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.bigquery.datapolicies_v1.DataPolicyServiceClient.TestIamPermissions", + extra={ + "serviceName": "google.cloud.bigquery.datapolicies.v1.DataPolicyService", + "rpcName": "TestIamPermissions", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = DataPolicyServiceRestTransport._TestIamPermissions._get_response( self._host, @@ -1309,7 +1710,29 @@ def __call__( pb_resp = resp json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_test_iam_permissions(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = json_format.MessageToJson(resp) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.bigquery.datapolicies_v1.DataPolicyServiceClient.test_iam_permissions", + extra={ + "serviceName": "google.cloud.bigquery.datapolicies.v1.DataPolicyService", + "rpcName": "TestIamPermissions", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _UpdateDataPolicy( @@ -1348,7 +1771,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> datapolicy.DataPolicy: r"""Call the update data policy method over HTTP. @@ -1359,8 +1782,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.datapolicy.DataPolicy: @@ -1370,6 +1795,7 @@ def __call__( http_options = ( _BaseDataPolicyServiceRestTransport._BaseUpdateDataPolicy._get_http_options() ) + request, metadata = self._interceptor.pre_update_data_policy( request, metadata ) @@ -1386,6 +1812,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.bigquery.datapolicies_v1.DataPolicyServiceClient.UpdateDataPolicy", + extra={ + "serviceName": "google.cloud.bigquery.datapolicies.v1.DataPolicyService", + "rpcName": "UpdateDataPolicy", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = DataPolicyServiceRestTransport._UpdateDataPolicy._get_response( self._host, @@ -1407,7 +1860,29 @@ def __call__( pb_resp = datapolicy.DataPolicy.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_update_data_policy(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = datapolicy.DataPolicy.to_json(response) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.bigquery.datapolicies_v1.DataPolicyServiceClient.update_data_policy", + extra={ + "serviceName": "google.cloud.bigquery.datapolicies.v1.DataPolicyService", + "rpcName": "UpdateDataPolicy", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp @property diff --git a/packages/google-cloud-bigquery-datapolicies/google/cloud/bigquery_datapolicies_v1beta1/gapic_version.py b/packages/google-cloud-bigquery-datapolicies/google/cloud/bigquery_datapolicies_v1beta1/gapic_version.py index 8ebdaa033b52..558c8aab67c5 100644 --- a/packages/google-cloud-bigquery-datapolicies/google/cloud/bigquery_datapolicies_v1beta1/gapic_version.py +++ b/packages/google-cloud-bigquery-datapolicies/google/cloud/bigquery_datapolicies_v1beta1/gapic_version.py @@ -13,4 +13,4 @@ # See the License for the specific language governing permissions and # limitations under the License. # -__version__ = "0.6.10" # {x-release-please-version} +__version__ = "0.0.0" # {x-release-please-version} diff --git a/packages/google-cloud-bigquery-datapolicies/google/cloud/bigquery_datapolicies_v1beta1/services/data_policy_service/async_client.py b/packages/google-cloud-bigquery-datapolicies/google/cloud/bigquery_datapolicies_v1beta1/services/data_policy_service/async_client.py index a1bfade9d9f6..b6e2c73ebb29 100644 --- a/packages/google-cloud-bigquery-datapolicies/google/cloud/bigquery_datapolicies_v1beta1/services/data_policy_service/async_client.py +++ b/packages/google-cloud-bigquery-datapolicies/google/cloud/bigquery_datapolicies_v1beta1/services/data_policy_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, DataPolicyServiceTransport from .transports.grpc_asyncio import DataPolicyServiceGrpcAsyncIOTransport +try: + from google.api_core import client_logging # type: ignore + + CLIENT_LOGGING_SUPPORTED = True # pragma: NO COVER +except ImportError: # pragma: NO COVER + CLIENT_LOGGING_SUPPORTED = False + +_LOGGER = std_logging.getLogger(__name__) + class DataPolicyServiceAsyncClient: """Data Policy Service provides APIs for managing the @@ -268,6 +278,28 @@ def __init__( client_info=client_info, ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + std_logging.DEBUG + ): # pragma: NO COVER + _LOGGER.debug( + "Created client `google.cloud.bigquery.datapolicies_v1beta1.DataPolicyServiceAsyncClient`.", + extra={ + "serviceName": "google.cloud.bigquery.datapolicies.v1beta1.DataPolicyService", + "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.bigquery.datapolicies.v1beta1.DataPolicyService", + "credentialsType": None, + }, + ) + async def create_data_policy( self, request: Optional[Union[datapolicy.CreateDataPolicyRequest, dict]] = None, @@ -276,7 +308,7 @@ async def create_data_policy( data_policy: Optional[datapolicy.DataPolicy] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> datapolicy.DataPolicy: r"""Creates a new data policy under a project with the given ``dataPolicyId`` (used as the display name), policy tag, and @@ -336,8 +368,10 @@ async def sample_create_data_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.bigquery_datapolicies_v1beta1.types.DataPolicy: @@ -399,7 +433,7 @@ async def update_data_policy( update_mask: Optional[field_mask_pb2.FieldMask] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> datapolicy.DataPolicy: r"""Updates the metadata for an existing data policy. The target data policy can be specified by the resource @@ -465,8 +499,10 @@ async def sample_update_data_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.bigquery_datapolicies_v1beta1.types.DataPolicy: @@ -529,7 +565,7 @@ async def delete_data_policy( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> None: r"""Deletes the data policy specified by its resource name. @@ -572,8 +608,10 @@ async def sample_delete_data_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`. """ # Create or coerce a protobuf request object. # - Quick check: If we got a request object, we should *not* have @@ -625,7 +663,7 @@ async def get_data_policy( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> datapolicy.DataPolicy: r"""Gets the data policy specified by its resource name. @@ -670,8 +708,10 @@ async def sample_get_data_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.bigquery_datapolicies_v1beta1.types.DataPolicy: @@ -730,7 +770,7 @@ async def list_data_policies( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListDataPoliciesAsyncPager: r"""List all of the data policies in the specified parent project. @@ -777,8 +817,10 @@ async def sample_list_data_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.bigquery_datapolicies_v1beta1.services.data_policy_service.pagers.ListDataPoliciesAsyncPager: @@ -852,7 +894,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 the specified data policy. @@ -889,8 +931,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: @@ -966,7 +1010,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 policy for the specified data policy. @@ -1003,8 +1047,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: @@ -1080,7 +1126,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"""Returns the caller's permission on the specified data policy resource. @@ -1119,8 +1165,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: diff --git a/packages/google-cloud-bigquery-datapolicies/google/cloud/bigquery_datapolicies_v1beta1/services/data_policy_service/client.py b/packages/google-cloud-bigquery-datapolicies/google/cloud/bigquery_datapolicies_v1beta1/services/data_policy_service/client.py index a71fefd1fcc2..c74037a18619 100644 --- a/packages/google-cloud-bigquery-datapolicies/google/cloud/bigquery_datapolicies_v1beta1/services/data_policy_service/client.py +++ b/packages/google-cloud-bigquery-datapolicies/google/cloud/bigquery_datapolicies_v1beta1/services/data_policy_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.iam.v1 import iam_policy_pb2 # type: ignore from google.iam.v1 import policy_pb2 # type: ignore from google.protobuf import field_mask_pb2 # type: ignore @@ -590,6 +600,10 @@ def __init__( # Initialize the universe domain validation. self._is_universe_domain_valid = False + if CLIENT_LOGGING_SUPPORTED: # pragma: NO COVER + # 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.cloud.bigquery.datapolicies_v1beta1.DataPolicyServiceClient`.", + extra={ + "serviceName": "google.cloud.bigquery.datapolicies.v1beta1.DataPolicyService", + "universeDomain": getattr( + self._transport._credentials, "universe_domain", "" + ), + "credentialsType": f"{type(self._transport._credentials).__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.bigquery.datapolicies.v1beta1.DataPolicyService", + "credentialsType": None, + }, + ) + def create_data_policy( self, request: Optional[Union[datapolicy.CreateDataPolicyRequest, dict]] = None, @@ -664,7 +701,7 @@ def create_data_policy( data_policy: Optional[datapolicy.DataPolicy] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> datapolicy.DataPolicy: r"""Creates a new data policy under a project with the given ``dataPolicyId`` (used as the display name), policy tag, and @@ -724,8 +761,10 @@ def sample_create_data_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.bigquery_datapolicies_v1beta1.types.DataPolicy: @@ -784,7 +823,7 @@ def update_data_policy( update_mask: Optional[field_mask_pb2.FieldMask] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> datapolicy.DataPolicy: r"""Updates the metadata for an existing data policy. The target data policy can be specified by the resource @@ -850,8 +889,10 @@ def sample_update_data_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.bigquery_datapolicies_v1beta1.types.DataPolicy: @@ -911,7 +952,7 @@ def delete_data_policy( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> None: r"""Deletes the data policy specified by its resource name. @@ -954,8 +995,10 @@ def sample_delete_data_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`. """ # Create or coerce a protobuf request object. # - Quick check: If we got a request object, we should *not* have @@ -1004,7 +1047,7 @@ def get_data_policy( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> datapolicy.DataPolicy: r"""Gets the data policy specified by its resource name. @@ -1049,8 +1092,10 @@ def sample_get_data_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.bigquery_datapolicies_v1beta1.types.DataPolicy: @@ -1106,7 +1151,7 @@ def list_data_policies( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListDataPoliciesPager: r"""List all of the data policies in the specified parent project. @@ -1153,8 +1198,10 @@ def sample_list_data_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.bigquery_datapolicies_v1beta1.services.data_policy_service.pagers.ListDataPoliciesPager: @@ -1225,7 +1272,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 the specified data policy. @@ -1262,8 +1309,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: @@ -1338,7 +1387,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 policy for the specified data policy. @@ -1375,8 +1424,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: @@ -1451,7 +1502,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"""Returns the caller's permission on the specified data policy resource. @@ -1490,8 +1541,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: diff --git a/packages/google-cloud-bigquery-datapolicies/google/cloud/bigquery_datapolicies_v1beta1/services/data_policy_service/pagers.py b/packages/google-cloud-bigquery-datapolicies/google/cloud/bigquery_datapolicies_v1beta1/services/data_policy_service/pagers.py index ff84328942e5..3101b6f578d4 100644 --- a/packages/google-cloud-bigquery-datapolicies/google/cloud/bigquery_datapolicies_v1beta1/services/data_policy_service/pagers.py +++ b/packages/google-cloud-bigquery-datapolicies/google/cloud/bigquery_datapolicies_v1beta1/services/data_policy_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 = datapolicy.ListDataPoliciesRequest(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 = datapolicy.ListDataPoliciesRequest(request) diff --git a/packages/google-cloud-bigquery-datapolicies/google/cloud/bigquery_datapolicies_v1beta1/services/data_policy_service/transports/grpc.py b/packages/google-cloud-bigquery-datapolicies/google/cloud/bigquery_datapolicies_v1beta1/services/data_policy_service/transports/grpc.py index 8aa4ca771572..320caf42967c 100644 --- a/packages/google-cloud-bigquery-datapolicies/google/cloud/bigquery_datapolicies_v1beta1/services/data_policy_service/transports/grpc.py +++ b/packages/google-cloud-bigquery-datapolicies/google/cloud/bigquery_datapolicies_v1beta1/services/data_policy_service/transports/grpc.py @@ -13,6 +13,9 @@ # See the License for the specific language governing permissions and # limitations under the License. # +import json +import logging as std_logging +import pickle from typing import Callable, Dict, Optional, Sequence, Tuple, Union import warnings @@ -23,12 +26,90 @@ from google.iam.v1 import iam_policy_pb2 # type: ignore from google.iam.v1 import policy_pb2 # type: ignore from google.protobuf import empty_pb2 # type: ignore +from google.protobuf.json_format import MessageToJson +import google.protobuf.message import grpc # type: ignore +import proto # type: ignore from google.cloud.bigquery_datapolicies_v1beta1.types import datapolicy from .base import DEFAULT_CLIENT_INFO, DataPolicyServiceTransport +try: + from google.api_core import client_logging # 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.bigquery.datapolicies.v1beta1.DataPolicyService", + "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.bigquery.datapolicies.v1beta1.DataPolicyService", + "rpcName": client_call_details.method, + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class DataPolicyServiceGrpcTransport(DataPolicyServiceTransport): """gRPC backend transport for DataPolicyService. @@ -183,7 +264,12 @@ def __init__( ], ) - # Wrap messages. This must be done after self._grpc_channel exists + self._interceptor = _LoggingClientInterceptor() + self._logged_channel = grpc.intercept_channel( + self._grpc_channel, self._interceptor + ) + + # Wrap messages. This must be done after self._logged_channel exists self._prep_wrapped_messages(client_info) @classmethod @@ -259,7 +345,7 @@ def create_data_policy( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_data_policy" not in self._stubs: - self._stubs["create_data_policy"] = self.grpc_channel.unary_unary( + self._stubs["create_data_policy"] = self._logged_channel.unary_unary( "/google.cloud.bigquery.datapolicies.v1beta1.DataPolicyService/CreateDataPolicy", request_serializer=datapolicy.CreateDataPolicyRequest.serialize, response_deserializer=datapolicy.DataPolicy.deserialize, @@ -287,7 +373,7 @@ def update_data_policy( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_data_policy" not in self._stubs: - self._stubs["update_data_policy"] = self.grpc_channel.unary_unary( + self._stubs["update_data_policy"] = self._logged_channel.unary_unary( "/google.cloud.bigquery.datapolicies.v1beta1.DataPolicyService/UpdateDataPolicy", request_serializer=datapolicy.UpdateDataPolicyRequest.serialize, response_deserializer=datapolicy.DataPolicy.deserialize, @@ -314,7 +400,7 @@ def delete_data_policy( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_data_policy" not in self._stubs: - self._stubs["delete_data_policy"] = self.grpc_channel.unary_unary( + self._stubs["delete_data_policy"] = self._logged_channel.unary_unary( "/google.cloud.bigquery.datapolicies.v1beta1.DataPolicyService/DeleteDataPolicy", request_serializer=datapolicy.DeleteDataPolicyRequest.serialize, response_deserializer=empty_pb2.Empty.FromString, @@ -340,7 +426,7 @@ def get_data_policy( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_data_policy" not in self._stubs: - self._stubs["get_data_policy"] = self.grpc_channel.unary_unary( + self._stubs["get_data_policy"] = self._logged_channel.unary_unary( "/google.cloud.bigquery.datapolicies.v1beta1.DataPolicyService/GetDataPolicy", request_serializer=datapolicy.GetDataPolicyRequest.serialize, response_deserializer=datapolicy.DataPolicy.deserialize, @@ -369,7 +455,7 @@ def list_data_policies( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_data_policies" not in self._stubs: - self._stubs["list_data_policies"] = self.grpc_channel.unary_unary( + self._stubs["list_data_policies"] = self._logged_channel.unary_unary( "/google.cloud.bigquery.datapolicies.v1beta1.DataPolicyService/ListDataPolicies", request_serializer=datapolicy.ListDataPoliciesRequest.serialize, response_deserializer=datapolicy.ListDataPoliciesResponse.deserialize, @@ -395,7 +481,7 @@ def get_iam_policy( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_iam_policy" not in self._stubs: - self._stubs["get_iam_policy"] = self.grpc_channel.unary_unary( + self._stubs["get_iam_policy"] = self._logged_channel.unary_unary( "/google.cloud.bigquery.datapolicies.v1beta1.DataPolicyService/GetIamPolicy", request_serializer=iam_policy_pb2.GetIamPolicyRequest.SerializeToString, response_deserializer=policy_pb2.Policy.FromString, @@ -421,7 +507,7 @@ def set_iam_policy( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "set_iam_policy" not in self._stubs: - self._stubs["set_iam_policy"] = self.grpc_channel.unary_unary( + self._stubs["set_iam_policy"] = self._logged_channel.unary_unary( "/google.cloud.bigquery.datapolicies.v1beta1.DataPolicyService/SetIamPolicy", request_serializer=iam_policy_pb2.SetIamPolicyRequest.SerializeToString, response_deserializer=policy_pb2.Policy.FromString, @@ -451,7 +537,7 @@ def test_iam_permissions( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "test_iam_permissions" not in self._stubs: - self._stubs["test_iam_permissions"] = self.grpc_channel.unary_unary( + self._stubs["test_iam_permissions"] = self._logged_channel.unary_unary( "/google.cloud.bigquery.datapolicies.v1beta1.DataPolicyService/TestIamPermissions", request_serializer=iam_policy_pb2.TestIamPermissionsRequest.SerializeToString, response_deserializer=iam_policy_pb2.TestIamPermissionsResponse.FromString, @@ -459,7 +545,7 @@ def test_iam_permissions( return self._stubs["test_iam_permissions"] def close(self): - self.grpc_channel.close() + self._logged_channel.close() @property def kind(self) -> str: diff --git a/packages/google-cloud-bigquery-datapolicies/google/cloud/bigquery_datapolicies_v1beta1/services/data_policy_service/transports/grpc_asyncio.py b/packages/google-cloud-bigquery-datapolicies/google/cloud/bigquery_datapolicies_v1beta1/services/data_policy_service/transports/grpc_asyncio.py index c62f5a5f0b0c..067e9ec9bc1e 100644 --- a/packages/google-cloud-bigquery-datapolicies/google/cloud/bigquery_datapolicies_v1beta1/services/data_policy_service/transports/grpc_asyncio.py +++ b/packages/google-cloud-bigquery-datapolicies/google/cloud/bigquery_datapolicies_v1beta1/services/data_policy_service/transports/grpc_asyncio.py @@ -14,6 +14,9 @@ # limitations under the License. # import inspect +import json +import logging as std_logging +import pickle from typing import Awaitable, Callable, Dict, Optional, Sequence, Tuple, Union import warnings @@ -25,14 +28,93 @@ from google.iam.v1 import iam_policy_pb2 # type: ignore from google.iam.v1 import policy_pb2 # type: ignore from google.protobuf import empty_pb2 # type: ignore +from google.protobuf.json_format import MessageToJson +import google.protobuf.message import grpc # type: ignore from grpc.experimental import aio # type: ignore +import proto # type: ignore from google.cloud.bigquery_datapolicies_v1beta1.types import datapolicy from .base import DEFAULT_CLIENT_INFO, DataPolicyServiceTransport from .grpc import DataPolicyServiceGrpcTransport +try: + from google.api_core import client_logging # 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.bigquery.datapolicies.v1beta1.DataPolicyService", + "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.bigquery.datapolicies.v1beta1.DataPolicyService", + "rpcName": str(client_call_details.method), + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class DataPolicyServiceGrpcAsyncIOTransport(DataPolicyServiceTransport): """gRPC AsyncIO backend transport for DataPolicyService. @@ -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 create_data_policy( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_data_policy" not in self._stubs: - self._stubs["create_data_policy"] = self.grpc_channel.unary_unary( + self._stubs["create_data_policy"] = self._logged_channel.unary_unary( "/google.cloud.bigquery.datapolicies.v1beta1.DataPolicyService/CreateDataPolicy", request_serializer=datapolicy.CreateDataPolicyRequest.serialize, response_deserializer=datapolicy.DataPolicy.deserialize, @@ -299,7 +384,7 @@ def update_data_policy( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_data_policy" not in self._stubs: - self._stubs["update_data_policy"] = self.grpc_channel.unary_unary( + self._stubs["update_data_policy"] = self._logged_channel.unary_unary( "/google.cloud.bigquery.datapolicies.v1beta1.DataPolicyService/UpdateDataPolicy", request_serializer=datapolicy.UpdateDataPolicyRequest.serialize, response_deserializer=datapolicy.DataPolicy.deserialize, @@ -326,7 +411,7 @@ def delete_data_policy( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_data_policy" not in self._stubs: - self._stubs["delete_data_policy"] = self.grpc_channel.unary_unary( + self._stubs["delete_data_policy"] = self._logged_channel.unary_unary( "/google.cloud.bigquery.datapolicies.v1beta1.DataPolicyService/DeleteDataPolicy", request_serializer=datapolicy.DeleteDataPolicyRequest.serialize, response_deserializer=empty_pb2.Empty.FromString, @@ -352,7 +437,7 @@ def get_data_policy( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_data_policy" not in self._stubs: - self._stubs["get_data_policy"] = self.grpc_channel.unary_unary( + self._stubs["get_data_policy"] = self._logged_channel.unary_unary( "/google.cloud.bigquery.datapolicies.v1beta1.DataPolicyService/GetDataPolicy", request_serializer=datapolicy.GetDataPolicyRequest.serialize, response_deserializer=datapolicy.DataPolicy.deserialize, @@ -382,7 +467,7 @@ def list_data_policies( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_data_policies" not in self._stubs: - self._stubs["list_data_policies"] = self.grpc_channel.unary_unary( + self._stubs["list_data_policies"] = self._logged_channel.unary_unary( "/google.cloud.bigquery.datapolicies.v1beta1.DataPolicyService/ListDataPolicies", request_serializer=datapolicy.ListDataPoliciesRequest.serialize, response_deserializer=datapolicy.ListDataPoliciesResponse.deserialize, @@ -408,7 +493,7 @@ def get_iam_policy( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_iam_policy" not in self._stubs: - self._stubs["get_iam_policy"] = self.grpc_channel.unary_unary( + self._stubs["get_iam_policy"] = self._logged_channel.unary_unary( "/google.cloud.bigquery.datapolicies.v1beta1.DataPolicyService/GetIamPolicy", request_serializer=iam_policy_pb2.GetIamPolicyRequest.SerializeToString, response_deserializer=policy_pb2.Policy.FromString, @@ -434,7 +519,7 @@ def set_iam_policy( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "set_iam_policy" not in self._stubs: - self._stubs["set_iam_policy"] = self.grpc_channel.unary_unary( + self._stubs["set_iam_policy"] = self._logged_channel.unary_unary( "/google.cloud.bigquery.datapolicies.v1beta1.DataPolicyService/SetIamPolicy", request_serializer=iam_policy_pb2.SetIamPolicyRequest.SerializeToString, response_deserializer=policy_pb2.Policy.FromString, @@ -464,7 +549,7 @@ def test_iam_permissions( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "test_iam_permissions" not in self._stubs: - self._stubs["test_iam_permissions"] = self.grpc_channel.unary_unary( + self._stubs["test_iam_permissions"] = self._logged_channel.unary_unary( "/google.cloud.bigquery.datapolicies.v1beta1.DataPolicyService/TestIamPermissions", request_serializer=iam_policy_pb2.TestIamPermissionsRequest.SerializeToString, response_deserializer=iam_policy_pb2.TestIamPermissionsResponse.FromString, @@ -594,7 +679,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-bigquery-datapolicies/samples/generated_samples/snippet_metadata_google.cloud.bigquery.datapolicies.v1.json b/packages/google-cloud-bigquery-datapolicies/samples/generated_samples/snippet_metadata_google.cloud.bigquery.datapolicies.v1.json index 5dba0dd52f72..8f3adb520dfb 100644 --- a/packages/google-cloud-bigquery-datapolicies/samples/generated_samples/snippet_metadata_google.cloud.bigquery.datapolicies.v1.json +++ b/packages/google-cloud-bigquery-datapolicies/samples/generated_samples/snippet_metadata_google.cloud.bigquery.datapolicies.v1.json @@ -8,7 +8,7 @@ ], "language": "PYTHON", "name": "google-cloud-bigquery-datapolicies", - "version": "0.6.10" + "version": "0.1.0" }, "snippets": [ { @@ -51,7 +51,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.bigquery_datapolicies_v1.types.DataPolicy", @@ -135,7 +135,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.bigquery_datapolicies_v1.types.DataPolicy", @@ -216,7 +216,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "shortName": "delete_data_policy" @@ -293,7 +293,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "shortName": "delete_data_policy" @@ -371,7 +371,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.bigquery_datapolicies_v1.types.DataPolicy", @@ -451,7 +451,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.bigquery_datapolicies_v1.types.DataPolicy", @@ -528,7 +528,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.iam.v1.policy_pb2.Policy", @@ -604,7 +604,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.iam.v1.policy_pb2.Policy", @@ -685,7 +685,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.bigquery_datapolicies_v1.services.data_policy_service.pagers.ListDataPoliciesAsyncPager", @@ -765,7 +765,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.bigquery_datapolicies_v1.services.data_policy_service.pagers.ListDataPoliciesPager", @@ -850,7 +850,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.bigquery_datapolicies_v1.types.DataPolicy", @@ -934,7 +934,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.bigquery_datapolicies_v1.types.DataPolicy", @@ -1011,7 +1011,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.iam.v1.policy_pb2.Policy", @@ -1087,7 +1087,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.iam.v1.policy_pb2.Policy", @@ -1164,7 +1164,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.iam.v1.iam_policy_pb2.TestIamPermissionsResponse", @@ -1240,7 +1240,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.iam.v1.iam_policy_pb2.TestIamPermissionsResponse", @@ -1325,7 +1325,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.bigquery_datapolicies_v1.types.DataPolicy", @@ -1409,7 +1409,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.bigquery_datapolicies_v1.types.DataPolicy", diff --git a/packages/google-cloud-bigquery-datapolicies/samples/generated_samples/snippet_metadata_google.cloud.bigquery.datapolicies.v1beta1.json b/packages/google-cloud-bigquery-datapolicies/samples/generated_samples/snippet_metadata_google.cloud.bigquery.datapolicies.v1beta1.json index f1f0fc45f50f..f5896d1aac3d 100644 --- a/packages/google-cloud-bigquery-datapolicies/samples/generated_samples/snippet_metadata_google.cloud.bigquery.datapolicies.v1beta1.json +++ b/packages/google-cloud-bigquery-datapolicies/samples/generated_samples/snippet_metadata_google.cloud.bigquery.datapolicies.v1beta1.json @@ -8,7 +8,7 @@ ], "language": "PYTHON", "name": "google-cloud-bigquery-datapolicies", - "version": "0.6.10" + "version": "0.1.0" }, "snippets": [ { @@ -51,7 +51,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.bigquery_datapolicies_v1beta1.types.DataPolicy", @@ -135,7 +135,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.bigquery_datapolicies_v1beta1.types.DataPolicy", @@ -216,7 +216,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "shortName": "delete_data_policy" @@ -293,7 +293,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "shortName": "delete_data_policy" @@ -371,7 +371,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.bigquery_datapolicies_v1beta1.types.DataPolicy", @@ -451,7 +451,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.bigquery_datapolicies_v1beta1.types.DataPolicy", @@ -528,7 +528,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.iam.v1.policy_pb2.Policy", @@ -604,7 +604,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.iam.v1.policy_pb2.Policy", @@ -685,7 +685,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.bigquery_datapolicies_v1beta1.services.data_policy_service.pagers.ListDataPoliciesAsyncPager", @@ -765,7 +765,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.bigquery_datapolicies_v1beta1.services.data_policy_service.pagers.ListDataPoliciesPager", @@ -842,7 +842,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.iam.v1.policy_pb2.Policy", @@ -918,7 +918,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.iam.v1.policy_pb2.Policy", @@ -995,7 +995,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.iam.v1.iam_policy_pb2.TestIamPermissionsResponse", @@ -1071,7 +1071,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.iam.v1.iam_policy_pb2.TestIamPermissionsResponse", @@ -1156,7 +1156,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.bigquery_datapolicies_v1beta1.types.DataPolicy", @@ -1240,7 +1240,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.bigquery_datapolicies_v1beta1.types.DataPolicy", diff --git a/packages/google-cloud-bigquery-datapolicies/tests/unit/gapic/bigquery_datapolicies_v1/test_data_policy_service.py b/packages/google-cloud-bigquery-datapolicies/tests/unit/gapic/bigquery_datapolicies_v1/test_data_policy_service.py index 289587bb321e..c38e40f4af88 100644 --- a/packages/google-cloud-bigquery-datapolicies/tests/unit/gapic/bigquery_datapolicies_v1/test_data_policy_service.py +++ b/packages/google-cloud-bigquery-datapolicies/tests/unit/gapic/bigquery_datapolicies_v1/test_data_policy_service.py @@ -4319,6 +4319,7 @@ def test_create_data_policy_rest_required_fields( response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.create_data_policy(request) @@ -4373,6 +4374,7 @@ def test_create_data_policy_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.create_data_policy(**mock_args) @@ -4507,6 +4509,7 @@ def test_update_data_policy_rest_required_fields( response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.update_data_policy(request) @@ -4557,6 +4560,7 @@ def test_update_data_policy_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.update_data_policy(**mock_args) @@ -4698,6 +4702,7 @@ def test_rename_data_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.rename_data_policy(request) @@ -4754,6 +4759,7 @@ def test_rename_data_policy_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.rename_data_policy(**mock_args) @@ -4887,6 +4893,7 @@ def test_delete_data_policy_rest_required_fields( response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.delete_data_policy(request) @@ -4932,6 +4939,7 @@ def test_delete_data_policy_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_policy(**mock_args) @@ -5063,6 +5071,7 @@ def test_get_data_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_data_policy(request) @@ -5110,6 +5119,7 @@ def test_get_data_policy_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.get_data_policy(**mock_args) @@ -5253,6 +5263,7 @@ def test_list_data_policies_rest_required_fields( response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.list_data_policies(request) @@ -5307,6 +5318,7 @@ def test_list_data_policies_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.list_data_policies(**mock_args) @@ -5500,6 +5512,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) @@ -5618,6 +5631,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) @@ -5752,6 +5766,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) @@ -6387,6 +6402,7 @@ def test_create_data_policy_rest_bad_request( response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.create_data_policy(request) @@ -6499,6 +6515,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_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_policy(request) # Establish that the response is the type that we expect. @@ -6544,6 +6561,7 @@ def test_create_data_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 = datapolicy.DataPolicy.to_json(datapolicy.DataPolicy()) req.return_value.content = return_value @@ -6592,6 +6610,7 @@ def test_update_data_policy_rest_bad_request( response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.update_data_policy(request) @@ -6708,6 +6727,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_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_policy(request) # Establish that the response is the type that we expect. @@ -6753,6 +6773,7 @@ def test_update_data_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 = datapolicy.DataPolicy.to_json(datapolicy.DataPolicy()) req.return_value.content = return_value @@ -6797,6 +6818,7 @@ def test_rename_data_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.rename_data_policy(request) @@ -6835,6 +6857,7 @@ def test_rename_data_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.rename_data_policy(request) # Establish that the response is the type that we expect. @@ -6880,6 +6903,7 @@ def test_rename_data_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 = datapolicy.DataPolicy.to_json(datapolicy.DataPolicy()) req.return_value.content = return_value @@ -6924,6 +6948,7 @@ def test_delete_data_policy_rest_bad_request( response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.delete_data_policy(request) @@ -6954,6 +6979,7 @@ def test_delete_data_policy_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_policy(request) # Establish that the response is the type that we expect. @@ -6990,6 +7016,7 @@ def test_delete_data_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"} request = datapolicy.DeleteDataPolicyRequest() metadata = [ @@ -7028,6 +7055,7 @@ def test_get_data_policy_rest_bad_request(request_type=datapolicy.GetDataPolicyR response_value.status_code = 400 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_policy(request) @@ -7066,6 +7094,7 @@ def test_get_data_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_data_policy(request) # Establish that the response is the type that we expect. @@ -7111,6 +7140,7 @@ def test_get_data_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 = datapolicy.DataPolicy.to_json(datapolicy.DataPolicy()) req.return_value.content = return_value @@ -7155,6 +7185,7 @@ def test_list_data_policies_rest_bad_request( response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.list_data_policies(request) @@ -7190,6 +7221,7 @@ def test_list_data_policies_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.list_data_policies(request) # Establish that the response is the type that we expect. @@ -7230,6 +7262,7 @@ def test_list_data_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 = datapolicy.ListDataPoliciesResponse.to_json( datapolicy.ListDataPoliciesResponse() ) @@ -7278,6 +7311,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) @@ -7313,6 +7347,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. @@ -7352,6 +7387,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 @@ -7398,6 +7434,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) @@ -7433,6 +7470,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. @@ -7472,6 +7510,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 @@ -7518,6 +7557,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) @@ -7552,6 +7592,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. @@ -7590,6 +7631,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() ) diff --git a/packages/google-cloud-bigquery-datatransfer/google/cloud/bigquery_datatransfer/gapic_version.py b/packages/google-cloud-bigquery-datatransfer/google/cloud/bigquery_datatransfer/gapic_version.py index 6942500960db..558c8aab67c5 100644 --- a/packages/google-cloud-bigquery-datatransfer/google/cloud/bigquery_datatransfer/gapic_version.py +++ b/packages/google-cloud-bigquery-datatransfer/google/cloud/bigquery_datatransfer/gapic_version.py @@ -13,4 +13,4 @@ # See the License for the specific language governing permissions and # limitations under the License. # -__version__ = "3.17.1" # {x-release-please-version} +__version__ = "0.0.0" # {x-release-please-version} diff --git a/packages/google-cloud-bigquery-datatransfer/google/cloud/bigquery_datatransfer_v1/gapic_version.py b/packages/google-cloud-bigquery-datatransfer/google/cloud/bigquery_datatransfer_v1/gapic_version.py index 6942500960db..558c8aab67c5 100644 --- a/packages/google-cloud-bigquery-datatransfer/google/cloud/bigquery_datatransfer_v1/gapic_version.py +++ b/packages/google-cloud-bigquery-datatransfer/google/cloud/bigquery_datatransfer_v1/gapic_version.py @@ -13,4 +13,4 @@ # See the License for the specific language governing permissions and # limitations under the License. # -__version__ = "3.17.1" # {x-release-please-version} +__version__ = "0.0.0" # {x-release-please-version} diff --git a/packages/google-cloud-bigquery-datatransfer/google/cloud/bigquery_datatransfer_v1/services/data_transfer_service/async_client.py b/packages/google-cloud-bigquery-datatransfer/google/cloud/bigquery_datatransfer_v1/services/data_transfer_service/async_client.py index f9710eae8409..8a87cd16f700 100644 --- a/packages/google-cloud-bigquery-datatransfer/google/cloud/bigquery_datatransfer_v1/services/data_transfer_service/async_client.py +++ b/packages/google-cloud-bigquery-datatransfer/google/cloud/bigquery_datatransfer_v1/services/data_transfer_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, DataTransferServiceTransport from .transports.grpc_asyncio import DataTransferServiceGrpcAsyncIOTransport +try: + from google.api_core import client_logging # type: ignore + + CLIENT_LOGGING_SUPPORTED = True # pragma: NO COVER +except ImportError: # pragma: NO COVER + CLIENT_LOGGING_SUPPORTED = False + +_LOGGER = std_logging.getLogger(__name__) + class DataTransferServiceAsyncClient: """This API allows users to manage their data transfers into @@ -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.bigquery.datatransfer_v1.DataTransferServiceAsyncClient`.", + extra={ + "serviceName": "google.cloud.bigquery.datatransfer.v1.DataTransferService", + "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.bigquery.datatransfer.v1.DataTransferService", + "credentialsType": None, + }, + ) + async def get_data_source( self, request: Optional[Union[datatransfer.GetDataSourceRequest, dict]] = None, @@ -283,7 +315,7 @@ async def get_data_source( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> datatransfer.DataSource: r"""Retrieves a supported data source and returns its settings. @@ -330,8 +362,10 @@ async def sample_get_data_source(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.bigquery_datatransfer_v1.types.DataSource: @@ -392,7 +426,7 @@ async def list_data_sources( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListDataSourcesAsyncPager: r"""Lists supported data sources and returns their settings. @@ -441,8 +475,10 @@ async def sample_list_data_sources(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.bigquery_datatransfer_v1.services.data_transfer_service.pagers.ListDataSourcesAsyncPager: @@ -518,7 +554,7 @@ async def create_transfer_config( transfer_config: Optional[transfer.TransferConfig] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> transfer.TransferConfig: r"""Creates a new data transfer configuration. @@ -589,8 +625,10 @@ async def sample_create_transfer_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.bigquery_datatransfer_v1.types.TransferConfig: @@ -660,7 +698,7 @@ async def update_transfer_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]]] = (), ) -> transfer.TransferConfig: r"""Updates a data transfer configuration. All fields must be set, even if they are not updated. @@ -722,8 +760,10 @@ async def sample_update_transfer_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.bigquery_datatransfer_v1.types.TransferConfig: @@ -794,7 +834,7 @@ async def delete_transfer_config( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> None: r"""Deletes a data transfer configuration, including any associated transfer runs and logs. @@ -840,8 +880,10 @@ async def sample_delete_transfer_config(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. """ # Create or coerce a protobuf request object. # - Quick check: If we got a request object, we should *not* have @@ -893,7 +935,7 @@ async def get_transfer_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]]] = (), ) -> transfer.TransferConfig: r"""Returns information about a data transfer config. @@ -939,8 +981,10 @@ async def sample_get_transfer_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.bigquery_datatransfer_v1.types.TransferConfig: @@ -1007,7 +1051,7 @@ async def list_transfer_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.ListTransferConfigsAsyncPager: r"""Returns information about all transfer configs owned by a project in the specified location. @@ -1054,8 +1098,10 @@ async def sample_list_transfer_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.bigquery_datatransfer_v1.services.data_transfer_service.pagers.ListTransferConfigsAsyncPager: @@ -1132,7 +1178,7 @@ async def schedule_transfer_runs( end_time: Optional[timestamp_pb2.Timestamp] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> datatransfer.ScheduleTransferRunsResponse: r"""Creates transfer runs for a time range [start_time, end_time]. For each date - or whatever granularity the data source supports @@ -1195,8 +1241,10 @@ async def sample_schedule_transfer_runs(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.bigquery_datatransfer_v1.types.ScheduleTransferRunsResponse: @@ -1267,7 +1315,7 @@ async def start_manual_transfer_runs( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> datatransfer.StartManualTransferRunsResponse: r"""Start manual transfer runs to be executed now with schedule_time equal to current time. The transfer runs can be created for a @@ -1307,8 +1355,10 @@ async def sample_start_manual_transfer_runs(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.bigquery_datatransfer_v1.types.StartManualTransferRunsResponse: @@ -1355,7 +1405,7 @@ async def get_transfer_run( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> transfer.TransferRun: r"""Returns information about the particular transfer run. @@ -1403,8 +1453,10 @@ async def sample_get_transfer_run(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.bigquery_datatransfer_v1.types.TransferRun: @@ -1463,7 +1515,7 @@ async def delete_transfer_run( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> None: r"""Deletes the specified transfer run. @@ -1507,8 +1559,10 @@ async def sample_delete_transfer_run(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. """ # Create or coerce a protobuf request object. # - Quick check: If we got a request object, we should *not* have @@ -1560,7 +1614,7 @@ async def list_transfer_runs( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListTransferRunsAsyncPager: r"""Returns information about running and completed transfer runs. @@ -1608,8 +1662,10 @@ async def sample_list_transfer_runs(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.bigquery_datatransfer_v1.services.data_transfer_service.pagers.ListTransferRunsAsyncPager: @@ -1684,7 +1740,7 @@ async def list_transfer_logs( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListTransferLogsAsyncPager: r"""Returns log messages for the transfer run. @@ -1732,8 +1788,10 @@ async def sample_list_transfer_logs(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.bigquery_datatransfer_v1.services.data_transfer_service.pagers.ListTransferLogsAsyncPager: @@ -1808,7 +1866,7 @@ async def check_valid_creds( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> datatransfer.CheckValidCredsResponse: r"""Returns true if valid credentials exist for the given data source and requesting user. @@ -1864,8 +1922,10 @@ async def sample_check_valid_creds(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.bigquery_datatransfer_v1.types.CheckValidCredsResponse: @@ -1925,7 +1985,7 @@ async def enroll_data_sources( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> None: r"""Enroll data sources in a user project. This allows users to create transfer configurations for these data sources. They will @@ -1967,8 +2027,10 @@ async def sample_enroll_data_sources(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. """ # Create or coerce a protobuf request object. # - Use the request object if provided (there's no risk of modifying the input as @@ -2005,7 +2067,7 @@ async def unenroll_data_sources( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> None: r"""Unenroll data sources in a user project. This allows users to remove transfer configurations for these data sources. They will @@ -2045,8 +2107,10 @@ async def sample_unenroll_data_sources(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. """ # Create or coerce a protobuf request object. # - Use the request object if provided (there's no risk of modifying the input as @@ -2083,7 +2147,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. @@ -2094,8 +2158,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. @@ -2136,7 +2202,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. @@ -2147,8 +2213,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-bigquery-datatransfer/google/cloud/bigquery_datatransfer_v1/services/data_transfer_service/client.py b/packages/google-cloud-bigquery-datatransfer/google/cloud/bigquery_datatransfer_v1/services/data_transfer_service/client.py index 3f6bf741deed..21289026f52e 100644 --- a/packages/google-cloud-bigquery-datatransfer/google/cloud/bigquery_datatransfer_v1/services/data_transfer_service/client.py +++ b/packages/google-cloud-bigquery-datatransfer/google/cloud/bigquery_datatransfer_v1/services/data_transfer_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.protobuf import duration_pb2 # type: ignore from google.protobuf import field_mask_pb2 # type: ignore @@ -630,6 +640,10 @@ def __init__( # Initialize the universe domain validation. self._is_universe_domain_valid = False + if CLIENT_LOGGING_SUPPORTED: # pragma: NO COVER + # Setup logging. + client_logging.initialize_logging() + api_key_value = getattr(self._client_options, "api_key", None) if api_key_value and credentials: raise ValueError( @@ -696,6 +710,29 @@ def __init__( api_audience=self._client_options.api_audience, ) + if "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.bigquery.datatransfer_v1.DataTransferServiceClient`.", + extra={ + "serviceName": "google.cloud.bigquery.datatransfer.v1.DataTransferService", + "universeDomain": getattr( + self._transport._credentials, "universe_domain", "" + ), + "credentialsType": f"{type(self._transport._credentials).__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.bigquery.datatransfer.v1.DataTransferService", + "credentialsType": None, + }, + ) + def get_data_source( self, request: Optional[Union[datatransfer.GetDataSourceRequest, dict]] = None, @@ -703,7 +740,7 @@ def get_data_source( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> datatransfer.DataSource: r"""Retrieves a supported data source and returns its settings. @@ -750,8 +787,10 @@ def sample_get_data_source(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.bigquery_datatransfer_v1.types.DataSource: @@ -809,7 +848,7 @@ def list_data_sources( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListDataSourcesPager: r"""Lists supported data sources and returns their settings. @@ -858,8 +897,10 @@ def sample_list_data_sources(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.bigquery_datatransfer_v1.services.data_transfer_service.pagers.ListDataSourcesPager: @@ -932,7 +973,7 @@ def create_transfer_config( transfer_config: Optional[transfer.TransferConfig] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> transfer.TransferConfig: r"""Creates a new data transfer configuration. @@ -1003,8 +1044,10 @@ def sample_create_transfer_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.bigquery_datatransfer_v1.types.TransferConfig: @@ -1071,7 +1114,7 @@ def update_transfer_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]]] = (), ) -> transfer.TransferConfig: r"""Updates a data transfer configuration. All fields must be set, even if they are not updated. @@ -1133,8 +1176,10 @@ def sample_update_transfer_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.bigquery_datatransfer_v1.types.TransferConfig: @@ -1202,7 +1247,7 @@ def delete_transfer_config( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> None: r"""Deletes a data transfer configuration, including any associated transfer runs and logs. @@ -1248,8 +1293,10 @@ def sample_delete_transfer_config(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. """ # Create or coerce a protobuf request object. # - Quick check: If we got a request object, we should *not* have @@ -1298,7 +1345,7 @@ def get_transfer_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]]] = (), ) -> transfer.TransferConfig: r"""Returns information about a data transfer config. @@ -1344,8 +1391,10 @@ def sample_get_transfer_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.bigquery_datatransfer_v1.types.TransferConfig: @@ -1409,7 +1458,7 @@ def list_transfer_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.ListTransferConfigsPager: r"""Returns information about all transfer configs owned by a project in the specified location. @@ -1456,8 +1505,10 @@ def sample_list_transfer_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.bigquery_datatransfer_v1.services.data_transfer_service.pagers.ListTransferConfigsPager: @@ -1531,7 +1582,7 @@ def schedule_transfer_runs( end_time: Optional[timestamp_pb2.Timestamp] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> datatransfer.ScheduleTransferRunsResponse: r"""Creates transfer runs for a time range [start_time, end_time]. For each date - or whatever granularity the data source supports @@ -1594,8 +1645,10 @@ def sample_schedule_transfer_runs(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.bigquery_datatransfer_v1.types.ScheduleTransferRunsResponse: @@ -1663,7 +1716,7 @@ def start_manual_transfer_runs( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> datatransfer.StartManualTransferRunsResponse: r"""Start manual transfer runs to be executed now with schedule_time equal to current time. The transfer runs can be created for a @@ -1703,8 +1756,10 @@ def sample_start_manual_transfer_runs(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.bigquery_datatransfer_v1.types.StartManualTransferRunsResponse: @@ -1751,7 +1806,7 @@ def get_transfer_run( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> transfer.TransferRun: r"""Returns information about the particular transfer run. @@ -1799,8 +1854,10 @@ def sample_get_transfer_run(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.bigquery_datatransfer_v1.types.TransferRun: @@ -1856,7 +1913,7 @@ def delete_transfer_run( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> None: r"""Deletes the specified transfer run. @@ -1900,8 +1957,10 @@ def sample_delete_transfer_run(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. """ # Create or coerce a protobuf request object. # - Quick check: If we got a request object, we should *not* have @@ -1950,7 +2009,7 @@ def list_transfer_runs( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListTransferRunsPager: r"""Returns information about running and completed transfer runs. @@ -1998,8 +2057,10 @@ def sample_list_transfer_runs(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.bigquery_datatransfer_v1.services.data_transfer_service.pagers.ListTransferRunsPager: @@ -2071,7 +2132,7 @@ def list_transfer_logs( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListTransferLogsPager: r"""Returns log messages for the transfer run. @@ -2119,8 +2180,10 @@ def sample_list_transfer_logs(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.bigquery_datatransfer_v1.services.data_transfer_service.pagers.ListTransferLogsPager: @@ -2192,7 +2255,7 @@ def check_valid_creds( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> datatransfer.CheckValidCredsResponse: r"""Returns true if valid credentials exist for the given data source and requesting user. @@ -2248,8 +2311,10 @@ def sample_check_valid_creds(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.bigquery_datatransfer_v1.types.CheckValidCredsResponse: @@ -2306,7 +2371,7 @@ def enroll_data_sources( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> None: r"""Enroll data sources in a user project. This allows users to create transfer configurations for these data sources. They will @@ -2348,8 +2413,10 @@ def sample_enroll_data_sources(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. """ # Create or coerce a protobuf request object. # - Use the request object if provided (there's no risk of modifying the input as @@ -2384,7 +2451,7 @@ def unenroll_data_sources( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> None: r"""Unenroll data sources in a user project. This allows users to remove transfer configurations for these data sources. They will @@ -2424,8 +2491,10 @@ def sample_unenroll_data_sources(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. """ # Create or coerce a protobuf request object. # - Use the request object if provided (there's no risk of modifying the input as @@ -2473,7 +2542,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. @@ -2484,8 +2553,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. @@ -2526,7 +2597,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. @@ -2537,8 +2608,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-bigquery-datatransfer/google/cloud/bigquery_datatransfer_v1/services/data_transfer_service/pagers.py b/packages/google-cloud-bigquery-datatransfer/google/cloud/bigquery_datatransfer_v1/services/data_transfer_service/pagers.py index 0fa70f2b4b0d..c157825fd60f 100644 --- a/packages/google-cloud-bigquery-datatransfer/google/cloud/bigquery_datatransfer_v1/services/data_transfer_service/pagers.py +++ b/packages/google-cloud-bigquery-datatransfer/google/cloud/bigquery_datatransfer_v1/services/data_transfer_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 = datatransfer.ListDataSourcesRequest(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 = datatransfer.ListDataSourcesRequest(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 = datatransfer.ListTransferConfigsRequest(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 = datatransfer.ListTransferConfigsRequest(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 = datatransfer.ListTransferRunsRequest(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 = datatransfer.ListTransferRunsRequest(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 = datatransfer.ListTransferLogsRequest(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 = datatransfer.ListTransferLogsRequest(request) diff --git a/packages/google-cloud-bigquery-datatransfer/google/cloud/bigquery_datatransfer_v1/services/data_transfer_service/transports/grpc.py b/packages/google-cloud-bigquery-datatransfer/google/cloud/bigquery_datatransfer_v1/services/data_transfer_service/transports/grpc.py index 997333bd99ef..657d3644bdd1 100644 --- a/packages/google-cloud-bigquery-datatransfer/google/cloud/bigquery_datatransfer_v1/services/data_transfer_service/transports/grpc.py +++ b/packages/google-cloud-bigquery-datatransfer/google/cloud/bigquery_datatransfer_v1/services/data_transfer_service/transports/grpc.py @@ -13,6 +13,9 @@ # See the License for the specific language governing permissions and # limitations under the License. # +import json +import logging as std_logging +import pickle from typing import Callable, Dict, Optional, Sequence, Tuple, Union import warnings @@ -22,12 +25,90 @@ from google.auth.transport.grpc import SslCredentials # type: ignore from google.cloud.location import locations_pb2 # type: ignore from google.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.bigquery_datatransfer_v1.types import datatransfer, transfer from .base import DEFAULT_CLIENT_INFO, DataTransferServiceTransport +try: + from google.api_core import client_logging # 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.bigquery.datatransfer.v1.DataTransferService", + "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.bigquery.datatransfer.v1.DataTransferService", + "rpcName": client_call_details.method, + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class DataTransferServiceGrpcTransport(DataTransferServiceTransport): """gRPC backend transport for DataTransferService. @@ -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 @@ -257,7 +343,7 @@ def get_data_source( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_data_source" not in self._stubs: - self._stubs["get_data_source"] = self.grpc_channel.unary_unary( + self._stubs["get_data_source"] = self._logged_channel.unary_unary( "/google.cloud.bigquery.datatransfer.v1.DataTransferService/GetDataSource", request_serializer=datatransfer.GetDataSourceRequest.serialize, response_deserializer=datatransfer.DataSource.deserialize, @@ -286,7 +372,7 @@ def list_data_sources( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_data_sources" not in self._stubs: - self._stubs["list_data_sources"] = self.grpc_channel.unary_unary( + self._stubs["list_data_sources"] = self._logged_channel.unary_unary( "/google.cloud.bigquery.datatransfer.v1.DataTransferService/ListDataSources", request_serializer=datatransfer.ListDataSourcesRequest.serialize, response_deserializer=datatransfer.ListDataSourcesResponse.deserialize, @@ -312,7 +398,7 @@ def create_transfer_config( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_transfer_config" not in self._stubs: - self._stubs["create_transfer_config"] = self.grpc_channel.unary_unary( + self._stubs["create_transfer_config"] = self._logged_channel.unary_unary( "/google.cloud.bigquery.datatransfer.v1.DataTransferService/CreateTransferConfig", request_serializer=datatransfer.CreateTransferConfigRequest.serialize, response_deserializer=transfer.TransferConfig.deserialize, @@ -339,7 +425,7 @@ def update_transfer_config( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_transfer_config" not in self._stubs: - self._stubs["update_transfer_config"] = self.grpc_channel.unary_unary( + self._stubs["update_transfer_config"] = self._logged_channel.unary_unary( "/google.cloud.bigquery.datatransfer.v1.DataTransferService/UpdateTransferConfig", request_serializer=datatransfer.UpdateTransferConfigRequest.serialize, response_deserializer=transfer.TransferConfig.deserialize, @@ -366,7 +452,7 @@ def delete_transfer_config( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_transfer_config" not in self._stubs: - self._stubs["delete_transfer_config"] = self.grpc_channel.unary_unary( + self._stubs["delete_transfer_config"] = self._logged_channel.unary_unary( "/google.cloud.bigquery.datatransfer.v1.DataTransferService/DeleteTransferConfig", request_serializer=datatransfer.DeleteTransferConfigRequest.serialize, response_deserializer=empty_pb2.Empty.FromString, @@ -392,7 +478,7 @@ def get_transfer_config( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_transfer_config" not in self._stubs: - self._stubs["get_transfer_config"] = self.grpc_channel.unary_unary( + self._stubs["get_transfer_config"] = self._logged_channel.unary_unary( "/google.cloud.bigquery.datatransfer.v1.DataTransferService/GetTransferConfig", request_serializer=datatransfer.GetTransferConfigRequest.serialize, response_deserializer=transfer.TransferConfig.deserialize, @@ -422,7 +508,7 @@ def list_transfer_configs( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_transfer_configs" not in self._stubs: - self._stubs["list_transfer_configs"] = self.grpc_channel.unary_unary( + self._stubs["list_transfer_configs"] = self._logged_channel.unary_unary( "/google.cloud.bigquery.datatransfer.v1.DataTransferService/ListTransferConfigs", request_serializer=datatransfer.ListTransferConfigsRequest.serialize, response_deserializer=datatransfer.ListTransferConfigsResponse.deserialize, @@ -455,7 +541,7 @@ def schedule_transfer_runs( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "schedule_transfer_runs" not in self._stubs: - self._stubs["schedule_transfer_runs"] = self.grpc_channel.unary_unary( + self._stubs["schedule_transfer_runs"] = self._logged_channel.unary_unary( "/google.cloud.bigquery.datatransfer.v1.DataTransferService/ScheduleTransferRuns", request_serializer=datatransfer.ScheduleTransferRunsRequest.serialize, response_deserializer=datatransfer.ScheduleTransferRunsResponse.deserialize, @@ -487,7 +573,9 @@ def start_manual_transfer_runs( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "start_manual_transfer_runs" not in self._stubs: - self._stubs["start_manual_transfer_runs"] = self.grpc_channel.unary_unary( + self._stubs[ + "start_manual_transfer_runs" + ] = self._logged_channel.unary_unary( "/google.cloud.bigquery.datatransfer.v1.DataTransferService/StartManualTransferRuns", request_serializer=datatransfer.StartManualTransferRunsRequest.serialize, response_deserializer=datatransfer.StartManualTransferRunsResponse.deserialize, @@ -514,7 +602,7 @@ def get_transfer_run( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_transfer_run" not in self._stubs: - self._stubs["get_transfer_run"] = self.grpc_channel.unary_unary( + self._stubs["get_transfer_run"] = self._logged_channel.unary_unary( "/google.cloud.bigquery.datatransfer.v1.DataTransferService/GetTransferRun", request_serializer=datatransfer.GetTransferRunRequest.serialize, response_deserializer=transfer.TransferRun.deserialize, @@ -540,7 +628,7 @@ def delete_transfer_run( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_transfer_run" not in self._stubs: - self._stubs["delete_transfer_run"] = self.grpc_channel.unary_unary( + self._stubs["delete_transfer_run"] = self._logged_channel.unary_unary( "/google.cloud.bigquery.datatransfer.v1.DataTransferService/DeleteTransferRun", request_serializer=datatransfer.DeleteTransferRunRequest.serialize, response_deserializer=empty_pb2.Empty.FromString, @@ -569,7 +657,7 @@ def list_transfer_runs( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_transfer_runs" not in self._stubs: - self._stubs["list_transfer_runs"] = self.grpc_channel.unary_unary( + self._stubs["list_transfer_runs"] = self._logged_channel.unary_unary( "/google.cloud.bigquery.datatransfer.v1.DataTransferService/ListTransferRuns", request_serializer=datatransfer.ListTransferRunsRequest.serialize, response_deserializer=datatransfer.ListTransferRunsResponse.deserialize, @@ -597,7 +685,7 @@ def list_transfer_logs( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_transfer_logs" not in self._stubs: - self._stubs["list_transfer_logs"] = self.grpc_channel.unary_unary( + self._stubs["list_transfer_logs"] = self._logged_channel.unary_unary( "/google.cloud.bigquery.datatransfer.v1.DataTransferService/ListTransferLogs", request_serializer=datatransfer.ListTransferLogsRequest.serialize, response_deserializer=datatransfer.ListTransferLogsResponse.deserialize, @@ -626,7 +714,7 @@ def check_valid_creds( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "check_valid_creds" not in self._stubs: - self._stubs["check_valid_creds"] = self.grpc_channel.unary_unary( + self._stubs["check_valid_creds"] = self._logged_channel.unary_unary( "/google.cloud.bigquery.datatransfer.v1.DataTransferService/CheckValidCreds", request_serializer=datatransfer.CheckValidCredsRequest.serialize, response_deserializer=datatransfer.CheckValidCredsResponse.deserialize, @@ -660,7 +748,7 @@ def enroll_data_sources( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "enroll_data_sources" not in self._stubs: - self._stubs["enroll_data_sources"] = self.grpc_channel.unary_unary( + self._stubs["enroll_data_sources"] = self._logged_channel.unary_unary( "/google.cloud.bigquery.datatransfer.v1.DataTransferService/EnrollDataSources", request_serializer=datatransfer.EnrollDataSourcesRequest.serialize, response_deserializer=empty_pb2.Empty.FromString, @@ -692,7 +780,7 @@ def unenroll_data_sources( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "unenroll_data_sources" not in self._stubs: - self._stubs["unenroll_data_sources"] = self.grpc_channel.unary_unary( + self._stubs["unenroll_data_sources"] = self._logged_channel.unary_unary( "/google.cloud.bigquery.datatransfer.v1.DataTransferService/UnenrollDataSources", request_serializer=datatransfer.UnenrollDataSourcesRequest.serialize, response_deserializer=empty_pb2.Empty.FromString, @@ -700,7 +788,7 @@ def unenroll_data_sources( return self._stubs["unenroll_data_sources"] def close(self): - self.grpc_channel.close() + self._logged_channel.close() @property def list_locations( @@ -714,7 +802,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, @@ -731,7 +819,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-bigquery-datatransfer/google/cloud/bigquery_datatransfer_v1/services/data_transfer_service/transports/grpc_asyncio.py b/packages/google-cloud-bigquery-datatransfer/google/cloud/bigquery_datatransfer_v1/services/data_transfer_service/transports/grpc_asyncio.py index adeadae9846c..c4d132fbb47b 100644 --- a/packages/google-cloud-bigquery-datatransfer/google/cloud/bigquery_datatransfer_v1/services/data_transfer_service/transports/grpc_asyncio.py +++ b/packages/google-cloud-bigquery-datatransfer/google/cloud/bigquery_datatransfer_v1/services/data_transfer_service/transports/grpc_asyncio.py @@ -14,6 +14,9 @@ # limitations under the License. # import inspect +import json +import logging as std_logging +import pickle from typing import Awaitable, Callable, Dict, Optional, Sequence, Tuple, Union import warnings @@ -24,14 +27,93 @@ from google.auth.transport.grpc import SslCredentials # type: ignore from google.cloud.location import locations_pb2 # type: ignore from google.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.bigquery_datatransfer_v1.types import datatransfer, transfer from .base import DEFAULT_CLIENT_INFO, DataTransferServiceTransport from .grpc import DataTransferServiceGrpcTransport +try: + from google.api_core import client_logging # 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.bigquery.datatransfer.v1.DataTransferService", + "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.bigquery.datatransfer.v1.DataTransferService", + "rpcName": str(client_call_details.method), + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class DataTransferServiceGrpcAsyncIOTransport(DataTransferServiceTransport): """gRPC AsyncIO backend transport for DataTransferService. @@ -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 get_data_source( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_data_source" not in self._stubs: - self._stubs["get_data_source"] = self.grpc_channel.unary_unary( + self._stubs["get_data_source"] = self._logged_channel.unary_unary( "/google.cloud.bigquery.datatransfer.v1.DataTransferService/GetDataSource", request_serializer=datatransfer.GetDataSourceRequest.serialize, response_deserializer=datatransfer.DataSource.deserialize, @@ -297,7 +382,7 @@ def list_data_sources( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_data_sources" not in self._stubs: - self._stubs["list_data_sources"] = self.grpc_channel.unary_unary( + self._stubs["list_data_sources"] = self._logged_channel.unary_unary( "/google.cloud.bigquery.datatransfer.v1.DataTransferService/ListDataSources", request_serializer=datatransfer.ListDataSourcesRequest.serialize, response_deserializer=datatransfer.ListDataSourcesResponse.deserialize, @@ -325,7 +410,7 @@ def create_transfer_config( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_transfer_config" not in self._stubs: - self._stubs["create_transfer_config"] = self.grpc_channel.unary_unary( + self._stubs["create_transfer_config"] = self._logged_channel.unary_unary( "/google.cloud.bigquery.datatransfer.v1.DataTransferService/CreateTransferConfig", request_serializer=datatransfer.CreateTransferConfigRequest.serialize, response_deserializer=transfer.TransferConfig.deserialize, @@ -354,7 +439,7 @@ def update_transfer_config( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_transfer_config" not in self._stubs: - self._stubs["update_transfer_config"] = self.grpc_channel.unary_unary( + self._stubs["update_transfer_config"] = self._logged_channel.unary_unary( "/google.cloud.bigquery.datatransfer.v1.DataTransferService/UpdateTransferConfig", request_serializer=datatransfer.UpdateTransferConfigRequest.serialize, response_deserializer=transfer.TransferConfig.deserialize, @@ -383,7 +468,7 @@ def delete_transfer_config( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_transfer_config" not in self._stubs: - self._stubs["delete_transfer_config"] = self.grpc_channel.unary_unary( + self._stubs["delete_transfer_config"] = self._logged_channel.unary_unary( "/google.cloud.bigquery.datatransfer.v1.DataTransferService/DeleteTransferConfig", request_serializer=datatransfer.DeleteTransferConfigRequest.serialize, response_deserializer=empty_pb2.Empty.FromString, @@ -411,7 +496,7 @@ def get_transfer_config( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_transfer_config" not in self._stubs: - self._stubs["get_transfer_config"] = self.grpc_channel.unary_unary( + self._stubs["get_transfer_config"] = self._logged_channel.unary_unary( "/google.cloud.bigquery.datatransfer.v1.DataTransferService/GetTransferConfig", request_serializer=datatransfer.GetTransferConfigRequest.serialize, response_deserializer=transfer.TransferConfig.deserialize, @@ -441,7 +526,7 @@ def list_transfer_configs( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_transfer_configs" not in self._stubs: - self._stubs["list_transfer_configs"] = self.grpc_channel.unary_unary( + self._stubs["list_transfer_configs"] = self._logged_channel.unary_unary( "/google.cloud.bigquery.datatransfer.v1.DataTransferService/ListTransferConfigs", request_serializer=datatransfer.ListTransferConfigsRequest.serialize, response_deserializer=datatransfer.ListTransferConfigsResponse.deserialize, @@ -474,7 +559,7 @@ def schedule_transfer_runs( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "schedule_transfer_runs" not in self._stubs: - self._stubs["schedule_transfer_runs"] = self.grpc_channel.unary_unary( + self._stubs["schedule_transfer_runs"] = self._logged_channel.unary_unary( "/google.cloud.bigquery.datatransfer.v1.DataTransferService/ScheduleTransferRuns", request_serializer=datatransfer.ScheduleTransferRunsRequest.serialize, response_deserializer=datatransfer.ScheduleTransferRunsResponse.deserialize, @@ -506,7 +591,9 @@ def start_manual_transfer_runs( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "start_manual_transfer_runs" not in self._stubs: - self._stubs["start_manual_transfer_runs"] = self.grpc_channel.unary_unary( + self._stubs[ + "start_manual_transfer_runs" + ] = self._logged_channel.unary_unary( "/google.cloud.bigquery.datatransfer.v1.DataTransferService/StartManualTransferRuns", request_serializer=datatransfer.StartManualTransferRunsRequest.serialize, response_deserializer=datatransfer.StartManualTransferRunsResponse.deserialize, @@ -535,7 +622,7 @@ def get_transfer_run( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_transfer_run" not in self._stubs: - self._stubs["get_transfer_run"] = self.grpc_channel.unary_unary( + self._stubs["get_transfer_run"] = self._logged_channel.unary_unary( "/google.cloud.bigquery.datatransfer.v1.DataTransferService/GetTransferRun", request_serializer=datatransfer.GetTransferRunRequest.serialize, response_deserializer=transfer.TransferRun.deserialize, @@ -561,7 +648,7 @@ def delete_transfer_run( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_transfer_run" not in self._stubs: - self._stubs["delete_transfer_run"] = self.grpc_channel.unary_unary( + self._stubs["delete_transfer_run"] = self._logged_channel.unary_unary( "/google.cloud.bigquery.datatransfer.v1.DataTransferService/DeleteTransferRun", request_serializer=datatransfer.DeleteTransferRunRequest.serialize, response_deserializer=empty_pb2.Empty.FromString, @@ -591,7 +678,7 @@ def list_transfer_runs( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_transfer_runs" not in self._stubs: - self._stubs["list_transfer_runs"] = self.grpc_channel.unary_unary( + self._stubs["list_transfer_runs"] = self._logged_channel.unary_unary( "/google.cloud.bigquery.datatransfer.v1.DataTransferService/ListTransferRuns", request_serializer=datatransfer.ListTransferRunsRequest.serialize, response_deserializer=datatransfer.ListTransferRunsResponse.deserialize, @@ -620,7 +707,7 @@ def list_transfer_logs( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_transfer_logs" not in self._stubs: - self._stubs["list_transfer_logs"] = self.grpc_channel.unary_unary( + self._stubs["list_transfer_logs"] = self._logged_channel.unary_unary( "/google.cloud.bigquery.datatransfer.v1.DataTransferService/ListTransferLogs", request_serializer=datatransfer.ListTransferLogsRequest.serialize, response_deserializer=datatransfer.ListTransferLogsResponse.deserialize, @@ -650,7 +737,7 @@ def check_valid_creds( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "check_valid_creds" not in self._stubs: - self._stubs["check_valid_creds"] = self.grpc_channel.unary_unary( + self._stubs["check_valid_creds"] = self._logged_channel.unary_unary( "/google.cloud.bigquery.datatransfer.v1.DataTransferService/CheckValidCreds", request_serializer=datatransfer.CheckValidCredsRequest.serialize, response_deserializer=datatransfer.CheckValidCredsResponse.deserialize, @@ -684,7 +771,7 @@ def enroll_data_sources( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "enroll_data_sources" not in self._stubs: - self._stubs["enroll_data_sources"] = self.grpc_channel.unary_unary( + self._stubs["enroll_data_sources"] = self._logged_channel.unary_unary( "/google.cloud.bigquery.datatransfer.v1.DataTransferService/EnrollDataSources", request_serializer=datatransfer.EnrollDataSourcesRequest.serialize, response_deserializer=empty_pb2.Empty.FromString, @@ -718,7 +805,7 @@ def unenroll_data_sources( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "unenroll_data_sources" not in self._stubs: - self._stubs["unenroll_data_sources"] = self.grpc_channel.unary_unary( + self._stubs["unenroll_data_sources"] = self._logged_channel.unary_unary( "/google.cloud.bigquery.datatransfer.v1.DataTransferService/UnenrollDataSources", request_serializer=datatransfer.UnenrollDataSourcesRequest.serialize, response_deserializer=empty_pb2.Empty.FromString, @@ -926,7 +1013,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: @@ -944,7 +1031,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, @@ -961,7 +1048,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-bigquery-datatransfer/google/cloud/bigquery_datatransfer_v1/services/data_transfer_service/transports/rest.py b/packages/google-cloud-bigquery-datatransfer/google/cloud/bigquery_datatransfer_v1/services/data_transfer_service/transports/rest.py index 068530e74dbb..8eab3de2412b 100644 --- a/packages/google-cloud-bigquery-datatransfer/google/cloud/bigquery_datatransfer_v1/services/data_transfer_service/transports/rest.py +++ b/packages/google-cloud-bigquery-datatransfer/google/cloud/bigquery_datatransfer_v1/services/data_transfer_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, @@ -183,8 +191,10 @@ def post_update_transfer_config(self, response): def pre_check_valid_creds( self, request: datatransfer.CheckValidCredsRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[datatransfer.CheckValidCredsRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + datatransfer.CheckValidCredsRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for check_valid_creds Override in a subclass to manipulate the request or metadata @@ -206,8 +216,11 @@ def post_check_valid_creds( def pre_create_transfer_config( self, request: datatransfer.CreateTransferConfigRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[datatransfer.CreateTransferConfigRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + datatransfer.CreateTransferConfigRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for create_transfer_config Override in a subclass to manipulate the request or metadata @@ -229,8 +242,11 @@ def post_create_transfer_config( def pre_delete_transfer_config( self, request: datatransfer.DeleteTransferConfigRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[datatransfer.DeleteTransferConfigRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + datatransfer.DeleteTransferConfigRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for delete_transfer_config Override in a subclass to manipulate the request or metadata @@ -241,8 +257,10 @@ def pre_delete_transfer_config( def pre_delete_transfer_run( self, request: datatransfer.DeleteTransferRunRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[datatransfer.DeleteTransferRunRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + datatransfer.DeleteTransferRunRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for delete_transfer_run Override in a subclass to manipulate the request or metadata @@ -253,8 +271,10 @@ def pre_delete_transfer_run( def pre_enroll_data_sources( self, request: datatransfer.EnrollDataSourcesRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[datatransfer.EnrollDataSourcesRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + datatransfer.EnrollDataSourcesRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for enroll_data_sources Override in a subclass to manipulate the request or metadata @@ -265,8 +285,10 @@ def pre_enroll_data_sources( def pre_get_data_source( self, request: datatransfer.GetDataSourceRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[datatransfer.GetDataSourceRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + datatransfer.GetDataSourceRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for get_data_source Override in a subclass to manipulate the request or metadata @@ -288,8 +310,10 @@ def post_get_data_source( def pre_get_transfer_config( self, request: datatransfer.GetTransferConfigRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[datatransfer.GetTransferConfigRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + datatransfer.GetTransferConfigRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for get_transfer_config Override in a subclass to manipulate the request or metadata @@ -311,8 +335,10 @@ def post_get_transfer_config( def pre_get_transfer_run( self, request: datatransfer.GetTransferRunRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[datatransfer.GetTransferRunRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + datatransfer.GetTransferRunRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for get_transfer_run Override in a subclass to manipulate the request or metadata @@ -334,8 +360,10 @@ def post_get_transfer_run( def pre_list_data_sources( self, request: datatransfer.ListDataSourcesRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[datatransfer.ListDataSourcesRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + datatransfer.ListDataSourcesRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for list_data_sources Override in a subclass to manipulate the request or metadata @@ -357,8 +385,10 @@ def post_list_data_sources( def pre_list_transfer_configs( self, request: datatransfer.ListTransferConfigsRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[datatransfer.ListTransferConfigsRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + datatransfer.ListTransferConfigsRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for list_transfer_configs Override in a subclass to manipulate the request or metadata @@ -380,8 +410,10 @@ def post_list_transfer_configs( def pre_list_transfer_logs( self, request: datatransfer.ListTransferLogsRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[datatransfer.ListTransferLogsRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + datatransfer.ListTransferLogsRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for list_transfer_logs Override in a subclass to manipulate the request or metadata @@ -403,8 +435,10 @@ def post_list_transfer_logs( def pre_list_transfer_runs( self, request: datatransfer.ListTransferRunsRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[datatransfer.ListTransferRunsRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + datatransfer.ListTransferRunsRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for list_transfer_runs Override in a subclass to manipulate the request or metadata @@ -426,8 +460,11 @@ def post_list_transfer_runs( def pre_schedule_transfer_runs( self, request: datatransfer.ScheduleTransferRunsRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[datatransfer.ScheduleTransferRunsRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + datatransfer.ScheduleTransferRunsRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for schedule_transfer_runs Override in a subclass to manipulate the request or metadata @@ -449,8 +486,11 @@ def post_schedule_transfer_runs( def pre_start_manual_transfer_runs( self, request: datatransfer.StartManualTransferRunsRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[datatransfer.StartManualTransferRunsRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + datatransfer.StartManualTransferRunsRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for start_manual_transfer_runs Override in a subclass to manipulate the request or metadata @@ -472,8 +512,10 @@ def post_start_manual_transfer_runs( def pre_unenroll_data_sources( self, request: datatransfer.UnenrollDataSourcesRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[datatransfer.UnenrollDataSourcesRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + datatransfer.UnenrollDataSourcesRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for unenroll_data_sources Override in a subclass to manipulate the request or metadata @@ -484,8 +526,11 @@ def pre_unenroll_data_sources( def pre_update_transfer_config( self, request: datatransfer.UpdateTransferConfigRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[datatransfer.UpdateTransferConfigRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + datatransfer.UpdateTransferConfigRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for update_transfer_config Override in a subclass to manipulate the request or metadata @@ -507,8 +552,10 @@ def post_update_transfer_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 @@ -530,8 +577,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 @@ -674,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]]] = (), ) -> datatransfer.CheckValidCredsResponse: r"""Call the check valid creds method over HTTP. @@ -694,8 +743,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.datatransfer.CheckValidCredsResponse: @@ -707,6 +758,7 @@ def __call__( http_options = ( _BaseDataTransferServiceRestTransport._BaseCheckValidCreds._get_http_options() ) + request, metadata = self._interceptor.pre_check_valid_creds( request, metadata ) @@ -723,6 +775,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.bigquery.datatransfer_v1.DataTransferServiceClient.CheckValidCreds", + extra={ + "serviceName": "google.cloud.bigquery.datatransfer.v1.DataTransferService", + "rpcName": "CheckValidCreds", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = DataTransferServiceRestTransport._CheckValidCreds._get_response( self._host, @@ -744,7 +823,31 @@ def __call__( pb_resp = datatransfer.CheckValidCredsResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_check_valid_creds(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = datatransfer.CheckValidCredsResponse.to_json( + response + ) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.bigquery.datatransfer_v1.DataTransferServiceClient.check_valid_creds", + extra={ + "serviceName": "google.cloud.bigquery.datatransfer.v1.DataTransferService", + "rpcName": "CheckValidCreds", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _CreateTransferConfig( @@ -783,7 +886,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> transfer.TransferConfig: r"""Call the create transfer config method over HTTP. @@ -806,8 +909,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.transfer.TransferConfig: @@ -824,6 +929,7 @@ def __call__( http_options = ( _BaseDataTransferServiceRestTransport._BaseCreateTransferConfig._get_http_options() ) + request, metadata = self._interceptor.pre_create_transfer_config( request, metadata ) @@ -840,6 +946,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.bigquery.datatransfer_v1.DataTransferServiceClient.CreateTransferConfig", + extra={ + "serviceName": "google.cloud.bigquery.datatransfer.v1.DataTransferService", + "rpcName": "CreateTransferConfig", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ( DataTransferServiceRestTransport._CreateTransferConfig._get_response( @@ -863,7 +996,29 @@ def __call__( pb_resp = transfer.TransferConfig.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_create_transfer_config(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = transfer.TransferConfig.to_json(response) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.bigquery.datatransfer_v1.DataTransferServiceClient.create_transfer_config", + extra={ + "serviceName": "google.cloud.bigquery.datatransfer.v1.DataTransferService", + "rpcName": "CreateTransferConfig", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _DeleteTransferConfig( @@ -901,7 +1056,7 @@ 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 transfer config method over HTTP. @@ -914,13 +1069,16 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. """ http_options = ( _BaseDataTransferServiceRestTransport._BaseDeleteTransferConfig._get_http_options() ) + request, metadata = self._interceptor.pre_delete_transfer_config( request, metadata ) @@ -933,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.bigquery.datatransfer_v1.DataTransferServiceClient.DeleteTransferConfig", + extra={ + "serviceName": "google.cloud.bigquery.datatransfer.v1.DataTransferService", + "rpcName": "DeleteTransferConfig", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ( DataTransferServiceRestTransport._DeleteTransferConfig._get_response( @@ -985,7 +1170,7 @@ 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 transfer run method over HTTP. @@ -996,13 +1181,16 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. """ http_options = ( _BaseDataTransferServiceRestTransport._BaseDeleteTransferRun._get_http_options() ) + request, metadata = self._interceptor.pre_delete_transfer_run( request, metadata ) @@ -1015,6 +1203,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.bigquery.datatransfer_v1.DataTransferServiceClient.DeleteTransferRun", + extra={ + "serviceName": "google.cloud.bigquery.datatransfer.v1.DataTransferService", + "rpcName": "DeleteTransferRun", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ( DataTransferServiceRestTransport._DeleteTransferRun._get_response( @@ -1068,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]]] = (), ): r"""Call the enroll data sources method over HTTP. @@ -1079,13 +1294,16 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. """ http_options = ( _BaseDataTransferServiceRestTransport._BaseEnrollDataSources._get_http_options() ) + request, metadata = self._interceptor.pre_enroll_data_sources( request, metadata ) @@ -1102,6 +1320,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.bigquery.datatransfer_v1.DataTransferServiceClient.EnrollDataSources", + extra={ + "serviceName": "google.cloud.bigquery.datatransfer.v1.DataTransferService", + "rpcName": "EnrollDataSources", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ( DataTransferServiceRestTransport._EnrollDataSources._get_response( @@ -1155,7 +1400,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> datatransfer.DataSource: r"""Call the get data source method over HTTP. @@ -1165,8 +1410,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.datatransfer.DataSource: @@ -1178,6 +1425,7 @@ def __call__( http_options = ( _BaseDataTransferServiceRestTransport._BaseGetDataSource._get_http_options() ) + request, metadata = self._interceptor.pre_get_data_source(request, metadata) transcoded_request = _BaseDataTransferServiceRestTransport._BaseGetDataSource._get_transcoded_request( http_options, request @@ -1188,6 +1436,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.bigquery.datatransfer_v1.DataTransferServiceClient.GetDataSource", + extra={ + "serviceName": "google.cloud.bigquery.datatransfer.v1.DataTransferService", + "rpcName": "GetDataSource", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = DataTransferServiceRestTransport._GetDataSource._get_response( self._host, @@ -1208,7 +1483,29 @@ def __call__( pb_resp = datatransfer.DataSource.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_data_source(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = datatransfer.DataSource.to_json(response) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.bigquery.datatransfer_v1.DataTransferServiceClient.get_data_source", + extra={ + "serviceName": "google.cloud.bigquery.datatransfer.v1.DataTransferService", + "rpcName": "GetDataSource", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _GetTransferConfig( @@ -1246,7 +1543,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> transfer.TransferConfig: r"""Call the get transfer config method over HTTP. @@ -1257,8 +1554,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.transfer.TransferConfig: @@ -1275,6 +1574,7 @@ def __call__( http_options = ( _BaseDataTransferServiceRestTransport._BaseGetTransferConfig._get_http_options() ) + request, metadata = self._interceptor.pre_get_transfer_config( request, metadata ) @@ -1287,6 +1587,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.bigquery.datatransfer_v1.DataTransferServiceClient.GetTransferConfig", + extra={ + "serviceName": "google.cloud.bigquery.datatransfer.v1.DataTransferService", + "rpcName": "GetTransferConfig", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ( DataTransferServiceRestTransport._GetTransferConfig._get_response( @@ -1309,7 +1636,29 @@ def __call__( pb_resp = transfer.TransferConfig.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_transfer_config(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = transfer.TransferConfig.to_json(response) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.bigquery.datatransfer_v1.DataTransferServiceClient.get_transfer_config", + extra={ + "serviceName": "google.cloud.bigquery.datatransfer.v1.DataTransferService", + "rpcName": "GetTransferConfig", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _GetTransferRun( @@ -1347,7 +1696,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> transfer.TransferRun: r"""Call the get transfer run method over HTTP. @@ -1358,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: ~.transfer.TransferRun: @@ -1369,6 +1720,7 @@ def __call__( http_options = ( _BaseDataTransferServiceRestTransport._BaseGetTransferRun._get_http_options() ) + request, metadata = self._interceptor.pre_get_transfer_run( request, metadata ) @@ -1381,6 +1733,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.bigquery.datatransfer_v1.DataTransferServiceClient.GetTransferRun", + extra={ + "serviceName": "google.cloud.bigquery.datatransfer.v1.DataTransferService", + "rpcName": "GetTransferRun", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = DataTransferServiceRestTransport._GetTransferRun._get_response( self._host, @@ -1401,7 +1780,29 @@ def __call__( pb_resp = transfer.TransferRun.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_transfer_run(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = transfer.TransferRun.to_json(response) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.bigquery.datatransfer_v1.DataTransferServiceClient.get_transfer_run", + extra={ + "serviceName": "google.cloud.bigquery.datatransfer.v1.DataTransferService", + "rpcName": "GetTransferRun", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ListDataSources( @@ -1439,7 +1840,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> datatransfer.ListDataSourcesResponse: r"""Call the list data sources method over HTTP. @@ -1451,8 +1852,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.datatransfer.ListDataSourcesResponse: @@ -1464,6 +1867,7 @@ def __call__( http_options = ( _BaseDataTransferServiceRestTransport._BaseListDataSources._get_http_options() ) + request, metadata = self._interceptor.pre_list_data_sources( request, metadata ) @@ -1476,6 +1880,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.bigquery.datatransfer_v1.DataTransferServiceClient.ListDataSources", + extra={ + "serviceName": "google.cloud.bigquery.datatransfer.v1.DataTransferService", + "rpcName": "ListDataSources", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = DataTransferServiceRestTransport._ListDataSources._get_response( self._host, @@ -1496,7 +1927,31 @@ def __call__( pb_resp = datatransfer.ListDataSourcesResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_data_sources(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = datatransfer.ListDataSourcesResponse.to_json( + response + ) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.bigquery.datatransfer_v1.DataTransferServiceClient.list_data_sources", + extra={ + "serviceName": "google.cloud.bigquery.datatransfer.v1.DataTransferService", + "rpcName": "ListDataSources", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ListTransferConfigs( @@ -1534,7 +1989,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> datatransfer.ListTransferConfigsResponse: r"""Call the list transfer configs method over HTTP. @@ -1545,8 +2000,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.datatransfer.ListTransferConfigsResponse: @@ -1558,6 +2015,7 @@ def __call__( http_options = ( _BaseDataTransferServiceRestTransport._BaseListTransferConfigs._get_http_options() ) + request, metadata = self._interceptor.pre_list_transfer_configs( request, metadata ) @@ -1570,6 +2028,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.bigquery.datatransfer_v1.DataTransferServiceClient.ListTransferConfigs", + extra={ + "serviceName": "google.cloud.bigquery.datatransfer.v1.DataTransferService", + "rpcName": "ListTransferConfigs", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ( DataTransferServiceRestTransport._ListTransferConfigs._get_response( @@ -1592,7 +2077,31 @@ def __call__( pb_resp = datatransfer.ListTransferConfigsResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_transfer_configs(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = datatransfer.ListTransferConfigsResponse.to_json( + response + ) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.bigquery.datatransfer_v1.DataTransferServiceClient.list_transfer_configs", + extra={ + "serviceName": "google.cloud.bigquery.datatransfer.v1.DataTransferService", + "rpcName": "ListTransferConfigs", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ListTransferLogs( @@ -1630,7 +2139,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> datatransfer.ListTransferLogsResponse: r"""Call the list transfer logs method over HTTP. @@ -1642,8 +2151,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.datatransfer.ListTransferLogsResponse: @@ -1655,6 +2166,7 @@ def __call__( http_options = ( _BaseDataTransferServiceRestTransport._BaseListTransferLogs._get_http_options() ) + request, metadata = self._interceptor.pre_list_transfer_logs( request, metadata ) @@ -1667,6 +2179,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.bigquery.datatransfer_v1.DataTransferServiceClient.ListTransferLogs", + extra={ + "serviceName": "google.cloud.bigquery.datatransfer.v1.DataTransferService", + "rpcName": "ListTransferLogs", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = DataTransferServiceRestTransport._ListTransferLogs._get_response( self._host, @@ -1687,7 +2226,31 @@ def __call__( pb_resp = datatransfer.ListTransferLogsResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_transfer_logs(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = datatransfer.ListTransferLogsResponse.to_json( + response + ) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.bigquery.datatransfer_v1.DataTransferServiceClient.list_transfer_logs", + extra={ + "serviceName": "google.cloud.bigquery.datatransfer.v1.DataTransferService", + "rpcName": "ListTransferLogs", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ListTransferRuns( @@ -1725,7 +2288,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> datatransfer.ListTransferRunsResponse: r"""Call the list transfer runs method over HTTP. @@ -1735,8 +2298,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.datatransfer.ListTransferRunsResponse: @@ -1748,6 +2313,7 @@ def __call__( http_options = ( _BaseDataTransferServiceRestTransport._BaseListTransferRuns._get_http_options() ) + request, metadata = self._interceptor.pre_list_transfer_runs( request, metadata ) @@ -1760,6 +2326,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.bigquery.datatransfer_v1.DataTransferServiceClient.ListTransferRuns", + extra={ + "serviceName": "google.cloud.bigquery.datatransfer.v1.DataTransferService", + "rpcName": "ListTransferRuns", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = DataTransferServiceRestTransport._ListTransferRuns._get_response( self._host, @@ -1780,7 +2373,31 @@ def __call__( pb_resp = datatransfer.ListTransferRunsResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_transfer_runs(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = datatransfer.ListTransferRunsResponse.to_json( + response + ) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.bigquery.datatransfer_v1.DataTransferServiceClient.list_transfer_runs", + extra={ + "serviceName": "google.cloud.bigquery.datatransfer.v1.DataTransferService", + "rpcName": "ListTransferRuns", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ScheduleTransferRuns( @@ -1819,7 +2436,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> datatransfer.ScheduleTransferRunsResponse: r"""Call the schedule transfer runs method over HTTP. @@ -1830,8 +2447,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.datatransfer.ScheduleTransferRunsResponse: @@ -1843,6 +2462,7 @@ def __call__( http_options = ( _BaseDataTransferServiceRestTransport._BaseScheduleTransferRuns._get_http_options() ) + request, metadata = self._interceptor.pre_schedule_transfer_runs( request, metadata ) @@ -1859,6 +2479,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.bigquery.datatransfer_v1.DataTransferServiceClient.ScheduleTransferRuns", + extra={ + "serviceName": "google.cloud.bigquery.datatransfer.v1.DataTransferService", + "rpcName": "ScheduleTransferRuns", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ( DataTransferServiceRestTransport._ScheduleTransferRuns._get_response( @@ -1882,7 +2529,31 @@ def __call__( pb_resp = datatransfer.ScheduleTransferRunsResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_schedule_transfer_runs(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = ( + datatransfer.ScheduleTransferRunsResponse.to_json(response) + ) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.bigquery.datatransfer_v1.DataTransferServiceClient.schedule_transfer_runs", + extra={ + "serviceName": "google.cloud.bigquery.datatransfer.v1.DataTransferService", + "rpcName": "ScheduleTransferRuns", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _StartManualTransferRuns( @@ -1921,7 +2592,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> datatransfer.StartManualTransferRunsResponse: r"""Call the start manual transfer runs method over HTTP. @@ -1933,8 +2604,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.datatransfer.StartManualTransferRunsResponse: @@ -1946,6 +2619,7 @@ def __call__( http_options = ( _BaseDataTransferServiceRestTransport._BaseStartManualTransferRuns._get_http_options() ) + request, metadata = self._interceptor.pre_start_manual_transfer_runs( request, metadata ) @@ -1962,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 = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.bigquery.datatransfer_v1.DataTransferServiceClient.StartManualTransferRuns", + extra={ + "serviceName": "google.cloud.bigquery.datatransfer.v1.DataTransferService", + "rpcName": "StartManualTransferRuns", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ( DataTransferServiceRestTransport._StartManualTransferRuns._get_response( @@ -1985,7 +2686,31 @@ def __call__( pb_resp = datatransfer.StartManualTransferRunsResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_start_manual_transfer_runs(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = ( + datatransfer.StartManualTransferRunsResponse.to_json(response) + ) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.bigquery.datatransfer_v1.DataTransferServiceClient.start_manual_transfer_runs", + extra={ + "serviceName": "google.cloud.bigquery.datatransfer.v1.DataTransferService", + "rpcName": "StartManualTransferRuns", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _UnenrollDataSources( @@ -2024,7 +2749,7 @@ 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 unenroll data sources method over HTTP. @@ -2035,13 +2760,16 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. """ http_options = ( _BaseDataTransferServiceRestTransport._BaseUnenrollDataSources._get_http_options() ) + request, metadata = self._interceptor.pre_unenroll_data_sources( request, metadata ) @@ -2058,6 +2786,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.bigquery.datatransfer_v1.DataTransferServiceClient.UnenrollDataSources", + extra={ + "serviceName": "google.cloud.bigquery.datatransfer.v1.DataTransferService", + "rpcName": "UnenrollDataSources", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ( DataTransferServiceRestTransport._UnenrollDataSources._get_response( @@ -2112,7 +2867,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> transfer.TransferConfig: r"""Call the update transfer config method over HTTP. @@ -2130,8 +2885,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.transfer.TransferConfig: @@ -2148,6 +2905,7 @@ def __call__( http_options = ( _BaseDataTransferServiceRestTransport._BaseUpdateTransferConfig._get_http_options() ) + request, metadata = self._interceptor.pre_update_transfer_config( request, metadata ) @@ -2164,6 +2922,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.bigquery.datatransfer_v1.DataTransferServiceClient.UpdateTransferConfig", + extra={ + "serviceName": "google.cloud.bigquery.datatransfer.v1.DataTransferService", + "rpcName": "UpdateTransferConfig", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ( DataTransferServiceRestTransport._UpdateTransferConfig._get_response( @@ -2187,7 +2972,29 @@ def __call__( pb_resp = transfer.TransferConfig.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_update_transfer_config(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = transfer.TransferConfig.to_json(response) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.bigquery.datatransfer_v1.DataTransferServiceClient.update_transfer_config", + extra={ + "serviceName": "google.cloud.bigquery.datatransfer.v1.DataTransferService", + "rpcName": "UpdateTransferConfig", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp @property @@ -2374,7 +3181,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> locations_pb2.Location: r"""Call the get location method over HTTP. @@ -2384,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: locations_pb2.Location: Response from GetLocation method. @@ -2394,6 +3203,7 @@ def __call__( http_options = ( _BaseDataTransferServiceRestTransport._BaseGetLocation._get_http_options() ) + request, metadata = self._interceptor.pre_get_location(request, metadata) transcoded_request = _BaseDataTransferServiceRestTransport._BaseGetLocation._get_transcoded_request( http_options, request @@ -2404,6 +3214,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.bigquery.datatransfer_v1.DataTransferServiceClient.GetLocation", + extra={ + "serviceName": "google.cloud.bigquery.datatransfer.v1.DataTransferService", + "rpcName": "GetLocation", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = DataTransferServiceRestTransport._GetLocation._get_response( self._host, @@ -2423,6 +3260,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.bigquery.datatransfer_v1.DataTransferServiceAsyncClient.GetLocation", + extra={ + "serviceName": "google.cloud.bigquery.datatransfer.v1.DataTransferService", + "rpcName": "GetLocation", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property @@ -2464,7 +3322,7 @@ 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. @@ -2474,8 +3332,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each 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. @@ -2484,6 +3344,7 @@ def __call__( http_options = ( _BaseDataTransferServiceRestTransport._BaseListLocations._get_http_options() ) + request, metadata = self._interceptor.pre_list_locations(request, metadata) transcoded_request = _BaseDataTransferServiceRestTransport._BaseListLocations._get_transcoded_request( http_options, request @@ -2494,6 +3355,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.bigquery.datatransfer_v1.DataTransferServiceClient.ListLocations", + extra={ + "serviceName": "google.cloud.bigquery.datatransfer.v1.DataTransferService", + "rpcName": "ListLocations", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = DataTransferServiceRestTransport._ListLocations._get_response( self._host, @@ -2513,6 +3401,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.bigquery.datatransfer_v1.DataTransferServiceAsyncClient.ListLocations", + extra={ + "serviceName": "google.cloud.bigquery.datatransfer.v1.DataTransferService", + "rpcName": "ListLocations", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property diff --git a/packages/google-cloud-bigquery-datatransfer/samples/generated_samples/snippet_metadata_google.cloud.bigquery.datatransfer.v1.json b/packages/google-cloud-bigquery-datatransfer/samples/generated_samples/snippet_metadata_google.cloud.bigquery.datatransfer.v1.json index fb91bc666764..b0668de9f1d8 100644 --- a/packages/google-cloud-bigquery-datatransfer/samples/generated_samples/snippet_metadata_google.cloud.bigquery.datatransfer.v1.json +++ b/packages/google-cloud-bigquery-datatransfer/samples/generated_samples/snippet_metadata_google.cloud.bigquery.datatransfer.v1.json @@ -8,7 +8,7 @@ ], "language": "PYTHON", "name": "google-cloud-bigquery-datatransfer", - "version": "3.17.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.bigquery_datatransfer_v1.types.CheckValidCredsResponse", @@ -127,7 +127,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.bigquery_datatransfer_v1.types.CheckValidCredsResponse", @@ -212,7 +212,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.bigquery_datatransfer_v1.types.TransferConfig", @@ -296,7 +296,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.bigquery_datatransfer_v1.types.TransferConfig", @@ -377,7 +377,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "shortName": "delete_transfer_config" @@ -454,7 +454,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "shortName": "delete_transfer_config" @@ -532,7 +532,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "shortName": "delete_transfer_run" @@ -609,7 +609,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "shortName": "delete_transfer_run" @@ -683,7 +683,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "shortName": "enroll_data_sources" @@ -756,7 +756,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "shortName": "enroll_data_sources" @@ -834,7 +834,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.bigquery_datatransfer_v1.types.DataSource", @@ -914,7 +914,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.bigquery_datatransfer_v1.types.DataSource", @@ -995,7 +995,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.bigquery_datatransfer_v1.types.TransferConfig", @@ -1075,7 +1075,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.bigquery_datatransfer_v1.types.TransferConfig", @@ -1156,7 +1156,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.bigquery_datatransfer_v1.types.TransferRun", @@ -1236,7 +1236,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.bigquery_datatransfer_v1.types.TransferRun", @@ -1317,7 +1317,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.bigquery_datatransfer_v1.services.data_transfer_service.pagers.ListDataSourcesAsyncPager", @@ -1397,7 +1397,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.bigquery_datatransfer_v1.services.data_transfer_service.pagers.ListDataSourcesPager", @@ -1478,7 +1478,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.bigquery_datatransfer_v1.services.data_transfer_service.pagers.ListTransferConfigsAsyncPager", @@ -1558,7 +1558,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.bigquery_datatransfer_v1.services.data_transfer_service.pagers.ListTransferConfigsPager", @@ -1639,7 +1639,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.bigquery_datatransfer_v1.services.data_transfer_service.pagers.ListTransferLogsAsyncPager", @@ -1719,7 +1719,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.bigquery_datatransfer_v1.services.data_transfer_service.pagers.ListTransferLogsPager", @@ -1800,7 +1800,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.bigquery_datatransfer_v1.services.data_transfer_service.pagers.ListTransferRunsAsyncPager", @@ -1880,7 +1880,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.bigquery_datatransfer_v1.services.data_transfer_service.pagers.ListTransferRunsPager", @@ -1969,7 +1969,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.bigquery_datatransfer_v1.types.ScheduleTransferRunsResponse", @@ -2057,7 +2057,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.bigquery_datatransfer_v1.types.ScheduleTransferRunsResponse", @@ -2134,7 +2134,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.bigquery_datatransfer_v1.types.StartManualTransferRunsResponse", @@ -2210,7 +2210,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.bigquery_datatransfer_v1.types.StartManualTransferRunsResponse", @@ -2287,7 +2287,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "shortName": "unenroll_data_sources" @@ -2360,7 +2360,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "shortName": "unenroll_data_sources" @@ -2442,7 +2442,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.bigquery_datatransfer_v1.types.TransferConfig", @@ -2526,7 +2526,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.bigquery_datatransfer_v1.types.TransferConfig", diff --git a/packages/google-cloud-bigquery-datatransfer/tests/unit/gapic/bigquery_datatransfer_v1/test_data_transfer_service.py b/packages/google-cloud-bigquery-datatransfer/tests/unit/gapic/bigquery_datatransfer_v1/test_data_transfer_service.py index 48c9b73e15b0..add441b9f214 100644 --- a/packages/google-cloud-bigquery-datatransfer/tests/unit/gapic/bigquery_datatransfer_v1/test_data_transfer_service.py +++ b/packages/google-cloud-bigquery-datatransfer/tests/unit/gapic/bigquery_datatransfer_v1/test_data_transfer_service.py @@ -7418,6 +7418,7 @@ def test_get_data_source_rest_required_fields( response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.get_data_source(request) @@ -7465,6 +7466,7 @@ def test_get_data_source_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.get_data_source(**mock_args) @@ -7605,6 +7607,7 @@ def test_list_data_sources_rest_required_fields( response_value._content = json_return_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_sources(request) @@ -7658,6 +7661,7 @@ def test_list_data_sources_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.list_data_sources(**mock_args) @@ -7866,6 +7870,7 @@ def test_create_transfer_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_transfer_config(request) @@ -7926,6 +7931,7 @@ def test_create_transfer_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_transfer_config(**mock_args) @@ -8068,6 +8074,7 @@ def test_update_transfer_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_transfer_config(request) @@ -8133,6 +8140,7 @@ def test_update_transfer_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_transfer_config(**mock_args) @@ -8267,6 +8275,7 @@ def test_delete_transfer_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_transfer_config(request) @@ -8312,6 +8321,7 @@ def test_delete_transfer_config_rest_flattened(): json_return_value = "" response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.delete_transfer_config(**mock_args) @@ -8447,6 +8457,7 @@ def test_get_transfer_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_transfer_config(request) @@ -8494,6 +8505,7 @@ def test_get_transfer_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_transfer_config(**mock_args) @@ -8638,6 +8650,7 @@ def test_list_transfer_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_transfer_configs(request) @@ -8692,6 +8705,7 @@ def test_list_transfer_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_transfer_configs(**mock_args) @@ -8892,6 +8906,7 @@ def test_schedule_transfer_runs_rest_required_fields( response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.schedule_transfer_runs(request) @@ -8950,6 +8965,7 @@ def test_schedule_transfer_runs_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.schedule_transfer_runs(**mock_args) @@ -9089,6 +9105,7 @@ def test_start_manual_transfer_runs_rest_required_fields( response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.start_manual_transfer_runs(request) @@ -9210,6 +9227,7 @@ def test_get_transfer_run_rest_required_fields( response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.get_transfer_run(request) @@ -9257,6 +9275,7 @@ def test_get_transfer_run_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.get_transfer_run(**mock_args) @@ -9389,6 +9408,7 @@ def test_delete_transfer_run_rest_required_fields( response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.delete_transfer_run(request) @@ -9434,6 +9454,7 @@ def test_delete_transfer_run_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_transfer_run(**mock_args) @@ -9578,6 +9599,7 @@ def test_list_transfer_runs_rest_required_fields( response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.list_transfer_runs(request) @@ -9635,6 +9657,7 @@ def test_list_transfer_runs_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.list_transfer_runs(**mock_args) @@ -9843,6 +9866,7 @@ def test_list_transfer_logs_rest_required_fields( response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.list_transfer_logs(request) @@ -9899,6 +9923,7 @@ def test_list_transfer_logs_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.list_transfer_logs(**mock_args) @@ -10098,6 +10123,7 @@ def test_check_valid_creds_rest_required_fields( response_value._content = json_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_valid_creds(request) @@ -10145,6 +10171,7 @@ def test_check_valid_creds_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.check_valid_creds(**mock_args) @@ -10278,6 +10305,7 @@ def test_enroll_data_sources_rest_required_fields( response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.enroll_data_sources(request) @@ -10400,6 +10428,7 @@ def test_unenroll_data_sources_rest_required_fields( response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.unenroll_data_sources(request) @@ -11416,6 +11445,7 @@ def test_get_data_source_rest_bad_request( response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.get_data_source(request) @@ -11466,6 +11496,7 @@ def test_get_data_source_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.get_data_source(request) # Establish that the response is the type that we expect. @@ -11527,6 +11558,7 @@ def test_get_data_source_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = datatransfer.DataSource.to_json(datatransfer.DataSource()) req.return_value.content = return_value @@ -11571,6 +11603,7 @@ def test_list_data_sources_rest_bad_request( response_value.status_code = 400 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_sources(request) @@ -11606,6 +11639,7 @@ def test_list_data_sources_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.list_data_sources(request) # Establish that the response is the type that we expect. @@ -11646,6 +11680,7 @@ def test_list_data_sources_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = datatransfer.ListDataSourcesResponse.to_json( datatransfer.ListDataSourcesResponse() ) @@ -11692,6 +11727,7 @@ def test_create_transfer_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_transfer_config(request) @@ -11849,6 +11885,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.create_transfer_config(request) # Establish that the response is the type that we expect. @@ -11898,6 +11935,7 @@ def test_create_transfer_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 = transfer.TransferConfig.to_json(transfer.TransferConfig()) req.return_value.content = return_value @@ -11946,6 +11984,7 @@ def test_update_transfer_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_transfer_config(request) @@ -12107,6 +12146,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.update_transfer_config(request) # Establish that the response is the type that we expect. @@ -12156,6 +12196,7 @@ def test_update_transfer_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 = transfer.TransferConfig.to_json(transfer.TransferConfig()) req.return_value.content = return_value @@ -12202,6 +12243,7 @@ def test_delete_transfer_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_transfer_config(request) @@ -12234,6 +12276,7 @@ def test_delete_transfer_config_rest_call_success(request_type): json_return_value = "" response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.delete_transfer_config(request) # Establish that the response is the type that we expect. @@ -12270,6 +12313,7 @@ def test_delete_transfer_config_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} request = datatransfer.DeleteTransferConfigRequest() metadata = [ @@ -12312,6 +12356,7 @@ def test_get_transfer_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_transfer_config(request) @@ -12359,6 +12404,7 @@ def test_get_transfer_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_transfer_config(request) # Establish that the response is the type that we expect. @@ -12408,6 +12454,7 @@ def test_get_transfer_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 = transfer.TransferConfig.to_json(transfer.TransferConfig()) req.return_value.content = return_value @@ -12452,6 +12499,7 @@ def test_list_transfer_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_transfer_configs(request) @@ -12487,6 +12535,7 @@ def test_list_transfer_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_transfer_configs(request) # Establish that the response is the type that we expect. @@ -12527,6 +12576,7 @@ def test_list_transfer_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 = datatransfer.ListTransferConfigsResponse.to_json( datatransfer.ListTransferConfigsResponse() ) @@ -12575,6 +12625,7 @@ def test_schedule_transfer_runs_rest_bad_request( response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.schedule_transfer_runs(request) @@ -12610,6 +12661,7 @@ def test_schedule_transfer_runs_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.schedule_transfer_runs(request) # Establish that the response is the type that we expect. @@ -12649,6 +12701,7 @@ def test_schedule_transfer_runs_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = datatransfer.ScheduleTransferRunsResponse.to_json( datatransfer.ScheduleTransferRunsResponse() ) @@ -12697,6 +12750,7 @@ def test_start_manual_transfer_runs_rest_bad_request( response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.start_manual_transfer_runs(request) @@ -12732,6 +12786,7 @@ def test_start_manual_transfer_runs_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.start_manual_transfer_runs(request) # Establish that the response is the type that we expect. @@ -12771,6 +12826,7 @@ def test_start_manual_transfer_runs_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = datatransfer.StartManualTransferRunsResponse.to_json( datatransfer.StartManualTransferRunsResponse() ) @@ -12819,6 +12875,7 @@ def test_get_transfer_run_rest_bad_request( response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.get_transfer_run(request) @@ -12862,6 +12919,7 @@ def test_get_transfer_run_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.get_transfer_run(request) # Establish that the response is the type that we expect. @@ -12907,6 +12965,7 @@ def test_get_transfer_run_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = transfer.TransferRun.to_json(transfer.TransferRun()) req.return_value.content = return_value @@ -12953,6 +13012,7 @@ def test_delete_transfer_run_rest_bad_request( response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.delete_transfer_run(request) @@ -12985,6 +13045,7 @@ def test_delete_transfer_run_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_transfer_run(request) # Establish that the response is the type that we expect. @@ -13021,6 +13082,7 @@ def test_delete_transfer_run_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} request = datatransfer.DeleteTransferRunRequest() metadata = [ @@ -13063,6 +13125,7 @@ def test_list_transfer_runs_rest_bad_request( response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.list_transfer_runs(request) @@ -13100,6 +13163,7 @@ def test_list_transfer_runs_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.list_transfer_runs(request) # Establish that the response is the type that we expect. @@ -13140,6 +13204,7 @@ def test_list_transfer_runs_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = datatransfer.ListTransferRunsResponse.to_json( datatransfer.ListTransferRunsResponse() ) @@ -13188,6 +13253,7 @@ def test_list_transfer_logs_rest_bad_request( response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.list_transfer_logs(request) @@ -13225,6 +13291,7 @@ def test_list_transfer_logs_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.list_transfer_logs(request) # Establish that the response is the type that we expect. @@ -13265,6 +13332,7 @@ def test_list_transfer_logs_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = datatransfer.ListTransferLogsResponse.to_json( datatransfer.ListTransferLogsResponse() ) @@ -13311,6 +13379,7 @@ def test_check_valid_creds_rest_bad_request( response_value.status_code = 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_valid_creds(request) @@ -13346,6 +13415,7 @@ def test_check_valid_creds_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_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_valid_creds(request) # Establish that the response is the type that we expect. @@ -13386,6 +13456,7 @@ def test_check_valid_creds_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = datatransfer.CheckValidCredsResponse.to_json( datatransfer.CheckValidCredsResponse() ) @@ -13432,6 +13503,7 @@ def test_enroll_data_sources_rest_bad_request( response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.enroll_data_sources(request) @@ -13462,6 +13534,7 @@ def test_enroll_data_sources_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.enroll_data_sources(request) # Establish that the response is the type that we expect. @@ -13498,6 +13571,7 @@ def test_enroll_data_sources_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} request = datatransfer.EnrollDataSourcesRequest() metadata = [ @@ -13538,6 +13612,7 @@ def test_unenroll_data_sources_rest_bad_request( response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.unenroll_data_sources(request) @@ -13568,6 +13643,7 @@ def test_unenroll_data_sources_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.unenroll_data_sources(request) # Establish that the response is the type that we expect. @@ -13604,6 +13680,7 @@ def test_unenroll_data_sources_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} request = datatransfer.UnenrollDataSourcesRequest() metadata = [ @@ -13644,6 +13721,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) @@ -13674,6 +13752,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) @@ -13702,6 +13781,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) @@ -13732,6 +13812,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-bigquery-migration/google/cloud/bigquery_migration/gapic_version.py b/packages/google-cloud-bigquery-migration/google/cloud/bigquery_migration/gapic_version.py index 11e34cec2824..558c8aab67c5 100644 --- a/packages/google-cloud-bigquery-migration/google/cloud/bigquery_migration/gapic_version.py +++ b/packages/google-cloud-bigquery-migration/google/cloud/bigquery_migration/gapic_version.py @@ -13,4 +13,4 @@ # See the License for the specific language governing permissions and # limitations under the License. # -__version__ = "0.11.11" # {x-release-please-version} +__version__ = "0.0.0" # {x-release-please-version} diff --git a/packages/google-cloud-bigquery-migration/google/cloud/bigquery_migration_v2/gapic_version.py b/packages/google-cloud-bigquery-migration/google/cloud/bigquery_migration_v2/gapic_version.py index 11e34cec2824..558c8aab67c5 100644 --- a/packages/google-cloud-bigquery-migration/google/cloud/bigquery_migration_v2/gapic_version.py +++ b/packages/google-cloud-bigquery-migration/google/cloud/bigquery_migration_v2/gapic_version.py @@ -13,4 +13,4 @@ # See the License for the specific language governing permissions and # limitations under the License. # -__version__ = "0.11.11" # {x-release-please-version} +__version__ = "0.0.0" # {x-release-please-version} diff --git a/packages/google-cloud-bigquery-migration/google/cloud/bigquery_migration_v2/services/migration_service/async_client.py b/packages/google-cloud-bigquery-migration/google/cloud/bigquery_migration_v2/services/migration_service/async_client.py index bd489ab5e971..688bc627f711 100644 --- a/packages/google-cloud-bigquery-migration/google/cloud/bigquery_migration_v2/services/migration_service/async_client.py +++ b/packages/google-cloud-bigquery-migration/google/cloud/bigquery_migration_v2/services/migration_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, MigrationServiceTransport from .transports.grpc_asyncio import MigrationServiceGrpcAsyncIOTransport +try: + from google.api_core import client_logging # type: ignore + + CLIENT_LOGGING_SUPPORTED = True # pragma: NO COVER +except ImportError: # pragma: NO COVER + CLIENT_LOGGING_SUPPORTED = False + +_LOGGER = std_logging.getLogger(__name__) + class MigrationServiceAsyncClient: """Service to handle EDW migrations.""" @@ -272,6 +282,28 @@ def __init__( client_info=client_info, ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + std_logging.DEBUG + ): # pragma: NO COVER + _LOGGER.debug( + "Created client `google.cloud.bigquery.migration_v2.MigrationServiceAsyncClient`.", + extra={ + "serviceName": "google.cloud.bigquery.migration.v2.MigrationService", + "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.bigquery.migration.v2.MigrationService", + "credentialsType": None, + }, + ) + async def create_migration_workflow( self, request: Optional[ @@ -282,7 +314,7 @@ async def create_migration_workflow( migration_workflow: Optional[migration_entities.MigrationWorkflow] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> migration_entities.MigrationWorkflow: r"""Creates a migration workflow. @@ -334,8 +366,10 @@ async def sample_create_migration_workflow(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.bigquery_migration_v2.types.MigrationWorkflow: @@ -401,7 +435,7 @@ async def get_migration_workflow( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> migration_entities.MigrationWorkflow: r"""Gets a previously created migration workflow. @@ -446,8 +480,10 @@ async def sample_get_migration_workflow(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.bigquery_migration_v2.types.MigrationWorkflow: @@ -511,7 +547,7 @@ async def list_migration_workflows( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListMigrationWorkflowsAsyncPager: r"""Lists previously created migration workflow. @@ -557,8 +593,10 @@ async def sample_list_migration_workflows(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.bigquery_migration_v2.services.migration_service.pagers.ListMigrationWorkflowsAsyncPager: @@ -634,7 +672,7 @@ async def delete_migration_workflow( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> None: r"""Deletes a migration workflow by name. @@ -676,8 +714,10 @@ async def sample_delete_migration_workflow(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. """ # Create or coerce a protobuf request object. # - Quick check: If we got a request object, we should *not* have @@ -731,7 +771,7 @@ async def start_migration_workflow( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> None: r"""Starts a previously created migration workflow. I.e., the state transitions from DRAFT to RUNNING. This is a @@ -777,8 +817,10 @@ async def sample_start_migration_workflow(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. """ # Create or coerce a protobuf request object. # - Quick check: If we got a request object, we should *not* have @@ -832,7 +874,7 @@ async def get_migration_subtask( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> migration_entities.MigrationSubtask: r"""Gets a previously created migration subtask. @@ -877,8 +919,10 @@ async def sample_get_migration_subtask(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.bigquery_migration_v2.types.MigrationSubtask: @@ -945,7 +989,7 @@ async def list_migration_subtasks( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListMigrationSubtasksAsyncPager: r"""Lists previously created migration subtasks. @@ -990,8 +1034,10 @@ async def sample_list_migration_subtasks(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.bigquery_migration_v2.services.migration_service.pagers.ListMigrationSubtasksAsyncPager: diff --git a/packages/google-cloud-bigquery-migration/google/cloud/bigquery_migration_v2/services/migration_service/client.py b/packages/google-cloud-bigquery-migration/google/cloud/bigquery_migration_v2/services/migration_service/client.py index 0db4106dafbf..00c0357c7680 100644 --- a/packages/google-cloud-bigquery-migration/google/cloud/bigquery_migration_v2/services/migration_service/client.py +++ b/packages/google-cloud-bigquery-migration/google/cloud/bigquery_migration_v2/services/migration_service/client.py @@ -14,6 +14,7 @@ # limitations under the License. # from collections import OrderedDict +import logging as std_logging import os import re from typing import ( @@ -48,6 +49,15 @@ except AttributeError: # pragma: NO COVER OptionalRetry = Union[retries.Retry, object, None] # type: ignore +try: + from google.api_core import client_logging # type: ignore + + CLIENT_LOGGING_SUPPORTED = True # pragma: NO COVER +except ImportError: # pragma: NO COVER + CLIENT_LOGGING_SUPPORTED = False + +_LOGGER = std_logging.getLogger(__name__) + from google.protobuf import timestamp_pb2 # type: ignore from google.rpc import error_details_pb2 # type: ignore @@ -610,6 +620,10 @@ def __init__( # Initialize the universe domain validation. self._is_universe_domain_valid = False + if CLIENT_LOGGING_SUPPORTED: # pragma: NO COVER + # Setup logging. + client_logging.initialize_logging() + api_key_value = getattr(self._client_options, "api_key", None) if api_key_value and credentials: raise ValueError( @@ -676,6 +690,29 @@ def __init__( api_audience=self._client_options.api_audience, ) + if "async" not in str(self._transport): + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + std_logging.DEBUG + ): # pragma: NO COVER + _LOGGER.debug( + "Created client `google.cloud.bigquery.migration_v2.MigrationServiceClient`.", + extra={ + "serviceName": "google.cloud.bigquery.migration.v2.MigrationService", + "universeDomain": getattr( + self._transport._credentials, "universe_domain", "" + ), + "credentialsType": f"{type(self._transport._credentials).__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.bigquery.migration.v2.MigrationService", + "credentialsType": None, + }, + ) + def create_migration_workflow( self, request: Optional[ @@ -686,7 +723,7 @@ def create_migration_workflow( migration_workflow: Optional[migration_entities.MigrationWorkflow] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> migration_entities.MigrationWorkflow: r"""Creates a migration workflow. @@ -738,8 +775,10 @@ def sample_create_migration_workflow(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.bigquery_migration_v2.types.MigrationWorkflow: @@ -804,7 +843,7 @@ def get_migration_workflow( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> migration_entities.MigrationWorkflow: r"""Gets a previously created migration workflow. @@ -849,8 +888,10 @@ def sample_get_migration_workflow(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.bigquery_migration_v2.types.MigrationWorkflow: @@ -911,7 +952,7 @@ def list_migration_workflows( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListMigrationWorkflowsPager: r"""Lists previously created migration workflow. @@ -957,8 +998,10 @@ def sample_list_migration_workflows(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.bigquery_migration_v2.services.migration_service.pagers.ListMigrationWorkflowsPager: @@ -1031,7 +1074,7 @@ def delete_migration_workflow( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> None: r"""Deletes a migration workflow by name. @@ -1073,8 +1116,10 @@ def sample_delete_migration_workflow(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. """ # Create or coerce a protobuf request object. # - Quick check: If we got a request object, we should *not* have @@ -1127,7 +1172,7 @@ def start_migration_workflow( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> None: r"""Starts a previously created migration workflow. I.e., the state transitions from DRAFT to RUNNING. This is a @@ -1173,8 +1218,10 @@ def sample_start_migration_workflow(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. """ # Create or coerce a protobuf request object. # - Quick check: If we got a request object, we should *not* have @@ -1225,7 +1272,7 @@ def get_migration_subtask( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> migration_entities.MigrationSubtask: r"""Gets a previously created migration subtask. @@ -1270,8 +1317,10 @@ def sample_get_migration_subtask(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.bigquery_migration_v2.types.MigrationSubtask: @@ -1335,7 +1384,7 @@ def list_migration_subtasks( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListMigrationSubtasksPager: r"""Lists previously created migration subtasks. @@ -1380,8 +1429,10 @@ def sample_list_migration_subtasks(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.bigquery_migration_v2.services.migration_service.pagers.ListMigrationSubtasksPager: diff --git a/packages/google-cloud-bigquery-migration/google/cloud/bigquery_migration_v2/services/migration_service/pagers.py b/packages/google-cloud-bigquery-migration/google/cloud/bigquery_migration_v2/services/migration_service/pagers.py index 99a5392842c5..c60b39b121d8 100644 --- a/packages/google-cloud-bigquery-migration/google/cloud/bigquery_migration_v2/services/migration_service/pagers.py +++ b/packages/google-cloud-bigquery-migration/google/cloud/bigquery_migration_v2/services/migration_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 = migration_service.ListMigrationWorkflowsRequest(request) @@ -146,7 +148,7 @@ def __init__( *, retry: OptionalAsyncRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiates the pager. @@ -160,8 +162,10 @@ def __init__( retry (google.api_core.retry.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. """ self._method = method self._request = migration_service.ListMigrationWorkflowsRequest(request) @@ -226,7 +230,7 @@ def __init__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiate the pager. @@ -240,8 +244,10 @@ def __init__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. """ self._method = method self._request = migration_service.ListMigrationSubtasksRequest(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 = migration_service.ListMigrationSubtasksRequest(request) diff --git a/packages/google-cloud-bigquery-migration/google/cloud/bigquery_migration_v2/services/migration_service/transports/grpc.py b/packages/google-cloud-bigquery-migration/google/cloud/bigquery_migration_v2/services/migration_service/transports/grpc.py index f404e628c931..1f6cf040f2d8 100644 --- a/packages/google-cloud-bigquery-migration/google/cloud/bigquery_migration_v2/services/migration_service/transports/grpc.py +++ b/packages/google-cloud-bigquery-migration/google/cloud/bigquery_migration_v2/services/migration_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.cloud.bigquery_migration_v2.types import ( migration_entities, @@ -30,6 +36,81 @@ from .base import DEFAULT_CLIENT_INFO, MigrationServiceTransport +try: + from google.api_core import client_logging # 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.bigquery.migration.v2.MigrationService", + "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.bigquery.migration.v2.MigrationService", + "rpcName": client_call_details.method, + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class MigrationServiceGrpcTransport(MigrationServiceTransport): """gRPC backend transport for MigrationService. @@ -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 create_migration_workflow( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_migration_workflow" not in self._stubs: - self._stubs["create_migration_workflow"] = self.grpc_channel.unary_unary( + self._stubs["create_migration_workflow"] = self._logged_channel.unary_unary( "/google.cloud.bigquery.migration.v2.MigrationService/CreateMigrationWorkflow", request_serializer=migration_service.CreateMigrationWorkflowRequest.serialize, response_deserializer=migration_entities.MigrationWorkflow.deserialize, @@ -289,7 +375,7 @@ def get_migration_workflow( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_migration_workflow" not in self._stubs: - self._stubs["get_migration_workflow"] = self.grpc_channel.unary_unary( + self._stubs["get_migration_workflow"] = self._logged_channel.unary_unary( "/google.cloud.bigquery.migration.v2.MigrationService/GetMigrationWorkflow", request_serializer=migration_service.GetMigrationWorkflowRequest.serialize, response_deserializer=migration_entities.MigrationWorkflow.deserialize, @@ -318,7 +404,7 @@ def list_migration_workflows( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_migration_workflows" not in self._stubs: - self._stubs["list_migration_workflows"] = self.grpc_channel.unary_unary( + self._stubs["list_migration_workflows"] = self._logged_channel.unary_unary( "/google.cloud.bigquery.migration.v2.MigrationService/ListMigrationWorkflows", request_serializer=migration_service.ListMigrationWorkflowsRequest.serialize, response_deserializer=migration_service.ListMigrationWorkflowsResponse.deserialize, @@ -344,7 +430,7 @@ def delete_migration_workflow( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_migration_workflow" not in self._stubs: - self._stubs["delete_migration_workflow"] = self.grpc_channel.unary_unary( + self._stubs["delete_migration_workflow"] = self._logged_channel.unary_unary( "/google.cloud.bigquery.migration.v2.MigrationService/DeleteMigrationWorkflow", request_serializer=migration_service.DeleteMigrationWorkflowRequest.serialize, response_deserializer=empty_pb2.Empty.FromString, @@ -374,7 +460,7 @@ def start_migration_workflow( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "start_migration_workflow" not in self._stubs: - self._stubs["start_migration_workflow"] = self.grpc_channel.unary_unary( + self._stubs["start_migration_workflow"] = self._logged_channel.unary_unary( "/google.cloud.bigquery.migration.v2.MigrationService/StartMigrationWorkflow", request_serializer=migration_service.StartMigrationWorkflowRequest.serialize, response_deserializer=empty_pb2.Empty.FromString, @@ -403,7 +489,7 @@ def get_migration_subtask( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_migration_subtask" not in self._stubs: - self._stubs["get_migration_subtask"] = self.grpc_channel.unary_unary( + self._stubs["get_migration_subtask"] = self._logged_channel.unary_unary( "/google.cloud.bigquery.migration.v2.MigrationService/GetMigrationSubtask", request_serializer=migration_service.GetMigrationSubtaskRequest.serialize, response_deserializer=migration_entities.MigrationSubtask.deserialize, @@ -432,7 +518,7 @@ def list_migration_subtasks( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_migration_subtasks" not in self._stubs: - self._stubs["list_migration_subtasks"] = self.grpc_channel.unary_unary( + self._stubs["list_migration_subtasks"] = self._logged_channel.unary_unary( "/google.cloud.bigquery.migration.v2.MigrationService/ListMigrationSubtasks", request_serializer=migration_service.ListMigrationSubtasksRequest.serialize, response_deserializer=migration_service.ListMigrationSubtasksResponse.deserialize, @@ -440,7 +526,7 @@ def list_migration_subtasks( return self._stubs["list_migration_subtasks"] def close(self): - self.grpc_channel.close() + self._logged_channel.close() @property def kind(self) -> str: diff --git a/packages/google-cloud-bigquery-migration/google/cloud/bigquery_migration_v2/services/migration_service/transports/grpc_asyncio.py b/packages/google-cloud-bigquery-migration/google/cloud/bigquery_migration_v2/services/migration_service/transports/grpc_asyncio.py index 71ac5c89c18b..e76ed9661e33 100644 --- a/packages/google-cloud-bigquery-migration/google/cloud/bigquery_migration_v2/services/migration_service/transports/grpc_asyncio.py +++ b/packages/google-cloud-bigquery-migration/google/cloud/bigquery_migration_v2/services/migration_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.cloud.bigquery_migration_v2.types import ( migration_entities, @@ -34,6 +40,82 @@ from .base import DEFAULT_CLIENT_INFO, MigrationServiceTransport from .grpc import MigrationServiceGrpcTransport +try: + from google.api_core import client_logging # 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.bigquery.migration.v2.MigrationService", + "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.bigquery.migration.v2.MigrationService", + "rpcName": str(client_call_details.method), + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class MigrationServiceGrpcAsyncIOTransport(MigrationServiceTransport): """gRPC AsyncIO backend transport for MigrationService. @@ -230,10 +312,13 @@ def __init__( ], ) - # Wrap messages. This must be done after self._grpc_channel exists + self._interceptor = _LoggingClientAIOInterceptor() + self._grpc_channel._unary_unary_interceptors.append(self._interceptor) + self._logged_channel = self._grpc_channel self._wrap_with_kind = ( "kind" in inspect.signature(gapic_v1.method_async.wrap_method).parameters ) + # Wrap messages. This must be done after self._logged_channel exists self._prep_wrapped_messages(client_info) @property @@ -268,7 +353,7 @@ def create_migration_workflow( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_migration_workflow" not in self._stubs: - self._stubs["create_migration_workflow"] = self.grpc_channel.unary_unary( + self._stubs["create_migration_workflow"] = self._logged_channel.unary_unary( "/google.cloud.bigquery.migration.v2.MigrationService/CreateMigrationWorkflow", request_serializer=migration_service.CreateMigrationWorkflowRequest.serialize, response_deserializer=migration_entities.MigrationWorkflow.deserialize, @@ -297,7 +382,7 @@ def get_migration_workflow( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_migration_workflow" not in self._stubs: - self._stubs["get_migration_workflow"] = self.grpc_channel.unary_unary( + self._stubs["get_migration_workflow"] = self._logged_channel.unary_unary( "/google.cloud.bigquery.migration.v2.MigrationService/GetMigrationWorkflow", request_serializer=migration_service.GetMigrationWorkflowRequest.serialize, response_deserializer=migration_entities.MigrationWorkflow.deserialize, @@ -326,7 +411,7 @@ def list_migration_workflows( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_migration_workflows" not in self._stubs: - self._stubs["list_migration_workflows"] = self.grpc_channel.unary_unary( + self._stubs["list_migration_workflows"] = self._logged_channel.unary_unary( "/google.cloud.bigquery.migration.v2.MigrationService/ListMigrationWorkflows", request_serializer=migration_service.ListMigrationWorkflowsRequest.serialize, response_deserializer=migration_service.ListMigrationWorkflowsResponse.deserialize, @@ -354,7 +439,7 @@ def delete_migration_workflow( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_migration_workflow" not in self._stubs: - self._stubs["delete_migration_workflow"] = self.grpc_channel.unary_unary( + self._stubs["delete_migration_workflow"] = self._logged_channel.unary_unary( "/google.cloud.bigquery.migration.v2.MigrationService/DeleteMigrationWorkflow", request_serializer=migration_service.DeleteMigrationWorkflowRequest.serialize, response_deserializer=empty_pb2.Empty.FromString, @@ -386,7 +471,7 @@ def start_migration_workflow( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "start_migration_workflow" not in self._stubs: - self._stubs["start_migration_workflow"] = self.grpc_channel.unary_unary( + self._stubs["start_migration_workflow"] = self._logged_channel.unary_unary( "/google.cloud.bigquery.migration.v2.MigrationService/StartMigrationWorkflow", request_serializer=migration_service.StartMigrationWorkflowRequest.serialize, response_deserializer=empty_pb2.Empty.FromString, @@ -415,7 +500,7 @@ def get_migration_subtask( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_migration_subtask" not in self._stubs: - self._stubs["get_migration_subtask"] = self.grpc_channel.unary_unary( + self._stubs["get_migration_subtask"] = self._logged_channel.unary_unary( "/google.cloud.bigquery.migration.v2.MigrationService/GetMigrationSubtask", request_serializer=migration_service.GetMigrationSubtaskRequest.serialize, response_deserializer=migration_entities.MigrationSubtask.deserialize, @@ -444,7 +529,7 @@ def list_migration_subtasks( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_migration_subtasks" not in self._stubs: - self._stubs["list_migration_subtasks"] = self.grpc_channel.unary_unary( + self._stubs["list_migration_subtasks"] = self._logged_channel.unary_unary( "/google.cloud.bigquery.migration.v2.MigrationService/ListMigrationSubtasks", request_serializer=migration_service.ListMigrationSubtasksRequest.serialize, response_deserializer=migration_service.ListMigrationSubtasksResponse.deserialize, @@ -524,7 +609,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-bigquery-migration/google/cloud/bigquery_migration_v2alpha/gapic_version.py b/packages/google-cloud-bigquery-migration/google/cloud/bigquery_migration_v2alpha/gapic_version.py index 11e34cec2824..558c8aab67c5 100644 --- a/packages/google-cloud-bigquery-migration/google/cloud/bigquery_migration_v2alpha/gapic_version.py +++ b/packages/google-cloud-bigquery-migration/google/cloud/bigquery_migration_v2alpha/gapic_version.py @@ -13,4 +13,4 @@ # See the License for the specific language governing permissions and # limitations under the License. # -__version__ = "0.11.11" # {x-release-please-version} +__version__ = "0.0.0" # {x-release-please-version} diff --git a/packages/google-cloud-bigquery-migration/google/cloud/bigquery_migration_v2alpha/services/migration_service/async_client.py b/packages/google-cloud-bigquery-migration/google/cloud/bigquery_migration_v2alpha/services/migration_service/async_client.py index 78fbfa6e9f1f..cdefed995383 100644 --- a/packages/google-cloud-bigquery-migration/google/cloud/bigquery_migration_v2alpha/services/migration_service/async_client.py +++ b/packages/google-cloud-bigquery-migration/google/cloud/bigquery_migration_v2alpha/services/migration_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, MigrationServiceTransport from .transports.grpc_asyncio import MigrationServiceGrpcAsyncIOTransport +try: + from google.api_core import client_logging # type: ignore + + CLIENT_LOGGING_SUPPORTED = True # pragma: NO COVER +except ImportError: # pragma: NO COVER + CLIENT_LOGGING_SUPPORTED = False + +_LOGGER = std_logging.getLogger(__name__) + class MigrationServiceAsyncClient: """Service to handle EDW migrations.""" @@ -272,6 +282,28 @@ def __init__( client_info=client_info, ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + std_logging.DEBUG + ): # pragma: NO COVER + _LOGGER.debug( + "Created client `google.cloud.bigquery.migration_v2alpha.MigrationServiceAsyncClient`.", + extra={ + "serviceName": "google.cloud.bigquery.migration.v2alpha.MigrationService", + "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.bigquery.migration.v2alpha.MigrationService", + "credentialsType": None, + }, + ) + async def create_migration_workflow( self, request: Optional[ @@ -282,7 +314,7 @@ async def create_migration_workflow( migration_workflow: Optional[migration_entities.MigrationWorkflow] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> migration_entities.MigrationWorkflow: r"""Creates a migration workflow. @@ -334,8 +366,10 @@ async def sample_create_migration_workflow(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.bigquery_migration_v2alpha.types.MigrationWorkflow: @@ -401,7 +435,7 @@ async def get_migration_workflow( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> migration_entities.MigrationWorkflow: r"""Gets a previously created migration workflow. @@ -446,8 +480,10 @@ async def sample_get_migration_workflow(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.bigquery_migration_v2alpha.types.MigrationWorkflow: @@ -511,7 +547,7 @@ async def list_migration_workflows( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListMigrationWorkflowsAsyncPager: r"""Lists previously created migration workflow. @@ -557,8 +593,10 @@ async def sample_list_migration_workflows(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.bigquery_migration_v2alpha.services.migration_service.pagers.ListMigrationWorkflowsAsyncPager: @@ -634,7 +672,7 @@ async def delete_migration_workflow( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> None: r"""Deletes a migration workflow by name. @@ -676,8 +714,10 @@ async def sample_delete_migration_workflow(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. """ # Create or coerce a protobuf request object. # - Quick check: If we got a request object, we should *not* have @@ -731,7 +771,7 @@ async def start_migration_workflow( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> None: r"""Starts a previously created migration workflow. I.e., the state transitions from DRAFT to RUNNING. This is a @@ -777,8 +817,10 @@ async def sample_start_migration_workflow(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. """ # Create or coerce a protobuf request object. # - Quick check: If we got a request object, we should *not* have @@ -832,7 +874,7 @@ async def get_migration_subtask( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> migration_entities.MigrationSubtask: r"""Gets a previously created migration subtask. @@ -877,8 +919,10 @@ async def sample_get_migration_subtask(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.bigquery_migration_v2alpha.types.MigrationSubtask: @@ -945,7 +989,7 @@ async def list_migration_subtasks( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListMigrationSubtasksAsyncPager: r"""Lists previously created migration subtasks. @@ -990,8 +1034,10 @@ async def sample_list_migration_subtasks(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.bigquery_migration_v2alpha.services.migration_service.pagers.ListMigrationSubtasksAsyncPager: diff --git a/packages/google-cloud-bigquery-migration/google/cloud/bigquery_migration_v2alpha/services/migration_service/client.py b/packages/google-cloud-bigquery-migration/google/cloud/bigquery_migration_v2alpha/services/migration_service/client.py index 5a2c7a340e99..f25c72cba44f 100644 --- a/packages/google-cloud-bigquery-migration/google/cloud/bigquery_migration_v2alpha/services/migration_service/client.py +++ b/packages/google-cloud-bigquery-migration/google/cloud/bigquery_migration_v2alpha/services/migration_service/client.py @@ -14,6 +14,7 @@ # limitations under the License. # from collections import OrderedDict +import logging as std_logging import os import re from typing import ( @@ -48,6 +49,15 @@ except AttributeError: # pragma: NO COVER OptionalRetry = Union[retries.Retry, object, None] # type: ignore +try: + from google.api_core import client_logging # type: ignore + + CLIENT_LOGGING_SUPPORTED = True # pragma: NO COVER +except ImportError: # pragma: NO COVER + CLIENT_LOGGING_SUPPORTED = False + +_LOGGER = std_logging.getLogger(__name__) + from google.protobuf import timestamp_pb2 # type: ignore from google.rpc import error_details_pb2 # type: ignore @@ -610,6 +620,10 @@ def __init__( # Initialize the universe domain validation. self._is_universe_domain_valid = False + if CLIENT_LOGGING_SUPPORTED: # pragma: NO COVER + # Setup logging. + client_logging.initialize_logging() + api_key_value = getattr(self._client_options, "api_key", None) if api_key_value and credentials: raise ValueError( @@ -676,6 +690,29 @@ def __init__( api_audience=self._client_options.api_audience, ) + if "async" not in str(self._transport): + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + std_logging.DEBUG + ): # pragma: NO COVER + _LOGGER.debug( + "Created client `google.cloud.bigquery.migration_v2alpha.MigrationServiceClient`.", + extra={ + "serviceName": "google.cloud.bigquery.migration.v2alpha.MigrationService", + "universeDomain": getattr( + self._transport._credentials, "universe_domain", "" + ), + "credentialsType": f"{type(self._transport._credentials).__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.bigquery.migration.v2alpha.MigrationService", + "credentialsType": None, + }, + ) + def create_migration_workflow( self, request: Optional[ @@ -686,7 +723,7 @@ def create_migration_workflow( migration_workflow: Optional[migration_entities.MigrationWorkflow] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> migration_entities.MigrationWorkflow: r"""Creates a migration workflow. @@ -738,8 +775,10 @@ def sample_create_migration_workflow(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.bigquery_migration_v2alpha.types.MigrationWorkflow: @@ -804,7 +843,7 @@ def get_migration_workflow( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> migration_entities.MigrationWorkflow: r"""Gets a previously created migration workflow. @@ -849,8 +888,10 @@ def sample_get_migration_workflow(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.bigquery_migration_v2alpha.types.MigrationWorkflow: @@ -911,7 +952,7 @@ def list_migration_workflows( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListMigrationWorkflowsPager: r"""Lists previously created migration workflow. @@ -957,8 +998,10 @@ def sample_list_migration_workflows(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.bigquery_migration_v2alpha.services.migration_service.pagers.ListMigrationWorkflowsPager: @@ -1031,7 +1074,7 @@ def delete_migration_workflow( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> None: r"""Deletes a migration workflow by name. @@ -1073,8 +1116,10 @@ def sample_delete_migration_workflow(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. """ # Create or coerce a protobuf request object. # - Quick check: If we got a request object, we should *not* have @@ -1127,7 +1172,7 @@ def start_migration_workflow( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> None: r"""Starts a previously created migration workflow. I.e., the state transitions from DRAFT to RUNNING. This is a @@ -1173,8 +1218,10 @@ def sample_start_migration_workflow(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. """ # Create or coerce a protobuf request object. # - Quick check: If we got a request object, we should *not* have @@ -1225,7 +1272,7 @@ def get_migration_subtask( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> migration_entities.MigrationSubtask: r"""Gets a previously created migration subtask. @@ -1270,8 +1317,10 @@ def sample_get_migration_subtask(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.bigquery_migration_v2alpha.types.MigrationSubtask: @@ -1335,7 +1384,7 @@ def list_migration_subtasks( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListMigrationSubtasksPager: r"""Lists previously created migration subtasks. @@ -1380,8 +1429,10 @@ def sample_list_migration_subtasks(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.bigquery_migration_v2alpha.services.migration_service.pagers.ListMigrationSubtasksPager: diff --git a/packages/google-cloud-bigquery-migration/google/cloud/bigquery_migration_v2alpha/services/migration_service/pagers.py b/packages/google-cloud-bigquery-migration/google/cloud/bigquery_migration_v2alpha/services/migration_service/pagers.py index 69f9ce6d1c30..b3d563b21bfd 100644 --- a/packages/google-cloud-bigquery-migration/google/cloud/bigquery_migration_v2alpha/services/migration_service/pagers.py +++ b/packages/google-cloud-bigquery-migration/google/cloud/bigquery_migration_v2alpha/services/migration_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 = migration_service.ListMigrationWorkflowsRequest(request) @@ -146,7 +148,7 @@ def __init__( *, retry: OptionalAsyncRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiates the pager. @@ -160,8 +162,10 @@ def __init__( retry (google.api_core.retry.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. """ self._method = method self._request = migration_service.ListMigrationWorkflowsRequest(request) @@ -226,7 +230,7 @@ def __init__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiate the pager. @@ -240,8 +244,10 @@ def __init__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. """ self._method = method self._request = migration_service.ListMigrationSubtasksRequest(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 = migration_service.ListMigrationSubtasksRequest(request) diff --git a/packages/google-cloud-bigquery-migration/google/cloud/bigquery_migration_v2alpha/services/migration_service/transports/grpc.py b/packages/google-cloud-bigquery-migration/google/cloud/bigquery_migration_v2alpha/services/migration_service/transports/grpc.py index f26555f23d01..e53660582297 100644 --- a/packages/google-cloud-bigquery-migration/google/cloud/bigquery_migration_v2alpha/services/migration_service/transports/grpc.py +++ b/packages/google-cloud-bigquery-migration/google/cloud/bigquery_migration_v2alpha/services/migration_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.cloud.bigquery_migration_v2alpha.types import ( migration_entities, @@ -30,6 +36,81 @@ from .base import DEFAULT_CLIENT_INFO, MigrationServiceTransport +try: + from google.api_core import client_logging # 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.bigquery.migration.v2alpha.MigrationService", + "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.bigquery.migration.v2alpha.MigrationService", + "rpcName": client_call_details.method, + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class MigrationServiceGrpcTransport(MigrationServiceTransport): """gRPC backend transport for MigrationService. @@ -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 create_migration_workflow( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_migration_workflow" not in self._stubs: - self._stubs["create_migration_workflow"] = self.grpc_channel.unary_unary( + self._stubs["create_migration_workflow"] = self._logged_channel.unary_unary( "/google.cloud.bigquery.migration.v2alpha.MigrationService/CreateMigrationWorkflow", request_serializer=migration_service.CreateMigrationWorkflowRequest.serialize, response_deserializer=migration_entities.MigrationWorkflow.deserialize, @@ -289,7 +375,7 @@ def get_migration_workflow( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_migration_workflow" not in self._stubs: - self._stubs["get_migration_workflow"] = self.grpc_channel.unary_unary( + self._stubs["get_migration_workflow"] = self._logged_channel.unary_unary( "/google.cloud.bigquery.migration.v2alpha.MigrationService/GetMigrationWorkflow", request_serializer=migration_service.GetMigrationWorkflowRequest.serialize, response_deserializer=migration_entities.MigrationWorkflow.deserialize, @@ -318,7 +404,7 @@ def list_migration_workflows( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_migration_workflows" not in self._stubs: - self._stubs["list_migration_workflows"] = self.grpc_channel.unary_unary( + self._stubs["list_migration_workflows"] = self._logged_channel.unary_unary( "/google.cloud.bigquery.migration.v2alpha.MigrationService/ListMigrationWorkflows", request_serializer=migration_service.ListMigrationWorkflowsRequest.serialize, response_deserializer=migration_service.ListMigrationWorkflowsResponse.deserialize, @@ -344,7 +430,7 @@ def delete_migration_workflow( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_migration_workflow" not in self._stubs: - self._stubs["delete_migration_workflow"] = self.grpc_channel.unary_unary( + self._stubs["delete_migration_workflow"] = self._logged_channel.unary_unary( "/google.cloud.bigquery.migration.v2alpha.MigrationService/DeleteMigrationWorkflow", request_serializer=migration_service.DeleteMigrationWorkflowRequest.serialize, response_deserializer=empty_pb2.Empty.FromString, @@ -374,7 +460,7 @@ def start_migration_workflow( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "start_migration_workflow" not in self._stubs: - self._stubs["start_migration_workflow"] = self.grpc_channel.unary_unary( + self._stubs["start_migration_workflow"] = self._logged_channel.unary_unary( "/google.cloud.bigquery.migration.v2alpha.MigrationService/StartMigrationWorkflow", request_serializer=migration_service.StartMigrationWorkflowRequest.serialize, response_deserializer=empty_pb2.Empty.FromString, @@ -403,7 +489,7 @@ def get_migration_subtask( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_migration_subtask" not in self._stubs: - self._stubs["get_migration_subtask"] = self.grpc_channel.unary_unary( + self._stubs["get_migration_subtask"] = self._logged_channel.unary_unary( "/google.cloud.bigquery.migration.v2alpha.MigrationService/GetMigrationSubtask", request_serializer=migration_service.GetMigrationSubtaskRequest.serialize, response_deserializer=migration_entities.MigrationSubtask.deserialize, @@ -432,7 +518,7 @@ def list_migration_subtasks( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_migration_subtasks" not in self._stubs: - self._stubs["list_migration_subtasks"] = self.grpc_channel.unary_unary( + self._stubs["list_migration_subtasks"] = self._logged_channel.unary_unary( "/google.cloud.bigquery.migration.v2alpha.MigrationService/ListMigrationSubtasks", request_serializer=migration_service.ListMigrationSubtasksRequest.serialize, response_deserializer=migration_service.ListMigrationSubtasksResponse.deserialize, @@ -440,7 +526,7 @@ def list_migration_subtasks( return self._stubs["list_migration_subtasks"] def close(self): - self.grpc_channel.close() + self._logged_channel.close() @property def kind(self) -> str: diff --git a/packages/google-cloud-bigquery-migration/google/cloud/bigquery_migration_v2alpha/services/migration_service/transports/grpc_asyncio.py b/packages/google-cloud-bigquery-migration/google/cloud/bigquery_migration_v2alpha/services/migration_service/transports/grpc_asyncio.py index 2696f9442c29..7a909cd77039 100644 --- a/packages/google-cloud-bigquery-migration/google/cloud/bigquery_migration_v2alpha/services/migration_service/transports/grpc_asyncio.py +++ b/packages/google-cloud-bigquery-migration/google/cloud/bigquery_migration_v2alpha/services/migration_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.cloud.bigquery_migration_v2alpha.types import ( migration_entities, @@ -34,6 +40,82 @@ from .base import DEFAULT_CLIENT_INFO, MigrationServiceTransport from .grpc import MigrationServiceGrpcTransport +try: + from google.api_core import client_logging # 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.bigquery.migration.v2alpha.MigrationService", + "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.bigquery.migration.v2alpha.MigrationService", + "rpcName": str(client_call_details.method), + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class MigrationServiceGrpcAsyncIOTransport(MigrationServiceTransport): """gRPC AsyncIO backend transport for MigrationService. @@ -230,10 +312,13 @@ def __init__( ], ) - # Wrap messages. This must be done after self._grpc_channel exists + self._interceptor = _LoggingClientAIOInterceptor() + self._grpc_channel._unary_unary_interceptors.append(self._interceptor) + self._logged_channel = self._grpc_channel self._wrap_with_kind = ( "kind" in inspect.signature(gapic_v1.method_async.wrap_method).parameters ) + # Wrap messages. This must be done after self._logged_channel exists self._prep_wrapped_messages(client_info) @property @@ -268,7 +353,7 @@ def create_migration_workflow( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_migration_workflow" not in self._stubs: - self._stubs["create_migration_workflow"] = self.grpc_channel.unary_unary( + self._stubs["create_migration_workflow"] = self._logged_channel.unary_unary( "/google.cloud.bigquery.migration.v2alpha.MigrationService/CreateMigrationWorkflow", request_serializer=migration_service.CreateMigrationWorkflowRequest.serialize, response_deserializer=migration_entities.MigrationWorkflow.deserialize, @@ -297,7 +382,7 @@ def get_migration_workflow( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_migration_workflow" not in self._stubs: - self._stubs["get_migration_workflow"] = self.grpc_channel.unary_unary( + self._stubs["get_migration_workflow"] = self._logged_channel.unary_unary( "/google.cloud.bigquery.migration.v2alpha.MigrationService/GetMigrationWorkflow", request_serializer=migration_service.GetMigrationWorkflowRequest.serialize, response_deserializer=migration_entities.MigrationWorkflow.deserialize, @@ -326,7 +411,7 @@ def list_migration_workflows( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_migration_workflows" not in self._stubs: - self._stubs["list_migration_workflows"] = self.grpc_channel.unary_unary( + self._stubs["list_migration_workflows"] = self._logged_channel.unary_unary( "/google.cloud.bigquery.migration.v2alpha.MigrationService/ListMigrationWorkflows", request_serializer=migration_service.ListMigrationWorkflowsRequest.serialize, response_deserializer=migration_service.ListMigrationWorkflowsResponse.deserialize, @@ -354,7 +439,7 @@ def delete_migration_workflow( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_migration_workflow" not in self._stubs: - self._stubs["delete_migration_workflow"] = self.grpc_channel.unary_unary( + self._stubs["delete_migration_workflow"] = self._logged_channel.unary_unary( "/google.cloud.bigquery.migration.v2alpha.MigrationService/DeleteMigrationWorkflow", request_serializer=migration_service.DeleteMigrationWorkflowRequest.serialize, response_deserializer=empty_pb2.Empty.FromString, @@ -386,7 +471,7 @@ def start_migration_workflow( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "start_migration_workflow" not in self._stubs: - self._stubs["start_migration_workflow"] = self.grpc_channel.unary_unary( + self._stubs["start_migration_workflow"] = self._logged_channel.unary_unary( "/google.cloud.bigquery.migration.v2alpha.MigrationService/StartMigrationWorkflow", request_serializer=migration_service.StartMigrationWorkflowRequest.serialize, response_deserializer=empty_pb2.Empty.FromString, @@ -415,7 +500,7 @@ def get_migration_subtask( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_migration_subtask" not in self._stubs: - self._stubs["get_migration_subtask"] = self.grpc_channel.unary_unary( + self._stubs["get_migration_subtask"] = self._logged_channel.unary_unary( "/google.cloud.bigquery.migration.v2alpha.MigrationService/GetMigrationSubtask", request_serializer=migration_service.GetMigrationSubtaskRequest.serialize, response_deserializer=migration_entities.MigrationSubtask.deserialize, @@ -444,7 +529,7 @@ def list_migration_subtasks( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_migration_subtasks" not in self._stubs: - self._stubs["list_migration_subtasks"] = self.grpc_channel.unary_unary( + self._stubs["list_migration_subtasks"] = self._logged_channel.unary_unary( "/google.cloud.bigquery.migration.v2alpha.MigrationService/ListMigrationSubtasks", request_serializer=migration_service.ListMigrationSubtasksRequest.serialize, response_deserializer=migration_service.ListMigrationSubtasksResponse.deserialize, @@ -542,7 +627,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-bigquery-migration/google/cloud/bigquery_migration_v2alpha/services/sql_translation_service/async_client.py b/packages/google-cloud-bigquery-migration/google/cloud/bigquery_migration_v2alpha/services/sql_translation_service/async_client.py index c9f47f4dec54..e5ec26439722 100644 --- a/packages/google-cloud-bigquery-migration/google/cloud/bigquery_migration_v2alpha/services/sql_translation_service/async_client.py +++ b/packages/google-cloud-bigquery-migration/google/cloud/bigquery_migration_v2alpha/services/sql_translation_service/async_client.py @@ -14,6 +14,7 @@ # limitations under the License. # from collections import OrderedDict +import logging as std_logging import re from typing import ( Callable, @@ -48,6 +49,15 @@ from .transports.base import DEFAULT_CLIENT_INFO, SqlTranslationServiceTransport from .transports.grpc_asyncio import SqlTranslationServiceGrpcAsyncIOTransport +try: + from google.api_core import client_logging # type: ignore + + CLIENT_LOGGING_SUPPORTED = True # pragma: NO COVER +except ImportError: # pragma: NO COVER + CLIENT_LOGGING_SUPPORTED = False + +_LOGGER = std_logging.getLogger(__name__) + class SqlTranslationServiceAsyncClient: """Provides other SQL dialects to GoogleSQL translation @@ -259,6 +269,28 @@ def __init__( client_info=client_info, ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + std_logging.DEBUG + ): # pragma: NO COVER + _LOGGER.debug( + "Created client `google.cloud.bigquery.migration_v2alpha.SqlTranslationServiceAsyncClient`.", + extra={ + "serviceName": "google.cloud.bigquery.migration.v2alpha.SqlTranslationService", + "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.bigquery.migration.v2alpha.SqlTranslationService", + "credentialsType": None, + }, + ) + async def translate_query( self, request: Optional[ @@ -272,7 +304,7 @@ async def translate_query( 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]]] = (), ) -> translation_service.TranslateQueryResponse: r"""Translates input queries from source dialects to GoogleSQL. @@ -330,8 +362,10 @@ async def sample_translate_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.bigquery_migration_v2alpha.types.TranslateQueryResponse: diff --git a/packages/google-cloud-bigquery-migration/google/cloud/bigquery_migration_v2alpha/services/sql_translation_service/client.py b/packages/google-cloud-bigquery-migration/google/cloud/bigquery_migration_v2alpha/services/sql_translation_service/client.py index 54c1064a5a02..f474b7a3e006 100644 --- a/packages/google-cloud-bigquery-migration/google/cloud/bigquery_migration_v2alpha/services/sql_translation_service/client.py +++ b/packages/google-cloud-bigquery-migration/google/cloud/bigquery_migration_v2alpha/services/sql_translation_service/client.py @@ -14,6 +14,7 @@ # limitations under the License. # from collections import OrderedDict +import logging as std_logging import os import re from typing import ( @@ -48,6 +49,15 @@ except AttributeError: # pragma: NO COVER OptionalRetry = Union[retries.Retry, object, None] # type: ignore +try: + from google.api_core import client_logging # type: ignore + + CLIENT_LOGGING_SUPPORTED = True # pragma: NO COVER +except ImportError: # pragma: NO COVER + CLIENT_LOGGING_SUPPORTED = False + +_LOGGER = std_logging.getLogger(__name__) + from google.cloud.bigquery_migration_v2alpha.types import translation_service from .transports.base import DEFAULT_CLIENT_INFO, SqlTranslationServiceTransport @@ -561,6 +571,10 @@ def __init__( # Initialize the universe domain validation. self._is_universe_domain_valid = False + if CLIENT_LOGGING_SUPPORTED: # pragma: NO COVER + # Setup logging. + client_logging.initialize_logging() + api_key_value = getattr(self._client_options, "api_key", None) if api_key_value and credentials: raise ValueError( @@ -627,6 +641,29 @@ def __init__( api_audience=self._client_options.api_audience, ) + if "async" not in str(self._transport): + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + std_logging.DEBUG + ): # pragma: NO COVER + _LOGGER.debug( + "Created client `google.cloud.bigquery.migration_v2alpha.SqlTranslationServiceClient`.", + extra={ + "serviceName": "google.cloud.bigquery.migration.v2alpha.SqlTranslationService", + "universeDomain": getattr( + self._transport._credentials, "universe_domain", "" + ), + "credentialsType": f"{type(self._transport._credentials).__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.bigquery.migration.v2alpha.SqlTranslationService", + "credentialsType": None, + }, + ) + def translate_query( self, request: Optional[ @@ -640,7 +677,7 @@ def translate_query( 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]]] = (), ) -> translation_service.TranslateQueryResponse: r"""Translates input queries from source dialects to GoogleSQL. @@ -698,8 +735,10 @@ def sample_translate_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.bigquery_migration_v2alpha.types.TranslateQueryResponse: diff --git a/packages/google-cloud-bigquery-migration/google/cloud/bigquery_migration_v2alpha/services/sql_translation_service/transports/grpc.py b/packages/google-cloud-bigquery-migration/google/cloud/bigquery_migration_v2alpha/services/sql_translation_service/transports/grpc.py index 1926ef5754e3..9b523ccb2f27 100644 --- a/packages/google-cloud-bigquery-migration/google/cloud/bigquery_migration_v2alpha/services/sql_translation_service/transports/grpc.py +++ b/packages/google-cloud-bigquery-migration/google/cloud/bigquery_migration_v2alpha/services/sql_translation_service/transports/grpc.py @@ -13,6 +13,9 @@ # See the License for the specific language governing permissions and # limitations under the License. # +import json +import logging as std_logging +import pickle from typing import Callable, Dict, Optional, Sequence, Tuple, Union import warnings @@ -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.bigquery_migration_v2alpha.types import translation_service from .base import DEFAULT_CLIENT_INFO, SqlTranslationServiceTransport +try: + from google.api_core import client_logging # 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.bigquery.migration.v2alpha.SqlTranslationService", + "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.bigquery.migration.v2alpha.SqlTranslationService", + "rpcName": client_call_details.method, + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class SqlTranslationServiceGrpcTransport(SqlTranslationServiceTransport): """gRPC backend transport for SqlTranslationService. @@ -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 @@ -258,7 +344,7 @@ def translate_query( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "translate_query" not in self._stubs: - self._stubs["translate_query"] = self.grpc_channel.unary_unary( + self._stubs["translate_query"] = self._logged_channel.unary_unary( "/google.cloud.bigquery.migration.v2alpha.SqlTranslationService/TranslateQuery", request_serializer=translation_service.TranslateQueryRequest.serialize, response_deserializer=translation_service.TranslateQueryResponse.deserialize, @@ -266,7 +352,7 @@ def translate_query( return self._stubs["translate_query"] def close(self): - self.grpc_channel.close() + self._logged_channel.close() @property def kind(self) -> str: diff --git a/packages/google-cloud-bigquery-migration/google/cloud/bigquery_migration_v2alpha/services/sql_translation_service/transports/grpc_asyncio.py b/packages/google-cloud-bigquery-migration/google/cloud/bigquery_migration_v2alpha/services/sql_translation_service/transports/grpc_asyncio.py index 80d2604f766b..93effdcec27b 100644 --- a/packages/google-cloud-bigquery-migration/google/cloud/bigquery_migration_v2alpha/services/sql_translation_service/transports/grpc_asyncio.py +++ b/packages/google-cloud-bigquery-migration/google/cloud/bigquery_migration_v2alpha/services/sql_translation_service/transports/grpc_asyncio.py @@ -14,6 +14,9 @@ # limitations under the License. # import inspect +import json +import logging as std_logging +import pickle from typing import Awaitable, Callable, Dict, Optional, Sequence, Tuple, Union import warnings @@ -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.bigquery_migration_v2alpha.types import translation_service from .base import DEFAULT_CLIENT_INFO, SqlTranslationServiceTransport from .grpc import SqlTranslationServiceGrpcTransport +try: + from google.api_core import client_logging # 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.bigquery.migration.v2alpha.SqlTranslationService", + "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.bigquery.migration.v2alpha.SqlTranslationService", + "rpcName": str(client_call_details.method), + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class SqlTranslationServiceGrpcAsyncIOTransport(SqlTranslationServiceTransport): """gRPC AsyncIO backend transport for SqlTranslationService. @@ -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 translate_query( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "translate_query" not in self._stubs: - self._stubs["translate_query"] = self.grpc_channel.unary_unary( + self._stubs["translate_query"] = self._logged_channel.unary_unary( "/google.cloud.bigquery.migration.v2alpha.SqlTranslationService/TranslateQuery", request_serializer=translation_service.TranslateQueryRequest.serialize, response_deserializer=translation_service.TranslateQueryResponse.deserialize, @@ -289,7 +374,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-bigquery-migration/samples/generated_samples/snippet_metadata_google.cloud.bigquery.migration.v2.json b/packages/google-cloud-bigquery-migration/samples/generated_samples/snippet_metadata_google.cloud.bigquery.migration.v2.json index 53768f71bcd4..07e44d919e85 100644 --- a/packages/google-cloud-bigquery-migration/samples/generated_samples/snippet_metadata_google.cloud.bigquery.migration.v2.json +++ b/packages/google-cloud-bigquery-migration/samples/generated_samples/snippet_metadata_google.cloud.bigquery.migration.v2.json @@ -8,7 +8,7 @@ ], "language": "PYTHON", "name": "google-cloud-bigquery-migration", - "version": "0.11.11" + "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.bigquery_migration_v2.types.MigrationWorkflow", @@ -135,7 +135,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.bigquery_migration_v2.types.MigrationWorkflow", @@ -216,7 +216,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "shortName": "delete_migration_workflow" @@ -293,7 +293,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "shortName": "delete_migration_workflow" @@ -371,7 +371,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.bigquery_migration_v2.types.MigrationSubtask", @@ -451,7 +451,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.bigquery_migration_v2.types.MigrationSubtask", @@ -532,7 +532,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.bigquery_migration_v2.types.MigrationWorkflow", @@ -612,7 +612,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.bigquery_migration_v2.types.MigrationWorkflow", @@ -693,7 +693,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.bigquery_migration_v2.services.migration_service.pagers.ListMigrationSubtasksAsyncPager", @@ -773,7 +773,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.bigquery_migration_v2.services.migration_service.pagers.ListMigrationSubtasksPager", @@ -854,7 +854,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.bigquery_migration_v2.services.migration_service.pagers.ListMigrationWorkflowsAsyncPager", @@ -934,7 +934,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.bigquery_migration_v2.services.migration_service.pagers.ListMigrationWorkflowsPager", @@ -1015,7 +1015,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "shortName": "start_migration_workflow" @@ -1092,7 +1092,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "shortName": "start_migration_workflow" diff --git a/packages/google-cloud-bigquery-migration/samples/generated_samples/snippet_metadata_google.cloud.bigquery.migration.v2alpha.json b/packages/google-cloud-bigquery-migration/samples/generated_samples/snippet_metadata_google.cloud.bigquery.migration.v2alpha.json index e6977344f9bb..d849f516e6d6 100644 --- a/packages/google-cloud-bigquery-migration/samples/generated_samples/snippet_metadata_google.cloud.bigquery.migration.v2alpha.json +++ b/packages/google-cloud-bigquery-migration/samples/generated_samples/snippet_metadata_google.cloud.bigquery.migration.v2alpha.json @@ -8,7 +8,7 @@ ], "language": "PYTHON", "name": "google-cloud-bigquery-migration", - "version": "0.11.11" + "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.bigquery_migration_v2alpha.types.MigrationWorkflow", @@ -135,7 +135,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.bigquery_migration_v2alpha.types.MigrationWorkflow", @@ -216,7 +216,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "shortName": "delete_migration_workflow" @@ -293,7 +293,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "shortName": "delete_migration_workflow" @@ -371,7 +371,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.bigquery_migration_v2alpha.types.MigrationSubtask", @@ -451,7 +451,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.bigquery_migration_v2alpha.types.MigrationSubtask", @@ -532,7 +532,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.bigquery_migration_v2alpha.types.MigrationWorkflow", @@ -612,7 +612,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.bigquery_migration_v2alpha.types.MigrationWorkflow", @@ -693,7 +693,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.bigquery_migration_v2alpha.services.migration_service.pagers.ListMigrationSubtasksAsyncPager", @@ -773,7 +773,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.bigquery_migration_v2alpha.services.migration_service.pagers.ListMigrationSubtasksPager", @@ -854,7 +854,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.bigquery_migration_v2alpha.services.migration_service.pagers.ListMigrationWorkflowsAsyncPager", @@ -934,7 +934,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.bigquery_migration_v2alpha.services.migration_service.pagers.ListMigrationWorkflowsPager", @@ -1015,7 +1015,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "shortName": "start_migration_workflow" @@ -1092,7 +1092,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "shortName": "start_migration_workflow" @@ -1178,7 +1178,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.bigquery_migration_v2alpha.types.TranslateQueryResponse", @@ -1266,7 +1266,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.bigquery_migration_v2alpha.types.TranslateQueryResponse", diff --git a/packages/google-cloud-bigquery-reservation/google/cloud/bigquery_reservation_v1/services/reservation_service/async_client.py b/packages/google-cloud-bigquery-reservation/google/cloud/bigquery_reservation_v1/services/reservation_service/async_client.py index ddf4193b701c..df6fbd91e5db 100644 --- a/packages/google-cloud-bigquery-reservation/google/cloud/bigquery_reservation_v1/services/reservation_service/async_client.py +++ b/packages/google-cloud-bigquery-reservation/google/cloud/bigquery_reservation_v1/services/reservation_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, ReservationServiceTransport from .transports.grpc_asyncio import ReservationServiceGrpcAsyncIOTransport +try: + from google.api_core import client_logging # type: ignore + + CLIENT_LOGGING_SUPPORTED = True # pragma: NO COVER +except ImportError: # pragma: NO COVER + CLIENT_LOGGING_SUPPORTED = False + +_LOGGER = std_logging.getLogger(__name__) + class ReservationServiceAsyncClient: """This API allows users to manage their BigQuery reservations. @@ -294,6 +304,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.bigquery.reservation_v1.ReservationServiceAsyncClient`.", + extra={ + "serviceName": "google.cloud.bigquery.reservation.v1.ReservationService", + "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.bigquery.reservation.v1.ReservationService", + "credentialsType": None, + }, + ) + async def create_reservation( self, request: Optional[ @@ -305,7 +337,7 @@ async def create_reservation( reservation_id: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> gcbr_reservation.Reservation: r"""Creates a new reservation resource. @@ -366,8 +398,10 @@ async def sample_create_reservation(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.bigquery_reservation_v1.types.Reservation: @@ -432,7 +466,7 @@ async def list_reservations( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListReservationsAsyncPager: r"""Lists all the reservations for the project in the specified location. @@ -478,8 +512,10 @@ async def sample_list_reservations(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.bigquery_reservation_v1.services.reservation_service.pagers.ListReservationsAsyncPager: @@ -554,7 +590,7 @@ async def get_reservation( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> reservation.Reservation: r"""Returns information about the reservation. @@ -599,8 +635,10 @@ async def sample_get_reservation(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.bigquery_reservation_v1.types.Reservation: @@ -661,7 +699,7 @@ async def delete_reservation( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.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 reservation. Returns ``google.rpc.Code.FAILED_PRECONDITION`` when reservation has @@ -705,8 +743,10 @@ async def sample_delete_reservation(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. """ # Create or coerce a protobuf request object. # - Quick check: If we got a request object, we should *not* have @@ -761,7 +801,7 @@ async def update_reservation( update_mask: Optional[field_mask_pb2.FieldMask] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> gcbr_reservation.Reservation: r"""Updates an existing reservation resource. @@ -809,8 +849,10 @@ async def sample_update_reservation(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.bigquery_reservation_v1.types.Reservation: @@ -874,7 +916,7 @@ async def failover_reservation( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> reservation.Reservation: r"""Fail over a reservation to the secondary location. The operation should be done in the current secondary location, which will be @@ -916,8 +958,10 @@ async def sample_failover_reservation(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.bigquery_reservation_v1.types.Reservation: @@ -967,7 +1011,7 @@ async def create_capacity_commitment( capacity_commitment: Optional[reservation.CapacityCommitment] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> reservation.CapacityCommitment: r"""Creates a new capacity commitment resource. @@ -1018,8 +1062,10 @@ async def sample_create_capacity_commitment(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.bigquery_reservation_v1.types.CapacityCommitment: @@ -1096,7 +1142,7 @@ async def list_capacity_commitments( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListCapacityCommitmentsAsyncPager: r"""Lists all the capacity commitments for the admin project. @@ -1142,8 +1188,10 @@ async def sample_list_capacity_commitments(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.bigquery_reservation_v1.services.reservation_service.pagers.ListCapacityCommitmentsAsyncPager: @@ -1218,7 +1266,7 @@ async def get_capacity_commitment( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> reservation.CapacityCommitment: r"""Returns information about the capacity commitment. @@ -1263,8 +1311,10 @@ async def sample_get_capacity_commitment(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.bigquery_reservation_v1.types.CapacityCommitment: @@ -1339,7 +1389,7 @@ async def delete_capacity_commitment( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.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 capacity commitment. Attempting to delete capacity commitment before its commitment_end_time will fail with the @@ -1383,8 +1433,10 @@ async def sample_delete_capacity_commitment(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. """ # Create or coerce a protobuf request object. # - Quick check: If we got a request object, we should *not* have @@ -1439,7 +1491,7 @@ async def update_capacity_commitment( update_mask: Optional[field_mask_pb2.FieldMask] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> reservation.CapacityCommitment: r"""Updates an existing capacity commitment. @@ -1496,8 +1548,10 @@ async def sample_update_capacity_commitment(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.bigquery_reservation_v1.types.CapacityCommitment: @@ -1577,7 +1631,7 @@ async def split_capacity_commitment( slot_count: 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]]] = (), ) -> reservation.SplitCapacityCommitmentResponse: r"""Splits capacity commitment to two commitments of the same plan and ``commitment_end_time``. @@ -1636,8 +1690,10 @@ async def sample_split_capacity_commitment(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.bigquery_reservation_v1.types.SplitCapacityCommitmentResponse: @@ -1703,7 +1759,7 @@ async def merge_capacity_commitments( capacity_commitment_ids: 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]]] = (), ) -> reservation.CapacityCommitment: r"""Merges capacity commitments of the same plan into a single commitment. @@ -1767,8 +1823,10 @@ async def sample_merge_capacity_commitments(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.bigquery_reservation_v1.types.CapacityCommitment: @@ -1844,7 +1902,7 @@ async def create_assignment( assignment: Optional[reservation.Assignment] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> reservation.Assignment: r"""Creates an assignment object which allows the given project to submit jobs of a certain type using slots from the specified @@ -1933,8 +1991,10 @@ async def sample_create_assignment(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.bigquery_reservation_v1.types.Assignment: @@ -1998,7 +2058,7 @@ async def list_assignments( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListAssignmentsAsyncPager: r"""Lists assignments. @@ -2069,8 +2129,10 @@ async def sample_list_assignments(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.bigquery_reservation_v1.services.reservation_service.pagers.ListAssignmentsAsyncPager: @@ -2145,7 +2207,7 @@ async def delete_assignment( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.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 assignment. No expansion will happen. @@ -2203,8 +2265,10 @@ async def sample_delete_assignment(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. """ # Create or coerce a protobuf request object. # - Quick check: If we got a request object, we should *not* have @@ -2257,7 +2321,7 @@ async def search_assignments( 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.SearchAssignmentsAsyncPager: r"""Deprecated: Looks up assignments for a specified resource for a particular region. If the request is about a project: @@ -2341,8 +2405,10 @@ async def sample_search_assignments(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.bigquery_reservation_v1.services.reservation_service.pagers.SearchAssignmentsAsyncPager: @@ -2425,7 +2491,7 @@ async def search_all_assignments( 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.SearchAllAssignmentsAsyncPager: r"""Looks up assignments for a specified resource for a particular region. If the request is about a project: @@ -2507,8 +2573,10 @@ async def sample_search_all_assignments(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.bigquery_reservation_v1.services.reservation_service.pagers.SearchAllAssignmentsAsyncPager: @@ -2586,7 +2654,7 @@ async def move_assignment( destination_id: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> reservation.Assignment: r"""Moves an assignment under a new reservation. @@ -2649,8 +2717,10 @@ async def sample_move_assignment(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.bigquery_reservation_v1.types.Assignment: @@ -2715,7 +2785,7 @@ async def update_assignment( update_mask: Optional[field_mask_pb2.FieldMask] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> reservation.Assignment: r"""Updates an existing assignment. @@ -2765,8 +2835,10 @@ async def sample_update_assignment(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.bigquery_reservation_v1.types.Assignment: @@ -2832,7 +2904,7 @@ async def get_bi_reservation( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> reservation.BiReservation: r"""Retrieves a BI reservation. @@ -2877,8 +2949,10 @@ async def sample_get_bi_reservation(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.bigquery_reservation_v1.types.BiReservation: @@ -2938,7 +3012,7 @@ async def update_bi_reservation( update_mask: Optional[field_mask_pb2.FieldMask] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> reservation.BiReservation: r"""Updates a BI reservation. @@ -2992,8 +3066,10 @@ async def sample_update_bi_reservation(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.bigquery_reservation_v1.types.BiReservation: diff --git a/packages/google-cloud-bigquery-reservation/google/cloud/bigquery_reservation_v1/services/reservation_service/client.py b/packages/google-cloud-bigquery-reservation/google/cloud/bigquery_reservation_v1/services/reservation_service/client.py index 4e62889a97be..a4d2d1aaf5b8 100644 --- a/packages/google-cloud-bigquery-reservation/google/cloud/bigquery_reservation_v1/services/reservation_service/client.py +++ b/packages/google-cloud-bigquery-reservation/google/cloud/bigquery_reservation_v1/services/reservation_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.rpc import status_pb2 # type: ignore @@ -671,6 +681,10 @@ def __init__( # Initialize the universe domain validation. self._is_universe_domain_valid = False + if CLIENT_LOGGING_SUPPORTED: # pragma: NO COVER + # Setup logging. + client_logging.initialize_logging() + api_key_value = getattr(self._client_options, "api_key", None) if api_key_value and credentials: raise ValueError( @@ -737,6 +751,29 @@ def __init__( api_audience=self._client_options.api_audience, ) + if "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.bigquery.reservation_v1.ReservationServiceClient`.", + extra={ + "serviceName": "google.cloud.bigquery.reservation.v1.ReservationService", + "universeDomain": getattr( + self._transport._credentials, "universe_domain", "" + ), + "credentialsType": f"{type(self._transport._credentials).__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.bigquery.reservation.v1.ReservationService", + "credentialsType": None, + }, + ) + def create_reservation( self, request: Optional[ @@ -748,7 +785,7 @@ def create_reservation( reservation_id: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> gcbr_reservation.Reservation: r"""Creates a new reservation resource. @@ -809,8 +846,10 @@ def sample_create_reservation(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.bigquery_reservation_v1.types.Reservation: @@ -872,7 +911,7 @@ def list_reservations( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListReservationsPager: r"""Lists all the reservations for the project in the specified location. @@ -918,8 +957,10 @@ def sample_list_reservations(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.bigquery_reservation_v1.services.reservation_service.pagers.ListReservationsPager: @@ -991,7 +1032,7 @@ def get_reservation( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> reservation.Reservation: r"""Returns information about the reservation. @@ -1036,8 +1077,10 @@ def sample_get_reservation(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.bigquery_reservation_v1.types.Reservation: @@ -1095,7 +1138,7 @@ def delete_reservation( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.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 reservation. Returns ``google.rpc.Code.FAILED_PRECONDITION`` when reservation has @@ -1139,8 +1182,10 @@ def sample_delete_reservation(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. """ # Create or coerce a protobuf request object. # - Quick check: If we got a request object, we should *not* have @@ -1192,7 +1237,7 @@ def update_reservation( update_mask: Optional[field_mask_pb2.FieldMask] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> gcbr_reservation.Reservation: r"""Updates an existing reservation resource. @@ -1240,8 +1285,10 @@ def sample_update_reservation(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.bigquery_reservation_v1.types.Reservation: @@ -1302,7 +1349,7 @@ def failover_reservation( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> reservation.Reservation: r"""Fail over a reservation to the secondary location. The operation should be done in the current secondary location, which will be @@ -1344,8 +1391,10 @@ def sample_failover_reservation(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.bigquery_reservation_v1.types.Reservation: @@ -1393,7 +1442,7 @@ def create_capacity_commitment( capacity_commitment: Optional[reservation.CapacityCommitment] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> reservation.CapacityCommitment: r"""Creates a new capacity commitment resource. @@ -1444,8 +1493,10 @@ def sample_create_capacity_commitment(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.bigquery_reservation_v1.types.CapacityCommitment: @@ -1521,7 +1572,7 @@ def list_capacity_commitments( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListCapacityCommitmentsPager: r"""Lists all the capacity commitments for the admin project. @@ -1567,8 +1618,10 @@ def sample_list_capacity_commitments(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.bigquery_reservation_v1.services.reservation_service.pagers.ListCapacityCommitmentsPager: @@ -1642,7 +1695,7 @@ def get_capacity_commitment( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> reservation.CapacityCommitment: r"""Returns information about the capacity commitment. @@ -1687,8 +1740,10 @@ def sample_get_capacity_commitment(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.bigquery_reservation_v1.types.CapacityCommitment: @@ -1760,7 +1815,7 @@ def delete_capacity_commitment( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.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 capacity commitment. Attempting to delete capacity commitment before its commitment_end_time will fail with the @@ -1804,8 +1859,10 @@ def sample_delete_capacity_commitment(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. """ # Create or coerce a protobuf request object. # - Quick check: If we got a request object, we should *not* have @@ -1859,7 +1916,7 @@ def update_capacity_commitment( update_mask: Optional[field_mask_pb2.FieldMask] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> reservation.CapacityCommitment: r"""Updates an existing capacity commitment. @@ -1916,8 +1973,10 @@ def sample_update_capacity_commitment(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.bigquery_reservation_v1.types.CapacityCommitment: @@ -1996,7 +2055,7 @@ def split_capacity_commitment( slot_count: 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]]] = (), ) -> reservation.SplitCapacityCommitmentResponse: r"""Splits capacity commitment to two commitments of the same plan and ``commitment_end_time``. @@ -2055,8 +2114,10 @@ def sample_split_capacity_commitment(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.bigquery_reservation_v1.types.SplitCapacityCommitmentResponse: @@ -2121,7 +2182,7 @@ def merge_capacity_commitments( capacity_commitment_ids: 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]]] = (), ) -> reservation.CapacityCommitment: r"""Merges capacity commitments of the same plan into a single commitment. @@ -2185,8 +2246,10 @@ def sample_merge_capacity_commitments(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.bigquery_reservation_v1.types.CapacityCommitment: @@ -2261,7 +2324,7 @@ def create_assignment( assignment: Optional[reservation.Assignment] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> reservation.Assignment: r"""Creates an assignment object which allows the given project to submit jobs of a certain type using slots from the specified @@ -2350,8 +2413,10 @@ def sample_create_assignment(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.bigquery_reservation_v1.types.Assignment: @@ -2412,7 +2477,7 @@ def list_assignments( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListAssignmentsPager: r"""Lists assignments. @@ -2483,8 +2548,10 @@ def sample_list_assignments(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.bigquery_reservation_v1.services.reservation_service.pagers.ListAssignmentsPager: @@ -2556,7 +2623,7 @@ def delete_assignment( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.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 assignment. No expansion will happen. @@ -2614,8 +2681,10 @@ def sample_delete_assignment(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. """ # Create or coerce a protobuf request object. # - Quick check: If we got a request object, we should *not* have @@ -2665,7 +2734,7 @@ def search_assignments( 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.SearchAssignmentsPager: r"""Deprecated: Looks up assignments for a specified resource for a particular region. If the request is about a project: @@ -2749,8 +2818,10 @@ def sample_search_assignments(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.bigquery_reservation_v1.services.reservation_service.pagers.SearchAssignmentsPager: @@ -2830,7 +2901,7 @@ def search_all_assignments( 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.SearchAllAssignmentsPager: r"""Looks up assignments for a specified resource for a particular region. If the request is about a project: @@ -2912,8 +2983,10 @@ def sample_search_all_assignments(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.bigquery_reservation_v1.services.reservation_service.pagers.SearchAllAssignmentsPager: @@ -2988,7 +3061,7 @@ def move_assignment( destination_id: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> reservation.Assignment: r"""Moves an assignment under a new reservation. @@ -3051,8 +3124,10 @@ def sample_move_assignment(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.bigquery_reservation_v1.types.Assignment: @@ -3114,7 +3189,7 @@ def update_assignment( update_mask: Optional[field_mask_pb2.FieldMask] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> reservation.Assignment: r"""Updates an existing assignment. @@ -3164,8 +3239,10 @@ def sample_update_assignment(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.bigquery_reservation_v1.types.Assignment: @@ -3228,7 +3305,7 @@ def get_bi_reservation( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> reservation.BiReservation: r"""Retrieves a BI reservation. @@ -3273,8 +3350,10 @@ def sample_get_bi_reservation(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.bigquery_reservation_v1.types.BiReservation: @@ -3331,7 +3410,7 @@ def update_bi_reservation( update_mask: Optional[field_mask_pb2.FieldMask] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> reservation.BiReservation: r"""Updates a BI reservation. @@ -3385,8 +3464,10 @@ def sample_update_bi_reservation(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.bigquery_reservation_v1.types.BiReservation: diff --git a/packages/google-cloud-bigquery-reservation/google/cloud/bigquery_reservation_v1/services/reservation_service/pagers.py b/packages/google-cloud-bigquery-reservation/google/cloud/bigquery_reservation_v1/services/reservation_service/pagers.py index 715c34a1bcc8..a47bf14272be 100644 --- a/packages/google-cloud-bigquery-reservation/google/cloud/bigquery_reservation_v1/services/reservation_service/pagers.py +++ b/packages/google-cloud-bigquery-reservation/google/cloud/bigquery_reservation_v1/services/reservation_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 = reservation.ListReservationsRequest(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 = reservation.ListReservationsRequest(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 = reservation.ListCapacityCommitmentsRequest(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 = reservation.ListCapacityCommitmentsRequest(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 = reservation.ListAssignmentsRequest(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 = reservation.ListAssignmentsRequest(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 = reservation.SearchAssignmentsRequest(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 = reservation.SearchAssignmentsRequest(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 = reservation.SearchAllAssignmentsRequest(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 = reservation.SearchAllAssignmentsRequest(request) diff --git a/packages/google-cloud-bigquery-reservation/google/cloud/bigquery_reservation_v1/services/reservation_service/transports/grpc.py b/packages/google-cloud-bigquery-reservation/google/cloud/bigquery_reservation_v1/services/reservation_service/transports/grpc.py index 479349935974..4ccfc35c69d1 100644 --- a/packages/google-cloud-bigquery-reservation/google/cloud/bigquery_reservation_v1/services/reservation_service/transports/grpc.py +++ b/packages/google-cloud-bigquery-reservation/google/cloud/bigquery_reservation_v1/services/reservation_service/transports/grpc.py @@ -13,6 +13,9 @@ # See the License for the specific language governing permissions and # limitations under the License. # +import json +import logging as std_logging +import pickle from typing import Callable, Dict, Optional, Sequence, Tuple, Union import warnings @@ -21,13 +24,91 @@ from google.auth import credentials as ga_credentials # type: ignore from google.auth.transport.grpc import SslCredentials # type: ignore from google.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.bigquery_reservation_v1.types import reservation as gcbr_reservation from google.cloud.bigquery_reservation_v1.types import reservation from .base import DEFAULT_CLIENT_INFO, ReservationServiceTransport +try: + from google.api_core import client_logging # 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.bigquery.reservation.v1.ReservationService", + "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.bigquery.reservation.v1.ReservationService", + "rpcName": client_call_details.method, + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class ReservationServiceGrpcTransport(ReservationServiceTransport): """gRPC backend transport for ReservationService. @@ -196,7 +277,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 @@ -272,7 +358,7 @@ def create_reservation( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_reservation" not in self._stubs: - self._stubs["create_reservation"] = self.grpc_channel.unary_unary( + self._stubs["create_reservation"] = self._logged_channel.unary_unary( "/google.cloud.bigquery.reservation.v1.ReservationService/CreateReservation", request_serializer=gcbr_reservation.CreateReservationRequest.serialize, response_deserializer=gcbr_reservation.Reservation.deserialize, @@ -301,7 +387,7 @@ def list_reservations( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_reservations" not in self._stubs: - self._stubs["list_reservations"] = self.grpc_channel.unary_unary( + self._stubs["list_reservations"] = self._logged_channel.unary_unary( "/google.cloud.bigquery.reservation.v1.ReservationService/ListReservations", request_serializer=reservation.ListReservationsRequest.serialize, response_deserializer=reservation.ListReservationsResponse.deserialize, @@ -327,7 +413,7 @@ def get_reservation( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_reservation" not in self._stubs: - self._stubs["get_reservation"] = self.grpc_channel.unary_unary( + self._stubs["get_reservation"] = self._logged_channel.unary_unary( "/google.cloud.bigquery.reservation.v1.ReservationService/GetReservation", request_serializer=reservation.GetReservationRequest.serialize, response_deserializer=reservation.Reservation.deserialize, @@ -355,7 +441,7 @@ def delete_reservation( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_reservation" not in self._stubs: - self._stubs["delete_reservation"] = self.grpc_channel.unary_unary( + self._stubs["delete_reservation"] = self._logged_channel.unary_unary( "/google.cloud.bigquery.reservation.v1.ReservationService/DeleteReservation", request_serializer=reservation.DeleteReservationRequest.serialize, response_deserializer=empty_pb2.Empty.FromString, @@ -383,7 +469,7 @@ def update_reservation( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_reservation" not in self._stubs: - self._stubs["update_reservation"] = self.grpc_channel.unary_unary( + self._stubs["update_reservation"] = self._logged_channel.unary_unary( "/google.cloud.bigquery.reservation.v1.ReservationService/UpdateReservation", request_serializer=gcbr_reservation.UpdateReservationRequest.serialize, response_deserializer=gcbr_reservation.Reservation.deserialize, @@ -414,7 +500,7 @@ def failover_reservation( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "failover_reservation" not in self._stubs: - self._stubs["failover_reservation"] = self.grpc_channel.unary_unary( + self._stubs["failover_reservation"] = self._logged_channel.unary_unary( "/google.cloud.bigquery.reservation.v1.ReservationService/FailoverReservation", request_serializer=reservation.FailoverReservationRequest.serialize, response_deserializer=reservation.Reservation.deserialize, @@ -442,7 +528,9 @@ def create_capacity_commitment( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_capacity_commitment" not in self._stubs: - self._stubs["create_capacity_commitment"] = self.grpc_channel.unary_unary( + self._stubs[ + "create_capacity_commitment" + ] = self._logged_channel.unary_unary( "/google.cloud.bigquery.reservation.v1.ReservationService/CreateCapacityCommitment", request_serializer=reservation.CreateCapacityCommitmentRequest.serialize, response_deserializer=reservation.CapacityCommitment.deserialize, @@ -472,7 +560,7 @@ def list_capacity_commitments( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_capacity_commitments" not in self._stubs: - self._stubs["list_capacity_commitments"] = self.grpc_channel.unary_unary( + self._stubs["list_capacity_commitments"] = self._logged_channel.unary_unary( "/google.cloud.bigquery.reservation.v1.ReservationService/ListCapacityCommitments", request_serializer=reservation.ListCapacityCommitmentsRequest.serialize, response_deserializer=reservation.ListCapacityCommitmentsResponse.deserialize, @@ -500,7 +588,7 @@ def get_capacity_commitment( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_capacity_commitment" not in self._stubs: - self._stubs["get_capacity_commitment"] = self.grpc_channel.unary_unary( + self._stubs["get_capacity_commitment"] = self._logged_channel.unary_unary( "/google.cloud.bigquery.reservation.v1.ReservationService/GetCapacityCommitment", request_serializer=reservation.GetCapacityCommitmentRequest.serialize, response_deserializer=reservation.CapacityCommitment.deserialize, @@ -528,7 +616,9 @@ def delete_capacity_commitment( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_capacity_commitment" not in self._stubs: - self._stubs["delete_capacity_commitment"] = self.grpc_channel.unary_unary( + self._stubs[ + "delete_capacity_commitment" + ] = self._logged_channel.unary_unary( "/google.cloud.bigquery.reservation.v1.ReservationService/DeleteCapacityCommitment", request_serializer=reservation.DeleteCapacityCommitmentRequest.serialize, response_deserializer=empty_pb2.Empty.FromString, @@ -563,7 +653,9 @@ def update_capacity_commitment( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_capacity_commitment" not in self._stubs: - self._stubs["update_capacity_commitment"] = self.grpc_channel.unary_unary( + self._stubs[ + "update_capacity_commitment" + ] = self._logged_channel.unary_unary( "/google.cloud.bigquery.reservation.v1.ReservationService/UpdateCapacityCommitment", request_serializer=reservation.UpdateCapacityCommitmentRequest.serialize, response_deserializer=reservation.CapacityCommitment.deserialize, @@ -600,7 +692,7 @@ def split_capacity_commitment( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "split_capacity_commitment" not in self._stubs: - self._stubs["split_capacity_commitment"] = self.grpc_channel.unary_unary( + self._stubs["split_capacity_commitment"] = self._logged_channel.unary_unary( "/google.cloud.bigquery.reservation.v1.ReservationService/SplitCapacityCommitment", request_serializer=reservation.SplitCapacityCommitmentRequest.serialize, response_deserializer=reservation.SplitCapacityCommitmentResponse.deserialize, @@ -637,7 +729,9 @@ def merge_capacity_commitments( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "merge_capacity_commitments" not in self._stubs: - self._stubs["merge_capacity_commitments"] = self.grpc_channel.unary_unary( + self._stubs[ + "merge_capacity_commitments" + ] = self._logged_channel.unary_unary( "/google.cloud.bigquery.reservation.v1.ReservationService/MergeCapacityCommitments", request_serializer=reservation.MergeCapacityCommitmentsRequest.serialize, response_deserializer=reservation.CapacityCommitment.deserialize, @@ -700,7 +794,7 @@ def create_assignment( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_assignment" not in self._stubs: - self._stubs["create_assignment"] = self.grpc_channel.unary_unary( + self._stubs["create_assignment"] = self._logged_channel.unary_unary( "/google.cloud.bigquery.reservation.v1.ReservationService/CreateAssignment", request_serializer=reservation.CreateAssignmentRequest.serialize, response_deserializer=reservation.Assignment.deserialize, @@ -749,7 +843,7 @@ def list_assignments( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_assignments" not in self._stubs: - self._stubs["list_assignments"] = self.grpc_channel.unary_unary( + self._stubs["list_assignments"] = self._logged_channel.unary_unary( "/google.cloud.bigquery.reservation.v1.ReservationService/ListAssignments", request_serializer=reservation.ListAssignmentsRequest.serialize, response_deserializer=reservation.ListAssignmentsResponse.deserialize, @@ -790,7 +884,7 @@ def delete_assignment( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_assignment" not in self._stubs: - self._stubs["delete_assignment"] = self.grpc_channel.unary_unary( + self._stubs["delete_assignment"] = self._logged_channel.unary_unary( "/google.cloud.bigquery.reservation.v1.ReservationService/DeleteAssignment", request_serializer=reservation.DeleteAssignmentRequest.serialize, response_deserializer=empty_pb2.Empty.FromString, @@ -842,7 +936,7 @@ def search_assignments( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "search_assignments" not in self._stubs: - self._stubs["search_assignments"] = self.grpc_channel.unary_unary( + self._stubs["search_assignments"] = self._logged_channel.unary_unary( "/google.cloud.bigquery.reservation.v1.ReservationService/SearchAssignments", request_serializer=reservation.SearchAssignmentsRequest.serialize, response_deserializer=reservation.SearchAssignmentsResponse.deserialize, @@ -893,7 +987,7 @@ def search_all_assignments( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "search_all_assignments" not in self._stubs: - self._stubs["search_all_assignments"] = self.grpc_channel.unary_unary( + self._stubs["search_all_assignments"] = self._logged_channel.unary_unary( "/google.cloud.bigquery.reservation.v1.ReservationService/SearchAllAssignments", request_serializer=reservation.SearchAllAssignmentsRequest.serialize, response_deserializer=reservation.SearchAllAssignmentsResponse.deserialize, @@ -924,7 +1018,7 @@ def move_assignment( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "move_assignment" not in self._stubs: - self._stubs["move_assignment"] = self.grpc_channel.unary_unary( + self._stubs["move_assignment"] = self._logged_channel.unary_unary( "/google.cloud.bigquery.reservation.v1.ReservationService/MoveAssignment", request_serializer=reservation.MoveAssignmentRequest.serialize, response_deserializer=reservation.Assignment.deserialize, @@ -952,7 +1046,7 @@ def update_assignment( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_assignment" not in self._stubs: - self._stubs["update_assignment"] = self.grpc_channel.unary_unary( + self._stubs["update_assignment"] = self._logged_channel.unary_unary( "/google.cloud.bigquery.reservation.v1.ReservationService/UpdateAssignment", request_serializer=reservation.UpdateAssignmentRequest.serialize, response_deserializer=reservation.Assignment.deserialize, @@ -978,7 +1072,7 @@ def get_bi_reservation( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_bi_reservation" not in self._stubs: - self._stubs["get_bi_reservation"] = self.grpc_channel.unary_unary( + self._stubs["get_bi_reservation"] = self._logged_channel.unary_unary( "/google.cloud.bigquery.reservation.v1.ReservationService/GetBiReservation", request_serializer=reservation.GetBiReservationRequest.serialize, response_deserializer=reservation.BiReservation.deserialize, @@ -1011,7 +1105,7 @@ def update_bi_reservation( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_bi_reservation" not in self._stubs: - self._stubs["update_bi_reservation"] = self.grpc_channel.unary_unary( + self._stubs["update_bi_reservation"] = self._logged_channel.unary_unary( "/google.cloud.bigquery.reservation.v1.ReservationService/UpdateBiReservation", request_serializer=reservation.UpdateBiReservationRequest.serialize, response_deserializer=reservation.BiReservation.deserialize, @@ -1019,7 +1113,7 @@ def update_bi_reservation( return self._stubs["update_bi_reservation"] def close(self): - self.grpc_channel.close() + self._logged_channel.close() @property def kind(self) -> str: diff --git a/packages/google-cloud-bigquery-reservation/google/cloud/bigquery_reservation_v1/services/reservation_service/transports/grpc_asyncio.py b/packages/google-cloud-bigquery-reservation/google/cloud/bigquery_reservation_v1/services/reservation_service/transports/grpc_asyncio.py index 170c5030d0ae..c6daa98481f1 100644 --- a/packages/google-cloud-bigquery-reservation/google/cloud/bigquery_reservation_v1/services/reservation_service/transports/grpc_asyncio.py +++ b/packages/google-cloud-bigquery-reservation/google/cloud/bigquery_reservation_v1/services/reservation_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.cloud.bigquery_reservation_v1.types import reservation as gcbr_reservation from google.cloud.bigquery_reservation_v1.types import reservation @@ -32,6 +38,82 @@ from .base import DEFAULT_CLIENT_INFO, ReservationServiceTransport from .grpc import ReservationServiceGrpcTransport +try: + from google.api_core import client_logging # 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.bigquery.reservation.v1.ReservationService", + "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.bigquery.reservation.v1.ReservationService", + "rpcName": str(client_call_details.method), + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class ReservationServiceGrpcAsyncIOTransport(ReservationServiceTransport): """gRPC AsyncIO backend transport for ReservationService. @@ -243,10 +325,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 @@ -281,7 +366,7 @@ def create_reservation( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_reservation" not in self._stubs: - self._stubs["create_reservation"] = self.grpc_channel.unary_unary( + self._stubs["create_reservation"] = self._logged_channel.unary_unary( "/google.cloud.bigquery.reservation.v1.ReservationService/CreateReservation", request_serializer=gcbr_reservation.CreateReservationRequest.serialize, response_deserializer=gcbr_reservation.Reservation.deserialize, @@ -311,7 +396,7 @@ def list_reservations( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_reservations" not in self._stubs: - self._stubs["list_reservations"] = self.grpc_channel.unary_unary( + self._stubs["list_reservations"] = self._logged_channel.unary_unary( "/google.cloud.bigquery.reservation.v1.ReservationService/ListReservations", request_serializer=reservation.ListReservationsRequest.serialize, response_deserializer=reservation.ListReservationsResponse.deserialize, @@ -339,7 +424,7 @@ def get_reservation( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_reservation" not in self._stubs: - self._stubs["get_reservation"] = self.grpc_channel.unary_unary( + self._stubs["get_reservation"] = self._logged_channel.unary_unary( "/google.cloud.bigquery.reservation.v1.ReservationService/GetReservation", request_serializer=reservation.GetReservationRequest.serialize, response_deserializer=reservation.Reservation.deserialize, @@ -367,7 +452,7 @@ def delete_reservation( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_reservation" not in self._stubs: - self._stubs["delete_reservation"] = self.grpc_channel.unary_unary( + self._stubs["delete_reservation"] = self._logged_channel.unary_unary( "/google.cloud.bigquery.reservation.v1.ReservationService/DeleteReservation", request_serializer=reservation.DeleteReservationRequest.serialize, response_deserializer=empty_pb2.Empty.FromString, @@ -396,7 +481,7 @@ def update_reservation( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_reservation" not in self._stubs: - self._stubs["update_reservation"] = self.grpc_channel.unary_unary( + self._stubs["update_reservation"] = self._logged_channel.unary_unary( "/google.cloud.bigquery.reservation.v1.ReservationService/UpdateReservation", request_serializer=gcbr_reservation.UpdateReservationRequest.serialize, response_deserializer=gcbr_reservation.Reservation.deserialize, @@ -429,7 +514,7 @@ def failover_reservation( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "failover_reservation" not in self._stubs: - self._stubs["failover_reservation"] = self.grpc_channel.unary_unary( + self._stubs["failover_reservation"] = self._logged_channel.unary_unary( "/google.cloud.bigquery.reservation.v1.ReservationService/FailoverReservation", request_serializer=reservation.FailoverReservationRequest.serialize, response_deserializer=reservation.Reservation.deserialize, @@ -458,7 +543,9 @@ def create_capacity_commitment( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_capacity_commitment" not in self._stubs: - self._stubs["create_capacity_commitment"] = self.grpc_channel.unary_unary( + self._stubs[ + "create_capacity_commitment" + ] = self._logged_channel.unary_unary( "/google.cloud.bigquery.reservation.v1.ReservationService/CreateCapacityCommitment", request_serializer=reservation.CreateCapacityCommitmentRequest.serialize, response_deserializer=reservation.CapacityCommitment.deserialize, @@ -488,7 +575,7 @@ def list_capacity_commitments( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_capacity_commitments" not in self._stubs: - self._stubs["list_capacity_commitments"] = self.grpc_channel.unary_unary( + self._stubs["list_capacity_commitments"] = self._logged_channel.unary_unary( "/google.cloud.bigquery.reservation.v1.ReservationService/ListCapacityCommitments", request_serializer=reservation.ListCapacityCommitmentsRequest.serialize, response_deserializer=reservation.ListCapacityCommitmentsResponse.deserialize, @@ -517,7 +604,7 @@ def get_capacity_commitment( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_capacity_commitment" not in self._stubs: - self._stubs["get_capacity_commitment"] = self.grpc_channel.unary_unary( + self._stubs["get_capacity_commitment"] = self._logged_channel.unary_unary( "/google.cloud.bigquery.reservation.v1.ReservationService/GetCapacityCommitment", request_serializer=reservation.GetCapacityCommitmentRequest.serialize, response_deserializer=reservation.CapacityCommitment.deserialize, @@ -547,7 +634,9 @@ def delete_capacity_commitment( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_capacity_commitment" not in self._stubs: - self._stubs["delete_capacity_commitment"] = self.grpc_channel.unary_unary( + self._stubs[ + "delete_capacity_commitment" + ] = self._logged_channel.unary_unary( "/google.cloud.bigquery.reservation.v1.ReservationService/DeleteCapacityCommitment", request_serializer=reservation.DeleteCapacityCommitmentRequest.serialize, response_deserializer=empty_pb2.Empty.FromString, @@ -583,7 +672,9 @@ def update_capacity_commitment( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_capacity_commitment" not in self._stubs: - self._stubs["update_capacity_commitment"] = self.grpc_channel.unary_unary( + self._stubs[ + "update_capacity_commitment" + ] = self._logged_channel.unary_unary( "/google.cloud.bigquery.reservation.v1.ReservationService/UpdateCapacityCommitment", request_serializer=reservation.UpdateCapacityCommitmentRequest.serialize, response_deserializer=reservation.CapacityCommitment.deserialize, @@ -620,7 +711,7 @@ def split_capacity_commitment( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "split_capacity_commitment" not in self._stubs: - self._stubs["split_capacity_commitment"] = self.grpc_channel.unary_unary( + self._stubs["split_capacity_commitment"] = self._logged_channel.unary_unary( "/google.cloud.bigquery.reservation.v1.ReservationService/SplitCapacityCommitment", request_serializer=reservation.SplitCapacityCommitmentRequest.serialize, response_deserializer=reservation.SplitCapacityCommitmentResponse.deserialize, @@ -658,7 +749,9 @@ def merge_capacity_commitments( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "merge_capacity_commitments" not in self._stubs: - self._stubs["merge_capacity_commitments"] = self.grpc_channel.unary_unary( + self._stubs[ + "merge_capacity_commitments" + ] = self._logged_channel.unary_unary( "/google.cloud.bigquery.reservation.v1.ReservationService/MergeCapacityCommitments", request_serializer=reservation.MergeCapacityCommitmentsRequest.serialize, response_deserializer=reservation.CapacityCommitment.deserialize, @@ -723,7 +816,7 @@ def create_assignment( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_assignment" not in self._stubs: - self._stubs["create_assignment"] = self.grpc_channel.unary_unary( + self._stubs["create_assignment"] = self._logged_channel.unary_unary( "/google.cloud.bigquery.reservation.v1.ReservationService/CreateAssignment", request_serializer=reservation.CreateAssignmentRequest.serialize, response_deserializer=reservation.Assignment.deserialize, @@ -773,7 +866,7 @@ def list_assignments( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_assignments" not in self._stubs: - self._stubs["list_assignments"] = self.grpc_channel.unary_unary( + self._stubs["list_assignments"] = self._logged_channel.unary_unary( "/google.cloud.bigquery.reservation.v1.ReservationService/ListAssignments", request_serializer=reservation.ListAssignmentsRequest.serialize, response_deserializer=reservation.ListAssignmentsResponse.deserialize, @@ -814,7 +907,7 @@ def delete_assignment( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_assignment" not in self._stubs: - self._stubs["delete_assignment"] = self.grpc_channel.unary_unary( + self._stubs["delete_assignment"] = self._logged_channel.unary_unary( "/google.cloud.bigquery.reservation.v1.ReservationService/DeleteAssignment", request_serializer=reservation.DeleteAssignmentRequest.serialize, response_deserializer=empty_pb2.Empty.FromString, @@ -867,7 +960,7 @@ def search_assignments( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "search_assignments" not in self._stubs: - self._stubs["search_assignments"] = self.grpc_channel.unary_unary( + self._stubs["search_assignments"] = self._logged_channel.unary_unary( "/google.cloud.bigquery.reservation.v1.ReservationService/SearchAssignments", request_serializer=reservation.SearchAssignmentsRequest.serialize, response_deserializer=reservation.SearchAssignmentsResponse.deserialize, @@ -918,7 +1011,7 @@ def search_all_assignments( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "search_all_assignments" not in self._stubs: - self._stubs["search_all_assignments"] = self.grpc_channel.unary_unary( + self._stubs["search_all_assignments"] = self._logged_channel.unary_unary( "/google.cloud.bigquery.reservation.v1.ReservationService/SearchAllAssignments", request_serializer=reservation.SearchAllAssignmentsRequest.serialize, response_deserializer=reservation.SearchAllAssignmentsResponse.deserialize, @@ -951,7 +1044,7 @@ def move_assignment( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "move_assignment" not in self._stubs: - self._stubs["move_assignment"] = self.grpc_channel.unary_unary( + self._stubs["move_assignment"] = self._logged_channel.unary_unary( "/google.cloud.bigquery.reservation.v1.ReservationService/MoveAssignment", request_serializer=reservation.MoveAssignmentRequest.serialize, response_deserializer=reservation.Assignment.deserialize, @@ -981,7 +1074,7 @@ def update_assignment( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_assignment" not in self._stubs: - self._stubs["update_assignment"] = self.grpc_channel.unary_unary( + self._stubs["update_assignment"] = self._logged_channel.unary_unary( "/google.cloud.bigquery.reservation.v1.ReservationService/UpdateAssignment", request_serializer=reservation.UpdateAssignmentRequest.serialize, response_deserializer=reservation.Assignment.deserialize, @@ -1009,7 +1102,7 @@ def get_bi_reservation( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_bi_reservation" not in self._stubs: - self._stubs["get_bi_reservation"] = self.grpc_channel.unary_unary( + self._stubs["get_bi_reservation"] = self._logged_channel.unary_unary( "/google.cloud.bigquery.reservation.v1.ReservationService/GetBiReservation", request_serializer=reservation.GetBiReservationRequest.serialize, response_deserializer=reservation.BiReservation.deserialize, @@ -1044,7 +1137,7 @@ def update_bi_reservation( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_bi_reservation" not in self._stubs: - self._stubs["update_bi_reservation"] = self.grpc_channel.unary_unary( + self._stubs["update_bi_reservation"] = self._logged_channel.unary_unary( "/google.cloud.bigquery.reservation.v1.ReservationService/UpdateBiReservation", request_serializer=reservation.UpdateBiReservationRequest.serialize, response_deserializer=reservation.BiReservation.deserialize, @@ -1272,7 +1365,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-bigquery-reservation/google/cloud/bigquery_reservation_v1/services/reservation_service/transports/rest.py b/packages/google-cloud-bigquery-reservation/google/cloud/bigquery_reservation_v1/services/reservation_service/transports/rest.py index 45a4cdbc77e4..a62771c411d0 100644 --- a/packages/google-cloud-bigquery-reservation/google/cloud/bigquery_reservation_v1/services/reservation_service/transports/rest.py +++ b/packages/google-cloud-bigquery-reservation/google/cloud/bigquery_reservation_v1/services/reservation_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, @@ -235,8 +243,10 @@ def post_update_reservation(self, response): def pre_create_assignment( self, request: reservation.CreateAssignmentRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[reservation.CreateAssignmentRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + reservation.CreateAssignmentRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for create_assignment Override in a subclass to manipulate the request or metadata @@ -258,8 +268,11 @@ def post_create_assignment( def pre_create_capacity_commitment( self, request: reservation.CreateCapacityCommitmentRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[reservation.CreateCapacityCommitmentRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + reservation.CreateCapacityCommitmentRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for create_capacity_commitment Override in a subclass to manipulate the request or metadata @@ -281,8 +294,11 @@ def post_create_capacity_commitment( def pre_create_reservation( self, request: gcbr_reservation.CreateReservationRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[gcbr_reservation.CreateReservationRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + gcbr_reservation.CreateReservationRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for create_reservation Override in a subclass to manipulate the request or metadata @@ -304,8 +320,10 @@ def post_create_reservation( def pre_delete_assignment( self, request: reservation.DeleteAssignmentRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[reservation.DeleteAssignmentRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + reservation.DeleteAssignmentRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for delete_assignment Override in a subclass to manipulate the request or metadata @@ -316,8 +334,11 @@ def pre_delete_assignment( def pre_delete_capacity_commitment( self, request: reservation.DeleteCapacityCommitmentRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[reservation.DeleteCapacityCommitmentRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + reservation.DeleteCapacityCommitmentRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for delete_capacity_commitment Override in a subclass to manipulate the request or metadata @@ -328,8 +349,10 @@ def pre_delete_capacity_commitment( def pre_delete_reservation( self, request: reservation.DeleteReservationRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[reservation.DeleteReservationRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + reservation.DeleteReservationRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for delete_reservation Override in a subclass to manipulate the request or metadata @@ -340,8 +363,10 @@ def pre_delete_reservation( def pre_failover_reservation( self, request: reservation.FailoverReservationRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[reservation.FailoverReservationRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + reservation.FailoverReservationRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for failover_reservation Override in a subclass to manipulate the request or metadata @@ -363,8 +388,10 @@ def post_failover_reservation( def pre_get_bi_reservation( self, request: reservation.GetBiReservationRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[reservation.GetBiReservationRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + reservation.GetBiReservationRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for get_bi_reservation Override in a subclass to manipulate the request or metadata @@ -386,8 +413,11 @@ def post_get_bi_reservation( def pre_get_capacity_commitment( self, request: reservation.GetCapacityCommitmentRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[reservation.GetCapacityCommitmentRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + reservation.GetCapacityCommitmentRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for get_capacity_commitment Override in a subclass to manipulate the request or metadata @@ -409,8 +439,10 @@ def post_get_capacity_commitment( def pre_get_reservation( self, request: reservation.GetReservationRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[reservation.GetReservationRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + reservation.GetReservationRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for get_reservation Override in a subclass to manipulate the request or metadata @@ -432,8 +464,10 @@ def post_get_reservation( def pre_list_assignments( self, request: reservation.ListAssignmentsRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[reservation.ListAssignmentsRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + reservation.ListAssignmentsRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for list_assignments Override in a subclass to manipulate the request or metadata @@ -455,8 +489,11 @@ def post_list_assignments( def pre_list_capacity_commitments( self, request: reservation.ListCapacityCommitmentsRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[reservation.ListCapacityCommitmentsRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + reservation.ListCapacityCommitmentsRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for list_capacity_commitments Override in a subclass to manipulate the request or metadata @@ -478,8 +515,10 @@ def post_list_capacity_commitments( def pre_list_reservations( self, request: reservation.ListReservationsRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[reservation.ListReservationsRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + reservation.ListReservationsRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for list_reservations Override in a subclass to manipulate the request or metadata @@ -501,8 +540,11 @@ def post_list_reservations( def pre_merge_capacity_commitments( self, request: reservation.MergeCapacityCommitmentsRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[reservation.MergeCapacityCommitmentsRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + reservation.MergeCapacityCommitmentsRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for merge_capacity_commitments Override in a subclass to manipulate the request or metadata @@ -524,8 +566,10 @@ def post_merge_capacity_commitments( def pre_move_assignment( self, request: reservation.MoveAssignmentRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[reservation.MoveAssignmentRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + reservation.MoveAssignmentRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for move_assignment Override in a subclass to manipulate the request or metadata @@ -547,8 +591,10 @@ def post_move_assignment( def pre_search_all_assignments( self, request: reservation.SearchAllAssignmentsRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[reservation.SearchAllAssignmentsRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + reservation.SearchAllAssignmentsRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for search_all_assignments Override in a subclass to manipulate the request or metadata @@ -570,8 +616,10 @@ def post_search_all_assignments( def pre_search_assignments( self, request: reservation.SearchAssignmentsRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[reservation.SearchAssignmentsRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + reservation.SearchAssignmentsRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for search_assignments Override in a subclass to manipulate the request or metadata @@ -593,8 +641,11 @@ def post_search_assignments( def pre_split_capacity_commitment( self, request: reservation.SplitCapacityCommitmentRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[reservation.SplitCapacityCommitmentRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + reservation.SplitCapacityCommitmentRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for split_capacity_commitment Override in a subclass to manipulate the request or metadata @@ -616,8 +667,10 @@ def post_split_capacity_commitment( def pre_update_assignment( self, request: reservation.UpdateAssignmentRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[reservation.UpdateAssignmentRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + reservation.UpdateAssignmentRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for update_assignment Override in a subclass to manipulate the request or metadata @@ -639,8 +692,10 @@ def post_update_assignment( def pre_update_bi_reservation( self, request: reservation.UpdateBiReservationRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[reservation.UpdateBiReservationRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + reservation.UpdateBiReservationRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for update_bi_reservation Override in a subclass to manipulate the request or metadata @@ -662,8 +717,11 @@ def post_update_bi_reservation( def pre_update_capacity_commitment( self, request: reservation.UpdateCapacityCommitmentRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[reservation.UpdateCapacityCommitmentRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + reservation.UpdateCapacityCommitmentRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for update_capacity_commitment Override in a subclass to manipulate the request or metadata @@ -685,8 +743,11 @@ def post_update_capacity_commitment( def pre_update_reservation( self, request: gcbr_reservation.UpdateReservationRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[gcbr_reservation.UpdateReservationRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + gcbr_reservation.UpdateReservationRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for update_reservation Override in a subclass to manipulate the request or metadata @@ -843,7 +904,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> reservation.Assignment: r"""Call the create assignment method over HTTP. @@ -856,8 +917,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.reservation.Assignment: @@ -870,6 +933,7 @@ def __call__( http_options = ( _BaseReservationServiceRestTransport._BaseCreateAssignment._get_http_options() ) + request, metadata = self._interceptor.pre_create_assignment( request, metadata ) @@ -886,6 +950,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.bigquery.reservation_v1.ReservationServiceClient.CreateAssignment", + extra={ + "serviceName": "google.cloud.bigquery.reservation.v1.ReservationService", + "rpcName": "CreateAssignment", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ReservationServiceRestTransport._CreateAssignment._get_response( self._host, @@ -907,7 +998,29 @@ def __call__( pb_resp = reservation.Assignment.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_create_assignment(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = reservation.Assignment.to_json(response) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.bigquery.reservation_v1.ReservationServiceClient.create_assignment", + extra={ + "serviceName": "google.cloud.bigquery.reservation.v1.ReservationService", + "rpcName": "CreateAssignment", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _CreateCapacityCommitment( @@ -946,7 +1059,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> reservation.CapacityCommitment: r"""Call the create capacity commitment method over HTTP. @@ -958,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: ~.reservation.CapacityCommitment: @@ -983,6 +1098,7 @@ def __call__( http_options = ( _BaseReservationServiceRestTransport._BaseCreateCapacityCommitment._get_http_options() ) + request, metadata = self._interceptor.pre_create_capacity_commitment( request, metadata ) @@ -999,6 +1115,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.bigquery.reservation_v1.ReservationServiceClient.CreateCapacityCommitment", + extra={ + "serviceName": "google.cloud.bigquery.reservation.v1.ReservationService", + "rpcName": "CreateCapacityCommitment", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ( ReservationServiceRestTransport._CreateCapacityCommitment._get_response( @@ -1022,7 +1165,29 @@ def __call__( pb_resp = reservation.CapacityCommitment.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_create_capacity_commitment(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = reservation.CapacityCommitment.to_json(response) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.bigquery.reservation_v1.ReservationServiceClient.create_capacity_commitment", + extra={ + "serviceName": "google.cloud.bigquery.reservation.v1.ReservationService", + "rpcName": "CreateCapacityCommitment", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _CreateReservation( @@ -1061,7 +1226,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> gcbr_reservation.Reservation: r"""Call the create reservation method over HTTP. @@ -1072,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: ~.gcbr_reservation.Reservation: @@ -1085,6 +1252,7 @@ def __call__( http_options = ( _BaseReservationServiceRestTransport._BaseCreateReservation._get_http_options() ) + request, metadata = self._interceptor.pre_create_reservation( request, metadata ) @@ -1101,6 +1269,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.bigquery.reservation_v1.ReservationServiceClient.CreateReservation", + extra={ + "serviceName": "google.cloud.bigquery.reservation.v1.ReservationService", + "rpcName": "CreateReservation", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ReservationServiceRestTransport._CreateReservation._get_response( self._host, @@ -1122,7 +1317,29 @@ def __call__( pb_resp = gcbr_reservation.Reservation.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_create_reservation(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = gcbr_reservation.Reservation.to_json(response) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.bigquery.reservation_v1.ReservationServiceClient.create_reservation", + extra={ + "serviceName": "google.cloud.bigquery.reservation.v1.ReservationService", + "rpcName": "CreateReservation", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _DeleteAssignment( @@ -1160,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]]] = (), ): r"""Call the delete assignment method over HTTP. @@ -1173,13 +1390,16 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. """ http_options = ( _BaseReservationServiceRestTransport._BaseDeleteAssignment._get_http_options() ) + request, metadata = self._interceptor.pre_delete_assignment( request, metadata ) @@ -1192,6 +1412,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.bigquery.reservation_v1.ReservationServiceClient.DeleteAssignment", + extra={ + "serviceName": "google.cloud.bigquery.reservation.v1.ReservationService", + "rpcName": "DeleteAssignment", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ReservationServiceRestTransport._DeleteAssignment._get_response( self._host, @@ -1242,7 +1489,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ): r"""Call the delete capacity commitment method over HTTP. @@ -1254,13 +1501,16 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. """ http_options = ( _BaseReservationServiceRestTransport._BaseDeleteCapacityCommitment._get_http_options() ) + request, metadata = self._interceptor.pre_delete_capacity_commitment( request, metadata ) @@ -1273,6 +1523,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.bigquery.reservation_v1.ReservationServiceClient.DeleteCapacityCommitment", + extra={ + "serviceName": "google.cloud.bigquery.reservation.v1.ReservationService", + "rpcName": "DeleteCapacityCommitment", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ( ReservationServiceRestTransport._DeleteCapacityCommitment._get_response( @@ -1325,7 +1602,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ): r"""Call the delete reservation method over HTTP. @@ -1336,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 = ( _BaseReservationServiceRestTransport._BaseDeleteReservation._get_http_options() ) + request, metadata = self._interceptor.pre_delete_reservation( request, metadata ) @@ -1355,6 +1635,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.bigquery.reservation_v1.ReservationServiceClient.DeleteReservation", + extra={ + "serviceName": "google.cloud.bigquery.reservation.v1.ReservationService", + "rpcName": "DeleteReservation", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ReservationServiceRestTransport._DeleteReservation._get_response( self._host, @@ -1406,7 +1713,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> reservation.Reservation: r"""Call the failover reservation method over HTTP. @@ -1417,8 +1724,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.reservation.Reservation: @@ -1430,6 +1739,7 @@ def __call__( http_options = ( _BaseReservationServiceRestTransport._BaseFailoverReservation._get_http_options() ) + request, metadata = self._interceptor.pre_failover_reservation( request, metadata ) @@ -1446,6 +1756,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.bigquery.reservation_v1.ReservationServiceClient.FailoverReservation", + extra={ + "serviceName": "google.cloud.bigquery.reservation.v1.ReservationService", + "rpcName": "FailoverReservation", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ( ReservationServiceRestTransport._FailoverReservation._get_response( @@ -1469,7 +1806,29 @@ def __call__( pb_resp = reservation.Reservation.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_failover_reservation(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = reservation.Reservation.to_json(response) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.bigquery.reservation_v1.ReservationServiceClient.failover_reservation", + extra={ + "serviceName": "google.cloud.bigquery.reservation.v1.ReservationService", + "rpcName": "FailoverReservation", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _GetBiReservation( @@ -1507,7 +1866,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> reservation.BiReservation: r"""Call the get bi reservation method over HTTP. @@ -1518,8 +1877,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.reservation.BiReservation: @@ -1529,6 +1890,7 @@ def __call__( http_options = ( _BaseReservationServiceRestTransport._BaseGetBiReservation._get_http_options() ) + request, metadata = self._interceptor.pre_get_bi_reservation( request, metadata ) @@ -1541,6 +1903,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.bigquery.reservation_v1.ReservationServiceClient.GetBiReservation", + extra={ + "serviceName": "google.cloud.bigquery.reservation.v1.ReservationService", + "rpcName": "GetBiReservation", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ReservationServiceRestTransport._GetBiReservation._get_response( self._host, @@ -1561,7 +1950,29 @@ def __call__( pb_resp = reservation.BiReservation.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_bi_reservation(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = reservation.BiReservation.to_json(response) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.bigquery.reservation_v1.ReservationServiceClient.get_bi_reservation", + extra={ + "serviceName": "google.cloud.bigquery.reservation.v1.ReservationService", + "rpcName": "GetBiReservation", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _GetCapacityCommitment( @@ -1599,7 +2010,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> reservation.CapacityCommitment: r"""Call the get capacity commitment method over HTTP. @@ -1610,8 +2021,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.reservation.CapacityCommitment: @@ -1635,6 +2048,7 @@ def __call__( http_options = ( _BaseReservationServiceRestTransport._BaseGetCapacityCommitment._get_http_options() ) + request, metadata = self._interceptor.pre_get_capacity_commitment( request, metadata ) @@ -1647,6 +2061,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.bigquery.reservation_v1.ReservationServiceClient.GetCapacityCommitment", + extra={ + "serviceName": "google.cloud.bigquery.reservation.v1.ReservationService", + "rpcName": "GetCapacityCommitment", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ( ReservationServiceRestTransport._GetCapacityCommitment._get_response( @@ -1669,7 +2110,29 @@ def __call__( pb_resp = reservation.CapacityCommitment.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_capacity_commitment(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = reservation.CapacityCommitment.to_json(response) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.bigquery.reservation_v1.ReservationServiceClient.get_capacity_commitment", + extra={ + "serviceName": "google.cloud.bigquery.reservation.v1.ReservationService", + "rpcName": "GetCapacityCommitment", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _GetReservation( @@ -1707,7 +2170,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> reservation.Reservation: r"""Call the get reservation method over HTTP. @@ -1718,8 +2181,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.reservation.Reservation: @@ -1731,6 +2196,7 @@ def __call__( http_options = ( _BaseReservationServiceRestTransport._BaseGetReservation._get_http_options() ) + request, metadata = self._interceptor.pre_get_reservation(request, metadata) transcoded_request = _BaseReservationServiceRestTransport._BaseGetReservation._get_transcoded_request( http_options, request @@ -1741,6 +2207,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.bigquery.reservation_v1.ReservationServiceClient.GetReservation", + extra={ + "serviceName": "google.cloud.bigquery.reservation.v1.ReservationService", + "rpcName": "GetReservation", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ReservationServiceRestTransport._GetReservation._get_response( self._host, @@ -1761,7 +2254,29 @@ def __call__( pb_resp = reservation.Reservation.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_reservation(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = reservation.Reservation.to_json(response) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.bigquery.reservation_v1.ReservationServiceClient.get_reservation", + extra={ + "serviceName": "google.cloud.bigquery.reservation.v1.ReservationService", + "rpcName": "GetReservation", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ListAssignments( @@ -1799,7 +2314,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> reservation.ListAssignmentsResponse: r"""Call the list assignments method over HTTP. @@ -1810,8 +2325,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.reservation.ListAssignmentsResponse: @@ -1823,6 +2340,7 @@ def __call__( http_options = ( _BaseReservationServiceRestTransport._BaseListAssignments._get_http_options() ) + request, metadata = self._interceptor.pre_list_assignments( request, metadata ) @@ -1835,6 +2353,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.bigquery.reservation_v1.ReservationServiceClient.ListAssignments", + extra={ + "serviceName": "google.cloud.bigquery.reservation.v1.ReservationService", + "rpcName": "ListAssignments", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ReservationServiceRestTransport._ListAssignments._get_response( self._host, @@ -1855,7 +2400,31 @@ def __call__( pb_resp = reservation.ListAssignmentsResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_assignments(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = reservation.ListAssignmentsResponse.to_json( + response + ) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.bigquery.reservation_v1.ReservationServiceClient.list_assignments", + extra={ + "serviceName": "google.cloud.bigquery.reservation.v1.ReservationService", + "rpcName": "ListAssignments", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ListCapacityCommitments( @@ -1893,7 +2462,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> reservation.ListCapacityCommitmentsResponse: r"""Call the list capacity commitments method over HTTP. @@ -1904,8 +2473,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.reservation.ListCapacityCommitmentsResponse: @@ -1917,6 +2488,7 @@ def __call__( http_options = ( _BaseReservationServiceRestTransport._BaseListCapacityCommitments._get_http_options() ) + request, metadata = self._interceptor.pre_list_capacity_commitments( request, metadata ) @@ -1929,6 +2501,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.bigquery.reservation_v1.ReservationServiceClient.ListCapacityCommitments", + extra={ + "serviceName": "google.cloud.bigquery.reservation.v1.ReservationService", + "rpcName": "ListCapacityCommitments", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ( ReservationServiceRestTransport._ListCapacityCommitments._get_response( @@ -1951,7 +2550,31 @@ def __call__( pb_resp = reservation.ListCapacityCommitmentsResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_capacity_commitments(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = ( + reservation.ListCapacityCommitmentsResponse.to_json(response) + ) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.bigquery.reservation_v1.ReservationServiceClient.list_capacity_commitments", + extra={ + "serviceName": "google.cloud.bigquery.reservation.v1.ReservationService", + "rpcName": "ListCapacityCommitments", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ListReservations( @@ -1989,7 +2612,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> reservation.ListReservationsResponse: r"""Call the list reservations method over HTTP. @@ -2000,8 +2623,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.reservation.ListReservationsResponse: @@ -2013,6 +2638,7 @@ def __call__( http_options = ( _BaseReservationServiceRestTransport._BaseListReservations._get_http_options() ) + request, metadata = self._interceptor.pre_list_reservations( request, metadata ) @@ -2025,6 +2651,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.bigquery.reservation_v1.ReservationServiceClient.ListReservations", + extra={ + "serviceName": "google.cloud.bigquery.reservation.v1.ReservationService", + "rpcName": "ListReservations", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ReservationServiceRestTransport._ListReservations._get_response( self._host, @@ -2045,7 +2698,31 @@ def __call__( pb_resp = reservation.ListReservationsResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_reservations(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = reservation.ListReservationsResponse.to_json( + response + ) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.bigquery.reservation_v1.ReservationServiceClient.list_reservations", + extra={ + "serviceName": "google.cloud.bigquery.reservation.v1.ReservationService", + "rpcName": "ListReservations", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _MergeCapacityCommitments( @@ -2084,7 +2761,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> reservation.CapacityCommitment: r"""Call the merge capacity commitments method over HTTP. @@ -2096,8 +2773,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.reservation.CapacityCommitment: @@ -2121,6 +2800,7 @@ def __call__( http_options = ( _BaseReservationServiceRestTransport._BaseMergeCapacityCommitments._get_http_options() ) + request, metadata = self._interceptor.pre_merge_capacity_commitments( request, metadata ) @@ -2137,6 +2817,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.bigquery.reservation_v1.ReservationServiceClient.MergeCapacityCommitments", + extra={ + "serviceName": "google.cloud.bigquery.reservation.v1.ReservationService", + "rpcName": "MergeCapacityCommitments", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ( ReservationServiceRestTransport._MergeCapacityCommitments._get_response( @@ -2160,7 +2867,29 @@ def __call__( pb_resp = reservation.CapacityCommitment.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_merge_capacity_commitments(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = reservation.CapacityCommitment.to_json(response) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.bigquery.reservation_v1.ReservationServiceClient.merge_capacity_commitments", + extra={ + "serviceName": "google.cloud.bigquery.reservation.v1.ReservationService", + "rpcName": "MergeCapacityCommitments", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _MoveAssignment( @@ -2199,7 +2928,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> reservation.Assignment: r"""Call the move assignment method over HTTP. @@ -2217,8 +2946,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.reservation.Assignment: @@ -2231,6 +2962,7 @@ def __call__( http_options = ( _BaseReservationServiceRestTransport._BaseMoveAssignment._get_http_options() ) + request, metadata = self._interceptor.pre_move_assignment(request, metadata) transcoded_request = _BaseReservationServiceRestTransport._BaseMoveAssignment._get_transcoded_request( http_options, request @@ -2245,6 +2977,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.bigquery.reservation_v1.ReservationServiceClient.MoveAssignment", + extra={ + "serviceName": "google.cloud.bigquery.reservation.v1.ReservationService", + "rpcName": "MoveAssignment", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ReservationServiceRestTransport._MoveAssignment._get_response( self._host, @@ -2266,7 +3025,29 @@ def __call__( pb_resp = reservation.Assignment.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_move_assignment(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = reservation.Assignment.to_json(response) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.bigquery.reservation_v1.ReservationServiceClient.move_assignment", + extra={ + "serviceName": "google.cloud.bigquery.reservation.v1.ReservationService", + "rpcName": "MoveAssignment", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _SearchAllAssignments( @@ -2304,7 +3085,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> reservation.SearchAllAssignmentsResponse: r"""Call the search all assignments method over HTTP. @@ -2317,8 +3098,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.reservation.SearchAllAssignmentsResponse: @@ -2330,6 +3113,7 @@ def __call__( http_options = ( _BaseReservationServiceRestTransport._BaseSearchAllAssignments._get_http_options() ) + request, metadata = self._interceptor.pre_search_all_assignments( request, metadata ) @@ -2342,6 +3126,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.bigquery.reservation_v1.ReservationServiceClient.SearchAllAssignments", + extra={ + "serviceName": "google.cloud.bigquery.reservation.v1.ReservationService", + "rpcName": "SearchAllAssignments", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ( ReservationServiceRestTransport._SearchAllAssignments._get_response( @@ -2364,7 +3175,31 @@ def __call__( pb_resp = reservation.SearchAllAssignmentsResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_search_all_assignments(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = reservation.SearchAllAssignmentsResponse.to_json( + response + ) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.bigquery.reservation_v1.ReservationServiceClient.search_all_assignments", + extra={ + "serviceName": "google.cloud.bigquery.reservation.v1.ReservationService", + "rpcName": "SearchAllAssignments", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _SearchAssignments( @@ -2402,7 +3237,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> reservation.SearchAssignmentsResponse: r"""Call the search assignments method over HTTP. @@ -2415,8 +3250,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.reservation.SearchAssignmentsResponse: @@ -2428,6 +3265,7 @@ def __call__( http_options = ( _BaseReservationServiceRestTransport._BaseSearchAssignments._get_http_options() ) + request, metadata = self._interceptor.pre_search_assignments( request, metadata ) @@ -2440,6 +3278,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.bigquery.reservation_v1.ReservationServiceClient.SearchAssignments", + extra={ + "serviceName": "google.cloud.bigquery.reservation.v1.ReservationService", + "rpcName": "SearchAssignments", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ReservationServiceRestTransport._SearchAssignments._get_response( self._host, @@ -2460,7 +3325,31 @@ def __call__( pb_resp = reservation.SearchAssignmentsResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_search_assignments(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = reservation.SearchAssignmentsResponse.to_json( + response + ) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.bigquery.reservation_v1.ReservationServiceClient.search_assignments", + extra={ + "serviceName": "google.cloud.bigquery.reservation.v1.ReservationService", + "rpcName": "SearchAssignments", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _SplitCapacityCommitment( @@ -2499,7 +3388,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> reservation.SplitCapacityCommitmentResponse: r"""Call the split capacity commitment method over HTTP. @@ -2510,8 +3399,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.reservation.SplitCapacityCommitmentResponse: @@ -2523,6 +3414,7 @@ def __call__( http_options = ( _BaseReservationServiceRestTransport._BaseSplitCapacityCommitment._get_http_options() ) + request, metadata = self._interceptor.pre_split_capacity_commitment( request, metadata ) @@ -2539,6 +3431,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.bigquery.reservation_v1.ReservationServiceClient.SplitCapacityCommitment", + extra={ + "serviceName": "google.cloud.bigquery.reservation.v1.ReservationService", + "rpcName": "SplitCapacityCommitment", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ( ReservationServiceRestTransport._SplitCapacityCommitment._get_response( @@ -2562,7 +3481,31 @@ def __call__( pb_resp = reservation.SplitCapacityCommitmentResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_split_capacity_commitment(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = ( + reservation.SplitCapacityCommitmentResponse.to_json(response) + ) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.bigquery.reservation_v1.ReservationServiceClient.split_capacity_commitment", + extra={ + "serviceName": "google.cloud.bigquery.reservation.v1.ReservationService", + "rpcName": "SplitCapacityCommitment", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _UpdateAssignment( @@ -2601,7 +3544,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> reservation.Assignment: r"""Call the update assignment method over HTTP. @@ -2612,8 +3555,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.reservation.Assignment: @@ -2626,6 +3571,7 @@ def __call__( http_options = ( _BaseReservationServiceRestTransport._BaseUpdateAssignment._get_http_options() ) + request, metadata = self._interceptor.pre_update_assignment( request, metadata ) @@ -2642,6 +3588,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.bigquery.reservation_v1.ReservationServiceClient.UpdateAssignment", + extra={ + "serviceName": "google.cloud.bigquery.reservation.v1.ReservationService", + "rpcName": "UpdateAssignment", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ReservationServiceRestTransport._UpdateAssignment._get_response( self._host, @@ -2663,7 +3636,29 @@ def __call__( pb_resp = reservation.Assignment.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_update_assignment(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = reservation.Assignment.to_json(response) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.bigquery.reservation_v1.ReservationServiceClient.update_assignment", + extra={ + "serviceName": "google.cloud.bigquery.reservation.v1.ReservationService", + "rpcName": "UpdateAssignment", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _UpdateBiReservation( @@ -2702,7 +3697,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> reservation.BiReservation: r"""Call the update bi reservation method over HTTP. @@ -2712,8 +3707,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.reservation.BiReservation: @@ -2723,6 +3720,7 @@ def __call__( http_options = ( _BaseReservationServiceRestTransport._BaseUpdateBiReservation._get_http_options() ) + request, metadata = self._interceptor.pre_update_bi_reservation( request, metadata ) @@ -2739,6 +3737,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.bigquery.reservation_v1.ReservationServiceClient.UpdateBiReservation", + extra={ + "serviceName": "google.cloud.bigquery.reservation.v1.ReservationService", + "rpcName": "UpdateBiReservation", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ( ReservationServiceRestTransport._UpdateBiReservation._get_response( @@ -2762,7 +3787,29 @@ def __call__( pb_resp = reservation.BiReservation.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_update_bi_reservation(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = reservation.BiReservation.to_json(response) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.bigquery.reservation_v1.ReservationServiceClient.update_bi_reservation", + extra={ + "serviceName": "google.cloud.bigquery.reservation.v1.ReservationService", + "rpcName": "UpdateBiReservation", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _UpdateCapacityCommitment( @@ -2801,7 +3848,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> reservation.CapacityCommitment: r"""Call the update capacity commitment method over HTTP. @@ -2813,8 +3860,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.reservation.CapacityCommitment: @@ -2838,6 +3887,7 @@ def __call__( http_options = ( _BaseReservationServiceRestTransport._BaseUpdateCapacityCommitment._get_http_options() ) + request, metadata = self._interceptor.pre_update_capacity_commitment( request, metadata ) @@ -2854,6 +3904,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.bigquery.reservation_v1.ReservationServiceClient.UpdateCapacityCommitment", + extra={ + "serviceName": "google.cloud.bigquery.reservation.v1.ReservationService", + "rpcName": "UpdateCapacityCommitment", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ( ReservationServiceRestTransport._UpdateCapacityCommitment._get_response( @@ -2877,7 +3954,29 @@ def __call__( pb_resp = reservation.CapacityCommitment.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_update_capacity_commitment(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = reservation.CapacityCommitment.to_json(response) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.bigquery.reservation_v1.ReservationServiceClient.update_capacity_commitment", + extra={ + "serviceName": "google.cloud.bigquery.reservation.v1.ReservationService", + "rpcName": "UpdateCapacityCommitment", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _UpdateReservation( @@ -2916,7 +4015,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> gcbr_reservation.Reservation: r"""Call the update reservation method over HTTP. @@ -2927,8 +4026,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.gcbr_reservation.Reservation: @@ -2940,6 +4041,7 @@ def __call__( http_options = ( _BaseReservationServiceRestTransport._BaseUpdateReservation._get_http_options() ) + request, metadata = self._interceptor.pre_update_reservation( request, metadata ) @@ -2956,6 +4058,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.bigquery.reservation_v1.ReservationServiceClient.UpdateReservation", + extra={ + "serviceName": "google.cloud.bigquery.reservation.v1.ReservationService", + "rpcName": "UpdateReservation", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ReservationServiceRestTransport._UpdateReservation._get_response( self._host, @@ -2977,7 +4106,29 @@ def __call__( pb_resp = gcbr_reservation.Reservation.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_update_reservation(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = gcbr_reservation.Reservation.to_json(response) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.bigquery.reservation_v1.ReservationServiceClient.update_reservation", + extra={ + "serviceName": "google.cloud.bigquery.reservation.v1.ReservationService", + "rpcName": "UpdateReservation", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp @property diff --git a/packages/google-cloud-bigquery-reservation/samples/generated_samples/snippet_metadata_google.cloud.bigquery.reservation.v1.json b/packages/google-cloud-bigquery-reservation/samples/generated_samples/snippet_metadata_google.cloud.bigquery.reservation.v1.json index e5b0aa18a87f..4cdd226b3806 100644 --- a/packages/google-cloud-bigquery-reservation/samples/generated_samples/snippet_metadata_google.cloud.bigquery.reservation.v1.json +++ b/packages/google-cloud-bigquery-reservation/samples/generated_samples/snippet_metadata_google.cloud.bigquery.reservation.v1.json @@ -51,7 +51,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.bigquery_reservation_v1.types.Assignment", @@ -135,7 +135,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.bigquery_reservation_v1.types.Assignment", @@ -220,7 +220,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.bigquery_reservation_v1.types.CapacityCommitment", @@ -304,7 +304,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.bigquery_reservation_v1.types.CapacityCommitment", @@ -393,7 +393,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.bigquery_reservation_v1.types.Reservation", @@ -481,7 +481,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.bigquery_reservation_v1.types.Reservation", @@ -562,7 +562,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "shortName": "delete_assignment" @@ -639,7 +639,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "shortName": "delete_assignment" @@ -717,7 +717,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "shortName": "delete_capacity_commitment" @@ -794,7 +794,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "shortName": "delete_capacity_commitment" @@ -872,7 +872,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "shortName": "delete_reservation" @@ -949,7 +949,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "shortName": "delete_reservation" @@ -1023,7 +1023,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.bigquery_reservation_v1.types.Reservation", @@ -1099,7 +1099,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.bigquery_reservation_v1.types.Reservation", @@ -1180,7 +1180,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.bigquery_reservation_v1.types.BiReservation", @@ -1260,7 +1260,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.bigquery_reservation_v1.types.BiReservation", @@ -1341,7 +1341,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.bigquery_reservation_v1.types.CapacityCommitment", @@ -1421,7 +1421,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.bigquery_reservation_v1.types.CapacityCommitment", @@ -1502,7 +1502,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.bigquery_reservation_v1.types.Reservation", @@ -1582,7 +1582,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.bigquery_reservation_v1.types.Reservation", @@ -1663,7 +1663,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.bigquery_reservation_v1.services.reservation_service.pagers.ListAssignmentsAsyncPager", @@ -1743,7 +1743,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.bigquery_reservation_v1.services.reservation_service.pagers.ListAssignmentsPager", @@ -1824,7 +1824,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.bigquery_reservation_v1.services.reservation_service.pagers.ListCapacityCommitmentsAsyncPager", @@ -1904,7 +1904,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.bigquery_reservation_v1.services.reservation_service.pagers.ListCapacityCommitmentsPager", @@ -1985,7 +1985,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.bigquery_reservation_v1.services.reservation_service.pagers.ListReservationsAsyncPager", @@ -2065,7 +2065,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.bigquery_reservation_v1.services.reservation_service.pagers.ListReservationsPager", @@ -2150,7 +2150,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.bigquery_reservation_v1.types.CapacityCommitment", @@ -2234,7 +2234,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.bigquery_reservation_v1.types.CapacityCommitment", @@ -2319,7 +2319,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.bigquery_reservation_v1.types.Assignment", @@ -2403,7 +2403,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.bigquery_reservation_v1.types.Assignment", @@ -2488,7 +2488,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.bigquery_reservation_v1.services.reservation_service.pagers.SearchAllAssignmentsAsyncPager", @@ -2572,7 +2572,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.bigquery_reservation_v1.services.reservation_service.pagers.SearchAllAssignmentsPager", @@ -2657,7 +2657,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.bigquery_reservation_v1.services.reservation_service.pagers.SearchAssignmentsAsyncPager", @@ -2741,7 +2741,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.bigquery_reservation_v1.services.reservation_service.pagers.SearchAssignmentsPager", @@ -2826,7 +2826,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.bigquery_reservation_v1.types.SplitCapacityCommitmentResponse", @@ -2910,7 +2910,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.bigquery_reservation_v1.types.SplitCapacityCommitmentResponse", @@ -2995,7 +2995,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.bigquery_reservation_v1.types.Assignment", @@ -3079,7 +3079,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.bigquery_reservation_v1.types.Assignment", @@ -3164,7 +3164,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.bigquery_reservation_v1.types.BiReservation", @@ -3248,7 +3248,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.bigquery_reservation_v1.types.BiReservation", @@ -3333,7 +3333,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.bigquery_reservation_v1.types.CapacityCommitment", @@ -3417,7 +3417,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.bigquery_reservation_v1.types.CapacityCommitment", @@ -3502,7 +3502,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.bigquery_reservation_v1.types.Reservation", @@ -3586,7 +3586,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.bigquery_reservation_v1.types.Reservation", diff --git a/packages/google-cloud-bigquery-reservation/tests/unit/gapic/bigquery_reservation_v1/test_reservation_service.py b/packages/google-cloud-bigquery-reservation/tests/unit/gapic/bigquery_reservation_v1/test_reservation_service.py index 8b6f79cbd379..970a335958c8 100644 --- a/packages/google-cloud-bigquery-reservation/tests/unit/gapic/bigquery_reservation_v1/test_reservation_service.py +++ b/packages/google-cloud-bigquery-reservation/tests/unit/gapic/bigquery_reservation_v1/test_reservation_service.py @@ -9978,6 +9978,7 @@ def test_create_reservation_rest_required_fields( response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.create_reservation(request) @@ -10025,6 +10026,7 @@ def test_create_reservation_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.create_reservation(**mock_args) @@ -10167,6 +10169,7 @@ def test_list_reservations_rest_required_fields( response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.list_reservations(request) @@ -10220,6 +10223,7 @@ def test_list_reservations_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.list_reservations(**mock_args) @@ -10414,6 +10418,7 @@ def test_get_reservation_rest_required_fields( response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.get_reservation(request) @@ -10461,6 +10466,7 @@ def test_get_reservation_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.get_reservation(**mock_args) @@ -10593,6 +10599,7 @@ def test_delete_reservation_rest_required_fields( response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.delete_reservation(request) @@ -10638,6 +10645,7 @@ def test_delete_reservation_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_reservation(**mock_args) @@ -10740,6 +10748,7 @@ def test_update_reservation_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.update_reservation(**mock_args) @@ -10877,6 +10886,7 @@ def test_failover_reservation_rest_required_fields( response_value._content = json_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_reservation(request) @@ -11009,6 +11019,7 @@ def test_create_capacity_commitment_rest_required_fields( response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.create_capacity_commitment(request) @@ -11063,6 +11074,7 @@ def test_create_capacity_commitment_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.create_capacity_commitment(**mock_args) @@ -11207,6 +11219,7 @@ def test_list_capacity_commitments_rest_required_fields( response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.list_capacity_commitments(request) @@ -11260,6 +11273,7 @@ def test_list_capacity_commitments_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.list_capacity_commitments(**mock_args) @@ -11459,6 +11473,7 @@ def test_get_capacity_commitment_rest_required_fields( response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.get_capacity_commitment(request) @@ -11506,6 +11521,7 @@ def test_get_capacity_commitment_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.get_capacity_commitment(**mock_args) @@ -11641,6 +11657,7 @@ def test_delete_capacity_commitment_rest_required_fields( response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.delete_capacity_commitment(request) @@ -11686,6 +11703,7 @@ def test_delete_capacity_commitment_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_capacity_commitment(**mock_args) @@ -11789,6 +11807,7 @@ def test_update_capacity_commitment_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.update_capacity_commitment(**mock_args) @@ -11927,6 +11946,7 @@ def test_split_capacity_commitment_rest_required_fields( response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.split_capacity_commitment(request) @@ -11975,6 +11995,7 @@ def test_split_capacity_commitment_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.split_capacity_commitment(**mock_args) @@ -12075,6 +12096,7 @@ def test_merge_capacity_commitments_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.merge_capacity_commitments(**mock_args) @@ -12212,6 +12234,7 @@ def test_create_assignment_rest_required_fields( response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.create_assignment(request) @@ -12260,6 +12283,7 @@ def test_create_assignment_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.create_assignment(**mock_args) @@ -12401,6 +12425,7 @@ def test_list_assignments_rest_required_fields( response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.list_assignments(request) @@ -12456,6 +12481,7 @@ def test_list_assignments_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.list_assignments(**mock_args) @@ -12651,6 +12677,7 @@ def test_delete_assignment_rest_required_fields( response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.delete_assignment(request) @@ -12696,6 +12723,7 @@ def test_delete_assignment_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_assignment(**mock_args) @@ -12839,6 +12867,7 @@ def test_search_assignments_rest_required_fields( response_value._content = json_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_assignments(request) @@ -12894,6 +12923,7 @@ def test_search_assignments_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = 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_assignments(**mock_args) @@ -13102,6 +13132,7 @@ def test_search_all_assignments_rest_required_fields( response_value._content = json_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_assignments(request) @@ -13157,6 +13188,7 @@ def test_search_all_assignments_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = 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_assignments(**mock_args) @@ -13353,6 +13385,7 @@ def test_move_assignment_rest_required_fields( response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.move_assignment(request) @@ -13401,6 +13434,7 @@ def test_move_assignment_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.move_assignment(**mock_args) @@ -13502,6 +13536,7 @@ def test_update_assignment_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.update_assignment(**mock_args) @@ -13638,6 +13673,7 @@ def test_get_bi_reservation_rest_required_fields( response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.get_bi_reservation(request) @@ -13683,6 +13719,7 @@ def test_get_bi_reservation_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.get_bi_reservation(**mock_args) @@ -13786,6 +13823,7 @@ def test_update_bi_reservation_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.update_bi_reservation(**mock_args) @@ -15153,6 +15191,7 @@ def test_create_reservation_rest_bad_request( response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.create_reservation(request) @@ -15277,6 +15316,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.create_reservation(request) # Establish that the response is the type that we expect. @@ -15325,6 +15365,7 @@ def test_create_reservation_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = gcbr_reservation.Reservation.to_json( gcbr_reservation.Reservation() ) @@ -15371,6 +15412,7 @@ def test_list_reservations_rest_bad_request( response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.list_reservations(request) @@ -15406,6 +15448,7 @@ def test_list_reservations_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.list_reservations(request) # Establish that the response is the type that we expect. @@ -15446,6 +15489,7 @@ def test_list_reservations_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = reservation.ListReservationsResponse.to_json( reservation.ListReservationsResponse() ) @@ -15492,6 +15536,7 @@ def test_get_reservation_rest_bad_request( response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.get_reservation(request) @@ -15535,6 +15580,7 @@ def test_get_reservation_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.get_reservation(request) # Establish that the response is the type that we expect. @@ -15583,6 +15629,7 @@ def test_get_reservation_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = reservation.Reservation.to_json(reservation.Reservation()) req.return_value.content = return_value @@ -15627,6 +15674,7 @@ def test_delete_reservation_rest_bad_request( response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.delete_reservation(request) @@ -15657,6 +15705,7 @@ def test_delete_reservation_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_reservation(request) # Establish that the response is the type that we expect. @@ -15693,6 +15742,7 @@ def test_delete_reservation_rest_interceptors(null_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 = reservation.DeleteReservationRequest() metadata = [ @@ -15737,6 +15787,7 @@ def test_update_reservation_rest_bad_request( response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.update_reservation(request) @@ -15865,6 +15916,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.update_reservation(request) # Establish that the response is the type that we expect. @@ -15913,6 +15965,7 @@ def test_update_reservation_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = gcbr_reservation.Reservation.to_json( gcbr_reservation.Reservation() ) @@ -15959,6 +16012,7 @@ def test_failover_reservation_rest_bad_request( response_value.status_code = 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_reservation(request) @@ -16002,6 +16056,7 @@ def test_failover_reservation_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_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_reservation(request) # Establish that the response is the type that we expect. @@ -16050,6 +16105,7 @@ def test_failover_reservation_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = reservation.Reservation.to_json(reservation.Reservation()) req.return_value.content = return_value @@ -16094,6 +16150,7 @@ def test_create_capacity_commitment_rest_bad_request( response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.create_capacity_commitment(request) @@ -16227,6 +16284,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.create_capacity_commitment(request) # Establish that the response is the type that we expect. @@ -16274,6 +16332,7 @@ def test_create_capacity_commitment_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = reservation.CapacityCommitment.to_json( reservation.CapacityCommitment() ) @@ -16320,6 +16379,7 @@ def test_list_capacity_commitments_rest_bad_request( response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.list_capacity_commitments(request) @@ -16355,6 +16415,7 @@ def test_list_capacity_commitments_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.list_capacity_commitments(request) # Establish that the response is the type that we expect. @@ -16395,6 +16456,7 @@ def test_list_capacity_commitments_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = reservation.ListCapacityCommitmentsResponse.to_json( reservation.ListCapacityCommitmentsResponse() ) @@ -16443,6 +16505,7 @@ def test_get_capacity_commitment_rest_bad_request( response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.get_capacity_commitment(request) @@ -16487,6 +16550,7 @@ def test_get_capacity_commitment_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.get_capacity_commitment(request) # Establish that the response is the type that we expect. @@ -16534,6 +16598,7 @@ def test_get_capacity_commitment_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = reservation.CapacityCommitment.to_json( reservation.CapacityCommitment() ) @@ -16582,6 +16647,7 @@ def test_delete_capacity_commitment_rest_bad_request( response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.delete_capacity_commitment(request) @@ -16614,6 +16680,7 @@ def test_delete_capacity_commitment_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_capacity_commitment(request) # Establish that the response is the type that we expect. @@ -16650,6 +16717,7 @@ def test_delete_capacity_commitment_rest_interceptors(null_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 = reservation.DeleteCapacityCommitmentRequest() metadata = [ @@ -16694,6 +16762,7 @@ def test_update_capacity_commitment_rest_bad_request( response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.update_capacity_commitment(request) @@ -16831,6 +16900,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.update_capacity_commitment(request) # Establish that the response is the type that we expect. @@ -16878,6 +16948,7 @@ def test_update_capacity_commitment_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = reservation.CapacityCommitment.to_json( reservation.CapacityCommitment() ) @@ -16926,6 +16997,7 @@ def test_split_capacity_commitment_rest_bad_request( response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.split_capacity_commitment(request) @@ -16961,6 +17033,7 @@ def test_split_capacity_commitment_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.split_capacity_commitment(request) # Establish that the response is the type that we expect. @@ -17000,6 +17073,7 @@ def test_split_capacity_commitment_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = reservation.SplitCapacityCommitmentResponse.to_json( reservation.SplitCapacityCommitmentResponse() ) @@ -17046,6 +17120,7 @@ def test_merge_capacity_commitments_rest_bad_request( response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.merge_capacity_commitments(request) @@ -17088,6 +17163,7 @@ def test_merge_capacity_commitments_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.merge_capacity_commitments(request) # Establish that the response is the type that we expect. @@ -17135,6 +17211,7 @@ def test_merge_capacity_commitments_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = reservation.CapacityCommitment.to_json( reservation.CapacityCommitment() ) @@ -17181,6 +17258,7 @@ def test_create_assignment_rest_bad_request( response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.create_assignment(request) @@ -17292,6 +17370,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.create_assignment(request) # Establish that the response is the type that we expect. @@ -17335,6 +17414,7 @@ def test_create_assignment_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = reservation.Assignment.to_json(reservation.Assignment()) req.return_value.content = return_value @@ -17379,6 +17459,7 @@ def test_list_assignments_rest_bad_request( response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.list_assignments(request) @@ -17414,6 +17495,7 @@ def test_list_assignments_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.list_assignments(request) # Establish that the response is the type that we expect. @@ -17454,6 +17536,7 @@ def test_list_assignments_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = reservation.ListAssignmentsResponse.to_json( reservation.ListAssignmentsResponse() ) @@ -17502,6 +17585,7 @@ def test_delete_assignment_rest_bad_request( response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.delete_assignment(request) @@ -17534,6 +17618,7 @@ def test_delete_assignment_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_assignment(request) # Establish that the response is the type that we expect. @@ -17570,6 +17655,7 @@ def test_delete_assignment_rest_interceptors(null_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 = reservation.DeleteAssignmentRequest() metadata = [ @@ -17610,6 +17696,7 @@ def test_search_assignments_rest_bad_request( response_value.status_code = 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_assignments(request) @@ -17645,6 +17732,7 @@ def test_search_assignments_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_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_assignments(request) # Establish that the response is the type that we expect. @@ -17685,6 +17773,7 @@ def test_search_assignments_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = reservation.SearchAssignmentsResponse.to_json( reservation.SearchAssignmentsResponse() ) @@ -17731,6 +17820,7 @@ def test_search_all_assignments_rest_bad_request( response_value.status_code = 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_assignments(request) @@ -17766,6 +17856,7 @@ def test_search_all_assignments_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_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_assignments(request) # Establish that the response is the type that we expect. @@ -17806,6 +17897,7 @@ def test_search_all_assignments_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = reservation.SearchAllAssignmentsResponse.to_json( reservation.SearchAllAssignmentsResponse() ) @@ -17854,6 +17946,7 @@ def test_move_assignment_rest_bad_request( response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.move_assignment(request) @@ -17894,6 +17987,7 @@ def test_move_assignment_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.move_assignment(request) # Establish that the response is the type that we expect. @@ -17937,6 +18031,7 @@ def test_move_assignment_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = reservation.Assignment.to_json(reservation.Assignment()) req.return_value.content = return_value @@ -17985,6 +18080,7 @@ def test_update_assignment_rest_bad_request( response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.update_assignment(request) @@ -18100,6 +18196,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.update_assignment(request) # Establish that the response is the type that we expect. @@ -18143,6 +18240,7 @@ def test_update_assignment_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = reservation.Assignment.to_json(reservation.Assignment()) req.return_value.content = return_value @@ -18187,6 +18285,7 @@ def test_get_bi_reservation_rest_bad_request( response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.get_bi_reservation(request) @@ -18223,6 +18322,7 @@ def test_get_bi_reservation_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.get_bi_reservation(request) # Establish that the response is the type that we expect. @@ -18264,6 +18364,7 @@ def test_get_bi_reservation_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = reservation.BiReservation.to_json(reservation.BiReservation()) req.return_value.content = return_value @@ -18310,6 +18411,7 @@ def test_update_bi_reservation_rest_bad_request( response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.update_bi_reservation(request) @@ -18427,6 +18529,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.update_bi_reservation(request) # Establish that the response is the type that we expect. @@ -18468,6 +18571,7 @@ def test_update_bi_reservation_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = reservation.BiReservation.to_json(reservation.BiReservation()) req.return_value.content = return_value diff --git a/packages/google-cloud-billing-budgets/google/cloud/billing/budgets/gapic_version.py b/packages/google-cloud-billing-budgets/google/cloud/billing/budgets/gapic_version.py index 2fd2bb1630b4..558c8aab67c5 100644 --- a/packages/google-cloud-billing-budgets/google/cloud/billing/budgets/gapic_version.py +++ b/packages/google-cloud-billing-budgets/google/cloud/billing/budgets/gapic_version.py @@ -13,4 +13,4 @@ # See the License for the specific language governing permissions and # limitations under the License. # -__version__ = "1.15.1" # {x-release-please-version} +__version__ = "0.0.0" # {x-release-please-version} diff --git a/packages/google-cloud-billing-budgets/google/cloud/billing/budgets_v1/gapic_version.py b/packages/google-cloud-billing-budgets/google/cloud/billing/budgets_v1/gapic_version.py index 2fd2bb1630b4..558c8aab67c5 100644 --- a/packages/google-cloud-billing-budgets/google/cloud/billing/budgets_v1/gapic_version.py +++ b/packages/google-cloud-billing-budgets/google/cloud/billing/budgets_v1/gapic_version.py @@ -13,4 +13,4 @@ # See the License for the specific language governing permissions and # limitations under the License. # -__version__ = "1.15.1" # {x-release-please-version} +__version__ = "0.0.0" # {x-release-please-version} diff --git a/packages/google-cloud-billing-budgets/google/cloud/billing/budgets_v1/services/budget_service/async_client.py b/packages/google-cloud-billing-budgets/google/cloud/billing/budgets_v1/services/budget_service/async_client.py index ecb32d617b1e..920480517190 100644 --- a/packages/google-cloud-billing-budgets/google/cloud/billing/budgets_v1/services/budget_service/async_client.py +++ b/packages/google-cloud-billing-budgets/google/cloud/billing/budgets_v1/services/budget_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, BudgetServiceTransport from .transports.grpc_asyncio import BudgetServiceGrpcAsyncIOTransport +try: + from google.api_core import client_logging # type: ignore + + CLIENT_LOGGING_SUPPORTED = True # pragma: NO COVER +except ImportError: # pragma: NO COVER + CLIENT_LOGGING_SUPPORTED = False + +_LOGGER = std_logging.getLogger(__name__) + class BudgetServiceAsyncClient: """BudgetService stores Cloud Billing budgets, which define a @@ -259,6 +269,28 @@ def __init__( client_info=client_info, ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + std_logging.DEBUG + ): # pragma: NO COVER + _LOGGER.debug( + "Created client `google.cloud.billing.budgets_v1.BudgetServiceAsyncClient`.", + extra={ + "serviceName": "google.cloud.billing.budgets.v1.BudgetService", + "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.billing.budgets.v1.BudgetService", + "credentialsType": None, + }, + ) + async def create_budget( self, request: Optional[Union[budget_service.CreateBudgetRequest, dict]] = None, @@ -267,7 +299,7 @@ async def create_budget( budget: Optional[budget_model.Budget] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> budget_model.Budget: r"""Creates a new budget. See `Quotas and limits `__ for more @@ -319,8 +351,10 @@ async def sample_create_budget(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.billing.budgets_v1.types.Budget: @@ -391,7 +425,7 @@ async def update_budget( update_mask: Optional[field_mask_pb2.FieldMask] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> budget_model.Budget: r"""Updates a budget and returns the updated budget. @@ -450,8 +484,10 @@ async def sample_update_budget(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.billing.budgets_v1.types.Budget: @@ -523,7 +559,7 @@ async def get_budget( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> budget_model.Budget: r"""Returns a budget. @@ -572,8 +608,10 @@ async def sample_get_budget(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.billing.budgets_v1.types.Budget: @@ -641,7 +679,7 @@ async def list_budgets( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListBudgetsAsyncPager: r"""Returns a list of budgets for a billing account. @@ -692,8 +730,10 @@ async def sample_list_budgets(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.billing.budgets_v1.services.budget_service.pagers.ListBudgetsAsyncPager: @@ -768,7 +808,7 @@ async def delete_budget( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.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 budget. Returns successfully if already deleted. @@ -810,8 +850,10 @@ async def sample_delete_budget(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. """ # Create or coerce a protobuf request object. # - Quick check: If we got a request object, we should *not* have diff --git a/packages/google-cloud-billing-budgets/google/cloud/billing/budgets_v1/services/budget_service/client.py b/packages/google-cloud-billing-budgets/google/cloud/billing/budgets_v1/services/budget_service/client.py index a87f5383108a..31004c0485da 100644 --- a/packages/google-cloud-billing-budgets/google/cloud/billing/budgets_v1/services/budget_service/client.py +++ b/packages/google-cloud-billing-budgets/google/cloud/billing/budgets_v1/services/budget_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.cloud.billing.budgets_v1.services.budget_service import pagers @@ -578,6 +588,10 @@ def __init__( # Initialize the universe domain validation. self._is_universe_domain_valid = False + if CLIENT_LOGGING_SUPPORTED: # pragma: NO COVER + # Setup logging. + client_logging.initialize_logging() + api_key_value = getattr(self._client_options, "api_key", None) if api_key_value and credentials: raise ValueError( @@ -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.billing.budgets_v1.BudgetServiceClient`.", + extra={ + "serviceName": "google.cloud.billing.budgets.v1.BudgetService", + "universeDomain": getattr( + self._transport._credentials, "universe_domain", "" + ), + "credentialsType": f"{type(self._transport._credentials).__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.billing.budgets.v1.BudgetService", + "credentialsType": None, + }, + ) + def create_budget( self, request: Optional[Union[budget_service.CreateBudgetRequest, dict]] = None, @@ -651,7 +688,7 @@ def create_budget( budget: Optional[budget_model.Budget] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> budget_model.Budget: r"""Creates a new budget. See `Quotas and limits `__ for more @@ -703,8 +740,10 @@ def sample_create_budget(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.billing.budgets_v1.types.Budget: @@ -772,7 +811,7 @@ def update_budget( update_mask: Optional[field_mask_pb2.FieldMask] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> budget_model.Budget: r"""Updates a budget and returns the updated budget. @@ -831,8 +870,10 @@ def sample_update_budget(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.billing.budgets_v1.types.Budget: @@ -901,7 +942,7 @@ def get_budget( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> budget_model.Budget: r"""Returns a budget. @@ -950,8 +991,10 @@ def sample_get_budget(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.billing.budgets_v1.types.Budget: @@ -1016,7 +1059,7 @@ def list_budgets( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListBudgetsPager: r"""Returns a list of budgets for a billing account. @@ -1067,8 +1110,10 @@ def sample_list_budgets(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.billing.budgets_v1.services.budget_service.pagers.ListBudgetsPager: @@ -1140,7 +1185,7 @@ def delete_budget( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.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 budget. Returns successfully if already deleted. @@ -1182,8 +1227,10 @@ def sample_delete_budget(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. """ # Create or coerce a protobuf request object. # - Quick check: If we got a request object, we should *not* have diff --git a/packages/google-cloud-billing-budgets/google/cloud/billing/budgets_v1/services/budget_service/pagers.py b/packages/google-cloud-billing-budgets/google/cloud/billing/budgets_v1/services/budget_service/pagers.py index a056f9e12627..c6a4653d154d 100644 --- a/packages/google-cloud-billing-budgets/google/cloud/billing/budgets_v1/services/budget_service/pagers.py +++ b/packages/google-cloud-billing-budgets/google/cloud/billing/budgets_v1/services/budget_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 = budget_service.ListBudgetsRequest(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 = budget_service.ListBudgetsRequest(request) diff --git a/packages/google-cloud-billing-budgets/google/cloud/billing/budgets_v1/services/budget_service/transports/grpc.py b/packages/google-cloud-billing-budgets/google/cloud/billing/budgets_v1/services/budget_service/transports/grpc.py index 1a3a50d39a95..0cda9b9c87db 100644 --- a/packages/google-cloud-billing-budgets/google/cloud/billing/budgets_v1/services/budget_service/transports/grpc.py +++ b/packages/google-cloud-billing-budgets/google/cloud/billing/budgets_v1/services/budget_service/transports/grpc.py @@ -13,6 +13,9 @@ # See the License for the specific language governing permissions and # limitations under the License. # +import json +import logging as std_logging +import pickle from typing import Callable, Dict, Optional, Sequence, Tuple, Union import warnings @@ -21,12 +24,90 @@ from google.auth import credentials as ga_credentials # type: ignore from google.auth.transport.grpc import SslCredentials # type: ignore from google.protobuf import empty_pb2 # type: ignore +from google.protobuf.json_format import MessageToJson +import google.protobuf.message import grpc # type: ignore +import proto # type: ignore from google.cloud.billing.budgets_v1.types import budget_model, budget_service from .base import DEFAULT_CLIENT_INFO, BudgetServiceTransport +try: + from google.api_core import client_logging # 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.billing.budgets.v1.BudgetService", + "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.billing.budgets.v1.BudgetService", + "rpcName": client_call_details.method, + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class BudgetServiceGrpcTransport(BudgetServiceTransport): """gRPC backend transport for BudgetService. @@ -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 create_budget( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_budget" not in self._stubs: - self._stubs["create_budget"] = self.grpc_channel.unary_unary( + self._stubs["create_budget"] = self._logged_channel.unary_unary( "/google.cloud.billing.budgets.v1.BudgetService/CreateBudget", request_serializer=budget_service.CreateBudgetRequest.serialize, response_deserializer=budget_model.Budget.deserialize, @@ -290,7 +376,7 @@ def update_budget( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_budget" not in self._stubs: - self._stubs["update_budget"] = self.grpc_channel.unary_unary( + self._stubs["update_budget"] = self._logged_channel.unary_unary( "/google.cloud.billing.budgets.v1.BudgetService/UpdateBudget", request_serializer=budget_service.UpdateBudgetRequest.serialize, response_deserializer=budget_model.Budget.deserialize, @@ -322,7 +408,7 @@ def get_budget( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_budget" not in self._stubs: - self._stubs["get_budget"] = self.grpc_channel.unary_unary( + self._stubs["get_budget"] = self._logged_channel.unary_unary( "/google.cloud.billing.budgets.v1.BudgetService/GetBudget", request_serializer=budget_service.GetBudgetRequest.serialize, response_deserializer=budget_model.Budget.deserialize, @@ -356,7 +442,7 @@ def list_budgets( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_budgets" not in self._stubs: - self._stubs["list_budgets"] = self.grpc_channel.unary_unary( + self._stubs["list_budgets"] = self._logged_channel.unary_unary( "/google.cloud.billing.budgets.v1.BudgetService/ListBudgets", request_serializer=budget_service.ListBudgetsRequest.serialize, response_deserializer=budget_service.ListBudgetsResponse.deserialize, @@ -383,7 +469,7 @@ def delete_budget( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_budget" not in self._stubs: - self._stubs["delete_budget"] = self.grpc_channel.unary_unary( + self._stubs["delete_budget"] = self._logged_channel.unary_unary( "/google.cloud.billing.budgets.v1.BudgetService/DeleteBudget", request_serializer=budget_service.DeleteBudgetRequest.serialize, response_deserializer=empty_pb2.Empty.FromString, @@ -391,7 +477,7 @@ def delete_budget( return self._stubs["delete_budget"] def close(self): - self.grpc_channel.close() + self._logged_channel.close() @property def kind(self) -> str: diff --git a/packages/google-cloud-billing-budgets/google/cloud/billing/budgets_v1/services/budget_service/transports/grpc_asyncio.py b/packages/google-cloud-billing-budgets/google/cloud/billing/budgets_v1/services/budget_service/transports/grpc_asyncio.py index 7f1068f8e6f0..e7be3f1b81f2 100644 --- a/packages/google-cloud-billing-budgets/google/cloud/billing/budgets_v1/services/budget_service/transports/grpc_asyncio.py +++ b/packages/google-cloud-billing-budgets/google/cloud/billing/budgets_v1/services/budget_service/transports/grpc_asyncio.py @@ -14,6 +14,9 @@ # limitations under the License. # import inspect +import json +import logging as std_logging +import pickle from typing import Awaitable, Callable, Dict, Optional, Sequence, Tuple, Union import warnings @@ -23,14 +26,93 @@ from google.auth import credentials as ga_credentials # type: ignore from google.auth.transport.grpc import SslCredentials # type: ignore from google.protobuf import empty_pb2 # type: ignore +from google.protobuf.json_format import MessageToJson +import google.protobuf.message import grpc # type: ignore from grpc.experimental import aio # type: ignore +import proto # type: ignore from google.cloud.billing.budgets_v1.types import budget_model, budget_service from .base import DEFAULT_CLIENT_INFO, BudgetServiceTransport from .grpc import BudgetServiceGrpcTransport +try: + from google.api_core import client_logging # 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.billing.budgets.v1.BudgetService", + "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.billing.budgets.v1.BudgetService", + "rpcName": str(client_call_details.method), + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class BudgetServiceGrpcAsyncIOTransport(BudgetServiceTransport): """gRPC AsyncIO backend transport for BudgetService. @@ -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 create_budget( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_budget" not in self._stubs: - self._stubs["create_budget"] = self.grpc_channel.unary_unary( + self._stubs["create_budget"] = self._logged_channel.unary_unary( "/google.cloud.billing.budgets.v1.BudgetService/CreateBudget", request_serializer=budget_service.CreateBudgetRequest.serialize, response_deserializer=budget_model.Budget.deserialize, @@ -298,7 +383,7 @@ def update_budget( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_budget" not in self._stubs: - self._stubs["update_budget"] = self.grpc_channel.unary_unary( + self._stubs["update_budget"] = self._logged_channel.unary_unary( "/google.cloud.billing.budgets.v1.BudgetService/UpdateBudget", request_serializer=budget_service.UpdateBudgetRequest.serialize, response_deserializer=budget_model.Budget.deserialize, @@ -330,7 +415,7 @@ def get_budget( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_budget" not in self._stubs: - self._stubs["get_budget"] = self.grpc_channel.unary_unary( + self._stubs["get_budget"] = self._logged_channel.unary_unary( "/google.cloud.billing.budgets.v1.BudgetService/GetBudget", request_serializer=budget_service.GetBudgetRequest.serialize, response_deserializer=budget_model.Budget.deserialize, @@ -365,7 +450,7 @@ def list_budgets( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_budgets" not in self._stubs: - self._stubs["list_budgets"] = self.grpc_channel.unary_unary( + self._stubs["list_budgets"] = self._logged_channel.unary_unary( "/google.cloud.billing.budgets.v1.BudgetService/ListBudgets", request_serializer=budget_service.ListBudgetsRequest.serialize, response_deserializer=budget_service.ListBudgetsResponse.deserialize, @@ -392,7 +477,7 @@ def delete_budget( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_budget" not in self._stubs: - self._stubs["delete_budget"] = self.grpc_channel.unary_unary( + self._stubs["delete_budget"] = self._logged_channel.unary_unary( "/google.cloud.billing.budgets.v1.BudgetService/DeleteBudget", request_serializer=budget_service.DeleteBudgetRequest.serialize, response_deserializer=empty_pb2.Empty.FromString, @@ -475,7 +560,7 @@ def _wrap_method(self, func, *args, **kwargs): return gapic_v1.method_async.wrap_method(func, *args, **kwargs) def close(self): - return self.grpc_channel.close() + return self._logged_channel.close() @property def kind(self) -> str: diff --git a/packages/google-cloud-billing-budgets/google/cloud/billing/budgets_v1/services/budget_service/transports/rest.py b/packages/google-cloud-billing-budgets/google/cloud/billing/budgets_v1/services/budget_service/transports/rest.py index ddcf6e0c2122..890821cd16a1 100644 --- a/packages/google-cloud-billing-budgets/google/cloud/billing/budgets_v1/services/budget_service/transports/rest.py +++ b/packages/google-cloud-billing-budgets/google/cloud/billing/budgets_v1/services/budget_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, @@ -106,8 +114,10 @@ def post_update_budget(self, response): def pre_create_budget( self, request: budget_service.CreateBudgetRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[budget_service.CreateBudgetRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + budget_service.CreateBudgetRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for create_budget Override in a subclass to manipulate the request or metadata @@ -127,8 +137,10 @@ def post_create_budget(self, response: budget_model.Budget) -> budget_model.Budg def pre_delete_budget( self, request: budget_service.DeleteBudgetRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[budget_service.DeleteBudgetRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + budget_service.DeleteBudgetRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for delete_budget Override in a subclass to manipulate the request or metadata @@ -139,8 +151,10 @@ def pre_delete_budget( def pre_get_budget( self, request: budget_service.GetBudgetRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[budget_service.GetBudgetRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + budget_service.GetBudgetRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for get_budget Override in a subclass to manipulate the request or metadata @@ -160,8 +174,10 @@ def post_get_budget(self, response: budget_model.Budget) -> budget_model.Budget: def pre_list_budgets( self, request: budget_service.ListBudgetsRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[budget_service.ListBudgetsRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + budget_service.ListBudgetsRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for list_budgets Override in a subclass to manipulate the request or metadata @@ -183,8 +199,10 @@ def post_list_budgets( def pre_update_budget( self, request: budget_service.UpdateBudgetRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[budget_service.UpdateBudgetRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + budget_service.UpdateBudgetRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for update_budget Override in a subclass to manipulate the request or metadata @@ -325,7 +343,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> budget_model.Budget: r"""Call the create budget method over HTTP. @@ -335,8 +353,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.budget_model.Budget: @@ -355,6 +375,7 @@ def __call__( http_options = ( _BaseBudgetServiceRestTransport._BaseCreateBudget._get_http_options() ) + request, metadata = self._interceptor.pre_create_budget(request, metadata) transcoded_request = _BaseBudgetServiceRestTransport._BaseCreateBudget._get_transcoded_request( http_options, request @@ -369,6 +390,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.billing.budgets_v1.BudgetServiceClient.CreateBudget", + extra={ + "serviceName": "google.cloud.billing.budgets.v1.BudgetService", + "rpcName": "CreateBudget", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = BudgetServiceRestTransport._CreateBudget._get_response( self._host, @@ -390,7 +438,29 @@ def __call__( pb_resp = budget_model.Budget.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_create_budget(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = budget_model.Budget.to_json(response) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.billing.budgets_v1.BudgetServiceClient.create_budget", + extra={ + "serviceName": "google.cloud.billing.budgets.v1.BudgetService", + "rpcName": "CreateBudget", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _DeleteBudget( @@ -427,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]]] = (), ): r"""Call the delete budget method over HTTP. @@ -437,13 +507,16 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. """ http_options = ( _BaseBudgetServiceRestTransport._BaseDeleteBudget._get_http_options() ) + request, metadata = self._interceptor.pre_delete_budget(request, metadata) transcoded_request = _BaseBudgetServiceRestTransport._BaseDeleteBudget._get_transcoded_request( http_options, request @@ -454,6 +527,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.billing.budgets_v1.BudgetServiceClient.DeleteBudget", + extra={ + "serviceName": "google.cloud.billing.budgets.v1.BudgetService", + "rpcName": "DeleteBudget", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = BudgetServiceRestTransport._DeleteBudget._get_response( self._host, @@ -503,7 +603,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> budget_model.Budget: r"""Call the get budget method over HTTP. @@ -513,8 +613,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.budget_model.Budget: @@ -533,6 +635,7 @@ def __call__( http_options = ( _BaseBudgetServiceRestTransport._BaseGetBudget._get_http_options() ) + request, metadata = self._interceptor.pre_get_budget(request, metadata) transcoded_request = ( _BaseBudgetServiceRestTransport._BaseGetBudget._get_transcoded_request( @@ -547,6 +650,33 @@ def __call__( ) ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.billing.budgets_v1.BudgetServiceClient.GetBudget", + extra={ + "serviceName": "google.cloud.billing.budgets.v1.BudgetService", + "rpcName": "GetBudget", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = BudgetServiceRestTransport._GetBudget._get_response( self._host, @@ -567,7 +697,29 @@ def __call__( pb_resp = budget_model.Budget.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_budget(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = budget_model.Budget.to_json(response) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.billing.budgets_v1.BudgetServiceClient.get_budget", + extra={ + "serviceName": "google.cloud.billing.budgets.v1.BudgetService", + "rpcName": "GetBudget", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ListBudgets( @@ -604,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]]] = (), ) -> budget_service.ListBudgetsResponse: r"""Call the list budgets method over HTTP. @@ -614,8 +766,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.budget_service.ListBudgetsResponse: @@ -625,6 +779,7 @@ def __call__( http_options = ( _BaseBudgetServiceRestTransport._BaseListBudgets._get_http_options() ) + request, metadata = self._interceptor.pre_list_budgets(request, metadata) transcoded_request = _BaseBudgetServiceRestTransport._BaseListBudgets._get_transcoded_request( http_options, request @@ -637,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.cloud.billing.budgets_v1.BudgetServiceClient.ListBudgets", + extra={ + "serviceName": "google.cloud.billing.budgets.v1.BudgetService", + "rpcName": "ListBudgets", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = BudgetServiceRestTransport._ListBudgets._get_response( self._host, @@ -657,7 +839,31 @@ def __call__( pb_resp = budget_service.ListBudgetsResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_budgets(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = budget_service.ListBudgetsResponse.to_json( + response + ) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.billing.budgets_v1.BudgetServiceClient.list_budgets", + extra={ + "serviceName": "google.cloud.billing.budgets.v1.BudgetService", + "rpcName": "ListBudgets", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _UpdateBudget( @@ -695,7 +901,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> budget_model.Budget: r"""Call the update budget method over HTTP. @@ -705,8 +911,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.budget_model.Budget: @@ -725,6 +933,7 @@ def __call__( http_options = ( _BaseBudgetServiceRestTransport._BaseUpdateBudget._get_http_options() ) + request, metadata = self._interceptor.pre_update_budget(request, metadata) transcoded_request = _BaseBudgetServiceRestTransport._BaseUpdateBudget._get_transcoded_request( http_options, request @@ -739,6 +948,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.billing.budgets_v1.BudgetServiceClient.UpdateBudget", + extra={ + "serviceName": "google.cloud.billing.budgets.v1.BudgetService", + "rpcName": "UpdateBudget", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = BudgetServiceRestTransport._UpdateBudget._get_response( self._host, @@ -760,7 +996,29 @@ def __call__( pb_resp = budget_model.Budget.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_update_budget(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = budget_model.Budget.to_json(response) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.billing.budgets_v1.BudgetServiceClient.update_budget", + extra={ + "serviceName": "google.cloud.billing.budgets.v1.BudgetService", + "rpcName": "UpdateBudget", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp @property diff --git a/packages/google-cloud-billing-budgets/google/cloud/billing/budgets_v1beta1/gapic_version.py b/packages/google-cloud-billing-budgets/google/cloud/billing/budgets_v1beta1/gapic_version.py index 2fd2bb1630b4..558c8aab67c5 100644 --- a/packages/google-cloud-billing-budgets/google/cloud/billing/budgets_v1beta1/gapic_version.py +++ b/packages/google-cloud-billing-budgets/google/cloud/billing/budgets_v1beta1/gapic_version.py @@ -13,4 +13,4 @@ # See the License for the specific language governing permissions and # limitations under the License. # -__version__ = "1.15.1" # {x-release-please-version} +__version__ = "0.0.0" # {x-release-please-version} diff --git a/packages/google-cloud-billing-budgets/google/cloud/billing/budgets_v1beta1/services/budget_service/async_client.py b/packages/google-cloud-billing-budgets/google/cloud/billing/budgets_v1beta1/services/budget_service/async_client.py index 0c14a2ea58ce..4bbc84da6dc5 100644 --- a/packages/google-cloud-billing-budgets/google/cloud/billing/budgets_v1beta1/services/budget_service/async_client.py +++ b/packages/google-cloud-billing-budgets/google/cloud/billing/budgets_v1beta1/services/budget_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, BudgetServiceTransport from .transports.grpc_asyncio import BudgetServiceGrpcAsyncIOTransport +try: + from google.api_core import client_logging # type: ignore + + CLIENT_LOGGING_SUPPORTED = True # pragma: NO COVER +except ImportError: # pragma: NO COVER + CLIENT_LOGGING_SUPPORTED = False + +_LOGGER = std_logging.getLogger(__name__) + class BudgetServiceAsyncClient: """BudgetService stores Cloud Billing budgets, which define a @@ -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.cloud.billing.budgets_v1beta1.BudgetServiceAsyncClient`.", + extra={ + "serviceName": "google.cloud.billing.budgets.v1beta1.BudgetService", + "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.billing.budgets.v1beta1.BudgetService", + "credentialsType": None, + }, + ) + async def create_budget( self, request: Optional[Union[budget_service.CreateBudgetRequest, 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]]] = (), ) -> budget_model.Budget: r"""Creates a new budget. See `Quotas and limits `__ for more @@ -302,8 +334,10 @@ async def sample_create_budget(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.billing.budgets_v1beta1.types.Budget: @@ -356,7 +390,7 @@ async def update_budget( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> budget_model.Budget: r"""Updates a budget and returns the updated budget. @@ -396,8 +430,10 @@ async def sample_update_budget(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.billing.budgets_v1beta1.types.Budget: @@ -452,7 +488,7 @@ async def get_budget( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> budget_model.Budget: r"""Returns a budget. @@ -494,8 +530,10 @@ async def sample_get_budget(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.billing.budgets_v1beta1.types.Budget: @@ -548,7 +586,7 @@ async def list_budgets( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListBudgetsAsyncPager: r"""Returns a list of budgets for a billing account. @@ -591,8 +629,10 @@ async def sample_list_budgets(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.billing.budgets_v1beta1.services.budget_service.pagers.ListBudgetsAsyncPager: @@ -652,7 +692,7 @@ async def delete_budget( *, retry: OptionalRetry = gapic_v1.method.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 budget. Returns successfully if already deleted. @@ -686,8 +726,10 @@ async def sample_delete_budget(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + 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-billing-budgets/google/cloud/billing/budgets_v1beta1/services/budget_service/client.py b/packages/google-cloud-billing-budgets/google/cloud/billing/budgets_v1beta1/services/budget_service/client.py index 40d7aa259418..0513d45e3a6d 100644 --- a/packages/google-cloud-billing-budgets/google/cloud/billing/budgets_v1beta1/services/budget_service/client.py +++ b/packages/google-cloud-billing-budgets/google/cloud/billing/budgets_v1beta1/services/budget_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.billing.budgets_v1beta1.services.budget_service import pagers from google.cloud.billing.budgets_v1beta1.types import budget_model, budget_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( @@ -639,13 +653,36 @@ def __init__( api_audience=self._client_options.api_audience, ) + if "async" not in str(self._transport): + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + std_logging.DEBUG + ): # pragma: NO COVER + _LOGGER.debug( + "Created client `google.cloud.billing.budgets_v1beta1.BudgetServiceClient`.", + extra={ + "serviceName": "google.cloud.billing.budgets.v1beta1.BudgetService", + "universeDomain": getattr( + self._transport._credentials, "universe_domain", "" + ), + "credentialsType": f"{type(self._transport._credentials).__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.billing.budgets.v1beta1.BudgetService", + "credentialsType": None, + }, + ) + def create_budget( self, request: Optional[Union[budget_service.CreateBudgetRequest, 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]]] = (), ) -> budget_model.Budget: r"""Creates a new budget. See `Quotas and limits `__ for more @@ -684,8 +721,10 @@ def sample_create_budget(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.billing.budgets_v1beta1.types.Budget: @@ -736,7 +775,7 @@ def update_budget( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> budget_model.Budget: r"""Updates a budget and returns the updated budget. @@ -776,8 +815,10 @@ def sample_update_budget(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.billing.budgets_v1beta1.types.Budget: @@ -830,7 +871,7 @@ def get_budget( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> budget_model.Budget: r"""Returns a budget. @@ -872,8 +913,10 @@ def sample_get_budget(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.billing.budgets_v1beta1.types.Budget: @@ -924,7 +967,7 @@ def list_budgets( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListBudgetsPager: r"""Returns a list of budgets for a billing account. @@ -967,8 +1010,10 @@ def sample_list_budgets(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.billing.budgets_v1beta1.services.budget_service.pagers.ListBudgetsPager: @@ -1026,7 +1071,7 @@ def delete_budget( *, retry: OptionalRetry = gapic_v1.method.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 budget. Returns successfully if already deleted. @@ -1060,8 +1105,10 @@ def sample_delete_budget(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + 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-billing-budgets/google/cloud/billing/budgets_v1beta1/services/budget_service/pagers.py b/packages/google-cloud-billing-budgets/google/cloud/billing/budgets_v1beta1/services/budget_service/pagers.py index a40714c42ff6..290e46489187 100644 --- a/packages/google-cloud-billing-budgets/google/cloud/billing/budgets_v1beta1/services/budget_service/pagers.py +++ b/packages/google-cloud-billing-budgets/google/cloud/billing/budgets_v1beta1/services/budget_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 = budget_service.ListBudgetsRequest(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 = budget_service.ListBudgetsRequest(request) diff --git a/packages/google-cloud-billing-budgets/google/cloud/billing/budgets_v1beta1/services/budget_service/transports/grpc.py b/packages/google-cloud-billing-budgets/google/cloud/billing/budgets_v1beta1/services/budget_service/transports/grpc.py index 2f6433093b9d..73a46cb0f0d5 100644 --- a/packages/google-cloud-billing-budgets/google/cloud/billing/budgets_v1beta1/services/budget_service/transports/grpc.py +++ b/packages/google-cloud-billing-budgets/google/cloud/billing/budgets_v1beta1/services/budget_service/transports/grpc.py @@ -13,6 +13,9 @@ # See the License for the specific language governing permissions and # limitations under the License. # +import json +import logging as std_logging +import pickle from typing import Callable, Dict, Optional, Sequence, Tuple, Union import warnings @@ -21,12 +24,90 @@ from google.auth import credentials as ga_credentials # type: ignore from google.auth.transport.grpc import SslCredentials # type: ignore from google.protobuf import empty_pb2 # type: ignore +from google.protobuf.json_format import MessageToJson +import google.protobuf.message import grpc # type: ignore +import proto # type: ignore from google.cloud.billing.budgets_v1beta1.types import budget_model, budget_service from .base import DEFAULT_CLIENT_INFO, BudgetServiceTransport +try: + from google.api_core import client_logging # 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.billing.budgets.v1beta1.BudgetService", + "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.billing.budgets.v1beta1.BudgetService", + "rpcName": client_call_details.method, + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class BudgetServiceGrpcTransport(BudgetServiceTransport): """gRPC backend transport for BudgetService. @@ -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 create_budget( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_budget" not in self._stubs: - self._stubs["create_budget"] = self.grpc_channel.unary_unary( + self._stubs["create_budget"] = self._logged_channel.unary_unary( "/google.cloud.billing.budgets.v1beta1.BudgetService/CreateBudget", request_serializer=budget_service.CreateBudgetRequest.serialize, response_deserializer=budget_model.Budget.deserialize, @@ -290,7 +376,7 @@ def update_budget( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_budget" not in self._stubs: - self._stubs["update_budget"] = self.grpc_channel.unary_unary( + self._stubs["update_budget"] = self._logged_channel.unary_unary( "/google.cloud.billing.budgets.v1beta1.BudgetService/UpdateBudget", request_serializer=budget_service.UpdateBudgetRequest.serialize, response_deserializer=budget_model.Budget.deserialize, @@ -322,7 +408,7 @@ def get_budget( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_budget" not in self._stubs: - self._stubs["get_budget"] = self.grpc_channel.unary_unary( + self._stubs["get_budget"] = self._logged_channel.unary_unary( "/google.cloud.billing.budgets.v1beta1.BudgetService/GetBudget", request_serializer=budget_service.GetBudgetRequest.serialize, response_deserializer=budget_model.Budget.deserialize, @@ -356,7 +442,7 @@ def list_budgets( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_budgets" not in self._stubs: - self._stubs["list_budgets"] = self.grpc_channel.unary_unary( + self._stubs["list_budgets"] = self._logged_channel.unary_unary( "/google.cloud.billing.budgets.v1beta1.BudgetService/ListBudgets", request_serializer=budget_service.ListBudgetsRequest.serialize, response_deserializer=budget_service.ListBudgetsResponse.deserialize, @@ -383,7 +469,7 @@ def delete_budget( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_budget" not in self._stubs: - self._stubs["delete_budget"] = self.grpc_channel.unary_unary( + self._stubs["delete_budget"] = self._logged_channel.unary_unary( "/google.cloud.billing.budgets.v1beta1.BudgetService/DeleteBudget", request_serializer=budget_service.DeleteBudgetRequest.serialize, response_deserializer=empty_pb2.Empty.FromString, @@ -391,7 +477,7 @@ def delete_budget( return self._stubs["delete_budget"] def close(self): - self.grpc_channel.close() + self._logged_channel.close() @property def kind(self) -> str: diff --git a/packages/google-cloud-billing-budgets/google/cloud/billing/budgets_v1beta1/services/budget_service/transports/grpc_asyncio.py b/packages/google-cloud-billing-budgets/google/cloud/billing/budgets_v1beta1/services/budget_service/transports/grpc_asyncio.py index 32f099760240..a2f3b35591af 100644 --- a/packages/google-cloud-billing-budgets/google/cloud/billing/budgets_v1beta1/services/budget_service/transports/grpc_asyncio.py +++ b/packages/google-cloud-billing-budgets/google/cloud/billing/budgets_v1beta1/services/budget_service/transports/grpc_asyncio.py @@ -14,6 +14,9 @@ # limitations under the License. # import inspect +import json +import logging as std_logging +import pickle from typing import Awaitable, Callable, Dict, Optional, Sequence, Tuple, Union import warnings @@ -23,14 +26,93 @@ from google.auth import credentials as ga_credentials # type: ignore from google.auth.transport.grpc import SslCredentials # type: ignore from google.protobuf import empty_pb2 # type: ignore +from google.protobuf.json_format import MessageToJson +import google.protobuf.message import grpc # type: ignore from grpc.experimental import aio # type: ignore +import proto # type: ignore from google.cloud.billing.budgets_v1beta1.types import budget_model, budget_service from .base import DEFAULT_CLIENT_INFO, BudgetServiceTransport from .grpc import BudgetServiceGrpcTransport +try: + from google.api_core import client_logging # 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.billing.budgets.v1beta1.BudgetService", + "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.billing.budgets.v1beta1.BudgetService", + "rpcName": str(client_call_details.method), + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class BudgetServiceGrpcAsyncIOTransport(BudgetServiceTransport): """gRPC AsyncIO backend transport for BudgetService. @@ -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 create_budget( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_budget" not in self._stubs: - self._stubs["create_budget"] = self.grpc_channel.unary_unary( + self._stubs["create_budget"] = self._logged_channel.unary_unary( "/google.cloud.billing.budgets.v1beta1.BudgetService/CreateBudget", request_serializer=budget_service.CreateBudgetRequest.serialize, response_deserializer=budget_model.Budget.deserialize, @@ -298,7 +383,7 @@ def update_budget( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_budget" not in self._stubs: - self._stubs["update_budget"] = self.grpc_channel.unary_unary( + self._stubs["update_budget"] = self._logged_channel.unary_unary( "/google.cloud.billing.budgets.v1beta1.BudgetService/UpdateBudget", request_serializer=budget_service.UpdateBudgetRequest.serialize, response_deserializer=budget_model.Budget.deserialize, @@ -330,7 +415,7 @@ def get_budget( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_budget" not in self._stubs: - self._stubs["get_budget"] = self.grpc_channel.unary_unary( + self._stubs["get_budget"] = self._logged_channel.unary_unary( "/google.cloud.billing.budgets.v1beta1.BudgetService/GetBudget", request_serializer=budget_service.GetBudgetRequest.serialize, response_deserializer=budget_model.Budget.deserialize, @@ -365,7 +450,7 @@ def list_budgets( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_budgets" not in self._stubs: - self._stubs["list_budgets"] = self.grpc_channel.unary_unary( + self._stubs["list_budgets"] = self._logged_channel.unary_unary( "/google.cloud.billing.budgets.v1beta1.BudgetService/ListBudgets", request_serializer=budget_service.ListBudgetsRequest.serialize, response_deserializer=budget_service.ListBudgetsResponse.deserialize, @@ -392,7 +477,7 @@ def delete_budget( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_budget" not in self._stubs: - self._stubs["delete_budget"] = self.grpc_channel.unary_unary( + self._stubs["delete_budget"] = self._logged_channel.unary_unary( "/google.cloud.billing.budgets.v1beta1.BudgetService/DeleteBudget", request_serializer=budget_service.DeleteBudgetRequest.serialize, response_deserializer=empty_pb2.Empty.FromString, @@ -475,7 +560,7 @@ def _wrap_method(self, func, *args, **kwargs): return gapic_v1.method_async.wrap_method(func, *args, **kwargs) def close(self): - return self.grpc_channel.close() + return self._logged_channel.close() @property def kind(self) -> str: diff --git a/packages/google-cloud-billing-budgets/samples/generated_samples/snippet_metadata_google.cloud.billing.budgets.v1.json b/packages/google-cloud-billing-budgets/samples/generated_samples/snippet_metadata_google.cloud.billing.budgets.v1.json index c53756bde983..c24b57dc687a 100644 --- a/packages/google-cloud-billing-budgets/samples/generated_samples/snippet_metadata_google.cloud.billing.budgets.v1.json +++ b/packages/google-cloud-billing-budgets/samples/generated_samples/snippet_metadata_google.cloud.billing.budgets.v1.json @@ -8,7 +8,7 @@ ], "language": "PYTHON", "name": "google-cloud-billing-budgets", - "version": "1.15.1" + "version": "0.1.0" }, "snippets": [ { @@ -51,7 +51,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.billing.budgets_v1.types.Budget", @@ -135,7 +135,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.billing.budgets_v1.types.Budget", @@ -216,7 +216,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "shortName": "delete_budget" @@ -293,7 +293,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "shortName": "delete_budget" @@ -371,7 +371,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.billing.budgets_v1.types.Budget", @@ -451,7 +451,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.billing.budgets_v1.types.Budget", @@ -532,7 +532,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.billing.budgets_v1.services.budget_service.pagers.ListBudgetsAsyncPager", @@ -612,7 +612,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.billing.budgets_v1.services.budget_service.pagers.ListBudgetsPager", @@ -697,7 +697,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.billing.budgets_v1.types.Budget", @@ -781,7 +781,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.billing.budgets_v1.types.Budget", diff --git a/packages/google-cloud-billing-budgets/samples/generated_samples/snippet_metadata_google.cloud.billing.budgets.v1beta1.json b/packages/google-cloud-billing-budgets/samples/generated_samples/snippet_metadata_google.cloud.billing.budgets.v1beta1.json index a3d3721a6a97..2c44cd8f7269 100644 --- a/packages/google-cloud-billing-budgets/samples/generated_samples/snippet_metadata_google.cloud.billing.budgets.v1beta1.json +++ b/packages/google-cloud-billing-budgets/samples/generated_samples/snippet_metadata_google.cloud.billing.budgets.v1beta1.json @@ -8,7 +8,7 @@ ], "language": "PYTHON", "name": "google-cloud-billing-budgets", - "version": "1.15.1" + "version": "0.1.0" }, "snippets": [ { @@ -43,7 +43,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.billing.budgets_v1beta1.types.Budget", @@ -119,7 +119,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.billing.budgets_v1beta1.types.Budget", @@ -196,7 +196,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "shortName": "delete_budget" @@ -269,7 +269,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "shortName": "delete_budget" @@ -343,7 +343,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.billing.budgets_v1beta1.types.Budget", @@ -419,7 +419,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.billing.budgets_v1beta1.types.Budget", @@ -496,7 +496,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.billing.budgets_v1beta1.services.budget_service.pagers.ListBudgetsAsyncPager", @@ -572,7 +572,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.billing.budgets_v1beta1.services.budget_service.pagers.ListBudgetsPager", @@ -649,7 +649,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.billing.budgets_v1beta1.types.Budget", @@ -725,7 +725,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.billing.budgets_v1beta1.types.Budget", diff --git a/packages/google-cloud-billing-budgets/tests/unit/gapic/budgets_v1/test_budget_service.py b/packages/google-cloud-billing-budgets/tests/unit/gapic/budgets_v1/test_budget_service.py index 0e2ce042a50f..3ecaef5f9e5a 100644 --- a/packages/google-cloud-billing-budgets/tests/unit/gapic/budgets_v1/test_budget_service.py +++ b/packages/google-cloud-billing-budgets/tests/unit/gapic/budgets_v1/test_budget_service.py @@ -2993,6 +2993,7 @@ def test_create_budget_rest_required_fields( response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.create_budget(request) @@ -3047,6 +3048,7 @@ def test_create_budget_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.create_budget(**mock_args) @@ -3175,6 +3177,7 @@ def test_update_budget_rest_required_fields( response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.update_budget(request) @@ -3221,6 +3224,7 @@ def test_update_budget_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.update_budget(**mock_args) @@ -3350,6 +3354,7 @@ def test_get_budget_rest_required_fields(request_type=budget_service.GetBudgetRe response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.get_budget(request) @@ -3395,6 +3400,7 @@ def test_get_budget_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.get_budget(**mock_args) @@ -3532,6 +3538,7 @@ def test_list_budgets_rest_required_fields( response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.list_budgets(request) @@ -3586,6 +3593,7 @@ def test_list_budgets_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.list_budgets(**mock_args) @@ -3775,6 +3783,7 @@ def test_delete_budget_rest_required_fields( response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.delete_budget(request) @@ -3818,6 +3827,7 @@ def test_delete_budget_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_budget(**mock_args) @@ -4235,6 +4245,7 @@ def test_create_budget_rest_bad_request( response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.create_budget(request) @@ -4380,6 +4391,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.create_budget(request) # Establish that the response is the type that we expect. @@ -4422,6 +4434,7 @@ def test_create_budget_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = budget_model.Budget.to_json(budget_model.Budget()) req.return_value.content = return_value @@ -4466,6 +4479,7 @@ def test_update_budget_rest_bad_request( response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.update_budget(request) @@ -4611,6 +4625,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.update_budget(request) # Establish that the response is the type that we expect. @@ -4653,6 +4668,7 @@ def test_update_budget_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = budget_model.Budget.to_json(budget_model.Budget()) req.return_value.content = return_value @@ -4695,6 +4711,7 @@ def test_get_budget_rest_bad_request(request_type=budget_service.GetBudgetReques response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.get_budget(request) @@ -4732,6 +4749,7 @@ def test_get_budget_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.get_budget(request) # Establish that the response is the type that we expect. @@ -4774,6 +4792,7 @@ def test_get_budget_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = budget_model.Budget.to_json(budget_model.Budget()) req.return_value.content = return_value @@ -4816,6 +4835,7 @@ def test_list_budgets_rest_bad_request(request_type=budget_service.ListBudgetsRe response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.list_budgets(request) @@ -4851,6 +4871,7 @@ def test_list_budgets_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.list_budgets(request) # Establish that the response is the type that we expect. @@ -4891,6 +4912,7 @@ def test_list_budgets_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = budget_service.ListBudgetsResponse.to_json( budget_service.ListBudgetsResponse() ) @@ -4937,6 +4959,7 @@ def test_delete_budget_rest_bad_request( response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.delete_budget(request) @@ -4967,6 +4990,7 @@ def test_delete_budget_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_budget(request) # Establish that the response is the type that we expect. @@ -5003,6 +5027,7 @@ def test_delete_budget_rest_interceptors(null_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 = budget_service.DeleteBudgetRequest() metadata = [ diff --git a/packages/google-cloud-billing/google/cloud/billing_v1/services/cloud_billing/async_client.py b/packages/google-cloud-billing/google/cloud/billing_v1/services/cloud_billing/async_client.py index f31888507582..da11d77cdeeb 100644 --- a/packages/google-cloud-billing/google/cloud/billing_v1/services/cloud_billing/async_client.py +++ b/packages/google-cloud-billing/google/cloud/billing_v1/services/cloud_billing/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, CloudBillingTransport from .transports.grpc_asyncio import CloudBillingGrpcAsyncIOTransport +try: + from google.api_core import client_logging # type: ignore + + CLIENT_LOGGING_SUPPORTED = True # pragma: NO COVER +except ImportError: # pragma: NO COVER + CLIENT_LOGGING_SUPPORTED = False + +_LOGGER = std_logging.getLogger(__name__) + class CloudBillingAsyncClient: """Retrieves the Google Cloud Console billing accounts and @@ -267,6 +277,28 @@ def __init__( client_info=client_info, ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + std_logging.DEBUG + ): # pragma: NO COVER + _LOGGER.debug( + "Created client `google.cloud.billing_v1.CloudBillingAsyncClient`.", + extra={ + "serviceName": "google.cloud.billing.v1.CloudBilling", + "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.billing.v1.CloudBilling", + "credentialsType": None, + }, + ) + async def get_billing_account( self, request: Optional[Union[cloud_billing.GetBillingAccountRequest, dict]] = None, @@ -274,7 +306,7 @@ async def get_billing_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]]] = (), ) -> cloud_billing.BillingAccount: r"""Gets information about a billing account. The current authenticated user must be a `viewer of the billing @@ -320,8 +352,10 @@ async def sample_get_billing_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.billing_v1.types.BillingAccount: @@ -384,7 +418,7 @@ async def list_billing_accounts( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListBillingAccountsAsyncPager: r"""Lists the billing accounts that the current authenticated user has permission to @@ -434,8 +468,10 @@ async def sample_list_billing_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.cloud.billing_v1.services.cloud_billing.pagers.ListBillingAccountsAsyncPager: @@ -506,7 +542,7 @@ async def update_billing_account( account: Optional[cloud_billing.BillingAccount] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> cloud_billing.BillingAccount: r"""Updates a billing account's fields. Currently the only field that can be edited is ``display_name``. The current @@ -562,8 +598,10 @@ async def sample_update_billing_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.billing_v1.types.BillingAccount: @@ -631,7 +669,7 @@ async def create_billing_account( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> cloud_billing.BillingAccount: r"""This method creates `billing subaccounts `__. @@ -700,8 +738,10 @@ async def sample_create_billing_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.billing_v1.types.BillingAccount: @@ -762,7 +802,7 @@ async def list_project_billing_info( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListProjectBillingInfoAsyncPager: r"""Lists the projects associated with a billing account. The current authenticated user must have the @@ -811,8 +851,10 @@ async def sample_list_project_billing_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.billing_v1.services.cloud_billing.pagers.ListProjectBillingInfoAsyncPager: @@ -888,7 +930,7 @@ async def get_project_billing_info( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> cloud_billing.ProjectBillingInfo: r"""Gets the billing information for a project. The current authenticated user must have the @@ -937,8 +979,10 @@ async def sample_get_project_billing_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.billing_v1.types.ProjectBillingInfo: @@ -1006,7 +1050,7 @@ async def update_project_billing_info( project_billing_info: Optional[cloud_billing.ProjectBillingInfo] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> cloud_billing.ProjectBillingInfo: r"""Sets or updates the billing account associated with a project. You specify the new billing account by setting the @@ -1093,8 +1137,10 @@ async def sample_update_project_billing_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.billing_v1.types.ProjectBillingInfo: @@ -1161,7 +1207,7 @@ async def get_iam_policy( resource: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> policy_pb2.Policy: r"""Gets the access control policy for a billing account. The caller must have the ``billing.accounts.getIamPolicy`` permission on @@ -1210,8 +1256,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: @@ -1297,7 +1345,7 @@ async def set_iam_policy( resource: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> policy_pb2.Policy: r"""Sets the access control policy for a billing account. Replaces any existing policy. The caller must have the @@ -1347,8 +1395,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: @@ -1435,7 +1485,7 @@ async def test_iam_permissions( permissions: Optional[MutableSequence[str]] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> iam_policy_pb2.TestIamPermissionsResponse: r"""Tests the access control policy for a billing account. This method takes the resource and a set of @@ -1495,8 +1545,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: @@ -1553,7 +1605,7 @@ async def move_billing_account( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> cloud_billing.BillingAccount: r"""Changes which parent organization a billing account belongs to. @@ -1591,8 +1643,10 @@ async def sample_move_billing_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.billing_v1.types.BillingAccount: diff --git a/packages/google-cloud-billing/google/cloud/billing_v1/services/cloud_billing/client.py b/packages/google-cloud-billing/google/cloud/billing_v1/services/cloud_billing/client.py index cc1f995bfa12..14c05607a3b1 100644 --- a/packages/google-cloud-billing/google/cloud/billing_v1/services/cloud_billing/client.py +++ b/packages/google-cloud-billing/google/cloud/billing_v1/services/cloud_billing/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.iam.v1 import iam_policy_pb2 # type: ignore from google.iam.v1 import policy_pb2 # type: ignore @@ -619,6 +629,10 @@ def __init__( # Initialize the universe domain validation. self._is_universe_domain_valid = False + if CLIENT_LOGGING_SUPPORTED: # pragma: NO COVER + # Setup logging. + client_logging.initialize_logging() + api_key_value = getattr(self._client_options, "api_key", None) if api_key_value and credentials: raise ValueError( @@ -681,6 +695,29 @@ def __init__( api_audience=self._client_options.api_audience, ) + if "async" not in str(self._transport): + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + std_logging.DEBUG + ): # pragma: NO COVER + _LOGGER.debug( + "Created client `google.cloud.billing_v1.CloudBillingClient`.", + extra={ + "serviceName": "google.cloud.billing.v1.CloudBilling", + "universeDomain": getattr( + self._transport._credentials, "universe_domain", "" + ), + "credentialsType": f"{type(self._transport._credentials).__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.billing.v1.CloudBilling", + "credentialsType": None, + }, + ) + def get_billing_account( self, request: Optional[Union[cloud_billing.GetBillingAccountRequest, dict]] = None, @@ -688,7 +725,7 @@ def get_billing_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]]] = (), ) -> cloud_billing.BillingAccount: r"""Gets information about a billing account. The current authenticated user must be a `viewer of the billing @@ -734,8 +771,10 @@ def sample_get_billing_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.billing_v1.types.BillingAccount: @@ -795,7 +834,7 @@ def list_billing_accounts( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListBillingAccountsPager: r"""Lists the billing accounts that the current authenticated user has permission to @@ -845,8 +884,10 @@ def sample_list_billing_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.cloud.billing_v1.services.cloud_billing.pagers.ListBillingAccountsPager: @@ -914,7 +955,7 @@ def update_billing_account( account: Optional[cloud_billing.BillingAccount] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> cloud_billing.BillingAccount: r"""Updates a billing account's fields. Currently the only field that can be edited is ``display_name``. The current @@ -970,8 +1011,10 @@ def sample_update_billing_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.billing_v1.types.BillingAccount: @@ -1036,7 +1079,7 @@ def create_billing_account( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> cloud_billing.BillingAccount: r"""This method creates `billing subaccounts `__. @@ -1105,8 +1148,10 @@ def sample_create_billing_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.billing_v1.types.BillingAccount: @@ -1164,7 +1209,7 @@ def list_project_billing_info( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListProjectBillingInfoPager: r"""Lists the projects associated with a billing account. The current authenticated user must have the @@ -1213,8 +1258,10 @@ def sample_list_project_billing_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.billing_v1.services.cloud_billing.pagers.ListProjectBillingInfoPager: @@ -1289,7 +1336,7 @@ def get_project_billing_info( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> cloud_billing.ProjectBillingInfo: r"""Gets the billing information for a project. The current authenticated user must have the @@ -1338,8 +1385,10 @@ def sample_get_project_billing_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.billing_v1.types.ProjectBillingInfo: @@ -1404,7 +1453,7 @@ def update_project_billing_info( project_billing_info: Optional[cloud_billing.ProjectBillingInfo] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> cloud_billing.ProjectBillingInfo: r"""Sets or updates the billing account associated with a project. You specify the new billing account by setting the @@ -1491,8 +1540,10 @@ def sample_update_project_billing_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.billing_v1.types.ProjectBillingInfo: @@ -1558,7 +1609,7 @@ def get_iam_policy( resource: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> policy_pb2.Policy: r"""Gets the access control policy for a billing account. The caller must have the ``billing.accounts.getIamPolicy`` permission on @@ -1607,8 +1658,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: @@ -1695,7 +1748,7 @@ def set_iam_policy( resource: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> policy_pb2.Policy: r"""Sets the access control policy for a billing account. Replaces any existing policy. The caller must have the @@ -1745,8 +1798,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: @@ -1834,7 +1889,7 @@ def test_iam_permissions( permissions: Optional[MutableSequence[str]] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> iam_policy_pb2.TestIamPermissionsResponse: r"""Tests the access control policy for a billing account. This method takes the resource and a set of @@ -1894,8 +1949,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: @@ -1953,7 +2010,7 @@ def move_billing_account( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> cloud_billing.BillingAccount: r"""Changes which parent organization a billing account belongs to. @@ -1991,8 +2048,10 @@ def sample_move_billing_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.billing_v1.types.BillingAccount: diff --git a/packages/google-cloud-billing/google/cloud/billing_v1/services/cloud_billing/pagers.py b/packages/google-cloud-billing/google/cloud/billing_v1/services/cloud_billing/pagers.py index 2f40fabf8254..b92c65e13b02 100644 --- a/packages/google-cloud-billing/google/cloud/billing_v1/services/cloud_billing/pagers.py +++ b/packages/google-cloud-billing/google/cloud/billing_v1/services/cloud_billing/pagers.py @@ -67,7 +67,7 @@ def __init__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiate the pager. @@ -81,8 +81,10 @@ def __init__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. """ self._method = method self._request = cloud_billing.ListBillingAccountsRequest(request) @@ -141,7 +143,7 @@ def __init__( *, retry: OptionalAsyncRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiates the pager. @@ -155,8 +157,10 @@ def __init__( retry (google.api_core.retry.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. """ self._method = method self._request = cloud_billing.ListBillingAccountsRequest(request) @@ -219,7 +223,7 @@ def __init__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiate the pager. @@ -233,8 +237,10 @@ def __init__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. """ self._method = method self._request = cloud_billing.ListProjectBillingInfoRequest(request) @@ -293,7 +299,7 @@ def __init__( *, retry: OptionalAsyncRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiates the pager. @@ -307,8 +313,10 @@ def __init__( retry (google.api_core.retry.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. """ self._method = method self._request = cloud_billing.ListProjectBillingInfoRequest(request) diff --git a/packages/google-cloud-billing/google/cloud/billing_v1/services/cloud_billing/transports/grpc.py b/packages/google-cloud-billing/google/cloud/billing_v1/services/cloud_billing/transports/grpc.py index 466d9fbf31dd..2b57fcea73f5 100644 --- a/packages/google-cloud-billing/google/cloud/billing_v1/services/cloud_billing/transports/grpc.py +++ b/packages/google-cloud-billing/google/cloud/billing_v1/services/cloud_billing/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.iam.v1 import iam_policy_pb2 # type: ignore from google.iam.v1 import policy_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.billing_v1.types import cloud_billing from .base import DEFAULT_CLIENT_INFO, CloudBillingTransport +try: + from google.api_core import client_logging # 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.billing.v1.CloudBilling", + "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.billing.v1.CloudBilling", + "rpcName": client_call_details.method, + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class CloudBillingGrpcTransport(CloudBillingTransport): """gRPC backend transport for CloudBilling. @@ -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 get_billing_account( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_billing_account" not in self._stubs: - self._stubs["get_billing_account"] = self.grpc_channel.unary_unary( + self._stubs["get_billing_account"] = self._logged_channel.unary_unary( "/google.cloud.billing.v1.CloudBilling/GetBillingAccount", request_serializer=cloud_billing.GetBillingAccountRequest.serialize, response_deserializer=cloud_billing.BillingAccount.deserialize, @@ -291,7 +377,7 @@ def list_billing_accounts( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_billing_accounts" not in self._stubs: - self._stubs["list_billing_accounts"] = self.grpc_channel.unary_unary( + self._stubs["list_billing_accounts"] = self._logged_channel.unary_unary( "/google.cloud.billing.v1.CloudBilling/ListBillingAccounts", request_serializer=cloud_billing.ListBillingAccountsRequest.serialize, response_deserializer=cloud_billing.ListBillingAccountsResponse.deserialize, @@ -324,7 +410,7 @@ def update_billing_account( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_billing_account" not in self._stubs: - self._stubs["update_billing_account"] = self.grpc_channel.unary_unary( + self._stubs["update_billing_account"] = self._logged_channel.unary_unary( "/google.cloud.billing.v1.CloudBilling/UpdateBillingAccount", request_serializer=cloud_billing.UpdateBillingAccountRequest.serialize, response_deserializer=cloud_billing.BillingAccount.deserialize, @@ -365,7 +451,7 @@ def create_billing_account( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_billing_account" not in self._stubs: - self._stubs["create_billing_account"] = self.grpc_channel.unary_unary( + self._stubs["create_billing_account"] = self._logged_channel.unary_unary( "/google.cloud.billing.v1.CloudBilling/CreateBillingAccount", request_serializer=cloud_billing.CreateBillingAccountRequest.serialize, response_deserializer=cloud_billing.BillingAccount.deserialize, @@ -398,7 +484,7 @@ def list_project_billing_info( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_project_billing_info" not in self._stubs: - self._stubs["list_project_billing_info"] = self.grpc_channel.unary_unary( + self._stubs["list_project_billing_info"] = self._logged_channel.unary_unary( "/google.cloud.billing.v1.CloudBilling/ListProjectBillingInfo", request_serializer=cloud_billing.ListProjectBillingInfoRequest.serialize, response_deserializer=cloud_billing.ListProjectBillingInfoResponse.deserialize, @@ -431,7 +517,7 @@ def get_project_billing_info( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_project_billing_info" not in self._stubs: - self._stubs["get_project_billing_info"] = self.grpc_channel.unary_unary( + self._stubs["get_project_billing_info"] = self._logged_channel.unary_unary( "/google.cloud.billing.v1.CloudBilling/GetProjectBillingInfo", request_serializer=cloud_billing.GetProjectBillingInfoRequest.serialize, response_deserializer=cloud_billing.ProjectBillingInfo.deserialize, @@ -495,7 +581,9 @@ def update_project_billing_info( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_project_billing_info" not in self._stubs: - self._stubs["update_project_billing_info"] = self.grpc_channel.unary_unary( + self._stubs[ + "update_project_billing_info" + ] = self._logged_channel.unary_unary( "/google.cloud.billing.v1.CloudBilling/UpdateProjectBillingInfo", request_serializer=cloud_billing.UpdateProjectBillingInfoRequest.serialize, response_deserializer=cloud_billing.ProjectBillingInfo.deserialize, @@ -524,7 +612,7 @@ def get_iam_policy( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_iam_policy" not in self._stubs: - self._stubs["get_iam_policy"] = self.grpc_channel.unary_unary( + self._stubs["get_iam_policy"] = self._logged_channel.unary_unary( "/google.cloud.billing.v1.CloudBilling/GetIamPolicy", request_serializer=iam_policy_pb2.GetIamPolicyRequest.SerializeToString, response_deserializer=policy_pb2.Policy.FromString, @@ -554,7 +642,7 @@ def set_iam_policy( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "set_iam_policy" not in self._stubs: - self._stubs["set_iam_policy"] = self.grpc_channel.unary_unary( + self._stubs["set_iam_policy"] = self._logged_channel.unary_unary( "/google.cloud.billing.v1.CloudBilling/SetIamPolicy", request_serializer=iam_policy_pb2.SetIamPolicyRequest.SerializeToString, response_deserializer=policy_pb2.Policy.FromString, @@ -587,7 +675,7 @@ def test_iam_permissions( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "test_iam_permissions" not in self._stubs: - self._stubs["test_iam_permissions"] = self.grpc_channel.unary_unary( + self._stubs["test_iam_permissions"] = self._logged_channel.unary_unary( "/google.cloud.billing.v1.CloudBilling/TestIamPermissions", request_serializer=iam_policy_pb2.TestIamPermissionsRequest.SerializeToString, response_deserializer=iam_policy_pb2.TestIamPermissionsResponse.FromString, @@ -616,7 +704,7 @@ def move_billing_account( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "move_billing_account" not in self._stubs: - self._stubs["move_billing_account"] = self.grpc_channel.unary_unary( + self._stubs["move_billing_account"] = self._logged_channel.unary_unary( "/google.cloud.billing.v1.CloudBilling/MoveBillingAccount", request_serializer=cloud_billing.MoveBillingAccountRequest.serialize, response_deserializer=cloud_billing.BillingAccount.deserialize, @@ -624,7 +712,7 @@ def move_billing_account( return self._stubs["move_billing_account"] def close(self): - self.grpc_channel.close() + self._logged_channel.close() @property def kind(self) -> str: diff --git a/packages/google-cloud-billing/google/cloud/billing_v1/services/cloud_billing/transports/grpc_asyncio.py b/packages/google-cloud-billing/google/cloud/billing_v1/services/cloud_billing/transports/grpc_asyncio.py index e2cd6f2c30a0..3af3bdf58764 100644 --- a/packages/google-cloud-billing/google/cloud/billing_v1/services/cloud_billing/transports/grpc_asyncio.py +++ b/packages/google-cloud-billing/google/cloud/billing_v1/services/cloud_billing/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.iam.v1 import iam_policy_pb2 # type: ignore from google.iam.v1 import policy_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.billing_v1.types import cloud_billing from .base import DEFAULT_CLIENT_INFO, CloudBillingTransport from .grpc import CloudBillingGrpcTransport +try: + from google.api_core import client_logging # 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.billing.v1.CloudBilling", + "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.billing.v1.CloudBilling", + "rpcName": str(client_call_details.method), + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class CloudBillingGrpcAsyncIOTransport(CloudBillingTransport): """gRPC AsyncIO backend transport for CloudBilling. @@ -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 @@ -269,7 +354,7 @@ def get_billing_account( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_billing_account" not in self._stubs: - self._stubs["get_billing_account"] = self.grpc_channel.unary_unary( + self._stubs["get_billing_account"] = self._logged_channel.unary_unary( "/google.cloud.billing.v1.CloudBilling/GetBillingAccount", request_serializer=cloud_billing.GetBillingAccountRequest.serialize, response_deserializer=cloud_billing.BillingAccount.deserialize, @@ -300,7 +385,7 @@ def list_billing_accounts( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_billing_accounts" not in self._stubs: - self._stubs["list_billing_accounts"] = self.grpc_channel.unary_unary( + self._stubs["list_billing_accounts"] = self._logged_channel.unary_unary( "/google.cloud.billing.v1.CloudBilling/ListBillingAccounts", request_serializer=cloud_billing.ListBillingAccountsRequest.serialize, response_deserializer=cloud_billing.ListBillingAccountsResponse.deserialize, @@ -334,7 +419,7 @@ def update_billing_account( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_billing_account" not in self._stubs: - self._stubs["update_billing_account"] = self.grpc_channel.unary_unary( + self._stubs["update_billing_account"] = self._logged_channel.unary_unary( "/google.cloud.billing.v1.CloudBilling/UpdateBillingAccount", request_serializer=cloud_billing.UpdateBillingAccountRequest.serialize, response_deserializer=cloud_billing.BillingAccount.deserialize, @@ -376,7 +461,7 @@ def create_billing_account( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_billing_account" not in self._stubs: - self._stubs["create_billing_account"] = self.grpc_channel.unary_unary( + self._stubs["create_billing_account"] = self._logged_channel.unary_unary( "/google.cloud.billing.v1.CloudBilling/CreateBillingAccount", request_serializer=cloud_billing.CreateBillingAccountRequest.serialize, response_deserializer=cloud_billing.BillingAccount.deserialize, @@ -409,7 +494,7 @@ def list_project_billing_info( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_project_billing_info" not in self._stubs: - self._stubs["list_project_billing_info"] = self.grpc_channel.unary_unary( + self._stubs["list_project_billing_info"] = self._logged_channel.unary_unary( "/google.cloud.billing.v1.CloudBilling/ListProjectBillingInfo", request_serializer=cloud_billing.ListProjectBillingInfoRequest.serialize, response_deserializer=cloud_billing.ListProjectBillingInfoResponse.deserialize, @@ -443,7 +528,7 @@ def get_project_billing_info( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_project_billing_info" not in self._stubs: - self._stubs["get_project_billing_info"] = self.grpc_channel.unary_unary( + self._stubs["get_project_billing_info"] = self._logged_channel.unary_unary( "/google.cloud.billing.v1.CloudBilling/GetProjectBillingInfo", request_serializer=cloud_billing.GetProjectBillingInfoRequest.serialize, response_deserializer=cloud_billing.ProjectBillingInfo.deserialize, @@ -507,7 +592,9 @@ def update_project_billing_info( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_project_billing_info" not in self._stubs: - self._stubs["update_project_billing_info"] = self.grpc_channel.unary_unary( + self._stubs[ + "update_project_billing_info" + ] = self._logged_channel.unary_unary( "/google.cloud.billing.v1.CloudBilling/UpdateProjectBillingInfo", request_serializer=cloud_billing.UpdateProjectBillingInfoRequest.serialize, response_deserializer=cloud_billing.ProjectBillingInfo.deserialize, @@ -536,7 +623,7 @@ def get_iam_policy( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_iam_policy" not in self._stubs: - self._stubs["get_iam_policy"] = self.grpc_channel.unary_unary( + self._stubs["get_iam_policy"] = self._logged_channel.unary_unary( "/google.cloud.billing.v1.CloudBilling/GetIamPolicy", request_serializer=iam_policy_pb2.GetIamPolicyRequest.SerializeToString, response_deserializer=policy_pb2.Policy.FromString, @@ -566,7 +653,7 @@ def set_iam_policy( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "set_iam_policy" not in self._stubs: - self._stubs["set_iam_policy"] = self.grpc_channel.unary_unary( + self._stubs["set_iam_policy"] = self._logged_channel.unary_unary( "/google.cloud.billing.v1.CloudBilling/SetIamPolicy", request_serializer=iam_policy_pb2.SetIamPolicyRequest.SerializeToString, response_deserializer=policy_pb2.Policy.FromString, @@ -599,7 +686,7 @@ def test_iam_permissions( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "test_iam_permissions" not in self._stubs: - self._stubs["test_iam_permissions"] = self.grpc_channel.unary_unary( + self._stubs["test_iam_permissions"] = self._logged_channel.unary_unary( "/google.cloud.billing.v1.CloudBilling/TestIamPermissions", request_serializer=iam_policy_pb2.TestIamPermissionsRequest.SerializeToString, response_deserializer=iam_policy_pb2.TestIamPermissionsResponse.FromString, @@ -629,7 +716,7 @@ def move_billing_account( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "move_billing_account" not in self._stubs: - self._stubs["move_billing_account"] = self.grpc_channel.unary_unary( + self._stubs["move_billing_account"] = self._logged_channel.unary_unary( "/google.cloud.billing.v1.CloudBilling/MoveBillingAccount", request_serializer=cloud_billing.MoveBillingAccountRequest.serialize, response_deserializer=cloud_billing.BillingAccount.deserialize, @@ -792,7 +879,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-billing/google/cloud/billing_v1/services/cloud_billing/transports/rest.py b/packages/google-cloud-billing/google/cloud/billing_v1/services/cloud_billing/transports/rest.py index 6a0141fd0379..025dccaacb6d 100644 --- a/packages/google-cloud-billing/google/cloud/billing_v1/services/cloud_billing/transports/rest.py +++ b/packages/google-cloud-billing/google/cloud/billing_v1/services/cloud_billing/transports/rest.py @@ -13,9 +13,9 @@ # See the License for the specific language governing permissions and # limitations 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, @@ -159,8 +167,11 @@ def post_update_project_billing_info(self, response): def pre_create_billing_account( self, request: cloud_billing.CreateBillingAccountRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[cloud_billing.CreateBillingAccountRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + cloud_billing.CreateBillingAccountRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for create_billing_account Override in a subclass to manipulate the request or metadata @@ -182,8 +193,10 @@ def post_create_billing_account( def pre_get_billing_account( self, request: cloud_billing.GetBillingAccountRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[cloud_billing.GetBillingAccountRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + cloud_billing.GetBillingAccountRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for get_billing_account Override in a subclass to manipulate the request or metadata @@ -205,8 +218,10 @@ def post_get_billing_account( 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 @@ -226,8 +241,11 @@ def post_get_iam_policy(self, response: policy_pb2.Policy) -> policy_pb2.Policy: def pre_get_project_billing_info( self, request: cloud_billing.GetProjectBillingInfoRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[cloud_billing.GetProjectBillingInfoRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + cloud_billing.GetProjectBillingInfoRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for get_project_billing_info Override in a subclass to manipulate the request or metadata @@ -249,8 +267,11 @@ def post_get_project_billing_info( def pre_list_billing_accounts( self, request: cloud_billing.ListBillingAccountsRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[cloud_billing.ListBillingAccountsRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + cloud_billing.ListBillingAccountsRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for list_billing_accounts Override in a subclass to manipulate the request or metadata @@ -272,8 +293,11 @@ def post_list_billing_accounts( def pre_list_project_billing_info( self, request: cloud_billing.ListProjectBillingInfoRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[cloud_billing.ListProjectBillingInfoRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + cloud_billing.ListProjectBillingInfoRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for list_project_billing_info Override in a subclass to manipulate the request or metadata @@ -295,8 +319,10 @@ def post_list_project_billing_info( def pre_move_billing_account( self, request: cloud_billing.MoveBillingAccountRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[cloud_billing.MoveBillingAccountRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + cloud_billing.MoveBillingAccountRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for move_billing_account Override in a subclass to manipulate the request or metadata @@ -318,8 +344,10 @@ def post_move_billing_account( 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 @@ -339,8 +367,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 @@ -362,8 +393,11 @@ def post_test_iam_permissions( def pre_update_billing_account( self, request: cloud_billing.UpdateBillingAccountRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[cloud_billing.UpdateBillingAccountRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + cloud_billing.UpdateBillingAccountRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for update_billing_account Override in a subclass to manipulate the request or metadata @@ -385,9 +419,10 @@ def post_update_billing_account( def pre_update_project_billing_info( self, request: cloud_billing.UpdateProjectBillingInfoRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ - cloud_billing.UpdateProjectBillingInfoRequest, Sequence[Tuple[str, str]] + cloud_billing.UpdateProjectBillingInfoRequest, + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for update_project_billing_info @@ -530,7 +565,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> cloud_billing.BillingAccount: r"""Call the create billing account method over HTTP. @@ -540,8 +575,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.cloud_billing.BillingAccount: @@ -554,6 +591,7 @@ def __call__( http_options = ( _BaseCloudBillingRestTransport._BaseCreateBillingAccount._get_http_options() ) + request, metadata = self._interceptor.pre_create_billing_account( request, metadata ) @@ -570,6 +608,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.billing_v1.CloudBillingClient.CreateBillingAccount", + extra={ + "serviceName": "google.cloud.billing.v1.CloudBilling", + "rpcName": "CreateBillingAccount", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = CloudBillingRestTransport._CreateBillingAccount._get_response( self._host, @@ -591,7 +656,29 @@ def __call__( pb_resp = cloud_billing.BillingAccount.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_create_billing_account(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = cloud_billing.BillingAccount.to_json(response) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.billing_v1.CloudBillingClient.create_billing_account", + extra={ + "serviceName": "google.cloud.billing.v1.CloudBilling", + "rpcName": "CreateBillingAccount", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _GetBillingAccount( @@ -628,7 +715,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> cloud_billing.BillingAccount: r"""Call the get billing account method over HTTP. @@ -638,8 +725,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.cloud_billing.BillingAccount: @@ -652,6 +741,7 @@ def __call__( http_options = ( _BaseCloudBillingRestTransport._BaseGetBillingAccount._get_http_options() ) + request, metadata = self._interceptor.pre_get_billing_account( request, metadata ) @@ -664,6 +754,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.billing_v1.CloudBillingClient.GetBillingAccount", + extra={ + "serviceName": "google.cloud.billing.v1.CloudBilling", + "rpcName": "GetBillingAccount", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = CloudBillingRestTransport._GetBillingAccount._get_response( self._host, @@ -684,7 +801,29 @@ def __call__( pb_resp = cloud_billing.BillingAccount.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_billing_account(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = cloud_billing.BillingAccount.to_json(response) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.billing_v1.CloudBillingClient.get_billing_account", + extra={ + "serviceName": "google.cloud.billing.v1.CloudBilling", + "rpcName": "GetBillingAccount", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _GetIamPolicy( @@ -721,7 +860,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> policy_pb2.Policy: r"""Call the get iam policy method over HTTP. @@ -731,8 +870,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.policy_pb2.Policy: @@ -817,6 +958,7 @@ def __call__( http_options = ( _BaseCloudBillingRestTransport._BaseGetIamPolicy._get_http_options() ) + request, metadata = self._interceptor.pre_get_iam_policy(request, metadata) transcoded_request = _BaseCloudBillingRestTransport._BaseGetIamPolicy._get_transcoded_request( http_options, request @@ -829,6 +971,33 @@ def __call__( ) ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.billing_v1.CloudBillingClient.GetIamPolicy", + extra={ + "serviceName": "google.cloud.billing.v1.CloudBilling", + "rpcName": "GetIamPolicy", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = CloudBillingRestTransport._GetIamPolicy._get_response( self._host, @@ -849,7 +1018,29 @@ def __call__( pb_resp = resp json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_iam_policy(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = json_format.MessageToJson(resp) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.billing_v1.CloudBillingClient.get_iam_policy", + extra={ + "serviceName": "google.cloud.billing.v1.CloudBilling", + "rpcName": "GetIamPolicy", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _GetProjectBillingInfo( @@ -886,7 +1077,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> cloud_billing.ProjectBillingInfo: r"""Call the get project billing info method over HTTP. @@ -896,8 +1087,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.cloud_billing.ProjectBillingInfo: @@ -913,6 +1106,7 @@ def __call__( http_options = ( _BaseCloudBillingRestTransport._BaseGetProjectBillingInfo._get_http_options() ) + request, metadata = self._interceptor.pre_get_project_billing_info( request, metadata ) @@ -925,6 +1119,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.billing_v1.CloudBillingClient.GetProjectBillingInfo", + extra={ + "serviceName": "google.cloud.billing.v1.CloudBilling", + "rpcName": "GetProjectBillingInfo", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = CloudBillingRestTransport._GetProjectBillingInfo._get_response( self._host, @@ -945,7 +1166,31 @@ def __call__( pb_resp = cloud_billing.ProjectBillingInfo.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_project_billing_info(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = cloud_billing.ProjectBillingInfo.to_json( + response + ) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.billing_v1.CloudBillingClient.get_project_billing_info", + extra={ + "serviceName": "google.cloud.billing.v1.CloudBilling", + "rpcName": "GetProjectBillingInfo", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ListBillingAccounts( @@ -982,7 +1227,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> cloud_billing.ListBillingAccountsResponse: r"""Call the list billing accounts method over HTTP. @@ -992,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: ~.cloud_billing.ListBillingAccountsResponse: @@ -1003,6 +1250,7 @@ def __call__( http_options = ( _BaseCloudBillingRestTransport._BaseListBillingAccounts._get_http_options() ) + request, metadata = self._interceptor.pre_list_billing_accounts( request, metadata ) @@ -1015,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.cloud.billing_v1.CloudBillingClient.ListBillingAccounts", + extra={ + "serviceName": "google.cloud.billing.v1.CloudBilling", + "rpcName": "ListBillingAccounts", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = CloudBillingRestTransport._ListBillingAccounts._get_response( self._host, @@ -1035,7 +1310,31 @@ def __call__( pb_resp = cloud_billing.ListBillingAccountsResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_billing_accounts(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = ( + cloud_billing.ListBillingAccountsResponse.to_json(response) + ) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.billing_v1.CloudBillingClient.list_billing_accounts", + extra={ + "serviceName": "google.cloud.billing.v1.CloudBilling", + "rpcName": "ListBillingAccounts", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ListProjectBillingInfo( @@ -1072,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]]] = (), ) -> cloud_billing.ListProjectBillingInfoResponse: r"""Call the list project billing info method over HTTP. @@ -1082,8 +1381,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.cloud_billing.ListProjectBillingInfoResponse: @@ -1093,6 +1394,7 @@ def __call__( http_options = ( _BaseCloudBillingRestTransport._BaseListProjectBillingInfo._get_http_options() ) + request, metadata = self._interceptor.pre_list_project_billing_info( request, metadata ) @@ -1105,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 = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.billing_v1.CloudBillingClient.ListProjectBillingInfo", + extra={ + "serviceName": "google.cloud.billing.v1.CloudBilling", + "rpcName": "ListProjectBillingInfo", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = CloudBillingRestTransport._ListProjectBillingInfo._get_response( self._host, @@ -1125,7 +1454,31 @@ def __call__( pb_resp = cloud_billing.ListProjectBillingInfoResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_project_billing_info(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = ( + cloud_billing.ListProjectBillingInfoResponse.to_json(response) + ) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.billing_v1.CloudBillingClient.list_project_billing_info", + extra={ + "serviceName": "google.cloud.billing.v1.CloudBilling", + "rpcName": "ListProjectBillingInfo", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _MoveBillingAccount( @@ -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]]] = (), ) -> cloud_billing.BillingAccount: r"""Call the move billing account method over HTTP. @@ -1173,8 +1526,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.cloud_billing.BillingAccount: @@ -1187,6 +1542,7 @@ def __call__( http_options = ( _BaseCloudBillingRestTransport._BaseMoveBillingAccount._get_http_options() ) + request, metadata = self._interceptor.pre_move_billing_account( request, metadata ) @@ -1203,6 +1559,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.billing_v1.CloudBillingClient.MoveBillingAccount", + extra={ + "serviceName": "google.cloud.billing.v1.CloudBilling", + "rpcName": "MoveBillingAccount", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = CloudBillingRestTransport._MoveBillingAccount._get_response( self._host, @@ -1224,7 +1607,29 @@ def __call__( pb_resp = cloud_billing.BillingAccount.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_move_billing_account(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = cloud_billing.BillingAccount.to_json(response) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.billing_v1.CloudBillingClient.move_billing_account", + extra={ + "serviceName": "google.cloud.billing.v1.CloudBilling", + "rpcName": "MoveBillingAccount", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _SetIamPolicy( @@ -1262,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]]] = (), ) -> policy_pb2.Policy: r"""Call the set iam policy method over HTTP. @@ -1272,8 +1677,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.policy_pb2.Policy: @@ -1358,6 +1765,7 @@ def __call__( http_options = ( _BaseCloudBillingRestTransport._BaseSetIamPolicy._get_http_options() ) + request, metadata = self._interceptor.pre_set_iam_policy(request, metadata) transcoded_request = _BaseCloudBillingRestTransport._BaseSetIamPolicy._get_transcoded_request( http_options, request @@ -1376,6 +1784,33 @@ def __call__( ) ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.billing_v1.CloudBillingClient.SetIamPolicy", + extra={ + "serviceName": "google.cloud.billing.v1.CloudBilling", + "rpcName": "SetIamPolicy", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = CloudBillingRestTransport._SetIamPolicy._get_response( self._host, @@ -1397,7 +1832,29 @@ def __call__( pb_resp = resp json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_set_iam_policy(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = json_format.MessageToJson(resp) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.billing_v1.CloudBillingClient.set_iam_policy", + extra={ + "serviceName": "google.cloud.billing.v1.CloudBilling", + "rpcName": "SetIamPolicy", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _TestIamPermissions( @@ -1435,7 +1892,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> iam_policy_pb2.TestIamPermissionsResponse: r"""Call the test iam permissions method over HTTP. @@ -1445,8 +1902,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.iam_policy_pb2.TestIamPermissionsResponse: @@ -1456,6 +1915,7 @@ def __call__( http_options = ( _BaseCloudBillingRestTransport._BaseTestIamPermissions._get_http_options() ) + request, metadata = self._interceptor.pre_test_iam_permissions( request, metadata ) @@ -1472,6 +1932,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.billing_v1.CloudBillingClient.TestIamPermissions", + extra={ + "serviceName": "google.cloud.billing.v1.CloudBilling", + "rpcName": "TestIamPermissions", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = CloudBillingRestTransport._TestIamPermissions._get_response( self._host, @@ -1493,7 +1980,29 @@ def __call__( pb_resp = resp json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_test_iam_permissions(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = json_format.MessageToJson(resp) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.billing_v1.CloudBillingClient.test_iam_permissions", + extra={ + "serviceName": "google.cloud.billing.v1.CloudBilling", + "rpcName": "TestIamPermissions", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _UpdateBillingAccount( @@ -1531,7 +2040,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> cloud_billing.BillingAccount: r"""Call the update billing account method over HTTP. @@ -1541,8 +2050,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.cloud_billing.BillingAccount: @@ -1555,6 +2066,7 @@ def __call__( http_options = ( _BaseCloudBillingRestTransport._BaseUpdateBillingAccount._get_http_options() ) + request, metadata = self._interceptor.pre_update_billing_account( request, metadata ) @@ -1571,6 +2083,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.billing_v1.CloudBillingClient.UpdateBillingAccount", + extra={ + "serviceName": "google.cloud.billing.v1.CloudBilling", + "rpcName": "UpdateBillingAccount", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = CloudBillingRestTransport._UpdateBillingAccount._get_response( self._host, @@ -1592,7 +2131,29 @@ def __call__( pb_resp = cloud_billing.BillingAccount.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_update_billing_account(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = cloud_billing.BillingAccount.to_json(response) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.billing_v1.CloudBillingClient.update_billing_account", + extra={ + "serviceName": "google.cloud.billing.v1.CloudBilling", + "rpcName": "UpdateBillingAccount", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _UpdateProjectBillingInfo( @@ -1631,7 +2192,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> cloud_billing.ProjectBillingInfo: r"""Call the update project billing info method over HTTP. @@ -1642,8 +2203,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.cloud_billing.ProjectBillingInfo: @@ -1659,6 +2222,7 @@ def __call__( http_options = ( _BaseCloudBillingRestTransport._BaseUpdateProjectBillingInfo._get_http_options() ) + request, metadata = self._interceptor.pre_update_project_billing_info( request, metadata ) @@ -1675,6 +2239,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.billing_v1.CloudBillingClient.UpdateProjectBillingInfo", + extra={ + "serviceName": "google.cloud.billing.v1.CloudBilling", + "rpcName": "UpdateProjectBillingInfo", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ( CloudBillingRestTransport._UpdateProjectBillingInfo._get_response( @@ -1698,7 +2289,31 @@ def __call__( pb_resp = cloud_billing.ProjectBillingInfo.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_update_project_billing_info(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = cloud_billing.ProjectBillingInfo.to_json( + response + ) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.billing_v1.CloudBillingClient.update_project_billing_info", + extra={ + "serviceName": "google.cloud.billing.v1.CloudBilling", + "rpcName": "UpdateProjectBillingInfo", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp @property diff --git a/packages/google-cloud-billing/google/cloud/billing_v1/services/cloud_catalog/async_client.py b/packages/google-cloud-billing/google/cloud/billing_v1/services/cloud_catalog/async_client.py index b76b512fe9d6..9961844b1c22 100644 --- a/packages/google-cloud-billing/google/cloud/billing_v1/services/cloud_catalog/async_client.py +++ b/packages/google-cloud-billing/google/cloud/billing_v1/services/cloud_catalog/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, CloudCatalogTransport from .transports.grpc_asyncio import CloudCatalogGrpcAsyncIOTransport +try: + from google.api_core import client_logging # type: ignore + + CLIENT_LOGGING_SUPPORTED = True # pragma: NO COVER +except ImportError: # pragma: NO COVER + CLIENT_LOGGING_SUPPORTED = False + +_LOGGER = std_logging.getLogger(__name__) + class CloudCatalogAsyncClient: """A catalog of Google Cloud Platform services and SKUs. @@ -255,13 +265,35 @@ def __init__( client_info=client_info, ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + std_logging.DEBUG + ): # pragma: NO COVER + _LOGGER.debug( + "Created client `google.cloud.billing_v1.CloudCatalogAsyncClient`.", + extra={ + "serviceName": "google.cloud.billing.v1.CloudCatalog", + "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.billing.v1.CloudCatalog", + "credentialsType": None, + }, + ) + async def list_services( self, request: Optional[Union[cloud_catalog.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 public cloud services. @@ -297,8 +329,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.billing_v1.services.cloud_catalog.pagers.ListServicesAsyncPager: @@ -352,7 +386,7 @@ async def list_skus( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListSkusAsyncPager: r"""Lists all publicly available SKUs for a given cloud service. @@ -397,8 +431,10 @@ async def sample_list_skus(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.billing_v1.services.cloud_catalog.pagers.ListSkusAsyncPager: diff --git a/packages/google-cloud-billing/google/cloud/billing_v1/services/cloud_catalog/client.py b/packages/google-cloud-billing/google/cloud/billing_v1/services/cloud_catalog/client.py index 60d8764dea8f..f24bba9587a8 100644 --- a/packages/google-cloud-billing/google/cloud/billing_v1/services/cloud_catalog/client.py +++ b/packages/google-cloud-billing/google/cloud/billing_v1/services/cloud_catalog/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.billing_v1.services.cloud_catalog import pagers from google.cloud.billing_v1.types import cloud_catalog @@ -589,6 +599,10 @@ def __init__( # Initialize the universe domain validation. self._is_universe_domain_valid = False + if CLIENT_LOGGING_SUPPORTED: # pragma: NO COVER + # Setup logging. + client_logging.initialize_logging() + api_key_value = getattr(self._client_options, "api_key", None) if api_key_value and credentials: raise ValueError( @@ -651,13 +665,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.billing_v1.CloudCatalogClient`.", + extra={ + "serviceName": "google.cloud.billing.v1.CloudCatalog", + "universeDomain": getattr( + self._transport._credentials, "universe_domain", "" + ), + "credentialsType": f"{type(self._transport._credentials).__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.billing.v1.CloudCatalog", + "credentialsType": None, + }, + ) + def list_services( self, request: Optional[Union[cloud_catalog.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 public cloud services. @@ -693,8 +730,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.billing_v1.services.cloud_catalog.pagers.ListServicesPager: @@ -746,7 +785,7 @@ def list_skus( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListSkusPager: r"""Lists all publicly available SKUs for a given cloud service. @@ -791,8 +830,10 @@ def sample_list_skus(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.billing_v1.services.cloud_catalog.pagers.ListSkusPager: diff --git a/packages/google-cloud-billing/google/cloud/billing_v1/services/cloud_catalog/pagers.py b/packages/google-cloud-billing/google/cloud/billing_v1/services/cloud_catalog/pagers.py index 9324ad0b0a13..801ec331d447 100644 --- a/packages/google-cloud-billing/google/cloud/billing_v1/services/cloud_catalog/pagers.py +++ b/packages/google-cloud-billing/google/cloud/billing_v1/services/cloud_catalog/pagers.py @@ -67,7 +67,7 @@ def __init__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiate the pager. @@ -81,8 +81,10 @@ def __init__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. """ self._method = method self._request = cloud_catalog.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 = cloud_catalog.ListServicesRequest(request) @@ -219,7 +223,7 @@ def __init__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiate the pager. @@ -233,8 +237,10 @@ def __init__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. """ self._method = method self._request = cloud_catalog.ListSkusRequest(request) @@ -293,7 +299,7 @@ def __init__( *, retry: OptionalAsyncRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiates the pager. @@ -307,8 +313,10 @@ def __init__( retry (google.api_core.retry.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. """ self._method = method self._request = cloud_catalog.ListSkusRequest(request) diff --git a/packages/google-cloud-billing/google/cloud/billing_v1/services/cloud_catalog/transports/grpc.py b/packages/google-cloud-billing/google/cloud/billing_v1/services/cloud_catalog/transports/grpc.py index 4dcd72d1093d..8d5c6cdb5a98 100644 --- a/packages/google-cloud-billing/google/cloud/billing_v1/services/cloud_catalog/transports/grpc.py +++ b/packages/google-cloud-billing/google/cloud/billing_v1/services/cloud_catalog/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.billing_v1.types import cloud_catalog from .base import DEFAULT_CLIENT_INFO, CloudCatalogTransport +try: + from google.api_core import client_logging # 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.billing.v1.CloudCatalog", + "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.billing.v1.CloudCatalog", + "rpcName": client_call_details.method, + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class CloudCatalogGrpcTransport(CloudCatalogTransport): """gRPC backend transport for CloudCatalog. @@ -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 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.billing.v1.CloudCatalog/ListServices", request_serializer=cloud_catalog.ListServicesRequest.serialize, response_deserializer=cloud_catalog.ListServicesResponse.deserialize, @@ -284,7 +370,7 @@ def list_skus( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_skus" not in self._stubs: - self._stubs["list_skus"] = self.grpc_channel.unary_unary( + self._stubs["list_skus"] = self._logged_channel.unary_unary( "/google.cloud.billing.v1.CloudCatalog/ListSkus", request_serializer=cloud_catalog.ListSkusRequest.serialize, response_deserializer=cloud_catalog.ListSkusResponse.deserialize, @@ -292,7 +378,7 @@ def list_skus( return self._stubs["list_skus"] def close(self): - self.grpc_channel.close() + self._logged_channel.close() @property def kind(self) -> str: diff --git a/packages/google-cloud-billing/google/cloud/billing_v1/services/cloud_catalog/transports/grpc_asyncio.py b/packages/google-cloud-billing/google/cloud/billing_v1/services/cloud_catalog/transports/grpc_asyncio.py index 719f9f7876e2..424234636e6a 100644 --- a/packages/google-cloud-billing/google/cloud/billing_v1/services/cloud_catalog/transports/grpc_asyncio.py +++ b/packages/google-cloud-billing/google/cloud/billing_v1/services/cloud_catalog/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.billing_v1.types import cloud_catalog from .base import DEFAULT_CLIENT_INFO, CloudCatalogTransport from .grpc import CloudCatalogGrpcTransport +try: + from google.api_core import client_logging # 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.billing.v1.CloudCatalog", + "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.billing.v1.CloudCatalog", + "rpcName": str(client_call_details.method), + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class CloudCatalogGrpcAsyncIOTransport(CloudCatalogTransport): """gRPC AsyncIO backend transport for CloudCatalog. @@ -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 @@ -266,7 +351,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.billing.v1.CloudCatalog/ListServices", request_serializer=cloud_catalog.ListServicesRequest.serialize, response_deserializer=cloud_catalog.ListServicesResponse.deserialize, @@ -295,7 +380,7 @@ def list_skus( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_skus" not in self._stubs: - self._stubs["list_skus"] = self.grpc_channel.unary_unary( + self._stubs["list_skus"] = self._logged_channel.unary_unary( "/google.cloud.billing.v1.CloudCatalog/ListSkus", request_serializer=cloud_catalog.ListSkusRequest.serialize, response_deserializer=cloud_catalog.ListSkusResponse.deserialize, @@ -323,7 +408,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-billing/google/cloud/billing_v1/services/cloud_catalog/transports/rest.py b/packages/google-cloud-billing/google/cloud/billing_v1/services/cloud_catalog/transports/rest.py index bd28ba537b55..81482d2bce28 100644 --- a/packages/google-cloud-billing/google/cloud/billing_v1/services/cloud_catalog/transports/rest.py +++ b/packages/google-cloud-billing/google/cloud/billing_v1/services/cloud_catalog/transports/rest.py @@ -13,9 +13,9 @@ # See the License for the specific language governing permissions and # limitations under the License. # - import dataclasses import json # type: ignore +import logging from typing import Any, Callable, Dict, List, Optional, Sequence, Tuple, Union import warnings @@ -37,6 +37,14 @@ except AttributeError: # pragma: NO COVER OptionalRetry = Union[retries.Retry, object, None] # type: ignore +try: + from google.api_core import client_logging # type: ignore + + CLIENT_LOGGING_SUPPORTED = True # pragma: NO COVER +except ImportError: # pragma: NO COVER + CLIENT_LOGGING_SUPPORTED = False + +_LOGGER = logging.getLogger(__name__) DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo( gapic_version=BASE_DEFAULT_CLIENT_INFO.gapic_version, @@ -85,8 +93,10 @@ def post_list_skus(self, response): def pre_list_services( self, request: cloud_catalog.ListServicesRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[cloud_catalog.ListServicesRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + cloud_catalog.ListServicesRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for list_services Override in a subclass to manipulate the request or metadata @@ -108,8 +118,8 @@ def post_list_services( def pre_list_skus( self, request: cloud_catalog.ListSkusRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[cloud_catalog.ListSkusRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[cloud_catalog.ListSkusRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for list_skus 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]]] = (), ) -> cloud_catalog.ListServicesResponse: r"""Call the list services method over HTTP. @@ -261,8 +271,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.cloud_catalog.ListServicesResponse: @@ -272,6 +284,7 @@ def __call__( http_options = ( _BaseCloudCatalogRestTransport._BaseListServices._get_http_options() ) + request, metadata = self._interceptor.pre_list_services(request, metadata) transcoded_request = _BaseCloudCatalogRestTransport._BaseListServices._get_transcoded_request( http_options, 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.cloud.billing_v1.CloudCatalogClient.ListServices", + extra={ + "serviceName": "google.cloud.billing.v1.CloudCatalog", + "rpcName": "ListServices", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = CloudCatalogRestTransport._ListServices._get_response( self._host, @@ -304,7 +344,31 @@ def __call__( pb_resp = cloud_catalog.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 = cloud_catalog.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.billing_v1.CloudCatalogClient.list_services", + extra={ + "serviceName": "google.cloud.billing.v1.CloudCatalog", + "rpcName": "ListServices", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ListSkus(_BaseCloudCatalogRestTransport._BaseListSkus, CloudCatalogRestStub): @@ -339,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]]] = (), ) -> cloud_catalog.ListSkusResponse: r"""Call the list skus method over HTTP. @@ -349,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: ~.cloud_catalog.ListSkusResponse: @@ -360,6 +426,7 @@ def __call__( http_options = ( _BaseCloudCatalogRestTransport._BaseListSkus._get_http_options() ) + request, metadata = self._interceptor.pre_list_skus(request, metadata) transcoded_request = ( _BaseCloudCatalogRestTransport._BaseListSkus._get_transcoded_request( @@ -374,6 +441,33 @@ def __call__( ) ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.billing_v1.CloudCatalogClient.ListSkus", + extra={ + "serviceName": "google.cloud.billing.v1.CloudCatalog", + "rpcName": "ListSkus", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = CloudCatalogRestTransport._ListSkus._get_response( self._host, @@ -394,7 +488,29 @@ def __call__( pb_resp = cloud_catalog.ListSkusResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_skus(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = cloud_catalog.ListSkusResponse.to_json(response) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.billing_v1.CloudCatalogClient.list_skus", + extra={ + "serviceName": "google.cloud.billing.v1.CloudCatalog", + "rpcName": "ListSkus", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp @property diff --git a/packages/google-cloud-billing/samples/generated_samples/snippet_metadata_google.cloud.billing.v1.json b/packages/google-cloud-billing/samples/generated_samples/snippet_metadata_google.cloud.billing.v1.json index 94a6ddeb90f9..027b84af0571 100644 --- a/packages/google-cloud-billing/samples/generated_samples/snippet_metadata_google.cloud.billing.v1.json +++ b/packages/google-cloud-billing/samples/generated_samples/snippet_metadata_google.cloud.billing.v1.json @@ -51,7 +51,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.billing_v1.types.BillingAccount", @@ -135,7 +135,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.billing_v1.types.BillingAccount", @@ -216,7 +216,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.billing_v1.types.BillingAccount", @@ -296,7 +296,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.billing_v1.types.BillingAccount", @@ -377,7 +377,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.iam.v1.policy_pb2.Policy", @@ -457,7 +457,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.iam.v1.policy_pb2.Policy", @@ -538,7 +538,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.billing_v1.types.ProjectBillingInfo", @@ -618,7 +618,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.billing_v1.types.ProjectBillingInfo", @@ -699,7 +699,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.billing_v1.services.cloud_billing.pagers.ListBillingAccountsAsyncPager", @@ -779,7 +779,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.billing_v1.services.cloud_billing.pagers.ListBillingAccountsPager", @@ -860,7 +860,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.billing_v1.services.cloud_billing.pagers.ListProjectBillingInfoAsyncPager", @@ -940,7 +940,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.billing_v1.services.cloud_billing.pagers.ListProjectBillingInfoPager", @@ -1017,7 +1017,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.billing_v1.types.BillingAccount", @@ -1093,7 +1093,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.billing_v1.types.BillingAccount", @@ -1174,7 +1174,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.iam.v1.policy_pb2.Policy", @@ -1254,7 +1254,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.iam.v1.policy_pb2.Policy", @@ -1339,7 +1339,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.iam.v1.iam_policy_pb2.TestIamPermissionsResponse", @@ -1423,7 +1423,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.iam.v1.iam_policy_pb2.TestIamPermissionsResponse", @@ -1508,7 +1508,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.billing_v1.types.BillingAccount", @@ -1592,7 +1592,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.billing_v1.types.BillingAccount", @@ -1677,7 +1677,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.billing_v1.types.ProjectBillingInfo", @@ -1761,7 +1761,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.billing_v1.types.ProjectBillingInfo", @@ -1838,7 +1838,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.billing_v1.services.cloud_catalog.pagers.ListServicesAsyncPager", @@ -1914,7 +1914,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.billing_v1.services.cloud_catalog.pagers.ListServicesPager", @@ -1995,7 +1995,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.billing_v1.services.cloud_catalog.pagers.ListSkusAsyncPager", @@ -2075,7 +2075,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.billing_v1.services.cloud_catalog.pagers.ListSkusPager", diff --git a/packages/google-cloud-billing/tests/unit/gapic/billing_v1/test_cloud_billing.py b/packages/google-cloud-billing/tests/unit/gapic/billing_v1/test_cloud_billing.py index 287d68577f3b..cfb8fc6b73b5 100644 --- a/packages/google-cloud-billing/tests/unit/gapic/billing_v1/test_cloud_billing.py +++ b/packages/google-cloud-billing/tests/unit/gapic/billing_v1/test_cloud_billing.py @@ -5274,6 +5274,7 @@ def test_get_billing_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_billing_account(request) @@ -5319,6 +5320,7 @@ def test_get_billing_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_billing_account(**mock_args) @@ -5415,6 +5417,7 @@ def test_list_billing_accounts_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.list_billing_accounts(**mock_args) @@ -5615,6 +5618,7 @@ def test_update_billing_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_billing_account(request) @@ -5669,6 +5673,7 @@ def test_update_billing_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_billing_account(**mock_args) @@ -5802,6 +5807,7 @@ def test_create_billing_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.create_billing_account(request) @@ -5848,6 +5854,7 @@ def test_create_billing_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.create_billing_account(**mock_args) @@ -5990,6 +5997,7 @@ def test_list_project_billing_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.list_project_billing_info(request) @@ -6043,6 +6051,7 @@ def test_list_project_billing_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.list_project_billing_info(**mock_args) @@ -6240,6 +6249,7 @@ def test_get_project_billing_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_project_billing_info(request) @@ -6285,6 +6295,7 @@ def test_get_project_billing_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_project_billing_info(**mock_args) @@ -6420,6 +6431,7 @@ def test_update_project_billing_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.update_project_billing_info(request) @@ -6466,6 +6478,7 @@ def test_update_project_billing_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.update_project_billing_info(**mock_args) @@ -6596,6 +6609,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) @@ -6639,6 +6653,7 @@ def test_get_iam_policy_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.get_iam_policy(**mock_args) @@ -6768,6 +6783,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) @@ -6819,6 +6835,7 @@ def test_set_iam_policy_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.set_iam_policy(**mock_args) @@ -6956,6 +6973,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) @@ -7008,6 +7026,7 @@ def test_test_iam_permissions_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.test_iam_permissions(**mock_args) @@ -7149,6 +7168,7 @@ def test_move_billing_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.move_billing_account(request) @@ -7914,6 +7934,7 @@ def test_get_billing_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_billing_account(request) @@ -7954,6 +7975,7 @@ def test_get_billing_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_billing_account(request) # Establish that the response is the type that we expect. @@ -7999,6 +8021,7 @@ def test_get_billing_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 = cloud_billing.BillingAccount.to_json( cloud_billing.BillingAccount() ) @@ -8045,6 +8068,7 @@ def test_list_billing_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_billing_accounts(request) @@ -8080,6 +8104,7 @@ def test_list_billing_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_billing_accounts(request) # Establish that the response is the type that we expect. @@ -8120,6 +8145,7 @@ def test_list_billing_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 = cloud_billing.ListBillingAccountsResponse.to_json( cloud_billing.ListBillingAccountsResponse() ) @@ -8166,6 +8192,7 @@ def test_update_billing_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_billing_account(request) @@ -8281,6 +8308,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.update_billing_account(request) # Establish that the response is the type that we expect. @@ -8326,6 +8354,7 @@ def test_update_billing_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 = cloud_billing.BillingAccount.to_json( cloud_billing.BillingAccount() ) @@ -8372,6 +8401,7 @@ def test_create_billing_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.create_billing_account(request) @@ -8489,6 +8519,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.create_billing_account(request) # Establish that the response is the type that we expect. @@ -8534,6 +8565,7 @@ def test_create_billing_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 = cloud_billing.BillingAccount.to_json( cloud_billing.BillingAccount() ) @@ -8580,6 +8612,7 @@ def test_list_project_billing_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.list_project_billing_info(request) @@ -8615,6 +8648,7 @@ def test_list_project_billing_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.list_project_billing_info(request) # Establish that the response is the type that we expect. @@ -8655,6 +8689,7 @@ def test_list_project_billing_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 = cloud_billing.ListProjectBillingInfoResponse.to_json( cloud_billing.ListProjectBillingInfoResponse() ) @@ -8701,6 +8736,7 @@ def test_get_project_billing_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_project_billing_info(request) @@ -8739,6 +8775,7 @@ def test_get_project_billing_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_project_billing_info(request) # Establish that the response is the type that we expect. @@ -8782,6 +8819,7 @@ def test_get_project_billing_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 = cloud_billing.ProjectBillingInfo.to_json( cloud_billing.ProjectBillingInfo() ) @@ -8828,6 +8866,7 @@ def test_update_project_billing_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.update_project_billing_info(request) @@ -8943,6 +8982,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_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_billing_info(request) # Establish that the response is the type that we expect. @@ -8986,6 +9026,7 @@ def test_update_project_billing_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 = cloud_billing.ProjectBillingInfo.to_json( cloud_billing.ProjectBillingInfo() ) @@ -9032,6 +9073,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) @@ -9065,6 +9107,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. @@ -9104,6 +9147,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 @@ -9148,6 +9192,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) @@ -9181,6 +9226,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. @@ -9220,6 +9266,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 @@ -9264,6 +9311,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) @@ -9296,6 +9344,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. @@ -9334,6 +9383,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() ) @@ -9380,6 +9430,7 @@ def test_move_billing_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.move_billing_account(request) @@ -9420,6 +9471,7 @@ def test_move_billing_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.move_billing_account(request) # Establish that the response is the type that we expect. @@ -9465,6 +9517,7 @@ def test_move_billing_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 = cloud_billing.BillingAccount.to_json( cloud_billing.BillingAccount() ) diff --git a/packages/google-cloud-billing/tests/unit/gapic/billing_v1/test_cloud_catalog.py b/packages/google-cloud-billing/tests/unit/gapic/billing_v1/test_cloud_catalog.py index e653309e24b8..e49ec3f945d9 100644 --- a/packages/google-cloud-billing/tests/unit/gapic/billing_v1/test_cloud_catalog.py +++ b/packages/google-cloud-billing/tests/unit/gapic/billing_v1/test_cloud_catalog.py @@ -2141,6 +2141,7 @@ def test_list_skus_rest_required_fields(request_type=cloud_catalog.ListSkusReque response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.list_skus(request) @@ -2197,6 +2198,7 @@ def test_list_skus_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.list_skus(**mock_args) @@ -2527,6 +2529,7 @@ def test_list_services_rest_bad_request(request_type=cloud_catalog.ListServicesR response_value.status_code = 400 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) @@ -2562,6 +2565,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. @@ -2602,6 +2606,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 = cloud_catalog.ListServicesResponse.to_json( cloud_catalog.ListServicesResponse() ) @@ -2646,6 +2651,7 @@ def test_list_skus_rest_bad_request(request_type=cloud_catalog.ListSkusRequest): response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.list_skus(request) @@ -2681,6 +2687,7 @@ def test_list_skus_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.list_skus(request) # Establish that the response is the type that we expect. @@ -2719,6 +2726,7 @@ def test_list_skus_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = cloud_catalog.ListSkusResponse.to_json( cloud_catalog.ListSkusResponse() ) diff --git a/packages/google-cloud-binary-authorization/google/cloud/binaryauthorization/gapic_version.py b/packages/google-cloud-binary-authorization/google/cloud/binaryauthorization/gapic_version.py index b50cada0b7ee..558c8aab67c5 100644 --- a/packages/google-cloud-binary-authorization/google/cloud/binaryauthorization/gapic_version.py +++ b/packages/google-cloud-binary-authorization/google/cloud/binaryauthorization/gapic_version.py @@ -13,4 +13,4 @@ # See the License for the specific language governing permissions and # limitations under the License. # -__version__ = "1.11.1" # {x-release-please-version} +__version__ = "0.0.0" # {x-release-please-version} diff --git a/packages/google-cloud-binary-authorization/google/cloud/binaryauthorization_v1/gapic_version.py b/packages/google-cloud-binary-authorization/google/cloud/binaryauthorization_v1/gapic_version.py index b50cada0b7ee..558c8aab67c5 100644 --- a/packages/google-cloud-binary-authorization/google/cloud/binaryauthorization_v1/gapic_version.py +++ b/packages/google-cloud-binary-authorization/google/cloud/binaryauthorization_v1/gapic_version.py @@ -13,4 +13,4 @@ # See the License for the specific language governing permissions and # limitations under the License. # -__version__ = "1.11.1" # {x-release-please-version} +__version__ = "0.0.0" # {x-release-please-version} diff --git a/packages/google-cloud-binary-authorization/google/cloud/binaryauthorization_v1/services/binauthz_management_service_v1/async_client.py b/packages/google-cloud-binary-authorization/google/cloud/binaryauthorization_v1/services/binauthz_management_service_v1/async_client.py index 20913d2aee62..7917b16e2502 100644 --- a/packages/google-cloud-binary-authorization/google/cloud/binaryauthorization_v1/services/binauthz_management_service_v1/async_client.py +++ b/packages/google-cloud-binary-authorization/google/cloud/binaryauthorization_v1/services/binauthz_management_service_v1/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, BinauthzManagementServiceV1Transport from .transports.grpc_asyncio import BinauthzManagementServiceV1GrpcAsyncIOTransport +try: + from google.api_core import client_logging # type: ignore + + CLIENT_LOGGING_SUPPORTED = True # pragma: NO COVER +except ImportError: # pragma: NO COVER + CLIENT_LOGGING_SUPPORTED = False + +_LOGGER = std_logging.getLogger(__name__) + class BinauthzManagementServiceV1AsyncClient: """Google Cloud Management Service for Binary Authorization admission @@ -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.binaryauthorization_v1.BinauthzManagementServiceV1AsyncClient`.", + extra={ + "serviceName": "google.cloud.binaryauthorization.v1.BinauthzManagementServiceV1", + "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.binaryauthorization.v1.BinauthzManagementServiceV1", + "credentialsType": None, + }, + ) + async def get_policy( self, request: Optional[Union[service.GetPolicyRequest, dict]] = None, @@ -290,7 +322,7 @@ async def get_policy( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> resources.Policy: r"""A [policy][google.cloud.binaryauthorization.v1.Policy] specifies the [attestors][google.cloud.binaryauthorization.v1.Attestor] @@ -345,8 +377,10 @@ async def sample_get_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.binaryauthorization_v1.types.Policy: @@ -407,7 +441,7 @@ async def update_policy( policy: Optional[resources.Policy] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> resources.Policy: r"""Creates or updates a project's [policy][google.cloud.binaryauthorization.v1.Policy], and @@ -466,8 +500,10 @@ async def sample_update_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.binaryauthorization_v1.types.Policy: @@ -532,7 +568,7 @@ async def create_attestor( attestor: Optional[resources.Attestor] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> resources.Attestor: r"""Creates an [attestor][google.cloud.binaryauthorization.v1.Attestor], and @@ -608,8 +644,10 @@ async def sample_create_attestor(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.binaryauthorization_v1.types.Attestor: @@ -675,7 +713,7 @@ async def get_attestor( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> resources.Attestor: r"""Gets an [attestor][google.cloud.binaryauthorization.v1.Attestor]. @@ -724,8 +762,10 @@ async def sample_get_attestor(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.binaryauthorization_v1.types.Attestor: @@ -787,7 +827,7 @@ async def update_attestor( attestor: Optional[resources.Attestor] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> resources.Attestor: r"""Updates an [attestor][google.cloud.binaryauthorization.v1.Attestor]. @@ -843,8 +883,10 @@ async def sample_update_attestor(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.binaryauthorization_v1.types.Attestor: @@ -908,7 +950,7 @@ async def list_attestors( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListAttestorsAsyncPager: r"""Lists [attestors][google.cloud.binaryauthorization.v1.Attestor]. Returns INVALID_ARGUMENT if the project does not exist. @@ -956,8 +998,10 @@ async def sample_list_attestors(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.binaryauthorization_v1.services.binauthz_management_service_v1.pagers.ListAttestorsAsyncPager: @@ -1032,7 +1076,7 @@ async def delete_attestor( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.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 [attestor][google.cloud.binaryauthorization.v1.Attestor]. @@ -1078,8 +1122,10 @@ async def sample_delete_attestor(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. """ # Create or coerce a protobuf request object. # - Quick check: If we got a request object, we should *not* have diff --git a/packages/google-cloud-binary-authorization/google/cloud/binaryauthorization_v1/services/binauthz_management_service_v1/client.py b/packages/google-cloud-binary-authorization/google/cloud/binaryauthorization_v1/services/binauthz_management_service_v1/client.py index bdc3fbb0f4ef..83e9804a7776 100644 --- a/packages/google-cloud-binary-authorization/google/cloud/binaryauthorization_v1/services/binauthz_management_service_v1/client.py +++ b/packages/google-cloud-binary-authorization/google/cloud/binaryauthorization_v1/services/binauthz_management_service_v1/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.binaryauthorization_v1.services.binauthz_management_service_v1 import ( @@ -611,6 +621,10 @@ def __init__( # Initialize the universe domain validation. self._is_universe_domain_valid = False + if CLIENT_LOGGING_SUPPORTED: # pragma: NO COVER + # Setup logging. + client_logging.initialize_logging() + api_key_value = getattr(self._client_options, "api_key", None) if api_key_value and credentials: raise ValueError( @@ -679,6 +693,29 @@ def __init__( api_audience=self._client_options.api_audience, ) + if "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.binaryauthorization_v1.BinauthzManagementServiceV1Client`.", + extra={ + "serviceName": "google.cloud.binaryauthorization.v1.BinauthzManagementServiceV1", + "universeDomain": getattr( + self._transport._credentials, "universe_domain", "" + ), + "credentialsType": f"{type(self._transport._credentials).__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.binaryauthorization.v1.BinauthzManagementServiceV1", + "credentialsType": None, + }, + ) + def get_policy( self, request: Optional[Union[service.GetPolicyRequest, dict]] = None, @@ -686,7 +723,7 @@ def get_policy( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> resources.Policy: r"""A [policy][google.cloud.binaryauthorization.v1.Policy] specifies the [attestors][google.cloud.binaryauthorization.v1.Attestor] @@ -741,8 +778,10 @@ def sample_get_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.binaryauthorization_v1.types.Policy: @@ -800,7 +839,7 @@ def update_policy( policy: Optional[resources.Policy] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> resources.Policy: r"""Creates or updates a project's [policy][google.cloud.binaryauthorization.v1.Policy], and @@ -859,8 +898,10 @@ def sample_update_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.binaryauthorization_v1.types.Policy: @@ -922,7 +963,7 @@ def create_attestor( attestor: Optional[resources.Attestor] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> resources.Attestor: r"""Creates an [attestor][google.cloud.binaryauthorization.v1.Attestor], and @@ -998,8 +1039,10 @@ def sample_create_attestor(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.binaryauthorization_v1.types.Attestor: @@ -1062,7 +1105,7 @@ def get_attestor( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> resources.Attestor: r"""Gets an [attestor][google.cloud.binaryauthorization.v1.Attestor]. @@ -1111,8 +1154,10 @@ def sample_get_attestor(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.binaryauthorization_v1.types.Attestor: @@ -1171,7 +1216,7 @@ def update_attestor( attestor: Optional[resources.Attestor] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> resources.Attestor: r"""Updates an [attestor][google.cloud.binaryauthorization.v1.Attestor]. @@ -1227,8 +1272,10 @@ def sample_update_attestor(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.binaryauthorization_v1.types.Attestor: @@ -1289,7 +1336,7 @@ def list_attestors( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListAttestorsPager: r"""Lists [attestors][google.cloud.binaryauthorization.v1.Attestor]. Returns INVALID_ARGUMENT if the project does not exist. @@ -1337,8 +1384,10 @@ def sample_list_attestors(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.binaryauthorization_v1.services.binauthz_management_service_v1.pagers.ListAttestorsPager: @@ -1410,7 +1459,7 @@ def delete_attestor( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.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 [attestor][google.cloud.binaryauthorization.v1.Attestor]. @@ -1456,8 +1505,10 @@ def sample_delete_attestor(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. """ # Create or coerce a protobuf request object. # - Quick check: If we got a request object, we should *not* have diff --git a/packages/google-cloud-binary-authorization/google/cloud/binaryauthorization_v1/services/binauthz_management_service_v1/pagers.py b/packages/google-cloud-binary-authorization/google/cloud/binaryauthorization_v1/services/binauthz_management_service_v1/pagers.py index d0f21af43b61..81dec3d20259 100644 --- a/packages/google-cloud-binary-authorization/google/cloud/binaryauthorization_v1/services/binauthz_management_service_v1/pagers.py +++ b/packages/google-cloud-binary-authorization/google/cloud/binaryauthorization_v1/services/binauthz_management_service_v1/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.ListAttestorsRequest(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.ListAttestorsRequest(request) diff --git a/packages/google-cloud-binary-authorization/google/cloud/binaryauthorization_v1/services/binauthz_management_service_v1/transports/grpc.py b/packages/google-cloud-binary-authorization/google/cloud/binaryauthorization_v1/services/binauthz_management_service_v1/transports/grpc.py index 375f4b06afa9..6b2a8744b352 100644 --- a/packages/google-cloud-binary-authorization/google/cloud/binaryauthorization_v1/services/binauthz_management_service_v1/transports/grpc.py +++ b/packages/google-cloud-binary-authorization/google/cloud/binaryauthorization_v1/services/binauthz_management_service_v1/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.binaryauthorization_v1.types import resources, service from .base import DEFAULT_CLIENT_INFO, BinauthzManagementServiceV1Transport +try: + from google.api_core import client_logging # 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.binaryauthorization.v1.BinauthzManagementServiceV1", + "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.binaryauthorization.v1.BinauthzManagementServiceV1", + "rpcName": client_call_details.method, + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class BinauthzManagementServiceV1GrpcTransport(BinauthzManagementServiceV1Transport): """gRPC backend transport for BinauthzManagementServiceV1. @@ -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 @@ -268,7 +354,7 @@ def get_policy(self) -> Callable[[service.GetPolicyRequest], resources.Policy]: # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_policy" not in self._stubs: - self._stubs["get_policy"] = self.grpc_channel.unary_unary( + self._stubs["get_policy"] = self._logged_channel.unary_unary( "/google.cloud.binaryauthorization.v1.BinauthzManagementServiceV1/GetPolicy", request_serializer=service.GetPolicyRequest.serialize, response_deserializer=resources.Policy.deserialize, @@ -301,7 +387,7 @@ def update_policy( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_policy" not in self._stubs: - self._stubs["update_policy"] = self.grpc_channel.unary_unary( + self._stubs["update_policy"] = self._logged_channel.unary_unary( "/google.cloud.binaryauthorization.v1.BinauthzManagementServiceV1/UpdatePolicy", request_serializer=service.UpdatePolicyRequest.serialize, response_deserializer=resources.Policy.deserialize, @@ -334,7 +420,7 @@ def create_attestor( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_attestor" not in self._stubs: - self._stubs["create_attestor"] = self.grpc_channel.unary_unary( + self._stubs["create_attestor"] = self._logged_channel.unary_unary( "/google.cloud.binaryauthorization.v1.BinauthzManagementServiceV1/CreateAttestor", request_serializer=service.CreateAttestorRequest.serialize, response_deserializer=resources.Attestor.deserialize, @@ -364,7 +450,7 @@ def get_attestor( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_attestor" not in self._stubs: - self._stubs["get_attestor"] = self.grpc_channel.unary_unary( + self._stubs["get_attestor"] = self._logged_channel.unary_unary( "/google.cloud.binaryauthorization.v1.BinauthzManagementServiceV1/GetAttestor", request_serializer=service.GetAttestorRequest.serialize, response_deserializer=resources.Attestor.deserialize, @@ -394,7 +480,7 @@ def update_attestor( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_attestor" not in self._stubs: - self._stubs["update_attestor"] = self.grpc_channel.unary_unary( + self._stubs["update_attestor"] = self._logged_channel.unary_unary( "/google.cloud.binaryauthorization.v1.BinauthzManagementServiceV1/UpdateAttestor", request_serializer=service.UpdateAttestorRequest.serialize, response_deserializer=resources.Attestor.deserialize, @@ -421,7 +507,7 @@ def list_attestors( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_attestors" not in self._stubs: - self._stubs["list_attestors"] = self.grpc_channel.unary_unary( + self._stubs["list_attestors"] = self._logged_channel.unary_unary( "/google.cloud.binaryauthorization.v1.BinauthzManagementServiceV1/ListAttestors", request_serializer=service.ListAttestorsRequest.serialize, response_deserializer=service.ListAttestorsResponse.deserialize, @@ -451,7 +537,7 @@ def delete_attestor( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_attestor" not in self._stubs: - self._stubs["delete_attestor"] = self.grpc_channel.unary_unary( + self._stubs["delete_attestor"] = self._logged_channel.unary_unary( "/google.cloud.binaryauthorization.v1.BinauthzManagementServiceV1/DeleteAttestor", request_serializer=service.DeleteAttestorRequest.serialize, response_deserializer=empty_pb2.Empty.FromString, @@ -459,7 +545,7 @@ def delete_attestor( return self._stubs["delete_attestor"] def close(self): - self.grpc_channel.close() + self._logged_channel.close() @property def kind(self) -> str: diff --git a/packages/google-cloud-binary-authorization/google/cloud/binaryauthorization_v1/services/binauthz_management_service_v1/transports/grpc_asyncio.py b/packages/google-cloud-binary-authorization/google/cloud/binaryauthorization_v1/services/binauthz_management_service_v1/transports/grpc_asyncio.py index a11bffb7e536..861bf8c9a807 100644 --- a/packages/google-cloud-binary-authorization/google/cloud/binaryauthorization_v1/services/binauthz_management_service_v1/transports/grpc_asyncio.py +++ b/packages/google-cloud-binary-authorization/google/cloud/binaryauthorization_v1/services/binauthz_management_service_v1/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.binaryauthorization_v1.types import resources, service from .base import DEFAULT_CLIENT_INFO, BinauthzManagementServiceV1Transport from .grpc import BinauthzManagementServiceV1GrpcTransport +try: + from google.api_core import client_logging # 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.binaryauthorization.v1.BinauthzManagementServiceV1", + "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.binaryauthorization.v1.BinauthzManagementServiceV1", + "rpcName": str(client_call_details.method), + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class BinauthzManagementServiceV1GrpcAsyncIOTransport( BinauthzManagementServiceV1Transport @@ -235,10 +317,13 @@ def __init__( ], ) - # Wrap messages. This must be done after self._grpc_channel exists + self._interceptor = _LoggingClientAIOInterceptor() + self._grpc_channel._unary_unary_interceptors.append(self._interceptor) + self._logged_channel = self._grpc_channel self._wrap_with_kind = ( "kind" in inspect.signature(gapic_v1.method_async.wrap_method).parameters ) + # Wrap messages. This must be done after self._logged_channel exists self._prep_wrapped_messages(client_info) @property @@ -280,7 +365,7 @@ def get_policy( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_policy" not in self._stubs: - self._stubs["get_policy"] = self.grpc_channel.unary_unary( + self._stubs["get_policy"] = self._logged_channel.unary_unary( "/google.cloud.binaryauthorization.v1.BinauthzManagementServiceV1/GetPolicy", request_serializer=service.GetPolicyRequest.serialize, response_deserializer=resources.Policy.deserialize, @@ -313,7 +398,7 @@ def update_policy( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_policy" not in self._stubs: - self._stubs["update_policy"] = self.grpc_channel.unary_unary( + self._stubs["update_policy"] = self._logged_channel.unary_unary( "/google.cloud.binaryauthorization.v1.BinauthzManagementServiceV1/UpdatePolicy", request_serializer=service.UpdatePolicyRequest.serialize, response_deserializer=resources.Policy.deserialize, @@ -346,7 +431,7 @@ def create_attestor( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_attestor" not in self._stubs: - self._stubs["create_attestor"] = self.grpc_channel.unary_unary( + self._stubs["create_attestor"] = self._logged_channel.unary_unary( "/google.cloud.binaryauthorization.v1.BinauthzManagementServiceV1/CreateAttestor", request_serializer=service.CreateAttestorRequest.serialize, response_deserializer=resources.Attestor.deserialize, @@ -376,7 +461,7 @@ def get_attestor( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_attestor" not in self._stubs: - self._stubs["get_attestor"] = self.grpc_channel.unary_unary( + self._stubs["get_attestor"] = self._logged_channel.unary_unary( "/google.cloud.binaryauthorization.v1.BinauthzManagementServiceV1/GetAttestor", request_serializer=service.GetAttestorRequest.serialize, response_deserializer=resources.Attestor.deserialize, @@ -406,7 +491,7 @@ def update_attestor( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_attestor" not in self._stubs: - self._stubs["update_attestor"] = self.grpc_channel.unary_unary( + self._stubs["update_attestor"] = self._logged_channel.unary_unary( "/google.cloud.binaryauthorization.v1.BinauthzManagementServiceV1/UpdateAttestor", request_serializer=service.UpdateAttestorRequest.serialize, response_deserializer=resources.Attestor.deserialize, @@ -435,7 +520,7 @@ def list_attestors( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_attestors" not in self._stubs: - self._stubs["list_attestors"] = self.grpc_channel.unary_unary( + self._stubs["list_attestors"] = self._logged_channel.unary_unary( "/google.cloud.binaryauthorization.v1.BinauthzManagementServiceV1/ListAttestors", request_serializer=service.ListAttestorsRequest.serialize, response_deserializer=service.ListAttestorsResponse.deserialize, @@ -465,7 +550,7 @@ def delete_attestor( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_attestor" not in self._stubs: - self._stubs["delete_attestor"] = self.grpc_channel.unary_unary( + self._stubs["delete_attestor"] = self._logged_channel.unary_unary( "/google.cloud.binaryauthorization.v1.BinauthzManagementServiceV1/DeleteAttestor", request_serializer=service.DeleteAttestorRequest.serialize, response_deserializer=empty_pb2.Empty.FromString, @@ -578,7 +663,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-binary-authorization/google/cloud/binaryauthorization_v1/services/binauthz_management_service_v1/transports/rest.py b/packages/google-cloud-binary-authorization/google/cloud/binaryauthorization_v1/services/binauthz_management_service_v1/transports/rest.py index bee69a8a6482..a2ecdb27bba1 100644 --- a/packages/google-cloud-binary-authorization/google/cloud/binaryauthorization_v1/services/binauthz_management_service_v1/transports/rest.py +++ b/packages/google-cloud-binary-authorization/google/cloud/binaryauthorization_v1/services/binauthz_management_service_v1/transports/rest.py @@ -13,9 +13,9 @@ # See the License for the specific language governing permissions and # limitations 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, @@ -122,8 +130,8 @@ def post_update_policy(self, response): def pre_create_attestor( self, request: service.CreateAttestorRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[service.CreateAttestorRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[service.CreateAttestorRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for create_attestor Override in a subclass to manipulate the request or metadata @@ -143,8 +151,8 @@ def post_create_attestor(self, response: resources.Attestor) -> resources.Attest def pre_delete_attestor( self, request: service.DeleteAttestorRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[service.DeleteAttestorRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[service.DeleteAttestorRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for delete_attestor Override in a subclass to manipulate the request or metadata @@ -153,8 +161,10 @@ def pre_delete_attestor( return request, metadata def pre_get_attestor( - self, request: service.GetAttestorRequest, metadata: Sequence[Tuple[str, str]] - ) -> Tuple[service.GetAttestorRequest, Sequence[Tuple[str, str]]]: + self, + request: service.GetAttestorRequest, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[service.GetAttestorRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for get_attestor Override in a subclass to manipulate the request or metadata @@ -172,8 +182,10 @@ def post_get_attestor(self, response: resources.Attestor) -> resources.Attestor: return response def pre_get_policy( - self, request: service.GetPolicyRequest, metadata: Sequence[Tuple[str, str]] - ) -> Tuple[service.GetPolicyRequest, Sequence[Tuple[str, str]]]: + self, + request: service.GetPolicyRequest, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[service.GetPolicyRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for get_policy Override in a subclass to manipulate the request or metadata @@ -191,8 +203,10 @@ def post_get_policy(self, response: resources.Policy) -> resources.Policy: return response def pre_list_attestors( - self, request: service.ListAttestorsRequest, metadata: Sequence[Tuple[str, str]] - ) -> Tuple[service.ListAttestorsRequest, Sequence[Tuple[str, str]]]: + self, + request: service.ListAttestorsRequest, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[service.ListAttestorsRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for list_attestors Override in a subclass to manipulate the request or metadata @@ -214,8 +228,8 @@ def post_list_attestors( def pre_update_attestor( self, request: service.UpdateAttestorRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[service.UpdateAttestorRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[service.UpdateAttestorRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for update_attestor Override in a subclass to manipulate the request or metadata @@ -233,8 +247,10 @@ def post_update_attestor(self, response: resources.Attestor) -> resources.Attest return response def pre_update_policy( - self, request: service.UpdatePolicyRequest, metadata: Sequence[Tuple[str, str]] - ) -> Tuple[service.UpdatePolicyRequest, Sequence[Tuple[str, str]]]: + self, + request: service.UpdatePolicyRequest, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[service.UpdatePolicyRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for update_policy Override in a subclass to manipulate the request or metadata @@ -382,7 +398,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> resources.Attestor: r"""Call the create attestor method over HTTP. @@ -393,8 +409,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.resources.Attestor: @@ -408,6 +426,7 @@ def __call__( http_options = ( _BaseBinauthzManagementServiceV1RestTransport._BaseCreateAttestor._get_http_options() ) + request, metadata = self._interceptor.pre_create_attestor(request, metadata) transcoded_request = _BaseBinauthzManagementServiceV1RestTransport._BaseCreateAttestor._get_transcoded_request( http_options, request @@ -422,6 +441,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.binaryauthorization_v1.BinauthzManagementServiceV1Client.CreateAttestor", + extra={ + "serviceName": "google.cloud.binaryauthorization.v1.BinauthzManagementServiceV1", + "rpcName": "CreateAttestor", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ( BinauthzManagementServiceV1RestTransport._CreateAttestor._get_response( @@ -445,7 +491,29 @@ def __call__( pb_resp = resources.Attestor.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_create_attestor(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = resources.Attestor.to_json(response) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.binaryauthorization_v1.BinauthzManagementServiceV1Client.create_attestor", + extra={ + "serviceName": "google.cloud.binaryauthorization.v1.BinauthzManagementServiceV1", + "rpcName": "CreateAttestor", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _DeleteAttestor( @@ -483,7 +551,7 @@ 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 attestor method over HTTP. @@ -494,13 +562,16 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. """ http_options = ( _BaseBinauthzManagementServiceV1RestTransport._BaseDeleteAttestor._get_http_options() ) + request, metadata = self._interceptor.pre_delete_attestor(request, metadata) transcoded_request = _BaseBinauthzManagementServiceV1RestTransport._BaseDeleteAttestor._get_transcoded_request( http_options, request @@ -511,6 +582,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.binaryauthorization_v1.BinauthzManagementServiceV1Client.DeleteAttestor", + extra={ + "serviceName": "google.cloud.binaryauthorization.v1.BinauthzManagementServiceV1", + "rpcName": "DeleteAttestor", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ( BinauthzManagementServiceV1RestTransport._DeleteAttestor._get_response( @@ -563,7 +661,7 @@ 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.Attestor: r"""Call the get attestor method over HTTP. @@ -574,8 +672,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each 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.Attestor: @@ -589,6 +689,7 @@ def __call__( http_options = ( _BaseBinauthzManagementServiceV1RestTransport._BaseGetAttestor._get_http_options() ) + request, metadata = self._interceptor.pre_get_attestor(request, metadata) transcoded_request = _BaseBinauthzManagementServiceV1RestTransport._BaseGetAttestor._get_transcoded_request( http_options, request @@ -599,6 +700,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.binaryauthorization_v1.BinauthzManagementServiceV1Client.GetAttestor", + extra={ + "serviceName": "google.cloud.binaryauthorization.v1.BinauthzManagementServiceV1", + "rpcName": "GetAttestor", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ( BinauthzManagementServiceV1RestTransport._GetAttestor._get_response( @@ -621,7 +749,29 @@ def __call__( pb_resp = resources.Attestor.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_attestor(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = resources.Attestor.to_json(response) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.binaryauthorization_v1.BinauthzManagementServiceV1Client.get_attestor", + extra={ + "serviceName": "google.cloud.binaryauthorization.v1.BinauthzManagementServiceV1", + "rpcName": "GetAttestor", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _GetPolicy( @@ -659,7 +809,7 @@ 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.Policy: r"""Call the get policy method over HTTP. @@ -670,8 +820,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each 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.Policy: @@ -683,6 +835,7 @@ def __call__( http_options = ( _BaseBinauthzManagementServiceV1RestTransport._BaseGetPolicy._get_http_options() ) + request, metadata = self._interceptor.pre_get_policy(request, metadata) transcoded_request = _BaseBinauthzManagementServiceV1RestTransport._BaseGetPolicy._get_transcoded_request( http_options, request @@ -693,6 +846,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.binaryauthorization_v1.BinauthzManagementServiceV1Client.GetPolicy", + extra={ + "serviceName": "google.cloud.binaryauthorization.v1.BinauthzManagementServiceV1", + "rpcName": "GetPolicy", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ( BinauthzManagementServiceV1RestTransport._GetPolicy._get_response( @@ -715,7 +895,29 @@ def __call__( pb_resp = resources.Policy.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_policy(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = resources.Policy.to_json(response) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.binaryauthorization_v1.BinauthzManagementServiceV1Client.get_policy", + extra={ + "serviceName": "google.cloud.binaryauthorization.v1.BinauthzManagementServiceV1", + "rpcName": "GetPolicy", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ListAttestors( @@ -753,7 +955,7 @@ 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.ListAttestorsResponse: r"""Call the list attestors method over HTTP. @@ -764,8 +966,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.service.ListAttestorsResponse: @@ -777,6 +981,7 @@ def __call__( http_options = ( _BaseBinauthzManagementServiceV1RestTransport._BaseListAttestors._get_http_options() ) + request, metadata = self._interceptor.pre_list_attestors(request, metadata) transcoded_request = _BaseBinauthzManagementServiceV1RestTransport._BaseListAttestors._get_transcoded_request( http_options, request @@ -787,6 +992,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.binaryauthorization_v1.BinauthzManagementServiceV1Client.ListAttestors", + extra={ + "serviceName": "google.cloud.binaryauthorization.v1.BinauthzManagementServiceV1", + "rpcName": "ListAttestors", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ( BinauthzManagementServiceV1RestTransport._ListAttestors._get_response( @@ -809,7 +1041,29 @@ def __call__( pb_resp = service.ListAttestorsResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_attestors(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = service.ListAttestorsResponse.to_json(response) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.binaryauthorization_v1.BinauthzManagementServiceV1Client.list_attestors", + extra={ + "serviceName": "google.cloud.binaryauthorization.v1.BinauthzManagementServiceV1", + "rpcName": "ListAttestors", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _UpdateAttestor( @@ -848,7 +1102,7 @@ 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.Attestor: r"""Call the update attestor method over HTTP. @@ -859,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: ~.resources.Attestor: @@ -874,6 +1130,7 @@ def __call__( http_options = ( _BaseBinauthzManagementServiceV1RestTransport._BaseUpdateAttestor._get_http_options() ) + request, metadata = self._interceptor.pre_update_attestor(request, metadata) transcoded_request = _BaseBinauthzManagementServiceV1RestTransport._BaseUpdateAttestor._get_transcoded_request( http_options, request @@ -888,6 +1145,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.binaryauthorization_v1.BinauthzManagementServiceV1Client.UpdateAttestor", + extra={ + "serviceName": "google.cloud.binaryauthorization.v1.BinauthzManagementServiceV1", + "rpcName": "UpdateAttestor", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ( BinauthzManagementServiceV1RestTransport._UpdateAttestor._get_response( @@ -911,7 +1195,29 @@ def __call__( pb_resp = resources.Attestor.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_update_attestor(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = resources.Attestor.to_json(response) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.binaryauthorization_v1.BinauthzManagementServiceV1Client.update_attestor", + extra={ + "serviceName": "google.cloud.binaryauthorization.v1.BinauthzManagementServiceV1", + "rpcName": "UpdateAttestor", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _UpdatePolicy( @@ -950,7 +1256,7 @@ 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.Policy: r"""Call the update policy method over HTTP. @@ -961,8 +1267,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.resources.Policy: @@ -974,6 +1282,7 @@ def __call__( http_options = ( _BaseBinauthzManagementServiceV1RestTransport._BaseUpdatePolicy._get_http_options() ) + request, metadata = self._interceptor.pre_update_policy(request, metadata) transcoded_request = _BaseBinauthzManagementServiceV1RestTransport._BaseUpdatePolicy._get_transcoded_request( http_options, request @@ -988,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.cloud.binaryauthorization_v1.BinauthzManagementServiceV1Client.UpdatePolicy", + extra={ + "serviceName": "google.cloud.binaryauthorization.v1.BinauthzManagementServiceV1", + "rpcName": "UpdatePolicy", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ( BinauthzManagementServiceV1RestTransport._UpdatePolicy._get_response( @@ -1011,7 +1347,29 @@ def __call__( pb_resp = resources.Policy.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_update_policy(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = resources.Policy.to_json(response) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.binaryauthorization_v1.BinauthzManagementServiceV1Client.update_policy", + extra={ + "serviceName": "google.cloud.binaryauthorization.v1.BinauthzManagementServiceV1", + "rpcName": "UpdatePolicy", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp @property diff --git a/packages/google-cloud-binary-authorization/google/cloud/binaryauthorization_v1/services/system_policy_v1/async_client.py b/packages/google-cloud-binary-authorization/google/cloud/binaryauthorization_v1/services/system_policy_v1/async_client.py index 609494774d87..93a3026a662d 100644 --- a/packages/google-cloud-binary-authorization/google/cloud/binaryauthorization_v1/services/system_policy_v1/async_client.py +++ b/packages/google-cloud-binary-authorization/google/cloud/binaryauthorization_v1/services/system_policy_v1/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, SystemPolicyV1Transport from .transports.grpc_asyncio import SystemPolicyV1GrpcAsyncIOTransport +try: + from google.api_core import client_logging # type: ignore + + CLIENT_LOGGING_SUPPORTED = True # pragma: NO COVER +except ImportError: # pragma: NO COVER + CLIENT_LOGGING_SUPPORTED = False + +_LOGGER = std_logging.getLogger(__name__) + class SystemPolicyV1AsyncClient: """API for working with the system policy.""" @@ -255,6 +265,28 @@ def __init__( client_info=client_info, ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + std_logging.DEBUG + ): # pragma: NO COVER + _LOGGER.debug( + "Created client `google.cloud.binaryauthorization_v1.SystemPolicyV1AsyncClient`.", + extra={ + "serviceName": "google.cloud.binaryauthorization.v1.SystemPolicyV1", + "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.binaryauthorization.v1.SystemPolicyV1", + "credentialsType": None, + }, + ) + async def get_system_policy( self, request: Optional[Union[service.GetSystemPolicyRequest, dict]] = None, @@ -262,7 +294,7 @@ async def get_system_policy( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> resources.Policy: r"""Gets the current system policy in the specified location. @@ -308,8 +340,10 @@ async def sample_get_system_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.binaryauthorization_v1.types.Policy: diff --git a/packages/google-cloud-binary-authorization/google/cloud/binaryauthorization_v1/services/system_policy_v1/client.py b/packages/google-cloud-binary-authorization/google/cloud/binaryauthorization_v1/services/system_policy_v1/client.py index c1194731d1ea..d4c7c39ef0e7 100644 --- a/packages/google-cloud-binary-authorization/google/cloud/binaryauthorization_v1/services/system_policy_v1/client.py +++ b/packages/google-cloud-binary-authorization/google/cloud/binaryauthorization_v1/services/system_policy_v1/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.binaryauthorization_v1.types import resources, 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( @@ -637,6 +651,29 @@ def __init__( api_audience=self._client_options.api_audience, ) + if "async" not in str(self._transport): + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + std_logging.DEBUG + ): # pragma: NO COVER + _LOGGER.debug( + "Created client `google.cloud.binaryauthorization_v1.SystemPolicyV1Client`.", + extra={ + "serviceName": "google.cloud.binaryauthorization.v1.SystemPolicyV1", + "universeDomain": getattr( + self._transport._credentials, "universe_domain", "" + ), + "credentialsType": f"{type(self._transport._credentials).__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.binaryauthorization.v1.SystemPolicyV1", + "credentialsType": None, + }, + ) + def get_system_policy( self, request: Optional[Union[service.GetSystemPolicyRequest, dict]] = None, @@ -644,7 +681,7 @@ def get_system_policy( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> resources.Policy: r"""Gets the current system policy in the specified location. @@ -690,8 +727,10 @@ def sample_get_system_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.binaryauthorization_v1.types.Policy: diff --git a/packages/google-cloud-binary-authorization/google/cloud/binaryauthorization_v1/services/system_policy_v1/transports/grpc.py b/packages/google-cloud-binary-authorization/google/cloud/binaryauthorization_v1/services/system_policy_v1/transports/grpc.py index 5ea0c932207c..1cc777fac2a0 100644 --- a/packages/google-cloud-binary-authorization/google/cloud/binaryauthorization_v1/services/system_policy_v1/transports/grpc.py +++ b/packages/google-cloud-binary-authorization/google/cloud/binaryauthorization_v1/services/system_policy_v1/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.binaryauthorization_v1.types import resources, service from .base import DEFAULT_CLIENT_INFO, SystemPolicyV1Transport +try: + from google.api_core import client_logging # 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.binaryauthorization.v1.SystemPolicyV1", + "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.binaryauthorization.v1.SystemPolicyV1", + "rpcName": client_call_details.method, + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class SystemPolicyV1GrpcTransport(SystemPolicyV1Transport): """gRPC backend transport for SystemPolicyV1. @@ -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 @@ -254,7 +340,7 @@ def get_system_policy( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_system_policy" not in self._stubs: - self._stubs["get_system_policy"] = self.grpc_channel.unary_unary( + self._stubs["get_system_policy"] = self._logged_channel.unary_unary( "/google.cloud.binaryauthorization.v1.SystemPolicyV1/GetSystemPolicy", request_serializer=service.GetSystemPolicyRequest.serialize, response_deserializer=resources.Policy.deserialize, @@ -262,7 +348,7 @@ def get_system_policy( return self._stubs["get_system_policy"] def close(self): - self.grpc_channel.close() + self._logged_channel.close() @property def kind(self) -> str: diff --git a/packages/google-cloud-binary-authorization/google/cloud/binaryauthorization_v1/services/system_policy_v1/transports/grpc_asyncio.py b/packages/google-cloud-binary-authorization/google/cloud/binaryauthorization_v1/services/system_policy_v1/transports/grpc_asyncio.py index 433d1fa57eb7..3d3ba95dd7a9 100644 --- a/packages/google-cloud-binary-authorization/google/cloud/binaryauthorization_v1/services/system_policy_v1/transports/grpc_asyncio.py +++ b/packages/google-cloud-binary-authorization/google/cloud/binaryauthorization_v1/services/system_policy_v1/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.binaryauthorization_v1.types import resources, service from .base import DEFAULT_CLIENT_INFO, SystemPolicyV1Transport from .grpc import SystemPolicyV1GrpcTransport +try: + from google.api_core import client_logging # 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.binaryauthorization.v1.SystemPolicyV1", + "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.binaryauthorization.v1.SystemPolicyV1", + "rpcName": str(client_call_details.method), + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class SystemPolicyV1GrpcAsyncIOTransport(SystemPolicyV1Transport): """gRPC AsyncIO backend transport for SystemPolicyV1. @@ -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 @@ -262,7 +347,7 @@ def get_system_policy( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_system_policy" not in self._stubs: - self._stubs["get_system_policy"] = self.grpc_channel.unary_unary( + self._stubs["get_system_policy"] = self._logged_channel.unary_unary( "/google.cloud.binaryauthorization.v1.SystemPolicyV1/GetSystemPolicy", request_serializer=service.GetSystemPolicyRequest.serialize, response_deserializer=resources.Policy.deserialize, @@ -285,7 +370,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-binary-authorization/google/cloud/binaryauthorization_v1/services/system_policy_v1/transports/rest.py b/packages/google-cloud-binary-authorization/google/cloud/binaryauthorization_v1/services/system_policy_v1/transports/rest.py index 63917b7ae989..c1b06a8b6c5b 100644 --- a/packages/google-cloud-binary-authorization/google/cloud/binaryauthorization_v1/services/system_policy_v1/transports/rest.py +++ b/packages/google-cloud-binary-authorization/google/cloud/binaryauthorization_v1/services/system_policy_v1/transports/rest.py @@ -13,9 +13,9 @@ # See the License for the specific language governing permissions and # limitations under the License. # - import dataclasses import json # type: ignore +import logging from typing import Any, Callable, Dict, List, Optional, Sequence, Tuple, Union import warnings @@ -37,6 +37,14 @@ except AttributeError: # pragma: NO COVER OptionalRetry = Union[retries.Retry, object, None] # type: ignore +try: + from google.api_core import client_logging # type: ignore + + CLIENT_LOGGING_SUPPORTED = True # pragma: NO COVER +except ImportError: # pragma: NO COVER + CLIENT_LOGGING_SUPPORTED = False + +_LOGGER = logging.getLogger(__name__) DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo( gapic_version=BASE_DEFAULT_CLIENT_INFO.gapic_version, @@ -77,8 +85,8 @@ def post_get_system_policy(self, response): def pre_get_system_policy( self, request: service.GetSystemPolicyRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[service.GetSystemPolicyRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[service.GetSystemPolicyRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for get_system_policy Override in a subclass to manipulate the request or metadata @@ -216,7 +224,7 @@ 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.Policy: r"""Call the get system policy method over HTTP. @@ -227,8 +235,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each 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.Policy: @@ -240,6 +250,7 @@ def __call__( http_options = ( _BaseSystemPolicyV1RestTransport._BaseGetSystemPolicy._get_http_options() ) + request, metadata = self._interceptor.pre_get_system_policy( request, metadata ) @@ -252,6 +263,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.binaryauthorization_v1.SystemPolicyV1Client.GetSystemPolicy", + extra={ + "serviceName": "google.cloud.binaryauthorization.v1.SystemPolicyV1", + "rpcName": "GetSystemPolicy", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = SystemPolicyV1RestTransport._GetSystemPolicy._get_response( self._host, @@ -272,7 +310,29 @@ def __call__( pb_resp = resources.Policy.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_system_policy(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = resources.Policy.to_json(response) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.binaryauthorization_v1.SystemPolicyV1Client.get_system_policy", + extra={ + "serviceName": "google.cloud.binaryauthorization.v1.SystemPolicyV1", + "rpcName": "GetSystemPolicy", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp @property diff --git a/packages/google-cloud-binary-authorization/google/cloud/binaryauthorization_v1/services/validation_helper_v1/async_client.py b/packages/google-cloud-binary-authorization/google/cloud/binaryauthorization_v1/services/validation_helper_v1/async_client.py index 8570c32538c9..62892e5c7cc9 100644 --- a/packages/google-cloud-binary-authorization/google/cloud/binaryauthorization_v1/services/validation_helper_v1/async_client.py +++ b/packages/google-cloud-binary-authorization/google/cloud/binaryauthorization_v1/services/validation_helper_v1/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, ValidationHelperV1Transport from .transports.grpc_asyncio import ValidationHelperV1GrpcAsyncIOTransport +try: + from google.api_core import client_logging # type: ignore + + CLIENT_LOGGING_SUPPORTED = True # pragma: NO COVER +except ImportError: # pragma: NO COVER + CLIENT_LOGGING_SUPPORTED = False + +_LOGGER = std_logging.getLogger(__name__) + class ValidationHelperV1AsyncClient: """BinAuthz Attestor verification""" @@ -255,6 +265,28 @@ def __init__( client_info=client_info, ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + std_logging.DEBUG + ): # pragma: NO COVER + _LOGGER.debug( + "Created client `google.cloud.binaryauthorization_v1.ValidationHelperV1AsyncClient`.", + extra={ + "serviceName": "google.cloud.binaryauthorization.v1.ValidationHelperV1", + "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.binaryauthorization.v1.ValidationHelperV1", + "credentialsType": None, + }, + ) + async def validate_attestation_occurrence( self, request: Optional[ @@ -263,7 +295,7 @@ async def validate_attestation_occurrence( *, retry: OptionalRetry = 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.ValidateAttestationOccurrenceResponse: r"""Returns whether the given Attestation for the given image URI was signed by the given Attestor @@ -303,8 +335,10 @@ async def sample_validate_attestation_occurrence(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.binaryauthorization_v1.types.ValidateAttestationOccurrenceResponse: diff --git a/packages/google-cloud-binary-authorization/google/cloud/binaryauthorization_v1/services/validation_helper_v1/client.py b/packages/google-cloud-binary-authorization/google/cloud/binaryauthorization_v1/services/validation_helper_v1/client.py index 3bbd7927dfe1..c2ea5ae38197 100644 --- a/packages/google-cloud-binary-authorization/google/cloud/binaryauthorization_v1/services/validation_helper_v1/client.py +++ b/packages/google-cloud-binary-authorization/google/cloud/binaryauthorization_v1/services/validation_helper_v1/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.binaryauthorization_v1.types import service from .transports.base import DEFAULT_CLIENT_INFO, ValidationHelperV1Transport @@ -559,6 +569,10 @@ def __init__( # Initialize the universe domain validation. self._is_universe_domain_valid = False + if CLIENT_LOGGING_SUPPORTED: # pragma: NO COVER + # Setup logging. + client_logging.initialize_logging() + api_key_value = getattr(self._client_options, "api_key", None) if api_key_value and credentials: raise ValueError( @@ -625,6 +639,29 @@ def __init__( api_audience=self._client_options.api_audience, ) + if "async" not in str(self._transport): + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + std_logging.DEBUG + ): # pragma: NO COVER + _LOGGER.debug( + "Created client `google.cloud.binaryauthorization_v1.ValidationHelperV1Client`.", + extra={ + "serviceName": "google.cloud.binaryauthorization.v1.ValidationHelperV1", + "universeDomain": getattr( + self._transport._credentials, "universe_domain", "" + ), + "credentialsType": f"{type(self._transport._credentials).__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.binaryauthorization.v1.ValidationHelperV1", + "credentialsType": None, + }, + ) + def validate_attestation_occurrence( self, request: Optional[ @@ -633,7 +670,7 @@ def validate_attestation_occurrence( *, retry: OptionalRetry = 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.ValidateAttestationOccurrenceResponse: r"""Returns whether the given Attestation for the given image URI was signed by the given Attestor @@ -673,8 +710,10 @@ def sample_validate_attestation_occurrence(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.binaryauthorization_v1.types.ValidateAttestationOccurrenceResponse: diff --git a/packages/google-cloud-binary-authorization/google/cloud/binaryauthorization_v1/services/validation_helper_v1/transports/grpc.py b/packages/google-cloud-binary-authorization/google/cloud/binaryauthorization_v1/services/validation_helper_v1/transports/grpc.py index 016eac3e3720..0ef33dd412ef 100644 --- a/packages/google-cloud-binary-authorization/google/cloud/binaryauthorization_v1/services/validation_helper_v1/transports/grpc.py +++ b/packages/google-cloud-binary-authorization/google/cloud/binaryauthorization_v1/services/validation_helper_v1/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.binaryauthorization_v1.types import service from .base import DEFAULT_CLIENT_INFO, ValidationHelperV1Transport +try: + from google.api_core import client_logging # 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.binaryauthorization.v1.ValidationHelperV1", + "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.binaryauthorization.v1.ValidationHelperV1", + "rpcName": client_call_details.method, + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class ValidationHelperV1GrpcTransport(ValidationHelperV1Transport): """gRPC backend transport for ValidationHelperV1. @@ -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 @@ -260,7 +346,7 @@ def validate_attestation_occurrence( if "validate_attestation_occurrence" not in self._stubs: self._stubs[ "validate_attestation_occurrence" - ] = self.grpc_channel.unary_unary( + ] = self._logged_channel.unary_unary( "/google.cloud.binaryauthorization.v1.ValidationHelperV1/ValidateAttestationOccurrence", request_serializer=service.ValidateAttestationOccurrenceRequest.serialize, response_deserializer=service.ValidateAttestationOccurrenceResponse.deserialize, @@ -268,7 +354,7 @@ def validate_attestation_occurrence( return self._stubs["validate_attestation_occurrence"] def close(self): - self.grpc_channel.close() + self._logged_channel.close() @property def kind(self) -> str: diff --git a/packages/google-cloud-binary-authorization/google/cloud/binaryauthorization_v1/services/validation_helper_v1/transports/grpc_asyncio.py b/packages/google-cloud-binary-authorization/google/cloud/binaryauthorization_v1/services/validation_helper_v1/transports/grpc_asyncio.py index e6984a95e1c1..bbbf3acfe763 100644 --- a/packages/google-cloud-binary-authorization/google/cloud/binaryauthorization_v1/services/validation_helper_v1/transports/grpc_asyncio.py +++ b/packages/google-cloud-binary-authorization/google/cloud/binaryauthorization_v1/services/validation_helper_v1/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.binaryauthorization_v1.types import service from .base import DEFAULT_CLIENT_INFO, ValidationHelperV1Transport from .grpc import ValidationHelperV1GrpcTransport +try: + from google.api_core import client_logging # 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.binaryauthorization.v1.ValidationHelperV1", + "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.binaryauthorization.v1.ValidationHelperV1", + "rpcName": str(client_call_details.method), + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class ValidationHelperV1GrpcAsyncIOTransport(ValidationHelperV1Transport): """gRPC AsyncIO backend transport for ValidationHelperV1. @@ -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 @@ -268,7 +353,7 @@ def validate_attestation_occurrence( if "validate_attestation_occurrence" not in self._stubs: self._stubs[ "validate_attestation_occurrence" - ] = self.grpc_channel.unary_unary( + ] = self._logged_channel.unary_unary( "/google.cloud.binaryauthorization.v1.ValidationHelperV1/ValidateAttestationOccurrence", request_serializer=service.ValidateAttestationOccurrenceRequest.serialize, response_deserializer=service.ValidateAttestationOccurrenceResponse.deserialize, @@ -291,7 +376,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-binary-authorization/google/cloud/binaryauthorization_v1/services/validation_helper_v1/transports/rest.py b/packages/google-cloud-binary-authorization/google/cloud/binaryauthorization_v1/services/validation_helper_v1/transports/rest.py index 222f183e6087..150b136a97d6 100644 --- a/packages/google-cloud-binary-authorization/google/cloud/binaryauthorization_v1/services/validation_helper_v1/transports/rest.py +++ b/packages/google-cloud-binary-authorization/google/cloud/binaryauthorization_v1/services/validation_helper_v1/transports/rest.py @@ -13,9 +13,9 @@ # See the License for the specific language governing permissions and # limitations under the License. # - import dataclasses import json # type: ignore +import logging from typing import Any, Callable, Dict, List, Optional, Sequence, Tuple, Union import warnings @@ -37,6 +37,14 @@ except AttributeError: # pragma: NO COVER OptionalRetry = Union[retries.Retry, object, None] # type: ignore +try: + from google.api_core import client_logging # type: ignore + + CLIENT_LOGGING_SUPPORTED = True # pragma: NO COVER +except ImportError: # pragma: NO COVER + CLIENT_LOGGING_SUPPORTED = False + +_LOGGER = logging.getLogger(__name__) DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo( gapic_version=BASE_DEFAULT_CLIENT_INFO.gapic_version, @@ -77,8 +85,11 @@ def post_validate_attestation_occurrence(self, response): def pre_validate_attestation_occurrence( self, request: service.ValidateAttestationOccurrenceRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[service.ValidateAttestationOccurrenceRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + service.ValidateAttestationOccurrenceRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for validate_attestation_occurrence Override in a subclass to manipulate the request or metadata @@ -220,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]]] = (), ) -> service.ValidateAttestationOccurrenceResponse: r"""Call the validate attestation occurrence method over HTTP. @@ -232,8 +243,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.service.ValidateAttestationOccurrenceResponse: @@ -245,6 +258,7 @@ def __call__( http_options = ( _BaseValidationHelperV1RestTransport._BaseValidateAttestationOccurrence._get_http_options() ) + request, metadata = self._interceptor.pre_validate_attestation_occurrence( request, metadata ) @@ -261,6 +275,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.binaryauthorization_v1.ValidationHelperV1Client.ValidateAttestationOccurrence", + extra={ + "serviceName": "google.cloud.binaryauthorization.v1.ValidationHelperV1", + "rpcName": "ValidateAttestationOccurrence", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ValidationHelperV1RestTransport._ValidateAttestationOccurrence._get_response( self._host, @@ -282,7 +323,31 @@ def __call__( pb_resp = service.ValidateAttestationOccurrenceResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_validate_attestation_occurrence(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = ( + service.ValidateAttestationOccurrenceResponse.to_json(response) + ) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.binaryauthorization_v1.ValidationHelperV1Client.validate_attestation_occurrence", + extra={ + "serviceName": "google.cloud.binaryauthorization.v1.ValidationHelperV1", + "rpcName": "ValidateAttestationOccurrence", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp @property diff --git a/packages/google-cloud-binary-authorization/google/cloud/binaryauthorization_v1beta1/gapic_version.py b/packages/google-cloud-binary-authorization/google/cloud/binaryauthorization_v1beta1/gapic_version.py index b50cada0b7ee..558c8aab67c5 100644 --- a/packages/google-cloud-binary-authorization/google/cloud/binaryauthorization_v1beta1/gapic_version.py +++ b/packages/google-cloud-binary-authorization/google/cloud/binaryauthorization_v1beta1/gapic_version.py @@ -13,4 +13,4 @@ # See the License for the specific language governing permissions and # limitations under the License. # -__version__ = "1.11.1" # {x-release-please-version} +__version__ = "0.0.0" # {x-release-please-version} diff --git a/packages/google-cloud-binary-authorization/google/cloud/binaryauthorization_v1beta1/services/binauthz_management_service_v1_beta1/async_client.py b/packages/google-cloud-binary-authorization/google/cloud/binaryauthorization_v1beta1/services/binauthz_management_service_v1_beta1/async_client.py index ebe7a778f8be..0ad05bcdbe87 100644 --- a/packages/google-cloud-binary-authorization/google/cloud/binaryauthorization_v1beta1/services/binauthz_management_service_v1_beta1/async_client.py +++ b/packages/google-cloud-binary-authorization/google/cloud/binaryauthorization_v1beta1/services/binauthz_management_service_v1_beta1/async_client.py @@ -14,6 +14,7 @@ # limitations under the License. # from collections import OrderedDict +import logging as std_logging import re from typing import ( Callable, @@ -58,6 +59,15 @@ BinauthzManagementServiceV1Beta1GrpcAsyncIOTransport, ) +try: + from google.api_core import client_logging # type: ignore + + CLIENT_LOGGING_SUPPORTED = True # pragma: NO COVER +except ImportError: # pragma: NO COVER + CLIENT_LOGGING_SUPPORTED = False + +_LOGGER = std_logging.getLogger(__name__) + class BinauthzManagementServiceV1Beta1AsyncClient: """Google Cloud Management Service for Binary Authorization admission @@ -288,6 +298,28 @@ def __init__( client_info=client_info, ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + std_logging.DEBUG + ): # pragma: NO COVER + _LOGGER.debug( + "Created client `google.cloud.binaryauthorization_v1beta1.BinauthzManagementServiceV1Beta1AsyncClient`.", + extra={ + "serviceName": "google.cloud.binaryauthorization.v1beta1.BinauthzManagementServiceV1Beta1", + "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.binaryauthorization.v1beta1.BinauthzManagementServiceV1Beta1", + "credentialsType": None, + }, + ) + async def get_policy( self, request: Optional[Union[service.GetPolicyRequest, dict]] = None, @@ -295,7 +327,7 @@ async def get_policy( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> resources.Policy: r"""A [policy][google.cloud.binaryauthorization.v1beta1.Policy] specifies the @@ -352,8 +384,10 @@ async def sample_get_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.binaryauthorization_v1beta1.types.Policy: @@ -415,7 +449,7 @@ async def update_policy( policy: Optional[resources.Policy] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> resources.Policy: r"""Creates or updates a project's [policy][google.cloud.binaryauthorization.v1beta1.Policy], and @@ -474,8 +508,10 @@ async def sample_update_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.binaryauthorization_v1beta1.types.Policy: @@ -541,7 +577,7 @@ async def create_attestor( attestor: Optional[resources.Attestor] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> resources.Attestor: r"""Creates an [attestor][google.cloud.binaryauthorization.v1beta1.Attestor], @@ -618,8 +654,10 @@ async def sample_create_attestor(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.binaryauthorization_v1beta1.types.Attestor: @@ -685,7 +723,7 @@ async def get_attestor( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> resources.Attestor: r"""Gets an [attestor][google.cloud.binaryauthorization.v1beta1.Attestor]. @@ -734,8 +772,10 @@ async def sample_get_attestor(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.binaryauthorization_v1beta1.types.Attestor: @@ -797,7 +837,7 @@ async def update_attestor( attestor: Optional[resources.Attestor] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> resources.Attestor: r"""Updates an [attestor][google.cloud.binaryauthorization.v1beta1.Attestor]. @@ -853,8 +893,10 @@ async def sample_update_attestor(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.binaryauthorization_v1beta1.types.Attestor: @@ -918,7 +960,7 @@ async def list_attestors( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListAttestorsAsyncPager: r"""Lists [attestors][google.cloud.binaryauthorization.v1beta1.Attestor]. @@ -967,8 +1009,10 @@ async def sample_list_attestors(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.binaryauthorization_v1beta1.services.binauthz_management_service_v1_beta1.pagers.ListAttestorsAsyncPager: @@ -1043,7 +1087,7 @@ async def delete_attestor( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.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 [attestor][google.cloud.binaryauthorization.v1beta1.Attestor]. @@ -1089,8 +1133,10 @@ async def sample_delete_attestor(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. """ # Create or coerce a protobuf request object. # - Quick check: If we got a request object, we should *not* have diff --git a/packages/google-cloud-binary-authorization/google/cloud/binaryauthorization_v1beta1/services/binauthz_management_service_v1_beta1/client.py b/packages/google-cloud-binary-authorization/google/cloud/binaryauthorization_v1beta1/services/binauthz_management_service_v1_beta1/client.py index 9a7a80609bcc..3c9049d1f08f 100644 --- a/packages/google-cloud-binary-authorization/google/cloud/binaryauthorization_v1beta1/services/binauthz_management_service_v1_beta1/client.py +++ b/packages/google-cloud-binary-authorization/google/cloud/binaryauthorization_v1beta1/services/binauthz_management_service_v1_beta1/client.py @@ -14,6 +14,7 @@ # limitations under the License. # from collections import OrderedDict +import logging as std_logging import os import re from typing import ( @@ -48,6 +49,15 @@ except AttributeError: # pragma: NO COVER OptionalRetry = Union[retries.Retry, object, None] # type: ignore +try: + from google.api_core import client_logging # type: ignore + + CLIENT_LOGGING_SUPPORTED = True # pragma: NO COVER +except ImportError: # pragma: NO COVER + CLIENT_LOGGING_SUPPORTED = False + +_LOGGER = std_logging.getLogger(__name__) + from google.protobuf import timestamp_pb2 # type: ignore from google.cloud.binaryauthorization_v1beta1.services.binauthz_management_service_v1_beta1 import ( @@ -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( @@ -686,6 +700,29 @@ def __init__( api_audience=self._client_options.api_audience, ) + if "async" not in str(self._transport): + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + std_logging.DEBUG + ): # pragma: NO COVER + _LOGGER.debug( + "Created client `google.cloud.binaryauthorization_v1beta1.BinauthzManagementServiceV1Beta1Client`.", + extra={ + "serviceName": "google.cloud.binaryauthorization.v1beta1.BinauthzManagementServiceV1Beta1", + "universeDomain": getattr( + self._transport._credentials, "universe_domain", "" + ), + "credentialsType": f"{type(self._transport._credentials).__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.binaryauthorization.v1beta1.BinauthzManagementServiceV1Beta1", + "credentialsType": None, + }, + ) + def get_policy( self, request: Optional[Union[service.GetPolicyRequest, dict]] = None, @@ -693,7 +730,7 @@ def get_policy( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> resources.Policy: r"""A [policy][google.cloud.binaryauthorization.v1beta1.Policy] specifies the @@ -750,8 +787,10 @@ def sample_get_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.binaryauthorization_v1beta1.types.Policy: @@ -810,7 +849,7 @@ def update_policy( policy: Optional[resources.Policy] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> resources.Policy: r"""Creates or updates a project's [policy][google.cloud.binaryauthorization.v1beta1.Policy], and @@ -869,8 +908,10 @@ def sample_update_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.binaryauthorization_v1beta1.types.Policy: @@ -933,7 +974,7 @@ def create_attestor( attestor: Optional[resources.Attestor] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> resources.Attestor: r"""Creates an [attestor][google.cloud.binaryauthorization.v1beta1.Attestor], @@ -1010,8 +1051,10 @@ def sample_create_attestor(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.binaryauthorization_v1beta1.types.Attestor: @@ -1074,7 +1117,7 @@ def get_attestor( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> resources.Attestor: r"""Gets an [attestor][google.cloud.binaryauthorization.v1beta1.Attestor]. @@ -1123,8 +1166,10 @@ def sample_get_attestor(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.binaryauthorization_v1beta1.types.Attestor: @@ -1183,7 +1228,7 @@ def update_attestor( attestor: Optional[resources.Attestor] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> resources.Attestor: r"""Updates an [attestor][google.cloud.binaryauthorization.v1beta1.Attestor]. @@ -1239,8 +1284,10 @@ def sample_update_attestor(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.binaryauthorization_v1beta1.types.Attestor: @@ -1301,7 +1348,7 @@ def list_attestors( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListAttestorsPager: r"""Lists [attestors][google.cloud.binaryauthorization.v1beta1.Attestor]. @@ -1350,8 +1397,10 @@ def sample_list_attestors(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.binaryauthorization_v1beta1.services.binauthz_management_service_v1_beta1.pagers.ListAttestorsPager: @@ -1423,7 +1472,7 @@ def delete_attestor( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.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 [attestor][google.cloud.binaryauthorization.v1beta1.Attestor]. @@ -1469,8 +1518,10 @@ def sample_delete_attestor(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. """ # Create or coerce a protobuf request object. # - Quick check: If we got a request object, we should *not* have diff --git a/packages/google-cloud-binary-authorization/google/cloud/binaryauthorization_v1beta1/services/binauthz_management_service_v1_beta1/pagers.py b/packages/google-cloud-binary-authorization/google/cloud/binaryauthorization_v1beta1/services/binauthz_management_service_v1_beta1/pagers.py index 314cbfc9646f..230974221bfe 100644 --- a/packages/google-cloud-binary-authorization/google/cloud/binaryauthorization_v1beta1/services/binauthz_management_service_v1_beta1/pagers.py +++ b/packages/google-cloud-binary-authorization/google/cloud/binaryauthorization_v1beta1/services/binauthz_management_service_v1_beta1/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.ListAttestorsRequest(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.ListAttestorsRequest(request) diff --git a/packages/google-cloud-binary-authorization/google/cloud/binaryauthorization_v1beta1/services/binauthz_management_service_v1_beta1/transports/grpc.py b/packages/google-cloud-binary-authorization/google/cloud/binaryauthorization_v1beta1/services/binauthz_management_service_v1_beta1/transports/grpc.py index 1793b6bcf4a8..d93dfa4bb0e1 100644 --- a/packages/google-cloud-binary-authorization/google/cloud/binaryauthorization_v1beta1/services/binauthz_management_service_v1_beta1/transports/grpc.py +++ b/packages/google-cloud-binary-authorization/google/cloud/binaryauthorization_v1beta1/services/binauthz_management_service_v1_beta1/transports/grpc.py @@ -13,6 +13,9 @@ # See the License for the specific language governing permissions and # limitations under the License. # +import json +import logging as std_logging +import pickle from typing import Callable, Dict, Optional, Sequence, Tuple, Union import warnings @@ -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.binaryauthorization_v1beta1.types import resources, service from .base import DEFAULT_CLIENT_INFO, BinauthzManagementServiceV1Beta1Transport +try: + from google.api_core import client_logging # 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.binaryauthorization.v1beta1.BinauthzManagementServiceV1Beta1", + "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.binaryauthorization.v1beta1.BinauthzManagementServiceV1Beta1", + "rpcName": client_call_details.method, + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class BinauthzManagementServiceV1Beta1GrpcTransport( BinauthzManagementServiceV1Beta1Transport @@ -188,7 +269,12 @@ def __init__( ], ) - # Wrap messages. This must be done after self._grpc_channel exists + self._interceptor = _LoggingClientInterceptor() + self._logged_channel = grpc.intercept_channel( + self._grpc_channel, self._interceptor + ) + + # Wrap messages. This must be done after self._logged_channel exists self._prep_wrapped_messages(client_info) @classmethod @@ -272,7 +358,7 @@ def get_policy(self) -> Callable[[service.GetPolicyRequest], resources.Policy]: # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_policy" not in self._stubs: - self._stubs["get_policy"] = self.grpc_channel.unary_unary( + self._stubs["get_policy"] = self._logged_channel.unary_unary( "/google.cloud.binaryauthorization.v1beta1.BinauthzManagementServiceV1Beta1/GetPolicy", request_serializer=service.GetPolicyRequest.serialize, response_deserializer=resources.Policy.deserialize, @@ -305,7 +391,7 @@ def update_policy( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_policy" not in self._stubs: - self._stubs["update_policy"] = self.grpc_channel.unary_unary( + self._stubs["update_policy"] = self._logged_channel.unary_unary( "/google.cloud.binaryauthorization.v1beta1.BinauthzManagementServiceV1Beta1/UpdatePolicy", request_serializer=service.UpdatePolicyRequest.serialize, response_deserializer=resources.Policy.deserialize, @@ -339,7 +425,7 @@ def create_attestor( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_attestor" not in self._stubs: - self._stubs["create_attestor"] = self.grpc_channel.unary_unary( + self._stubs["create_attestor"] = self._logged_channel.unary_unary( "/google.cloud.binaryauthorization.v1beta1.BinauthzManagementServiceV1Beta1/CreateAttestor", request_serializer=service.CreateAttestorRequest.serialize, response_deserializer=resources.Attestor.deserialize, @@ -369,7 +455,7 @@ def get_attestor( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_attestor" not in self._stubs: - self._stubs["get_attestor"] = self.grpc_channel.unary_unary( + self._stubs["get_attestor"] = self._logged_channel.unary_unary( "/google.cloud.binaryauthorization.v1beta1.BinauthzManagementServiceV1Beta1/GetAttestor", request_serializer=service.GetAttestorRequest.serialize, response_deserializer=resources.Attestor.deserialize, @@ -399,7 +485,7 @@ def update_attestor( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_attestor" not in self._stubs: - self._stubs["update_attestor"] = self.grpc_channel.unary_unary( + self._stubs["update_attestor"] = self._logged_channel.unary_unary( "/google.cloud.binaryauthorization.v1beta1.BinauthzManagementServiceV1Beta1/UpdateAttestor", request_serializer=service.UpdateAttestorRequest.serialize, response_deserializer=resources.Attestor.deserialize, @@ -427,7 +513,7 @@ def list_attestors( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_attestors" not in self._stubs: - self._stubs["list_attestors"] = self.grpc_channel.unary_unary( + self._stubs["list_attestors"] = self._logged_channel.unary_unary( "/google.cloud.binaryauthorization.v1beta1.BinauthzManagementServiceV1Beta1/ListAttestors", request_serializer=service.ListAttestorsRequest.serialize, response_deserializer=service.ListAttestorsResponse.deserialize, @@ -457,7 +543,7 @@ def delete_attestor( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_attestor" not in self._stubs: - self._stubs["delete_attestor"] = self.grpc_channel.unary_unary( + self._stubs["delete_attestor"] = self._logged_channel.unary_unary( "/google.cloud.binaryauthorization.v1beta1.BinauthzManagementServiceV1Beta1/DeleteAttestor", request_serializer=service.DeleteAttestorRequest.serialize, response_deserializer=empty_pb2.Empty.FromString, @@ -465,7 +551,7 @@ def delete_attestor( return self._stubs["delete_attestor"] def close(self): - self.grpc_channel.close() + self._logged_channel.close() @property def kind(self) -> str: diff --git a/packages/google-cloud-binary-authorization/google/cloud/binaryauthorization_v1beta1/services/binauthz_management_service_v1_beta1/transports/grpc_asyncio.py b/packages/google-cloud-binary-authorization/google/cloud/binaryauthorization_v1beta1/services/binauthz_management_service_v1_beta1/transports/grpc_asyncio.py index 91fa790e1e48..b3b98abcc01c 100644 --- a/packages/google-cloud-binary-authorization/google/cloud/binaryauthorization_v1beta1/services/binauthz_management_service_v1_beta1/transports/grpc_asyncio.py +++ b/packages/google-cloud-binary-authorization/google/cloud/binaryauthorization_v1beta1/services/binauthz_management_service_v1_beta1/transports/grpc_asyncio.py @@ -14,6 +14,9 @@ # limitations under the License. # import inspect +import json +import logging as std_logging +import pickle from typing import Awaitable, Callable, Dict, Optional, Sequence, Tuple, Union import warnings @@ -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.binaryauthorization_v1beta1.types import resources, service from .base import DEFAULT_CLIENT_INFO, BinauthzManagementServiceV1Beta1Transport from .grpc import BinauthzManagementServiceV1Beta1GrpcTransport +try: + from google.api_core import client_logging # 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.binaryauthorization.v1beta1.BinauthzManagementServiceV1Beta1", + "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.binaryauthorization.v1beta1.BinauthzManagementServiceV1Beta1", + "rpcName": str(client_call_details.method), + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class BinauthzManagementServiceV1Beta1GrpcAsyncIOTransport( BinauthzManagementServiceV1Beta1Transport @@ -235,10 +317,13 @@ def __init__( ], ) - # Wrap messages. This must be done after self._grpc_channel exists + self._interceptor = _LoggingClientAIOInterceptor() + self._grpc_channel._unary_unary_interceptors.append(self._interceptor) + self._logged_channel = self._grpc_channel self._wrap_with_kind = ( "kind" in inspect.signature(gapic_v1.method_async.wrap_method).parameters ) + # Wrap messages. This must be done after self._logged_channel exists self._prep_wrapped_messages(client_info) @property @@ -282,7 +367,7 @@ def get_policy( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_policy" not in self._stubs: - self._stubs["get_policy"] = self.grpc_channel.unary_unary( + self._stubs["get_policy"] = self._logged_channel.unary_unary( "/google.cloud.binaryauthorization.v1beta1.BinauthzManagementServiceV1Beta1/GetPolicy", request_serializer=service.GetPolicyRequest.serialize, response_deserializer=resources.Policy.deserialize, @@ -315,7 +400,7 @@ def update_policy( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_policy" not in self._stubs: - self._stubs["update_policy"] = self.grpc_channel.unary_unary( + self._stubs["update_policy"] = self._logged_channel.unary_unary( "/google.cloud.binaryauthorization.v1beta1.BinauthzManagementServiceV1Beta1/UpdatePolicy", request_serializer=service.UpdatePolicyRequest.serialize, response_deserializer=resources.Policy.deserialize, @@ -349,7 +434,7 @@ def create_attestor( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_attestor" not in self._stubs: - self._stubs["create_attestor"] = self.grpc_channel.unary_unary( + self._stubs["create_attestor"] = self._logged_channel.unary_unary( "/google.cloud.binaryauthorization.v1beta1.BinauthzManagementServiceV1Beta1/CreateAttestor", request_serializer=service.CreateAttestorRequest.serialize, response_deserializer=resources.Attestor.deserialize, @@ -379,7 +464,7 @@ def get_attestor( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_attestor" not in self._stubs: - self._stubs["get_attestor"] = self.grpc_channel.unary_unary( + self._stubs["get_attestor"] = self._logged_channel.unary_unary( "/google.cloud.binaryauthorization.v1beta1.BinauthzManagementServiceV1Beta1/GetAttestor", request_serializer=service.GetAttestorRequest.serialize, response_deserializer=resources.Attestor.deserialize, @@ -409,7 +494,7 @@ def update_attestor( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_attestor" not in self._stubs: - self._stubs["update_attestor"] = self.grpc_channel.unary_unary( + self._stubs["update_attestor"] = self._logged_channel.unary_unary( "/google.cloud.binaryauthorization.v1beta1.BinauthzManagementServiceV1Beta1/UpdateAttestor", request_serializer=service.UpdateAttestorRequest.serialize, response_deserializer=resources.Attestor.deserialize, @@ -439,7 +524,7 @@ def list_attestors( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_attestors" not in self._stubs: - self._stubs["list_attestors"] = self.grpc_channel.unary_unary( + self._stubs["list_attestors"] = self._logged_channel.unary_unary( "/google.cloud.binaryauthorization.v1beta1.BinauthzManagementServiceV1Beta1/ListAttestors", request_serializer=service.ListAttestorsRequest.serialize, response_deserializer=service.ListAttestorsResponse.deserialize, @@ -469,7 +554,7 @@ def delete_attestor( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_attestor" not in self._stubs: - self._stubs["delete_attestor"] = self.grpc_channel.unary_unary( + self._stubs["delete_attestor"] = self._logged_channel.unary_unary( "/google.cloud.binaryauthorization.v1beta1.BinauthzManagementServiceV1Beta1/DeleteAttestor", request_serializer=service.DeleteAttestorRequest.serialize, response_deserializer=empty_pb2.Empty.FromString, @@ -582,7 +667,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-binary-authorization/google/cloud/binaryauthorization_v1beta1/services/binauthz_management_service_v1_beta1/transports/rest.py b/packages/google-cloud-binary-authorization/google/cloud/binaryauthorization_v1beta1/services/binauthz_management_service_v1_beta1/transports/rest.py index 2b6b35503e20..9232ba96aeaf 100644 --- a/packages/google-cloud-binary-authorization/google/cloud/binaryauthorization_v1beta1/services/binauthz_management_service_v1_beta1/transports/rest.py +++ b/packages/google-cloud-binary-authorization/google/cloud/binaryauthorization_v1beta1/services/binauthz_management_service_v1_beta1/transports/rest.py @@ -13,9 +13,9 @@ # See the License for the specific language governing permissions and # limitations under the License. # - import dataclasses import json # type: ignore +import logging from typing import Any, Callable, Dict, List, Optional, Sequence, Tuple, Union import warnings @@ -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, @@ -122,8 +130,8 @@ def post_update_policy(self, response): def pre_create_attestor( self, request: service.CreateAttestorRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[service.CreateAttestorRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[service.CreateAttestorRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for create_attestor Override in a subclass to manipulate the request or metadata @@ -143,8 +151,8 @@ def post_create_attestor(self, response: resources.Attestor) -> resources.Attest def pre_delete_attestor( self, request: service.DeleteAttestorRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[service.DeleteAttestorRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[service.DeleteAttestorRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for delete_attestor Override in a subclass to manipulate the request or metadata @@ -153,8 +161,10 @@ def pre_delete_attestor( return request, metadata def pre_get_attestor( - self, request: service.GetAttestorRequest, metadata: Sequence[Tuple[str, str]] - ) -> Tuple[service.GetAttestorRequest, Sequence[Tuple[str, str]]]: + self, + request: service.GetAttestorRequest, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[service.GetAttestorRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for get_attestor Override in a subclass to manipulate the request or metadata @@ -172,8 +182,10 @@ def post_get_attestor(self, response: resources.Attestor) -> resources.Attestor: return response def pre_get_policy( - self, request: service.GetPolicyRequest, metadata: Sequence[Tuple[str, str]] - ) -> Tuple[service.GetPolicyRequest, Sequence[Tuple[str, str]]]: + self, + request: service.GetPolicyRequest, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[service.GetPolicyRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for get_policy Override in a subclass to manipulate the request or metadata @@ -191,8 +203,10 @@ def post_get_policy(self, response: resources.Policy) -> resources.Policy: return response def pre_list_attestors( - self, request: service.ListAttestorsRequest, metadata: Sequence[Tuple[str, str]] - ) -> Tuple[service.ListAttestorsRequest, Sequence[Tuple[str, str]]]: + self, + request: service.ListAttestorsRequest, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[service.ListAttestorsRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for list_attestors Override in a subclass to manipulate the request or metadata @@ -214,8 +228,8 @@ def post_list_attestors( def pre_update_attestor( self, request: service.UpdateAttestorRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[service.UpdateAttestorRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[service.UpdateAttestorRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for update_attestor Override in a subclass to manipulate the request or metadata @@ -233,8 +247,10 @@ def post_update_attestor(self, response: resources.Attestor) -> resources.Attest return response def pre_update_policy( - self, request: service.UpdatePolicyRequest, metadata: Sequence[Tuple[str, str]] - ) -> Tuple[service.UpdatePolicyRequest, Sequence[Tuple[str, str]]]: + self, + request: service.UpdatePolicyRequest, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[service.UpdatePolicyRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for update_policy Override in a subclass to manipulate the request or metadata @@ -384,7 +400,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> resources.Attestor: r"""Call the create attestor method over HTTP. @@ -395,8 +411,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.resources.Attestor: @@ -410,6 +428,7 @@ def __call__( http_options = ( _BaseBinauthzManagementServiceV1Beta1RestTransport._BaseCreateAttestor._get_http_options() ) + request, metadata = self._interceptor.pre_create_attestor(request, metadata) transcoded_request = _BaseBinauthzManagementServiceV1Beta1RestTransport._BaseCreateAttestor._get_transcoded_request( http_options, request @@ -424,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.binaryauthorization_v1beta1.BinauthzManagementServiceV1Beta1Client.CreateAttestor", + extra={ + "serviceName": "google.cloud.binaryauthorization.v1beta1.BinauthzManagementServiceV1Beta1", + "rpcName": "CreateAttestor", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = BinauthzManagementServiceV1Beta1RestTransport._CreateAttestor._get_response( self._host, @@ -445,7 +491,29 @@ def __call__( pb_resp = resources.Attestor.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_create_attestor(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = resources.Attestor.to_json(response) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.binaryauthorization_v1beta1.BinauthzManagementServiceV1Beta1Client.create_attestor", + extra={ + "serviceName": "google.cloud.binaryauthorization.v1beta1.BinauthzManagementServiceV1Beta1", + "rpcName": "CreateAttestor", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _DeleteAttestor( @@ -483,7 +551,7 @@ 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 attestor method over HTTP. @@ -494,13 +562,16 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. """ http_options = ( _BaseBinauthzManagementServiceV1Beta1RestTransport._BaseDeleteAttestor._get_http_options() ) + request, metadata = self._interceptor.pre_delete_attestor(request, metadata) transcoded_request = _BaseBinauthzManagementServiceV1Beta1RestTransport._BaseDeleteAttestor._get_transcoded_request( http_options, request @@ -511,6 +582,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.binaryauthorization_v1beta1.BinauthzManagementServiceV1Beta1Client.DeleteAttestor", + extra={ + "serviceName": "google.cloud.binaryauthorization.v1beta1.BinauthzManagementServiceV1Beta1", + "rpcName": "DeleteAttestor", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = BinauthzManagementServiceV1Beta1RestTransport._DeleteAttestor._get_response( self._host, @@ -561,7 +659,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> resources.Attestor: r"""Call the get attestor method over HTTP. @@ -572,8 +670,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each 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.Attestor: @@ -587,6 +687,7 @@ def __call__( http_options = ( _BaseBinauthzManagementServiceV1Beta1RestTransport._BaseGetAttestor._get_http_options() ) + request, metadata = self._interceptor.pre_get_attestor(request, metadata) transcoded_request = _BaseBinauthzManagementServiceV1Beta1RestTransport._BaseGetAttestor._get_transcoded_request( http_options, request @@ -597,6 +698,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.binaryauthorization_v1beta1.BinauthzManagementServiceV1Beta1Client.GetAttestor", + extra={ + "serviceName": "google.cloud.binaryauthorization.v1beta1.BinauthzManagementServiceV1Beta1", + "rpcName": "GetAttestor", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = BinauthzManagementServiceV1Beta1RestTransport._GetAttestor._get_response( self._host, @@ -617,7 +745,29 @@ def __call__( pb_resp = resources.Attestor.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_attestor(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = resources.Attestor.to_json(response) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.binaryauthorization_v1beta1.BinauthzManagementServiceV1Beta1Client.get_attestor", + extra={ + "serviceName": "google.cloud.binaryauthorization.v1beta1.BinauthzManagementServiceV1Beta1", + "rpcName": "GetAttestor", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _GetPolicy( @@ -655,7 +805,7 @@ 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.Policy: r"""Call the get policy method over HTTP. @@ -666,8 +816,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each 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.Policy: @@ -680,6 +832,7 @@ def __call__( http_options = ( _BaseBinauthzManagementServiceV1Beta1RestTransport._BaseGetPolicy._get_http_options() ) + request, metadata = self._interceptor.pre_get_policy(request, metadata) transcoded_request = _BaseBinauthzManagementServiceV1Beta1RestTransport._BaseGetPolicy._get_transcoded_request( http_options, request @@ -690,6 +843,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.binaryauthorization_v1beta1.BinauthzManagementServiceV1Beta1Client.GetPolicy", + extra={ + "serviceName": "google.cloud.binaryauthorization.v1beta1.BinauthzManagementServiceV1Beta1", + "rpcName": "GetPolicy", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ( BinauthzManagementServiceV1Beta1RestTransport._GetPolicy._get_response( @@ -712,7 +892,29 @@ def __call__( pb_resp = resources.Policy.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_policy(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = resources.Policy.to_json(response) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.binaryauthorization_v1beta1.BinauthzManagementServiceV1Beta1Client.get_policy", + extra={ + "serviceName": "google.cloud.binaryauthorization.v1beta1.BinauthzManagementServiceV1Beta1", + "rpcName": "GetPolicy", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ListAttestors( @@ -750,7 +952,7 @@ 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.ListAttestorsResponse: r"""Call the list attestors method over HTTP. @@ -761,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: ~.service.ListAttestorsResponse: @@ -774,6 +978,7 @@ def __call__( http_options = ( _BaseBinauthzManagementServiceV1Beta1RestTransport._BaseListAttestors._get_http_options() ) + request, metadata = self._interceptor.pre_list_attestors(request, metadata) transcoded_request = _BaseBinauthzManagementServiceV1Beta1RestTransport._BaseListAttestors._get_transcoded_request( http_options, request @@ -784,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.binaryauthorization_v1beta1.BinauthzManagementServiceV1Beta1Client.ListAttestors", + extra={ + "serviceName": "google.cloud.binaryauthorization.v1beta1.BinauthzManagementServiceV1Beta1", + "rpcName": "ListAttestors", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = BinauthzManagementServiceV1Beta1RestTransport._ListAttestors._get_response( self._host, @@ -804,7 +1036,29 @@ def __call__( pb_resp = service.ListAttestorsResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_attestors(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = service.ListAttestorsResponse.to_json(response) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.binaryauthorization_v1beta1.BinauthzManagementServiceV1Beta1Client.list_attestors", + extra={ + "serviceName": "google.cloud.binaryauthorization.v1beta1.BinauthzManagementServiceV1Beta1", + "rpcName": "ListAttestors", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _UpdateAttestor( @@ -843,7 +1097,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> resources.Attestor: r"""Call the update attestor method over HTTP. @@ -854,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: ~.resources.Attestor: @@ -869,6 +1125,7 @@ def __call__( http_options = ( _BaseBinauthzManagementServiceV1Beta1RestTransport._BaseUpdateAttestor._get_http_options() ) + request, metadata = self._interceptor.pre_update_attestor(request, metadata) transcoded_request = _BaseBinauthzManagementServiceV1Beta1RestTransport._BaseUpdateAttestor._get_transcoded_request( http_options, request @@ -883,6 +1140,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.binaryauthorization_v1beta1.BinauthzManagementServiceV1Beta1Client.UpdateAttestor", + extra={ + "serviceName": "google.cloud.binaryauthorization.v1beta1.BinauthzManagementServiceV1Beta1", + "rpcName": "UpdateAttestor", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = BinauthzManagementServiceV1Beta1RestTransport._UpdateAttestor._get_response( self._host, @@ -904,7 +1188,29 @@ def __call__( pb_resp = resources.Attestor.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_update_attestor(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = resources.Attestor.to_json(response) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.binaryauthorization_v1beta1.BinauthzManagementServiceV1Beta1Client.update_attestor", + extra={ + "serviceName": "google.cloud.binaryauthorization.v1beta1.BinauthzManagementServiceV1Beta1", + "rpcName": "UpdateAttestor", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _UpdatePolicy( @@ -943,7 +1249,7 @@ 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.Policy: r"""Call the update policy method over HTTP. @@ -954,8 +1260,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each 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.Policy: @@ -968,6 +1276,7 @@ def __call__( http_options = ( _BaseBinauthzManagementServiceV1Beta1RestTransport._BaseUpdatePolicy._get_http_options() ) + request, metadata = self._interceptor.pre_update_policy(request, metadata) transcoded_request = _BaseBinauthzManagementServiceV1Beta1RestTransport._BaseUpdatePolicy._get_transcoded_request( http_options, request @@ -982,6 +1291,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.binaryauthorization_v1beta1.BinauthzManagementServiceV1Beta1Client.UpdatePolicy", + extra={ + "serviceName": "google.cloud.binaryauthorization.v1beta1.BinauthzManagementServiceV1Beta1", + "rpcName": "UpdatePolicy", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = BinauthzManagementServiceV1Beta1RestTransport._UpdatePolicy._get_response( self._host, @@ -1003,7 +1339,29 @@ def __call__( pb_resp = resources.Policy.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_update_policy(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = resources.Policy.to_json(response) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.binaryauthorization_v1beta1.BinauthzManagementServiceV1Beta1Client.update_policy", + extra={ + "serviceName": "google.cloud.binaryauthorization.v1beta1.BinauthzManagementServiceV1Beta1", + "rpcName": "UpdatePolicy", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp @property diff --git a/packages/google-cloud-binary-authorization/google/cloud/binaryauthorization_v1beta1/services/system_policy_v1_beta1/async_client.py b/packages/google-cloud-binary-authorization/google/cloud/binaryauthorization_v1beta1/services/system_policy_v1_beta1/async_client.py index d041cd8db3e8..a74287edb412 100644 --- a/packages/google-cloud-binary-authorization/google/cloud/binaryauthorization_v1beta1/services/system_policy_v1_beta1/async_client.py +++ b/packages/google-cloud-binary-authorization/google/cloud/binaryauthorization_v1beta1/services/system_policy_v1_beta1/async_client.py @@ -14,6 +14,7 @@ # limitations under the License. # from collections import OrderedDict +import logging as std_logging import re from typing import ( Callable, @@ -50,6 +51,15 @@ from .transports.base import DEFAULT_CLIENT_INFO, SystemPolicyV1Beta1Transport from .transports.grpc_asyncio import SystemPolicyV1Beta1GrpcAsyncIOTransport +try: + from google.api_core import client_logging # type: ignore + + CLIENT_LOGGING_SUPPORTED = True # pragma: NO COVER +except ImportError: # pragma: NO COVER + CLIENT_LOGGING_SUPPORTED = False + +_LOGGER = std_logging.getLogger(__name__) + class SystemPolicyV1Beta1AsyncClient: """API for working with the system policy.""" @@ -259,6 +269,28 @@ def __init__( client_info=client_info, ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + std_logging.DEBUG + ): # pragma: NO COVER + _LOGGER.debug( + "Created client `google.cloud.binaryauthorization_v1beta1.SystemPolicyV1Beta1AsyncClient`.", + extra={ + "serviceName": "google.cloud.binaryauthorization.v1beta1.SystemPolicyV1Beta1", + "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.binaryauthorization.v1beta1.SystemPolicyV1Beta1", + "credentialsType": None, + }, + ) + async def get_system_policy( self, request: Optional[Union[service.GetSystemPolicyRequest, dict]] = None, @@ -266,7 +298,7 @@ async def get_system_policy( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> resources.Policy: r"""Gets the current system policy in the specified location. @@ -312,8 +344,10 @@ async def sample_get_system_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.binaryauthorization_v1beta1.types.Policy: diff --git a/packages/google-cloud-binary-authorization/google/cloud/binaryauthorization_v1beta1/services/system_policy_v1_beta1/client.py b/packages/google-cloud-binary-authorization/google/cloud/binaryauthorization_v1beta1/services/system_policy_v1_beta1/client.py index 41cb4ed15afe..43b7d624fc96 100644 --- a/packages/google-cloud-binary-authorization/google/cloud/binaryauthorization_v1beta1/services/system_policy_v1_beta1/client.py +++ b/packages/google-cloud-binary-authorization/google/cloud/binaryauthorization_v1beta1/services/system_policy_v1_beta1/client.py @@ -14,6 +14,7 @@ # limitations under the License. # from collections import OrderedDict +import logging as std_logging import os import re from typing import ( @@ -48,6 +49,15 @@ except AttributeError: # pragma: NO COVER OptionalRetry = Union[retries.Retry, object, None] # type: ignore +try: + from google.api_core import client_logging # type: ignore + + CLIENT_LOGGING_SUPPORTED = True # pragma: NO COVER +except ImportError: # pragma: NO COVER + CLIENT_LOGGING_SUPPORTED = False + +_LOGGER = std_logging.getLogger(__name__) + from google.protobuf import timestamp_pb2 # type: ignore from google.cloud.binaryauthorization_v1beta1.types import resources, service @@ -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( @@ -642,6 +656,29 @@ def __init__( api_audience=self._client_options.api_audience, ) + if "async" not in str(self._transport): + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + std_logging.DEBUG + ): # pragma: NO COVER + _LOGGER.debug( + "Created client `google.cloud.binaryauthorization_v1beta1.SystemPolicyV1Beta1Client`.", + extra={ + "serviceName": "google.cloud.binaryauthorization.v1beta1.SystemPolicyV1Beta1", + "universeDomain": getattr( + self._transport._credentials, "universe_domain", "" + ), + "credentialsType": f"{type(self._transport._credentials).__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.binaryauthorization.v1beta1.SystemPolicyV1Beta1", + "credentialsType": None, + }, + ) + def get_system_policy( self, request: Optional[Union[service.GetSystemPolicyRequest, dict]] = None, @@ -649,7 +686,7 @@ def get_system_policy( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> resources.Policy: r"""Gets the current system policy in the specified location. @@ -695,8 +732,10 @@ def sample_get_system_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.binaryauthorization_v1beta1.types.Policy: diff --git a/packages/google-cloud-binary-authorization/google/cloud/binaryauthorization_v1beta1/services/system_policy_v1_beta1/transports/grpc.py b/packages/google-cloud-binary-authorization/google/cloud/binaryauthorization_v1beta1/services/system_policy_v1_beta1/transports/grpc.py index 6ef0a7a61c62..16c7f0bba2c4 100644 --- a/packages/google-cloud-binary-authorization/google/cloud/binaryauthorization_v1beta1/services/system_policy_v1_beta1/transports/grpc.py +++ b/packages/google-cloud-binary-authorization/google/cloud/binaryauthorization_v1beta1/services/system_policy_v1_beta1/transports/grpc.py @@ -13,6 +13,9 @@ # See the License for the specific language governing permissions and # limitations under the License. # +import json +import logging as std_logging +import pickle from typing import Callable, Dict, Optional, Sequence, Tuple, Union import warnings @@ -20,12 +23,90 @@ import google.auth # type: ignore from google.auth import credentials as ga_credentials # type: ignore from google.auth.transport.grpc import SslCredentials # type: ignore +from google.protobuf.json_format import MessageToJson +import google.protobuf.message import grpc # type: ignore +import proto # type: ignore from google.cloud.binaryauthorization_v1beta1.types import resources, service from .base import DEFAULT_CLIENT_INFO, SystemPolicyV1Beta1Transport +try: + from google.api_core import client_logging # 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.binaryauthorization.v1beta1.SystemPolicyV1Beta1", + "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.binaryauthorization.v1beta1.SystemPolicyV1Beta1", + "rpcName": client_call_details.method, + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class SystemPolicyV1Beta1GrpcTransport(SystemPolicyV1Beta1Transport): """gRPC backend transport for SystemPolicyV1Beta1. @@ -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 @@ -254,7 +340,7 @@ def get_system_policy( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_system_policy" not in self._stubs: - self._stubs["get_system_policy"] = self.grpc_channel.unary_unary( + self._stubs["get_system_policy"] = self._logged_channel.unary_unary( "/google.cloud.binaryauthorization.v1beta1.SystemPolicyV1Beta1/GetSystemPolicy", request_serializer=service.GetSystemPolicyRequest.serialize, response_deserializer=resources.Policy.deserialize, @@ -262,7 +348,7 @@ def get_system_policy( return self._stubs["get_system_policy"] def close(self): - self.grpc_channel.close() + self._logged_channel.close() @property def kind(self) -> str: diff --git a/packages/google-cloud-binary-authorization/google/cloud/binaryauthorization_v1beta1/services/system_policy_v1_beta1/transports/grpc_asyncio.py b/packages/google-cloud-binary-authorization/google/cloud/binaryauthorization_v1beta1/services/system_policy_v1_beta1/transports/grpc_asyncio.py index 1bba5b5a554a..a2ce51d8b8cd 100644 --- a/packages/google-cloud-binary-authorization/google/cloud/binaryauthorization_v1beta1/services/system_policy_v1_beta1/transports/grpc_asyncio.py +++ b/packages/google-cloud-binary-authorization/google/cloud/binaryauthorization_v1beta1/services/system_policy_v1_beta1/transports/grpc_asyncio.py @@ -14,6 +14,9 @@ # limitations under the License. # import inspect +import json +import logging as std_logging +import pickle from typing import Awaitable, Callable, Dict, Optional, Sequence, Tuple, Union import warnings @@ -22,14 +25,93 @@ from google.api_core import retry_async as retries from google.auth import credentials as ga_credentials # type: ignore from google.auth.transport.grpc import SslCredentials # type: ignore +from google.protobuf.json_format import MessageToJson +import google.protobuf.message import grpc # type: ignore from grpc.experimental import aio # type: ignore +import proto # type: ignore from google.cloud.binaryauthorization_v1beta1.types import resources, service from .base import DEFAULT_CLIENT_INFO, SystemPolicyV1Beta1Transport from .grpc import SystemPolicyV1Beta1GrpcTransport +try: + from google.api_core import client_logging # 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.binaryauthorization.v1beta1.SystemPolicyV1Beta1", + "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.binaryauthorization.v1beta1.SystemPolicyV1Beta1", + "rpcName": str(client_call_details.method), + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class SystemPolicyV1Beta1GrpcAsyncIOTransport(SystemPolicyV1Beta1Transport): """gRPC AsyncIO backend transport for SystemPolicyV1Beta1. @@ -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 @@ -262,7 +347,7 @@ def get_system_policy( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_system_policy" not in self._stubs: - self._stubs["get_system_policy"] = self.grpc_channel.unary_unary( + self._stubs["get_system_policy"] = self._logged_channel.unary_unary( "/google.cloud.binaryauthorization.v1beta1.SystemPolicyV1Beta1/GetSystemPolicy", request_serializer=service.GetSystemPolicyRequest.serialize, response_deserializer=resources.Policy.deserialize, @@ -285,7 +370,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-binary-authorization/google/cloud/binaryauthorization_v1beta1/services/system_policy_v1_beta1/transports/rest.py b/packages/google-cloud-binary-authorization/google/cloud/binaryauthorization_v1beta1/services/system_policy_v1_beta1/transports/rest.py index 3048dc8af05b..c060c2bf08f3 100644 --- a/packages/google-cloud-binary-authorization/google/cloud/binaryauthorization_v1beta1/services/system_policy_v1_beta1/transports/rest.py +++ b/packages/google-cloud-binary-authorization/google/cloud/binaryauthorization_v1beta1/services/system_policy_v1_beta1/transports/rest.py @@ -13,9 +13,9 @@ # See the License for the specific language governing permissions and # limitations under the License. # - import dataclasses import json # type: ignore +import logging from typing import Any, Callable, Dict, List, Optional, Sequence, Tuple, Union import warnings @@ -37,6 +37,14 @@ except AttributeError: # pragma: NO COVER OptionalRetry = Union[retries.Retry, object, None] # type: ignore +try: + from google.api_core import client_logging # type: ignore + + CLIENT_LOGGING_SUPPORTED = True # pragma: NO COVER +except ImportError: # pragma: NO COVER + CLIENT_LOGGING_SUPPORTED = False + +_LOGGER = logging.getLogger(__name__) DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo( gapic_version=BASE_DEFAULT_CLIENT_INFO.gapic_version, @@ -77,8 +85,8 @@ def post_get_system_policy(self, response): def pre_get_system_policy( self, request: service.GetSystemPolicyRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[service.GetSystemPolicyRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[service.GetSystemPolicyRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for get_system_policy Override in a subclass to manipulate the request or metadata @@ -217,7 +225,7 @@ 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.Policy: r"""Call the get system policy method over HTTP. @@ -228,8 +236,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each 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.Policy: @@ -242,6 +252,7 @@ def __call__( http_options = ( _BaseSystemPolicyV1Beta1RestTransport._BaseGetSystemPolicy._get_http_options() ) + request, metadata = self._interceptor.pre_get_system_policy( request, metadata ) @@ -254,6 +265,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.binaryauthorization_v1beta1.SystemPolicyV1Beta1Client.GetSystemPolicy", + extra={ + "serviceName": "google.cloud.binaryauthorization.v1beta1.SystemPolicyV1Beta1", + "rpcName": "GetSystemPolicy", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = SystemPolicyV1Beta1RestTransport._GetSystemPolicy._get_response( self._host, @@ -274,7 +312,29 @@ def __call__( pb_resp = resources.Policy.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_system_policy(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = resources.Policy.to_json(response) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.binaryauthorization_v1beta1.SystemPolicyV1Beta1Client.get_system_policy", + extra={ + "serviceName": "google.cloud.binaryauthorization.v1beta1.SystemPolicyV1Beta1", + "rpcName": "GetSystemPolicy", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp @property diff --git a/packages/google-cloud-binary-authorization/samples/generated_samples/snippet_metadata_google.cloud.binaryauthorization.v1.json b/packages/google-cloud-binary-authorization/samples/generated_samples/snippet_metadata_google.cloud.binaryauthorization.v1.json index 1c782ac5a11a..d3f819ebeddc 100644 --- a/packages/google-cloud-binary-authorization/samples/generated_samples/snippet_metadata_google.cloud.binaryauthorization.v1.json +++ b/packages/google-cloud-binary-authorization/samples/generated_samples/snippet_metadata_google.cloud.binaryauthorization.v1.json @@ -8,7 +8,7 @@ ], "language": "PYTHON", "name": "google-cloud-binary-authorization", - "version": "1.11.1" + "version": "0.1.0" }, "snippets": [ { @@ -55,7 +55,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.binaryauthorization_v1.types.Attestor", @@ -143,7 +143,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.binaryauthorization_v1.types.Attestor", @@ -224,7 +224,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "shortName": "delete_attestor" @@ -301,7 +301,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "shortName": "delete_attestor" @@ -379,7 +379,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.binaryauthorization_v1.types.Attestor", @@ -459,7 +459,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.binaryauthorization_v1.types.Attestor", @@ -540,7 +540,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.binaryauthorization_v1.types.Policy", @@ -620,7 +620,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.binaryauthorization_v1.types.Policy", @@ -701,7 +701,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.binaryauthorization_v1.services.binauthz_management_service_v1.pagers.ListAttestorsAsyncPager", @@ -781,7 +781,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.binaryauthorization_v1.services.binauthz_management_service_v1.pagers.ListAttestorsPager", @@ -862,7 +862,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.binaryauthorization_v1.types.Attestor", @@ -942,7 +942,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.binaryauthorization_v1.types.Attestor", @@ -1023,7 +1023,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.binaryauthorization_v1.types.Policy", @@ -1103,7 +1103,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.binaryauthorization_v1.types.Policy", @@ -1184,7 +1184,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.binaryauthorization_v1.types.Policy", @@ -1264,7 +1264,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.binaryauthorization_v1.types.Policy", @@ -1341,7 +1341,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.binaryauthorization_v1.types.ValidateAttestationOccurrenceResponse", @@ -1417,7 +1417,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.binaryauthorization_v1.types.ValidateAttestationOccurrenceResponse", diff --git a/packages/google-cloud-binary-authorization/samples/generated_samples/snippet_metadata_google.cloud.binaryauthorization.v1beta1.json b/packages/google-cloud-binary-authorization/samples/generated_samples/snippet_metadata_google.cloud.binaryauthorization.v1beta1.json index 076840734bfd..1e9460cea8ee 100644 --- a/packages/google-cloud-binary-authorization/samples/generated_samples/snippet_metadata_google.cloud.binaryauthorization.v1beta1.json +++ b/packages/google-cloud-binary-authorization/samples/generated_samples/snippet_metadata_google.cloud.binaryauthorization.v1beta1.json @@ -8,7 +8,7 @@ ], "language": "PYTHON", "name": "google-cloud-binary-authorization", - "version": "1.11.1" + "version": "0.1.0" }, "snippets": [ { @@ -55,7 +55,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.binaryauthorization_v1beta1.types.Attestor", @@ -143,7 +143,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.binaryauthorization_v1beta1.types.Attestor", @@ -224,7 +224,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "shortName": "delete_attestor" @@ -301,7 +301,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "shortName": "delete_attestor" @@ -379,7 +379,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.binaryauthorization_v1beta1.types.Attestor", @@ -459,7 +459,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.binaryauthorization_v1beta1.types.Attestor", @@ -540,7 +540,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.binaryauthorization_v1beta1.types.Policy", @@ -620,7 +620,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.binaryauthorization_v1beta1.types.Policy", @@ -701,7 +701,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.binaryauthorization_v1beta1.services.binauthz_management_service_v1_beta1.pagers.ListAttestorsAsyncPager", @@ -781,7 +781,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.binaryauthorization_v1beta1.services.binauthz_management_service_v1_beta1.pagers.ListAttestorsPager", @@ -862,7 +862,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.binaryauthorization_v1beta1.types.Attestor", @@ -942,7 +942,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.binaryauthorization_v1beta1.types.Attestor", @@ -1023,7 +1023,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.binaryauthorization_v1beta1.types.Policy", @@ -1103,7 +1103,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.binaryauthorization_v1beta1.types.Policy", @@ -1184,7 +1184,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.binaryauthorization_v1beta1.types.Policy", @@ -1264,7 +1264,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.binaryauthorization_v1beta1.types.Policy", diff --git a/packages/google-cloud-binary-authorization/tests/unit/gapic/binaryauthorization_v1/test_binauthz_management_service_v1.py b/packages/google-cloud-binary-authorization/tests/unit/gapic/binaryauthorization_v1/test_binauthz_management_service_v1.py index dbf9b366a305..db66ba0e415f 100644 --- a/packages/google-cloud-binary-authorization/tests/unit/gapic/binaryauthorization_v1/test_binauthz_management_service_v1.py +++ b/packages/google-cloud-binary-authorization/tests/unit/gapic/binaryauthorization_v1/test_binauthz_management_service_v1.py @@ -3718,6 +3718,7 @@ def test_get_policy_rest_required_fields(request_type=service.GetPolicyRequest): response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.get_policy(request) @@ -3763,6 +3764,7 @@ def test_get_policy_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.get_policy(**mock_args) @@ -3886,6 +3888,7 @@ def test_update_policy_rest_required_fields(request_type=service.UpdatePolicyReq response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.update_policy(request) @@ -3931,6 +3934,7 @@ def test_update_policy_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.update_policy(**mock_args) @@ -4070,6 +4074,7 @@ def test_create_attestor_rest_required_fields( response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.create_attestor(request) @@ -4132,6 +4137,7 @@ def test_create_attestor_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.create_attestor(**mock_args) @@ -4261,6 +4267,7 @@ def test_get_attestor_rest_required_fields(request_type=service.GetAttestorReque response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.get_attestor(request) @@ -4306,6 +4313,7 @@ def test_get_attestor_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.get_attestor(**mock_args) @@ -4431,6 +4439,7 @@ def test_update_attestor_rest_required_fields( response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.update_attestor(request) @@ -4476,6 +4485,7 @@ def test_update_attestor_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.update_attestor(**mock_args) @@ -4611,6 +4621,7 @@ def test_list_attestors_rest_required_fields(request_type=service.ListAttestorsR response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.list_attestors(request) @@ -4664,6 +4675,7 @@ def test_list_attestors_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.list_attestors(**mock_args) @@ -4851,6 +4863,7 @@ def test_delete_attestor_rest_required_fields( response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.delete_attestor(request) @@ -4894,6 +4907,7 @@ def test_delete_attestor_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_attestor(**mock_args) @@ -5406,6 +5420,7 @@ def test_get_policy_rest_bad_request(request_type=service.GetPolicyRequest): response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.get_policy(request) @@ -5443,6 +5458,7 @@ def test_get_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_policy(request) # Establish that the response is the type that we expect. @@ -5486,6 +5502,7 @@ def test_get_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 = resources.Policy.to_json(resources.Policy()) req.return_value.content = return_value @@ -5528,6 +5545,7 @@ def test_update_policy_rest_bad_request(request_type=service.UpdatePolicyRequest response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.update_policy(request) @@ -5651,6 +5669,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.update_policy(request) # Establish that the response is the type that we expect. @@ -5694,6 +5713,7 @@ def test_update_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 = resources.Policy.to_json(resources.Policy()) req.return_value.content = return_value @@ -5736,6 +5756,7 @@ def test_create_attestor_rest_bad_request(request_type=service.CreateAttestorReq response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.create_attestor(request) @@ -5859,6 +5880,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.create_attestor(request) # Establish that the response is the type that we expect. @@ -5898,6 +5920,7 @@ def test_create_attestor_rest_interceptors(null_interceptor): req.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.Attestor.to_json(resources.Attestor()) req.return_value.content = return_value @@ -5940,6 +5963,7 @@ def test_get_attestor_rest_bad_request(request_type=service.GetAttestorRequest): response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.get_attestor(request) @@ -5976,6 +6000,7 @@ def test_get_attestor_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.get_attestor(request) # Establish that the response is the type that we expect. @@ -6015,6 +6040,7 @@ def test_get_attestor_rest_interceptors(null_interceptor): req.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.Attestor.to_json(resources.Attestor()) req.return_value.content = return_value @@ -6057,6 +6083,7 @@ def test_update_attestor_rest_bad_request(request_type=service.UpdateAttestorReq response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.update_attestor(request) @@ -6180,6 +6207,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.update_attestor(request) # Establish that the response is the type that we expect. @@ -6219,6 +6247,7 @@ def test_update_attestor_rest_interceptors(null_interceptor): req.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.Attestor.to_json(resources.Attestor()) req.return_value.content = return_value @@ -6261,6 +6290,7 @@ def test_list_attestors_rest_bad_request(request_type=service.ListAttestorsReque response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.list_attestors(request) @@ -6296,6 +6326,7 @@ def test_list_attestors_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.list_attestors(request) # Establish that the response is the type that we expect. @@ -6334,6 +6365,7 @@ def test_list_attestors_rest_interceptors(null_interceptor): req.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.ListAttestorsResponse.to_json( service.ListAttestorsResponse() ) @@ -6378,6 +6410,7 @@ def test_delete_attestor_rest_bad_request(request_type=service.DeleteAttestorReq response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.delete_attestor(request) @@ -6408,6 +6441,7 @@ def test_delete_attestor_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_attestor(request) # Establish that the response is the type that we expect. @@ -6442,6 +6476,7 @@ def test_delete_attestor_rest_interceptors(null_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.DeleteAttestorRequest() metadata = [ diff --git a/packages/google-cloud-binary-authorization/tests/unit/gapic/binaryauthorization_v1/test_system_policy_v1.py b/packages/google-cloud-binary-authorization/tests/unit/gapic/binaryauthorization_v1/test_system_policy_v1.py index 238de5153e22..938fc36413b1 100644 --- a/packages/google-cloud-binary-authorization/tests/unit/gapic/binaryauthorization_v1/test_system_policy_v1.py +++ b/packages/google-cloud-binary-authorization/tests/unit/gapic/binaryauthorization_v1/test_system_policy_v1.py @@ -1517,6 +1517,7 @@ def test_get_system_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_system_policy(request) @@ -1562,6 +1563,7 @@ def test_get_system_policy_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.get_system_policy(**mock_args) @@ -1791,6 +1793,7 @@ def test_get_system_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_system_policy(request) @@ -1828,6 +1831,7 @@ def test_get_system_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_system_policy(request) # Establish that the response is the type that we expect. @@ -1871,6 +1875,7 @@ def test_get_system_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 = resources.Policy.to_json(resources.Policy()) req.return_value.content = return_value diff --git a/packages/google-cloud-binary-authorization/tests/unit/gapic/binaryauthorization_v1/test_validation_helper_v1.py b/packages/google-cloud-binary-authorization/tests/unit/gapic/binaryauthorization_v1/test_validation_helper_v1.py index deef7b1a5d01..614c6fc6b159 100644 --- a/packages/google-cloud-binary-authorization/tests/unit/gapic/binaryauthorization_v1/test_validation_helper_v1.py +++ b/packages/google-cloud-binary-authorization/tests/unit/gapic/binaryauthorization_v1/test_validation_helper_v1.py @@ -1488,6 +1488,7 @@ def test_validate_attestation_occurrence_rest_required_fields( response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.validate_attestation_occurrence(request) @@ -1718,6 +1719,7 @@ def test_validate_attestation_occurrence_rest_bad_request( response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.validate_attestation_occurrence(request) @@ -1754,6 +1756,7 @@ def test_validate_attestation_occurrence_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.validate_attestation_occurrence(request) # Establish that the response is the type that we expect. @@ -1799,6 +1802,7 @@ def test_validate_attestation_occurrence_rest_interceptors(null_interceptor): req.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.ValidateAttestationOccurrenceResponse.to_json( service.ValidateAttestationOccurrenceResponse() ) diff --git a/packages/google-cloud-binary-authorization/tests/unit/gapic/binaryauthorization_v1beta1/test_binauthz_management_service_v1_beta1.py b/packages/google-cloud-binary-authorization/tests/unit/gapic/binaryauthorization_v1beta1/test_binauthz_management_service_v1_beta1.py index 69ad9bc3eb1e..caacaa039933 100644 --- a/packages/google-cloud-binary-authorization/tests/unit/gapic/binaryauthorization_v1beta1/test_binauthz_management_service_v1_beta1.py +++ b/packages/google-cloud-binary-authorization/tests/unit/gapic/binaryauthorization_v1beta1/test_binauthz_management_service_v1_beta1.py @@ -3740,6 +3740,7 @@ def test_get_policy_rest_required_fields(request_type=service.GetPolicyRequest): response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.get_policy(request) @@ -3785,6 +3786,7 @@ def test_get_policy_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.get_policy(**mock_args) @@ -3908,6 +3910,7 @@ def test_update_policy_rest_required_fields(request_type=service.UpdatePolicyReq response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.update_policy(request) @@ -3953,6 +3956,7 @@ def test_update_policy_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.update_policy(**mock_args) @@ -4093,6 +4097,7 @@ def test_create_attestor_rest_required_fields( response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.create_attestor(request) @@ -4155,6 +4160,7 @@ def test_create_attestor_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.create_attestor(**mock_args) @@ -4284,6 +4290,7 @@ def test_get_attestor_rest_required_fields(request_type=service.GetAttestorReque response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.get_attestor(request) @@ -4329,6 +4336,7 @@ def test_get_attestor_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.get_attestor(**mock_args) @@ -4454,6 +4462,7 @@ def test_update_attestor_rest_required_fields( response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.update_attestor(request) @@ -4499,6 +4508,7 @@ def test_update_attestor_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.update_attestor(**mock_args) @@ -4635,6 +4645,7 @@ def test_list_attestors_rest_required_fields(request_type=service.ListAttestorsR response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.list_attestors(request) @@ -4688,6 +4699,7 @@ def test_list_attestors_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.list_attestors(**mock_args) @@ -4875,6 +4887,7 @@ def test_delete_attestor_rest_required_fields( response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.delete_attestor(request) @@ -4918,6 +4931,7 @@ def test_delete_attestor_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_attestor(**mock_args) @@ -5430,6 +5444,7 @@ def test_get_policy_rest_bad_request(request_type=service.GetPolicyRequest): response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.get_policy(request) @@ -5467,6 +5482,7 @@ def test_get_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_policy(request) # Establish that the response is the type that we expect. @@ -5510,6 +5526,7 @@ def test_get_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 = resources.Policy.to_json(resources.Policy()) req.return_value.content = return_value @@ -5552,6 +5569,7 @@ def test_update_policy_rest_bad_request(request_type=service.UpdatePolicyRequest response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.update_policy(request) @@ -5675,6 +5693,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.update_policy(request) # Establish that the response is the type that we expect. @@ -5718,6 +5737,7 @@ def test_update_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 = resources.Policy.to_json(resources.Policy()) req.return_value.content = return_value @@ -5760,6 +5780,7 @@ def test_create_attestor_rest_bad_request(request_type=service.CreateAttestorReq response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.create_attestor(request) @@ -5883,6 +5904,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.create_attestor(request) # Establish that the response is the type that we expect. @@ -5924,6 +5946,7 @@ def test_create_attestor_rest_interceptors(null_interceptor): req.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.Attestor.to_json(resources.Attestor()) req.return_value.content = return_value @@ -5966,6 +5989,7 @@ def test_get_attestor_rest_bad_request(request_type=service.GetAttestorRequest): response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.get_attestor(request) @@ -6002,6 +6026,7 @@ def test_get_attestor_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.get_attestor(request) # Establish that the response is the type that we expect. @@ -6041,6 +6066,7 @@ def test_get_attestor_rest_interceptors(null_interceptor): req.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.Attestor.to_json(resources.Attestor()) req.return_value.content = return_value @@ -6083,6 +6109,7 @@ def test_update_attestor_rest_bad_request(request_type=service.UpdateAttestorReq response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.update_attestor(request) @@ -6206,6 +6233,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.update_attestor(request) # Establish that the response is the type that we expect. @@ -6247,6 +6275,7 @@ def test_update_attestor_rest_interceptors(null_interceptor): req.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.Attestor.to_json(resources.Attestor()) req.return_value.content = return_value @@ -6289,6 +6318,7 @@ def test_list_attestors_rest_bad_request(request_type=service.ListAttestorsReque response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.list_attestors(request) @@ -6324,6 +6354,7 @@ def test_list_attestors_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.list_attestors(request) # Establish that the response is the type that we expect. @@ -6363,6 +6394,7 @@ def test_list_attestors_rest_interceptors(null_interceptor): req.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.ListAttestorsResponse.to_json( service.ListAttestorsResponse() ) @@ -6407,6 +6439,7 @@ def test_delete_attestor_rest_bad_request(request_type=service.DeleteAttestorReq response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.delete_attestor(request) @@ -6437,6 +6470,7 @@ def test_delete_attestor_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_attestor(request) # Establish that the response is the type that we expect. @@ -6472,6 +6506,7 @@ def test_delete_attestor_rest_interceptors(null_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.DeleteAttestorRequest() metadata = [ diff --git a/packages/google-cloud-binary-authorization/tests/unit/gapic/binaryauthorization_v1beta1/test_system_policy_v1_beta1.py b/packages/google-cloud-binary-authorization/tests/unit/gapic/binaryauthorization_v1beta1/test_system_policy_v1_beta1.py index a1f7defa50ae..a087ff6756ca 100644 --- a/packages/google-cloud-binary-authorization/tests/unit/gapic/binaryauthorization_v1beta1/test_system_policy_v1_beta1.py +++ b/packages/google-cloud-binary-authorization/tests/unit/gapic/binaryauthorization_v1beta1/test_system_policy_v1_beta1.py @@ -1573,6 +1573,7 @@ def test_get_system_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_system_policy(request) @@ -1618,6 +1619,7 @@ def test_get_system_policy_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.get_system_policy(**mock_args) @@ -1847,6 +1849,7 @@ def test_get_system_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_system_policy(request) @@ -1884,6 +1887,7 @@ def test_get_system_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_system_policy(request) # Establish that the response is the type that we expect. @@ -1927,6 +1931,7 @@ def test_get_system_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 = resources.Policy.to_json(resources.Policy()) req.return_value.content = return_value diff --git a/packages/google-cloud-build/google/cloud/devtools/cloudbuild/gapic_version.py b/packages/google-cloud-build/google/cloud/devtools/cloudbuild/gapic_version.py index 7af2fa694463..558c8aab67c5 100644 --- a/packages/google-cloud-build/google/cloud/devtools/cloudbuild/gapic_version.py +++ b/packages/google-cloud-build/google/cloud/devtools/cloudbuild/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-build/google/cloud/devtools/cloudbuild_v1/gapic_version.py b/packages/google-cloud-build/google/cloud/devtools/cloudbuild_v1/gapic_version.py index 7af2fa694463..558c8aab67c5 100644 --- a/packages/google-cloud-build/google/cloud/devtools/cloudbuild_v1/gapic_version.py +++ b/packages/google-cloud-build/google/cloud/devtools/cloudbuild_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-build/google/cloud/devtools/cloudbuild_v1/services/cloud_build/async_client.py b/packages/google-cloud-build/google/cloud/devtools/cloudbuild_v1/services/cloud_build/async_client.py index d617fec2eb4a..060166408631 100644 --- a/packages/google-cloud-build/google/cloud/devtools/cloudbuild_v1/services/cloud_build/async_client.py +++ b/packages/google-cloud-build/google/cloud/devtools/cloudbuild_v1/services/cloud_build/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, CloudBuildTransport from .transports.grpc_asyncio import CloudBuildGrpcAsyncIOTransport +try: + from google.api_core import client_logging # type: ignore + + CLIENT_LOGGING_SUPPORTED = True # pragma: NO COVER +except ImportError: # pragma: NO COVER + CLIENT_LOGGING_SUPPORTED = False + +_LOGGER = std_logging.getLogger(__name__) + class CloudBuildAsyncClient: """Creates and manages builds on Google Cloud Platform. @@ -293,6 +303,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.cloudbuild_v1.CloudBuildAsyncClient`.", + extra={ + "serviceName": "google.devtools.cloudbuild.v1.CloudBuild", + "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.cloudbuild.v1.CloudBuild", + "credentialsType": None, + }, + ) + async def create_build( self, request: Optional[Union[cloudbuild.CreateBuildRequest, dict]] = None, @@ -301,7 +333,7 @@ async def create_build( build: Optional[cloudbuild.Build] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation_async.AsyncOperation: r"""Starts a build with the specified configuration. @@ -355,8 +387,10 @@ async def sample_create_build(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.api_core.operation_async.AsyncOperation: @@ -462,7 +496,7 @@ async def get_build( id: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> cloudbuild.Build: r"""Returns information about a previously requested build. @@ -513,8 +547,10 @@ async def sample_get_build(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.devtools.cloudbuild_v1.types.Build: @@ -608,7 +644,7 @@ async def list_builds( 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.ListBuildsAsyncPager: r"""Lists previously requested builds. @@ -660,8 +696,10 @@ async def sample_list_builds(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.devtools.cloudbuild_v1.services.cloud_build.pagers.ListBuildsAsyncPager: @@ -747,7 +785,7 @@ async def cancel_build( id: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> cloudbuild.Build: r"""Cancels a build in progress. @@ -794,8 +832,10 @@ async def sample_cancel_build(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.devtools.cloudbuild_v1.types.Build: @@ -889,7 +929,7 @@ async def retry_build( id: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, 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 build based on the specified build. @@ -971,8 +1011,10 @@ async def sample_retry_build(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.api_core.operation_async.AsyncOperation: @@ -1078,7 +1120,7 @@ async def approve_build( approval_result: Optional[cloudbuild.ApprovalResult] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation_async.AsyncOperation: r"""Approves or rejects a pending build. @@ -1136,8 +1178,10 @@ async def sample_approve_build(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.api_core.operation_async.AsyncOperation: @@ -1243,7 +1287,7 @@ async def create_build_trigger( trigger: Optional[cloudbuild.BuildTrigger] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> cloudbuild.BuildTrigger: r"""Creates a new ``BuildTrigger``. @@ -1297,8 +1341,10 @@ async def sample_create_build_trigger(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.devtools.cloudbuild_v1.types.BuildTrigger: @@ -1371,7 +1417,7 @@ async def get_build_trigger( trigger_id: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> cloudbuild.BuildTrigger: r"""Returns information about a ``BuildTrigger``. @@ -1424,8 +1470,10 @@ async def sample_get_build_trigger(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.devtools.cloudbuild_v1.types.BuildTrigger: @@ -1497,7 +1545,7 @@ async def list_build_triggers( project_id: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListBuildTriggersAsyncPager: r"""Lists existing ``BuildTrigger``\ s. @@ -1543,8 +1591,10 @@ async def sample_list_build_triggers(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.devtools.cloudbuild_v1.services.cloud_build.pagers.ListBuildTriggersAsyncPager: @@ -1627,7 +1677,7 @@ async def delete_build_trigger( trigger_id: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.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 ``BuildTrigger`` by its project ID and trigger ID. @@ -1675,8 +1725,10 @@ async def sample_delete_build_trigger(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. """ # Create or coerce a protobuf request object. # - Quick check: If we got a request object, we should *not* have @@ -1740,7 +1792,7 @@ async def update_build_trigger( trigger: Optional[cloudbuild.BuildTrigger] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> cloudbuild.BuildTrigger: r"""Updates a ``BuildTrigger`` by its project ID and trigger ID. @@ -1800,8 +1852,10 @@ async def sample_update_build_trigger(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.devtools.cloudbuild_v1.types.BuildTrigger: @@ -1877,7 +1931,7 @@ async def run_build_trigger( source: Optional[cloudbuild.RepoSource] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation_async.AsyncOperation: r"""Runs a ``BuildTrigger`` at a particular source revision. @@ -1943,8 +1997,10 @@ async def sample_run_build_trigger(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.api_core.operation_async.AsyncOperation: @@ -2050,7 +2106,7 @@ async def receive_trigger_webhook( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> cloudbuild.ReceiveTriggerWebhookResponse: r"""ReceiveTriggerWebhook [Experimental] is called when the API receives a webhook request targeted at a specific trigger. @@ -2088,8 +2144,10 @@ async def sample_receive_trigger_webhook(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.devtools.cloudbuild_v1.types.ReceiveTriggerWebhookResponse: @@ -2143,7 +2201,7 @@ async def create_worker_pool( worker_pool_id: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, 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 ``WorkerPool``. @@ -2208,8 +2266,10 @@ async def sample_create_worker_pool(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.api_core.operation_async.AsyncOperation: @@ -2307,7 +2367,7 @@ async def get_worker_pool( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> cloudbuild.WorkerPool: r"""Returns details of a ``WorkerPool``. @@ -2351,8 +2411,10 @@ async def sample_get_worker_pool(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.devtools.cloudbuild_v1.types.WorkerPool: @@ -2434,7 +2496,7 @@ async def delete_worker_pool( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation_async.AsyncOperation: r"""Deletes a ``WorkerPool``. @@ -2482,8 +2544,10 @@ async def sample_delete_worker_pool(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.api_core.operation_async.AsyncOperation: @@ -2571,7 +2635,7 @@ async def update_worker_pool( update_mask: Optional[field_mask_pb2.FieldMask] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation_async.AsyncOperation: r"""Updates a ``WorkerPool``. @@ -2627,8 +2691,10 @@ async def sample_update_worker_pool(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.api_core.operation_async.AsyncOperation: @@ -2724,7 +2790,7 @@ async def list_worker_pools( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListWorkerPoolsAsyncPager: r"""Lists ``WorkerPool``\ s. @@ -2769,8 +2835,10 @@ async def sample_list_worker_pools(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.devtools.cloudbuild_v1.services.cloud_build.pagers.ListWorkerPoolsAsyncPager: diff --git a/packages/google-cloud-build/google/cloud/devtools/cloudbuild_v1/services/cloud_build/client.py b/packages/google-cloud-build/google/cloud/devtools/cloudbuild_v1/services/cloud_build/client.py index b851a7ccd636..348efb88cb69 100644 --- a/packages/google-cloud-build/google/cloud/devtools/cloudbuild_v1/services/cloud_build/client.py +++ b/packages/google-cloud-build/google/cloud/devtools/cloudbuild_v1/services/cloud_build/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 duration_pb2 # type: ignore @@ -813,6 +823,10 @@ def __init__( # Initialize the universe domain validation. self._is_universe_domain_valid = False + if CLIENT_LOGGING_SUPPORTED: # pragma: NO COVER + # Setup logging. + client_logging.initialize_logging() + api_key_value = getattr(self._client_options, "api_key", None) if api_key_value and credentials: raise ValueError( @@ -875,6 +889,29 @@ def __init__( api_audience=self._client_options.api_audience, ) + if "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.cloudbuild_v1.CloudBuildClient`.", + extra={ + "serviceName": "google.devtools.cloudbuild.v1.CloudBuild", + "universeDomain": getattr( + self._transport._credentials, "universe_domain", "" + ), + "credentialsType": f"{type(self._transport._credentials).__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.cloudbuild.v1.CloudBuild", + "credentialsType": None, + }, + ) + def create_build( self, request: Optional[Union[cloudbuild.CreateBuildRequest, dict]] = None, @@ -883,7 +920,7 @@ def create_build( build: Optional[cloudbuild.Build] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation.Operation: r"""Starts a build with the specified configuration. @@ -937,8 +974,10 @@ def sample_create_build(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.api_core.operation.Operation: @@ -1041,7 +1080,7 @@ def get_build( id: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> cloudbuild.Build: r"""Returns information about a previously requested build. @@ -1092,8 +1131,10 @@ def sample_get_build(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.devtools.cloudbuild_v1.types.Build: @@ -1184,7 +1225,7 @@ def list_builds( 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.ListBuildsPager: r"""Lists previously requested builds. @@ -1236,8 +1277,10 @@ def sample_list_builds(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.devtools.cloudbuild_v1.services.cloud_build.pagers.ListBuildsPager: @@ -1320,7 +1363,7 @@ def cancel_build( id: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> cloudbuild.Build: r"""Cancels a build in progress. @@ -1367,8 +1410,10 @@ def sample_cancel_build(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.devtools.cloudbuild_v1.types.Build: @@ -1459,7 +1504,7 @@ def retry_build( id: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.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 build based on the specified build. @@ -1541,8 +1586,10 @@ def sample_retry_build(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.api_core.operation.Operation: @@ -1645,7 +1692,7 @@ def approve_build( approval_result: Optional[cloudbuild.ApprovalResult] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation.Operation: r"""Approves or rejects a pending build. @@ -1703,8 +1750,10 @@ def sample_approve_build(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.api_core.operation.Operation: @@ -1807,7 +1856,7 @@ def create_build_trigger( trigger: Optional[cloudbuild.BuildTrigger] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> cloudbuild.BuildTrigger: r"""Creates a new ``BuildTrigger``. @@ -1861,8 +1910,10 @@ def sample_create_build_trigger(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.devtools.cloudbuild_v1.types.BuildTrigger: @@ -1932,7 +1983,7 @@ def get_build_trigger( trigger_id: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> cloudbuild.BuildTrigger: r"""Returns information about a ``BuildTrigger``. @@ -1985,8 +2036,10 @@ def sample_get_build_trigger(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.devtools.cloudbuild_v1.types.BuildTrigger: @@ -2055,7 +2108,7 @@ def list_build_triggers( project_id: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListBuildTriggersPager: r"""Lists existing ``BuildTrigger``\ s. @@ -2101,8 +2154,10 @@ def sample_list_build_triggers(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.devtools.cloudbuild_v1.services.cloud_build.pagers.ListBuildTriggersPager: @@ -2182,7 +2237,7 @@ def delete_build_trigger( trigger_id: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.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 ``BuildTrigger`` by its project ID and trigger ID. @@ -2230,8 +2285,10 @@ def sample_delete_build_trigger(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. """ # Create or coerce a protobuf request object. # - Quick check: If we got a request object, we should *not* have @@ -2292,7 +2349,7 @@ def update_build_trigger( trigger: Optional[cloudbuild.BuildTrigger] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> cloudbuild.BuildTrigger: r"""Updates a ``BuildTrigger`` by its project ID and trigger ID. @@ -2352,8 +2409,10 @@ def sample_update_build_trigger(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.devtools.cloudbuild_v1.types.BuildTrigger: @@ -2426,7 +2485,7 @@ def run_build_trigger( source: Optional[cloudbuild.RepoSource] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation.Operation: r"""Runs a ``BuildTrigger`` at a particular source revision. @@ -2492,8 +2551,10 @@ def sample_run_build_trigger(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.api_core.operation.Operation: @@ -2596,7 +2657,7 @@ def receive_trigger_webhook( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> cloudbuild.ReceiveTriggerWebhookResponse: r"""ReceiveTriggerWebhook [Experimental] is called when the API receives a webhook request targeted at a specific trigger. @@ -2634,8 +2695,10 @@ def sample_receive_trigger_webhook(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.devtools.cloudbuild_v1.types.ReceiveTriggerWebhookResponse: @@ -2687,7 +2750,7 @@ def create_worker_pool( worker_pool_id: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.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 ``WorkerPool``. @@ -2752,8 +2815,10 @@ def sample_create_worker_pool(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.api_core.operation.Operation: @@ -2848,7 +2913,7 @@ def get_worker_pool( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> cloudbuild.WorkerPool: r"""Returns details of a ``WorkerPool``. @@ -2892,8 +2957,10 @@ def sample_get_worker_pool(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.devtools.cloudbuild_v1.types.WorkerPool: @@ -2972,7 +3039,7 @@ def delete_worker_pool( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation.Operation: r"""Deletes a ``WorkerPool``. @@ -3020,8 +3087,10 @@ def sample_delete_worker_pool(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.api_core.operation.Operation: @@ -3106,7 +3175,7 @@ def update_worker_pool( update_mask: Optional[field_mask_pb2.FieldMask] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation.Operation: r"""Updates a ``WorkerPool``. @@ -3162,8 +3231,10 @@ def sample_update_worker_pool(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.api_core.operation.Operation: @@ -3256,7 +3327,7 @@ def list_worker_pools( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListWorkerPoolsPager: r"""Lists ``WorkerPool``\ s. @@ -3301,8 +3372,10 @@ def sample_list_worker_pools(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.devtools.cloudbuild_v1.services.cloud_build.pagers.ListWorkerPoolsPager: diff --git a/packages/google-cloud-build/google/cloud/devtools/cloudbuild_v1/services/cloud_build/pagers.py b/packages/google-cloud-build/google/cloud/devtools/cloudbuild_v1/services/cloud_build/pagers.py index 253c8242d1bd..6d992e059fbf 100644 --- a/packages/google-cloud-build/google/cloud/devtools/cloudbuild_v1/services/cloud_build/pagers.py +++ b/packages/google-cloud-build/google/cloud/devtools/cloudbuild_v1/services/cloud_build/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 = cloudbuild.ListBuildsRequest(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 = cloudbuild.ListBuildsRequest(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 = cloudbuild.ListBuildTriggersRequest(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 = cloudbuild.ListBuildTriggersRequest(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 = cloudbuild.ListWorkerPoolsRequest(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 = cloudbuild.ListWorkerPoolsRequest(request) diff --git a/packages/google-cloud-build/google/cloud/devtools/cloudbuild_v1/services/cloud_build/transports/grpc.py b/packages/google-cloud-build/google/cloud/devtools/cloudbuild_v1/services/cloud_build/transports/grpc.py index a8510315392c..f95489c013cc 100644 --- a/packages/google-cloud-build/google/cloud/devtools/cloudbuild_v1/services/cloud_build/transports/grpc.py +++ b/packages/google-cloud-build/google/cloud/devtools/cloudbuild_v1/services/cloud_build/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.devtools.cloudbuild_v1.types import cloudbuild from .base import DEFAULT_CLIENT_INFO, CloudBuildTransport +try: + from google.api_core import client_logging # 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.cloudbuild.v1.CloudBuild", + "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.cloudbuild.v1.CloudBuild", + "rpcName": client_call_details.method, + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class CloudBuildGrpcTransport(CloudBuildTransport): """gRPC backend transport for CloudBuild. @@ -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 @@ -253,7 +339,9 @@ def operations_client(self) -> operations_v1.OperationsClient: """ # Quick check: Only create a new client if we do not already have one. if self._operations_client is None: - self._operations_client = operations_v1.OperationsClient(self.grpc_channel) + self._operations_client = operations_v1.OperationsClient( + self._logged_channel + ) # Return the client from cache. return self._operations_client @@ -281,7 +369,7 @@ def create_build( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_build" not in self._stubs: - self._stubs["create_build"] = self.grpc_channel.unary_unary( + self._stubs["create_build"] = self._logged_channel.unary_unary( "/google.devtools.cloudbuild.v1.CloudBuild/CreateBuild", request_serializer=cloudbuild.CreateBuildRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -309,7 +397,7 @@ def get_build(self) -> Callable[[cloudbuild.GetBuildRequest], cloudbuild.Build]: # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_build" not in self._stubs: - self._stubs["get_build"] = self.grpc_channel.unary_unary( + self._stubs["get_build"] = self._logged_channel.unary_unary( "/google.devtools.cloudbuild.v1.CloudBuild/GetBuild", request_serializer=cloudbuild.GetBuildRequest.serialize, response_deserializer=cloudbuild.Build.deserialize, @@ -338,7 +426,7 @@ def list_builds( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_builds" not in self._stubs: - self._stubs["list_builds"] = self.grpc_channel.unary_unary( + self._stubs["list_builds"] = self._logged_channel.unary_unary( "/google.devtools.cloudbuild.v1.CloudBuild/ListBuilds", request_serializer=cloudbuild.ListBuildsRequest.serialize, response_deserializer=cloudbuild.ListBuildsResponse.deserialize, @@ -364,7 +452,7 @@ def cancel_build( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "cancel_build" not in self._stubs: - self._stubs["cancel_build"] = self.grpc_channel.unary_unary( + self._stubs["cancel_build"] = self._logged_channel.unary_unary( "/google.devtools.cloudbuild.v1.CloudBuild/CancelBuild", request_serializer=cloudbuild.CancelBuildRequest.serialize, response_deserializer=cloudbuild.Build.deserialize, @@ -419,7 +507,7 @@ def retry_build( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "retry_build" not in self._stubs: - self._stubs["retry_build"] = self.grpc_channel.unary_unary( + self._stubs["retry_build"] = self._logged_channel.unary_unary( "/google.devtools.cloudbuild.v1.CloudBuild/RetryBuild", request_serializer=cloudbuild.RetryBuildRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -450,7 +538,7 @@ def approve_build( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "approve_build" not in self._stubs: - self._stubs["approve_build"] = self.grpc_channel.unary_unary( + self._stubs["approve_build"] = self._logged_channel.unary_unary( "/google.devtools.cloudbuild.v1.CloudBuild/ApproveBuild", request_serializer=cloudbuild.ApproveBuildRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -478,7 +566,7 @@ def create_build_trigger( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_build_trigger" not in self._stubs: - self._stubs["create_build_trigger"] = self.grpc_channel.unary_unary( + self._stubs["create_build_trigger"] = self._logged_channel.unary_unary( "/google.devtools.cloudbuild.v1.CloudBuild/CreateBuildTrigger", request_serializer=cloudbuild.CreateBuildTriggerRequest.serialize, response_deserializer=cloudbuild.BuildTrigger.deserialize, @@ -506,7 +594,7 @@ def get_build_trigger( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_build_trigger" not in self._stubs: - self._stubs["get_build_trigger"] = self.grpc_channel.unary_unary( + self._stubs["get_build_trigger"] = self._logged_channel.unary_unary( "/google.devtools.cloudbuild.v1.CloudBuild/GetBuildTrigger", request_serializer=cloudbuild.GetBuildTriggerRequest.serialize, response_deserializer=cloudbuild.BuildTrigger.deserialize, @@ -536,7 +624,7 @@ def list_build_triggers( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_build_triggers" not in self._stubs: - self._stubs["list_build_triggers"] = self.grpc_channel.unary_unary( + self._stubs["list_build_triggers"] = self._logged_channel.unary_unary( "/google.devtools.cloudbuild.v1.CloudBuild/ListBuildTriggers", request_serializer=cloudbuild.ListBuildTriggersRequest.serialize, response_deserializer=cloudbuild.ListBuildTriggersResponse.deserialize, @@ -564,7 +652,7 @@ def delete_build_trigger( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_build_trigger" not in self._stubs: - self._stubs["delete_build_trigger"] = self.grpc_channel.unary_unary( + self._stubs["delete_build_trigger"] = self._logged_channel.unary_unary( "/google.devtools.cloudbuild.v1.CloudBuild/DeleteBuildTrigger", request_serializer=cloudbuild.DeleteBuildTriggerRequest.serialize, response_deserializer=empty_pb2.Empty.FromString, @@ -592,7 +680,7 @@ def update_build_trigger( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_build_trigger" not in self._stubs: - self._stubs["update_build_trigger"] = self.grpc_channel.unary_unary( + self._stubs["update_build_trigger"] = self._logged_channel.unary_unary( "/google.devtools.cloudbuild.v1.CloudBuild/UpdateBuildTrigger", request_serializer=cloudbuild.UpdateBuildTriggerRequest.serialize, response_deserializer=cloudbuild.BuildTrigger.deserialize, @@ -624,7 +712,7 @@ def run_build_trigger( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "run_build_trigger" not in self._stubs: - self._stubs["run_build_trigger"] = self.grpc_channel.unary_unary( + self._stubs["run_build_trigger"] = self._logged_channel.unary_unary( "/google.devtools.cloudbuild.v1.CloudBuild/RunBuildTrigger", request_serializer=cloudbuild.RunBuildTriggerRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -654,7 +742,7 @@ def receive_trigger_webhook( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "receive_trigger_webhook" not in self._stubs: - self._stubs["receive_trigger_webhook"] = self.grpc_channel.unary_unary( + self._stubs["receive_trigger_webhook"] = self._logged_channel.unary_unary( "/google.devtools.cloudbuild.v1.CloudBuild/ReceiveTriggerWebhook", request_serializer=cloudbuild.ReceiveTriggerWebhookRequest.serialize, response_deserializer=cloudbuild.ReceiveTriggerWebhookResponse.deserialize, @@ -680,7 +768,7 @@ def create_worker_pool( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_worker_pool" not in self._stubs: - self._stubs["create_worker_pool"] = self.grpc_channel.unary_unary( + self._stubs["create_worker_pool"] = self._logged_channel.unary_unary( "/google.devtools.cloudbuild.v1.CloudBuild/CreateWorkerPool", request_serializer=cloudbuild.CreateWorkerPoolRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -706,7 +794,7 @@ def get_worker_pool( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_worker_pool" not in self._stubs: - self._stubs["get_worker_pool"] = self.grpc_channel.unary_unary( + self._stubs["get_worker_pool"] = self._logged_channel.unary_unary( "/google.devtools.cloudbuild.v1.CloudBuild/GetWorkerPool", request_serializer=cloudbuild.GetWorkerPoolRequest.serialize, response_deserializer=cloudbuild.WorkerPool.deserialize, @@ -732,7 +820,7 @@ def delete_worker_pool( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_worker_pool" not in self._stubs: - self._stubs["delete_worker_pool"] = self.grpc_channel.unary_unary( + self._stubs["delete_worker_pool"] = self._logged_channel.unary_unary( "/google.devtools.cloudbuild.v1.CloudBuild/DeleteWorkerPool", request_serializer=cloudbuild.DeleteWorkerPoolRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -758,7 +846,7 @@ def update_worker_pool( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_worker_pool" not in self._stubs: - self._stubs["update_worker_pool"] = self.grpc_channel.unary_unary( + self._stubs["update_worker_pool"] = self._logged_channel.unary_unary( "/google.devtools.cloudbuild.v1.CloudBuild/UpdateWorkerPool", request_serializer=cloudbuild.UpdateWorkerPoolRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -786,7 +874,7 @@ def list_worker_pools( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_worker_pools" not in self._stubs: - self._stubs["list_worker_pools"] = self.grpc_channel.unary_unary( + self._stubs["list_worker_pools"] = self._logged_channel.unary_unary( "/google.devtools.cloudbuild.v1.CloudBuild/ListWorkerPools", request_serializer=cloudbuild.ListWorkerPoolsRequest.serialize, response_deserializer=cloudbuild.ListWorkerPoolsResponse.deserialize, @@ -794,7 +882,7 @@ def list_worker_pools( return self._stubs["list_worker_pools"] def close(self): - self.grpc_channel.close() + self._logged_channel.close() @property def kind(self) -> str: diff --git a/packages/google-cloud-build/google/cloud/devtools/cloudbuild_v1/services/cloud_build/transports/grpc_asyncio.py b/packages/google-cloud-build/google/cloud/devtools/cloudbuild_v1/services/cloud_build/transports/grpc_asyncio.py index 00f7e2b950fc..7626dd4c23f6 100644 --- a/packages/google-cloud-build/google/cloud/devtools/cloudbuild_v1/services/cloud_build/transports/grpc_asyncio.py +++ b/packages/google-cloud-build/google/cloud/devtools/cloudbuild_v1/services/cloud_build/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.devtools.cloudbuild_v1.types import cloudbuild from .base import DEFAULT_CLIENT_INFO, CloudBuildTransport from .grpc import CloudBuildGrpcTransport +try: + from google.api_core import client_logging # 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.cloudbuild.v1.CloudBuild", + "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.cloudbuild.v1.CloudBuild", + "rpcName": str(client_call_details.method), + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class CloudBuildGrpcAsyncIOTransport(CloudBuildTransport): """gRPC AsyncIO backend transport for CloudBuild. @@ -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 @@ -262,7 +347,7 @@ def operations_client(self) -> operations_v1.OperationsAsyncClient: # Quick check: Only create a new client if we do not already have one. if self._operations_client is None: self._operations_client = operations_v1.OperationsAsyncClient( - self.grpc_channel + self._logged_channel ) # Return the client from cache. @@ -291,7 +376,7 @@ def create_build( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_build" not in self._stubs: - self._stubs["create_build"] = self.grpc_channel.unary_unary( + self._stubs["create_build"] = self._logged_channel.unary_unary( "/google.devtools.cloudbuild.v1.CloudBuild/CreateBuild", request_serializer=cloudbuild.CreateBuildRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -321,7 +406,7 @@ def get_build( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_build" not in self._stubs: - self._stubs["get_build"] = self.grpc_channel.unary_unary( + self._stubs["get_build"] = self._logged_channel.unary_unary( "/google.devtools.cloudbuild.v1.CloudBuild/GetBuild", request_serializer=cloudbuild.GetBuildRequest.serialize, response_deserializer=cloudbuild.Build.deserialize, @@ -352,7 +437,7 @@ def list_builds( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_builds" not in self._stubs: - self._stubs["list_builds"] = self.grpc_channel.unary_unary( + self._stubs["list_builds"] = self._logged_channel.unary_unary( "/google.devtools.cloudbuild.v1.CloudBuild/ListBuilds", request_serializer=cloudbuild.ListBuildsRequest.serialize, response_deserializer=cloudbuild.ListBuildsResponse.deserialize, @@ -378,7 +463,7 @@ def cancel_build( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "cancel_build" not in self._stubs: - self._stubs["cancel_build"] = self.grpc_channel.unary_unary( + self._stubs["cancel_build"] = self._logged_channel.unary_unary( "/google.devtools.cloudbuild.v1.CloudBuild/CancelBuild", request_serializer=cloudbuild.CancelBuildRequest.serialize, response_deserializer=cloudbuild.Build.deserialize, @@ -433,7 +518,7 @@ def retry_build( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "retry_build" not in self._stubs: - self._stubs["retry_build"] = self.grpc_channel.unary_unary( + self._stubs["retry_build"] = self._logged_channel.unary_unary( "/google.devtools.cloudbuild.v1.CloudBuild/RetryBuild", request_serializer=cloudbuild.RetryBuildRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -466,7 +551,7 @@ def approve_build( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "approve_build" not in self._stubs: - self._stubs["approve_build"] = self.grpc_channel.unary_unary( + self._stubs["approve_build"] = self._logged_channel.unary_unary( "/google.devtools.cloudbuild.v1.CloudBuild/ApproveBuild", request_serializer=cloudbuild.ApproveBuildRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -496,7 +581,7 @@ def create_build_trigger( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_build_trigger" not in self._stubs: - self._stubs["create_build_trigger"] = self.grpc_channel.unary_unary( + self._stubs["create_build_trigger"] = self._logged_channel.unary_unary( "/google.devtools.cloudbuild.v1.CloudBuild/CreateBuildTrigger", request_serializer=cloudbuild.CreateBuildTriggerRequest.serialize, response_deserializer=cloudbuild.BuildTrigger.deserialize, @@ -526,7 +611,7 @@ def get_build_trigger( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_build_trigger" not in self._stubs: - self._stubs["get_build_trigger"] = self.grpc_channel.unary_unary( + self._stubs["get_build_trigger"] = self._logged_channel.unary_unary( "/google.devtools.cloudbuild.v1.CloudBuild/GetBuildTrigger", request_serializer=cloudbuild.GetBuildTriggerRequest.serialize, response_deserializer=cloudbuild.BuildTrigger.deserialize, @@ -557,7 +642,7 @@ def list_build_triggers( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_build_triggers" not in self._stubs: - self._stubs["list_build_triggers"] = self.grpc_channel.unary_unary( + self._stubs["list_build_triggers"] = self._logged_channel.unary_unary( "/google.devtools.cloudbuild.v1.CloudBuild/ListBuildTriggers", request_serializer=cloudbuild.ListBuildTriggersRequest.serialize, response_deserializer=cloudbuild.ListBuildTriggersResponse.deserialize, @@ -585,7 +670,7 @@ def delete_build_trigger( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_build_trigger" not in self._stubs: - self._stubs["delete_build_trigger"] = self.grpc_channel.unary_unary( + self._stubs["delete_build_trigger"] = self._logged_channel.unary_unary( "/google.devtools.cloudbuild.v1.CloudBuild/DeleteBuildTrigger", request_serializer=cloudbuild.DeleteBuildTriggerRequest.serialize, response_deserializer=empty_pb2.Empty.FromString, @@ -615,7 +700,7 @@ def update_build_trigger( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_build_trigger" not in self._stubs: - self._stubs["update_build_trigger"] = self.grpc_channel.unary_unary( + self._stubs["update_build_trigger"] = self._logged_channel.unary_unary( "/google.devtools.cloudbuild.v1.CloudBuild/UpdateBuildTrigger", request_serializer=cloudbuild.UpdateBuildTriggerRequest.serialize, response_deserializer=cloudbuild.BuildTrigger.deserialize, @@ -649,7 +734,7 @@ def run_build_trigger( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "run_build_trigger" not in self._stubs: - self._stubs["run_build_trigger"] = self.grpc_channel.unary_unary( + self._stubs["run_build_trigger"] = self._logged_channel.unary_unary( "/google.devtools.cloudbuild.v1.CloudBuild/RunBuildTrigger", request_serializer=cloudbuild.RunBuildTriggerRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -679,7 +764,7 @@ def receive_trigger_webhook( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "receive_trigger_webhook" not in self._stubs: - self._stubs["receive_trigger_webhook"] = self.grpc_channel.unary_unary( + self._stubs["receive_trigger_webhook"] = self._logged_channel.unary_unary( "/google.devtools.cloudbuild.v1.CloudBuild/ReceiveTriggerWebhook", request_serializer=cloudbuild.ReceiveTriggerWebhookRequest.serialize, response_deserializer=cloudbuild.ReceiveTriggerWebhookResponse.deserialize, @@ -707,7 +792,7 @@ def create_worker_pool( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_worker_pool" not in self._stubs: - self._stubs["create_worker_pool"] = self.grpc_channel.unary_unary( + self._stubs["create_worker_pool"] = self._logged_channel.unary_unary( "/google.devtools.cloudbuild.v1.CloudBuild/CreateWorkerPool", request_serializer=cloudbuild.CreateWorkerPoolRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -733,7 +818,7 @@ def get_worker_pool( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_worker_pool" not in self._stubs: - self._stubs["get_worker_pool"] = self.grpc_channel.unary_unary( + self._stubs["get_worker_pool"] = self._logged_channel.unary_unary( "/google.devtools.cloudbuild.v1.CloudBuild/GetWorkerPool", request_serializer=cloudbuild.GetWorkerPoolRequest.serialize, response_deserializer=cloudbuild.WorkerPool.deserialize, @@ -761,7 +846,7 @@ def delete_worker_pool( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_worker_pool" not in self._stubs: - self._stubs["delete_worker_pool"] = self.grpc_channel.unary_unary( + self._stubs["delete_worker_pool"] = self._logged_channel.unary_unary( "/google.devtools.cloudbuild.v1.CloudBuild/DeleteWorkerPool", request_serializer=cloudbuild.DeleteWorkerPoolRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -789,7 +874,7 @@ def update_worker_pool( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_worker_pool" not in self._stubs: - self._stubs["update_worker_pool"] = self.grpc_channel.unary_unary( + self._stubs["update_worker_pool"] = self._logged_channel.unary_unary( "/google.devtools.cloudbuild.v1.CloudBuild/UpdateWorkerPool", request_serializer=cloudbuild.UpdateWorkerPoolRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -818,7 +903,7 @@ def list_worker_pools( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_worker_pools" not in self._stubs: - self._stubs["list_worker_pools"] = self.grpc_channel.unary_unary( + self._stubs["list_worker_pools"] = self._logged_channel.unary_unary( "/google.devtools.cloudbuild.v1.CloudBuild/ListWorkerPools", request_serializer=cloudbuild.ListWorkerPoolsRequest.serialize, response_deserializer=cloudbuild.ListWorkerPoolsResponse.deserialize, @@ -996,7 +1081,7 @@ def _wrap_method(self, func, *args, **kwargs): return gapic_v1.method_async.wrap_method(func, *args, **kwargs) def close(self): - return self.grpc_channel.close() + return self._logged_channel.close() @property def kind(self) -> str: diff --git a/packages/google-cloud-build/google/cloud/devtools/cloudbuild_v1/services/cloud_build/transports/rest.py b/packages/google-cloud-build/google/cloud/devtools/cloudbuild_v1/services/cloud_build/transports/rest.py index 7f031fcc783a..f3b4ff8c54ec 100644 --- a/packages/google-cloud-build/google/cloud/devtools/cloudbuild_v1/services/cloud_build/transports/rest.py +++ b/packages/google-cloud-build/google/cloud/devtools/cloudbuild_v1/services/cloud_build/transports/rest.py @@ -13,9 +13,9 @@ # See the License for the specific language governing permissions and # limitations 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, @@ -211,8 +219,8 @@ def post_update_worker_pool(self, response): def pre_approve_build( self, request: cloudbuild.ApproveBuildRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[cloudbuild.ApproveBuildRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[cloudbuild.ApproveBuildRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for approve_build Override in a subclass to manipulate the request or metadata @@ -234,8 +242,8 @@ def post_approve_build( def pre_cancel_build( self, request: cloudbuild.CancelBuildRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[cloudbuild.CancelBuildRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[cloudbuild.CancelBuildRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for cancel_build Override in a subclass to manipulate the request or metadata @@ -255,8 +263,8 @@ def post_cancel_build(self, response: cloudbuild.Build) -> cloudbuild.Build: def pre_create_build( self, request: cloudbuild.CreateBuildRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[cloudbuild.CreateBuildRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[cloudbuild.CreateBuildRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for create_build Override in a subclass to manipulate the request or metadata @@ -278,8 +286,10 @@ def post_create_build( def pre_create_build_trigger( self, request: cloudbuild.CreateBuildTriggerRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[cloudbuild.CreateBuildTriggerRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + cloudbuild.CreateBuildTriggerRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for create_build_trigger Override in a subclass to manipulate the request or metadata @@ -301,8 +311,10 @@ def post_create_build_trigger( def pre_create_worker_pool( self, request: cloudbuild.CreateWorkerPoolRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[cloudbuild.CreateWorkerPoolRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + cloudbuild.CreateWorkerPoolRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for create_worker_pool Override in a subclass to manipulate the request or metadata @@ -324,8 +336,10 @@ def post_create_worker_pool( def pre_delete_build_trigger( self, request: cloudbuild.DeleteBuildTriggerRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[cloudbuild.DeleteBuildTriggerRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + cloudbuild.DeleteBuildTriggerRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for delete_build_trigger Override in a subclass to manipulate the request or metadata @@ -336,8 +350,10 @@ def pre_delete_build_trigger( def pre_delete_worker_pool( self, request: cloudbuild.DeleteWorkerPoolRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[cloudbuild.DeleteWorkerPoolRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + cloudbuild.DeleteWorkerPoolRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for delete_worker_pool Override in a subclass to manipulate the request or metadata @@ -357,8 +373,10 @@ def post_delete_worker_pool( return response def pre_get_build( - self, request: cloudbuild.GetBuildRequest, metadata: Sequence[Tuple[str, str]] - ) -> Tuple[cloudbuild.GetBuildRequest, Sequence[Tuple[str, str]]]: + self, + request: cloudbuild.GetBuildRequest, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[cloudbuild.GetBuildRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for get_build Override in a subclass to manipulate the request or metadata @@ -378,8 +396,10 @@ def post_get_build(self, response: cloudbuild.Build) -> cloudbuild.Build: def pre_get_build_trigger( self, request: cloudbuild.GetBuildTriggerRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[cloudbuild.GetBuildTriggerRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + cloudbuild.GetBuildTriggerRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for get_build_trigger Override in a subclass to manipulate the request or metadata @@ -401,8 +421,10 @@ def post_get_build_trigger( def pre_get_worker_pool( self, request: cloudbuild.GetWorkerPoolRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[cloudbuild.GetWorkerPoolRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + cloudbuild.GetWorkerPoolRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for get_worker_pool Override in a subclass to manipulate the request or metadata @@ -422,8 +444,10 @@ def post_get_worker_pool( return response def pre_list_builds( - self, request: cloudbuild.ListBuildsRequest, metadata: Sequence[Tuple[str, str]] - ) -> Tuple[cloudbuild.ListBuildsRequest, Sequence[Tuple[str, str]]]: + self, + request: cloudbuild.ListBuildsRequest, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[cloudbuild.ListBuildsRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for list_builds Override in a subclass to manipulate the request or metadata @@ -445,8 +469,10 @@ def post_list_builds( def pre_list_build_triggers( self, request: cloudbuild.ListBuildTriggersRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[cloudbuild.ListBuildTriggersRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + cloudbuild.ListBuildTriggersRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for list_build_triggers Override in a subclass to manipulate the request or metadata @@ -468,8 +494,10 @@ def post_list_build_triggers( def pre_list_worker_pools( self, request: cloudbuild.ListWorkerPoolsRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[cloudbuild.ListWorkerPoolsRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + cloudbuild.ListWorkerPoolsRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for list_worker_pools Override in a subclass to manipulate the request or metadata @@ -491,8 +519,10 @@ def post_list_worker_pools( def pre_receive_trigger_webhook( self, request: cloudbuild.ReceiveTriggerWebhookRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[cloudbuild.ReceiveTriggerWebhookRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + cloudbuild.ReceiveTriggerWebhookRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for receive_trigger_webhook Override in a subclass to manipulate the request or metadata @@ -512,8 +542,10 @@ def post_receive_trigger_webhook( return response def pre_retry_build( - self, request: cloudbuild.RetryBuildRequest, metadata: Sequence[Tuple[str, str]] - ) -> Tuple[cloudbuild.RetryBuildRequest, Sequence[Tuple[str, str]]]: + self, + request: cloudbuild.RetryBuildRequest, + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[cloudbuild.RetryBuildRequest, Sequence[Tuple[str, Union[str, bytes]]]]: """Pre-rpc interceptor for retry_build Override in a subclass to manipulate the request or metadata @@ -535,8 +567,10 @@ def post_retry_build( def pre_run_build_trigger( self, request: cloudbuild.RunBuildTriggerRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[cloudbuild.RunBuildTriggerRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + cloudbuild.RunBuildTriggerRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for run_build_trigger Override in a subclass to manipulate the request or metadata @@ -558,8 +592,10 @@ def post_run_build_trigger( def pre_update_build_trigger( self, request: cloudbuild.UpdateBuildTriggerRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[cloudbuild.UpdateBuildTriggerRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + cloudbuild.UpdateBuildTriggerRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for update_build_trigger Override in a subclass to manipulate the request or metadata @@ -581,8 +617,10 @@ def post_update_build_trigger( def pre_update_worker_pool( self, request: cloudbuild.UpdateWorkerPoolRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[cloudbuild.UpdateWorkerPoolRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + cloudbuild.UpdateWorkerPoolRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for update_worker_pool Override in a subclass to manipulate the request or metadata @@ -781,7 +819,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Call the approve build method over HTTP. @@ -792,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: ~.operations_pb2.Operation: @@ -806,6 +846,7 @@ def __call__( http_options = ( _BaseCloudBuildRestTransport._BaseApproveBuild._get_http_options() ) + request, metadata = self._interceptor.pre_approve_build(request, metadata) transcoded_request = ( _BaseCloudBuildRestTransport._BaseApproveBuild._get_transcoded_request( @@ -826,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 = json_format.MessageToJson(request) + 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.cloudbuild_v1.CloudBuildClient.ApproveBuild", + extra={ + "serviceName": "google.devtools.cloudbuild.v1.CloudBuild", + "rpcName": "ApproveBuild", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = CloudBuildRestTransport._ApproveBuild._get_response( self._host, @@ -845,7 +913,29 @@ def __call__( # Return the response resp = operations_pb2.Operation() json_format.Parse(response.content, resp, ignore_unknown_fields=True) + resp = self._interceptor.post_approve_build(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = json_format.MessageToJson(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.cloudbuild_v1.CloudBuildClient.approve_build", + extra={ + "serviceName": "google.devtools.cloudbuild.v1.CloudBuild", + "rpcName": "ApproveBuild", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _CancelBuild( @@ -883,7 +973,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> cloudbuild.Build: r"""Call the cancel build method over HTTP. @@ -893,8 +983,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.cloudbuild.Build: @@ -928,6 +1020,7 @@ def __call__( http_options = ( _BaseCloudBuildRestTransport._BaseCancelBuild._get_http_options() ) + request, metadata = self._interceptor.pre_cancel_build(request, metadata) transcoded_request = ( _BaseCloudBuildRestTransport._BaseCancelBuild._get_transcoded_request( @@ -946,6 +1039,33 @@ def __call__( ) ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.devtools.cloudbuild_v1.CloudBuildClient.CancelBuild", + extra={ + "serviceName": "google.devtools.cloudbuild.v1.CloudBuild", + "rpcName": "CancelBuild", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = CloudBuildRestTransport._CancelBuild._get_response( self._host, @@ -967,7 +1087,29 @@ def __call__( pb_resp = cloudbuild.Build.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_cancel_build(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = cloudbuild.Build.to_json(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.cloudbuild_v1.CloudBuildClient.cancel_build", + extra={ + "serviceName": "google.devtools.cloudbuild.v1.CloudBuild", + "rpcName": "CancelBuild", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _CreateBuild( @@ -1005,7 +1147,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Call the create build method over HTTP. @@ -1015,8 +1157,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.operations_pb2.Operation: @@ -1029,6 +1173,7 @@ def __call__( http_options = ( _BaseCloudBuildRestTransport._BaseCreateBuild._get_http_options() ) + request, metadata = self._interceptor.pre_create_build(request, metadata) transcoded_request = ( _BaseCloudBuildRestTransport._BaseCreateBuild._get_transcoded_request( @@ -1047,6 +1192,33 @@ def __call__( ) ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + 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.cloudbuild_v1.CloudBuildClient.CreateBuild", + extra={ + "serviceName": "google.devtools.cloudbuild.v1.CloudBuild", + "rpcName": "CreateBuild", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = CloudBuildRestTransport._CreateBuild._get_response( self._host, @@ -1066,7 +1238,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_build(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = json_format.MessageToJson(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.cloudbuild_v1.CloudBuildClient.create_build", + extra={ + "serviceName": "google.devtools.cloudbuild.v1.CloudBuild", + "rpcName": "CreateBuild", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _CreateBuildTrigger( @@ -1104,7 +1298,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> cloudbuild.BuildTrigger: r"""Call the create build trigger method over HTTP. @@ -1114,8 +1308,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.cloudbuild.BuildTrigger: @@ -1128,6 +1324,7 @@ def __call__( http_options = ( _BaseCloudBuildRestTransport._BaseCreateBuildTrigger._get_http_options() ) + request, metadata = self._interceptor.pre_create_build_trigger( request, metadata ) @@ -1144,6 +1341,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + 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.cloudbuild_v1.CloudBuildClient.CreateBuildTrigger", + extra={ + "serviceName": "google.devtools.cloudbuild.v1.CloudBuild", + "rpcName": "CreateBuildTrigger", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = CloudBuildRestTransport._CreateBuildTrigger._get_response( self._host, @@ -1165,7 +1389,29 @@ def __call__( pb_resp = cloudbuild.BuildTrigger.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_create_build_trigger(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = cloudbuild.BuildTrigger.to_json(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.cloudbuild_v1.CloudBuildClient.create_build_trigger", + extra={ + "serviceName": "google.devtools.cloudbuild.v1.CloudBuild", + "rpcName": "CreateBuildTrigger", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _CreateWorkerPool( @@ -1203,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 create worker pool method over HTTP. @@ -1213,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: @@ -1227,6 +1475,7 @@ def __call__( http_options = ( _BaseCloudBuildRestTransport._BaseCreateWorkerPool._get_http_options() ) + request, metadata = self._interceptor.pre_create_worker_pool( request, metadata ) @@ -1243,6 +1492,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + 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.cloudbuild_v1.CloudBuildClient.CreateWorkerPool", + extra={ + "serviceName": "google.devtools.cloudbuild.v1.CloudBuild", + "rpcName": "CreateWorkerPool", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = CloudBuildRestTransport._CreateWorkerPool._get_response( self._host, @@ -1262,7 +1538,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_worker_pool(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = json_format.MessageToJson(resp) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.devtools.cloudbuild_v1.CloudBuildClient.create_worker_pool", + extra={ + "serviceName": "google.devtools.cloudbuild.v1.CloudBuild", + "rpcName": "CreateWorkerPool", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _DeleteBuildTrigger( @@ -1299,7 +1597,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ): r"""Call the delete build trigger method over HTTP. @@ -1309,13 +1607,16 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. """ http_options = ( _BaseCloudBuildRestTransport._BaseDeleteBuildTrigger._get_http_options() ) + request, metadata = self._interceptor.pre_delete_build_trigger( request, metadata ) @@ -1328,6 +1629,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + 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.cloudbuild_v1.CloudBuildClient.DeleteBuildTrigger", + extra={ + "serviceName": "google.devtools.cloudbuild.v1.CloudBuild", + "rpcName": "DeleteBuildTrigger", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = CloudBuildRestTransport._DeleteBuildTrigger._get_response( self._host, @@ -1377,7 +1705,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Call the delete worker pool method over HTTP. @@ -1387,8 +1715,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.operations_pb2.Operation: @@ -1401,6 +1731,7 @@ def __call__( http_options = ( _BaseCloudBuildRestTransport._BaseDeleteWorkerPool._get_http_options() ) + request, metadata = self._interceptor.pre_delete_worker_pool( request, metadata ) @@ -1413,6 +1744,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + 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.cloudbuild_v1.CloudBuildClient.DeleteWorkerPool", + extra={ + "serviceName": "google.devtools.cloudbuild.v1.CloudBuild", + "rpcName": "DeleteWorkerPool", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = CloudBuildRestTransport._DeleteWorkerPool._get_response( self._host, @@ -1431,7 +1789,29 @@ def __call__( # Return the response resp = operations_pb2.Operation() json_format.Parse(response.content, resp, ignore_unknown_fields=True) + resp = self._interceptor.post_delete_worker_pool(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = json_format.MessageToJson(resp) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.devtools.cloudbuild_v1.CloudBuildClient.delete_worker_pool", + extra={ + "serviceName": "google.devtools.cloudbuild.v1.CloudBuild", + "rpcName": "DeleteWorkerPool", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _GetBuild(_BaseCloudBuildRestTransport._BaseGetBuild, CloudBuildRestStub): @@ -1466,7 +1846,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> cloudbuild.Build: r"""Call the get build method over HTTP. @@ -1476,8 +1856,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.cloudbuild.Build: @@ -1511,6 +1893,7 @@ def __call__( http_options = ( _BaseCloudBuildRestTransport._BaseGetBuild._get_http_options() ) + request, metadata = self._interceptor.pre_get_build(request, metadata) transcoded_request = ( _BaseCloudBuildRestTransport._BaseGetBuild._get_transcoded_request( @@ -1525,6 +1908,33 @@ def __call__( ) ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + 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.cloudbuild_v1.CloudBuildClient.GetBuild", + extra={ + "serviceName": "google.devtools.cloudbuild.v1.CloudBuild", + "rpcName": "GetBuild", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = CloudBuildRestTransport._GetBuild._get_response( self._host, @@ -1545,7 +1955,29 @@ def __call__( pb_resp = cloudbuild.Build.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_build(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = cloudbuild.Build.to_json(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.cloudbuild_v1.CloudBuildClient.get_build", + extra={ + "serviceName": "google.devtools.cloudbuild.v1.CloudBuild", + "rpcName": "GetBuild", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _GetBuildTrigger( @@ -1582,7 +2014,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> cloudbuild.BuildTrigger: r"""Call the get build trigger method over HTTP. @@ -1592,8 +2024,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.cloudbuild.BuildTrigger: @@ -1606,6 +2040,7 @@ def __call__( http_options = ( _BaseCloudBuildRestTransport._BaseGetBuildTrigger._get_http_options() ) + request, metadata = self._interceptor.pre_get_build_trigger( request, metadata ) @@ -1618,6 +2053,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + 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.cloudbuild_v1.CloudBuildClient.GetBuildTrigger", + extra={ + "serviceName": "google.devtools.cloudbuild.v1.CloudBuild", + "rpcName": "GetBuildTrigger", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = CloudBuildRestTransport._GetBuildTrigger._get_response( self._host, @@ -1638,7 +2100,29 @@ def __call__( pb_resp = cloudbuild.BuildTrigger.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_build_trigger(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = cloudbuild.BuildTrigger.to_json(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.cloudbuild_v1.CloudBuildClient.get_build_trigger", + extra={ + "serviceName": "google.devtools.cloudbuild.v1.CloudBuild", + "rpcName": "GetBuildTrigger", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _GetWorkerPool( @@ -1675,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]]] = (), ) -> cloudbuild.WorkerPool: r"""Call the get worker pool method over HTTP. @@ -1685,8 +2169,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.cloudbuild.WorkerPool: @@ -1711,6 +2197,7 @@ def __call__( http_options = ( _BaseCloudBuildRestTransport._BaseGetWorkerPool._get_http_options() ) + request, metadata = self._interceptor.pre_get_worker_pool(request, metadata) transcoded_request = ( _BaseCloudBuildRestTransport._BaseGetWorkerPool._get_transcoded_request( @@ -1725,6 +2212,33 @@ def __call__( ) ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + 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.cloudbuild_v1.CloudBuildClient.GetWorkerPool", + extra={ + "serviceName": "google.devtools.cloudbuild.v1.CloudBuild", + "rpcName": "GetWorkerPool", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = CloudBuildRestTransport._GetWorkerPool._get_response( self._host, @@ -1745,7 +2259,29 @@ def __call__( pb_resp = cloudbuild.WorkerPool.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_worker_pool(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = cloudbuild.WorkerPool.to_json(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.cloudbuild_v1.CloudBuildClient.get_worker_pool", + extra={ + "serviceName": "google.devtools.cloudbuild.v1.CloudBuild", + "rpcName": "GetWorkerPool", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ListBuilds(_BaseCloudBuildRestTransport._BaseListBuilds, CloudBuildRestStub): @@ -1780,7 +2316,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> cloudbuild.ListBuildsResponse: r"""Call the list builds method over HTTP. @@ -1790,8 +2326,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.cloudbuild.ListBuildsResponse: @@ -1801,6 +2339,7 @@ def __call__( http_options = ( _BaseCloudBuildRestTransport._BaseListBuilds._get_http_options() ) + request, metadata = self._interceptor.pre_list_builds(request, metadata) transcoded_request = ( _BaseCloudBuildRestTransport._BaseListBuilds._get_transcoded_request( @@ -1815,6 +2354,33 @@ def __call__( ) ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + 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.cloudbuild_v1.CloudBuildClient.ListBuilds", + extra={ + "serviceName": "google.devtools.cloudbuild.v1.CloudBuild", + "rpcName": "ListBuilds", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = CloudBuildRestTransport._ListBuilds._get_response( self._host, @@ -1835,7 +2401,29 @@ def __call__( pb_resp = cloudbuild.ListBuildsResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_builds(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = cloudbuild.ListBuildsResponse.to_json(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.cloudbuild_v1.CloudBuildClient.list_builds", + extra={ + "serviceName": "google.devtools.cloudbuild.v1.CloudBuild", + "rpcName": "ListBuilds", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ListBuildTriggers( @@ -1872,7 +2460,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> cloudbuild.ListBuildTriggersResponse: r"""Call the list build triggers method over HTTP. @@ -1882,8 +2470,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.cloudbuild.ListBuildTriggersResponse: @@ -1893,6 +2483,7 @@ def __call__( http_options = ( _BaseCloudBuildRestTransport._BaseListBuildTriggers._get_http_options() ) + request, metadata = self._interceptor.pre_list_build_triggers( request, metadata ) @@ -1905,6 +2496,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.devtools.cloudbuild_v1.CloudBuildClient.ListBuildTriggers", + extra={ + "serviceName": "google.devtools.cloudbuild.v1.CloudBuild", + "rpcName": "ListBuildTriggers", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = CloudBuildRestTransport._ListBuildTriggers._get_response( self._host, @@ -1925,7 +2543,31 @@ def __call__( pb_resp = cloudbuild.ListBuildTriggersResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_build_triggers(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = cloudbuild.ListBuildTriggersResponse.to_json( + 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.cloudbuild_v1.CloudBuildClient.list_build_triggers", + extra={ + "serviceName": "google.devtools.cloudbuild.v1.CloudBuild", + "rpcName": "ListBuildTriggers", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ListWorkerPools( @@ -1962,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]]] = (), ) -> cloudbuild.ListWorkerPoolsResponse: r"""Call the list worker pools method over HTTP. @@ -1972,8 +2614,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.cloudbuild.ListWorkerPoolsResponse: @@ -1983,6 +2627,7 @@ def __call__( http_options = ( _BaseCloudBuildRestTransport._BaseListWorkerPools._get_http_options() ) + request, metadata = self._interceptor.pre_list_worker_pools( request, metadata ) @@ -1995,6 +2640,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + 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.cloudbuild_v1.CloudBuildClient.ListWorkerPools", + extra={ + "serviceName": "google.devtools.cloudbuild.v1.CloudBuild", + "rpcName": "ListWorkerPools", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = CloudBuildRestTransport._ListWorkerPools._get_response( self._host, @@ -2015,7 +2687,31 @@ def __call__( pb_resp = cloudbuild.ListWorkerPoolsResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_worker_pools(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = cloudbuild.ListWorkerPoolsResponse.to_json( + 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.cloudbuild_v1.CloudBuildClient.list_worker_pools", + extra={ + "serviceName": "google.devtools.cloudbuild.v1.CloudBuild", + "rpcName": "ListWorkerPools", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ReceiveTriggerWebhook( @@ -2053,7 +2749,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> cloudbuild.ReceiveTriggerWebhookResponse: r"""Call the receive trigger webhook method over HTTP. @@ -2065,8 +2761,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.cloudbuild.ReceiveTriggerWebhookResponse: @@ -2078,6 +2776,7 @@ def __call__( http_options = ( _BaseCloudBuildRestTransport._BaseReceiveTriggerWebhook._get_http_options() ) + request, metadata = self._interceptor.pre_receive_trigger_webhook( request, metadata ) @@ -2094,6 +2793,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + 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.cloudbuild_v1.CloudBuildClient.ReceiveTriggerWebhook", + extra={ + "serviceName": "google.devtools.cloudbuild.v1.CloudBuild", + "rpcName": "ReceiveTriggerWebhook", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = CloudBuildRestTransport._ReceiveTriggerWebhook._get_response( self._host, @@ -2115,7 +2841,31 @@ def __call__( pb_resp = cloudbuild.ReceiveTriggerWebhookResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_receive_trigger_webhook(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = cloudbuild.ReceiveTriggerWebhookResponse.to_json( + 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.cloudbuild_v1.CloudBuildClient.receive_trigger_webhook", + extra={ + "serviceName": "google.devtools.cloudbuild.v1.CloudBuild", + "rpcName": "ReceiveTriggerWebhook", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _RetryBuild(_BaseCloudBuildRestTransport._BaseRetryBuild, CloudBuildRestStub): @@ -2151,7 +2901,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Call the retry build method over HTTP. @@ -2161,8 +2911,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.operations_pb2.Operation: @@ -2175,6 +2927,7 @@ def __call__( http_options = ( _BaseCloudBuildRestTransport._BaseRetryBuild._get_http_options() ) + request, metadata = self._interceptor.pre_retry_build(request, metadata) transcoded_request = ( _BaseCloudBuildRestTransport._BaseRetryBuild._get_transcoded_request( @@ -2193,6 +2946,33 @@ def __call__( ) ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + 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.cloudbuild_v1.CloudBuildClient.RetryBuild", + extra={ + "serviceName": "google.devtools.cloudbuild.v1.CloudBuild", + "rpcName": "RetryBuild", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = CloudBuildRestTransport._RetryBuild._get_response( self._host, @@ -2212,7 +2992,29 @@ def __call__( # Return the response resp = operations_pb2.Operation() json_format.Parse(response.content, resp, ignore_unknown_fields=True) + resp = self._interceptor.post_retry_build(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = json_format.MessageToJson(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.cloudbuild_v1.CloudBuildClient.retry_build", + extra={ + "serviceName": "google.devtools.cloudbuild.v1.CloudBuild", + "rpcName": "RetryBuild", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _RunBuildTrigger( @@ -2250,7 +3052,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.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 build trigger method over HTTP. @@ -2261,8 +3063,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.operations_pb2.Operation: @@ -2275,6 +3079,7 @@ def __call__( http_options = ( _BaseCloudBuildRestTransport._BaseRunBuildTrigger._get_http_options() ) + request, metadata = self._interceptor.pre_run_build_trigger( request, metadata ) @@ -2291,6 +3096,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + 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.cloudbuild_v1.CloudBuildClient.RunBuildTrigger", + extra={ + "serviceName": "google.devtools.cloudbuild.v1.CloudBuild", + "rpcName": "RunBuildTrigger", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = CloudBuildRestTransport._RunBuildTrigger._get_response( self._host, @@ -2310,7 +3142,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_build_trigger(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = json_format.MessageToJson(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.cloudbuild_v1.CloudBuildClient.run_build_trigger", + extra={ + "serviceName": "google.devtools.cloudbuild.v1.CloudBuild", + "rpcName": "RunBuildTrigger", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _UpdateBuildTrigger( @@ -2348,7 +3202,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> cloudbuild.BuildTrigger: r"""Call the update build trigger method over HTTP. @@ -2358,8 +3212,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.cloudbuild.BuildTrigger: @@ -2372,6 +3228,7 @@ def __call__( http_options = ( _BaseCloudBuildRestTransport._BaseUpdateBuildTrigger._get_http_options() ) + request, metadata = self._interceptor.pre_update_build_trigger( request, metadata ) @@ -2388,6 +3245,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + 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.cloudbuild_v1.CloudBuildClient.UpdateBuildTrigger", + extra={ + "serviceName": "google.devtools.cloudbuild.v1.CloudBuild", + "rpcName": "UpdateBuildTrigger", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = CloudBuildRestTransport._UpdateBuildTrigger._get_response( self._host, @@ -2409,7 +3293,29 @@ def __call__( pb_resp = cloudbuild.BuildTrigger.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_update_build_trigger(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = cloudbuild.BuildTrigger.to_json(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.cloudbuild_v1.CloudBuildClient.update_build_trigger", + extra={ + "serviceName": "google.devtools.cloudbuild.v1.CloudBuild", + "rpcName": "UpdateBuildTrigger", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _UpdateWorkerPool( @@ -2447,7 +3353,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.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 worker pool method over HTTP. @@ -2457,8 +3363,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.operations_pb2.Operation: @@ -2471,6 +3379,7 @@ def __call__( http_options = ( _BaseCloudBuildRestTransport._BaseUpdateWorkerPool._get_http_options() ) + request, metadata = self._interceptor.pre_update_worker_pool( request, metadata ) @@ -2487,6 +3396,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + 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.cloudbuild_v1.CloudBuildClient.UpdateWorkerPool", + extra={ + "serviceName": "google.devtools.cloudbuild.v1.CloudBuild", + "rpcName": "UpdateWorkerPool", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = CloudBuildRestTransport._UpdateWorkerPool._get_response( self._host, @@ -2506,7 +3442,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_worker_pool(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = json_format.MessageToJson(resp) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.devtools.cloudbuild_v1.CloudBuildClient.update_worker_pool", + extra={ + "serviceName": "google.devtools.cloudbuild.v1.CloudBuild", + "rpcName": "UpdateWorkerPool", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp @property diff --git a/packages/google-cloud-build/google/cloud/devtools/cloudbuild_v2/gapic_version.py b/packages/google-cloud-build/google/cloud/devtools/cloudbuild_v2/gapic_version.py index 7af2fa694463..558c8aab67c5 100644 --- a/packages/google-cloud-build/google/cloud/devtools/cloudbuild_v2/gapic_version.py +++ b/packages/google-cloud-build/google/cloud/devtools/cloudbuild_v2/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-build/google/cloud/devtools/cloudbuild_v2/services/repository_manager/async_client.py b/packages/google-cloud-build/google/cloud/devtools/cloudbuild_v2/services/repository_manager/async_client.py index 46f903b158fc..5a6c2a384a3a 100644 --- a/packages/google-cloud-build/google/cloud/devtools/cloudbuild_v2/services/repository_manager/async_client.py +++ b/packages/google-cloud-build/google/cloud/devtools/cloudbuild_v2/services/repository_manager/async_client.py @@ -14,6 +14,7 @@ # limitations under the License. # from collections import OrderedDict +import logging as std_logging import re from typing import ( Callable, @@ -59,6 +60,15 @@ from .transports.base import DEFAULT_CLIENT_INFO, RepositoryManagerTransport from .transports.grpc_asyncio import RepositoryManagerGrpcAsyncIOTransport +try: + from google.api_core import client_logging # type: ignore + + CLIENT_LOGGING_SUPPORTED = True # pragma: NO COVER +except ImportError: # pragma: NO COVER + CLIENT_LOGGING_SUPPORTED = False + +_LOGGER = std_logging.getLogger(__name__) + class RepositoryManagerAsyncClient: """Manages connections to source code repositories.""" @@ -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.devtools.cloudbuild_v2.RepositoryManagerAsyncClient`.", + extra={ + "serviceName": "google.devtools.cloudbuild.v2.RepositoryManager", + "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.cloudbuild.v2.RepositoryManager", + "credentialsType": None, + }, + ) + async def create_connection( self, request: Optional[Union[repositories.CreateConnectionRequest, dict]] = None, @@ -285,7 +317,7 @@ async def create_connection( connection_id: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation_async.AsyncOperation: r"""Creates a Connection. @@ -348,8 +380,10 @@ async def sample_create_connection(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.api_core.operation_async.AsyncOperation: @@ -424,7 +458,7 @@ async def get_connection( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> repositories.Connection: r"""Gets details of a single connection. @@ -468,8 +502,10 @@ async def sample_get_connection(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.devtools.cloudbuild_v2.types.Connection: @@ -531,7 +567,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 in a given project and location. @@ -576,8 +612,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.devtools.cloudbuild_v2.services.repository_manager.pagers.ListConnectionsAsyncPager: @@ -653,7 +691,7 @@ async def update_connection( update_mask: Optional[field_mask_pb2.FieldMask] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation_async.AsyncOperation: r"""Updates a single connection. @@ -702,8 +740,10 @@ async def sample_update_connection(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.api_core.operation_async.AsyncOperation: @@ -778,7 +818,7 @@ async def delete_connection( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation_async.AsyncOperation: r"""Deletes a single connection. @@ -825,8 +865,10 @@ async def sample_delete_connection(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.api_core.operation_async.AsyncOperation: @@ -907,7 +949,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. @@ -976,8 +1018,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: @@ -1058,7 +1102,7 @@ async def batch_create_repositories( ] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation_async.AsyncOperation: r"""Creates multiple repositories inside a connection. @@ -1122,8 +1166,10 @@ async def sample_batch_create_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.api_core.operation_async.AsyncOperation: @@ -1197,7 +1243,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]]] = (), ) -> repositories.Repository: r"""Gets details of a single repository. @@ -1242,8 +1288,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.devtools.cloudbuild_v2.types.Repository: @@ -1304,7 +1352,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 in a given connection. @@ -1350,8 +1398,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.devtools.cloudbuild_v2.services.repository_manager.pagers.ListRepositoriesAsyncPager: @@ -1426,7 +1476,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 single repository. @@ -1473,8 +1523,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: @@ -1553,7 +1605,7 @@ async def fetch_read_write_token( repository: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> repositories.FetchReadWriteTokenResponse: r"""Fetches read/write token of a given repository. @@ -1598,8 +1650,10 @@ async def sample_fetch_read_write_token(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.devtools.cloudbuild_v2.types.FetchReadWriteTokenResponse: @@ -1662,7 +1716,7 @@ async def fetch_read_token( repository: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> repositories.FetchReadTokenResponse: r"""Fetches read token of a given repository. @@ -1706,8 +1760,10 @@ async def sample_fetch_read_token(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.devtools.cloudbuild_v2.types.FetchReadTokenResponse: @@ -1771,7 +1827,7 @@ async def fetch_linkable_repositories( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.FetchLinkableRepositoriesAsyncPager: r"""FetchLinkableRepositories get repositories from SCM that are accessible and could be added to the @@ -1811,8 +1867,10 @@ async def sample_fetch_linkable_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.devtools.cloudbuild_v2.services.repository_manager.pagers.FetchLinkableRepositoriesAsyncPager: @@ -1875,7 +1933,7 @@ async def fetch_git_refs( repository: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> repositories.FetchGitRefsResponse: r"""Fetch the list of branches or tags for a given repository. @@ -1920,8 +1978,10 @@ async def sample_fetch_git_refs(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.devtools.cloudbuild_v2.types.FetchGitRefsResponse: @@ -1981,7 +2041,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. @@ -1992,8 +2052,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. @@ -2034,7 +2096,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. @@ -2049,8 +2111,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 """ @@ -2087,7 +2151,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. @@ -2100,8 +2164,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. @@ -2206,7 +2272,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. @@ -2220,8 +2286,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. @@ -2326,7 +2394,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. @@ -2341,8 +2409,10 @@ async def test_iam_permissions( retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.iam_policy_pb2.TestIamPermissionsResponse: Response message for ``TestIamPermissions`` method. diff --git a/packages/google-cloud-build/google/cloud/devtools/cloudbuild_v2/services/repository_manager/client.py b/packages/google-cloud-build/google/cloud/devtools/cloudbuild_v2/services/repository_manager/client.py index bd2250d96314..af342d03425e 100644 --- a/packages/google-cloud-build/google/cloud/devtools/cloudbuild_v2/services/repository_manager/client.py +++ b/packages/google-cloud-build/google/cloud/devtools/cloudbuild_v2/services/repository_manager/client.py @@ -14,6 +14,7 @@ # limitations under the License. # from collections import OrderedDict +import logging as std_logging import os import re from typing import ( @@ -48,6 +49,15 @@ except AttributeError: # pragma: NO COVER OptionalRetry = Union[retries.Retry, object, None] # type: ignore +try: + from google.api_core import client_logging # type: ignore + + CLIENT_LOGGING_SUPPORTED = True # pragma: NO COVER +except ImportError: # pragma: NO COVER + CLIENT_LOGGING_SUPPORTED = False + +_LOGGER = std_logging.getLogger(__name__) + from google.api_core import operation # type: ignore from google.api_core import operation_async # type: ignore from google.cloud.location import locations_pb2 # type: ignore @@ -664,6 +674,10 @@ def __init__( # Initialize the universe domain validation. self._is_universe_domain_valid = False + if CLIENT_LOGGING_SUPPORTED: # pragma: NO COVER + # Setup logging. + client_logging.initialize_logging() + api_key_value = getattr(self._client_options, "api_key", None) if api_key_value and credentials: raise ValueError( @@ -730,6 +744,29 @@ def __init__( api_audience=self._client_options.api_audience, ) + if "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.cloudbuild_v2.RepositoryManagerClient`.", + extra={ + "serviceName": "google.devtools.cloudbuild.v2.RepositoryManager", + "universeDomain": getattr( + self._transport._credentials, "universe_domain", "" + ), + "credentialsType": f"{type(self._transport._credentials).__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.cloudbuild.v2.RepositoryManager", + "credentialsType": None, + }, + ) + def create_connection( self, request: Optional[Union[repositories.CreateConnectionRequest, dict]] = None, @@ -739,7 +776,7 @@ def create_connection( connection_id: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation.Operation: r"""Creates a Connection. @@ -802,8 +839,10 @@ def sample_create_connection(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.api_core.operation.Operation: @@ -875,7 +914,7 @@ def get_connection( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> repositories.Connection: r"""Gets details of a single connection. @@ -919,8 +958,10 @@ def sample_get_connection(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.devtools.cloudbuild_v2.types.Connection: @@ -979,7 +1020,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 in a given project and location. @@ -1024,8 +1065,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.devtools.cloudbuild_v2.services.repository_manager.pagers.ListConnectionsPager: @@ -1098,7 +1141,7 @@ def update_connection( update_mask: Optional[field_mask_pb2.FieldMask] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation.Operation: r"""Updates a single connection. @@ -1147,8 +1190,10 @@ def sample_update_connection(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.api_core.operation.Operation: @@ -1220,7 +1265,7 @@ def delete_connection( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation.Operation: r"""Deletes a single connection. @@ -1267,8 +1312,10 @@ def sample_delete_connection(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.api_core.operation.Operation: @@ -1346,7 +1393,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. @@ -1415,8 +1462,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: @@ -1494,7 +1543,7 @@ def batch_create_repositories( ] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation.Operation: r"""Creates multiple repositories inside a connection. @@ -1558,8 +1607,10 @@ def sample_batch_create_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.api_core.operation.Operation: @@ -1632,7 +1683,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]]] = (), ) -> repositories.Repository: r"""Gets details of a single repository. @@ -1677,8 +1728,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.devtools.cloudbuild_v2.types.Repository: @@ -1736,7 +1789,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 in a given connection. @@ -1782,8 +1835,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.devtools.cloudbuild_v2.services.repository_manager.pagers.ListRepositoriesPager: @@ -1855,7 +1910,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 single repository. @@ -1902,8 +1957,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: @@ -1979,7 +2036,7 @@ def fetch_read_write_token( repository: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> repositories.FetchReadWriteTokenResponse: r"""Fetches read/write token of a given repository. @@ -2024,8 +2081,10 @@ def sample_fetch_read_write_token(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.devtools.cloudbuild_v2.types.FetchReadWriteTokenResponse: @@ -2085,7 +2144,7 @@ def fetch_read_token( repository: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> repositories.FetchReadTokenResponse: r"""Fetches read token of a given repository. @@ -2129,8 +2188,10 @@ def sample_fetch_read_token(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.devtools.cloudbuild_v2.types.FetchReadTokenResponse: @@ -2191,7 +2252,7 @@ def fetch_linkable_repositories( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.FetchLinkableRepositoriesPager: r"""FetchLinkableRepositories get repositories from SCM that are accessible and could be added to the @@ -2231,8 +2292,10 @@ def sample_fetch_linkable_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.devtools.cloudbuild_v2.services.repository_manager.pagers.FetchLinkableRepositoriesPager: @@ -2295,7 +2358,7 @@ def fetch_git_refs( repository: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> repositories.FetchGitRefsResponse: r"""Fetch the list of branches or tags for a given repository. @@ -2340,8 +2403,10 @@ def sample_fetch_git_refs(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.devtools.cloudbuild_v2.types.FetchGitRefsResponse: @@ -2411,7 +2476,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. @@ -2422,8 +2487,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. @@ -2464,7 +2531,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. @@ -2479,8 +2546,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 """ @@ -2517,7 +2586,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. @@ -2530,8 +2599,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. @@ -2636,7 +2707,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. @@ -2650,8 +2721,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. @@ -2756,7 +2829,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. @@ -2771,8 +2844,10 @@ def test_iam_permissions( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.iam_policy_pb2.TestIamPermissionsResponse: Response message for ``TestIamPermissions`` method. diff --git a/packages/google-cloud-build/google/cloud/devtools/cloudbuild_v2/services/repository_manager/pagers.py b/packages/google-cloud-build/google/cloud/devtools/cloudbuild_v2/services/repository_manager/pagers.py index a7f0ddaa243c..e1d2985e4a4a 100644 --- a/packages/google-cloud-build/google/cloud/devtools/cloudbuild_v2/services/repository_manager/pagers.py +++ b/packages/google-cloud-build/google/cloud/devtools/cloudbuild_v2/services/repository_manager/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 = repositories.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 = repositories.ListConnectionsRequest(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 = repositories.ListRepositoriesRequest(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 = repositories.ListRepositoriesRequest(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 = repositories.FetchLinkableRepositoriesRequest(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 = repositories.FetchLinkableRepositoriesRequest(request) diff --git a/packages/google-cloud-build/google/cloud/devtools/cloudbuild_v2/services/repository_manager/transports/grpc.py b/packages/google-cloud-build/google/cloud/devtools/cloudbuild_v2/services/repository_manager/transports/grpc.py index 9cda4b35f09b..62d3448666ef 100644 --- a/packages/google-cloud-build/google/cloud/devtools/cloudbuild_v2/services/repository_manager/transports/grpc.py +++ b/packages/google-cloud-build/google/cloud/devtools/cloudbuild_v2/services/repository_manager/transports/grpc.py @@ -13,6 +13,9 @@ # See the License for the specific language governing permissions and # limitations under the License. # +import json +import logging as std_logging +import pickle from typing import Callable, Dict, Optional, Sequence, Tuple, Union import warnings @@ -24,12 +27,90 @@ from google.iam.v1 import iam_policy_pb2 # type: ignore from google.iam.v1 import policy_pb2 # type: ignore from google.longrunning import operations_pb2 # type: ignore +from google.protobuf.json_format import MessageToJson +import google.protobuf.message import grpc # type: ignore +import proto # type: ignore from google.cloud.devtools.cloudbuild_v2.types import repositories from .base import DEFAULT_CLIENT_INFO, RepositoryManagerTransport +try: + from google.api_core import client_logging # 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.cloudbuild.v2.RepositoryManager", + "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.cloudbuild.v2.RepositoryManager", + "rpcName": client_call_details.method, + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class RepositoryManagerGrpcTransport(RepositoryManagerTransport): """gRPC backend transport for RepositoryManager. @@ -184,7 +265,12 @@ def __init__( ], ) - # Wrap messages. This must be done after self._grpc_channel exists + self._interceptor = _LoggingClientInterceptor() + self._logged_channel = grpc.intercept_channel( + self._grpc_channel, self._interceptor + ) + + # Wrap messages. This must be done after self._logged_channel exists self._prep_wrapped_messages(client_info) @classmethod @@ -248,7 +334,9 @@ def operations_client(self) -> operations_v1.OperationsClient: """ # Quick check: Only create a new client if we do not already have one. if self._operations_client is None: - self._operations_client = operations_v1.OperationsClient(self.grpc_channel) + self._operations_client = operations_v1.OperationsClient( + self._logged_channel + ) # Return the client from cache. return self._operations_client @@ -272,7 +360,7 @@ def create_connection( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_connection" not in self._stubs: - self._stubs["create_connection"] = self.grpc_channel.unary_unary( + self._stubs["create_connection"] = self._logged_channel.unary_unary( "/google.devtools.cloudbuild.v2.RepositoryManager/CreateConnection", request_serializer=repositories.CreateConnectionRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -298,7 +386,7 @@ def get_connection( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_connection" not in self._stubs: - self._stubs["get_connection"] = self.grpc_channel.unary_unary( + self._stubs["get_connection"] = self._logged_channel.unary_unary( "/google.devtools.cloudbuild.v2.RepositoryManager/GetConnection", request_serializer=repositories.GetConnectionRequest.serialize, response_deserializer=repositories.Connection.deserialize, @@ -326,7 +414,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.devtools.cloudbuild.v2.RepositoryManager/ListConnections", request_serializer=repositories.ListConnectionsRequest.serialize, response_deserializer=repositories.ListConnectionsResponse.deserialize, @@ -352,7 +440,7 @@ def update_connection( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_connection" not in self._stubs: - self._stubs["update_connection"] = self.grpc_channel.unary_unary( + self._stubs["update_connection"] = self._logged_channel.unary_unary( "/google.devtools.cloudbuild.v2.RepositoryManager/UpdateConnection", request_serializer=repositories.UpdateConnectionRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -378,7 +466,7 @@ def delete_connection( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_connection" not in self._stubs: - self._stubs["delete_connection"] = self.grpc_channel.unary_unary( + self._stubs["delete_connection"] = self._logged_channel.unary_unary( "/google.devtools.cloudbuild.v2.RepositoryManager/DeleteConnection", request_serializer=repositories.DeleteConnectionRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -404,7 +492,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.cloudbuild.v2.RepositoryManager/CreateRepository", request_serializer=repositories.CreateRepositoryRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -432,7 +520,7 @@ def batch_create_repositories( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "batch_create_repositories" not in self._stubs: - self._stubs["batch_create_repositories"] = self.grpc_channel.unary_unary( + self._stubs["batch_create_repositories"] = self._logged_channel.unary_unary( "/google.devtools.cloudbuild.v2.RepositoryManager/BatchCreateRepositories", request_serializer=repositories.BatchCreateRepositoriesRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -458,7 +546,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.cloudbuild.v2.RepositoryManager/GetRepository", request_serializer=repositories.GetRepositoryRequest.serialize, response_deserializer=repositories.Repository.deserialize, @@ -486,7 +574,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.cloudbuild.v2.RepositoryManager/ListRepositories", request_serializer=repositories.ListRepositoriesRequest.serialize, response_deserializer=repositories.ListRepositoriesResponse.deserialize, @@ -512,7 +600,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.cloudbuild.v2.RepositoryManager/DeleteRepository", request_serializer=repositories.DeleteRepositoryRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -541,7 +629,7 @@ def fetch_read_write_token( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "fetch_read_write_token" not in self._stubs: - self._stubs["fetch_read_write_token"] = self.grpc_channel.unary_unary( + self._stubs["fetch_read_write_token"] = self._logged_channel.unary_unary( "/google.devtools.cloudbuild.v2.RepositoryManager/FetchReadWriteToken", request_serializer=repositories.FetchReadWriteTokenRequest.serialize, response_deserializer=repositories.FetchReadWriteTokenResponse.deserialize, @@ -569,7 +657,7 @@ def fetch_read_token( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "fetch_read_token" not in self._stubs: - self._stubs["fetch_read_token"] = self.grpc_channel.unary_unary( + self._stubs["fetch_read_token"] = self._logged_channel.unary_unary( "/google.devtools.cloudbuild.v2.RepositoryManager/FetchReadToken", request_serializer=repositories.FetchReadTokenRequest.serialize, response_deserializer=repositories.FetchReadTokenResponse.deserialize, @@ -600,7 +688,9 @@ def fetch_linkable_repositories( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "fetch_linkable_repositories" not in self._stubs: - self._stubs["fetch_linkable_repositories"] = self.grpc_channel.unary_unary( + self._stubs[ + "fetch_linkable_repositories" + ] = self._logged_channel.unary_unary( "/google.devtools.cloudbuild.v2.RepositoryManager/FetchLinkableRepositories", request_serializer=repositories.FetchLinkableRepositoriesRequest.serialize, response_deserializer=repositories.FetchLinkableRepositoriesResponse.deserialize, @@ -629,7 +719,7 @@ def fetch_git_refs( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "fetch_git_refs" not in self._stubs: - self._stubs["fetch_git_refs"] = self.grpc_channel.unary_unary( + self._stubs["fetch_git_refs"] = self._logged_channel.unary_unary( "/google.devtools.cloudbuild.v2.RepositoryManager/FetchGitRefs", request_serializer=repositories.FetchGitRefsRequest.serialize, response_deserializer=repositories.FetchGitRefsResponse.deserialize, @@ -637,7 +727,7 @@ def fetch_git_refs( return self._stubs["fetch_git_refs"] def close(self): - self.grpc_channel.close() + self._logged_channel.close() @property def cancel_operation( @@ -649,7 +739,7 @@ def cancel_operation( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "cancel_operation" not in self._stubs: - self._stubs["cancel_operation"] = self.grpc_channel.unary_unary( + self._stubs["cancel_operation"] = self._logged_channel.unary_unary( "/google.longrunning.Operations/CancelOperation", request_serializer=operations_pb2.CancelOperationRequest.SerializeToString, response_deserializer=None, @@ -666,7 +756,7 @@ def get_operation( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_operation" not in self._stubs: - self._stubs["get_operation"] = self.grpc_channel.unary_unary( + self._stubs["get_operation"] = self._logged_channel.unary_unary( "/google.longrunning.Operations/GetOperation", request_serializer=operations_pb2.GetOperationRequest.SerializeToString, response_deserializer=operations_pb2.Operation.FromString, @@ -691,7 +781,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, @@ -717,7 +807,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, @@ -746,7 +836,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-build/google/cloud/devtools/cloudbuild_v2/services/repository_manager/transports/grpc_asyncio.py b/packages/google-cloud-build/google/cloud/devtools/cloudbuild_v2/services/repository_manager/transports/grpc_asyncio.py index 4916f61cd751..07d76f467d81 100644 --- a/packages/google-cloud-build/google/cloud/devtools/cloudbuild_v2/services/repository_manager/transports/grpc_asyncio.py +++ b/packages/google-cloud-build/google/cloud/devtools/cloudbuild_v2/services/repository_manager/transports/grpc_asyncio.py @@ -14,6 +14,9 @@ # limitations under the License. # import inspect +import json +import logging as std_logging +import pickle from typing import Awaitable, Callable, Dict, Optional, Sequence, Tuple, Union import warnings @@ -26,14 +29,93 @@ from google.iam.v1 import iam_policy_pb2 # type: ignore from google.iam.v1 import policy_pb2 # type: ignore from google.longrunning import operations_pb2 # type: ignore +from google.protobuf.json_format import MessageToJson +import google.protobuf.message import grpc # type: ignore from grpc.experimental import aio # type: ignore +import proto # type: ignore from google.cloud.devtools.cloudbuild_v2.types import repositories from .base import DEFAULT_CLIENT_INFO, RepositoryManagerTransport from .grpc import RepositoryManagerGrpcTransport +try: + from google.api_core import client_logging # 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.cloudbuild.v2.RepositoryManager", + "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.cloudbuild.v2.RepositoryManager", + "rpcName": str(client_call_details.method), + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class RepositoryManagerGrpcAsyncIOTransport(RepositoryManagerTransport): """gRPC AsyncIO backend transport for RepositoryManager. @@ -231,10 +313,13 @@ def __init__( ], ) - # Wrap messages. This must be done after self._grpc_channel exists + self._interceptor = _LoggingClientAIOInterceptor() + self._grpc_channel._unary_unary_interceptors.append(self._interceptor) + self._logged_channel = self._grpc_channel self._wrap_with_kind = ( "kind" in inspect.signature(gapic_v1.method_async.wrap_method).parameters ) + # Wrap messages. This must be done after self._logged_channel exists self._prep_wrapped_messages(client_info) @property @@ -257,7 +342,7 @@ def operations_client(self) -> operations_v1.OperationsAsyncClient: # Quick check: Only create a new client if we do not already have one. if self._operations_client is None: self._operations_client = operations_v1.OperationsAsyncClient( - self.grpc_channel + self._logged_channel ) # Return the client from cache. @@ -284,7 +369,7 @@ def create_connection( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_connection" not in self._stubs: - self._stubs["create_connection"] = self.grpc_channel.unary_unary( + self._stubs["create_connection"] = self._logged_channel.unary_unary( "/google.devtools.cloudbuild.v2.RepositoryManager/CreateConnection", request_serializer=repositories.CreateConnectionRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -312,7 +397,7 @@ def get_connection( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_connection" not in self._stubs: - self._stubs["get_connection"] = self.grpc_channel.unary_unary( + self._stubs["get_connection"] = self._logged_channel.unary_unary( "/google.devtools.cloudbuild.v2.RepositoryManager/GetConnection", request_serializer=repositories.GetConnectionRequest.serialize, response_deserializer=repositories.Connection.deserialize, @@ -341,7 +426,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.devtools.cloudbuild.v2.RepositoryManager/ListConnections", request_serializer=repositories.ListConnectionsRequest.serialize, response_deserializer=repositories.ListConnectionsResponse.deserialize, @@ -369,7 +454,7 @@ def update_connection( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_connection" not in self._stubs: - self._stubs["update_connection"] = self.grpc_channel.unary_unary( + self._stubs["update_connection"] = self._logged_channel.unary_unary( "/google.devtools.cloudbuild.v2.RepositoryManager/UpdateConnection", request_serializer=repositories.UpdateConnectionRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -397,7 +482,7 @@ def delete_connection( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_connection" not in self._stubs: - self._stubs["delete_connection"] = self.grpc_channel.unary_unary( + self._stubs["delete_connection"] = self._logged_channel.unary_unary( "/google.devtools.cloudbuild.v2.RepositoryManager/DeleteConnection", request_serializer=repositories.DeleteConnectionRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -425,7 +510,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.cloudbuild.v2.RepositoryManager/CreateRepository", request_serializer=repositories.CreateRepositoryRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -454,7 +539,7 @@ def batch_create_repositories( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "batch_create_repositories" not in self._stubs: - self._stubs["batch_create_repositories"] = self.grpc_channel.unary_unary( + self._stubs["batch_create_repositories"] = self._logged_channel.unary_unary( "/google.devtools.cloudbuild.v2.RepositoryManager/BatchCreateRepositories", request_serializer=repositories.BatchCreateRepositoriesRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -482,7 +567,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.cloudbuild.v2.RepositoryManager/GetRepository", request_serializer=repositories.GetRepositoryRequest.serialize, response_deserializer=repositories.Repository.deserialize, @@ -511,7 +596,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.cloudbuild.v2.RepositoryManager/ListRepositories", request_serializer=repositories.ListRepositoriesRequest.serialize, response_deserializer=repositories.ListRepositoriesResponse.deserialize, @@ -539,7 +624,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.cloudbuild.v2.RepositoryManager/DeleteRepository", request_serializer=repositories.DeleteRepositoryRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -568,7 +653,7 @@ def fetch_read_write_token( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "fetch_read_write_token" not in self._stubs: - self._stubs["fetch_read_write_token"] = self.grpc_channel.unary_unary( + self._stubs["fetch_read_write_token"] = self._logged_channel.unary_unary( "/google.devtools.cloudbuild.v2.RepositoryManager/FetchReadWriteToken", request_serializer=repositories.FetchReadWriteTokenRequest.serialize, response_deserializer=repositories.FetchReadWriteTokenResponse.deserialize, @@ -597,7 +682,7 @@ def fetch_read_token( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "fetch_read_token" not in self._stubs: - self._stubs["fetch_read_token"] = self.grpc_channel.unary_unary( + self._stubs["fetch_read_token"] = self._logged_channel.unary_unary( "/google.devtools.cloudbuild.v2.RepositoryManager/FetchReadToken", request_serializer=repositories.FetchReadTokenRequest.serialize, response_deserializer=repositories.FetchReadTokenResponse.deserialize, @@ -628,7 +713,9 @@ def fetch_linkable_repositories( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "fetch_linkable_repositories" not in self._stubs: - self._stubs["fetch_linkable_repositories"] = self.grpc_channel.unary_unary( + self._stubs[ + "fetch_linkable_repositories" + ] = self._logged_channel.unary_unary( "/google.devtools.cloudbuild.v2.RepositoryManager/FetchLinkableRepositories", request_serializer=repositories.FetchLinkableRepositoriesRequest.serialize, response_deserializer=repositories.FetchLinkableRepositoriesResponse.deserialize, @@ -657,7 +744,7 @@ def fetch_git_refs( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "fetch_git_refs" not in self._stubs: - self._stubs["fetch_git_refs"] = self.grpc_channel.unary_unary( + self._stubs["fetch_git_refs"] = self._logged_channel.unary_unary( "/google.devtools.cloudbuild.v2.RepositoryManager/FetchGitRefs", request_serializer=repositories.FetchGitRefsRequest.serialize, response_deserializer=repositories.FetchGitRefsResponse.deserialize, @@ -833,7 +920,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: @@ -849,7 +936,7 @@ def cancel_operation( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "cancel_operation" not in self._stubs: - self._stubs["cancel_operation"] = self.grpc_channel.unary_unary( + self._stubs["cancel_operation"] = self._logged_channel.unary_unary( "/google.longrunning.Operations/CancelOperation", request_serializer=operations_pb2.CancelOperationRequest.SerializeToString, response_deserializer=None, @@ -866,7 +953,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, @@ -891,7 +978,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, @@ -917,7 +1004,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, @@ -946,7 +1033,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-build/google/cloud/devtools/cloudbuild_v2/services/repository_manager/transports/rest.py b/packages/google-cloud-build/google/cloud/devtools/cloudbuild_v2/services/repository_manager/transports/rest.py index 3f0ef24c8b88..423e06e151e9 100644 --- a/packages/google-cloud-build/google/cloud/devtools/cloudbuild_v2/services/repository_manager/transports/rest.py +++ b/packages/google-cloud-build/google/cloud/devtools/cloudbuild_v2/services/repository_manager/transports/rest.py @@ -13,9 +13,9 @@ # See the License for the specific language governing permissions and # limitations under the License. # - import dataclasses import json # type: ignore +import logging from typing import Any, Callable, Dict, List, Optional, Sequence, Tuple, Union import warnings @@ -41,6 +41,14 @@ except AttributeError: # pragma: NO COVER OptionalRetry = Union[retries.Retry, object, None] # type: ignore +try: + from google.api_core import client_logging # type: ignore + + CLIENT_LOGGING_SUPPORTED = True # pragma: NO COVER +except ImportError: # pragma: NO COVER + CLIENT_LOGGING_SUPPORTED = False + +_LOGGER = logging.getLogger(__name__) DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo( gapic_version=BASE_DEFAULT_CLIENT_INFO.gapic_version, @@ -185,8 +193,11 @@ def post_update_connection(self, response): def pre_batch_create_repositories( self, request: repositories.BatchCreateRepositoriesRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[repositories.BatchCreateRepositoriesRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + repositories.BatchCreateRepositoriesRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for batch_create_repositories Override in a subclass to manipulate the request or metadata @@ -208,8 +219,10 @@ def post_batch_create_repositories( def pre_create_connection( self, request: repositories.CreateConnectionRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[repositories.CreateConnectionRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + repositories.CreateConnectionRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for create_connection Override in a subclass to manipulate the request or metadata @@ -231,8 +244,10 @@ def post_create_connection( def pre_create_repository( self, request: repositories.CreateRepositoryRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[repositories.CreateRepositoryRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + repositories.CreateRepositoryRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for create_repository Override in a subclass to manipulate the request or metadata @@ -254,8 +269,10 @@ def post_create_repository( def pre_delete_connection( self, request: repositories.DeleteConnectionRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[repositories.DeleteConnectionRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + repositories.DeleteConnectionRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for delete_connection Override in a subclass to manipulate the request or metadata @@ -277,8 +294,10 @@ def post_delete_connection( def pre_delete_repository( self, request: repositories.DeleteRepositoryRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[repositories.DeleteRepositoryRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + repositories.DeleteRepositoryRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for delete_repository Override in a subclass to manipulate the request or metadata @@ -300,8 +319,10 @@ def post_delete_repository( def pre_fetch_git_refs( self, request: repositories.FetchGitRefsRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[repositories.FetchGitRefsRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + repositories.FetchGitRefsRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for fetch_git_refs Override in a subclass to manipulate the request or metadata @@ -323,9 +344,10 @@ def post_fetch_git_refs( def pre_fetch_linkable_repositories( self, request: repositories.FetchLinkableRepositoriesRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ - repositories.FetchLinkableRepositoriesRequest, Sequence[Tuple[str, str]] + repositories.FetchLinkableRepositoriesRequest, + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for fetch_linkable_repositories @@ -348,8 +370,10 @@ def post_fetch_linkable_repositories( def pre_fetch_read_token( self, request: repositories.FetchReadTokenRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[repositories.FetchReadTokenRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + repositories.FetchReadTokenRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for fetch_read_token Override in a subclass to manipulate the request or metadata @@ -371,8 +395,10 @@ def post_fetch_read_token( def pre_fetch_read_write_token( self, request: repositories.FetchReadWriteTokenRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[repositories.FetchReadWriteTokenRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + repositories.FetchReadWriteTokenRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for fetch_read_write_token Override in a subclass to manipulate the request or metadata @@ -394,8 +420,10 @@ def post_fetch_read_write_token( def pre_get_connection( self, request: repositories.GetConnectionRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[repositories.GetConnectionRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + repositories.GetConnectionRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for get_connection Override in a subclass to manipulate the request or metadata @@ -417,8 +445,10 @@ def post_get_connection( def pre_get_repository( self, request: repositories.GetRepositoryRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[repositories.GetRepositoryRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + repositories.GetRepositoryRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for get_repository Override in a subclass to manipulate the request or metadata @@ -440,8 +470,10 @@ def post_get_repository( def pre_list_connections( self, request: repositories.ListConnectionsRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[repositories.ListConnectionsRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + repositories.ListConnectionsRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for list_connections Override in a subclass to manipulate the request or metadata @@ -463,8 +495,10 @@ def post_list_connections( def pre_list_repositories( self, request: repositories.ListRepositoriesRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[repositories.ListRepositoriesRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + repositories.ListRepositoriesRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for list_repositories Override in a subclass to manipulate the request or metadata @@ -486,8 +520,10 @@ def post_list_repositories( def pre_update_connection( self, request: repositories.UpdateConnectionRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[repositories.UpdateConnectionRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + repositories.UpdateConnectionRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for update_connection Override in a subclass to manipulate the request or metadata @@ -509,8 +545,10 @@ def post_update_connection( 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 @@ -530,8 +568,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 @@ -551,8 +591,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 @@ -574,8 +617,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 @@ -595,8 +640,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 @@ -780,7 +827,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.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 repositories method over HTTP. @@ -791,8 +838,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.operations_pb2.Operation: @@ -805,6 +854,7 @@ def __call__( http_options = ( _BaseRepositoryManagerRestTransport._BaseBatchCreateRepositories._get_http_options() ) + request, metadata = self._interceptor.pre_batch_create_repositories( request, metadata ) @@ -821,6 +871,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + 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.cloudbuild_v2.RepositoryManagerClient.BatchCreateRepositories", + extra={ + "serviceName": "google.devtools.cloudbuild.v2.RepositoryManager", + "rpcName": "BatchCreateRepositories", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ( RepositoryManagerRestTransport._BatchCreateRepositories._get_response( @@ -842,7 +919,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_repositories(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = json_format.MessageToJson(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.cloudbuild_v2.RepositoryManagerClient.batch_create_repositories", + extra={ + "serviceName": "google.devtools.cloudbuild.v2.RepositoryManager", + "rpcName": "BatchCreateRepositories", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _CreateConnection( @@ -881,7 +980,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.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 connection method over HTTP. @@ -891,8 +990,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.operations_pb2.Operation: @@ -905,6 +1006,7 @@ def __call__( http_options = ( _BaseRepositoryManagerRestTransport._BaseCreateConnection._get_http_options() ) + request, metadata = self._interceptor.pre_create_connection( request, metadata ) @@ -921,6 +1023,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + 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.cloudbuild_v2.RepositoryManagerClient.CreateConnection", + extra={ + "serviceName": "google.devtools.cloudbuild.v2.RepositoryManager", + "rpcName": "CreateConnection", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = RepositoryManagerRestTransport._CreateConnection._get_response( self._host, @@ -940,7 +1069,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_connection(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = json_format.MessageToJson(resp) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.devtools.cloudbuild_v2.RepositoryManagerClient.create_connection", + extra={ + "serviceName": "google.devtools.cloudbuild.v2.RepositoryManager", + "rpcName": "CreateConnection", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _CreateRepository( @@ -979,7 +1130,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Call the create repository method over HTTP. @@ -989,8 +1140,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.operations_pb2.Operation: @@ -1003,6 +1156,7 @@ def __call__( http_options = ( _BaseRepositoryManagerRestTransport._BaseCreateRepository._get_http_options() ) + request, metadata = self._interceptor.pre_create_repository( request, metadata ) @@ -1019,6 +1173,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + 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.cloudbuild_v2.RepositoryManagerClient.CreateRepository", + extra={ + "serviceName": "google.devtools.cloudbuild.v2.RepositoryManager", + "rpcName": "CreateRepository", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = RepositoryManagerRestTransport._CreateRepository._get_response( self._host, @@ -1038,7 +1219,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.cloudbuild_v2.RepositoryManagerClient.create_repository", + extra={ + "serviceName": "google.devtools.cloudbuild.v2.RepositoryManager", + "rpcName": "CreateRepository", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _DeleteConnection( @@ -1076,7 +1279,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Call the delete connection method over HTTP. @@ -1086,8 +1289,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be 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 +1305,7 @@ def __call__( http_options = ( _BaseRepositoryManagerRestTransport._BaseDeleteConnection._get_http_options() ) + request, metadata = self._interceptor.pre_delete_connection( request, metadata ) @@ -1112,6 +1318,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + 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.cloudbuild_v2.RepositoryManagerClient.DeleteConnection", + extra={ + "serviceName": "google.devtools.cloudbuild.v2.RepositoryManager", + "rpcName": "DeleteConnection", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = RepositoryManagerRestTransport._DeleteConnection._get_response( self._host, @@ -1130,7 +1363,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_connection(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = json_format.MessageToJson(resp) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.devtools.cloudbuild_v2.RepositoryManagerClient.delete_connection", + extra={ + "serviceName": "google.devtools.cloudbuild.v2.RepositoryManager", + "rpcName": "DeleteConnection", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _DeleteRepository( @@ -1168,7 +1423,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.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. @@ -1178,8 +1433,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.operations_pb2.Operation: @@ -1192,6 +1449,7 @@ def __call__( http_options = ( _BaseRepositoryManagerRestTransport._BaseDeleteRepository._get_http_options() ) + request, metadata = self._interceptor.pre_delete_repository( request, metadata ) @@ -1204,6 +1462,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + 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.cloudbuild_v2.RepositoryManagerClient.DeleteRepository", + extra={ + "serviceName": "google.devtools.cloudbuild.v2.RepositoryManager", + "rpcName": "DeleteRepository", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = RepositoryManagerRestTransport._DeleteRepository._get_response( self._host, @@ -1222,7 +1507,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.cloudbuild_v2.RepositoryManagerClient.delete_repository", + extra={ + "serviceName": "google.devtools.cloudbuild.v2.RepositoryManager", + "rpcName": "DeleteRepository", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _FetchGitRefs( @@ -1259,7 +1566,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> repositories.FetchGitRefsResponse: r"""Call the fetch git refs method over HTTP. @@ -1269,8 +1576,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.repositories.FetchGitRefsResponse: @@ -1280,6 +1589,7 @@ def __call__( http_options = ( _BaseRepositoryManagerRestTransport._BaseFetchGitRefs._get_http_options() ) + request, metadata = self._interceptor.pre_fetch_git_refs(request, metadata) transcoded_request = _BaseRepositoryManagerRestTransport._BaseFetchGitRefs._get_transcoded_request( http_options, request @@ -1290,6 +1600,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + 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.cloudbuild_v2.RepositoryManagerClient.FetchGitRefs", + extra={ + "serviceName": "google.devtools.cloudbuild.v2.RepositoryManager", + "rpcName": "FetchGitRefs", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = RepositoryManagerRestTransport._FetchGitRefs._get_response( self._host, @@ -1310,7 +1647,31 @@ def __call__( pb_resp = repositories.FetchGitRefsResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_fetch_git_refs(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = repositories.FetchGitRefsResponse.to_json( + 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.cloudbuild_v2.RepositoryManagerClient.fetch_git_refs", + extra={ + "serviceName": "google.devtools.cloudbuild.v2.RepositoryManager", + "rpcName": "FetchGitRefs", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _FetchLinkableRepositories( @@ -1348,7 +1709,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> repositories.FetchLinkableRepositoriesResponse: r"""Call the fetch linkable repositories method over HTTP. @@ -1360,8 +1721,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.repositories.FetchLinkableRepositoriesResponse: @@ -1373,6 +1736,7 @@ def __call__( http_options = ( _BaseRepositoryManagerRestTransport._BaseFetchLinkableRepositories._get_http_options() ) + request, metadata = self._interceptor.pre_fetch_linkable_repositories( request, metadata ) @@ -1385,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 = type(request).to_json(request) + 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.cloudbuild_v2.RepositoryManagerClient.FetchLinkableRepositories", + extra={ + "serviceName": "google.devtools.cloudbuild.v2.RepositoryManager", + "rpcName": "FetchLinkableRepositories", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ( RepositoryManagerRestTransport._FetchLinkableRepositories._get_response( @@ -1407,7 +1798,31 @@ def __call__( pb_resp = repositories.FetchLinkableRepositoriesResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_fetch_linkable_repositories(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = ( + repositories.FetchLinkableRepositoriesResponse.to_json(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.cloudbuild_v2.RepositoryManagerClient.fetch_linkable_repositories", + extra={ + "serviceName": "google.devtools.cloudbuild.v2.RepositoryManager", + "rpcName": "FetchLinkableRepositories", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _FetchReadToken( @@ -1446,7 +1861,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> repositories.FetchReadTokenResponse: r"""Call the fetch read token method over HTTP. @@ -1456,8 +1871,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.repositories.FetchReadTokenResponse: @@ -1469,6 +1886,7 @@ def __call__( http_options = ( _BaseRepositoryManagerRestTransport._BaseFetchReadToken._get_http_options() ) + request, metadata = self._interceptor.pre_fetch_read_token( request, metadata ) @@ -1485,6 +1903,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + 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.cloudbuild_v2.RepositoryManagerClient.FetchReadToken", + extra={ + "serviceName": "google.devtools.cloudbuild.v2.RepositoryManager", + "rpcName": "FetchReadToken", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = RepositoryManagerRestTransport._FetchReadToken._get_response( self._host, @@ -1506,7 +1951,31 @@ def __call__( pb_resp = repositories.FetchReadTokenResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_fetch_read_token(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = repositories.FetchReadTokenResponse.to_json( + 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.cloudbuild_v2.RepositoryManagerClient.fetch_read_token", + extra={ + "serviceName": "google.devtools.cloudbuild.v2.RepositoryManager", + "rpcName": "FetchReadToken", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _FetchReadWriteToken( @@ -1545,7 +2014,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> repositories.FetchReadWriteTokenResponse: r"""Call the fetch read write token method over HTTP. @@ -1556,8 +2025,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.repositories.FetchReadWriteTokenResponse: @@ -1569,6 +2040,7 @@ def __call__( http_options = ( _BaseRepositoryManagerRestTransport._BaseFetchReadWriteToken._get_http_options() ) + request, metadata = self._interceptor.pre_fetch_read_write_token( request, metadata ) @@ -1585,6 +2057,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + 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.cloudbuild_v2.RepositoryManagerClient.FetchReadWriteToken", + extra={ + "serviceName": "google.devtools.cloudbuild.v2.RepositoryManager", + "rpcName": "FetchReadWriteToken", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ( RepositoryManagerRestTransport._FetchReadWriteToken._get_response( @@ -1608,7 +2107,31 @@ def __call__( pb_resp = repositories.FetchReadWriteTokenResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_fetch_read_write_token(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = repositories.FetchReadWriteTokenResponse.to_json( + 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.cloudbuild_v2.RepositoryManagerClient.fetch_read_write_token", + extra={ + "serviceName": "google.devtools.cloudbuild.v2.RepositoryManager", + "rpcName": "FetchReadWriteToken", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _GetConnection( @@ -1646,7 +2169,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> repositories.Connection: r"""Call the get connection method over HTTP. @@ -1657,8 +2180,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.repositories.Connection: @@ -1671,6 +2196,7 @@ def __call__( http_options = ( _BaseRepositoryManagerRestTransport._BaseGetConnection._get_http_options() ) + request, metadata = self._interceptor.pre_get_connection(request, metadata) transcoded_request = _BaseRepositoryManagerRestTransport._BaseGetConnection._get_transcoded_request( http_options, request @@ -1681,6 +2207,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + 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.cloudbuild_v2.RepositoryManagerClient.GetConnection", + extra={ + "serviceName": "google.devtools.cloudbuild.v2.RepositoryManager", + "rpcName": "GetConnection", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = RepositoryManagerRestTransport._GetConnection._get_response( self._host, @@ -1701,7 +2254,29 @@ def __call__( pb_resp = repositories.Connection.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_connection(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = repositories.Connection.to_json(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.cloudbuild_v2.RepositoryManagerClient.get_connection", + extra={ + "serviceName": "google.devtools.cloudbuild.v2.RepositoryManager", + "rpcName": "GetConnection", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _GetRepository( @@ -1739,7 +2314,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> repositories.Repository: r"""Call the get repository method over HTTP. @@ -1750,8 +2325,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.repositories.Repository: @@ -1763,6 +2340,7 @@ def __call__( http_options = ( _BaseRepositoryManagerRestTransport._BaseGetRepository._get_http_options() ) + request, metadata = self._interceptor.pre_get_repository(request, metadata) transcoded_request = _BaseRepositoryManagerRestTransport._BaseGetRepository._get_transcoded_request( http_options, request @@ -1773,6 +2351,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + 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.cloudbuild_v2.RepositoryManagerClient.GetRepository", + extra={ + "serviceName": "google.devtools.cloudbuild.v2.RepositoryManager", + "rpcName": "GetRepository", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = RepositoryManagerRestTransport._GetRepository._get_response( self._host, @@ -1793,7 +2398,29 @@ def __call__( pb_resp = repositories.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 = repositories.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.cloudbuild_v2.RepositoryManagerClient.get_repository", + extra={ + "serviceName": "google.devtools.cloudbuild.v2.RepositoryManager", + "rpcName": "GetRepository", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ListConnections( @@ -1831,7 +2458,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> repositories.ListConnectionsResponse: r"""Call the list connections method over HTTP. @@ -1842,8 +2469,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.repositories.ListConnectionsResponse: @@ -1855,6 +2484,7 @@ def __call__( http_options = ( _BaseRepositoryManagerRestTransport._BaseListConnections._get_http_options() ) + request, metadata = self._interceptor.pre_list_connections( request, metadata ) @@ -1867,6 +2497,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + 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.cloudbuild_v2.RepositoryManagerClient.ListConnections", + extra={ + "serviceName": "google.devtools.cloudbuild.v2.RepositoryManager", + "rpcName": "ListConnections", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = RepositoryManagerRestTransport._ListConnections._get_response( self._host, @@ -1887,7 +2544,31 @@ def __call__( pb_resp = repositories.ListConnectionsResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_connections(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = repositories.ListConnectionsResponse.to_json( + 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.cloudbuild_v2.RepositoryManagerClient.list_connections", + extra={ + "serviceName": "google.devtools.cloudbuild.v2.RepositoryManager", + "rpcName": "ListConnections", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ListRepositories( @@ -1925,7 +2606,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> repositories.ListRepositoriesResponse: r"""Call the list repositories method over HTTP. @@ -1936,8 +2617,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.repositories.ListRepositoriesResponse: @@ -1949,6 +2632,7 @@ def __call__( http_options = ( _BaseRepositoryManagerRestTransport._BaseListRepositories._get_http_options() ) + request, metadata = self._interceptor.pre_list_repositories( request, metadata ) @@ -1961,6 +2645,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.devtools.cloudbuild_v2.RepositoryManagerClient.ListRepositories", + extra={ + "serviceName": "google.devtools.cloudbuild.v2.RepositoryManager", + "rpcName": "ListRepositories", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = RepositoryManagerRestTransport._ListRepositories._get_response( self._host, @@ -1981,7 +2692,31 @@ def __call__( pb_resp = repositories.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 = repositories.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.cloudbuild_v2.RepositoryManagerClient.list_repositories", + extra={ + "serviceName": "google.devtools.cloudbuild.v2.RepositoryManager", + "rpcName": "ListRepositories", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _UpdateConnection( @@ -2020,7 +2755,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.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 connection method over HTTP. @@ -2030,8 +2765,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.operations_pb2.Operation: @@ -2044,6 +2781,7 @@ def __call__( http_options = ( _BaseRepositoryManagerRestTransport._BaseUpdateConnection._get_http_options() ) + request, metadata = self._interceptor.pre_update_connection( request, metadata ) @@ -2060,6 +2798,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + 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.cloudbuild_v2.RepositoryManagerClient.UpdateConnection", + extra={ + "serviceName": "google.devtools.cloudbuild.v2.RepositoryManager", + "rpcName": "UpdateConnection", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = RepositoryManagerRestTransport._UpdateConnection._get_response( self._host, @@ -2079,7 +2844,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_connection(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = json_format.MessageToJson(resp) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.devtools.cloudbuild_v2.RepositoryManagerClient.update_connection", + extra={ + "serviceName": "google.devtools.cloudbuild.v2.RepositoryManager", + "rpcName": "UpdateConnection", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp @property @@ -2248,7 +3035,7 @@ 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. @@ -2258,8 +3045,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each 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. @@ -2268,6 +3057,7 @@ def __call__( http_options = ( _BaseRepositoryManagerRestTransport._BaseGetIamPolicy._get_http_options() ) + request, metadata = self._interceptor.pre_get_iam_policy(request, metadata) transcoded_request = _BaseRepositoryManagerRestTransport._BaseGetIamPolicy._get_transcoded_request( http_options, request @@ -2278,6 +3068,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + 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.cloudbuild_v2.RepositoryManagerClient.GetIamPolicy", + extra={ + "serviceName": "google.devtools.cloudbuild.v2.RepositoryManager", + "rpcName": "GetIamPolicy", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = RepositoryManagerRestTransport._GetIamPolicy._get_response( self._host, @@ -2297,6 +3114,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.devtools.cloudbuild_v2.RepositoryManagerAsyncClient.GetIamPolicy", + extra={ + "serviceName": "google.devtools.cloudbuild.v2.RepositoryManager", + "rpcName": "GetIamPolicy", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property @@ -2338,7 +3176,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> policy_pb2.Policy: r"""Call the set iam policy method over HTTP. @@ -2348,8 +3186,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each 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. @@ -2358,6 +3198,7 @@ def __call__( http_options = ( _BaseRepositoryManagerRestTransport._BaseSetIamPolicy._get_http_options() ) + request, metadata = self._interceptor.pre_set_iam_policy(request, metadata) transcoded_request = _BaseRepositoryManagerRestTransport._BaseSetIamPolicy._get_transcoded_request( http_options, request @@ -2372,6 +3213,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + 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.cloudbuild_v2.RepositoryManagerClient.SetIamPolicy", + extra={ + "serviceName": "google.devtools.cloudbuild.v2.RepositoryManager", + "rpcName": "SetIamPolicy", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = RepositoryManagerRestTransport._SetIamPolicy._get_response( self._host, @@ -2392,6 +3260,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.devtools.cloudbuild_v2.RepositoryManagerAsyncClient.SetIamPolicy", + extra={ + "serviceName": "google.devtools.cloudbuild.v2.RepositoryManager", + "rpcName": "SetIamPolicy", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property @@ -2434,7 +3323,7 @@ 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. @@ -2444,8 +3333,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each 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. @@ -2454,6 +3345,7 @@ def __call__( http_options = ( _BaseRepositoryManagerRestTransport._BaseTestIamPermissions._get_http_options() ) + request, metadata = self._interceptor.pre_test_iam_permissions( request, metadata ) @@ -2470,6 +3362,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + 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.cloudbuild_v2.RepositoryManagerClient.TestIamPermissions", + extra={ + "serviceName": "google.devtools.cloudbuild.v2.RepositoryManager", + "rpcName": "TestIamPermissions", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = RepositoryManagerRestTransport._TestIamPermissions._get_response( self._host, @@ -2490,6 +3409,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.devtools.cloudbuild_v2.RepositoryManagerAsyncClient.TestIamPermissions", + extra={ + "serviceName": "google.devtools.cloudbuild.v2.RepositoryManager", + "rpcName": "TestIamPermissions", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property @@ -2532,7 +3472,7 @@ 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. @@ -2542,13 +3482,16 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. """ http_options = ( _BaseRepositoryManagerRestTransport._BaseCancelOperation._get_http_options() ) + request, metadata = self._interceptor.pre_cancel_operation( request, metadata ) @@ -2565,6 +3508,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + 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.cloudbuild_v2.RepositoryManagerClient.CancelOperation", + extra={ + "serviceName": "google.devtools.cloudbuild.v2.RepositoryManager", + "rpcName": "CancelOperation", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = RepositoryManagerRestTransport._CancelOperation._get_response( self._host, @@ -2621,7 +3591,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.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. @@ -2631,8 +3601,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be 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. @@ -2641,6 +3613,7 @@ def __call__( http_options = ( _BaseRepositoryManagerRestTransport._BaseGetOperation._get_http_options() ) + request, metadata = self._interceptor.pre_get_operation(request, metadata) transcoded_request = _BaseRepositoryManagerRestTransport._BaseGetOperation._get_transcoded_request( http_options, request @@ -2651,6 +3624,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + 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.cloudbuild_v2.RepositoryManagerClient.GetOperation", + extra={ + "serviceName": "google.devtools.cloudbuild.v2.RepositoryManager", + "rpcName": "GetOperation", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = RepositoryManagerRestTransport._GetOperation._get_response( self._host, @@ -2670,6 +3670,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.cloudbuild_v2.RepositoryManagerAsyncClient.GetOperation", + extra={ + "serviceName": "google.devtools.cloudbuild.v2.RepositoryManager", + "rpcName": "GetOperation", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property diff --git a/packages/google-cloud-build/samples/generated_samples/snippet_metadata_google.devtools.cloudbuild.v1.json b/packages/google-cloud-build/samples/generated_samples/snippet_metadata_google.devtools.cloudbuild.v1.json index 18e83f8ba807..48df7a914e6e 100644 --- a/packages/google-cloud-build/samples/generated_samples/snippet_metadata_google.devtools.cloudbuild.v1.json +++ b/packages/google-cloud-build/samples/generated_samples/snippet_metadata_google.devtools.cloudbuild.v1.json @@ -8,7 +8,7 @@ ], "language": "PYTHON", "name": "google-cloud-build", - "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.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.cloud.devtools.cloudbuild_v1.types.Build", @@ -304,7 +304,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.devtools.cloudbuild_v1.types.Build", @@ -389,7 +389,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.devtools.cloudbuild_v1.types.BuildTrigger", @@ -473,7 +473,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.devtools.cloudbuild_v1.types.BuildTrigger", @@ -558,7 +558,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -642,7 +642,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -731,7 +731,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -819,7 +819,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -904,7 +904,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "shortName": "delete_build_trigger" @@ -985,7 +985,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "shortName": "delete_build_trigger" @@ -1063,7 +1063,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -1143,7 +1143,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -1228,7 +1228,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.devtools.cloudbuild_v1.types.BuildTrigger", @@ -1312,7 +1312,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.devtools.cloudbuild_v1.types.BuildTrigger", @@ -1397,7 +1397,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.devtools.cloudbuild_v1.types.Build", @@ -1481,7 +1481,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.devtools.cloudbuild_v1.types.Build", @@ -1562,7 +1562,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.devtools.cloudbuild_v1.types.WorkerPool", @@ -1642,7 +1642,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.devtools.cloudbuild_v1.types.WorkerPool", @@ -1723,7 +1723,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.devtools.cloudbuild_v1.services.cloud_build.pagers.ListBuildTriggersAsyncPager", @@ -1803,7 +1803,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.devtools.cloudbuild_v1.services.cloud_build.pagers.ListBuildTriggersPager", @@ -1888,7 +1888,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.devtools.cloudbuild_v1.services.cloud_build.pagers.ListBuildsAsyncPager", @@ -1972,7 +1972,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.devtools.cloudbuild_v1.services.cloud_build.pagers.ListBuildsPager", @@ -2053,7 +2053,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.devtools.cloudbuild_v1.services.cloud_build.pagers.ListWorkerPoolsAsyncPager", @@ -2133,7 +2133,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.devtools.cloudbuild_v1.services.cloud_build.pagers.ListWorkerPoolsPager", @@ -2210,7 +2210,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.devtools.cloudbuild_v1.types.ReceiveTriggerWebhookResponse", @@ -2286,7 +2286,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.devtools.cloudbuild_v1.types.ReceiveTriggerWebhookResponse", @@ -2371,7 +2371,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -2455,7 +2455,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -2544,7 +2544,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -2632,7 +2632,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -2721,7 +2721,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.devtools.cloudbuild_v1.types.BuildTrigger", @@ -2809,7 +2809,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.devtools.cloudbuild_v1.types.BuildTrigger", @@ -2894,7 +2894,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -2978,7 +2978,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-build/samples/generated_samples/snippet_metadata_google.devtools.cloudbuild.v2.json b/packages/google-cloud-build/samples/generated_samples/snippet_metadata_google.devtools.cloudbuild.v2.json index e71bcd97a913..b384db6d11b0 100644 --- a/packages/google-cloud-build/samples/generated_samples/snippet_metadata_google.devtools.cloudbuild.v2.json +++ b/packages/google-cloud-build/samples/generated_samples/snippet_metadata_google.devtools.cloudbuild.v2.json @@ -8,7 +8,7 @@ ], "language": "PYTHON", "name": "google-cloud-build", - "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.api_core.operation_async.AsyncOperation", @@ -135,7 +135,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -224,7 +224,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -312,7 +312,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -401,7 +401,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -489,7 +489,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -570,7 +570,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -650,7 +650,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -731,7 +731,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -811,7 +811,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -892,7 +892,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.devtools.cloudbuild_v2.types.FetchGitRefsResponse", @@ -972,7 +972,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.devtools.cloudbuild_v2.types.FetchGitRefsResponse", @@ -1049,7 +1049,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.devtools.cloudbuild_v2.services.repository_manager.pagers.FetchLinkableRepositoriesAsyncPager", @@ -1125,7 +1125,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.devtools.cloudbuild_v2.services.repository_manager.pagers.FetchLinkableRepositoriesPager", @@ -1206,7 +1206,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.devtools.cloudbuild_v2.types.FetchReadTokenResponse", @@ -1286,7 +1286,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.devtools.cloudbuild_v2.types.FetchReadTokenResponse", @@ -1367,7 +1367,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.devtools.cloudbuild_v2.types.FetchReadWriteTokenResponse", @@ -1447,7 +1447,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.devtools.cloudbuild_v2.types.FetchReadWriteTokenResponse", @@ -1528,7 +1528,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.devtools.cloudbuild_v2.types.Connection", @@ -1608,7 +1608,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.devtools.cloudbuild_v2.types.Connection", @@ -1689,7 +1689,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.devtools.cloudbuild_v2.types.Repository", @@ -1769,7 +1769,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.devtools.cloudbuild_v2.types.Repository", @@ -1850,7 +1850,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.devtools.cloudbuild_v2.services.repository_manager.pagers.ListConnectionsAsyncPager", @@ -1930,7 +1930,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.devtools.cloudbuild_v2.services.repository_manager.pagers.ListConnectionsPager", @@ -2011,7 +2011,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.devtools.cloudbuild_v2.services.repository_manager.pagers.ListRepositoriesAsyncPager", @@ -2091,7 +2091,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.devtools.cloudbuild_v2.services.repository_manager.pagers.ListRepositoriesPager", @@ -2176,7 +2176,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -2260,7 +2260,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-build/tests/unit/gapic/cloudbuild_v1/test_cloud_build.py b/packages/google-cloud-build/tests/unit/gapic/cloudbuild_v1/test_cloud_build.py index c03d84e29e05..71c4b3109603 100644 --- a/packages/google-cloud-build/tests/unit/gapic/cloudbuild_v1/test_cloud_build.py +++ b/packages/google-cloud-build/tests/unit/gapic/cloudbuild_v1/test_cloud_build.py @@ -7004,6 +7004,7 @@ def test_create_build_rest_required_fields(request_type=cloudbuild.CreateBuildRe response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.create_build(request) @@ -7056,6 +7057,7 @@ def test_create_build_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.create_build(**mock_args) @@ -7190,6 +7192,7 @@ def test_get_build_rest_required_fields(request_type=cloudbuild.GetBuildRequest) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.get_build(request) @@ -7244,6 +7247,7 @@ def test_get_build_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.get_build(**mock_args) @@ -7381,6 +7385,7 @@ def test_list_builds_rest_required_fields(request_type=cloudbuild.ListBuildsRequ response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.list_builds(request) @@ -7437,6 +7442,7 @@ def test_list_builds_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.list_builds(**mock_args) @@ -7631,6 +7637,7 @@ def test_cancel_build_rest_required_fields(request_type=cloudbuild.CancelBuildRe response_value._content = json_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_build(request) @@ -7685,6 +7692,7 @@ def test_cancel_build_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.cancel_build(**mock_args) @@ -7820,6 +7828,7 @@ def test_retry_build_rest_required_fields(request_type=cloudbuild.RetryBuildRequ response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.retry_build(request) @@ -7872,6 +7881,7 @@ def test_retry_build_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.retry_build(**mock_args) @@ -8005,6 +8015,7 @@ def test_approve_build_rest_required_fields( response_value._content = json_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_build(request) @@ -8051,6 +8062,7 @@ def test_approve_build_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.approve_build(**mock_args) @@ -8190,6 +8202,7 @@ def test_create_build_trigger_rest_required_fields( response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.create_build_trigger(request) @@ -8244,6 +8257,7 @@ def test_create_build_trigger_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.create_build_trigger(**mock_args) @@ -8382,6 +8396,7 @@ def test_get_build_trigger_rest_required_fields( response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.get_build_trigger(request) @@ -8436,6 +8451,7 @@ def test_get_build_trigger_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.get_build_trigger(**mock_args) @@ -8580,6 +8596,7 @@ def test_list_build_triggers_rest_required_fields( response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.list_build_triggers(request) @@ -8634,6 +8651,7 @@ def test_list_build_triggers_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.list_build_triggers(**mock_args) @@ -8833,6 +8851,7 @@ def test_delete_build_trigger_rest_required_fields( response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.delete_build_trigger(request) @@ -8885,6 +8904,7 @@ def test_delete_build_trigger_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_build_trigger(**mock_args) @@ -9028,6 +9048,7 @@ def test_update_build_trigger_rest_required_fields( response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.update_build_trigger(request) @@ -9084,6 +9105,7 @@ def test_update_build_trigger_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.update_build_trigger(**mock_args) @@ -9227,6 +9249,7 @@ def test_run_build_trigger_rest_required_fields( response_value._content = json_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_build_trigger(request) @@ -9280,6 +9303,7 @@ def test_run_build_trigger_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = 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_build_trigger(**mock_args) @@ -9474,6 +9498,7 @@ def test_create_worker_pool_rest_required_fields( response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.create_worker_pool(request) @@ -9539,6 +9564,7 @@ def test_create_worker_pool_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.create_worker_pool(**mock_args) @@ -9672,6 +9698,7 @@ def test_get_worker_pool_rest_required_fields( response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.get_worker_pool(request) @@ -9719,6 +9746,7 @@ def test_get_worker_pool_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.get_worker_pool(**mock_args) @@ -9863,6 +9891,7 @@ def test_delete_worker_pool_rest_required_fields( response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.delete_worker_pool(request) @@ -9917,6 +9946,7 @@ def test_delete_worker_pool_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.delete_worker_pool(**mock_args) @@ -10056,6 +10086,7 @@ def test_update_worker_pool_rest_required_fields( response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.update_worker_pool(request) @@ -10112,6 +10143,7 @@ def test_update_worker_pool_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.update_worker_pool(**mock_args) @@ -10253,6 +10285,7 @@ def test_list_worker_pools_rest_required_fields( response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.list_worker_pools(request) @@ -10306,6 +10339,7 @@ def test_list_worker_pools_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.list_worker_pools(**mock_args) @@ -12638,6 +12672,7 @@ def test_create_build_rest_bad_request(request_type=cloudbuild.CreateBuildReques response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.create_build(request) @@ -12908,6 +12943,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.create_build(request) # Establish that the response is the type that we expect. @@ -12947,6 +12983,7 @@ def test_create_build_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = json_format.MessageToJson(operations_pb2.Operation()) req.return_value.content = return_value @@ -12989,6 +13026,7 @@ def test_get_build_rest_bad_request(request_type=cloudbuild.GetBuildRequest): response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.get_build(request) @@ -13034,6 +13072,7 @@ def test_get_build_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.get_build(request) # Establish that the response is the type that we expect. @@ -13082,6 +13121,7 @@ def test_get_build_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = cloudbuild.Build.to_json(cloudbuild.Build()) req.return_value.content = return_value @@ -13124,6 +13164,7 @@ def test_list_builds_rest_bad_request(request_type=cloudbuild.ListBuildsRequest) response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.list_builds(request) @@ -13159,6 +13200,7 @@ def test_list_builds_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.list_builds(request) # Establish that the response is the type that we expect. @@ -13197,6 +13239,7 @@ def test_list_builds_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = cloudbuild.ListBuildsResponse.to_json( cloudbuild.ListBuildsResponse() ) @@ -13241,6 +13284,7 @@ def test_cancel_build_rest_bad_request(request_type=cloudbuild.CancelBuildReques response_value.status_code = 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_build(request) @@ -13286,6 +13330,7 @@ def test_cancel_build_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_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_build(request) # Establish that the response is the type that we expect. @@ -13334,6 +13379,7 @@ def test_cancel_build_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = cloudbuild.Build.to_json(cloudbuild.Build()) req.return_value.content = return_value @@ -13376,6 +13422,7 @@ def test_retry_build_rest_bad_request(request_type=cloudbuild.RetryBuildRequest) response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.retry_build(request) @@ -13406,6 +13453,7 @@ def test_retry_build_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.retry_build(request) # Establish that the response is the type that we expect. @@ -13445,6 +13493,7 @@ def test_retry_build_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = json_format.MessageToJson(operations_pb2.Operation()) req.return_value.content = return_value @@ -13487,6 +13536,7 @@ def test_approve_build_rest_bad_request(request_type=cloudbuild.ApproveBuildRequ response_value.status_code = 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_build(request) @@ -13517,6 +13567,7 @@ def test_approve_build_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_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_build(request) # Establish that the response is the type that we expect. @@ -13556,6 +13607,7 @@ def test_approve_build_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = json_format.MessageToJson(operations_pb2.Operation()) req.return_value.content = return_value @@ -13600,6 +13652,7 @@ def test_create_build_trigger_rest_bad_request( response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.create_build_trigger(request) @@ -13948,6 +14001,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.create_build_trigger(request) # Establish that the response is the type that we expect. @@ -13997,6 +14051,7 @@ def test_create_build_trigger_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = cloudbuild.BuildTrigger.to_json(cloudbuild.BuildTrigger()) req.return_value.content = return_value @@ -14041,6 +14096,7 @@ def test_get_build_trigger_rest_bad_request( response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.get_build_trigger(request) @@ -14086,6 +14142,7 @@ def test_get_build_trigger_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.get_build_trigger(request) # Establish that the response is the type that we expect. @@ -14135,6 +14192,7 @@ def test_get_build_trigger_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = cloudbuild.BuildTrigger.to_json(cloudbuild.BuildTrigger()) req.return_value.content = return_value @@ -14179,6 +14237,7 @@ def test_list_build_triggers_rest_bad_request( response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.list_build_triggers(request) @@ -14214,6 +14273,7 @@ def test_list_build_triggers_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.list_build_triggers(request) # Establish that the response is the type that we expect. @@ -14254,6 +14314,7 @@ def test_list_build_triggers_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = cloudbuild.ListBuildTriggersResponse.to_json( cloudbuild.ListBuildTriggersResponse() ) @@ -14300,6 +14361,7 @@ def test_delete_build_trigger_rest_bad_request( response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.delete_build_trigger(request) @@ -14330,6 +14392,7 @@ def test_delete_build_trigger_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_build_trigger(request) # Establish that the response is the type that we expect. @@ -14366,6 +14429,7 @@ def test_delete_build_trigger_rest_interceptors(null_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 = cloudbuild.DeleteBuildTriggerRequest() metadata = [ @@ -14406,6 +14470,7 @@ def test_update_build_trigger_rest_bad_request( response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.update_build_trigger(request) @@ -14754,6 +14819,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.update_build_trigger(request) # Establish that the response is the type that we expect. @@ -14803,6 +14869,7 @@ def test_update_build_trigger_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = cloudbuild.BuildTrigger.to_json(cloudbuild.BuildTrigger()) req.return_value.content = return_value @@ -14847,6 +14914,7 @@ def test_run_build_trigger_rest_bad_request( response_value.status_code = 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_build_trigger(request) @@ -14954,6 +15022,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_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_build_trigger(request) # Establish that the response is the type that we expect. @@ -14995,6 +15064,7 @@ def test_run_build_trigger_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = json_format.MessageToJson(operations_pb2.Operation()) req.return_value.content = return_value @@ -15039,6 +15109,7 @@ def test_receive_trigger_webhook_rest_bad_request( response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.receive_trigger_webhook(request) @@ -15149,6 +15220,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.receive_trigger_webhook(request) # Establish that the response is the type that we expect. @@ -15188,6 +15260,7 @@ def test_receive_trigger_webhook_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = cloudbuild.ReceiveTriggerWebhookResponse.to_json( cloudbuild.ReceiveTriggerWebhookResponse() ) @@ -15234,6 +15307,7 @@ def test_create_worker_pool_rest_bad_request( response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.create_worker_pool(request) @@ -15358,6 +15432,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.create_worker_pool(request) # Establish that the response is the type that we expect. @@ -15399,6 +15474,7 @@ def test_create_worker_pool_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = json_format.MessageToJson(operations_pb2.Operation()) req.return_value.content = return_value @@ -15441,6 +15517,7 @@ def test_get_worker_pool_rest_bad_request(request_type=cloudbuild.GetWorkerPoolR response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.get_worker_pool(request) @@ -15480,6 +15557,7 @@ def test_get_worker_pool_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.get_worker_pool(request) # Establish that the response is the type that we expect. @@ -15524,6 +15602,7 @@ def test_get_worker_pool_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = cloudbuild.WorkerPool.to_json(cloudbuild.WorkerPool()) req.return_value.content = return_value @@ -15568,6 +15647,7 @@ def test_delete_worker_pool_rest_bad_request( response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.delete_worker_pool(request) @@ -15598,6 +15678,7 @@ def test_delete_worker_pool_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.delete_worker_pool(request) # Establish that the response is the type that we expect. @@ -15639,6 +15720,7 @@ def test_delete_worker_pool_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = json_format.MessageToJson(operations_pb2.Operation()) req.return_value.content = return_value @@ -15687,6 +15769,7 @@ def test_update_worker_pool_rest_bad_request( response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.update_worker_pool(request) @@ -15815,6 +15898,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.update_worker_pool(request) # Establish that the response is the type that we expect. @@ -15856,6 +15940,7 @@ def test_update_worker_pool_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = json_format.MessageToJson(operations_pb2.Operation()) req.return_value.content = return_value @@ -15900,6 +15985,7 @@ def test_list_worker_pools_rest_bad_request( response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.list_worker_pools(request) @@ -15935,6 +16021,7 @@ def test_list_worker_pools_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.list_worker_pools(request) # Establish that the response is the type that we expect. @@ -15975,6 +16062,7 @@ def test_list_worker_pools_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = cloudbuild.ListWorkerPoolsResponse.to_json( cloudbuild.ListWorkerPoolsResponse() ) diff --git a/packages/google-cloud-build/tests/unit/gapic/cloudbuild_v2/test_repository_manager.py b/packages/google-cloud-build/tests/unit/gapic/cloudbuild_v2/test_repository_manager.py index 5be3cfbec46e..fb4f00e50466 100644 --- a/packages/google-cloud-build/tests/unit/gapic/cloudbuild_v2/test_repository_manager.py +++ b/packages/google-cloud-build/tests/unit/gapic/cloudbuild_v2/test_repository_manager.py @@ -6550,6 +6550,7 @@ def test_create_connection_rest_required_fields( response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.create_connection(request) @@ -6610,6 +6611,7 @@ def test_create_connection_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.create_connection(**mock_args) @@ -6743,6 +6745,7 @@ def test_get_connection_rest_required_fields( response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.get_connection(request) @@ -6790,6 +6793,7 @@ def test_get_connection_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.get_connection(**mock_args) @@ -6930,6 +6934,7 @@ def test_list_connections_rest_required_fields( response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.list_connections(request) @@ -6983,6 +6988,7 @@ def test_list_connections_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.list_connections(**mock_args) @@ -7184,6 +7190,7 @@ def test_update_connection_rest_required_fields( response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.update_connection(request) @@ -7241,6 +7248,7 @@ def test_update_connection_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.update_connection(**mock_args) @@ -7383,6 +7391,7 @@ def test_delete_connection_rest_required_fields( response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.delete_connection(request) @@ -7436,6 +7445,7 @@ def test_delete_connection_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.delete_connection(**mock_args) @@ -7580,6 +7590,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) @@ -7642,6 +7653,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) @@ -7782,6 +7794,7 @@ def test_batch_create_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.batch_create_repositories(request) @@ -7836,6 +7849,7 @@ def test_batch_create_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.batch_create_repositories(**mock_args) @@ -7968,6 +7982,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) @@ -8015,6 +8030,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) @@ -8156,6 +8172,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) @@ -8212,6 +8229,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) @@ -8418,6 +8436,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) @@ -8471,6 +8490,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) @@ -8608,6 +8628,7 @@ def test_fetch_read_write_token_rest_required_fields( response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.fetch_read_write_token(request) @@ -8655,6 +8676,7 @@ def test_fetch_read_write_token_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.fetch_read_write_token(**mock_args) @@ -8789,6 +8811,7 @@ def test_fetch_read_token_rest_required_fields( response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.fetch_read_token(request) @@ -8836,6 +8859,7 @@ def test_fetch_read_token_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.fetch_read_token(**mock_args) @@ -8981,6 +9005,7 @@ def test_fetch_linkable_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.fetch_linkable_repositories(request) @@ -9175,6 +9200,7 @@ def test_fetch_git_refs_rest_required_fields( response_value._content = json_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_git_refs(request) @@ -9222,6 +9248,7 @@ def test_fetch_git_refs_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = 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_git_refs(**mock_args) @@ -10101,6 +10128,7 @@ def test_create_connection_rest_bad_request( response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.create_connection(request) @@ -10258,6 +10286,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.create_connection(request) # Establish that the response is the type that we expect. @@ -10299,6 +10328,7 @@ def test_create_connection_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = json_format.MessageToJson(operations_pb2.Operation()) req.return_value.content = return_value @@ -10343,6 +10373,7 @@ def test_get_connection_rest_bad_request( response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.get_connection(request) @@ -10381,6 +10412,7 @@ def test_get_connection_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.get_connection(request) # Establish that the response is the type that we expect. @@ -10424,6 +10456,7 @@ def test_get_connection_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = repositories.Connection.to_json(repositories.Connection()) req.return_value.content = return_value @@ -10468,6 +10501,7 @@ def test_list_connections_rest_bad_request( response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.list_connections(request) @@ -10503,6 +10537,7 @@ def test_list_connections_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.list_connections(request) # Establish that the response is the type that we expect. @@ -10543,6 +10578,7 @@ def test_list_connections_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = repositories.ListConnectionsResponse.to_json( repositories.ListConnectionsResponse() ) @@ -10591,6 +10627,7 @@ def test_update_connection_rest_bad_request( response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.update_connection(request) @@ -10750,6 +10787,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.update_connection(request) # Establish that the response is the type that we expect. @@ -10791,6 +10829,7 @@ def test_update_connection_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = json_format.MessageToJson(operations_pb2.Operation()) req.return_value.content = return_value @@ -10835,6 +10874,7 @@ def test_delete_connection_rest_bad_request( response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.delete_connection(request) @@ -10865,6 +10905,7 @@ def test_delete_connection_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.delete_connection(request) # Establish that the response is the type that we expect. @@ -10906,6 +10947,7 @@ def test_delete_connection_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = json_format.MessageToJson(operations_pb2.Operation()) req.return_value.content = return_value @@ -10950,6 +10992,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) @@ -11056,6 +11099,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_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. @@ -11097,6 +11141,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 @@ -11141,6 +11186,7 @@ def test_batch_create_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.batch_create_repositories(request) @@ -11171,6 +11217,7 @@ def test_batch_create_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.batch_create_repositories(request) # Establish that the response is the type that we expect. @@ -11212,6 +11259,7 @@ def test_batch_create_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 = json_format.MessageToJson(operations_pb2.Operation()) req.return_value.content = return_value @@ -11258,6 +11306,7 @@ def test_get_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.get_repository(request) @@ -11298,6 +11347,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. @@ -11341,6 +11391,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 = repositories.Repository.to_json(repositories.Repository()) req.return_value.content = return_value @@ -11385,6 +11436,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) @@ -11420,6 +11472,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. @@ -11460,6 +11513,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 = repositories.ListRepositoriesResponse.to_json( repositories.ListRepositoriesResponse() ) @@ -11508,6 +11562,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) @@ -11540,6 +11595,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. @@ -11581,6 +11637,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 @@ -11627,6 +11684,7 @@ def test_fetch_read_write_token_rest_bad_request( response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.fetch_read_write_token(request) @@ -11664,6 +11722,7 @@ def test_fetch_read_write_token_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.fetch_read_write_token(request) # Establish that the response is the type that we expect. @@ -11704,6 +11763,7 @@ def test_fetch_read_write_token_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = repositories.FetchReadWriteTokenResponse.to_json( repositories.FetchReadWriteTokenResponse() ) @@ -11752,6 +11812,7 @@ def test_fetch_read_token_rest_bad_request( response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.fetch_read_token(request) @@ -11789,6 +11850,7 @@ def test_fetch_read_token_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.fetch_read_token(request) # Establish that the response is the type that we expect. @@ -11829,6 +11891,7 @@ def test_fetch_read_token_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = repositories.FetchReadTokenResponse.to_json( repositories.FetchReadTokenResponse() ) @@ -11877,6 +11940,7 @@ def test_fetch_linkable_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.fetch_linkable_repositories(request) @@ -11914,6 +11978,7 @@ def test_fetch_linkable_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.fetch_linkable_repositories(request) # Establish that the response is the type that we expect. @@ -11954,6 +12019,7 @@ def test_fetch_linkable_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 = repositories.FetchLinkableRepositoriesResponse.to_json( repositories.FetchLinkableRepositoriesResponse() ) @@ -12000,6 +12066,7 @@ def test_fetch_git_refs_rest_bad_request(request_type=repositories.FetchGitRefsR response_value.status_code = 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_git_refs(request) @@ -12037,6 +12104,7 @@ def test_fetch_git_refs_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_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_git_refs(request) # Establish that the response is the type that we expect. @@ -12077,6 +12145,7 @@ def test_fetch_git_refs_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = repositories.FetchGitRefsResponse.to_json( repositories.FetchGitRefsResponse() ) @@ -12125,6 +12194,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) @@ -12157,6 +12227,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) @@ -12187,6 +12258,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) @@ -12219,6 +12291,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) @@ -12249,6 +12322,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) @@ -12281,6 +12355,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) @@ -12311,6 +12386,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) @@ -12341,6 +12417,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) @@ -12371,6 +12448,7 @@ def test_get_operation_rest_bad_request( response_value.status_code = 400 response_value.request = Request() req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.get_operation(request) @@ -12401,6 +12479,7 @@ def test_get_operation_rest(request_type): response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.get_operation(request) diff --git a/packages/google-cloud-certificate-manager/google/cloud/certificate_manager/gapic_version.py b/packages/google-cloud-certificate-manager/google/cloud/certificate_manager/gapic_version.py index 02874f69f4e5..558c8aab67c5 100644 --- a/packages/google-cloud-certificate-manager/google/cloud/certificate_manager/gapic_version.py +++ b/packages/google-cloud-certificate-manager/google/cloud/certificate_manager/gapic_version.py @@ -13,4 +13,4 @@ # See the License for the specific language governing permissions and # limitations under the License. # -__version__ = "1.8.1" # {x-release-please-version} +__version__ = "0.0.0" # {x-release-please-version} diff --git a/packages/google-cloud-certificate-manager/google/cloud/certificate_manager_v1/gapic_version.py b/packages/google-cloud-certificate-manager/google/cloud/certificate_manager_v1/gapic_version.py index 02874f69f4e5..558c8aab67c5 100644 --- a/packages/google-cloud-certificate-manager/google/cloud/certificate_manager_v1/gapic_version.py +++ b/packages/google-cloud-certificate-manager/google/cloud/certificate_manager_v1/gapic_version.py @@ -13,4 +13,4 @@ # See the License for the specific language governing permissions and # limitations under the License. # -__version__ = "1.8.1" # {x-release-please-version} +__version__ = "0.0.0" # {x-release-please-version} diff --git a/packages/google-cloud-certificate-manager/google/cloud/certificate_manager_v1/services/certificate_manager/async_client.py b/packages/google-cloud-certificate-manager/google/cloud/certificate_manager_v1/services/certificate_manager/async_client.py index c94eb8ade417..e4b7224d40f3 100644 --- a/packages/google-cloud-certificate-manager/google/cloud/certificate_manager_v1/services/certificate_manager/async_client.py +++ b/packages/google-cloud-certificate-manager/google/cloud/certificate_manager_v1/services/certificate_manager/async_client.py @@ -14,6 +14,7 @@ # limitations under the License. # from collections import OrderedDict +import logging as std_logging import re from typing import ( Callable, @@ -64,6 +65,15 @@ from .transports.base import DEFAULT_CLIENT_INFO, CertificateManagerTransport from .transports.grpc_asyncio import CertificateManagerGrpcAsyncIOTransport +try: + from google.api_core import client_logging # type: ignore + + CLIENT_LOGGING_SUPPORTED = True # pragma: NO COVER +except ImportError: # pragma: NO COVER + CLIENT_LOGGING_SUPPORTED = False + +_LOGGER = std_logging.getLogger(__name__) + class CertificateManagerAsyncClient: """API Overview @@ -331,6 +341,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.certificatemanager_v1.CertificateManagerAsyncClient`.", + extra={ + "serviceName": "google.cloud.certificatemanager.v1.CertificateManager", + "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.certificatemanager.v1.CertificateManager", + "credentialsType": None, + }, + ) + async def list_certificates( self, request: Optional[ @@ -340,7 +372,7 @@ async def list_certificates( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListCertificatesAsyncPager: r"""Lists Certificates in a given project and location. @@ -385,8 +417,10 @@ async def sample_list_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.certificate_manager_v1.services.certificate_manager.pagers.ListCertificatesAsyncPager: @@ -462,7 +496,7 @@ async def get_certificate( name: Optional[str] = None, retry: OptionalRetry = 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_manager.Certificate: r"""Gets details of a single Certificate. @@ -505,8 +539,10 @@ async def sample_get_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.certificate_manager_v1.types.Certificate: @@ -569,7 +605,7 @@ async def create_certificate( certificate_id: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, 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 Certificate in a given project and location. @@ -632,8 +668,10 @@ async def sample_create_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.api_core.operation_async.AsyncOperation: @@ -712,7 +750,7 @@ async def update_certificate( update_mask: Optional[field_mask_pb2.FieldMask] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, 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 Certificate. @@ -766,8 +804,10 @@ async def sample_update_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.api_core.operation_async.AsyncOperation: @@ -845,7 +885,7 @@ async def delete_certificate( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, 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 Certificate. @@ -892,8 +932,10 @@ async def sample_delete_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.api_core.operation_async.AsyncOperation: @@ -974,7 +1016,7 @@ async def list_certificate_maps( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListCertificateMapsAsyncPager: r"""Lists CertificateMaps in a given project and location. @@ -1020,8 +1062,10 @@ async def sample_list_certificate_maps(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.certificate_manager_v1.services.certificate_manager.pagers.ListCertificateMapsAsyncPager: @@ -1097,7 +1141,7 @@ async def get_certificate_map( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> certificate_manager.CertificateMap: r"""Gets details of a single CertificateMap. @@ -1141,8 +1185,10 @@ async def sample_get_certificate_map(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.certificate_manager_v1.types.CertificateMap: @@ -1207,7 +1253,7 @@ async def create_certificate_map( certificate_map_id: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, 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 CertificateMap in a given project and location. @@ -1270,8 +1316,10 @@ async def sample_create_certificate_map(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.api_core.operation_async.AsyncOperation: @@ -1350,7 +1398,7 @@ async def update_certificate_map( update_mask: Optional[field_mask_pb2.FieldMask] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, 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 CertificateMap. @@ -1404,8 +1452,10 @@ async def sample_update_certificate_map(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.api_core.operation_async.AsyncOperation: @@ -1483,7 +1533,7 @@ async def delete_certificate_map( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation_async.AsyncOperation: r"""Deletes a single CertificateMap. A Certificate Map can't be deleted if it contains Certificate Map Entries. @@ -1534,8 +1584,10 @@ async def sample_delete_certificate_map(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.api_core.operation_async.AsyncOperation: @@ -1616,7 +1668,7 @@ async def list_certificate_map_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.ListCertificateMapEntriesAsyncPager: r"""Lists CertificateMapEntries in a given project and location. @@ -1663,8 +1715,10 @@ async def sample_list_certificate_map_entries(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.certificate_manager_v1.services.certificate_manager.pagers.ListCertificateMapEntriesAsyncPager: @@ -1742,7 +1796,7 @@ async def get_certificate_map_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]]] = (), ) -> certificate_manager.CertificateMapEntry: r"""Gets details of a single CertificateMapEntry. @@ -1786,8 +1840,10 @@ async def sample_get_certificate_map_entry(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.certificate_manager_v1.types.CertificateMapEntry: @@ -1850,7 +1906,7 @@ async def create_certificate_map_entry( certificate_map_entry_id: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, 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 CertificateMapEntry in a given project and location. @@ -1918,8 +1974,10 @@ async def sample_create_certificate_map_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.api_core.operation_async.AsyncOperation: @@ -2002,7 +2060,7 @@ async def update_certificate_map_entry( update_mask: Optional[field_mask_pb2.FieldMask] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, 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 CertificateMapEntry. @@ -2061,8 +2119,10 @@ async def sample_update_certificate_map_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.api_core.operation_async.AsyncOperation: @@ -2142,7 +2202,7 @@ async def delete_certificate_map_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]]] = (), ) -> operation_async.AsyncOperation: r"""Deletes a single CertificateMapEntry. @@ -2190,8 +2250,10 @@ async def sample_delete_certificate_map_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.api_core.operation_async.AsyncOperation: @@ -2274,7 +2336,7 @@ async def list_dns_authorizations( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListDnsAuthorizationsAsyncPager: r"""Lists DnsAuthorizations in a given project and location. @@ -2320,8 +2382,10 @@ async def sample_list_dns_authorizations(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.certificate_manager_v1.services.certificate_manager.pagers.ListDnsAuthorizationsAsyncPager: @@ -2397,7 +2461,7 @@ async def get_dns_authorization( name: Optional[str] = None, retry: OptionalRetry = 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_manager.DnsAuthorization: r"""Gets details of a single DnsAuthorization. @@ -2441,8 +2505,10 @@ async def sample_get_dns_authorization(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.certificate_manager_v1.types.DnsAuthorization: @@ -2508,7 +2574,7 @@ async def create_dns_authorization( dns_authorization_id: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, 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 DnsAuthorization in a given project and location. @@ -2575,8 +2641,10 @@ async def sample_create_dns_authorization(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.api_core.operation_async.AsyncOperation: @@ -2654,7 +2722,7 @@ async def update_dns_authorization( update_mask: Optional[field_mask_pb2.FieldMask] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, 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 DnsAuthorization. @@ -2712,8 +2780,10 @@ async def sample_update_dns_authorization(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.api_core.operation_async.AsyncOperation: @@ -2790,7 +2860,7 @@ async def delete_dns_authorization( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, 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 DnsAuthorization. @@ -2838,8 +2908,10 @@ async def sample_delete_dns_authorization(): retry (google.api_core.retry_async.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.api_core.operation_async.AsyncOperation: @@ -2922,7 +2994,7 @@ async def list_certificate_issuance_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.ListCertificateIssuanceConfigsAsyncPager: r"""Lists CertificateIssuanceConfigs in a given project and location. @@ -2969,8 +3041,10 @@ async def sample_list_certificate_issuance_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.certificate_manager_v1.services.certificate_manager.pagers.ListCertificateIssuanceConfigsAsyncPager: @@ -3050,7 +3124,7 @@ async def get_certificate_issuance_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]]] = (), ) -> certificate_issuance_config.CertificateIssuanceConfig: r"""Gets details of a single CertificateIssuanceConfig. @@ -3094,8 +3168,10 @@ async def sample_get_certificate_issuance_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.certificate_manager_v1.types.CertificateIssuanceConfig: @@ -3169,7 +3245,7 @@ async def create_certificate_issuance_config( certificate_issuance_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 CertificateIssuanceConfig in a given project and location. @@ -3240,8 +3316,10 @@ async def sample_create_certificate_issuance_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: @@ -3331,7 +3409,7 @@ async def delete_certificate_issuance_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 CertificateIssuanceConfig. @@ -3380,8 +3458,10 @@ async def sample_delete_certificate_issuance_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: @@ -3466,7 +3546,7 @@ async def list_trust_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.ListTrustConfigsAsyncPager: r"""Lists TrustConfigs in a given project and location. @@ -3511,8 +3591,10 @@ async def sample_list_trust_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.certificate_manager_v1.services.certificate_manager.pagers.ListTrustConfigsAsyncPager: @@ -3586,7 +3668,7 @@ async def get_trust_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]]] = (), ) -> trust_config.TrustConfig: r"""Gets details of a single TrustConfig. @@ -3629,8 +3711,10 @@ async def sample_get_trust_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.certificate_manager_v1.types.TrustConfig: @@ -3693,7 +3777,7 @@ async def create_trust_config( trust_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 TrustConfig in a given project and location. @@ -3756,8 +3840,10 @@ async def sample_create_trust_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: @@ -3836,7 +3922,7 @@ async def update_trust_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 a TrustConfig. @@ -3890,8 +3976,10 @@ async def sample_update_trust_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: @@ -3967,7 +4055,7 @@ async def delete_trust_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 TrustConfig. @@ -4014,8 +4102,10 @@ async def sample_delete_trust_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: @@ -4093,7 +4183,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. @@ -4104,8 +4194,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. @@ -4146,7 +4238,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. @@ -4157,8 +4249,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. @@ -4199,7 +4293,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. @@ -4215,8 +4309,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 """ @@ -4253,7 +4349,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. @@ -4268,8 +4364,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 """ @@ -4306,7 +4404,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. @@ -4317,8 +4415,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. @@ -4359,7 +4459,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. @@ -4370,8 +4470,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-certificate-manager/google/cloud/certificate_manager_v1/services/certificate_manager/client.py b/packages/google-cloud-certificate-manager/google/cloud/certificate_manager_v1/services/certificate_manager/client.py index aee840ef5ff6..e894cc32e8f3 100644 --- a/packages/google-cloud-certificate-manager/google/cloud/certificate_manager_v1/services/certificate_manager/client.py +++ b/packages/google-cloud-certificate-manager/google/cloud/certificate_manager_v1/services/certificate_manager/client.py @@ -14,6 +14,7 @@ # limitations under the License. # from collections import OrderedDict +import logging as std_logging import os import re from typing import ( @@ -48,6 +49,15 @@ except AttributeError: # pragma: NO COVER OptionalRetry = Union[retries.Retry, object, None] # type: ignore +try: + from google.api_core import client_logging # type: ignore + + CLIENT_LOGGING_SUPPORTED = True # pragma: NO COVER +except ImportError: # pragma: NO COVER + CLIENT_LOGGING_SUPPORTED = False + +_LOGGER = std_logging.getLogger(__name__) + from google.api_core import operation # type: ignore from google.api_core import operation_async # type: ignore from google.cloud.location import locations_pb2 # type: ignore @@ -761,6 +771,10 @@ def __init__( # Initialize the universe domain validation. self._is_universe_domain_valid = False + if CLIENT_LOGGING_SUPPORTED: # pragma: NO COVER + # Setup logging. + client_logging.initialize_logging() + api_key_value = getattr(self._client_options, "api_key", None) if api_key_value and credentials: raise ValueError( @@ -827,6 +841,29 @@ def __init__( api_audience=self._client_options.api_audience, ) + if "async" not in str(self._transport): + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + std_logging.DEBUG + ): # pragma: NO COVER + _LOGGER.debug( + "Created client `google.cloud.certificatemanager_v1.CertificateManagerClient`.", + extra={ + "serviceName": "google.cloud.certificatemanager.v1.CertificateManager", + "universeDomain": getattr( + self._transport._credentials, "universe_domain", "" + ), + "credentialsType": f"{type(self._transport._credentials).__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.certificatemanager.v1.CertificateManager", + "credentialsType": None, + }, + ) + def list_certificates( self, request: Optional[ @@ -836,7 +873,7 @@ def list_certificates( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListCertificatesPager: r"""Lists Certificates in a given project and location. @@ -881,8 +918,10 @@ def sample_list_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.certificate_manager_v1.services.certificate_manager.pagers.ListCertificatesPager: @@ -955,7 +994,7 @@ def get_certificate( name: Optional[str] = None, retry: OptionalRetry = 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_manager.Certificate: r"""Gets details of a single Certificate. @@ -998,8 +1037,10 @@ def sample_get_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.certificate_manager_v1.types.Certificate: @@ -1059,7 +1100,7 @@ def create_certificate( certificate_id: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.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 Certificate in a given project and location. @@ -1122,8 +1163,10 @@ def sample_create_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.api_core.operation.Operation: @@ -1199,7 +1242,7 @@ def update_certificate( update_mask: Optional[field_mask_pb2.FieldMask] = None, retry: OptionalRetry = gapic_v1.method.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 Certificate. @@ -1253,8 +1296,10 @@ def sample_update_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.api_core.operation.Operation: @@ -1329,7 +1374,7 @@ def delete_certificate( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.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 Certificate. @@ -1376,8 +1421,10 @@ def sample_delete_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.api_core.operation.Operation: @@ -1455,7 +1502,7 @@ def list_certificate_maps( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListCertificateMapsPager: r"""Lists CertificateMaps in a given project and location. @@ -1501,8 +1548,10 @@ def sample_list_certificate_maps(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.certificate_manager_v1.services.certificate_manager.pagers.ListCertificateMapsPager: @@ -1575,7 +1624,7 @@ def get_certificate_map( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> certificate_manager.CertificateMap: r"""Gets details of a single CertificateMap. @@ -1619,8 +1668,10 @@ def sample_get_certificate_map(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.certificate_manager_v1.types.CertificateMap: @@ -1682,7 +1733,7 @@ def create_certificate_map( certificate_map_id: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.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 CertificateMap in a given project and location. @@ -1745,8 +1796,10 @@ def sample_create_certificate_map(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.api_core.operation.Operation: @@ -1822,7 +1875,7 @@ def update_certificate_map( update_mask: Optional[field_mask_pb2.FieldMask] = None, retry: OptionalRetry = gapic_v1.method.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 CertificateMap. @@ -1876,8 +1929,10 @@ def sample_update_certificate_map(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.api_core.operation.Operation: @@ -1952,7 +2007,7 @@ def delete_certificate_map( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operation.Operation: r"""Deletes a single CertificateMap. A Certificate Map can't be deleted if it contains Certificate Map Entries. @@ -2003,8 +2058,10 @@ def sample_delete_certificate_map(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.api_core.operation.Operation: @@ -2082,7 +2139,7 @@ def list_certificate_map_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.ListCertificateMapEntriesPager: r"""Lists CertificateMapEntries in a given project and location. @@ -2129,8 +2186,10 @@ def sample_list_certificate_map_entries(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.certificate_manager_v1.services.certificate_manager.pagers.ListCertificateMapEntriesPager: @@ -2207,7 +2266,7 @@ def get_certificate_map_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]]] = (), ) -> certificate_manager.CertificateMapEntry: r"""Gets details of a single CertificateMapEntry. @@ -2251,8 +2310,10 @@ def sample_get_certificate_map_entry(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.certificate_manager_v1.types.CertificateMapEntry: @@ -2314,7 +2375,7 @@ def create_certificate_map_entry( certificate_map_entry_id: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.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 CertificateMapEntry in a given project and location. @@ -2382,8 +2443,10 @@ def sample_create_certificate_map_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.api_core.operation.Operation: @@ -2465,7 +2528,7 @@ def update_certificate_map_entry( update_mask: Optional[field_mask_pb2.FieldMask] = None, retry: OptionalRetry = gapic_v1.method.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 CertificateMapEntry. @@ -2524,8 +2587,10 @@ def sample_update_certificate_map_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.api_core.operation.Operation: @@ -2604,7 +2669,7 @@ def delete_certificate_map_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]]] = (), ) -> operation.Operation: r"""Deletes a single CertificateMapEntry. @@ -2652,8 +2717,10 @@ def sample_delete_certificate_map_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.api_core.operation.Operation: @@ -2735,7 +2802,7 @@ def list_dns_authorizations( parent: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> pagers.ListDnsAuthorizationsPager: r"""Lists DnsAuthorizations in a given project and location. @@ -2781,8 +2848,10 @@ def sample_list_dns_authorizations(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.certificate_manager_v1.services.certificate_manager.pagers.ListDnsAuthorizationsPager: @@ -2855,7 +2924,7 @@ def get_dns_authorization( name: Optional[str] = None, retry: OptionalRetry = 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_manager.DnsAuthorization: r"""Gets details of a single DnsAuthorization. @@ -2899,8 +2968,10 @@ def sample_get_dns_authorization(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.cloud.certificate_manager_v1.types.DnsAuthorization: @@ -2963,7 +3034,7 @@ def create_dns_authorization( dns_authorization_id: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.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 DnsAuthorization in a given project and location. @@ -3030,8 +3101,10 @@ def sample_create_dns_authorization(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.api_core.operation.Operation: @@ -3106,7 +3179,7 @@ def update_dns_authorization( update_mask: Optional[field_mask_pb2.FieldMask] = None, retry: OptionalRetry = gapic_v1.method.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 DnsAuthorization. @@ -3164,8 +3237,10 @@ def sample_update_dns_authorization(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.api_core.operation.Operation: @@ -3239,7 +3314,7 @@ def delete_dns_authorization( name: Optional[str] = None, retry: OptionalRetry = gapic_v1.method.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 DnsAuthorization. @@ -3287,8 +3362,10 @@ def sample_delete_dns_authorization(): retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: google.api_core.operation.Operation: @@ -3368,7 +3445,7 @@ def list_certificate_issuance_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.ListCertificateIssuanceConfigsPager: r"""Lists CertificateIssuanceConfigs in a given project and location. @@ -3415,8 +3492,10 @@ def sample_list_certificate_issuance_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.certificate_manager_v1.services.certificate_manager.pagers.ListCertificateIssuanceConfigsPager: @@ -3495,7 +3574,7 @@ def get_certificate_issuance_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]]] = (), ) -> certificate_issuance_config.CertificateIssuanceConfig: r"""Gets details of a single CertificateIssuanceConfig. @@ -3539,8 +3618,10 @@ def sample_get_certificate_issuance_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.certificate_manager_v1.types.CertificateIssuanceConfig: @@ -3613,7 +3694,7 @@ def create_certificate_issuance_config( certificate_issuance_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 CertificateIssuanceConfig in a given project and location. @@ -3684,8 +3765,10 @@ def sample_create_certificate_issuance_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: @@ -3774,7 +3857,7 @@ def delete_certificate_issuance_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 CertificateIssuanceConfig. @@ -3823,8 +3906,10 @@ def sample_delete_certificate_issuance_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: @@ -3908,7 +3993,7 @@ def list_trust_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.ListTrustConfigsPager: r"""Lists TrustConfigs in a given project and location. @@ -3953,8 +4038,10 @@ def sample_list_trust_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.certificate_manager_v1.services.certificate_manager.pagers.ListTrustConfigsPager: @@ -4025,7 +4112,7 @@ def get_trust_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]]] = (), ) -> trust_config.TrustConfig: r"""Gets details of a single TrustConfig. @@ -4068,8 +4155,10 @@ def sample_get_trust_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.certificate_manager_v1.types.TrustConfig: @@ -4129,7 +4218,7 @@ def create_trust_config( trust_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 TrustConfig in a given project and location. @@ -4192,8 +4281,10 @@ def sample_create_trust_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: @@ -4269,7 +4360,7 @@ def update_trust_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 a TrustConfig. @@ -4323,8 +4414,10 @@ def sample_update_trust_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: @@ -4397,7 +4490,7 @@ def delete_trust_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 TrustConfig. @@ -4444,8 +4537,10 @@ def sample_delete_trust_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: @@ -4533,7 +4628,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. @@ -4544,8 +4639,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. @@ -4586,7 +4683,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. @@ -4597,8 +4694,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. @@ -4639,7 +4738,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. @@ -4655,8 +4754,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 """ @@ -4693,7 +4794,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. @@ -4708,8 +4809,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 """ @@ -4746,7 +4849,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. @@ -4757,8 +4860,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. @@ -4799,7 +4904,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. @@ -4810,8 +4915,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-certificate-manager/google/cloud/certificate_manager_v1/services/certificate_manager/pagers.py b/packages/google-cloud-certificate-manager/google/cloud/certificate_manager_v1/services/certificate_manager/pagers.py index 43b9e3446a05..c26e7b154217 100644 --- a/packages/google-cloud-certificate-manager/google/cloud/certificate_manager_v1/services/certificate_manager/pagers.py +++ b/packages/google-cloud-certificate-manager/google/cloud/certificate_manager_v1/services/certificate_manager/pagers.py @@ -71,7 +71,7 @@ def __init__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiate the pager. @@ -85,8 +85,10 @@ def __init__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. """ self._method = method self._request = certificate_manager.ListCertificatesRequest(request) @@ -145,7 +147,7 @@ def __init__( *, retry: OptionalAsyncRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiates the pager. @@ -159,8 +161,10 @@ def __init__( retry (google.api_core.retry.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. """ self._method = method self._request = certificate_manager.ListCertificatesRequest(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 = certificate_manager.ListCertificateMapsRequest(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 = certificate_manager.ListCertificateMapsRequest(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 = certificate_manager.ListCertificateMapEntriesRequest(request) @@ -457,7 +467,7 @@ def __init__( *, retry: OptionalAsyncRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiates the pager. @@ -471,8 +481,10 @@ def __init__( retry (google.api_core.retry.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. """ self._method = method self._request = certificate_manager.ListCertificateMapEntriesRequest(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 = certificate_manager.ListDnsAuthorizationsRequest(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 = certificate_manager.ListDnsAuthorizationsRequest(request) @@ -695,7 +711,7 @@ def __init__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiate the pager. @@ -709,8 +725,10 @@ def __init__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. """ self._method = method self._request = ( @@ -780,7 +798,7 @@ def __init__( *, retry: OptionalAsyncRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiates the pager. @@ -794,8 +812,10 @@ def __init__( retry (google.api_core.retry.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. """ self._method = method self._request = ( @@ -866,7 +886,7 @@ def __init__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiate the pager. @@ -880,8 +900,10 @@ def __init__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. """ self._method = method self._request = trust_config.ListTrustConfigsRequest(request) @@ -940,7 +962,7 @@ def __init__( *, retry: OptionalAsyncRetry = gapic_v1.method.DEFAULT, timeout: Union[float, object] = gapic_v1.method.DEFAULT, - metadata: Sequence[Tuple[str, str]] = () + metadata: Sequence[Tuple[str, Union[str, bytes]]] = () ): """Instantiates the pager. @@ -954,8 +976,10 @@ def __init__( retry (google.api_core.retry.AsyncRetry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. """ self._method = method self._request = trust_config.ListTrustConfigsRequest(request) diff --git a/packages/google-cloud-certificate-manager/google/cloud/certificate_manager_v1/services/certificate_manager/transports/grpc.py b/packages/google-cloud-certificate-manager/google/cloud/certificate_manager_v1/services/certificate_manager/transports/grpc.py index dc9f4d349363..15d1aaedc216 100644 --- a/packages/google-cloud-certificate-manager/google/cloud/certificate_manager_v1/services/certificate_manager/transports/grpc.py +++ b/packages/google-cloud-certificate-manager/google/cloud/certificate_manager_v1/services/certificate_manager/transports/grpc.py @@ -13,6 +13,9 @@ # See the License for the specific language governing permissions and # limitations under the License. # +import json +import logging as std_logging +import pickle from typing import Callable, Dict, Optional, Sequence, Tuple, Union import warnings @@ -22,7 +25,10 @@ from google.auth.transport.grpc import SslCredentials # type: ignore from google.cloud.location import locations_pb2 # type: ignore from google.longrunning import operations_pb2 # type: ignore +from google.protobuf.json_format import MessageToJson +import google.protobuf.message import grpc # type: ignore +import proto # type: ignore from google.cloud.certificate_manager_v1.types import certificate_issuance_config from google.cloud.certificate_manager_v1.types import ( @@ -34,6 +40,81 @@ from .base import DEFAULT_CLIENT_INFO, CertificateManagerTransport +try: + from google.api_core import client_logging # 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.certificatemanager.v1.CertificateManager", + "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.certificatemanager.v1.CertificateManager", + "rpcName": client_call_details.method, + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class CertificateManagerGrpcTransport(CertificateManagerTransport): """gRPC backend transport for CertificateManager. @@ -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 @@ -306,7 +394,7 @@ def list_certificates( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_certificates" not in self._stubs: - self._stubs["list_certificates"] = self.grpc_channel.unary_unary( + self._stubs["list_certificates"] = self._logged_channel.unary_unary( "/google.cloud.certificatemanager.v1.CertificateManager/ListCertificates", request_serializer=certificate_manager.ListCertificatesRequest.serialize, response_deserializer=certificate_manager.ListCertificatesResponse.deserialize, @@ -334,7 +422,7 @@ def get_certificate( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_certificate" not in self._stubs: - self._stubs["get_certificate"] = self.grpc_channel.unary_unary( + self._stubs["get_certificate"] = self._logged_channel.unary_unary( "/google.cloud.certificatemanager.v1.CertificateManager/GetCertificate", request_serializer=certificate_manager.GetCertificateRequest.serialize, response_deserializer=certificate_manager.Certificate.deserialize, @@ -363,7 +451,7 @@ def create_certificate( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_certificate" not in self._stubs: - self._stubs["create_certificate"] = self.grpc_channel.unary_unary( + self._stubs["create_certificate"] = self._logged_channel.unary_unary( "/google.cloud.certificatemanager.v1.CertificateManager/CreateCertificate", request_serializer=certificate_manager.CreateCertificateRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -391,7 +479,7 @@ def update_certificate( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_certificate" not in self._stubs: - self._stubs["update_certificate"] = self.grpc_channel.unary_unary( + self._stubs["update_certificate"] = self._logged_channel.unary_unary( "/google.cloud.certificatemanager.v1.CertificateManager/UpdateCertificate", request_serializer=certificate_manager.UpdateCertificateRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -419,7 +507,7 @@ def delete_certificate( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_certificate" not in self._stubs: - self._stubs["delete_certificate"] = self.grpc_channel.unary_unary( + self._stubs["delete_certificate"] = self._logged_channel.unary_unary( "/google.cloud.certificatemanager.v1.CertificateManager/DeleteCertificate", request_serializer=certificate_manager.DeleteCertificateRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -449,7 +537,7 @@ def list_certificate_maps( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_certificate_maps" not in self._stubs: - self._stubs["list_certificate_maps"] = self.grpc_channel.unary_unary( + self._stubs["list_certificate_maps"] = self._logged_channel.unary_unary( "/google.cloud.certificatemanager.v1.CertificateManager/ListCertificateMaps", request_serializer=certificate_manager.ListCertificateMapsRequest.serialize, response_deserializer=certificate_manager.ListCertificateMapsResponse.deserialize, @@ -478,7 +566,7 @@ def get_certificate_map( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_certificate_map" not in self._stubs: - self._stubs["get_certificate_map"] = self.grpc_channel.unary_unary( + self._stubs["get_certificate_map"] = self._logged_channel.unary_unary( "/google.cloud.certificatemanager.v1.CertificateManager/GetCertificateMap", request_serializer=certificate_manager.GetCertificateMapRequest.serialize, response_deserializer=certificate_manager.CertificateMap.deserialize, @@ -507,7 +595,7 @@ def create_certificate_map( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_certificate_map" not in self._stubs: - self._stubs["create_certificate_map"] = self.grpc_channel.unary_unary( + self._stubs["create_certificate_map"] = self._logged_channel.unary_unary( "/google.cloud.certificatemanager.v1.CertificateManager/CreateCertificateMap", request_serializer=certificate_manager.CreateCertificateMapRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -535,7 +623,7 @@ def update_certificate_map( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_certificate_map" not in self._stubs: - self._stubs["update_certificate_map"] = self.grpc_channel.unary_unary( + self._stubs["update_certificate_map"] = self._logged_channel.unary_unary( "/google.cloud.certificatemanager.v1.CertificateManager/UpdateCertificateMap", request_serializer=certificate_manager.UpdateCertificateMapRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -566,7 +654,7 @@ def delete_certificate_map( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_certificate_map" not in self._stubs: - self._stubs["delete_certificate_map"] = self.grpc_channel.unary_unary( + self._stubs["delete_certificate_map"] = self._logged_channel.unary_unary( "/google.cloud.certificatemanager.v1.CertificateManager/DeleteCertificateMap", request_serializer=certificate_manager.DeleteCertificateMapRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -596,7 +684,9 @@ def list_certificate_map_entries( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_certificate_map_entries" not in self._stubs: - self._stubs["list_certificate_map_entries"] = self.grpc_channel.unary_unary( + self._stubs[ + "list_certificate_map_entries" + ] = self._logged_channel.unary_unary( "/google.cloud.certificatemanager.v1.CertificateManager/ListCertificateMapEntries", request_serializer=certificate_manager.ListCertificateMapEntriesRequest.serialize, response_deserializer=certificate_manager.ListCertificateMapEntriesResponse.deserialize, @@ -625,7 +715,7 @@ def get_certificate_map_entry( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_certificate_map_entry" not in self._stubs: - self._stubs["get_certificate_map_entry"] = self.grpc_channel.unary_unary( + self._stubs["get_certificate_map_entry"] = self._logged_channel.unary_unary( "/google.cloud.certificatemanager.v1.CertificateManager/GetCertificateMapEntry", request_serializer=certificate_manager.GetCertificateMapEntryRequest.serialize, response_deserializer=certificate_manager.CertificateMapEntry.deserialize, @@ -654,7 +744,9 @@ def create_certificate_map_entry( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_certificate_map_entry" not in self._stubs: - self._stubs["create_certificate_map_entry"] = self.grpc_channel.unary_unary( + self._stubs[ + "create_certificate_map_entry" + ] = self._logged_channel.unary_unary( "/google.cloud.certificatemanager.v1.CertificateManager/CreateCertificateMapEntry", request_serializer=certificate_manager.CreateCertificateMapEntryRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -682,7 +774,9 @@ def update_certificate_map_entry( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_certificate_map_entry" not in self._stubs: - self._stubs["update_certificate_map_entry"] = self.grpc_channel.unary_unary( + self._stubs[ + "update_certificate_map_entry" + ] = self._logged_channel.unary_unary( "/google.cloud.certificatemanager.v1.CertificateManager/UpdateCertificateMapEntry", request_serializer=certificate_manager.UpdateCertificateMapEntryRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -710,7 +804,9 @@ def delete_certificate_map_entry( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_certificate_map_entry" not in self._stubs: - self._stubs["delete_certificate_map_entry"] = self.grpc_channel.unary_unary( + self._stubs[ + "delete_certificate_map_entry" + ] = self._logged_channel.unary_unary( "/google.cloud.certificatemanager.v1.CertificateManager/DeleteCertificateMapEntry", request_serializer=certificate_manager.DeleteCertificateMapEntryRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -740,7 +836,7 @@ def list_dns_authorizations( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_dns_authorizations" not in self._stubs: - self._stubs["list_dns_authorizations"] = self.grpc_channel.unary_unary( + self._stubs["list_dns_authorizations"] = self._logged_channel.unary_unary( "/google.cloud.certificatemanager.v1.CertificateManager/ListDnsAuthorizations", request_serializer=certificate_manager.ListDnsAuthorizationsRequest.serialize, response_deserializer=certificate_manager.ListDnsAuthorizationsResponse.deserialize, @@ -769,7 +865,7 @@ def get_dns_authorization( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_dns_authorization" not in self._stubs: - self._stubs["get_dns_authorization"] = self.grpc_channel.unary_unary( + self._stubs["get_dns_authorization"] = self._logged_channel.unary_unary( "/google.cloud.certificatemanager.v1.CertificateManager/GetDnsAuthorization", request_serializer=certificate_manager.GetDnsAuthorizationRequest.serialize, response_deserializer=certificate_manager.DnsAuthorization.deserialize, @@ -798,7 +894,7 @@ def create_dns_authorization( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_dns_authorization" not in self._stubs: - self._stubs["create_dns_authorization"] = self.grpc_channel.unary_unary( + self._stubs["create_dns_authorization"] = self._logged_channel.unary_unary( "/google.cloud.certificatemanager.v1.CertificateManager/CreateDnsAuthorization", request_serializer=certificate_manager.CreateDnsAuthorizationRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -826,7 +922,7 @@ def update_dns_authorization( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_dns_authorization" not in self._stubs: - self._stubs["update_dns_authorization"] = self.grpc_channel.unary_unary( + self._stubs["update_dns_authorization"] = self._logged_channel.unary_unary( "/google.cloud.certificatemanager.v1.CertificateManager/UpdateDnsAuthorization", request_serializer=certificate_manager.UpdateDnsAuthorizationRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -854,7 +950,7 @@ def delete_dns_authorization( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_dns_authorization" not in self._stubs: - self._stubs["delete_dns_authorization"] = self.grpc_channel.unary_unary( + self._stubs["delete_dns_authorization"] = self._logged_channel.unary_unary( "/google.cloud.certificatemanager.v1.CertificateManager/DeleteDnsAuthorization", request_serializer=certificate_manager.DeleteDnsAuthorizationRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -887,7 +983,7 @@ def list_certificate_issuance_configs( if "list_certificate_issuance_configs" not in self._stubs: self._stubs[ "list_certificate_issuance_configs" - ] = self.grpc_channel.unary_unary( + ] = self._logged_channel.unary_unary( "/google.cloud.certificatemanager.v1.CertificateManager/ListCertificateIssuanceConfigs", request_serializer=certificate_issuance_config.ListCertificateIssuanceConfigsRequest.serialize, response_deserializer=certificate_issuance_config.ListCertificateIssuanceConfigsResponse.deserialize, @@ -919,7 +1015,7 @@ def get_certificate_issuance_config( if "get_certificate_issuance_config" not in self._stubs: self._stubs[ "get_certificate_issuance_config" - ] = self.grpc_channel.unary_unary( + ] = self._logged_channel.unary_unary( "/google.cloud.certificatemanager.v1.CertificateManager/GetCertificateIssuanceConfig", request_serializer=certificate_issuance_config.GetCertificateIssuanceConfigRequest.serialize, response_deserializer=certificate_issuance_config.CertificateIssuanceConfig.deserialize, @@ -952,7 +1048,7 @@ def create_certificate_issuance_config( if "create_certificate_issuance_config" not in self._stubs: self._stubs[ "create_certificate_issuance_config" - ] = self.grpc_channel.unary_unary( + ] = self._logged_channel.unary_unary( "/google.cloud.certificatemanager.v1.CertificateManager/CreateCertificateIssuanceConfig", request_serializer=gcc_certificate_issuance_config.CreateCertificateIssuanceConfigRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -984,7 +1080,7 @@ def delete_certificate_issuance_config( if "delete_certificate_issuance_config" not in self._stubs: self._stubs[ "delete_certificate_issuance_config" - ] = self.grpc_channel.unary_unary( + ] = self._logged_channel.unary_unary( "/google.cloud.certificatemanager.v1.CertificateManager/DeleteCertificateIssuanceConfig", request_serializer=certificate_issuance_config.DeleteCertificateIssuanceConfigRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -1012,7 +1108,7 @@ def list_trust_configs( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_trust_configs" not in self._stubs: - self._stubs["list_trust_configs"] = self.grpc_channel.unary_unary( + self._stubs["list_trust_configs"] = self._logged_channel.unary_unary( "/google.cloud.certificatemanager.v1.CertificateManager/ListTrustConfigs", request_serializer=trust_config.ListTrustConfigsRequest.serialize, response_deserializer=trust_config.ListTrustConfigsResponse.deserialize, @@ -1038,7 +1134,7 @@ def get_trust_config( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_trust_config" not in self._stubs: - self._stubs["get_trust_config"] = self.grpc_channel.unary_unary( + self._stubs["get_trust_config"] = self._logged_channel.unary_unary( "/google.cloud.certificatemanager.v1.CertificateManager/GetTrustConfig", request_serializer=trust_config.GetTrustConfigRequest.serialize, response_deserializer=trust_config.TrustConfig.deserialize, @@ -1067,7 +1163,7 @@ def create_trust_config( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_trust_config" not in self._stubs: - self._stubs["create_trust_config"] = self.grpc_channel.unary_unary( + self._stubs["create_trust_config"] = self._logged_channel.unary_unary( "/google.cloud.certificatemanager.v1.CertificateManager/CreateTrustConfig", request_serializer=gcc_trust_config.CreateTrustConfigRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -1095,7 +1191,7 @@ def update_trust_config( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_trust_config" not in self._stubs: - self._stubs["update_trust_config"] = self.grpc_channel.unary_unary( + self._stubs["update_trust_config"] = self._logged_channel.unary_unary( "/google.cloud.certificatemanager.v1.CertificateManager/UpdateTrustConfig", request_serializer=gcc_trust_config.UpdateTrustConfigRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -1121,7 +1217,7 @@ def delete_trust_config( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_trust_config" not in self._stubs: - self._stubs["delete_trust_config"] = self.grpc_channel.unary_unary( + self._stubs["delete_trust_config"] = self._logged_channel.unary_unary( "/google.cloud.certificatemanager.v1.CertificateManager/DeleteTrustConfig", request_serializer=trust_config.DeleteTrustConfigRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -1129,7 +1225,7 @@ def delete_trust_config( return self._stubs["delete_trust_config"] def close(self): - self.grpc_channel.close() + self._logged_channel.close() @property def delete_operation( @@ -1141,7 +1237,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, @@ -1158,7 +1254,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, @@ -1175,7 +1271,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, @@ -1194,7 +1290,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, @@ -1213,7 +1309,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, @@ -1230,7 +1326,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-certificate-manager/google/cloud/certificate_manager_v1/services/certificate_manager/transports/grpc_asyncio.py b/packages/google-cloud-certificate-manager/google/cloud/certificate_manager_v1/services/certificate_manager/transports/grpc_asyncio.py index f70fa13b136a..6f77ff046790 100644 --- a/packages/google-cloud-certificate-manager/google/cloud/certificate_manager_v1/services/certificate_manager/transports/grpc_asyncio.py +++ b/packages/google-cloud-certificate-manager/google/cloud/certificate_manager_v1/services/certificate_manager/transports/grpc_asyncio.py @@ -14,6 +14,9 @@ # limitations under the License. # import inspect +import json +import logging as std_logging +import pickle from typing import Awaitable, Callable, Dict, Optional, Sequence, Tuple, Union import warnings @@ -24,8 +27,11 @@ from google.auth.transport.grpc import SslCredentials # type: ignore from google.cloud.location import locations_pb2 # type: ignore from google.longrunning import operations_pb2 # type: ignore +from google.protobuf.json_format import MessageToJson +import google.protobuf.message import grpc # type: ignore from grpc.experimental import aio # type: ignore +import proto # type: ignore from google.cloud.certificate_manager_v1.types import certificate_issuance_config from google.cloud.certificate_manager_v1.types import ( @@ -38,6 +44,82 @@ from .base import DEFAULT_CLIENT_INFO, CertificateManagerTransport from .grpc import CertificateManagerGrpcTransport +try: + from google.api_core import client_logging # 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.certificatemanager.v1.CertificateManager", + "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.certificatemanager.v1.CertificateManager", + "rpcName": str(client_call_details.method), + "response": grpc_response, + "metadata": grpc_response["metadata"], + }, + ) + return response + class CertificateManagerGrpcAsyncIOTransport(CertificateManagerTransport): """gRPC AsyncIO backend transport for CertificateManager. @@ -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. @@ -316,7 +401,7 @@ def list_certificates( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_certificates" not in self._stubs: - self._stubs["list_certificates"] = self.grpc_channel.unary_unary( + self._stubs["list_certificates"] = self._logged_channel.unary_unary( "/google.cloud.certificatemanager.v1.CertificateManager/ListCertificates", request_serializer=certificate_manager.ListCertificatesRequest.serialize, response_deserializer=certificate_manager.ListCertificatesResponse.deserialize, @@ -345,7 +430,7 @@ def get_certificate( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_certificate" not in self._stubs: - self._stubs["get_certificate"] = self.grpc_channel.unary_unary( + self._stubs["get_certificate"] = self._logged_channel.unary_unary( "/google.cloud.certificatemanager.v1.CertificateManager/GetCertificate", request_serializer=certificate_manager.GetCertificateRequest.serialize, response_deserializer=certificate_manager.Certificate.deserialize, @@ -375,7 +460,7 @@ def create_certificate( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_certificate" not in self._stubs: - self._stubs["create_certificate"] = self.grpc_channel.unary_unary( + self._stubs["create_certificate"] = self._logged_channel.unary_unary( "/google.cloud.certificatemanager.v1.CertificateManager/CreateCertificate", request_serializer=certificate_manager.CreateCertificateRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -404,7 +489,7 @@ def update_certificate( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_certificate" not in self._stubs: - self._stubs["update_certificate"] = self.grpc_channel.unary_unary( + self._stubs["update_certificate"] = self._logged_channel.unary_unary( "/google.cloud.certificatemanager.v1.CertificateManager/UpdateCertificate", request_serializer=certificate_manager.UpdateCertificateRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -433,7 +518,7 @@ def delete_certificate( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_certificate" not in self._stubs: - self._stubs["delete_certificate"] = self.grpc_channel.unary_unary( + self._stubs["delete_certificate"] = self._logged_channel.unary_unary( "/google.cloud.certificatemanager.v1.CertificateManager/DeleteCertificate", request_serializer=certificate_manager.DeleteCertificateRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -463,7 +548,7 @@ def list_certificate_maps( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_certificate_maps" not in self._stubs: - self._stubs["list_certificate_maps"] = self.grpc_channel.unary_unary( + self._stubs["list_certificate_maps"] = self._logged_channel.unary_unary( "/google.cloud.certificatemanager.v1.CertificateManager/ListCertificateMaps", request_serializer=certificate_manager.ListCertificateMapsRequest.serialize, response_deserializer=certificate_manager.ListCertificateMapsResponse.deserialize, @@ -492,7 +577,7 @@ def get_certificate_map( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_certificate_map" not in self._stubs: - self._stubs["get_certificate_map"] = self.grpc_channel.unary_unary( + self._stubs["get_certificate_map"] = self._logged_channel.unary_unary( "/google.cloud.certificatemanager.v1.CertificateManager/GetCertificateMap", request_serializer=certificate_manager.GetCertificateMapRequest.serialize, response_deserializer=certificate_manager.CertificateMap.deserialize, @@ -522,7 +607,7 @@ def create_certificate_map( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_certificate_map" not in self._stubs: - self._stubs["create_certificate_map"] = self.grpc_channel.unary_unary( + self._stubs["create_certificate_map"] = self._logged_channel.unary_unary( "/google.cloud.certificatemanager.v1.CertificateManager/CreateCertificateMap", request_serializer=certificate_manager.CreateCertificateMapRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -551,7 +636,7 @@ def update_certificate_map( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_certificate_map" not in self._stubs: - self._stubs["update_certificate_map"] = self.grpc_channel.unary_unary( + self._stubs["update_certificate_map"] = self._logged_channel.unary_unary( "/google.cloud.certificatemanager.v1.CertificateManager/UpdateCertificateMap", request_serializer=certificate_manager.UpdateCertificateMapRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -583,7 +668,7 @@ def delete_certificate_map( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_certificate_map" not in self._stubs: - self._stubs["delete_certificate_map"] = self.grpc_channel.unary_unary( + self._stubs["delete_certificate_map"] = self._logged_channel.unary_unary( "/google.cloud.certificatemanager.v1.CertificateManager/DeleteCertificateMap", request_serializer=certificate_manager.DeleteCertificateMapRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -613,7 +698,9 @@ def list_certificate_map_entries( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_certificate_map_entries" not in self._stubs: - self._stubs["list_certificate_map_entries"] = self.grpc_channel.unary_unary( + self._stubs[ + "list_certificate_map_entries" + ] = self._logged_channel.unary_unary( "/google.cloud.certificatemanager.v1.CertificateManager/ListCertificateMapEntries", request_serializer=certificate_manager.ListCertificateMapEntriesRequest.serialize, response_deserializer=certificate_manager.ListCertificateMapEntriesResponse.deserialize, @@ -642,7 +729,7 @@ def get_certificate_map_entry( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_certificate_map_entry" not in self._stubs: - self._stubs["get_certificate_map_entry"] = self.grpc_channel.unary_unary( + self._stubs["get_certificate_map_entry"] = self._logged_channel.unary_unary( "/google.cloud.certificatemanager.v1.CertificateManager/GetCertificateMapEntry", request_serializer=certificate_manager.GetCertificateMapEntryRequest.serialize, response_deserializer=certificate_manager.CertificateMapEntry.deserialize, @@ -672,7 +759,9 @@ def create_certificate_map_entry( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_certificate_map_entry" not in self._stubs: - self._stubs["create_certificate_map_entry"] = self.grpc_channel.unary_unary( + self._stubs[ + "create_certificate_map_entry" + ] = self._logged_channel.unary_unary( "/google.cloud.certificatemanager.v1.CertificateManager/CreateCertificateMapEntry", request_serializer=certificate_manager.CreateCertificateMapEntryRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -701,7 +790,9 @@ def update_certificate_map_entry( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_certificate_map_entry" not in self._stubs: - self._stubs["update_certificate_map_entry"] = self.grpc_channel.unary_unary( + self._stubs[ + "update_certificate_map_entry" + ] = self._logged_channel.unary_unary( "/google.cloud.certificatemanager.v1.CertificateManager/UpdateCertificateMapEntry", request_serializer=certificate_manager.UpdateCertificateMapEntryRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -730,7 +821,9 @@ def delete_certificate_map_entry( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_certificate_map_entry" not in self._stubs: - self._stubs["delete_certificate_map_entry"] = self.grpc_channel.unary_unary( + self._stubs[ + "delete_certificate_map_entry" + ] = self._logged_channel.unary_unary( "/google.cloud.certificatemanager.v1.CertificateManager/DeleteCertificateMapEntry", request_serializer=certificate_manager.DeleteCertificateMapEntryRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -760,7 +853,7 @@ def list_dns_authorizations( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_dns_authorizations" not in self._stubs: - self._stubs["list_dns_authorizations"] = self.grpc_channel.unary_unary( + self._stubs["list_dns_authorizations"] = self._logged_channel.unary_unary( "/google.cloud.certificatemanager.v1.CertificateManager/ListDnsAuthorizations", request_serializer=certificate_manager.ListDnsAuthorizationsRequest.serialize, response_deserializer=certificate_manager.ListDnsAuthorizationsResponse.deserialize, @@ -789,7 +882,7 @@ def get_dns_authorization( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_dns_authorization" not in self._stubs: - self._stubs["get_dns_authorization"] = self.grpc_channel.unary_unary( + self._stubs["get_dns_authorization"] = self._logged_channel.unary_unary( "/google.cloud.certificatemanager.v1.CertificateManager/GetDnsAuthorization", request_serializer=certificate_manager.GetDnsAuthorizationRequest.serialize, response_deserializer=certificate_manager.DnsAuthorization.deserialize, @@ -819,7 +912,7 @@ def create_dns_authorization( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_dns_authorization" not in self._stubs: - self._stubs["create_dns_authorization"] = self.grpc_channel.unary_unary( + self._stubs["create_dns_authorization"] = self._logged_channel.unary_unary( "/google.cloud.certificatemanager.v1.CertificateManager/CreateDnsAuthorization", request_serializer=certificate_manager.CreateDnsAuthorizationRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -848,7 +941,7 @@ def update_dns_authorization( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_dns_authorization" not in self._stubs: - self._stubs["update_dns_authorization"] = self.grpc_channel.unary_unary( + self._stubs["update_dns_authorization"] = self._logged_channel.unary_unary( "/google.cloud.certificatemanager.v1.CertificateManager/UpdateDnsAuthorization", request_serializer=certificate_manager.UpdateDnsAuthorizationRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -877,7 +970,7 @@ def delete_dns_authorization( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_dns_authorization" not in self._stubs: - self._stubs["delete_dns_authorization"] = self.grpc_channel.unary_unary( + self._stubs["delete_dns_authorization"] = self._logged_channel.unary_unary( "/google.cloud.certificatemanager.v1.CertificateManager/DeleteDnsAuthorization", request_serializer=certificate_manager.DeleteDnsAuthorizationRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -910,7 +1003,7 @@ def list_certificate_issuance_configs( if "list_certificate_issuance_configs" not in self._stubs: self._stubs[ "list_certificate_issuance_configs" - ] = self.grpc_channel.unary_unary( + ] = self._logged_channel.unary_unary( "/google.cloud.certificatemanager.v1.CertificateManager/ListCertificateIssuanceConfigs", request_serializer=certificate_issuance_config.ListCertificateIssuanceConfigsRequest.serialize, response_deserializer=certificate_issuance_config.ListCertificateIssuanceConfigsResponse.deserialize, @@ -942,7 +1035,7 @@ def get_certificate_issuance_config( if "get_certificate_issuance_config" not in self._stubs: self._stubs[ "get_certificate_issuance_config" - ] = self.grpc_channel.unary_unary( + ] = self._logged_channel.unary_unary( "/google.cloud.certificatemanager.v1.CertificateManager/GetCertificateIssuanceConfig", request_serializer=certificate_issuance_config.GetCertificateIssuanceConfigRequest.serialize, response_deserializer=certificate_issuance_config.CertificateIssuanceConfig.deserialize, @@ -975,7 +1068,7 @@ def create_certificate_issuance_config( if "create_certificate_issuance_config" not in self._stubs: self._stubs[ "create_certificate_issuance_config" - ] = self.grpc_channel.unary_unary( + ] = self._logged_channel.unary_unary( "/google.cloud.certificatemanager.v1.CertificateManager/CreateCertificateIssuanceConfig", request_serializer=gcc_certificate_issuance_config.CreateCertificateIssuanceConfigRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -1007,7 +1100,7 @@ def delete_certificate_issuance_config( if "delete_certificate_issuance_config" not in self._stubs: self._stubs[ "delete_certificate_issuance_config" - ] = self.grpc_channel.unary_unary( + ] = self._logged_channel.unary_unary( "/google.cloud.certificatemanager.v1.CertificateManager/DeleteCertificateIssuanceConfig", request_serializer=certificate_issuance_config.DeleteCertificateIssuanceConfigRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -1036,7 +1129,7 @@ def list_trust_configs( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "list_trust_configs" not in self._stubs: - self._stubs["list_trust_configs"] = self.grpc_channel.unary_unary( + self._stubs["list_trust_configs"] = self._logged_channel.unary_unary( "/google.cloud.certificatemanager.v1.CertificateManager/ListTrustConfigs", request_serializer=trust_config.ListTrustConfigsRequest.serialize, response_deserializer=trust_config.ListTrustConfigsResponse.deserialize, @@ -1064,7 +1157,7 @@ def get_trust_config( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "get_trust_config" not in self._stubs: - self._stubs["get_trust_config"] = self.grpc_channel.unary_unary( + self._stubs["get_trust_config"] = self._logged_channel.unary_unary( "/google.cloud.certificatemanager.v1.CertificateManager/GetTrustConfig", request_serializer=trust_config.GetTrustConfigRequest.serialize, response_deserializer=trust_config.TrustConfig.deserialize, @@ -1093,7 +1186,7 @@ def create_trust_config( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "create_trust_config" not in self._stubs: - self._stubs["create_trust_config"] = self.grpc_channel.unary_unary( + self._stubs["create_trust_config"] = self._logged_channel.unary_unary( "/google.cloud.certificatemanager.v1.CertificateManager/CreateTrustConfig", request_serializer=gcc_trust_config.CreateTrustConfigRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -1121,7 +1214,7 @@ def update_trust_config( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "update_trust_config" not in self._stubs: - self._stubs["update_trust_config"] = self.grpc_channel.unary_unary( + self._stubs["update_trust_config"] = self._logged_channel.unary_unary( "/google.cloud.certificatemanager.v1.CertificateManager/UpdateTrustConfig", request_serializer=gcc_trust_config.UpdateTrustConfigRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -1149,7 +1242,7 @@ def delete_trust_config( # gRPC handles serialization and deserialization, so we just need # to pass in the functions for each. if "delete_trust_config" not in self._stubs: - self._stubs["delete_trust_config"] = self.grpc_channel.unary_unary( + self._stubs["delete_trust_config"] = self._logged_channel.unary_unary( "/google.cloud.certificatemanager.v1.CertificateManager/DeleteTrustConfig", request_serializer=trust_config.DeleteTrustConfigRequest.serialize, response_deserializer=operations_pb2.Operation.FromString, @@ -1558,7 +1651,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: @@ -1574,7 +1667,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, @@ -1591,7 +1684,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, @@ -1608,7 +1701,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, @@ -1627,7 +1720,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, @@ -1646,7 +1739,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, @@ -1663,7 +1756,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-certificate-manager/google/cloud/certificate_manager_v1/services/certificate_manager/transports/rest.py b/packages/google-cloud-certificate-manager/google/cloud/certificate_manager_v1/services/certificate_manager/transports/rest.py index f5729a443a7b..dd7ddc945d4c 100644 --- a/packages/google-cloud-certificate-manager/google/cloud/certificate_manager_v1/services/certificate_manager/transports/rest.py +++ b/packages/google-cloud-certificate-manager/google/cloud/certificate_manager_v1/services/certificate_manager/transports/rest.py @@ -13,9 +13,9 @@ # See the License for the specific language governing permissions and # limitations under the License. # - import dataclasses import json # type: ignore +import logging from typing import Any, Callable, Dict, List, Optional, Sequence, Tuple, Union import warnings @@ -45,6 +45,14 @@ except AttributeError: # pragma: NO COVER OptionalRetry = Union[retries.Retry, object, None] # type: ignore +try: + from google.api_core import client_logging # type: ignore + + CLIENT_LOGGING_SUPPORTED = True # pragma: NO COVER +except ImportError: # pragma: NO COVER + CLIENT_LOGGING_SUPPORTED = False + +_LOGGER = logging.getLogger(__name__) DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo( gapic_version=BASE_DEFAULT_CLIENT_INFO.gapic_version, @@ -309,8 +317,11 @@ def post_update_trust_config(self, response): def pre_create_certificate( self, request: certificate_manager.CreateCertificateRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[certificate_manager.CreateCertificateRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + certificate_manager.CreateCertificateRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for create_certificate Override in a subclass to manipulate the request or metadata @@ -332,10 +343,10 @@ def post_create_certificate( def pre_create_certificate_issuance_config( self, request: gcc_certificate_issuance_config.CreateCertificateIssuanceConfigRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ gcc_certificate_issuance_config.CreateCertificateIssuanceConfigRequest, - Sequence[Tuple[str, str]], + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for create_certificate_issuance_config @@ -358,9 +369,10 @@ def post_create_certificate_issuance_config( def pre_create_certificate_map( self, request: certificate_manager.CreateCertificateMapRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ - certificate_manager.CreateCertificateMapRequest, Sequence[Tuple[str, str]] + certificate_manager.CreateCertificateMapRequest, + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for create_certificate_map @@ -383,9 +395,10 @@ def post_create_certificate_map( def pre_create_certificate_map_entry( self, request: certificate_manager.CreateCertificateMapEntryRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ - certificate_manager.CreateCertificateMapEntryRequest, Sequence[Tuple[str, str]] + certificate_manager.CreateCertificateMapEntryRequest, + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for create_certificate_map_entry @@ -408,9 +421,10 @@ def post_create_certificate_map_entry( def pre_create_dns_authorization( self, request: certificate_manager.CreateDnsAuthorizationRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ - certificate_manager.CreateDnsAuthorizationRequest, Sequence[Tuple[str, str]] + certificate_manager.CreateDnsAuthorizationRequest, + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for create_dns_authorization @@ -433,8 +447,11 @@ def post_create_dns_authorization( def pre_create_trust_config( self, request: gcc_trust_config.CreateTrustConfigRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[gcc_trust_config.CreateTrustConfigRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + gcc_trust_config.CreateTrustConfigRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for create_trust_config Override in a subclass to manipulate the request or metadata @@ -456,8 +473,11 @@ def post_create_trust_config( def pre_delete_certificate( self, request: certificate_manager.DeleteCertificateRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[certificate_manager.DeleteCertificateRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + certificate_manager.DeleteCertificateRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for delete_certificate Override in a subclass to manipulate the request or metadata @@ -479,10 +499,10 @@ def post_delete_certificate( def pre_delete_certificate_issuance_config( self, request: certificate_issuance_config.DeleteCertificateIssuanceConfigRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ certificate_issuance_config.DeleteCertificateIssuanceConfigRequest, - Sequence[Tuple[str, str]], + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for delete_certificate_issuance_config @@ -505,9 +525,10 @@ def post_delete_certificate_issuance_config( def pre_delete_certificate_map( self, request: certificate_manager.DeleteCertificateMapRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ - certificate_manager.DeleteCertificateMapRequest, Sequence[Tuple[str, str]] + certificate_manager.DeleteCertificateMapRequest, + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for delete_certificate_map @@ -530,9 +551,10 @@ def post_delete_certificate_map( def pre_delete_certificate_map_entry( self, request: certificate_manager.DeleteCertificateMapEntryRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ - certificate_manager.DeleteCertificateMapEntryRequest, Sequence[Tuple[str, str]] + certificate_manager.DeleteCertificateMapEntryRequest, + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for delete_certificate_map_entry @@ -555,9 +577,10 @@ def post_delete_certificate_map_entry( def pre_delete_dns_authorization( self, request: certificate_manager.DeleteDnsAuthorizationRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ - certificate_manager.DeleteDnsAuthorizationRequest, Sequence[Tuple[str, str]] + certificate_manager.DeleteDnsAuthorizationRequest, + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for delete_dns_authorization @@ -580,8 +603,10 @@ def post_delete_dns_authorization( def pre_delete_trust_config( self, request: trust_config.DeleteTrustConfigRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[trust_config.DeleteTrustConfigRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + trust_config.DeleteTrustConfigRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for delete_trust_config Override in a subclass to manipulate the request or metadata @@ -603,8 +628,11 @@ def post_delete_trust_config( def pre_get_certificate( self, request: certificate_manager.GetCertificateRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[certificate_manager.GetCertificateRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + certificate_manager.GetCertificateRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for get_certificate Override in a subclass to manipulate the request or metadata @@ -626,10 +654,10 @@ def post_get_certificate( def pre_get_certificate_issuance_config( self, request: certificate_issuance_config.GetCertificateIssuanceConfigRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ certificate_issuance_config.GetCertificateIssuanceConfigRequest, - Sequence[Tuple[str, str]], + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for get_certificate_issuance_config @@ -652,8 +680,11 @@ def post_get_certificate_issuance_config( def pre_get_certificate_map( self, request: certificate_manager.GetCertificateMapRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[certificate_manager.GetCertificateMapRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + certificate_manager.GetCertificateMapRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for get_certificate_map Override in a subclass to manipulate the request or metadata @@ -675,9 +706,10 @@ def post_get_certificate_map( def pre_get_certificate_map_entry( self, request: certificate_manager.GetCertificateMapEntryRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ - certificate_manager.GetCertificateMapEntryRequest, Sequence[Tuple[str, str]] + certificate_manager.GetCertificateMapEntryRequest, + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for get_certificate_map_entry @@ -700,9 +732,10 @@ def post_get_certificate_map_entry( def pre_get_dns_authorization( self, request: certificate_manager.GetDnsAuthorizationRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ - certificate_manager.GetDnsAuthorizationRequest, Sequence[Tuple[str, str]] + certificate_manager.GetDnsAuthorizationRequest, + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for get_dns_authorization @@ -725,8 +758,10 @@ def post_get_dns_authorization( def pre_get_trust_config( self, request: trust_config.GetTrustConfigRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[trust_config.GetTrustConfigRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + trust_config.GetTrustConfigRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for get_trust_config Override in a subclass to manipulate the request or metadata @@ -748,10 +783,10 @@ def post_get_trust_config( def pre_list_certificate_issuance_configs( self, request: certificate_issuance_config.ListCertificateIssuanceConfigsRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ certificate_issuance_config.ListCertificateIssuanceConfigsRequest, - Sequence[Tuple[str, str]], + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for list_certificate_issuance_configs @@ -775,9 +810,10 @@ def post_list_certificate_issuance_configs( def pre_list_certificate_map_entries( self, request: certificate_manager.ListCertificateMapEntriesRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ - certificate_manager.ListCertificateMapEntriesRequest, Sequence[Tuple[str, str]] + certificate_manager.ListCertificateMapEntriesRequest, + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for list_certificate_map_entries @@ -800,9 +836,10 @@ def post_list_certificate_map_entries( def pre_list_certificate_maps( self, request: certificate_manager.ListCertificateMapsRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ - certificate_manager.ListCertificateMapsRequest, Sequence[Tuple[str, str]] + certificate_manager.ListCertificateMapsRequest, + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for list_certificate_maps @@ -825,8 +862,11 @@ def post_list_certificate_maps( def pre_list_certificates( self, request: certificate_manager.ListCertificatesRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[certificate_manager.ListCertificatesRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + certificate_manager.ListCertificatesRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for list_certificates Override in a subclass to manipulate the request or metadata @@ -848,9 +888,10 @@ def post_list_certificates( def pre_list_dns_authorizations( self, request: certificate_manager.ListDnsAuthorizationsRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ - certificate_manager.ListDnsAuthorizationsRequest, Sequence[Tuple[str, str]] + certificate_manager.ListDnsAuthorizationsRequest, + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for list_dns_authorizations @@ -873,8 +914,10 @@ def post_list_dns_authorizations( def pre_list_trust_configs( self, request: trust_config.ListTrustConfigsRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[trust_config.ListTrustConfigsRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + trust_config.ListTrustConfigsRequest, Sequence[Tuple[str, Union[str, bytes]]] + ]: """Pre-rpc interceptor for list_trust_configs Override in a subclass to manipulate the request or metadata @@ -896,8 +939,11 @@ def post_list_trust_configs( def pre_update_certificate( self, request: certificate_manager.UpdateCertificateRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[certificate_manager.UpdateCertificateRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + certificate_manager.UpdateCertificateRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for update_certificate Override in a subclass to manipulate the request or metadata @@ -919,9 +965,10 @@ def post_update_certificate( def pre_update_certificate_map( self, request: certificate_manager.UpdateCertificateMapRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ - certificate_manager.UpdateCertificateMapRequest, Sequence[Tuple[str, str]] + certificate_manager.UpdateCertificateMapRequest, + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for update_certificate_map @@ -944,9 +991,10 @@ def post_update_certificate_map( def pre_update_certificate_map_entry( self, request: certificate_manager.UpdateCertificateMapEntryRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ - certificate_manager.UpdateCertificateMapEntryRequest, Sequence[Tuple[str, str]] + certificate_manager.UpdateCertificateMapEntryRequest, + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for update_certificate_map_entry @@ -969,9 +1017,10 @@ def post_update_certificate_map_entry( def pre_update_dns_authorization( self, request: certificate_manager.UpdateDnsAuthorizationRequest, - metadata: Sequence[Tuple[str, str]], + metadata: Sequence[Tuple[str, Union[str, bytes]]], ) -> Tuple[ - certificate_manager.UpdateDnsAuthorizationRequest, Sequence[Tuple[str, str]] + certificate_manager.UpdateDnsAuthorizationRequest, + Sequence[Tuple[str, Union[str, bytes]]], ]: """Pre-rpc interceptor for update_dns_authorization @@ -994,8 +1043,11 @@ def post_update_dns_authorization( def pre_update_trust_config( self, request: gcc_trust_config.UpdateTrustConfigRequest, - metadata: Sequence[Tuple[str, str]], - ) -> Tuple[gcc_trust_config.UpdateTrustConfigRequest, Sequence[Tuple[str, str]]]: + metadata: Sequence[Tuple[str, Union[str, bytes]]], + ) -> Tuple[ + gcc_trust_config.UpdateTrustConfigRequest, + Sequence[Tuple[str, Union[str, bytes]]], + ]: """Pre-rpc interceptor for update_trust_config Override in a subclass to manipulate the request or metadata @@ -1017,8 +1069,10 @@ def post_update_trust_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 @@ -1040,8 +1094,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 @@ -1063,8 +1119,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 @@ -1084,8 +1142,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 @@ -1105,8 +1165,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 @@ -1128,8 +1190,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 @@ -1352,7 +1416,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Call the create certificate method over HTTP. @@ -1362,8 +1426,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.operations_pb2.Operation: @@ -1376,6 +1442,7 @@ def __call__( http_options = ( _BaseCertificateManagerRestTransport._BaseCreateCertificate._get_http_options() ) + request, metadata = self._interceptor.pre_create_certificate( request, metadata ) @@ -1392,6 +1459,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.certificatemanager_v1.CertificateManagerClient.CreateCertificate", + extra={ + "serviceName": "google.cloud.certificatemanager.v1.CertificateManager", + "rpcName": "CreateCertificate", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = CertificateManagerRestTransport._CreateCertificate._get_response( self._host, @@ -1411,7 +1505,29 @@ def __call__( # Return the response resp = operations_pb2.Operation() json_format.Parse(response.content, resp, ignore_unknown_fields=True) + resp = self._interceptor.post_create_certificate(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = json_format.MessageToJson(resp) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.certificatemanager_v1.CertificateManagerClient.create_certificate", + extra={ + "serviceName": "google.cloud.certificatemanager.v1.CertificateManager", + "rpcName": "CreateCertificate", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _CreateCertificateIssuanceConfig( @@ -1452,7 +1568,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.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 certificate issuance config method over HTTP. @@ -1464,8 +1580,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.operations_pb2.Operation: @@ -1478,6 +1596,7 @@ def __call__( http_options = ( _BaseCertificateManagerRestTransport._BaseCreateCertificateIssuanceConfig._get_http_options() ) + ( request, metadata, @@ -1497,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.cloud.certificatemanager_v1.CertificateManagerClient.CreateCertificateIssuanceConfig", + extra={ + "serviceName": "google.cloud.certificatemanager.v1.CertificateManager", + "rpcName": "CreateCertificateIssuanceConfig", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = CertificateManagerRestTransport._CreateCertificateIssuanceConfig._get_response( self._host, @@ -1516,7 +1662,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_certificate_issuance_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.certificatemanager_v1.CertificateManagerClient.create_certificate_issuance_config", + extra={ + "serviceName": "google.cloud.certificatemanager.v1.CertificateManager", + "rpcName": "CreateCertificateIssuanceConfig", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _CreateCertificateMap( @@ -1555,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]]] = (), ) -> operations_pb2.Operation: r"""Call the create certificate map method over HTTP. @@ -1565,8 +1733,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.operations_pb2.Operation: @@ -1579,6 +1749,7 @@ def __call__( http_options = ( _BaseCertificateManagerRestTransport._BaseCreateCertificateMap._get_http_options() ) + request, metadata = self._interceptor.pre_create_certificate_map( request, metadata ) @@ -1595,6 +1766,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.certificatemanager_v1.CertificateManagerClient.CreateCertificateMap", + extra={ + "serviceName": "google.cloud.certificatemanager.v1.CertificateManager", + "rpcName": "CreateCertificateMap", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ( CertificateManagerRestTransport._CreateCertificateMap._get_response( @@ -1616,7 +1814,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_certificate_map(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = json_format.MessageToJson(resp) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.certificatemanager_v1.CertificateManagerClient.create_certificate_map", + extra={ + "serviceName": "google.cloud.certificatemanager.v1.CertificateManager", + "rpcName": "CreateCertificateMap", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _CreateCertificateMapEntry( @@ -1655,7 +1875,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.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 certificate map entry method over HTTP. @@ -1666,8 +1886,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.operations_pb2.Operation: @@ -1680,6 +1902,7 @@ def __call__( http_options = ( _BaseCertificateManagerRestTransport._BaseCreateCertificateMapEntry._get_http_options() ) + request, metadata = self._interceptor.pre_create_certificate_map_entry( request, metadata ) @@ -1696,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.certificatemanager_v1.CertificateManagerClient.CreateCertificateMapEntry", + extra={ + "serviceName": "google.cloud.certificatemanager.v1.CertificateManager", + "rpcName": "CreateCertificateMapEntry", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = CertificateManagerRestTransport._CreateCertificateMapEntry._get_response( self._host, @@ -1715,7 +1965,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_certificate_map_entry(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = json_format.MessageToJson(resp) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.certificatemanager_v1.CertificateManagerClient.create_certificate_map_entry", + extra={ + "serviceName": "google.cloud.certificatemanager.v1.CertificateManager", + "rpcName": "CreateCertificateMapEntry", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _CreateDnsAuthorization( @@ -1754,7 +2026,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Call the create dns authorization method over HTTP. @@ -1764,8 +2036,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.operations_pb2.Operation: @@ -1778,6 +2052,7 @@ def __call__( http_options = ( _BaseCertificateManagerRestTransport._BaseCreateDnsAuthorization._get_http_options() ) + request, metadata = self._interceptor.pre_create_dns_authorization( request, metadata ) @@ -1794,6 +2069,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.certificatemanager_v1.CertificateManagerClient.CreateDnsAuthorization", + extra={ + "serviceName": "google.cloud.certificatemanager.v1.CertificateManager", + "rpcName": "CreateDnsAuthorization", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ( CertificateManagerRestTransport._CreateDnsAuthorization._get_response( @@ -1815,7 +2117,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_dns_authorization(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = json_format.MessageToJson(resp) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.certificatemanager_v1.CertificateManagerClient.create_dns_authorization", + extra={ + "serviceName": "google.cloud.certificatemanager.v1.CertificateManager", + "rpcName": "CreateDnsAuthorization", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _CreateTrustConfig( @@ -1854,7 +2178,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.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 trust config method over HTTP. @@ -1864,8 +2188,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.operations_pb2.Operation: @@ -1878,6 +2204,7 @@ def __call__( http_options = ( _BaseCertificateManagerRestTransport._BaseCreateTrustConfig._get_http_options() ) + request, metadata = self._interceptor.pre_create_trust_config( request, metadata ) @@ -1894,6 +2221,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.certificatemanager_v1.CertificateManagerClient.CreateTrustConfig", + extra={ + "serviceName": "google.cloud.certificatemanager.v1.CertificateManager", + "rpcName": "CreateTrustConfig", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = CertificateManagerRestTransport._CreateTrustConfig._get_response( self._host, @@ -1913,7 +2267,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_trust_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.certificatemanager_v1.CertificateManagerClient.create_trust_config", + extra={ + "serviceName": "google.cloud.certificatemanager.v1.CertificateManager", + "rpcName": "CreateTrustConfig", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _DeleteCertificate( @@ -1951,7 +2327,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.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 certificate method over HTTP. @@ -1961,8 +2337,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.operations_pb2.Operation: @@ -1975,6 +2353,7 @@ def __call__( http_options = ( _BaseCertificateManagerRestTransport._BaseDeleteCertificate._get_http_options() ) + request, metadata = self._interceptor.pre_delete_certificate( request, metadata ) @@ -1987,6 +2366,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.certificatemanager_v1.CertificateManagerClient.DeleteCertificate", + extra={ + "serviceName": "google.cloud.certificatemanager.v1.CertificateManager", + "rpcName": "DeleteCertificate", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = CertificateManagerRestTransport._DeleteCertificate._get_response( self._host, @@ -2005,7 +2411,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_certificate(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = json_format.MessageToJson(resp) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.certificatemanager_v1.CertificateManagerClient.delete_certificate", + extra={ + "serviceName": "google.cloud.certificatemanager.v1.CertificateManager", + "rpcName": "DeleteCertificate", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _DeleteCertificateIssuanceConfig( @@ -2045,7 +2473,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.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 certificate issuance config method over HTTP. @@ -2057,8 +2485,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.operations_pb2.Operation: @@ -2071,6 +2501,7 @@ def __call__( http_options = ( _BaseCertificateManagerRestTransport._BaseDeleteCertificateIssuanceConfig._get_http_options() ) + ( request, metadata, @@ -2086,6 +2517,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.certificatemanager_v1.CertificateManagerClient.DeleteCertificateIssuanceConfig", + extra={ + "serviceName": "google.cloud.certificatemanager.v1.CertificateManager", + "rpcName": "DeleteCertificateIssuanceConfig", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = CertificateManagerRestTransport._DeleteCertificateIssuanceConfig._get_response( self._host, @@ -2104,7 +2562,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_certificate_issuance_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.certificatemanager_v1.CertificateManagerClient.delete_certificate_issuance_config", + extra={ + "serviceName": "google.cloud.certificatemanager.v1.CertificateManager", + "rpcName": "DeleteCertificateIssuanceConfig", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _DeleteCertificateMap( @@ -2142,7 +2622,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Call the delete certificate map method over HTTP. @@ -2152,8 +2632,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.operations_pb2.Operation: @@ -2166,6 +2648,7 @@ def __call__( http_options = ( _BaseCertificateManagerRestTransport._BaseDeleteCertificateMap._get_http_options() ) + request, metadata = self._interceptor.pre_delete_certificate_map( request, metadata ) @@ -2178,6 +2661,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.certificatemanager_v1.CertificateManagerClient.DeleteCertificateMap", + extra={ + "serviceName": "google.cloud.certificatemanager.v1.CertificateManager", + "rpcName": "DeleteCertificateMap", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ( CertificateManagerRestTransport._DeleteCertificateMap._get_response( @@ -2198,7 +2708,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_certificate_map(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = json_format.MessageToJson(resp) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.certificatemanager_v1.CertificateManagerClient.delete_certificate_map", + extra={ + "serviceName": "google.cloud.certificatemanager.v1.CertificateManager", + "rpcName": "DeleteCertificateMap", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _DeleteCertificateMapEntry( @@ -2236,7 +2768,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.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 certificate map entry method over HTTP. @@ -2247,8 +2779,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.operations_pb2.Operation: @@ -2261,6 +2795,7 @@ def __call__( http_options = ( _BaseCertificateManagerRestTransport._BaseDeleteCertificateMapEntry._get_http_options() ) + request, metadata = self._interceptor.pre_delete_certificate_map_entry( request, metadata ) @@ -2273,6 +2808,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.certificatemanager_v1.CertificateManagerClient.DeleteCertificateMapEntry", + extra={ + "serviceName": "google.cloud.certificatemanager.v1.CertificateManager", + "rpcName": "DeleteCertificateMapEntry", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = CertificateManagerRestTransport._DeleteCertificateMapEntry._get_response( self._host, @@ -2291,7 +2853,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_certificate_map_entry(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = json_format.MessageToJson(resp) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.certificatemanager_v1.CertificateManagerClient.delete_certificate_map_entry", + extra={ + "serviceName": "google.cloud.certificatemanager.v1.CertificateManager", + "rpcName": "DeleteCertificateMapEntry", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _DeleteDnsAuthorization( @@ -2329,7 +2913,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.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 dns authorization method over HTTP. @@ -2339,8 +2923,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.operations_pb2.Operation: @@ -2353,6 +2939,7 @@ def __call__( http_options = ( _BaseCertificateManagerRestTransport._BaseDeleteDnsAuthorization._get_http_options() ) + request, metadata = self._interceptor.pre_delete_dns_authorization( request, metadata ) @@ -2365,6 +2952,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.certificatemanager_v1.CertificateManagerClient.DeleteDnsAuthorization", + extra={ + "serviceName": "google.cloud.certificatemanager.v1.CertificateManager", + "rpcName": "DeleteDnsAuthorization", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ( CertificateManagerRestTransport._DeleteDnsAuthorization._get_response( @@ -2385,7 +2999,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_dns_authorization(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = json_format.MessageToJson(resp) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.certificatemanager_v1.CertificateManagerClient.delete_dns_authorization", + extra={ + "serviceName": "google.cloud.certificatemanager.v1.CertificateManager", + "rpcName": "DeleteDnsAuthorization", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _DeleteTrustConfig( @@ -2423,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]]] = (), ) -> operations_pb2.Operation: r"""Call the delete trust config method over HTTP. @@ -2433,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: ~.operations_pb2.Operation: @@ -2447,6 +3085,7 @@ def __call__( http_options = ( _BaseCertificateManagerRestTransport._BaseDeleteTrustConfig._get_http_options() ) + request, metadata = self._interceptor.pre_delete_trust_config( request, metadata ) @@ -2459,6 +3098,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.certificatemanager_v1.CertificateManagerClient.DeleteTrustConfig", + extra={ + "serviceName": "google.cloud.certificatemanager.v1.CertificateManager", + "rpcName": "DeleteTrustConfig", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = CertificateManagerRestTransport._DeleteTrustConfig._get_response( self._host, @@ -2477,7 +3143,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_trust_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.certificatemanager_v1.CertificateManagerClient.delete_trust_config", + extra={ + "serviceName": "google.cloud.certificatemanager.v1.CertificateManager", + "rpcName": "DeleteTrustConfig", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _GetCertificate( @@ -2515,7 +3203,7 @@ 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_manager.Certificate: r"""Call the get certificate method over HTTP. @@ -2525,8 +3213,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each 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_manager.Certificate: @@ -2536,6 +3226,7 @@ def __call__( http_options = ( _BaseCertificateManagerRestTransport._BaseGetCertificate._get_http_options() ) + request, metadata = self._interceptor.pre_get_certificate(request, metadata) transcoded_request = _BaseCertificateManagerRestTransport._BaseGetCertificate._get_transcoded_request( http_options, request @@ -2546,6 +3237,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.certificatemanager_v1.CertificateManagerClient.GetCertificate", + extra={ + "serviceName": "google.cloud.certificatemanager.v1.CertificateManager", + "rpcName": "GetCertificate", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = CertificateManagerRestTransport._GetCertificate._get_response( self._host, @@ -2566,7 +3284,29 @@ def __call__( pb_resp = certificate_manager.Certificate.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_certificate(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = certificate_manager.Certificate.to_json(response) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.certificatemanager_v1.CertificateManagerClient.get_certificate", + extra={ + "serviceName": "google.cloud.certificatemanager.v1.CertificateManager", + "rpcName": "GetCertificate", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _GetCertificateIssuanceConfig( @@ -2604,7 +3344,7 @@ 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_issuance_config.CertificateIssuanceConfig: r"""Call the get certificate issuance config method over HTTP. @@ -2615,8 +3355,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.certificate_issuance_config.CertificateIssuanceConfig: @@ -2628,6 +3370,7 @@ def __call__( http_options = ( _BaseCertificateManagerRestTransport._BaseGetCertificateIssuanceConfig._get_http_options() ) + request, metadata = self._interceptor.pre_get_certificate_issuance_config( request, metadata ) @@ -2640,6 +3383,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.certificatemanager_v1.CertificateManagerClient.GetCertificateIssuanceConfig", + extra={ + "serviceName": "google.cloud.certificatemanager.v1.CertificateManager", + "rpcName": "GetCertificateIssuanceConfig", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = CertificateManagerRestTransport._GetCertificateIssuanceConfig._get_response( self._host, @@ -2660,7 +3430,33 @@ def __call__( pb_resp = certificate_issuance_config.CertificateIssuanceConfig.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_certificate_issuance_config(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = ( + certificate_issuance_config.CertificateIssuanceConfig.to_json( + response + ) + ) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.certificatemanager_v1.CertificateManagerClient.get_certificate_issuance_config", + extra={ + "serviceName": "google.cloud.certificatemanager.v1.CertificateManager", + "rpcName": "GetCertificateIssuanceConfig", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _GetCertificateMap( @@ -2698,7 +3494,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> certificate_manager.CertificateMap: r"""Call the get certificate map method over HTTP. @@ -2708,8 +3504,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each 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_manager.CertificateMap: @@ -2721,6 +3519,7 @@ def __call__( http_options = ( _BaseCertificateManagerRestTransport._BaseGetCertificateMap._get_http_options() ) + request, metadata = self._interceptor.pre_get_certificate_map( request, metadata ) @@ -2733,6 +3532,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.certificatemanager_v1.CertificateManagerClient.GetCertificateMap", + extra={ + "serviceName": "google.cloud.certificatemanager.v1.CertificateManager", + "rpcName": "GetCertificateMap", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = CertificateManagerRestTransport._GetCertificateMap._get_response( self._host, @@ -2753,7 +3579,31 @@ def __call__( pb_resp = certificate_manager.CertificateMap.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_certificate_map(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = certificate_manager.CertificateMap.to_json( + response + ) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.certificatemanager_v1.CertificateManagerClient.get_certificate_map", + extra={ + "serviceName": "google.cloud.certificatemanager.v1.CertificateManager", + "rpcName": "GetCertificateMap", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _GetCertificateMapEntry( @@ -2791,7 +3641,7 @@ 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_manager.CertificateMapEntry: r"""Call the get certificate map entry method over HTTP. @@ -2801,8 +3651,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each 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_manager.CertificateMapEntry: @@ -2812,6 +3664,7 @@ def __call__( http_options = ( _BaseCertificateManagerRestTransport._BaseGetCertificateMapEntry._get_http_options() ) + request, metadata = self._interceptor.pre_get_certificate_map_entry( request, metadata ) @@ -2824,6 +3677,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.certificatemanager_v1.CertificateManagerClient.GetCertificateMapEntry", + extra={ + "serviceName": "google.cloud.certificatemanager.v1.CertificateManager", + "rpcName": "GetCertificateMapEntry", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ( CertificateManagerRestTransport._GetCertificateMapEntry._get_response( @@ -2846,7 +3726,31 @@ def __call__( pb_resp = certificate_manager.CertificateMapEntry.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_certificate_map_entry(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = certificate_manager.CertificateMapEntry.to_json( + response + ) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.certificatemanager_v1.CertificateManagerClient.get_certificate_map_entry", + extra={ + "serviceName": "google.cloud.certificatemanager.v1.CertificateManager", + "rpcName": "GetCertificateMapEntry", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _GetDnsAuthorization( @@ -2884,7 +3788,7 @@ 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_manager.DnsAuthorization: r"""Call the get dns authorization method over HTTP. @@ -2894,8 +3798,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each 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_manager.DnsAuthorization: @@ -2908,6 +3814,7 @@ def __call__( http_options = ( _BaseCertificateManagerRestTransport._BaseGetDnsAuthorization._get_http_options() ) + request, metadata = self._interceptor.pre_get_dns_authorization( request, metadata ) @@ -2920,6 +3827,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.certificatemanager_v1.CertificateManagerClient.GetDnsAuthorization", + extra={ + "serviceName": "google.cloud.certificatemanager.v1.CertificateManager", + "rpcName": "GetDnsAuthorization", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ( CertificateManagerRestTransport._GetDnsAuthorization._get_response( @@ -2942,7 +3876,31 @@ def __call__( pb_resp = certificate_manager.DnsAuthorization.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_dns_authorization(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = certificate_manager.DnsAuthorization.to_json( + response + ) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.certificatemanager_v1.CertificateManagerClient.get_dns_authorization", + extra={ + "serviceName": "google.cloud.certificatemanager.v1.CertificateManager", + "rpcName": "GetDnsAuthorization", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _GetTrustConfig( @@ -2980,7 +3938,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> trust_config.TrustConfig: r"""Call the get trust config method over HTTP. @@ -2990,8 +3948,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.trust_config.TrustConfig: @@ -3001,6 +3961,7 @@ def __call__( http_options = ( _BaseCertificateManagerRestTransport._BaseGetTrustConfig._get_http_options() ) + request, metadata = self._interceptor.pre_get_trust_config( request, metadata ) @@ -3013,6 +3974,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.certificatemanager_v1.CertificateManagerClient.GetTrustConfig", + extra={ + "serviceName": "google.cloud.certificatemanager.v1.CertificateManager", + "rpcName": "GetTrustConfig", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = CertificateManagerRestTransport._GetTrustConfig._get_response( self._host, @@ -3033,7 +4021,29 @@ def __call__( pb_resp = trust_config.TrustConfig.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_get_trust_config(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = trust_config.TrustConfig.to_json(response) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.certificatemanager_v1.CertificateManagerClient.get_trust_config", + extra={ + "serviceName": "google.cloud.certificatemanager.v1.CertificateManager", + "rpcName": "GetTrustConfig", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ListCertificateIssuanceConfigs( @@ -3073,7 +4083,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> certificate_issuance_config.ListCertificateIssuanceConfigsResponse: r"""Call the list certificate issuance configs method over HTTP. @@ -3085,8 +4095,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each 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_issuance_config.ListCertificateIssuanceConfigsResponse: @@ -3098,6 +4110,7 @@ def __call__( http_options = ( _BaseCertificateManagerRestTransport._BaseListCertificateIssuanceConfigs._get_http_options() ) + request, metadata = self._interceptor.pre_list_certificate_issuance_configs( request, metadata ) @@ -3110,6 +4123,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.certificatemanager_v1.CertificateManagerClient.ListCertificateIssuanceConfigs", + extra={ + "serviceName": "google.cloud.certificatemanager.v1.CertificateManager", + "rpcName": "ListCertificateIssuanceConfigs", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = CertificateManagerRestTransport._ListCertificateIssuanceConfigs._get_response( self._host, @@ -3134,7 +4174,31 @@ def __call__( ) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_certificate_issuance_configs(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = certificate_issuance_config.ListCertificateIssuanceConfigsResponse.to_json( + response + ) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.certificatemanager_v1.CertificateManagerClient.list_certificate_issuance_configs", + extra={ + "serviceName": "google.cloud.certificatemanager.v1.CertificateManager", + "rpcName": "ListCertificateIssuanceConfigs", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ListCertificateMapEntries( @@ -3172,7 +4236,7 @@ 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_manager.ListCertificateMapEntriesResponse: r"""Call the list certificate map entries method over HTTP. @@ -3183,8 +4247,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each 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_manager.ListCertificateMapEntriesResponse: @@ -3194,6 +4260,7 @@ def __call__( http_options = ( _BaseCertificateManagerRestTransport._BaseListCertificateMapEntries._get_http_options() ) + request, metadata = self._interceptor.pre_list_certificate_map_entries( request, metadata ) @@ -3206,6 +4273,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.certificatemanager_v1.CertificateManagerClient.ListCertificateMapEntries", + extra={ + "serviceName": "google.cloud.certificatemanager.v1.CertificateManager", + "rpcName": "ListCertificateMapEntries", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = CertificateManagerRestTransport._ListCertificateMapEntries._get_response( self._host, @@ -3226,7 +4320,33 @@ def __call__( pb_resp = certificate_manager.ListCertificateMapEntriesResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_certificate_map_entries(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = ( + certificate_manager.ListCertificateMapEntriesResponse.to_json( + response + ) + ) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.certificatemanager_v1.CertificateManagerClient.list_certificate_map_entries", + extra={ + "serviceName": "google.cloud.certificatemanager.v1.CertificateManager", + "rpcName": "ListCertificateMapEntries", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ListCertificateMaps( @@ -3264,7 +4384,7 @@ 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_manager.ListCertificateMapsResponse: r"""Call the list certificate maps method over HTTP. @@ -3274,8 +4394,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each 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_manager.ListCertificateMapsResponse: @@ -3285,6 +4407,7 @@ def __call__( http_options = ( _BaseCertificateManagerRestTransport._BaseListCertificateMaps._get_http_options() ) + request, metadata = self._interceptor.pre_list_certificate_maps( request, metadata ) @@ -3297,6 +4420,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.certificatemanager_v1.CertificateManagerClient.ListCertificateMaps", + extra={ + "serviceName": "google.cloud.certificatemanager.v1.CertificateManager", + "rpcName": "ListCertificateMaps", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ( CertificateManagerRestTransport._ListCertificateMaps._get_response( @@ -3319,7 +4469,33 @@ def __call__( pb_resp = certificate_manager.ListCertificateMapsResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_certificate_maps(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = ( + certificate_manager.ListCertificateMapsResponse.to_json( + response + ) + ) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.certificatemanager_v1.CertificateManagerClient.list_certificate_maps", + extra={ + "serviceName": "google.cloud.certificatemanager.v1.CertificateManager", + "rpcName": "ListCertificateMaps", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ListCertificates( @@ -3357,7 +4533,7 @@ 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_manager.ListCertificatesResponse: r"""Call the list certificates method over HTTP. @@ -3367,8 +4543,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each 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_manager.ListCertificatesResponse: @@ -3378,6 +4556,7 @@ def __call__( http_options = ( _BaseCertificateManagerRestTransport._BaseListCertificates._get_http_options() ) + request, metadata = self._interceptor.pre_list_certificates( request, metadata ) @@ -3390,6 +4569,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.certificatemanager_v1.CertificateManagerClient.ListCertificates", + extra={ + "serviceName": "google.cloud.certificatemanager.v1.CertificateManager", + "rpcName": "ListCertificates", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = CertificateManagerRestTransport._ListCertificates._get_response( self._host, @@ -3410,7 +4616,31 @@ def __call__( pb_resp = certificate_manager.ListCertificatesResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_certificates(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = ( + certificate_manager.ListCertificatesResponse.to_json(response) + ) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.certificatemanager_v1.CertificateManagerClient.list_certificates", + extra={ + "serviceName": "google.cloud.certificatemanager.v1.CertificateManager", + "rpcName": "ListCertificates", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ListDnsAuthorizations( @@ -3448,7 +4678,7 @@ 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_manager.ListDnsAuthorizationsResponse: r"""Call the list dns authorizations method over HTTP. @@ -3458,8 +4688,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each 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_manager.ListDnsAuthorizationsResponse: @@ -3469,6 +4701,7 @@ def __call__( http_options = ( _BaseCertificateManagerRestTransport._BaseListDnsAuthorizations._get_http_options() ) + request, metadata = self._interceptor.pre_list_dns_authorizations( request, metadata ) @@ -3481,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.cloud.certificatemanager_v1.CertificateManagerClient.ListDnsAuthorizations", + extra={ + "serviceName": "google.cloud.certificatemanager.v1.CertificateManager", + "rpcName": "ListDnsAuthorizations", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ( CertificateManagerRestTransport._ListDnsAuthorizations._get_response( @@ -3503,7 +4763,33 @@ def __call__( pb_resp = certificate_manager.ListDnsAuthorizationsResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_dns_authorizations(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = ( + certificate_manager.ListDnsAuthorizationsResponse.to_json( + response + ) + ) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.certificatemanager_v1.CertificateManagerClient.list_dns_authorizations", + extra={ + "serviceName": "google.cloud.certificatemanager.v1.CertificateManager", + "rpcName": "ListDnsAuthorizations", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _ListTrustConfigs( @@ -3541,7 +4827,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> trust_config.ListTrustConfigsResponse: r"""Call the list trust configs method over HTTP. @@ -3551,8 +4837,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.trust_config.ListTrustConfigsResponse: @@ -3562,6 +4850,7 @@ def __call__( http_options = ( _BaseCertificateManagerRestTransport._BaseListTrustConfigs._get_http_options() ) + request, metadata = self._interceptor.pre_list_trust_configs( request, metadata ) @@ -3574,6 +4863,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = type(request).to_json(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.certificatemanager_v1.CertificateManagerClient.ListTrustConfigs", + extra={ + "serviceName": "google.cloud.certificatemanager.v1.CertificateManager", + "rpcName": "ListTrustConfigs", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = CertificateManagerRestTransport._ListTrustConfigs._get_response( self._host, @@ -3594,7 +4910,31 @@ def __call__( pb_resp = trust_config.ListTrustConfigsResponse.pb(resp) json_format.Parse(response.content, pb_resp, ignore_unknown_fields=True) + resp = self._interceptor.post_list_trust_configs(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = trust_config.ListTrustConfigsResponse.to_json( + response + ) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.certificatemanager_v1.CertificateManagerClient.list_trust_configs", + extra={ + "serviceName": "google.cloud.certificatemanager.v1.CertificateManager", + "rpcName": "ListTrustConfigs", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _UpdateCertificate( @@ -3633,7 +4973,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.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 certificate method over HTTP. @@ -3643,8 +4983,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.operations_pb2.Operation: @@ -3657,6 +4999,7 @@ def __call__( http_options = ( _BaseCertificateManagerRestTransport._BaseUpdateCertificate._get_http_options() ) + request, metadata = self._interceptor.pre_update_certificate( request, metadata ) @@ -3673,6 +5016,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.certificatemanager_v1.CertificateManagerClient.UpdateCertificate", + extra={ + "serviceName": "google.cloud.certificatemanager.v1.CertificateManager", + "rpcName": "UpdateCertificate", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = CertificateManagerRestTransport._UpdateCertificate._get_response( self._host, @@ -3692,7 +5062,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_certificate(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = json_format.MessageToJson(resp) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.certificatemanager_v1.CertificateManagerClient.update_certificate", + extra={ + "serviceName": "google.cloud.certificatemanager.v1.CertificateManager", + "rpcName": "UpdateCertificate", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _UpdateCertificateMap( @@ -3731,7 +5123,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.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 certificate map method over HTTP. @@ -3741,8 +5133,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.operations_pb2.Operation: @@ -3755,6 +5149,7 @@ def __call__( http_options = ( _BaseCertificateManagerRestTransport._BaseUpdateCertificateMap._get_http_options() ) + request, metadata = self._interceptor.pre_update_certificate_map( request, metadata ) @@ -3771,6 +5166,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.certificatemanager_v1.CertificateManagerClient.UpdateCertificateMap", + extra={ + "serviceName": "google.cloud.certificatemanager.v1.CertificateManager", + "rpcName": "UpdateCertificateMap", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ( CertificateManagerRestTransport._UpdateCertificateMap._get_response( @@ -3792,7 +5214,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_certificate_map(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = json_format.MessageToJson(resp) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.certificatemanager_v1.CertificateManagerClient.update_certificate_map", + extra={ + "serviceName": "google.cloud.certificatemanager.v1.CertificateManager", + "rpcName": "UpdateCertificateMap", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _UpdateCertificateMapEntry( @@ -3831,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 update certificate map entry method over HTTP. @@ -3842,8 +5286,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be 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 +5302,7 @@ def __call__( http_options = ( _BaseCertificateManagerRestTransport._BaseUpdateCertificateMapEntry._get_http_options() ) + request, metadata = self._interceptor.pre_update_certificate_map_entry( request, metadata ) @@ -3872,6 +5319,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.certificatemanager_v1.CertificateManagerClient.UpdateCertificateMapEntry", + extra={ + "serviceName": "google.cloud.certificatemanager.v1.CertificateManager", + "rpcName": "UpdateCertificateMapEntry", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = CertificateManagerRestTransport._UpdateCertificateMapEntry._get_response( self._host, @@ -3891,7 +5365,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_certificate_map_entry(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = json_format.MessageToJson(resp) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.certificatemanager_v1.CertificateManagerClient.update_certificate_map_entry", + extra={ + "serviceName": "google.cloud.certificatemanager.v1.CertificateManager", + "rpcName": "UpdateCertificateMapEntry", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _UpdateDnsAuthorization( @@ -3930,7 +5426,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Call the update dns authorization method over HTTP. @@ -3940,8 +5436,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.operations_pb2.Operation: @@ -3954,6 +5452,7 @@ def __call__( http_options = ( _BaseCertificateManagerRestTransport._BaseUpdateDnsAuthorization._get_http_options() ) + request, metadata = self._interceptor.pre_update_dns_authorization( request, metadata ) @@ -3970,6 +5469,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.certificatemanager_v1.CertificateManagerClient.UpdateDnsAuthorization", + extra={ + "serviceName": "google.cloud.certificatemanager.v1.CertificateManager", + "rpcName": "UpdateDnsAuthorization", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = ( CertificateManagerRestTransport._UpdateDnsAuthorization._get_response( @@ -3991,7 +5517,29 @@ def __call__( # Return the response resp = operations_pb2.Operation() json_format.Parse(response.content, resp, ignore_unknown_fields=True) + resp = self._interceptor.post_update_dns_authorization(resp) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + try: + response_payload = json_format.MessageToJson(resp) + except: + response_payload = None + http_response = { + "payload": response_payload, + "headers": dict(response.headers), + "status": response.status_code, + } + _LOGGER.debug( + "Received response for google.cloud.certificatemanager_v1.CertificateManagerClient.update_dns_authorization", + extra={ + "serviceName": "google.cloud.certificatemanager.v1.CertificateManager", + "rpcName": "UpdateDnsAuthorization", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp class _UpdateTrustConfig( @@ -4030,7 +5578,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.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 trust config method over HTTP. @@ -4040,8 +5588,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: ~.operations_pb2.Operation: @@ -4054,6 +5604,7 @@ def __call__( http_options = ( _BaseCertificateManagerRestTransport._BaseUpdateTrustConfig._get_http_options() ) + request, metadata = self._interceptor.pre_update_trust_config( request, metadata ) @@ -4070,6 +5621,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.certificatemanager_v1.CertificateManagerClient.UpdateTrustConfig", + extra={ + "serviceName": "google.cloud.certificatemanager.v1.CertificateManager", + "rpcName": "UpdateTrustConfig", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = CertificateManagerRestTransport._UpdateTrustConfig._get_response( self._host, @@ -4089,7 +5667,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_trust_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.certificatemanager_v1.CertificateManagerClient.update_trust_config", + extra={ + "serviceName": "google.cloud.certificatemanager.v1.CertificateManager", + "rpcName": "UpdateTrustConfig", + "metadata": http_response["headers"], + "httpResponse": http_response, + }, + ) return resp @property @@ -4428,7 +6028,7 @@ 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. @@ -4438,8 +6038,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each 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. @@ -4448,6 +6050,7 @@ def __call__( http_options = ( _BaseCertificateManagerRestTransport._BaseGetLocation._get_http_options() ) + request, metadata = self._interceptor.pre_get_location(request, metadata) transcoded_request = _BaseCertificateManagerRestTransport._BaseGetLocation._get_transcoded_request( http_options, request @@ -4458,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.certificatemanager_v1.CertificateManagerClient.GetLocation", + extra={ + "serviceName": "google.cloud.certificatemanager.v1.CertificateManager", + "rpcName": "GetLocation", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = CertificateManagerRestTransport._GetLocation._get_response( self._host, @@ -4477,6 +6107,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.certificatemanager_v1.CertificateManagerAsyncClient.GetLocation", + extra={ + "serviceName": "google.cloud.certificatemanager.v1.CertificateManager", + "rpcName": "GetLocation", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property @@ -4518,7 +6169,7 @@ 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. @@ -4528,8 +6179,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each 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. @@ -4538,6 +6191,7 @@ def __call__( http_options = ( _BaseCertificateManagerRestTransport._BaseListLocations._get_http_options() ) + request, metadata = self._interceptor.pre_list_locations(request, metadata) transcoded_request = _BaseCertificateManagerRestTransport._BaseListLocations._get_transcoded_request( http_options, request @@ -4548,6 +6202,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.certificatemanager_v1.CertificateManagerClient.ListLocations", + extra={ + "serviceName": "google.cloud.certificatemanager.v1.CertificateManager", + "rpcName": "ListLocations", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = CertificateManagerRestTransport._ListLocations._get_response( self._host, @@ -4567,6 +6248,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.certificatemanager_v1.CertificateManagerAsyncClient.ListLocations", + extra={ + "serviceName": "google.cloud.certificatemanager.v1.CertificateManager", + "rpcName": "ListLocations", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property @@ -4609,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]]] = (), ) -> None: r"""Call the cancel operation method over HTTP. @@ -4619,13 +6321,16 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. """ http_options = ( _BaseCertificateManagerRestTransport._BaseCancelOperation._get_http_options() ) + request, metadata = self._interceptor.pre_cancel_operation( request, metadata ) @@ -4642,6 +6347,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.certificatemanager_v1.CertificateManagerClient.CancelOperation", + extra={ + "serviceName": "google.cloud.certificatemanager.v1.CertificateManager", + "rpcName": "CancelOperation", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = CertificateManagerRestTransport._CancelOperation._get_response( self._host, @@ -4699,7 +6431,7 @@ 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. @@ -4709,13 +6441,16 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. """ http_options = ( _BaseCertificateManagerRestTransport._BaseDeleteOperation._get_http_options() ) + request, metadata = self._interceptor.pre_delete_operation( request, metadata ) @@ -4728,6 +6463,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.certificatemanager_v1.CertificateManagerClient.DeleteOperation", + extra={ + "serviceName": "google.cloud.certificatemanager.v1.CertificateManager", + "rpcName": "DeleteOperation", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = CertificateManagerRestTransport._DeleteOperation._get_response( self._host, @@ -4784,7 +6546,7 @@ def __call__( *, retry: OptionalRetry = gapic_v1.method.DEFAULT, timeout: Optional[float] = None, - metadata: Sequence[Tuple[str, str]] = (), + metadata: Sequence[Tuple[str, Union[str, bytes]]] = (), ) -> operations_pb2.Operation: r"""Call the get operation method over HTTP. @@ -4794,8 +6556,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of type `str`, + but for metadata keys ending with the suffix `-bin`, the corresponding values must + be of type `bytes`. Returns: operations_pb2.Operation: Response from GetOperation method. @@ -4804,6 +6568,7 @@ def __call__( http_options = ( _BaseCertificateManagerRestTransport._BaseGetOperation._get_http_options() ) + request, metadata = self._interceptor.pre_get_operation(request, metadata) transcoded_request = _BaseCertificateManagerRestTransport._BaseGetOperation._get_transcoded_request( http_options, request @@ -4814,6 +6579,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.certificatemanager_v1.CertificateManagerClient.GetOperation", + extra={ + "serviceName": "google.cloud.certificatemanager.v1.CertificateManager", + "rpcName": "GetOperation", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = CertificateManagerRestTransport._GetOperation._get_response( self._host, @@ -4833,6 +6625,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.certificatemanager_v1.CertificateManagerAsyncClient.GetOperation", + extra={ + "serviceName": "google.cloud.certificatemanager.v1.CertificateManager", + "rpcName": "GetOperation", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property @@ -4874,7 +6687,7 @@ def __call__( *, 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 +6697,10 @@ def __call__( retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. - metadata (Sequence[Tuple[str, str]]): Strings which should be - sent along with the request as metadata. + metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be + sent along with the request as metadata. Normally, each value must be of 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 +6709,7 @@ def __call__( http_options = ( _BaseCertificateManagerRestTransport._BaseListOperations._get_http_options() ) + request, metadata = self._interceptor.pre_list_operations(request, metadata) transcoded_request = _BaseCertificateManagerRestTransport._BaseListOperations._get_transcoded_request( http_options, request @@ -4904,6 +6720,33 @@ def __call__( transcoded_request ) + if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor( + logging.DEBUG + ): # pragma: NO COVER + request_url = "{host}{uri}".format( + host=self._host, uri=transcoded_request["uri"] + ) + method = transcoded_request["method"] + try: + request_payload = json_format.MessageToJson(request) + except: + request_payload = None + http_request = { + "payload": request_payload, + "requestMethod": method, + "requestUrl": request_url, + "headers": dict(metadata), + } + _LOGGER.debug( + f"Sending request for google.cloud.certificatemanager_v1.CertificateManagerClient.ListOperations", + extra={ + "serviceName": "google.cloud.certificatemanager.v1.CertificateManager", + "rpcName": "ListOperations", + "httpRequest": http_request, + "metadata": http_request["headers"], + }, + ) + # Send the request response = CertificateManagerRestTransport._ListOperations._get_response( self._host, @@ -4923,6 +6766,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.certificatemanager_v1.CertificateManagerAsyncClient.ListOperations", + extra={ + "serviceName": "google.cloud.certificatemanager.v1.CertificateManager", + "rpcName": "ListOperations", + "httpResponse": http_response, + "metadata": http_response["headers"], + }, + ) return resp @property diff --git a/packages/google-cloud-certificate-manager/samples/generated_samples/snippet_metadata_google.cloud.certificatemanager.v1.json b/packages/google-cloud-certificate-manager/samples/generated_samples/snippet_metadata_google.cloud.certificatemanager.v1.json index 913377237d4f..294c1f4aa1e6 100644 --- a/packages/google-cloud-certificate-manager/samples/generated_samples/snippet_metadata_google.cloud.certificatemanager.v1.json +++ b/packages/google-cloud-certificate-manager/samples/generated_samples/snippet_metadata_google.cloud.certificatemanager.v1.json @@ -8,7 +8,7 @@ ], "language": "PYTHON", "name": "google-cloud-certificate-manager", - "version": "1.8.1" + "version": "0.1.0" }, "snippets": [ { @@ -55,7 +55,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -143,7 +143,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -232,7 +232,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -320,7 +320,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -409,7 +409,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -497,7 +497,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -586,7 +586,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -674,7 +674,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -763,7 +763,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -851,7 +851,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -940,7 +940,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -1028,7 +1028,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -1109,7 +1109,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -1189,7 +1189,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -1270,7 +1270,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -1350,7 +1350,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -1431,7 +1431,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -1511,7 +1511,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -1592,7 +1592,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -1672,7 +1672,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -1753,7 +1753,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -1833,7 +1833,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -1914,7 +1914,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -1994,7 +1994,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -2075,7 +2075,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.certificate_manager_v1.types.CertificateIssuanceConfig", @@ -2155,7 +2155,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.certificate_manager_v1.types.CertificateIssuanceConfig", @@ -2236,7 +2236,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.certificate_manager_v1.types.CertificateMapEntry", @@ -2316,7 +2316,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.certificate_manager_v1.types.CertificateMapEntry", @@ -2397,7 +2397,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.certificate_manager_v1.types.CertificateMap", @@ -2477,7 +2477,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.certificate_manager_v1.types.CertificateMap", @@ -2558,7 +2558,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.certificate_manager_v1.types.Certificate", @@ -2638,7 +2638,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.certificate_manager_v1.types.Certificate", @@ -2719,7 +2719,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.certificate_manager_v1.types.DnsAuthorization", @@ -2799,7 +2799,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.certificate_manager_v1.types.DnsAuthorization", @@ -2880,7 +2880,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.certificate_manager_v1.types.TrustConfig", @@ -2960,7 +2960,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.certificate_manager_v1.types.TrustConfig", @@ -3041,7 +3041,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.certificate_manager_v1.services.certificate_manager.pagers.ListCertificateIssuanceConfigsAsyncPager", @@ -3121,7 +3121,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.certificate_manager_v1.services.certificate_manager.pagers.ListCertificateIssuanceConfigsPager", @@ -3202,7 +3202,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.certificate_manager_v1.services.certificate_manager.pagers.ListCertificateMapEntriesAsyncPager", @@ -3282,7 +3282,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.certificate_manager_v1.services.certificate_manager.pagers.ListCertificateMapEntriesPager", @@ -3363,7 +3363,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.certificate_manager_v1.services.certificate_manager.pagers.ListCertificateMapsAsyncPager", @@ -3443,7 +3443,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.certificate_manager_v1.services.certificate_manager.pagers.ListCertificateMapsPager", @@ -3524,7 +3524,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.certificate_manager_v1.services.certificate_manager.pagers.ListCertificatesAsyncPager", @@ -3604,7 +3604,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.certificate_manager_v1.services.certificate_manager.pagers.ListCertificatesPager", @@ -3685,7 +3685,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.certificate_manager_v1.services.certificate_manager.pagers.ListDnsAuthorizationsAsyncPager", @@ -3765,7 +3765,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.certificate_manager_v1.services.certificate_manager.pagers.ListDnsAuthorizationsPager", @@ -3846,7 +3846,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.certificate_manager_v1.services.certificate_manager.pagers.ListTrustConfigsAsyncPager", @@ -3926,7 +3926,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.cloud.certificate_manager_v1.services.certificate_manager.pagers.ListTrustConfigsPager", @@ -4011,7 +4011,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -4095,7 +4095,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -4180,7 +4180,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -4264,7 +4264,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -4349,7 +4349,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -4433,7 +4433,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -4518,7 +4518,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -4602,7 +4602,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation.Operation", @@ -4687,7 +4687,7 @@ }, { "name": "metadata", - "type": "Sequence[Tuple[str, str]" + "type": "Sequence[Tuple[str, Union[str, bytes]]]" } ], "resultType": "google.api_core.operation_async.AsyncOperation", @@ -4771,7 +4771,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-certificate-manager/tests/unit/gapic/certificate_manager_v1/test_certificate_manager.py b/packages/google-cloud-certificate-manager/tests/unit/gapic/certificate_manager_v1/test_certificate_manager.py index c674b586a135..15cfd1ac8f70 100644 --- a/packages/google-cloud-certificate-manager/tests/unit/gapic/certificate_manager_v1/test_certificate_manager.py +++ b/packages/google-cloud-certificate-manager/tests/unit/gapic/certificate_manager_v1/test_certificate_manager.py @@ -12772,6 +12772,7 @@ def test_list_certificates_rest_required_fields( response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.list_certificates(request) @@ -12827,6 +12828,7 @@ def test_list_certificates_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.list_certificates(**mock_args) @@ -13021,6 +13023,7 @@ def test_get_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.get_certificate(request) @@ -13068,6 +13071,7 @@ def test_get_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.get_certificate(**mock_args) @@ -13214,6 +13218,7 @@ def test_create_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.create_certificate(request) @@ -13274,6 +13279,7 @@ def test_create_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.create_certificate(**mock_args) @@ -13410,6 +13416,7 @@ def test_update_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.update_certificate(request) @@ -13466,6 +13473,7 @@ def test_update_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.update_certificate(**mock_args) @@ -13603,6 +13611,7 @@ def test_delete_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.delete_certificate(request) @@ -13648,6 +13657,7 @@ def test_delete_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.delete_certificate(**mock_args) @@ -13795,6 +13805,7 @@ def test_list_certificate_maps_rest_required_fields( response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.list_certificate_maps(request) @@ -13850,6 +13861,7 @@ def test_list_certificate_maps_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.list_certificate_maps(**mock_args) @@ -14048,6 +14060,7 @@ def test_get_certificate_map_rest_required_fields( response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.get_certificate_map(request) @@ -14095,6 +14108,7 @@ def test_get_certificate_map_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.get_certificate_map(**mock_args) @@ -14242,6 +14256,7 @@ def test_create_certificate_map_rest_required_fields( response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.create_certificate_map(request) @@ -14302,6 +14317,7 @@ def test_create_certificate_map_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.create_certificate_map(**mock_args) @@ -14439,6 +14455,7 @@ def test_update_certificate_map_rest_required_fields( response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.update_certificate_map(request) @@ -14495,6 +14512,7 @@ def test_update_certificate_map_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.update_certificate_map(**mock_args) @@ -14633,6 +14651,7 @@ def test_delete_certificate_map_rest_required_fields( response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.delete_certificate_map(request) @@ -14678,6 +14697,7 @@ def test_delete_certificate_map_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.delete_certificate_map(**mock_args) @@ -14825,6 +14845,7 @@ def test_list_certificate_map_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_certificate_map_entries(request) @@ -14884,6 +14905,7 @@ def test_list_certificate_map_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_certificate_map_entries(**mock_args) @@ -15088,6 +15110,7 @@ def test_get_certificate_map_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_certificate_map_entry(request) @@ -15135,6 +15158,7 @@ def test_get_certificate_map_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_certificate_map_entry(**mock_args) @@ -15287,6 +15311,7 @@ def test_create_certificate_map_entry_rest_required_fields( response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.create_certificate_map_entry(request) @@ -15351,6 +15376,7 @@ def test_create_certificate_map_entry_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.create_certificate_map_entry(**mock_args) @@ -15490,6 +15516,7 @@ def test_update_certificate_map_entry_rest_required_fields( response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.update_certificate_map_entry(request) @@ -15548,6 +15575,7 @@ def test_update_certificate_map_entry_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.update_certificate_map_entry(**mock_args) @@ -15688,6 +15716,7 @@ def test_delete_certificate_map_entry_rest_required_fields( response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.delete_certificate_map_entry(request) @@ -15733,6 +15762,7 @@ def test_delete_certificate_map_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.delete_certificate_map_entry(**mock_args) @@ -15880,6 +15910,7 @@ def test_list_dns_authorizations_rest_required_fields( response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.list_dns_authorizations(request) @@ -15937,6 +15968,7 @@ def test_list_dns_authorizations_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.list_dns_authorizations(**mock_args) @@ -16137,6 +16169,7 @@ def test_get_dns_authorization_rest_required_fields( response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.get_dns_authorization(request) @@ -16184,6 +16217,7 @@ def test_get_dns_authorization_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.get_dns_authorization(**mock_args) @@ -16333,6 +16367,7 @@ def test_create_dns_authorization_rest_required_fields( response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.create_dns_authorization(request) @@ -16393,6 +16428,7 @@ def test_create_dns_authorization_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.create_dns_authorization(**mock_args) @@ -16530,6 +16566,7 @@ def test_update_dns_authorization_rest_required_fields( response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.update_dns_authorization(request) @@ -16586,6 +16623,7 @@ def test_update_dns_authorization_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.update_dns_authorization(**mock_args) @@ -16724,6 +16762,7 @@ def test_delete_dns_authorization_rest_required_fields( response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.delete_dns_authorization(request) @@ -16769,6 +16808,7 @@ def test_delete_dns_authorization_rest_flattened(): json_return_value = json_format.MessageToJson(return_value) response_value._content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.delete_dns_authorization(**mock_args) @@ -16918,6 +16958,7 @@ def test_list_certificate_issuance_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_certificate_issuance_configs(request) @@ -16981,6 +17022,7 @@ def test_list_certificate_issuance_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_certificate_issuance_configs(**mock_args) @@ -17192,6 +17234,7 @@ def test_get_certificate_issuance_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_certificate_issuance_config(request) @@ -17243,6 +17286,7 @@ def test_get_certificate_issuance_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_certificate_issuance_config(**mock_args) @@ -17398,6 +17442,7 @@ def test_create_certificate_issuance_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_certificate_issuance_config(request) @@ -17462,6 +17507,7 @@ def test_create_certificate_issuance_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_certificate_issuance_config(**mock_args) @@ -17605,6 +17651,7 @@ def test_delete_certificate_issuance_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_certificate_issuance_config(request) @@ -17652,6 +17699,7 @@ def test_delete_certificate_issuance_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_certificate_issuance_config(**mock_args) @@ -17798,6 +17846,7 @@ def test_list_trust_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_trust_configs(request) @@ -17853,6 +17902,7 @@ def test_list_trust_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_trust_configs(**mock_args) @@ -18049,6 +18099,7 @@ def test_get_trust_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_trust_config(request) @@ -18096,6 +18147,7 @@ def test_get_trust_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_trust_config(**mock_args) @@ -18242,6 +18294,7 @@ def test_create_trust_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_trust_config(request) @@ -18302,6 +18355,7 @@ def test_create_trust_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_trust_config(**mock_args) @@ -18438,6 +18492,7 @@ def test_update_trust_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_trust_config(request) @@ -18494,6 +18549,7 @@ def test_update_trust_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_trust_config(**mock_args) @@ -18633,6 +18689,7 @@ def test_delete_trust_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_trust_config(request) @@ -18678,6 +18735,7 @@ def test_delete_trust_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_trust_config(**mock_args) @@ -20357,6 +20415,7 @@ def test_list_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_certificates(request) @@ -20393,6 +20452,7 @@ def test_list_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_certificates(request) # Establish that the response is the type that we expect. @@ -20434,6 +20494,7 @@ def test_list_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 = certificate_manager.ListCertificatesResponse.to_json( certificate_manager.ListCertificatesResponse() ) @@ -20480,6 +20541,7 @@ def test_get_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_certificate(request) @@ -20519,6 +20581,7 @@ def test_get_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_certificate(request) # Establish that the response is the type that we expect. @@ -20563,6 +20626,7 @@ def test_get_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_manager.Certificate.to_json( certificate_manager.Certificate() ) @@ -20609,6 +20673,7 @@ def test_create_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_certificate(request) @@ -20739,6 +20804,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.create_certificate(request) # Establish that the response is the type that we expect. @@ -20780,6 +20846,7 @@ def test_create_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 = json_format.MessageToJson(operations_pb2.Operation()) req.return_value.content = return_value @@ -20828,6 +20895,7 @@ def test_update_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_certificate(request) @@ -20962,6 +21030,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.update_certificate(request) # Establish that the response is the type that we expect. @@ -21003,6 +21072,7 @@ def test_update_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 = json_format.MessageToJson(operations_pb2.Operation()) req.return_value.content = return_value @@ -21047,6 +21117,7 @@ def test_delete_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_certificate(request) @@ -21077,6 +21148,7 @@ def test_delete_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.delete_certificate(request) # Establish that the response is the type that we expect. @@ -21118,6 +21190,7 @@ def test_delete_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 = json_format.MessageToJson(operations_pb2.Operation()) req.return_value.content = return_value @@ -21162,6 +21235,7 @@ def test_list_certificate_maps_rest_bad_request( response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.list_certificate_maps(request) @@ -21198,6 +21272,7 @@ def test_list_certificate_maps_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.list_certificate_maps(request) # Establish that the response is the type that we expect. @@ -21239,6 +21314,7 @@ def test_list_certificate_maps_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = certificate_manager.ListCertificateMapsResponse.to_json( certificate_manager.ListCertificateMapsResponse() ) @@ -21287,6 +21363,7 @@ def test_get_certificate_map_rest_bad_request( response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.get_certificate_map(request) @@ -21325,6 +21402,7 @@ def test_get_certificate_map_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.get_certificate_map(request) # Establish that the response is the type that we expect. @@ -21366,6 +21444,7 @@ def test_get_certificate_map_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = certificate_manager.CertificateMap.to_json( certificate_manager.CertificateMap() ) @@ -21412,6 +21491,7 @@ def test_create_certificate_map_rest_bad_request( response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.create_certificate_map(request) @@ -21525,6 +21605,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.create_certificate_map(request) # Establish that the response is the type that we expect. @@ -21566,6 +21647,7 @@ def test_create_certificate_map_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = json_format.MessageToJson(operations_pb2.Operation()) req.return_value.content = return_value @@ -21614,6 +21696,7 @@ def test_update_certificate_map_rest_bad_request( response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.update_certificate_map(request) @@ -21731,6 +21814,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.update_certificate_map(request) # Establish that the response is the type that we expect. @@ -21772,6 +21856,7 @@ def test_update_certificate_map_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = json_format.MessageToJson(operations_pb2.Operation()) req.return_value.content = return_value @@ -21818,6 +21903,7 @@ def test_delete_certificate_map_rest_bad_request( response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.delete_certificate_map(request) @@ -21850,6 +21936,7 @@ def test_delete_certificate_map_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.delete_certificate_map(request) # Establish that the response is the type that we expect. @@ -21891,6 +21978,7 @@ def test_delete_certificate_map_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = json_format.MessageToJson(operations_pb2.Operation()) req.return_value.content = return_value @@ -21937,6 +22025,7 @@ def test_list_certificate_map_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_certificate_map_entries(request) @@ -21977,6 +22066,7 @@ def test_list_certificate_map_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_certificate_map_entries(request) # Establish that the response is the type that we expect. @@ -22019,6 +22109,7 @@ def test_list_certificate_map_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 = certificate_manager.ListCertificateMapEntriesResponse.to_json( certificate_manager.ListCertificateMapEntriesResponse() ) @@ -22067,6 +22158,7 @@ def test_get_certificate_map_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_certificate_map_entry(request) @@ -22108,6 +22200,7 @@ def test_get_certificate_map_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_certificate_map_entry(request) # Establish that the response is the type that we expect. @@ -22151,6 +22244,7 @@ def test_get_certificate_map_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 = certificate_manager.CertificateMapEntry.to_json( certificate_manager.CertificateMapEntry() ) @@ -22199,6 +22293,7 @@ def test_create_certificate_map_entry_rest_bad_request( response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.create_certificate_map_entry(request) @@ -22313,6 +22408,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.create_certificate_map_entry(request) # Establish that the response is the type that we expect. @@ -22355,6 +22451,7 @@ def test_create_certificate_map_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 = json_format.MessageToJson(operations_pb2.Operation()) req.return_value.content = return_value @@ -22403,6 +22500,7 @@ def test_update_certificate_map_entry_rest_bad_request( response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.update_certificate_map_entry(request) @@ -22519,6 +22617,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.update_certificate_map_entry(request) # Establish that the response is the type that we expect. @@ -22561,6 +22660,7 @@ def test_update_certificate_map_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 = json_format.MessageToJson(operations_pb2.Operation()) req.return_value.content = return_value @@ -22607,6 +22707,7 @@ def test_delete_certificate_map_entry_rest_bad_request( response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.delete_certificate_map_entry(request) @@ -22639,6 +22740,7 @@ def test_delete_certificate_map_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.delete_certificate_map_entry(request) # Establish that the response is the type that we expect. @@ -22681,6 +22783,7 @@ def test_delete_certificate_map_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 = json_format.MessageToJson(operations_pb2.Operation()) req.return_value.content = return_value @@ -22725,6 +22828,7 @@ def test_list_dns_authorizations_rest_bad_request( response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.list_dns_authorizations(request) @@ -22763,6 +22867,7 @@ def test_list_dns_authorizations_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.list_dns_authorizations(request) # Establish that the response is the type that we expect. @@ -22804,6 +22909,7 @@ def test_list_dns_authorizations_rest_interceptors(null_interceptor): req.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_manager.ListDnsAuthorizationsResponse.to_json( certificate_manager.ListDnsAuthorizationsResponse() ) @@ -22852,6 +22958,7 @@ def test_get_dns_authorization_rest_bad_request( response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.get_dns_authorization(request) @@ -22892,6 +22999,7 @@ def test_get_dns_authorization_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.get_dns_authorization(request) # Establish that the response is the type that we expect. @@ -22935,6 +23043,7 @@ def test_get_dns_authorization_rest_interceptors(null_interceptor): req.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_manager.DnsAuthorization.to_json( certificate_manager.DnsAuthorization() ) @@ -22981,6 +23090,7 @@ def test_create_dns_authorization_rest_bad_request( response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.create_dns_authorization(request) @@ -23094,6 +23204,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.create_dns_authorization(request) # Establish that the response is the type that we expect. @@ -23135,6 +23246,7 @@ def test_create_dns_authorization_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = json_format.MessageToJson(operations_pb2.Operation()) req.return_value.content = return_value @@ -23183,6 +23295,7 @@ def test_update_dns_authorization_rest_bad_request( response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.update_dns_authorization(request) @@ -23300,6 +23413,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.update_dns_authorization(request) # Establish that the response is the type that we expect. @@ -23341,6 +23455,7 @@ def test_update_dns_authorization_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = json_format.MessageToJson(operations_pb2.Operation()) req.return_value.content = return_value @@ -23387,6 +23502,7 @@ def test_delete_dns_authorization_rest_bad_request( response_value.status_code = 400 response_value.request = mock.Mock() req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} client.delete_dns_authorization(request) @@ -23419,6 +23535,7 @@ def test_delete_dns_authorization_rest_call_success(request_type): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.delete_dns_authorization(request) # Establish that the response is the type that we expect. @@ -23460,6 +23577,7 @@ def test_delete_dns_authorization_rest_interceptors(null_interceptor): req.return_value = mock.Mock() req.return_value.status_code = 200 + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} return_value = json_format.MessageToJson(operations_pb2.Operation()) req.return_value.content = return_value @@ -23504,6 +23622,7 @@ def test_list_certificate_issuance_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_certificate_issuance_configs(request) @@ -23546,6 +23665,7 @@ def test_list_certificate_issuance_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_certificate_issuance_configs(request) # Establish that the response is the type that we expect. @@ -23591,6 +23711,7 @@ def test_list_certificate_issuance_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 = ( certificate_issuance_config.ListCertificateIssuanceConfigsResponse.to_json( certificate_issuance_config.ListCertificateIssuanceConfigsResponse() @@ -23643,6 +23764,7 @@ def test_get_certificate_issuance_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_certificate_issuance_config(request) @@ -23685,6 +23807,7 @@ def test_get_certificate_issuance_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_certificate_issuance_config(request) # Establish that the response is the type that we expect. @@ -23733,6 +23856,7 @@ def test_get_certificate_issuance_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 = certificate_issuance_config.CertificateIssuanceConfig.to_json( certificate_issuance_config.CertificateIssuanceConfig() ) @@ -23779,6 +23903,7 @@ def test_create_certificate_issuance_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_certificate_issuance_config(request) @@ -23895,6 +24020,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.create_certificate_issuance_config(request) # Establish that the response is the type that we expect. @@ -23940,6 +24066,7 @@ def test_create_certificate_issuance_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 @@ -23988,6 +24115,7 @@ def test_delete_certificate_issuance_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_certificate_issuance_config(request) @@ -24020,6 +24148,7 @@ def test_delete_certificate_issuance_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_certificate_issuance_config(request) # Establish that the response is the type that we expect. @@ -24065,6 +24194,7 @@ def test_delete_certificate_issuance_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 @@ -24109,6 +24239,7 @@ def test_list_trust_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_trust_configs(request) @@ -24145,6 +24276,7 @@ def test_list_trust_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_trust_configs(request) # Establish that the response is the type that we expect. @@ -24186,6 +24318,7 @@ def test_list_trust_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 = trust_config.ListTrustConfigsResponse.to_json( trust_config.ListTrustConfigsResponse() ) @@ -24232,6 +24365,7 @@ def test_get_trust_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_trust_config(request) @@ -24269,6 +24403,7 @@ def test_get_trust_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_trust_config(request) # Establish that the response is the type that we expect. @@ -24311,6 +24446,7 @@ def test_get_trust_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 = trust_config.TrustConfig.to_json(trust_config.TrustConfig()) req.return_value.content = return_value @@ -24355,6 +24491,7 @@ def test_create_trust_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_trust_config(request) @@ -24466,6 +24603,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.create_trust_config(request) # Establish that the response is the type that we expect. @@ -24507,6 +24645,7 @@ def test_create_trust_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 @@ -24555,6 +24694,7 @@ def test_update_trust_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_trust_config(request) @@ -24670,6 +24810,7 @@ def get_message_fields(field): json_return_value = json_format.MessageToJson(return_value) response_value.content = json_return_value.encode("UTF-8") req.return_value = response_value + req.return_value.headers = {"header-1": "value-1", "header-2": "value-2"} response = client.update_trust_config(request) # Establish that the response is the type that we expect. @@ -24711,6 +24852,7 @@ def test_update_trust_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 @@ -24755,6 +24897,7 @@ def test_delete_trust_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_trust_config(request) @@ -24785,6 +24928,7 @@ def test_delete_trust_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_trust_config(request) # Establish that the response is the type that we expect. @@ -24826,6 +24970,7 @@ def test_delete_trust_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 @@ -24870,6 +25015,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) @@ -24900,6 +25046,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) @@ -24928,6 +25075,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) @@ -24958,6 +25106,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) @@ -24988,6 +25137,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) @@ -25018,6 +25168,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) @@ -25048,6 +25199,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) @@ -25078,6 +25230,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) @@ -25108,6 +25261,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) @@ -25138,6 +25292,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) @@ -25168,6 +25323,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) @@ -25198,6 +25354,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)