From 299b066c0b74350171fdc67d75ad6db1505e260e Mon Sep 17 00:00:00 2001 From: Dov Shlachter Date: Tue, 22 Sep 2020 13:58:16 -0700 Subject: [PATCH 1/2] fix: operation module is properly aliased if necessary Some APIs define their own module named 'operation' that naively clashes with google.api_core.operation. Both modules are imported with a disambiguating alias, but the alias was not always referenced for the api_core submodule. This change fixes that issue. Fix for #610 --- .../%name/%version/%sub/services/%service/client.py.j2 | 2 +- .../%name_%version/%sub/services/%service/async_client.py.j2 | 2 +- .../%name_%version/%sub/services/%service/client.py.j2 | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/gapic/ads-templates/%namespace/%name/%version/%sub/services/%service/client.py.j2 b/gapic/ads-templates/%namespace/%name/%version/%sub/services/%service/client.py.j2 index 8de258d60b..2acc770d91 100644 --- a/gapic/ads-templates/%namespace/%name/%version/%sub/services/%service/client.py.j2 +++ b/gapic/ads-templates/%namespace/%name/%version/%sub/services/%service/client.py.j2 @@ -369,7 +369,7 @@ class {{ service.client_name }}(metaclass={{ service.client_name }}Meta): {%- if method.lro %} # Wrap the response in an operation future. - response = operation.from_gapic( + response = {{ method.client_output.ident.module_alias or method.client_output.ident.module }}.from_gapic( response, self._transport.operations_client, {{ method.lro.response_type.ident }}, diff --git a/gapic/templates/%namespace/%name_%version/%sub/services/%service/async_client.py.j2 b/gapic/templates/%namespace/%name_%version/%sub/services/%service/async_client.py.j2 index 8dfeb1a0bd..02849a8fae 100644 --- a/gapic/templates/%namespace/%name_%version/%sub/services/%service/async_client.py.j2 +++ b/gapic/templates/%namespace/%name_%version/%sub/services/%service/async_client.py.j2 @@ -240,7 +240,7 @@ class {{ service.async_client_name }}: {%- if method.lro %} # Wrap the response in an operation future. - response = operation_async.from_gapic( + response = {{ method.client_output.ident.module_alias or method.client_output.ident.module }}.from_gapic( response, self._client._transport.operations_client, {{ method.lro.response_type.ident }}, diff --git a/gapic/templates/%namespace/%name_%version/%sub/services/%service/client.py.j2 b/gapic/templates/%namespace/%name_%version/%sub/services/%service/client.py.j2 index b598ac2526..b753848361 100644 --- a/gapic/templates/%namespace/%name_%version/%sub/services/%service/client.py.j2 +++ b/gapic/templates/%namespace/%name_%version/%sub/services/%service/client.py.j2 @@ -381,7 +381,7 @@ class {{ service.client_name }}(metaclass={{ service.client_name }}Meta): {%- if method.lro %} # Wrap the response in an operation future. - response = operation.from_gapic( + response = {{ method.client_output.ident.module_alias or method.client_output.ident.module }}.from_gapic( response, self._transport.operations_client, {{ method.lro.response_type.ident }}, From 89b84118b2f5f6613afa6db4ad4a4b062807e01f Mon Sep 17 00:00:00 2001 From: Dov Shlachter Date: Tue, 22 Sep 2020 14:16:22 -0700 Subject: [PATCH 2/2] fix for async output module path --- .../%name_%version/%sub/services/%service/async_client.py.j2 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gapic/templates/%namespace/%name_%version/%sub/services/%service/async_client.py.j2 b/gapic/templates/%namespace/%name_%version/%sub/services/%service/async_client.py.j2 index 02849a8fae..7368bf6943 100644 --- a/gapic/templates/%namespace/%name_%version/%sub/services/%service/async_client.py.j2 +++ b/gapic/templates/%namespace/%name_%version/%sub/services/%service/async_client.py.j2 @@ -240,7 +240,7 @@ class {{ service.async_client_name }}: {%- if method.lro %} # Wrap the response in an operation future. - response = {{ method.client_output.ident.module_alias or method.client_output.ident.module }}.from_gapic( + response = {{ method.client_output_async.ident.module_alias or method.client_output_async.ident.module }}.from_gapic( response, self._client._transport.operations_client, {{ method.lro.response_type.ident }},