From 7786cf35cf8c79a74878520a403e9a6fc4cb4372 Mon Sep 17 00:00:00 2001 From: Quentin Pradet Date: Wed, 6 Nov 2024 11:43:22 +0400 Subject: [PATCH 1/5] Add API warnings infrastructure --- elasticsearch/_async/client/utils.py | 4 ++ elasticsearch/_sync/client/utils.py | 48 +++++++++++++++ elasticsearch/exceptions.py | 4 ++ test_elasticsearch/test_client/test_utils.py | 64 +++++++++++++++++++- 4 files changed, 119 insertions(+), 1 deletion(-) diff --git a/elasticsearch/_async/client/utils.py b/elasticsearch/_async/client/utils.py index ec0a6e4b8..97918d9e4 100644 --- a/elasticsearch/_async/client/utils.py +++ b/elasticsearch/_async/client/utils.py @@ -20,10 +20,12 @@ _TYPE_HOSTS, CLIENT_META_SERVICE, SKIP_IN_PATH, + Stability, _base64_auth_header, _quote, _quote_query, _rewrite_parameters, + _stability_warning, client_node_configs, is_requests_http_auth, is_requests_node_class, @@ -37,8 +39,10 @@ "_quote_query", "_TYPE_HOSTS", "SKIP_IN_PATH", + "Stability", "client_node_configs", "_rewrite_parameters", + "_stability_warning", "is_requests_http_auth", "is_requests_node_class", ] diff --git a/elasticsearch/_sync/client/utils.py b/elasticsearch/_sync/client/utils.py index 1d1a983ac..42f9118e0 100644 --- a/elasticsearch/_sync/client/utils.py +++ b/elasticsearch/_sync/client/utils.py @@ -20,6 +20,7 @@ import urllib.parse import warnings from datetime import date, datetime +from enum import Enum, auto from functools import wraps from typing import ( TYPE_CHECKING, @@ -55,6 +56,8 @@ url_to_node_config, ) +from elasticsearch.exceptions import GeneralAvailabilityWarning + from ..._version import __versionstr__ from ...compat import to_bytes, to_str, warn_stacklevel @@ -70,6 +73,14 @@ # Default User-Agent used by the client USER_AGENT = create_user_agent("elasticsearch-py", __versionstr__) + +class Stability(Enum): + STABLE = auto() + BETA = auto() + EXPERIMENTAL = auto() + DEPRECATED = auto() + + _TYPE_HOSTS = Union[ str, Sequence[Union[str, Mapping[str, Union[str, int]], NodeConfig]] ] @@ -450,6 +461,43 @@ def wrapped(*args: Any, **kwargs: Any) -> Any: return wrapper +def _stability_warning( + stability: Stability, + version: Optional[str] = None, + message: Optional[str] = None, +) -> Callable[[F], F]: + def wrapper(api: F) -> F: + @wraps(api) + def wrapped(*args: Any, **kwargs: Any) -> Any: + if stability == Stability.BETA: + warnings.warn( + "This API is in beta and is subject to change. " + "The design and code is less mature than official GA features and is being provided as-is with no warranties. " + "Beta features are not subject to the support SLA of official GA features.", + category=GeneralAvailabilityWarning, + stacklevel=warn_stacklevel(), + ) + elif stability == Stability.EXPERIMENTAL: + warnings.warn( + "This API is in technical preview and may be changed or removed in a future release. " + "Elastic will work to fix any issues, but features in technical preview are not subject to the support SLA of official GA features.", + category=GeneralAvailabilityWarning, + stacklevel=warn_stacklevel(), + ) + elif stability == Stability.DEPRECATED: + warnings.warn( + f"This API was deprecated in Elasticsearch {version}. {message}", + category=DeprecationWarning, + stacklevel=warn_stacklevel(), + ) + + return api(*args, **kwargs) + + return wrapped # type: ignore[return-value] + + return wrapper + + def is_requests_http_auth(http_auth: Any) -> bool: """Detect if an http_auth value is a custom Requests auth object""" try: diff --git a/elasticsearch/exceptions.py b/elasticsearch/exceptions.py index f58706774..dc410ae30 100644 --- a/elasticsearch/exceptions.py +++ b/elasticsearch/exceptions.py @@ -115,6 +115,10 @@ class ElasticsearchWarning(TransportWarning): """ +class GeneralAvailabilityWarning(TransportWarning): + """Warning that is raised when a feature is not yet GA.""" + + # Aliases for backwards compatibility ElasticsearchDeprecationWarning = ElasticsearchWarning RequestError = BadRequestError diff --git a/test_elasticsearch/test_client/test_utils.py b/test_elasticsearch/test_client/test_utils.py index e53145bfd..90f8b106a 100644 --- a/test_elasticsearch/test_client/test_utils.py +++ b/test_elasticsearch/test_client/test_utils.py @@ -16,7 +16,10 @@ # under the License. -from elasticsearch._sync.client.utils import _quote +import warnings + +from elasticsearch._sync.client.utils import Stability, _quote, _stability_warning +from elasticsearch.exceptions import GeneralAvailabilityWarning def test_handles_ascii(): @@ -36,3 +39,62 @@ def test_handles_unicode(): def test_handles_unicode2(): string = "中*文," assert "%E4%B8%AD*%E6%96%87," == _quote(string) + + +class TestStabilityWarning: + def test_default(self): + + @_stability_warning(stability=Stability.STABLE) + def func_default(*args, **kwargs): + pass + + with warnings.catch_warnings(): + warnings.simplefilter("error") + func_default() + + def test_beta(self, recwarn): + + @_stability_warning(stability=Stability.BETA) + def func_beta(*args, **kwargs): + pass + + func_beta() + + assert len(recwarn) == 1 + user_warning = recwarn.pop(GeneralAvailabilityWarning) + assert user_warning.category == GeneralAvailabilityWarning + assert user_warning.message.args[0].startswith( + "This API is in beta and is subject to change." + ) + + def test_experimental(self, recwarn): + + @_stability_warning(stability=Stability.EXPERIMENTAL) + def func_experimental(*args, **kwargs): + pass + + func_experimental() + + assert len(recwarn) == 1 + user_warning = recwarn.pop(GeneralAvailabilityWarning) + assert user_warning.category == GeneralAvailabilityWarning + assert user_warning.message.args[0].startswith( + "This API is in technical preview and may be changed or removed in a future release." + ) + + def test_deprecated(self, recwarn): + + @_stability_warning( + stability=Stability.DEPRECATED, version="8.4.0", message="Use bar instead." + ) + def func_deprecated(*args, **kwargs): + pass + + func_deprecated() + + assert len(recwarn) == 1 + user_warning = recwarn.pop(DeprecationWarning) + assert user_warning.category == DeprecationWarning + assert user_warning.message.args[0] == ( + "This API was deprecated in Elasticsearch 8.4.0. Use bar instead." + ) From f0215f9ea9e58ed0ba4e39ddb176ffdbf07a3968 Mon Sep 17 00:00:00 2001 From: Quentin Pradet Date: Wed, 6 Nov 2024 11:44:01 +0400 Subject: [PATCH 2/5] Auto-generated API code --- elasticsearch/_async/client/__init__.py | 8 +++++ elasticsearch/_async/client/cat.py | 9 ++++- elasticsearch/_async/client/connector.py | 33 ++++++++++++++++++- elasticsearch/_async/client/features.py | 3 +- elasticsearch/_async/client/fleet.py | 10 +++++- elasticsearch/_async/client/indices.py | 11 ++++++- elasticsearch/_async/client/inference.py | 12 ++++++- elasticsearch/_async/client/ml.py | 13 +++++++- elasticsearch/_async/client/nodes.py | 10 +++++- elasticsearch/_async/client/rollup.py | 16 ++++++++- .../_async/client/search_application.py | 16 ++++++++- .../_async/client/searchable_snapshots.py | 10 +++++- elasticsearch/_async/client/snapshot.py | 9 ++++- elasticsearch/_async/client/tasks.py | 11 ++++++- elasticsearch/_sync/client/__init__.py | 8 +++++ elasticsearch/_sync/client/cat.py | 9 ++++- elasticsearch/_sync/client/connector.py | 33 ++++++++++++++++++- elasticsearch/_sync/client/features.py | 3 +- elasticsearch/_sync/client/fleet.py | 10 +++++- elasticsearch/_sync/client/indices.py | 11 ++++++- elasticsearch/_sync/client/inference.py | 12 ++++++- elasticsearch/_sync/client/ml.py | 13 +++++++- elasticsearch/_sync/client/nodes.py | 10 +++++- elasticsearch/_sync/client/rollup.py | 16 ++++++++- .../_sync/client/search_application.py | 16 ++++++++- .../_sync/client/searchable_snapshots.py | 10 +++++- elasticsearch/_sync/client/snapshot.py | 9 ++++- elasticsearch/_sync/client/tasks.py | 11 ++++++- 28 files changed, 316 insertions(+), 26 deletions(-) diff --git a/elasticsearch/_async/client/__init__.py b/elasticsearch/_async/client/__init__.py index 07b8856eb..efcbcfbca 100644 --- a/elasticsearch/_async/client/__init__.py +++ b/elasticsearch/_async/client/__init__.py @@ -82,8 +82,10 @@ _TYPE_HOSTS, CLIENT_META_SERVICE, SKIP_IN_PATH, + Stability, _quote, _rewrite_parameters, + _stability_warning, client_node_configs, is_requests_http_auth, is_requests_node_class, @@ -2494,6 +2496,11 @@ async def info( ), parameter_aliases={"_source": "source"}, ) + @_stability_warning( + Stability.DEPRECATED, + version="8.4.0", + message="The kNN search API has been replaced by the `knn` option in the search API.", + ) async def knn_search( self, *, @@ -3570,6 +3577,7 @@ async def render_search_template( @_rewrite_parameters( body_fields=("context", "context_setup", "script"), ) + @_stability_warning(Stability.EXPERIMENTAL) async def scripts_painless_execute( self, *, diff --git a/elasticsearch/_async/client/cat.py b/elasticsearch/_async/client/cat.py index 83a393e7a..cf2798c46 100644 --- a/elasticsearch/_async/client/cat.py +++ b/elasticsearch/_async/client/cat.py @@ -20,7 +20,13 @@ from elastic_transport import ObjectApiResponse, TextApiResponse from ._base import NamespacedClient -from .utils import SKIP_IN_PATH, _quote, _rewrite_parameters +from .utils import ( + SKIP_IN_PATH, + Stability, + _quote, + _rewrite_parameters, + _stability_warning, +) class CatClient(NamespacedClient): @@ -2517,6 +2523,7 @@ async def snapshots( ) @_rewrite_parameters() + @_stability_warning(Stability.EXPERIMENTAL) async def tasks( self, *, diff --git a/elasticsearch/_async/client/connector.py b/elasticsearch/_async/client/connector.py index fceb2896d..86dc55b96 100644 --- a/elasticsearch/_async/client/connector.py +++ b/elasticsearch/_async/client/connector.py @@ -20,12 +20,19 @@ from elastic_transport import ObjectApiResponse from ._base import NamespacedClient -from .utils import SKIP_IN_PATH, _quote, _rewrite_parameters +from .utils import ( + SKIP_IN_PATH, + Stability, + _quote, + _rewrite_parameters, + _stability_warning, +) class ConnectorClient(NamespacedClient): @_rewrite_parameters() + @_stability_warning(Stability.EXPERIMENTAL) async def check_in( self, *, @@ -67,6 +74,7 @@ async def check_in( ) @_rewrite_parameters() + @_stability_warning(Stability.BETA) async def delete( self, *, @@ -115,6 +123,7 @@ async def delete( ) @_rewrite_parameters() + @_stability_warning(Stability.BETA) async def get( self, *, @@ -170,6 +179,7 @@ async def get( "sync_cursor", ), ) + @_stability_warning(Stability.EXPERIMENTAL) async def last_sync( self, *, @@ -299,6 +309,7 @@ async def last_sync( @_rewrite_parameters( parameter_aliases={"from": "from_"}, ) + @_stability_warning(Stability.BETA) async def list( self, *, @@ -372,6 +383,7 @@ async def list( "service_type", ), ) + @_stability_warning(Stability.BETA) async def post( self, *, @@ -453,6 +465,7 @@ async def post( "service_type", ), ) + @_stability_warning(Stability.BETA) async def put( self, *, @@ -529,6 +542,7 @@ async def put( ) @_rewrite_parameters() + @_stability_warning(Stability.BETA) async def sync_job_cancel( self, *, @@ -576,6 +590,7 @@ async def sync_job_cancel( ) @_rewrite_parameters() + @_stability_warning(Stability.BETA) async def sync_job_delete( self, *, @@ -620,6 +635,7 @@ async def sync_job_delete( ) @_rewrite_parameters() + @_stability_warning(Stability.BETA) async def sync_job_get( self, *, @@ -664,6 +680,7 @@ async def sync_job_get( @_rewrite_parameters( parameter_aliases={"from": "from_"}, ) + @_stability_warning(Stability.BETA) async def sync_job_list( self, *, @@ -743,6 +760,7 @@ async def sync_job_list( @_rewrite_parameters( body_fields=("id", "job_type", "trigger_method"), ) + @_stability_warning(Stability.BETA) async def sync_job_post( self, *, @@ -802,6 +820,7 @@ async def sync_job_post( ) @_rewrite_parameters() + @_stability_warning(Stability.EXPERIMENTAL) async def update_active_filtering( self, *, @@ -845,6 +864,7 @@ async def update_active_filtering( @_rewrite_parameters( body_fields=("api_key_id", "api_key_secret_id"), ) + @_stability_warning(Stability.BETA) async def update_api_key_id( self, *, @@ -903,6 +923,7 @@ async def update_api_key_id( @_rewrite_parameters( body_fields=("configuration", "values"), ) + @_stability_warning(Stability.BETA) async def update_configuration( self, *, @@ -958,6 +979,7 @@ async def update_configuration( @_rewrite_parameters( body_fields=("error",), ) + @_stability_warning(Stability.EXPERIMENTAL) async def update_error( self, *, @@ -1013,6 +1035,7 @@ async def update_error( @_rewrite_parameters( body_fields=("advanced_snippet", "filtering", "rules"), ) + @_stability_warning(Stability.BETA) async def update_filtering( self, *, @@ -1074,6 +1097,7 @@ async def update_filtering( @_rewrite_parameters( body_fields=("validation",), ) + @_stability_warning(Stability.EXPERIMENTAL) async def update_filtering_validation( self, *, @@ -1127,6 +1151,7 @@ async def update_filtering_validation( @_rewrite_parameters( body_fields=("index_name",), ) + @_stability_warning(Stability.BETA) async def update_index_name( self, *, @@ -1180,6 +1205,7 @@ async def update_index_name( @_rewrite_parameters( body_fields=("description", "name"), ) + @_stability_warning(Stability.BETA) async def update_name( self, *, @@ -1234,6 +1260,7 @@ async def update_name( @_rewrite_parameters( body_fields=("is_native",), ) + @_stability_warning(Stability.BETA) async def update_native( self, *, @@ -1286,6 +1313,7 @@ async def update_native( @_rewrite_parameters( body_fields=("pipeline",), ) + @_stability_warning(Stability.BETA) async def update_pipeline( self, *, @@ -1339,6 +1367,7 @@ async def update_pipeline( @_rewrite_parameters( body_fields=("scheduling",), ) + @_stability_warning(Stability.BETA) async def update_scheduling( self, *, @@ -1391,6 +1420,7 @@ async def update_scheduling( @_rewrite_parameters( body_fields=("service_type",), ) + @_stability_warning(Stability.BETA) async def update_service_type( self, *, @@ -1443,6 +1473,7 @@ async def update_service_type( @_rewrite_parameters( body_fields=("status",), ) + @_stability_warning(Stability.EXPERIMENTAL) async def update_status( self, *, diff --git a/elasticsearch/_async/client/features.py b/elasticsearch/_async/client/features.py index a6fbf4d14..afa814cfd 100644 --- a/elasticsearch/_async/client/features.py +++ b/elasticsearch/_async/client/features.py @@ -20,7 +20,7 @@ from elastic_transport import ObjectApiResponse from ._base import NamespacedClient -from .utils import _rewrite_parameters +from .utils import Stability, _rewrite_parameters, _stability_warning class FeaturesClient(NamespacedClient): @@ -62,6 +62,7 @@ async def get_features( ) @_rewrite_parameters() + @_stability_warning(Stability.EXPERIMENTAL) async def reset_features( self, *, diff --git a/elasticsearch/_async/client/fleet.py b/elasticsearch/_async/client/fleet.py index e34aa0fd9..942c4018c 100644 --- a/elasticsearch/_async/client/fleet.py +++ b/elasticsearch/_async/client/fleet.py @@ -20,7 +20,13 @@ from elastic_transport import ObjectApiResponse from ._base import NamespacedClient -from .utils import SKIP_IN_PATH, _quote, _rewrite_parameters +from .utils import ( + SKIP_IN_PATH, + Stability, + _quote, + _rewrite_parameters, + _stability_warning, +) class FleetClient(NamespacedClient): @@ -91,6 +97,7 @@ async def global_checkpoints( @_rewrite_parameters( body_name="searches", ) + @_stability_warning(Stability.EXPERIMENTAL) async def msearch( self, *, @@ -277,6 +284,7 @@ async def msearch( "from": "from_", }, ) + @_stability_warning(Stability.EXPERIMENTAL) async def search( self, *, diff --git a/elasticsearch/_async/client/indices.py b/elasticsearch/_async/client/indices.py index e9ebc2900..399702412 100644 --- a/elasticsearch/_async/client/indices.py +++ b/elasticsearch/_async/client/indices.py @@ -20,7 +20,13 @@ from elastic_transport import HeadApiResponse, ObjectApiResponse from ._base import NamespacedClient -from .utils import SKIP_IN_PATH, _quote, _rewrite_parameters +from .utils import ( + SKIP_IN_PATH, + Stability, + _quote, + _rewrite_parameters, + _stability_warning, +) class IndicesClient(NamespacedClient): @@ -1032,6 +1038,7 @@ async def delete_template( ) @_rewrite_parameters() + @_stability_warning(Stability.EXPERIMENTAL) async def disk_usage( self, *, @@ -1114,6 +1121,7 @@ async def disk_usage( @_rewrite_parameters( body_name="config", ) + @_stability_warning(Stability.EXPERIMENTAL) async def downsample( self, *, @@ -1483,6 +1491,7 @@ async def explain_data_lifecycle( ) @_rewrite_parameters() + @_stability_warning(Stability.EXPERIMENTAL) async def field_usage_stats( self, *, diff --git a/elasticsearch/_async/client/inference.py b/elasticsearch/_async/client/inference.py index b7fd1b7a3..29906c000 100644 --- a/elasticsearch/_async/client/inference.py +++ b/elasticsearch/_async/client/inference.py @@ -20,12 +20,19 @@ from elastic_transport import ObjectApiResponse from ._base import NamespacedClient -from .utils import SKIP_IN_PATH, _quote, _rewrite_parameters +from .utils import ( + SKIP_IN_PATH, + Stability, + _quote, + _rewrite_parameters, + _stability_warning, +) class InferenceClient(NamespacedClient): @_rewrite_parameters() + @_stability_warning(Stability.EXPERIMENTAL) async def delete( self, *, @@ -93,6 +100,7 @@ async def delete( ) @_rewrite_parameters() + @_stability_warning(Stability.EXPERIMENTAL) async def get( self, *, @@ -151,6 +159,7 @@ async def get( @_rewrite_parameters( body_fields=("input", "query", "task_settings"), ) + @_stability_warning(Stability.EXPERIMENTAL) async def inference( self, *, @@ -237,6 +246,7 @@ async def inference( @_rewrite_parameters( body_name="inference_config", ) + @_stability_warning(Stability.EXPERIMENTAL) async def put( self, *, diff --git a/elasticsearch/_async/client/ml.py b/elasticsearch/_async/client/ml.py index be77a4c69..365ca7aad 100644 --- a/elasticsearch/_async/client/ml.py +++ b/elasticsearch/_async/client/ml.py @@ -20,7 +20,13 @@ from elastic_transport import ObjectApiResponse from ._base import NamespacedClient -from .utils import SKIP_IN_PATH, _quote, _rewrite_parameters +from .utils import ( + SKIP_IN_PATH, + Stability, + _quote, + _rewrite_parameters, + _stability_warning, +) class MlClient(NamespacedClient): @@ -2843,6 +2849,11 @@ async def post_calendar_events( @_rewrite_parameters( body_name="data", ) + @_stability_warning( + Stability.DEPRECATED, + version="7.11.0", + message="Posting data directly to anomaly detection jobs is deprecated, in a future major version a datafeed will be required.", + ) async def post_data( self, *, diff --git a/elasticsearch/_async/client/nodes.py b/elasticsearch/_async/client/nodes.py index 3056354c4..10774d761 100644 --- a/elasticsearch/_async/client/nodes.py +++ b/elasticsearch/_async/client/nodes.py @@ -20,12 +20,19 @@ from elastic_transport import ObjectApiResponse, TextApiResponse from ._base import NamespacedClient -from .utils import SKIP_IN_PATH, _quote, _rewrite_parameters +from .utils import ( + SKIP_IN_PATH, + Stability, + _quote, + _rewrite_parameters, + _stability_warning, +) class NodesClient(NamespacedClient): @_rewrite_parameters() + @_stability_warning(Stability.EXPERIMENTAL) async def clear_repositories_metering_archive( self, *, @@ -76,6 +83,7 @@ async def clear_repositories_metering_archive( ) @_rewrite_parameters() + @_stability_warning(Stability.EXPERIMENTAL) async def get_repositories_metering_info( self, *, diff --git a/elasticsearch/_async/client/rollup.py b/elasticsearch/_async/client/rollup.py index 5c6c157f0..6a3a4a057 100644 --- a/elasticsearch/_async/client/rollup.py +++ b/elasticsearch/_async/client/rollup.py @@ -20,12 +20,19 @@ from elastic_transport import ObjectApiResponse from ._base import NamespacedClient -from .utils import SKIP_IN_PATH, _quote, _rewrite_parameters +from .utils import ( + SKIP_IN_PATH, + Stability, + _quote, + _rewrite_parameters, + _stability_warning, +) class RollupClient(NamespacedClient): @_rewrite_parameters() + @_stability_warning(Stability.EXPERIMENTAL) async def delete_job( self, *, @@ -66,6 +73,7 @@ async def delete_job( ) @_rewrite_parameters() + @_stability_warning(Stability.EXPERIMENTAL) async def get_jobs( self, *, @@ -110,6 +118,7 @@ async def get_jobs( ) @_rewrite_parameters() + @_stability_warning(Stability.EXPERIMENTAL) async def get_rollup_caps( self, *, @@ -155,6 +164,7 @@ async def get_rollup_caps( ) @_rewrite_parameters() + @_stability_warning(Stability.EXPERIMENTAL) async def get_rollup_index_caps( self, *, @@ -209,6 +219,7 @@ async def get_rollup_index_caps( ), ignore_deprecated_options={"headers"}, ) + @_stability_warning(Stability.EXPERIMENTAL) async def put_job( self, *, @@ -327,6 +338,7 @@ async def put_job( @_rewrite_parameters( body_fields=("aggregations", "aggs", "query", "size"), ) + @_stability_warning(Stability.EXPERIMENTAL) async def rollup_search( self, *, @@ -397,6 +409,7 @@ async def rollup_search( ) @_rewrite_parameters() + @_stability_warning(Stability.EXPERIMENTAL) async def start_job( self, *, @@ -437,6 +450,7 @@ async def start_job( ) @_rewrite_parameters() + @_stability_warning(Stability.EXPERIMENTAL) async def stop_job( self, *, diff --git a/elasticsearch/_async/client/search_application.py b/elasticsearch/_async/client/search_application.py index f35714b39..d5a3d150b 100644 --- a/elasticsearch/_async/client/search_application.py +++ b/elasticsearch/_async/client/search_application.py @@ -20,12 +20,19 @@ from elastic_transport import ObjectApiResponse from ._base import NamespacedClient -from .utils import SKIP_IN_PATH, _quote, _rewrite_parameters +from .utils import ( + SKIP_IN_PATH, + Stability, + _quote, + _rewrite_parameters, + _stability_warning, +) class SearchApplicationClient(NamespacedClient): @_rewrite_parameters() + @_stability_warning(Stability.BETA) async def delete( self, *, @@ -67,6 +74,7 @@ async def delete( ) @_rewrite_parameters() + @_stability_warning(Stability.EXPERIMENTAL) async def delete_behavioral_analytics( self, *, @@ -108,6 +116,7 @@ async def delete_behavioral_analytics( ) @_rewrite_parameters() + @_stability_warning(Stability.BETA) async def get( self, *, @@ -148,6 +157,7 @@ async def get( ) @_rewrite_parameters() + @_stability_warning(Stability.EXPERIMENTAL) async def get_behavioral_analytics( self, *, @@ -193,6 +203,7 @@ async def get_behavioral_analytics( @_rewrite_parameters( parameter_aliases={"from": "from_"}, ) + @_stability_warning(Stability.BETA) async def list( self, *, @@ -243,6 +254,7 @@ async def list( @_rewrite_parameters( body_name="search_application", ) + @_stability_warning(Stability.BETA) async def put( self, *, @@ -299,6 +311,7 @@ async def put( ) @_rewrite_parameters() + @_stability_warning(Stability.EXPERIMENTAL) async def put_behavioral_analytics( self, *, @@ -342,6 +355,7 @@ async def put_behavioral_analytics( body_fields=("params",), ignore_deprecated_options={"params"}, ) + @_stability_warning(Stability.BETA) async def search( self, *, diff --git a/elasticsearch/_async/client/searchable_snapshots.py b/elasticsearch/_async/client/searchable_snapshots.py index b6a405991..bb7f01b39 100644 --- a/elasticsearch/_async/client/searchable_snapshots.py +++ b/elasticsearch/_async/client/searchable_snapshots.py @@ -20,12 +20,19 @@ from elastic_transport import ObjectApiResponse from ._base import NamespacedClient -from .utils import SKIP_IN_PATH, _quote, _rewrite_parameters +from .utils import ( + SKIP_IN_PATH, + Stability, + _quote, + _rewrite_parameters, + _stability_warning, +) class SearchableSnapshotsClient(NamespacedClient): @_rewrite_parameters() + @_stability_warning(Stability.EXPERIMENTAL) async def cache_stats( self, *, @@ -75,6 +82,7 @@ async def cache_stats( ) @_rewrite_parameters() + @_stability_warning(Stability.EXPERIMENTAL) async def clear_cache( self, *, diff --git a/elasticsearch/_async/client/snapshot.py b/elasticsearch/_async/client/snapshot.py index 3f66d60fb..35bc41ca1 100644 --- a/elasticsearch/_async/client/snapshot.py +++ b/elasticsearch/_async/client/snapshot.py @@ -20,7 +20,13 @@ from elastic_transport import ObjectApiResponse from ._base import NamespacedClient -from .utils import SKIP_IN_PATH, _quote, _rewrite_parameters +from .utils import ( + SKIP_IN_PATH, + Stability, + _quote, + _rewrite_parameters, + _stability_warning, +) class SnapshotClient(NamespacedClient): @@ -617,6 +623,7 @@ async def get_repository( ) @_rewrite_parameters() + @_stability_warning(Stability.EXPERIMENTAL) async def repository_verify_integrity( self, *, diff --git a/elasticsearch/_async/client/tasks.py b/elasticsearch/_async/client/tasks.py index 0acbfef31..ed083fb3a 100644 --- a/elasticsearch/_async/client/tasks.py +++ b/elasticsearch/_async/client/tasks.py @@ -20,12 +20,19 @@ from elastic_transport import ObjectApiResponse from ._base import NamespacedClient -from .utils import SKIP_IN_PATH, _quote, _rewrite_parameters +from .utils import ( + SKIP_IN_PATH, + Stability, + _quote, + _rewrite_parameters, + _stability_warning, +) class TasksClient(NamespacedClient): @_rewrite_parameters() + @_stability_warning(Stability.EXPERIMENTAL) async def cancel( self, *, @@ -87,6 +94,7 @@ async def cancel( ) @_rewrite_parameters() + @_stability_warning(Stability.EXPERIMENTAL) async def get( self, *, @@ -138,6 +146,7 @@ async def get( ) @_rewrite_parameters() + @_stability_warning(Stability.EXPERIMENTAL) async def list( self, *, diff --git a/elasticsearch/_sync/client/__init__.py b/elasticsearch/_sync/client/__init__.py index eb1b11219..a3f5fdc25 100644 --- a/elasticsearch/_sync/client/__init__.py +++ b/elasticsearch/_sync/client/__init__.py @@ -82,8 +82,10 @@ _TYPE_HOSTS, CLIENT_META_SERVICE, SKIP_IN_PATH, + Stability, _quote, _rewrite_parameters, + _stability_warning, client_node_configs, is_requests_http_auth, is_requests_node_class, @@ -2492,6 +2494,11 @@ def info( ), parameter_aliases={"_source": "source"}, ) + @_stability_warning( + Stability.DEPRECATED, + version="8.4.0", + message="The kNN search API has been replaced by the `knn` option in the search API.", + ) def knn_search( self, *, @@ -3568,6 +3575,7 @@ def render_search_template( @_rewrite_parameters( body_fields=("context", "context_setup", "script"), ) + @_stability_warning(Stability.EXPERIMENTAL) def scripts_painless_execute( self, *, diff --git a/elasticsearch/_sync/client/cat.py b/elasticsearch/_sync/client/cat.py index 067ededb6..7955a3ad5 100644 --- a/elasticsearch/_sync/client/cat.py +++ b/elasticsearch/_sync/client/cat.py @@ -20,7 +20,13 @@ from elastic_transport import ObjectApiResponse, TextApiResponse from ._base import NamespacedClient -from .utils import SKIP_IN_PATH, _quote, _rewrite_parameters +from .utils import ( + SKIP_IN_PATH, + Stability, + _quote, + _rewrite_parameters, + _stability_warning, +) class CatClient(NamespacedClient): @@ -2517,6 +2523,7 @@ def snapshots( ) @_rewrite_parameters() + @_stability_warning(Stability.EXPERIMENTAL) def tasks( self, *, diff --git a/elasticsearch/_sync/client/connector.py b/elasticsearch/_sync/client/connector.py index b35d858ff..55b87e090 100644 --- a/elasticsearch/_sync/client/connector.py +++ b/elasticsearch/_sync/client/connector.py @@ -20,12 +20,19 @@ from elastic_transport import ObjectApiResponse from ._base import NamespacedClient -from .utils import SKIP_IN_PATH, _quote, _rewrite_parameters +from .utils import ( + SKIP_IN_PATH, + Stability, + _quote, + _rewrite_parameters, + _stability_warning, +) class ConnectorClient(NamespacedClient): @_rewrite_parameters() + @_stability_warning(Stability.EXPERIMENTAL) def check_in( self, *, @@ -67,6 +74,7 @@ def check_in( ) @_rewrite_parameters() + @_stability_warning(Stability.BETA) def delete( self, *, @@ -115,6 +123,7 @@ def delete( ) @_rewrite_parameters() + @_stability_warning(Stability.BETA) def get( self, *, @@ -170,6 +179,7 @@ def get( "sync_cursor", ), ) + @_stability_warning(Stability.EXPERIMENTAL) def last_sync( self, *, @@ -299,6 +309,7 @@ def last_sync( @_rewrite_parameters( parameter_aliases={"from": "from_"}, ) + @_stability_warning(Stability.BETA) def list( self, *, @@ -372,6 +383,7 @@ def list( "service_type", ), ) + @_stability_warning(Stability.BETA) def post( self, *, @@ -453,6 +465,7 @@ def post( "service_type", ), ) + @_stability_warning(Stability.BETA) def put( self, *, @@ -529,6 +542,7 @@ def put( ) @_rewrite_parameters() + @_stability_warning(Stability.BETA) def sync_job_cancel( self, *, @@ -576,6 +590,7 @@ def sync_job_cancel( ) @_rewrite_parameters() + @_stability_warning(Stability.BETA) def sync_job_delete( self, *, @@ -620,6 +635,7 @@ def sync_job_delete( ) @_rewrite_parameters() + @_stability_warning(Stability.BETA) def sync_job_get( self, *, @@ -664,6 +680,7 @@ def sync_job_get( @_rewrite_parameters( parameter_aliases={"from": "from_"}, ) + @_stability_warning(Stability.BETA) def sync_job_list( self, *, @@ -743,6 +760,7 @@ def sync_job_list( @_rewrite_parameters( body_fields=("id", "job_type", "trigger_method"), ) + @_stability_warning(Stability.BETA) def sync_job_post( self, *, @@ -802,6 +820,7 @@ def sync_job_post( ) @_rewrite_parameters() + @_stability_warning(Stability.EXPERIMENTAL) def update_active_filtering( self, *, @@ -845,6 +864,7 @@ def update_active_filtering( @_rewrite_parameters( body_fields=("api_key_id", "api_key_secret_id"), ) + @_stability_warning(Stability.BETA) def update_api_key_id( self, *, @@ -903,6 +923,7 @@ def update_api_key_id( @_rewrite_parameters( body_fields=("configuration", "values"), ) + @_stability_warning(Stability.BETA) def update_configuration( self, *, @@ -958,6 +979,7 @@ def update_configuration( @_rewrite_parameters( body_fields=("error",), ) + @_stability_warning(Stability.EXPERIMENTAL) def update_error( self, *, @@ -1013,6 +1035,7 @@ def update_error( @_rewrite_parameters( body_fields=("advanced_snippet", "filtering", "rules"), ) + @_stability_warning(Stability.BETA) def update_filtering( self, *, @@ -1074,6 +1097,7 @@ def update_filtering( @_rewrite_parameters( body_fields=("validation",), ) + @_stability_warning(Stability.EXPERIMENTAL) def update_filtering_validation( self, *, @@ -1127,6 +1151,7 @@ def update_filtering_validation( @_rewrite_parameters( body_fields=("index_name",), ) + @_stability_warning(Stability.BETA) def update_index_name( self, *, @@ -1180,6 +1205,7 @@ def update_index_name( @_rewrite_parameters( body_fields=("description", "name"), ) + @_stability_warning(Stability.BETA) def update_name( self, *, @@ -1234,6 +1260,7 @@ def update_name( @_rewrite_parameters( body_fields=("is_native",), ) + @_stability_warning(Stability.BETA) def update_native( self, *, @@ -1286,6 +1313,7 @@ def update_native( @_rewrite_parameters( body_fields=("pipeline",), ) + @_stability_warning(Stability.BETA) def update_pipeline( self, *, @@ -1339,6 +1367,7 @@ def update_pipeline( @_rewrite_parameters( body_fields=("scheduling",), ) + @_stability_warning(Stability.BETA) def update_scheduling( self, *, @@ -1391,6 +1420,7 @@ def update_scheduling( @_rewrite_parameters( body_fields=("service_type",), ) + @_stability_warning(Stability.BETA) def update_service_type( self, *, @@ -1443,6 +1473,7 @@ def update_service_type( @_rewrite_parameters( body_fields=("status",), ) + @_stability_warning(Stability.EXPERIMENTAL) def update_status( self, *, diff --git a/elasticsearch/_sync/client/features.py b/elasticsearch/_sync/client/features.py index 5d95b3440..4386b4533 100644 --- a/elasticsearch/_sync/client/features.py +++ b/elasticsearch/_sync/client/features.py @@ -20,7 +20,7 @@ from elastic_transport import ObjectApiResponse from ._base import NamespacedClient -from .utils import _rewrite_parameters +from .utils import Stability, _rewrite_parameters, _stability_warning class FeaturesClient(NamespacedClient): @@ -62,6 +62,7 @@ def get_features( ) @_rewrite_parameters() + @_stability_warning(Stability.EXPERIMENTAL) def reset_features( self, *, diff --git a/elasticsearch/_sync/client/fleet.py b/elasticsearch/_sync/client/fleet.py index 001bcba36..2f9d6c186 100644 --- a/elasticsearch/_sync/client/fleet.py +++ b/elasticsearch/_sync/client/fleet.py @@ -20,7 +20,13 @@ from elastic_transport import ObjectApiResponse from ._base import NamespacedClient -from .utils import SKIP_IN_PATH, _quote, _rewrite_parameters +from .utils import ( + SKIP_IN_PATH, + Stability, + _quote, + _rewrite_parameters, + _stability_warning, +) class FleetClient(NamespacedClient): @@ -91,6 +97,7 @@ def global_checkpoints( @_rewrite_parameters( body_name="searches", ) + @_stability_warning(Stability.EXPERIMENTAL) def msearch( self, *, @@ -277,6 +284,7 @@ def msearch( "from": "from_", }, ) + @_stability_warning(Stability.EXPERIMENTAL) def search( self, *, diff --git a/elasticsearch/_sync/client/indices.py b/elasticsearch/_sync/client/indices.py index ef9d5a34a..b0dae49b4 100644 --- a/elasticsearch/_sync/client/indices.py +++ b/elasticsearch/_sync/client/indices.py @@ -20,7 +20,13 @@ from elastic_transport import HeadApiResponse, ObjectApiResponse from ._base import NamespacedClient -from .utils import SKIP_IN_PATH, _quote, _rewrite_parameters +from .utils import ( + SKIP_IN_PATH, + Stability, + _quote, + _rewrite_parameters, + _stability_warning, +) class IndicesClient(NamespacedClient): @@ -1032,6 +1038,7 @@ def delete_template( ) @_rewrite_parameters() + @_stability_warning(Stability.EXPERIMENTAL) def disk_usage( self, *, @@ -1114,6 +1121,7 @@ def disk_usage( @_rewrite_parameters( body_name="config", ) + @_stability_warning(Stability.EXPERIMENTAL) def downsample( self, *, @@ -1483,6 +1491,7 @@ def explain_data_lifecycle( ) @_rewrite_parameters() + @_stability_warning(Stability.EXPERIMENTAL) def field_usage_stats( self, *, diff --git a/elasticsearch/_sync/client/inference.py b/elasticsearch/_sync/client/inference.py index 2fc2a8de6..780db0aec 100644 --- a/elasticsearch/_sync/client/inference.py +++ b/elasticsearch/_sync/client/inference.py @@ -20,12 +20,19 @@ from elastic_transport import ObjectApiResponse from ._base import NamespacedClient -from .utils import SKIP_IN_PATH, _quote, _rewrite_parameters +from .utils import ( + SKIP_IN_PATH, + Stability, + _quote, + _rewrite_parameters, + _stability_warning, +) class InferenceClient(NamespacedClient): @_rewrite_parameters() + @_stability_warning(Stability.EXPERIMENTAL) def delete( self, *, @@ -93,6 +100,7 @@ def delete( ) @_rewrite_parameters() + @_stability_warning(Stability.EXPERIMENTAL) def get( self, *, @@ -151,6 +159,7 @@ def get( @_rewrite_parameters( body_fields=("input", "query", "task_settings"), ) + @_stability_warning(Stability.EXPERIMENTAL) def inference( self, *, @@ -237,6 +246,7 @@ def inference( @_rewrite_parameters( body_name="inference_config", ) + @_stability_warning(Stability.EXPERIMENTAL) def put( self, *, diff --git a/elasticsearch/_sync/client/ml.py b/elasticsearch/_sync/client/ml.py index df17aa247..d663ef4a7 100644 --- a/elasticsearch/_sync/client/ml.py +++ b/elasticsearch/_sync/client/ml.py @@ -20,7 +20,13 @@ from elastic_transport import ObjectApiResponse from ._base import NamespacedClient -from .utils import SKIP_IN_PATH, _quote, _rewrite_parameters +from .utils import ( + SKIP_IN_PATH, + Stability, + _quote, + _rewrite_parameters, + _stability_warning, +) class MlClient(NamespacedClient): @@ -2843,6 +2849,11 @@ def post_calendar_events( @_rewrite_parameters( body_name="data", ) + @_stability_warning( + Stability.DEPRECATED, + version="7.11.0", + message="Posting data directly to anomaly detection jobs is deprecated, in a future major version a datafeed will be required.", + ) def post_data( self, *, diff --git a/elasticsearch/_sync/client/nodes.py b/elasticsearch/_sync/client/nodes.py index 918bb8ced..97871cb53 100644 --- a/elasticsearch/_sync/client/nodes.py +++ b/elasticsearch/_sync/client/nodes.py @@ -20,12 +20,19 @@ from elastic_transport import ObjectApiResponse, TextApiResponse from ._base import NamespacedClient -from .utils import SKIP_IN_PATH, _quote, _rewrite_parameters +from .utils import ( + SKIP_IN_PATH, + Stability, + _quote, + _rewrite_parameters, + _stability_warning, +) class NodesClient(NamespacedClient): @_rewrite_parameters() + @_stability_warning(Stability.EXPERIMENTAL) def clear_repositories_metering_archive( self, *, @@ -76,6 +83,7 @@ def clear_repositories_metering_archive( ) @_rewrite_parameters() + @_stability_warning(Stability.EXPERIMENTAL) def get_repositories_metering_info( self, *, diff --git a/elasticsearch/_sync/client/rollup.py b/elasticsearch/_sync/client/rollup.py index 066427db5..e933f865d 100644 --- a/elasticsearch/_sync/client/rollup.py +++ b/elasticsearch/_sync/client/rollup.py @@ -20,12 +20,19 @@ from elastic_transport import ObjectApiResponse from ._base import NamespacedClient -from .utils import SKIP_IN_PATH, _quote, _rewrite_parameters +from .utils import ( + SKIP_IN_PATH, + Stability, + _quote, + _rewrite_parameters, + _stability_warning, +) class RollupClient(NamespacedClient): @_rewrite_parameters() + @_stability_warning(Stability.EXPERIMENTAL) def delete_job( self, *, @@ -66,6 +73,7 @@ def delete_job( ) @_rewrite_parameters() + @_stability_warning(Stability.EXPERIMENTAL) def get_jobs( self, *, @@ -110,6 +118,7 @@ def get_jobs( ) @_rewrite_parameters() + @_stability_warning(Stability.EXPERIMENTAL) def get_rollup_caps( self, *, @@ -155,6 +164,7 @@ def get_rollup_caps( ) @_rewrite_parameters() + @_stability_warning(Stability.EXPERIMENTAL) def get_rollup_index_caps( self, *, @@ -209,6 +219,7 @@ def get_rollup_index_caps( ), ignore_deprecated_options={"headers"}, ) + @_stability_warning(Stability.EXPERIMENTAL) def put_job( self, *, @@ -327,6 +338,7 @@ def put_job( @_rewrite_parameters( body_fields=("aggregations", "aggs", "query", "size"), ) + @_stability_warning(Stability.EXPERIMENTAL) def rollup_search( self, *, @@ -397,6 +409,7 @@ def rollup_search( ) @_rewrite_parameters() + @_stability_warning(Stability.EXPERIMENTAL) def start_job( self, *, @@ -437,6 +450,7 @@ def start_job( ) @_rewrite_parameters() + @_stability_warning(Stability.EXPERIMENTAL) def stop_job( self, *, diff --git a/elasticsearch/_sync/client/search_application.py b/elasticsearch/_sync/client/search_application.py index 69a186eb0..d13093fb0 100644 --- a/elasticsearch/_sync/client/search_application.py +++ b/elasticsearch/_sync/client/search_application.py @@ -20,12 +20,19 @@ from elastic_transport import ObjectApiResponse from ._base import NamespacedClient -from .utils import SKIP_IN_PATH, _quote, _rewrite_parameters +from .utils import ( + SKIP_IN_PATH, + Stability, + _quote, + _rewrite_parameters, + _stability_warning, +) class SearchApplicationClient(NamespacedClient): @_rewrite_parameters() + @_stability_warning(Stability.BETA) def delete( self, *, @@ -67,6 +74,7 @@ def delete( ) @_rewrite_parameters() + @_stability_warning(Stability.EXPERIMENTAL) def delete_behavioral_analytics( self, *, @@ -108,6 +116,7 @@ def delete_behavioral_analytics( ) @_rewrite_parameters() + @_stability_warning(Stability.BETA) def get( self, *, @@ -148,6 +157,7 @@ def get( ) @_rewrite_parameters() + @_stability_warning(Stability.EXPERIMENTAL) def get_behavioral_analytics( self, *, @@ -193,6 +203,7 @@ def get_behavioral_analytics( @_rewrite_parameters( parameter_aliases={"from": "from_"}, ) + @_stability_warning(Stability.BETA) def list( self, *, @@ -243,6 +254,7 @@ def list( @_rewrite_parameters( body_name="search_application", ) + @_stability_warning(Stability.BETA) def put( self, *, @@ -299,6 +311,7 @@ def put( ) @_rewrite_parameters() + @_stability_warning(Stability.EXPERIMENTAL) def put_behavioral_analytics( self, *, @@ -342,6 +355,7 @@ def put_behavioral_analytics( body_fields=("params",), ignore_deprecated_options={"params"}, ) + @_stability_warning(Stability.BETA) def search( self, *, diff --git a/elasticsearch/_sync/client/searchable_snapshots.py b/elasticsearch/_sync/client/searchable_snapshots.py index 823162b57..34384a6df 100644 --- a/elasticsearch/_sync/client/searchable_snapshots.py +++ b/elasticsearch/_sync/client/searchable_snapshots.py @@ -20,12 +20,19 @@ from elastic_transport import ObjectApiResponse from ._base import NamespacedClient -from .utils import SKIP_IN_PATH, _quote, _rewrite_parameters +from .utils import ( + SKIP_IN_PATH, + Stability, + _quote, + _rewrite_parameters, + _stability_warning, +) class SearchableSnapshotsClient(NamespacedClient): @_rewrite_parameters() + @_stability_warning(Stability.EXPERIMENTAL) def cache_stats( self, *, @@ -75,6 +82,7 @@ def cache_stats( ) @_rewrite_parameters() + @_stability_warning(Stability.EXPERIMENTAL) def clear_cache( self, *, diff --git a/elasticsearch/_sync/client/snapshot.py b/elasticsearch/_sync/client/snapshot.py index 1dc982ee5..0ffad7ff9 100644 --- a/elasticsearch/_sync/client/snapshot.py +++ b/elasticsearch/_sync/client/snapshot.py @@ -20,7 +20,13 @@ from elastic_transport import ObjectApiResponse from ._base import NamespacedClient -from .utils import SKIP_IN_PATH, _quote, _rewrite_parameters +from .utils import ( + SKIP_IN_PATH, + Stability, + _quote, + _rewrite_parameters, + _stability_warning, +) class SnapshotClient(NamespacedClient): @@ -617,6 +623,7 @@ def get_repository( ) @_rewrite_parameters() + @_stability_warning(Stability.EXPERIMENTAL) def repository_verify_integrity( self, *, diff --git a/elasticsearch/_sync/client/tasks.py b/elasticsearch/_sync/client/tasks.py index a0c4a742d..a12ebb1fa 100644 --- a/elasticsearch/_sync/client/tasks.py +++ b/elasticsearch/_sync/client/tasks.py @@ -20,12 +20,19 @@ from elastic_transport import ObjectApiResponse from ._base import NamespacedClient -from .utils import SKIP_IN_PATH, _quote, _rewrite_parameters +from .utils import ( + SKIP_IN_PATH, + Stability, + _quote, + _rewrite_parameters, + _stability_warning, +) class TasksClient(NamespacedClient): @_rewrite_parameters() + @_stability_warning(Stability.EXPERIMENTAL) def cancel( self, *, @@ -87,6 +94,7 @@ def cancel( ) @_rewrite_parameters() + @_stability_warning(Stability.EXPERIMENTAL) def get( self, *, @@ -138,6 +146,7 @@ def get( ) @_rewrite_parameters() + @_stability_warning(Stability.EXPERIMENTAL) def list( self, *, From 9d4eb4539e5be5793070786a41355b60660f95f8 Mon Sep 17 00:00:00 2001 From: Quentin Pradet Date: Thu, 7 Nov 2024 16:27:29 +0400 Subject: [PATCH 3/5] Stop warning about deprecated features When the server sends a warning in headers, we already surface it as an ElasticsearchWarning. --- elasticsearch/_async/client/__init__.py | 5 ----- elasticsearch/_async/client/ml.py | 13 +------------ elasticsearch/_sync/client/__init__.py | 5 ----- elasticsearch/_sync/client/ml.py | 13 +------------ elasticsearch/_sync/client/utils.py | 7 ------- test_elasticsearch/test_client/test_utils.py | 17 ----------------- 6 files changed, 2 insertions(+), 58 deletions(-) diff --git a/elasticsearch/_async/client/__init__.py b/elasticsearch/_async/client/__init__.py index efcbcfbca..d6b7360ec 100644 --- a/elasticsearch/_async/client/__init__.py +++ b/elasticsearch/_async/client/__init__.py @@ -2496,11 +2496,6 @@ async def info( ), parameter_aliases={"_source": "source"}, ) - @_stability_warning( - Stability.DEPRECATED, - version="8.4.0", - message="The kNN search API has been replaced by the `knn` option in the search API.", - ) async def knn_search( self, *, diff --git a/elasticsearch/_async/client/ml.py b/elasticsearch/_async/client/ml.py index 365ca7aad..be77a4c69 100644 --- a/elasticsearch/_async/client/ml.py +++ b/elasticsearch/_async/client/ml.py @@ -20,13 +20,7 @@ from elastic_transport import ObjectApiResponse from ._base import NamespacedClient -from .utils import ( - SKIP_IN_PATH, - Stability, - _quote, - _rewrite_parameters, - _stability_warning, -) +from .utils import SKIP_IN_PATH, _quote, _rewrite_parameters class MlClient(NamespacedClient): @@ -2849,11 +2843,6 @@ async def post_calendar_events( @_rewrite_parameters( body_name="data", ) - @_stability_warning( - Stability.DEPRECATED, - version="7.11.0", - message="Posting data directly to anomaly detection jobs is deprecated, in a future major version a datafeed will be required.", - ) async def post_data( self, *, diff --git a/elasticsearch/_sync/client/__init__.py b/elasticsearch/_sync/client/__init__.py index a3f5fdc25..6b099f17b 100644 --- a/elasticsearch/_sync/client/__init__.py +++ b/elasticsearch/_sync/client/__init__.py @@ -2494,11 +2494,6 @@ def info( ), parameter_aliases={"_source": "source"}, ) - @_stability_warning( - Stability.DEPRECATED, - version="8.4.0", - message="The kNN search API has been replaced by the `knn` option in the search API.", - ) def knn_search( self, *, diff --git a/elasticsearch/_sync/client/ml.py b/elasticsearch/_sync/client/ml.py index d663ef4a7..df17aa247 100644 --- a/elasticsearch/_sync/client/ml.py +++ b/elasticsearch/_sync/client/ml.py @@ -20,13 +20,7 @@ from elastic_transport import ObjectApiResponse from ._base import NamespacedClient -from .utils import ( - SKIP_IN_PATH, - Stability, - _quote, - _rewrite_parameters, - _stability_warning, -) +from .utils import SKIP_IN_PATH, _quote, _rewrite_parameters class MlClient(NamespacedClient): @@ -2849,11 +2843,6 @@ def post_calendar_events( @_rewrite_parameters( body_name="data", ) - @_stability_warning( - Stability.DEPRECATED, - version="7.11.0", - message="Posting data directly to anomaly detection jobs is deprecated, in a future major version a datafeed will be required.", - ) def post_data( self, *, diff --git a/elasticsearch/_sync/client/utils.py b/elasticsearch/_sync/client/utils.py index 42f9118e0..959f61bfd 100644 --- a/elasticsearch/_sync/client/utils.py +++ b/elasticsearch/_sync/client/utils.py @@ -78,7 +78,6 @@ class Stability(Enum): STABLE = auto() BETA = auto() EXPERIMENTAL = auto() - DEPRECATED = auto() _TYPE_HOSTS = Union[ @@ -484,12 +483,6 @@ def wrapped(*args: Any, **kwargs: Any) -> Any: category=GeneralAvailabilityWarning, stacklevel=warn_stacklevel(), ) - elif stability == Stability.DEPRECATED: - warnings.warn( - f"This API was deprecated in Elasticsearch {version}. {message}", - category=DeprecationWarning, - stacklevel=warn_stacklevel(), - ) return api(*args, **kwargs) diff --git a/test_elasticsearch/test_client/test_utils.py b/test_elasticsearch/test_client/test_utils.py index 90f8b106a..9bba9d951 100644 --- a/test_elasticsearch/test_client/test_utils.py +++ b/test_elasticsearch/test_client/test_utils.py @@ -81,20 +81,3 @@ def func_experimental(*args, **kwargs): assert user_warning.message.args[0].startswith( "This API is in technical preview and may be changed or removed in a future release." ) - - def test_deprecated(self, recwarn): - - @_stability_warning( - stability=Stability.DEPRECATED, version="8.4.0", message="Use bar instead." - ) - def func_deprecated(*args, **kwargs): - pass - - func_deprecated() - - assert len(recwarn) == 1 - user_warning = recwarn.pop(DeprecationWarning) - assert user_warning.category == DeprecationWarning - assert user_warning.message.args[0] == ( - "This API was deprecated in Elasticsearch 8.4.0. Use bar instead." - ) From fdc87c643f9514c0c5791a4055a819c1cd68853a Mon Sep 17 00:00:00 2001 From: Quentin Pradet Date: Thu, 7 Nov 2024 17:03:04 +0400 Subject: [PATCH 4/5] Show actual warnings raised on failure --- test_elasticsearch/test_client/test_utils.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test_elasticsearch/test_client/test_utils.py b/test_elasticsearch/test_client/test_utils.py index 9bba9d951..245f3506f 100644 --- a/test_elasticsearch/test_client/test_utils.py +++ b/test_elasticsearch/test_client/test_utils.py @@ -60,7 +60,7 @@ def func_beta(*args, **kwargs): func_beta() - assert len(recwarn) == 1 + assert len(recwarn) == 1, [w.message for w in recwarn] user_warning = recwarn.pop(GeneralAvailabilityWarning) assert user_warning.category == GeneralAvailabilityWarning assert user_warning.message.args[0].startswith( @@ -75,7 +75,7 @@ def func_experimental(*args, **kwargs): func_experimental() - assert len(recwarn) == 1 + assert len(recwarn) == 1, [w.message for w in recwarn] user_warning = recwarn.pop(GeneralAvailabilityWarning) assert user_warning.category == GeneralAvailabilityWarning assert user_warning.message.args[0].startswith( From 317df991c321c71d19c871a0fed4f2108c91dfde Mon Sep 17 00:00:00 2001 From: Quentin Pradet Date: Thu, 7 Nov 2024 17:27:10 +0400 Subject: [PATCH 5/5] Switch to pytest.warns to not catch unrelated warnings --- test_elasticsearch/test_client/test_utils.py | 28 +++++++++----------- 1 file changed, 12 insertions(+), 16 deletions(-) diff --git a/test_elasticsearch/test_client/test_utils.py b/test_elasticsearch/test_client/test_utils.py index 245f3506f..e4713ff1c 100644 --- a/test_elasticsearch/test_client/test_utils.py +++ b/test_elasticsearch/test_client/test_utils.py @@ -18,6 +18,8 @@ import warnings +import pytest + from elasticsearch._sync.client.utils import Stability, _quote, _stability_warning from elasticsearch.exceptions import GeneralAvailabilityWarning @@ -58,14 +60,11 @@ def test_beta(self, recwarn): def func_beta(*args, **kwargs): pass - func_beta() - - assert len(recwarn) == 1, [w.message for w in recwarn] - user_warning = recwarn.pop(GeneralAvailabilityWarning) - assert user_warning.category == GeneralAvailabilityWarning - assert user_warning.message.args[0].startswith( - "This API is in beta and is subject to change." - ) + with pytest.warns( + GeneralAvailabilityWarning, + match="This API is in beta and is subject to change.", + ): + func_beta() def test_experimental(self, recwarn): @@ -73,11 +72,8 @@ def test_experimental(self, recwarn): def func_experimental(*args, **kwargs): pass - func_experimental() - - assert len(recwarn) == 1, [w.message for w in recwarn] - user_warning = recwarn.pop(GeneralAvailabilityWarning) - assert user_warning.category == GeneralAvailabilityWarning - assert user_warning.message.args[0].startswith( - "This API is in technical preview and may be changed or removed in a future release." - ) + with pytest.warns( + GeneralAvailabilityWarning, + match="This API is in technical preview and may be changed or removed in a future release.", + ): + func_experimental()