From b83163b2d3ac4cbecda84240c3fa2c8fa4889e1a Mon Sep 17 00:00:00 2001 From: Josh Mock Date: Mon, 25 Sep 2023 14:49:09 -0500 Subject: [PATCH] Add support for 410 Gone --- docs/sphinx/exceptions.rst | 1 + elasticsearch/__init__.py | 2 ++ elasticsearch/exceptions.py | 6 ++++++ 3 files changed, 9 insertions(+) diff --git a/docs/sphinx/exceptions.rst b/docs/sphinx/exceptions.rst index 32c01d6cb..ff46d7fa5 100644 --- a/docs/sphinx/exceptions.rst +++ b/docs/sphinx/exceptions.rst @@ -17,6 +17,7 @@ These errors are triggered from an HTTP response that isn't 2XX: .. autoclass:: RequestError .. autoclass:: AuthenticationException .. autoclass:: AuthorizationException +.. autoclass:: ApiUnavailableException .. autoclass:: UnsupportedProductError Transport and Connection Errors diff --git a/elasticsearch/__init__.py b/elasticsearch/__init__.py index 8b38b3934..8e1e36fd7 100644 --- a/elasticsearch/__init__.py +++ b/elasticsearch/__init__.py @@ -47,6 +47,7 @@ from .exceptions import ElasticsearchDeprecationWarning # noqa: F401 from .exceptions import ( ApiError, + ApiUnavailableException, AuthenticationException, AuthorizationException, BadRequestError, @@ -69,6 +70,7 @@ __all__ = [ "ApiError", + "ApiUnavailableException", "AsyncElasticsearch", "BadRequestError", "Elasticsearch", diff --git a/elasticsearch/exceptions.py b/elasticsearch/exceptions.py index f58706774..05ee6658c 100644 --- a/elasticsearch/exceptions.py +++ b/elasticsearch/exceptions.py @@ -36,6 +36,7 @@ "NotFoundError", "ConflictError", "BadRequestError", + "ApiUnavailableException", ] @@ -109,6 +110,10 @@ class AuthorizationException(ApiError): """Exception representing a 403 status code.""" +class ApiUnavailableException(ApiError): + """Exception representing a 410 status code.""" + + class ElasticsearchWarning(TransportWarning): """Warning that is raised when a deprecated option or incorrect usage is flagged via the 'Warning' HTTP header. @@ -126,4 +131,5 @@ class ElasticsearchWarning(TransportWarning): 403: AuthorizationException, 404: NotFoundError, 409: ConflictError, + 410: ApiUnavailableException, }