Skip to content

Commit

Permalink
feat: implement async rest mixin methods
Browse files Browse the repository at this point in the history
  • Loading branch information
ohmayr committed Sep 24, 2024
1 parent 8696ed7 commit 931feda
Show file tree
Hide file tree
Showing 14 changed files with 923 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -353,8 +353,6 @@ class {{ async_method_name_prefix }}{{ service.name }}RestInterceptor:
{% endif %}{# if (not is_async) or (is_async and not method.lro and not method.extended_lro and not method.paged_result_field) #}
{% endfor %}

{# TODO(https://github.com/googleapis/gapic-generator-python/issues/2148): Remove the condition below once mixins are supported for async rest transport. #}
{% if not is_async %}
{% for name, signature in api.mixin_api_signatures.items() %}
{{ async_prefix }}def pre_{{ name|snake_case }}(
self, request: {{signature.request_type}}, metadata: Sequence[Tuple[str, str]]
Expand All @@ -377,7 +375,6 @@ class {{ async_method_name_prefix }}{{ service.name }}RestInterceptor:
"""
return response
{% endfor %}
{% endif %}
{% endmacro %}

{% macro generate_mixin_call_method(service, api, name, sig, is_async) %}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ from google.api_core.client_options import ClientOptions
from google.api_core import exceptions as core_exceptions
from google.api_core import gapic_v1
from google.api_core import retry_async as retries
import google.auth
from google.auth import credentials as ga_credentials # type: ignore
from google.oauth2 import service_account # type: ignore

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -225,6 +225,9 @@ class Async{{service.name}}RestTransport(_Base{{ service.name }}RestTransport):
return self._{{method.name}}(self._session, self._host, self._interceptor) # type: ignore

{% endfor %}
{% for name, sig in api.mixin_api_signatures.items() %}
{{ shared_macros.generate_mixin_call_method(service, api, name, sig, is_async=True) | indent(4) }}
{% endfor %}

@property
def kind(self) -> str:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1884,11 +1884,8 @@ def test_unsupported_parameter_rest_asyncio():
{% endfor %}{# for method in service.methods.values() #}
{% for name, sig in api.mixin_api_signatures.items() %}
{% if 'rest' in transport %}
{# TODO: Remove the following condition as we implement async mixins #}
{% if not is_async %}
{{ bad_request_mixins_test(service, api, name, sig, transport, is_async) }}
{{ call_success_mixins_test(service, api, name, sig, transport, is_async) }}
{% endif %}{# if not is_async #}
{% endif %}{# if 'rest' in transport #}
{% endfor %}
{{ initialize_client_with_transport_test(service, transport, is_async) }}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
from google.api_core import exceptions as core_exceptions
from google.api_core import gapic_v1
from google.api_core import retry_async as retries
import google.auth
from google.auth import credentials as ga_credentials # type: ignore
from google.oauth2 import service_account # type: ignore

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
from google.api_core import exceptions as core_exceptions
from google.api_core import gapic_v1
from google.api_core import retry_async as retries
import google.auth
from google.auth import credentials as ga_credentials # type: ignore
from google.oauth2 import service_account # type: ignore

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
from google.api_core import exceptions as core_exceptions
from google.api_core import gapic_v1
from google.api_core import retry_async as retries
import google.auth
from google.auth import credentials as ga_credentials # type: ignore
from google.oauth2 import service_account # type: ignore

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
from google.api_core import exceptions as core_exceptions
from google.api_core import gapic_v1
from google.api_core import retry_async as retries
import google.auth
from google.auth import credentials as ga_credentials # type: ignore
from google.oauth2 import service_account # type: ignore

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
from google.api_core import exceptions as core_exceptions
from google.api_core import gapic_v1
from google.api_core import retry_async as retries
import google.auth
from google.auth import credentials as ga_credentials # type: ignore
from google.oauth2 import service_account # type: ignore

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
from google.api_core import exceptions as core_exceptions
from google.api_core import gapic_v1
from google.api_core import retry_async as retries
import google.auth
from google.auth import credentials as ga_credentials # type: ignore
from google.oauth2 import service_account # type: ignore

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
from google.api_core import exceptions as core_exceptions
from google.api_core import gapic_v1
from google.api_core import retry_async as retries
import google.auth
from google.auth import credentials as ga_credentials # type: ignore
from google.oauth2 import service_account # type: ignore

Expand Down
Loading

0 comments on commit 931feda

Please sign in to comment.