From 2af34aaa2ad635332e0037f564730cf64c473bc6 Mon Sep 17 00:00:00 2001 From: ohmayr Date: Wed, 2 Oct 2024 20:45:32 +0000 Subject: [PATCH] file bugs --- .../abstract_operations_async_client.py | 2 ++ .../abstract_operations_base_client.py | 24 +++++++++++-------- .../operations_v1/transports/rest_asyncio.py | 4 ++++ 3 files changed, 20 insertions(+), 10 deletions(-) diff --git a/google/api_core/operations_v1/abstract_operations_async_client.py b/google/api_core/operations_v1/abstract_operations_async_client.py index 80b4621a..ac34941a 100644 --- a/google/api_core/operations_v1/abstract_operations_async_client.py +++ b/google/api_core/operations_v1/abstract_operations_async_client.py @@ -98,6 +98,8 @@ def __init__( """ super().__init__( credentials=credentials, # type: ignore + # NOTE: If a transport is not provided, we force the client to use the async + # REST transport, as it should. transport=transport or "rest_asyncio", client_options=client_options, client_info=client_info, diff --git a/google/api_core/operations_v1/abstract_operations_base_client.py b/google/api_core/operations_v1/abstract_operations_base_client.py index 7358ac78..5db9adf8 100644 --- a/google/api_core/operations_v1/abstract_operations_base_client.py +++ b/google/api_core/operations_v1/abstract_operations_base_client.py @@ -132,23 +132,23 @@ def _get_default_mtls_endpoint(api_endpoint): @classmethod def from_service_account_info(cls, info: dict, *args, **kwargs): - """Creates an instance of this client using the provided credentials - info. + """ + This class method should be overridden by the subclasses. Args: info (dict): The service account private key info. args: Additional arguments to pass to the constructor. kwargs: Additional arguments to pass to the constructor. - Returns: - AbstractOperationsClient: The constructed client. + Raises: + NotImplementedError: If the method is called on the base class. """ raise NotImplementedError("`from_service_account_info` is not implemented.") @classmethod def from_service_account_file(cls, filename: str, *args, **kwargs): - """Creates an instance of this client using the provided credentials - file. + """ + This class method should be overridden by the subclasses. Args: filename (str): The path to the service account private key json @@ -156,8 +156,8 @@ def from_service_account_file(cls, filename: str, *args, **kwargs): args: Additional arguments to pass to the constructor. kwargs: Additional arguments to pass to the constructor. - Returns: - AbstractOperationsClient: The constructed client. + Raises: + NotImplementedError: If the method is called on the base class. """ raise NotImplementedError("`from_service_account_file` is not implemented.") @@ -359,14 +359,18 @@ def __init__( self._transport = transport else: Transport = type(self).get_transport_class(transport) + # NOTE: The conditional logic below to initialize the transport can be removed + # once we have feature parity with the sync transport. if "async" in str(Transport).lower(): - # TODO(https://github.com/googleapis/gapic-generator-python/issues/2136): Support the following parameters in async rest. unsupported_params = { + # TODO(https://github.com/googleapis/python-api-core/issues/715): Add support for `credentials_file` to async REST transport. "google.api_core.client_options.ClientOptions.credentials_file": client_options.credentials_file, + # TODO(https://github.com/googleapis/python-api-core/issues/716): Add support for `scopes` to async REST transport. "google.api_core.client_options.ClientOptions.scopes": client_options.scopes, + # TODO(https://github.com/googleapis/python-api-core/issues/717): Add support for `quota_project_id` to async REST transport. "google.api_core.client_options.ClientOptions.quota_project_id": client_options.quota_project_id, + # TODO(https://github.com/googleapis/python-api-core/issues/718): Add support for `client_cert_source` to async REST transport. "google.api_core.client_options.ClientOptions.client_cert_source": client_options.client_cert_source, - "google.api_core.client_options.ClientOptions.api_audience": client_options.api_audience, } provided_unsupported_params = [ name diff --git a/google/api_core/operations_v1/transports/rest_asyncio.py b/google/api_core/operations_v1/transports/rest_asyncio.py index 739859e5..6dbfd6b0 100644 --- a/google/api_core/operations_v1/transports/rest_asyncio.py +++ b/google/api_core/operations_v1/transports/rest_asyncio.py @@ -77,6 +77,10 @@ def __init__( url_scheme: str = "https", http_options: Optional[Dict] = None, path_prefix: str = "v1", + # TODO(https://github.com/googleapis/python-api-core/issues/715): Add support for `credentials_file` to async REST transport. + # TODO(https://github.com/googleapis/python-api-core/issues/716): Add support for `scopes` to async REST transport. + # TODO(https://github.com/googleapis/python-api-core/issues/717): Add support for `quota_project_id` to async REST transport. + # TODO(https://github.com/googleapis/python-api-core/issues/718): Add support for `client_cert_source` to async REST transport. ) -> None: """Instantiate the transport.