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 bb9425bbfa..71aa2f7cba 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 @@ -8,6 +8,9 @@ import os import re from typing import Callable, Dict, Optional, {% if service.any_server_streaming %}Iterable, {% endif %}{% if service.any_client_streaming %}Iterator, {% endif %}Sequence, Tuple, Type, Union import pkg_resources +{% if service.any_deprecated %} +import warnings +{% endif %} from google.api_core import client_options as client_options_lib # type: ignore from google.api_core import exceptions as core_exceptions # type: ignore @@ -335,7 +338,9 @@ class {{ service.client_name }}(metaclass={{ service.client_name }}Meta): {% endif %} """ {% if method.is_deprecated %} - warnings.warn("{{ method.name|snake_case }} is deprecated", warnings.DeprecationWarning) + warnings.warn("{{ service.client_name }}.{{ method.name|snake_case }} is deprecated", + warnings.DeprecationWarning) + {% endif %} {% if not method.client_streaming %} # Create or coerce a protobuf request object. diff --git a/gapic/schema/wrappers.py b/gapic/schema/wrappers.py index 249ca5b5d4..0e59458921 100644 --- a/gapic/schema/wrappers.py +++ b/gapic/schema/wrappers.py @@ -1207,6 +1207,10 @@ def any_client_streaming(self) -> bool: def any_server_streaming(self) -> bool: return any(m.server_streaming for m in self.methods.values()) + @utils.cached_property + def any_deprecated(self) -> bool: + return any(m.is_deprecated for m in self.methods.values()) + def with_context(self, *, collisions: FrozenSet[str]) -> 'Service': """Return a derivative of this service with the provided context. 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 3c5988073c..fcff6b82ab 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 @@ -7,6 +7,9 @@ import functools import re from typing import Dict, {% if service.any_server_streaming %}AsyncIterable, Awaitable, {% endif %}{% if service.any_client_streaming %}AsyncIterator, {% endif %}Sequence, Tuple, Type, Union import pkg_resources +{% if service.any_deprecated %} +import warnings +{% endif %} import google.api_core.client_options as ClientOptions # type: ignore from google.api_core import exceptions as core_exceptions # type: ignore @@ -196,6 +199,11 @@ class {{ service.async_client_name }}: {{ method.client_output_async.meta.doc|rst(width=72, indent=16, source_format='rst') }} {% endif %} """ + {% if method.is_deprecated %} + warnings.warn("{{ service.async_client_name }}.{{ method.name|snake_case }} is deprecated", + warnings.DeprecationWarning) + + {% endif %} {% if not method.client_streaming %} # Create or coerce a protobuf request object. {% if method.flattened_fields %} 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 9db0f092d1..26c1ec8e3d 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 @@ -8,6 +8,9 @@ import os import re from typing import Callable, Dict, Optional, {% if service.any_server_streaming %}Iterable, {% endif %}{% if service.any_client_streaming %}Iterator, {% endif %}Sequence, Tuple, Type, Union import pkg_resources +{% if service.any_deprecated %} +import warnings +{% endif %} from google.api_core import client_options as client_options_lib # type: ignore from google.api_core import exceptions as core_exceptions # type: ignore @@ -360,7 +363,9 @@ class {{ service.client_name }}(metaclass={{ service.client_name }}Meta): {% endif %} """ {% if method.is_deprecated %} - warnings.warn("{{ method.name|snake_case }} is deprecated", warnings.DeprecationWarning) + warnings.warn("{{ service.client_name }}.{{ method.name|snake_case }} is deprecated", + warnings.DeprecationWarning) + {% endif %} {% if not method.client_streaming %} # Create or coerce a protobuf request object.