diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index e8e25f7b..899d2256 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -52,7 +52,7 @@ The process for contributing to any of the Elasticsearch repositories is similar $ python -m pip install nox # Auto-format and lint your changes - $ nox -s blacken + $ nox -s format # Run the test suite $ python setup.py test diff --git a/dev-requirements.txt b/dev-requirements.txt index 732fc4d2..66d63490 100644 --- a/dev-requirements.txt +++ b/dev-requirements.txt @@ -13,6 +13,7 @@ pandas # not amending that requirement to the package. :( pyyaml<5.3 +isort black; python_version>="3.6" twine diff --git a/docs/sphinx/xpack.rst b/docs/sphinx/xpack.rst index e60ece7b..1502e17c 100644 --- a/docs/sphinx/xpack.rst +++ b/docs/sphinx/xpack.rst @@ -166,6 +166,16 @@ to encrypt communications in your Elasticsearch cluster. .. autoclass:: SslClient :members: +Text Structure +-------------- + +`Text Structure API `_ +finds the structure of a text file. The text file must contain data that is +suitable to be ingested into Elasticsearch. + +.. autoclass:: TextStructureClient + :members: + Transform --------- diff --git a/elasticsearch/__init__.py b/elasticsearch/__init__.py index 7dc7be74..05f16398 100644 --- a/elasticsearch/__init__.py +++ b/elasticsearch/__init__.py @@ -18,9 +18,9 @@ # flake8: noqa from __future__ import absolute_import +import logging import re import sys -import logging import warnings from ._version import __versionstr__ @@ -34,26 +34,26 @@ logger = logging.getLogger("elasticsearch") logger.addHandler(logging.NullHandler()) from .client import Elasticsearch -from .transport import Transport -from .connection_pool import ConnectionPool, ConnectionSelector, RoundRobinSelector -from .serializer import JSONSerializer from .connection import Connection, RequestsHttpConnection, Urllib3HttpConnection +from .connection_pool import ConnectionPool, ConnectionSelector, RoundRobinSelector from .exceptions import ( - ImproperlyConfigured, - ElasticsearchException, - SerializationError, - TransportError, - NotFoundError, - ConflictError, - RequestError, - ConnectionError, - SSLError, - ConnectionTimeout, AuthenticationException, AuthorizationException, - ElasticsearchWarning, + ConflictError, + ConnectionError, + ConnectionTimeout, ElasticsearchDeprecationWarning, + ElasticsearchException, + ElasticsearchWarning, + ImproperlyConfigured, + NotFoundError, + RequestError, + SerializationError, + SSLError, + TransportError, ) +from .serializer import JSONSerializer +from .transport import Transport # Only raise one warning per deprecation message so as not # to spam up the user if the same action is done multiple times. @@ -90,9 +90,9 @@ try: if sys.version_info < (3, 6): raise ImportError + from ._async.client import AsyncElasticsearch from ._async.http_aiohttp import AIOHttpConnection, AsyncConnection from ._async.transport import AsyncTransport - from ._async.client import AsyncElasticsearch __all__ += [ "AIOHttpConnection", diff --git a/elasticsearch/__init__.pyi b/elasticsearch/__init__.pyi index 63cabf85..20a60aa2 100644 --- a/elasticsearch/__init__.pyi +++ b/elasticsearch/__init__.pyi @@ -19,41 +19,37 @@ import sys from typing import Tuple from .client import Elasticsearch as Elasticsearch -from .transport import Transport as Transport -from .connection_pool import ( - ConnectionPool as ConnectionPool, - ConnectionSelector as ConnectionSelector, - RoundRobinSelector as RoundRobinSelector, -) -from .serializer import JSONSerializer as JSONSerializer -from .connection import ( - Connection as Connection, - RequestsHttpConnection as RequestsHttpConnection, - Urllib3HttpConnection as Urllib3HttpConnection, -) +from .connection import Connection as Connection +from .connection import RequestsHttpConnection as RequestsHttpConnection +from .connection import Urllib3HttpConnection as Urllib3HttpConnection +from .connection_pool import ConnectionPool as ConnectionPool +from .connection_pool import ConnectionSelector as ConnectionSelector +from .connection_pool import RoundRobinSelector as RoundRobinSelector +from .exceptions import AuthenticationException as AuthenticationException +from .exceptions import AuthorizationException as AuthorizationException +from .exceptions import ConflictError as ConflictError +from .exceptions import ConnectionError as ConnectionError +from .exceptions import ConnectionTimeout as ConnectionTimeout from .exceptions import ( - ImproperlyConfigured as ImproperlyConfigured, - ElasticsearchException as ElasticsearchException, - SerializationError as SerializationError, - TransportError as TransportError, - NotFoundError as NotFoundError, - ConflictError as ConflictError, - RequestError as RequestError, - ConnectionError as ConnectionError, - SSLError as SSLError, - ConnectionTimeout as ConnectionTimeout, - AuthenticationException as AuthenticationException, - AuthorizationException as AuthorizationException, ElasticsearchDeprecationWarning as ElasticsearchDeprecationWarning, ) +from .exceptions import ElasticsearchException as ElasticsearchException +from .exceptions import ImproperlyConfigured as ImproperlyConfigured +from .exceptions import NotFoundError as NotFoundError +from .exceptions import RequestError as RequestError +from .exceptions import SerializationError as SerializationError +from .exceptions import SSLError as SSLError +from .exceptions import TransportError as TransportError +from .serializer import JSONSerializer as JSONSerializer +from .transport import Transport as Transport try: if sys.version_info < (3, 6): raise ImportError + from ._async.client import AsyncElasticsearch as AsyncElasticsearch from ._async.http_aiohttp import AIOHttpConnection as AIOHttpConnection from ._async.transport import AsyncTransport as AsyncTransport - from ._async.client import AsyncElasticsearch as AsyncElasticsearch except (ImportError, SyntaxError): pass diff --git a/elasticsearch/_async/_extra_imports.py b/elasticsearch/_async/_extra_imports.py index aa74e771..9877b368 100644 --- a/elasticsearch/_async/_extra_imports.py +++ b/elasticsearch/_async/_extra_imports.py @@ -32,7 +32,6 @@ import aiohttp import aiohttp.client_exceptions as aiohttp_exceptions - # We do this because we don't explicitly require 'yarl' # within our [async] extra any more. # See AIOHttpConnection.request() for more information why. diff --git a/elasticsearch/_async/client/__init__.py b/elasticsearch/_async/client/__init__.py index 2eb2a64b..14051695 100644 --- a/elasticsearch/_async/client/__init__.py +++ b/elasticsearch/_async/client/__init__.py @@ -17,45 +17,45 @@ # under the License. from __future__ import unicode_literals + import logging from ..transport import AsyncTransport, TransportError -from .utils import query_params, _make_path, SKIP_IN_PATH, _bulk_body, _normalize_hosts - from .async_search import AsyncSearchClient from .autoscaling import AutoscalingClient from .cat import CatClient +from .ccr import CcrClient from .cluster import ClusterClient from .dangling_indices import DanglingIndicesClient -from .indices import IndicesClient -from .ingest import IngestClient -from .nodes import NodesClient -from .remote import RemoteClient -from .snapshot import SnapshotClient -from .tasks import TasksClient - -# xpack APIs -from .xpack import XPackClient -from .ccr import CcrClient from .data_frame import Data_FrameClient from .deprecation import DeprecationClient from .enrich import EnrichClient from .eql import EqlClient from .graph import GraphClient from .ilm import IlmClient +from .indices import IndicesClient +from .ingest import IngestClient from .license import LicenseClient from .migration import MigrationClient from .ml import MlClient from .monitoring import MonitoringClient +from .nodes import NodesClient +from .remote import RemoteClient from .rollup import RollupClient from .searchable_snapshots import SearchableSnapshotsClient from .security import SecurityClient from .slm import SlmClient +from .snapshot import SnapshotClient from .sql import SqlClient from .ssl import SslClient +from .tasks import TasksClient +from .text_structure import TextStructureClient from .transform import TransformClient +from .utils import SKIP_IN_PATH, _bulk_body, _make_path, _normalize_hosts, query_params from .watcher import WatcherClient +# xpack APIs +from .xpack import XPackClient logger = logging.getLogger("elasticsearch") @@ -233,6 +233,7 @@ class AsyncElasticsearch(object): self.slm = SlmClient(self) self.sql = SqlClient(self) self.ssl = SslClient(self) + self.text_structure = TextStructureClient(self) self.transform = TransformClient(self) self.watcher = WatcherClient(self) @@ -1534,6 +1535,7 @@ class AsyncElasticsearch(object): "ignore_unavailable", "lenient", "max_concurrent_shard_requests", + "min_compatible_shard_node", "pre_filter_shard_size", "preference", "q", @@ -1616,6 +1618,9 @@ class AsyncElasticsearch(object): shard requests per node this search executes concurrently. This value should be used to limit the impact of the search on the cluster in order to limit the number of concurrent shard requests Default: 5 + :arg min_compatible_shard_node: The minimum compatible version + that all shards involved in search should have for this request to be + successful :arg pre_filter_shard_size: A threshold that enforces a pre- filter roundtrip to prefilter search shards based on query rewriting if the number of shards the search request expands to exceeds the diff --git a/elasticsearch/_async/client/__init__.pyi b/elasticsearch/_async/client/__init__.pyi index 47052a4d..ab91f140 100644 --- a/elasticsearch/_async/client/__init__.pyi +++ b/elasticsearch/_async/client/__init__.pyi @@ -17,43 +17,44 @@ # under the License. from __future__ import unicode_literals + import logging -from typing import Any, MutableMapping, Optional, Type, Union, Collection +from typing import Any, Collection, MutableMapping, Optional, Type, Union from ..transport import AsyncTransport - from .async_search import AsyncSearchClient from .autoscaling import AutoscalingClient from .cat import CatClient +from .ccr import CcrClient from .cluster import ClusterClient from .dangling_indices import DanglingIndicesClient -from .indices import IndicesClient -from .ingest import IngestClient -from .nodes import NodesClient -from .remote import RemoteClient -from .snapshot import SnapshotClient -from .tasks import TasksClient - -# xpack APIs -from .xpack import XPackClient -from .ccr import CcrClient from .enrich import EnrichClient from .eql import EqlClient from .graph import GraphClient from .ilm import IlmClient +from .indices import IndicesClient +from .ingest import IngestClient from .license import LicenseClient from .migration import MigrationClient from .ml import MlClient from .monitoring import MonitoringClient +from .nodes import NodesClient +from .remote import RemoteClient from .rollup import RollupClient from .searchable_snapshots import SearchableSnapshotsClient from .security import SecurityClient from .slm import SlmClient +from .snapshot import SnapshotClient from .sql import SqlClient from .ssl import SslClient +from .tasks import TasksClient +from .text_structure import TextStructureClient from .transform import TransformClient from .watcher import WatcherClient +# xpack APIs +from .xpack import XPackClient + logger: logging.Logger class AsyncElasticsearch(object): @@ -88,6 +89,7 @@ class AsyncElasticsearch(object): sql: SqlClient ssl: SslClient transform: TransformClient + text_structure: TextStructureClient watcher: WatcherClient def __init__( self, @@ -788,6 +790,7 @@ class AsyncElasticsearch(object): ignore_unavailable: Optional[Any] = ..., lenient: Optional[Any] = ..., max_concurrent_shard_requests: Optional[Any] = ..., + min_compatible_shard_node: Optional[Any] = ..., pre_filter_shard_size: Optional[Any] = ..., preference: Optional[Any] = ..., q: Optional[Any] = ..., diff --git a/elasticsearch/_async/client/async_search.py b/elasticsearch/_async/client/async_search.py index 599c8ad5..d37bbe9e 100644 --- a/elasticsearch/_async/client/async_search.py +++ b/elasticsearch/_async/client/async_search.py @@ -15,7 +15,7 @@ # specific language governing permissions and limitations # under the License. -from .utils import NamespacedClient, SKIP_IN_PATH, query_params, _make_path +from .utils import SKIP_IN_PATH, NamespacedClient, _make_path, query_params class AsyncSearchClient(NamespacedClient): diff --git a/elasticsearch/_async/client/async_search.pyi b/elasticsearch/_async/client/async_search.pyi index cd9ecaa6..806e88ac 100644 --- a/elasticsearch/_async/client/async_search.pyi +++ b/elasticsearch/_async/client/async_search.pyi @@ -15,7 +15,8 @@ # specific language governing permissions and limitations # under the License. -from typing import Any, MutableMapping, Optional, Union, Collection +from typing import Any, Collection, MutableMapping, Optional, Union + from .utils import NamespacedClient class AsyncSearchClient(NamespacedClient): diff --git a/elasticsearch/_async/client/autoscaling.py b/elasticsearch/_async/client/autoscaling.py index cb335b15..290d4bce 100644 --- a/elasticsearch/_async/client/autoscaling.py +++ b/elasticsearch/_async/client/autoscaling.py @@ -15,22 +15,18 @@ # specific language governing permissions and limitations # under the License. -from .utils import NamespacedClient, query_params, SKIP_IN_PATH, _make_path +from .utils import SKIP_IN_PATH, NamespacedClient, _make_path, query_params class AutoscalingClient(NamespacedClient): @query_params() async def delete_autoscaling_policy(self, name, params=None, headers=None): """ - Deletes an autoscaling policy. + Deletes an autoscaling policy. Designed for indirect use by ECE/ESS and ECK. + Direct use is not supported. ``_ - .. warning:: - - This API is **experimental** so may include breaking changes - or be removed in a future version - :arg name: the name of the autoscaling policy """ if name in SKIP_IN_PATH: @@ -46,15 +42,11 @@ class AutoscalingClient(NamespacedClient): @query_params() async def get_autoscaling_policy(self, name, params=None, headers=None): """ - Retrieves an autoscaling policy. + Retrieves an autoscaling policy. Designed for indirect use by ECE/ESS and ECK. + Direct use is not supported. ``_ - .. warning:: - - This API is **experimental** so may include breaking changes - or be removed in a future version - :arg name: the name of the autoscaling policy """ if name in SKIP_IN_PATH: @@ -70,15 +62,11 @@ class AutoscalingClient(NamespacedClient): @query_params() async def put_autoscaling_policy(self, name, body, params=None, headers=None): """ - Creates a new autoscaling policy. + Creates a new autoscaling policy. Designed for indirect use by ECE/ESS and ECK. + Direct use is not supported. ``_ - .. warning:: - - This API is **experimental** so may include breaking changes - or be removed in a future version - :arg name: the name of the autoscaling policy :arg body: the specification of the autoscaling policy """ @@ -98,14 +86,10 @@ class AutoscalingClient(NamespacedClient): async def get_autoscaling_capacity(self, params=None, headers=None): """ Gets the current autoscaling capacity based on the configured autoscaling - policy. + policy. Designed for indirect use by ECE/ESS and ECK. Direct use is not + supported. ``_ - - .. warning:: - - This API is **experimental** so may include breaking changes - or be removed in a future version """ return await self.transport.perform_request( "GET", "/_autoscaling/capacity", params=params, headers=headers diff --git a/elasticsearch/_async/client/autoscaling.pyi b/elasticsearch/_async/client/autoscaling.pyi index 1d7482b3..3adf4e3c 100644 --- a/elasticsearch/_async/client/autoscaling.pyi +++ b/elasticsearch/_async/client/autoscaling.pyi @@ -15,7 +15,8 @@ # specific language governing permissions and limitations # under the License. -from typing import Any, MutableMapping, Optional, Union, Collection +from typing import Any, Collection, MutableMapping, Optional, Union + from .utils import NamespacedClient class AutoscalingClient(NamespacedClient): diff --git a/elasticsearch/_async/client/cat.py b/elasticsearch/_async/client/cat.py index 2e32dc97..ed2f7d0c 100644 --- a/elasticsearch/_async/client/cat.py +++ b/elasticsearch/_async/client/cat.py @@ -15,7 +15,7 @@ # specific language governing permissions and limitations # under the License. -from .utils import NamespacedClient, query_params, _make_path +from .utils import NamespacedClient, _make_path, query_params class CatClient(NamespacedClient): @@ -420,7 +420,9 @@ class CatClient(NamespacedClient): headers=headers, ) - @query_params("format", "h", "help", "local", "master_timeout", "s", "v") + @query_params( + "format", "h", "help", "include_bootstrap", "local", "master_timeout", "s", "v" + ) async def plugins(self, params=None, headers=None): """ Returns information about installed plugins across nodes node. @@ -431,6 +433,8 @@ class CatClient(NamespacedClient): yaml :arg h: Comma-separated list of column names to display :arg help: Return help information + :arg include_bootstrap: Include bootstrap plugins in the + response :arg local: Return local information, do not retrieve the state from master node (default: false) :arg master_timeout: Explicit operation timeout for connection @@ -527,8 +531,8 @@ class CatClient(NamespacedClient): "format", "h", "help", - "node_id", - "parent_task", + "nodes", + "parent_task_id", "s", "time", "v", @@ -547,12 +551,11 @@ class CatClient(NamespacedClient): yaml :arg h: Comma-separated list of column names to display :arg help: Return help information - :arg node_id: A comma-separated list of node IDs or names to - limit the returned information; use `_local` to return information from - the node you're connecting to, leave empty to get information from all - nodes - :arg parent_task: Return tasks with specified parent task id. - Set to -1 to return all. + :arg nodes: A comma-separated list of node IDs or names to limit + the returned information; use `_local` to return information from the + node you're connecting to, leave empty to get information from all nodes + :arg parent_task_id: Return tasks with specified parent task id + (node_id:task_number). Set to -1 to return all. :arg s: Comma-separated list of column names or column aliases to sort by :arg time: The unit in which to display time values Valid diff --git a/elasticsearch/_async/client/cat.pyi b/elasticsearch/_async/client/cat.pyi index e9c4a49b..6ba185df 100644 --- a/elasticsearch/_async/client/cat.pyi +++ b/elasticsearch/_async/client/cat.pyi @@ -15,7 +15,8 @@ # specific language governing permissions and limitations # under the License. -from typing import Any, MutableMapping, Optional, Union, Collection +from typing import Any, Collection, MutableMapping, Optional, Union + from .utils import NamespacedClient class CatClient(NamespacedClient): @@ -322,6 +323,7 @@ class CatClient(NamespacedClient): format: Optional[Any] = ..., h: Optional[Any] = ..., help: Optional[Any] = ..., + include_bootstrap: Optional[Any] = ..., local: Optional[Any] = ..., master_timeout: Optional[Any] = ..., s: Optional[Any] = ..., @@ -406,8 +408,8 @@ class CatClient(NamespacedClient): format: Optional[Any] = ..., h: Optional[Any] = ..., help: Optional[Any] = ..., - node_id: Optional[Any] = ..., - parent_task: Optional[Any] = ..., + nodes: Optional[Any] = ..., + parent_task_id: Optional[Any] = ..., s: Optional[Any] = ..., time: Optional[Any] = ..., v: Optional[Any] = ..., diff --git a/elasticsearch/_async/client/ccr.py b/elasticsearch/_async/client/ccr.py index 683f55ce..edccae1c 100644 --- a/elasticsearch/_async/client/ccr.py +++ b/elasticsearch/_async/client/ccr.py @@ -15,7 +15,7 @@ # specific language governing permissions and limitations # under the License. -from .utils import NamespacedClient, query_params, _make_path, SKIP_IN_PATH +from .utils import SKIP_IN_PATH, NamespacedClient, _make_path, query_params class CcrClient(NamespacedClient): diff --git a/elasticsearch/_async/client/ccr.pyi b/elasticsearch/_async/client/ccr.pyi index d2c085a2..34120e45 100644 --- a/elasticsearch/_async/client/ccr.pyi +++ b/elasticsearch/_async/client/ccr.pyi @@ -15,7 +15,8 @@ # specific language governing permissions and limitations # under the License. -from typing import Any, MutableMapping, Optional, Union, Collection +from typing import Any, Collection, MutableMapping, Optional, Union + from .utils import NamespacedClient class CcrClient(NamespacedClient): diff --git a/elasticsearch/_async/client/cluster.py b/elasticsearch/_async/client/cluster.py index 8d817156..e47fb31a 100644 --- a/elasticsearch/_async/client/cluster.py +++ b/elasticsearch/_async/client/cluster.py @@ -15,7 +15,7 @@ # specific language governing permissions and limitations # under the License. -from .utils import NamespacedClient, query_params, _make_path, SKIP_IN_PATH +from .utils import SKIP_IN_PATH, NamespacedClient, _make_path, query_params class ClusterClient(NamespacedClient): diff --git a/elasticsearch/_async/client/cluster.pyi b/elasticsearch/_async/client/cluster.pyi index c70bd548..99fc1ccb 100644 --- a/elasticsearch/_async/client/cluster.pyi +++ b/elasticsearch/_async/client/cluster.pyi @@ -15,7 +15,8 @@ # specific language governing permissions and limitations # under the License. -from typing import Any, MutableMapping, Optional, Union, Collection +from typing import Any, Collection, MutableMapping, Optional, Union + from .utils import NamespacedClient class ClusterClient(NamespacedClient): diff --git a/elasticsearch/_async/client/dangling_indices.py b/elasticsearch/_async/client/dangling_indices.py index 34b21bce..86f8682a 100644 --- a/elasticsearch/_async/client/dangling_indices.py +++ b/elasticsearch/_async/client/dangling_indices.py @@ -15,7 +15,7 @@ # specific language governing permissions and limitations # under the License. -from .utils import NamespacedClient, SKIP_IN_PATH, query_params, _make_path +from .utils import SKIP_IN_PATH, NamespacedClient, _make_path, query_params class DanglingIndicesClient(NamespacedClient): diff --git a/elasticsearch/_async/client/dangling_indices.pyi b/elasticsearch/_async/client/dangling_indices.pyi index 5cc699d5..df5b7449 100644 --- a/elasticsearch/_async/client/dangling_indices.pyi +++ b/elasticsearch/_async/client/dangling_indices.pyi @@ -15,7 +15,8 @@ # specific language governing permissions and limitations # under the License. -from typing import Any, MutableMapping, Optional, Union, Collection +from typing import Any, Collection, MutableMapping, Optional, Union + from .utils import NamespacedClient class DanglingIndicesClient(NamespacedClient): diff --git a/elasticsearch/_async/client/data_frame.py b/elasticsearch/_async/client/data_frame.py index f52391af..e442d24a 100644 --- a/elasticsearch/_async/client/data_frame.py +++ b/elasticsearch/_async/client/data_frame.py @@ -15,7 +15,7 @@ # specific language governing permissions and limitations # under the License. -from .utils import NamespacedClient, query_params, _make_path, SKIP_IN_PATH +from .utils import SKIP_IN_PATH, NamespacedClient, _make_path, query_params class Data_FrameClient(NamespacedClient): diff --git a/elasticsearch/_async/client/data_frame.pyi b/elasticsearch/_async/client/data_frame.pyi index 3b7ed9d7..6c6a30f3 100644 --- a/elasticsearch/_async/client/data_frame.pyi +++ b/elasticsearch/_async/client/data_frame.pyi @@ -15,7 +15,8 @@ # specific language governing permissions and limitations # under the License. -from typing import Any, MutableMapping, Optional, Union, Collection +from typing import Any, Collection, MutableMapping, Optional, Union + from .utils import NamespacedClient class Data_FrameClient(NamespacedClient): diff --git a/elasticsearch/_async/client/deprecation.py b/elasticsearch/_async/client/deprecation.py index 05a9886c..710d292d 100644 --- a/elasticsearch/_async/client/deprecation.py +++ b/elasticsearch/_async/client/deprecation.py @@ -15,7 +15,7 @@ # specific language governing permissions and limitations # under the License. -from .utils import NamespacedClient, query_params, _make_path +from .utils import NamespacedClient, _make_path, query_params class DeprecationClient(NamespacedClient): diff --git a/elasticsearch/_async/client/deprecation.pyi b/elasticsearch/_async/client/deprecation.pyi index ebfaf6b6..be3fa8fb 100644 --- a/elasticsearch/_async/client/deprecation.pyi +++ b/elasticsearch/_async/client/deprecation.pyi @@ -15,7 +15,8 @@ # specific language governing permissions and limitations # under the License. -from typing import Any, MutableMapping, Optional, Union, Collection +from typing import Any, Collection, MutableMapping, Optional, Union + from .utils import NamespacedClient class DeprecationClient(NamespacedClient): diff --git a/elasticsearch/_async/client/enrich.py b/elasticsearch/_async/client/enrich.py index 02de6f5d..72474dfa 100644 --- a/elasticsearch/_async/client/enrich.py +++ b/elasticsearch/_async/client/enrich.py @@ -15,7 +15,7 @@ # specific language governing permissions and limitations # under the License. -from .utils import NamespacedClient, query_params, _make_path, SKIP_IN_PATH +from .utils import SKIP_IN_PATH, NamespacedClient, _make_path, query_params class EnrichClient(NamespacedClient): diff --git a/elasticsearch/_async/client/enrich.pyi b/elasticsearch/_async/client/enrich.pyi index a0c12b2f..3d17f835 100644 --- a/elasticsearch/_async/client/enrich.pyi +++ b/elasticsearch/_async/client/enrich.pyi @@ -15,7 +15,8 @@ # specific language governing permissions and limitations # under the License. -from typing import Any, MutableMapping, Optional, Union, Collection +from typing import Any, Collection, MutableMapping, Optional, Union + from .utils import NamespacedClient class EnrichClient(NamespacedClient): diff --git a/elasticsearch/_async/client/eql.py b/elasticsearch/_async/client/eql.py index a30cdb6c..0048071c 100644 --- a/elasticsearch/_async/client/eql.py +++ b/elasticsearch/_async/client/eql.py @@ -15,7 +15,7 @@ # specific language governing permissions and limitations # under the License. -from .utils import NamespacedClient, SKIP_IN_PATH, query_params, _make_path +from .utils import SKIP_IN_PATH, NamespacedClient, _make_path, query_params class EqlClient(NamespacedClient): @@ -26,11 +26,6 @@ class EqlClient(NamespacedClient): ``_ - .. warning:: - - This API is **beta** so may include breaking changes - or be removed in a future version - :arg index: The name of the index to scope the operation :arg body: Eql request body. Use the `query` to limit the query scope. @@ -62,11 +57,6 @@ class EqlClient(NamespacedClient): ``_ - .. warning:: - - This API is **beta** so may include breaking changes - or be removed in a future version - :arg id: The async search ID """ if id in SKIP_IN_PATH: @@ -84,11 +74,6 @@ class EqlClient(NamespacedClient): ``_ - .. warning:: - - This API is **beta** so may include breaking changes - or be removed in a future version - :arg id: The async search ID :arg keep_alive: Update the time interval in which the results (partial or final) for this search will be available Default: 5d diff --git a/elasticsearch/_async/client/eql.pyi b/elasticsearch/_async/client/eql.pyi index 1eec5ca5..2110cb65 100644 --- a/elasticsearch/_async/client/eql.pyi +++ b/elasticsearch/_async/client/eql.pyi @@ -15,7 +15,8 @@ # specific language governing permissions and limitations # under the License. -from typing import Any, MutableMapping, Optional, Union, Collection +from typing import Any, Collection, MutableMapping, Optional, Union + from .utils import NamespacedClient class EqlClient(NamespacedClient): diff --git a/elasticsearch/_async/client/graph.py b/elasticsearch/_async/client/graph.py index 27fae983..ff56eb5b 100644 --- a/elasticsearch/_async/client/graph.py +++ b/elasticsearch/_async/client/graph.py @@ -15,7 +15,7 @@ # specific language governing permissions and limitations # under the License. -from .utils import NamespacedClient, query_params, _make_path, SKIP_IN_PATH +from .utils import SKIP_IN_PATH, NamespacedClient, _make_path, query_params class GraphClient(NamespacedClient): diff --git a/elasticsearch/_async/client/graph.pyi b/elasticsearch/_async/client/graph.pyi index 6d19d539..19b6cbad 100644 --- a/elasticsearch/_async/client/graph.pyi +++ b/elasticsearch/_async/client/graph.pyi @@ -15,7 +15,8 @@ # specific language governing permissions and limitations # under the License. -from typing import Any, MutableMapping, Optional, Union, Collection +from typing import Any, Collection, MutableMapping, Optional, Union + from .utils import NamespacedClient class GraphClient(NamespacedClient): diff --git a/elasticsearch/_async/client/ilm.py b/elasticsearch/_async/client/ilm.py index 7ebb3847..909f70fb 100644 --- a/elasticsearch/_async/client/ilm.py +++ b/elasticsearch/_async/client/ilm.py @@ -15,7 +15,7 @@ # specific language governing permissions and limitations # under the License. -from .utils import NamespacedClient, query_params, _make_path, SKIP_IN_PATH +from .utils import SKIP_IN_PATH, NamespacedClient, _make_path, query_params class IlmClient(NamespacedClient): diff --git a/elasticsearch/_async/client/ilm.pyi b/elasticsearch/_async/client/ilm.pyi index 99afa7a6..35aec5ee 100644 --- a/elasticsearch/_async/client/ilm.pyi +++ b/elasticsearch/_async/client/ilm.pyi @@ -15,7 +15,8 @@ # specific language governing permissions and limitations # under the License. -from typing import Any, MutableMapping, Optional, Union, Collection +from typing import Any, Collection, MutableMapping, Optional, Union + from .utils import NamespacedClient class IlmClient(NamespacedClient): diff --git a/elasticsearch/_async/client/indices.py b/elasticsearch/_async/client/indices.py index 917b3828..d6eca9aa 100644 --- a/elasticsearch/_async/client/indices.py +++ b/elasticsearch/_async/client/indices.py @@ -15,7 +15,7 @@ # specific language governing permissions and limitations # under the License. -from .utils import NamespacedClient, query_params, _make_path, SKIP_IN_PATH +from .utils import SKIP_IN_PATH, NamespacedClient, _make_path, query_params class IndicesClient(NamespacedClient): @@ -1625,3 +1625,22 @@ class IndicesClient(NamespacedClient): params=params, headers=headers, ) + + @query_params() + async def migrate_to_data_stream(self, name, params=None, headers=None): + """ + Migrates an alias to a data stream + + ``_ + + :arg name: The name of the alias to migrate + """ + if name in SKIP_IN_PATH: + raise ValueError("Empty value passed for a required argument 'name'.") + + return await self.transport.perform_request( + "POST", + _make_path("_data_stream", "_migrate", name), + params=params, + headers=headers, + ) diff --git a/elasticsearch/_async/client/indices.pyi b/elasticsearch/_async/client/indices.pyi index 0b0a62d3..c5978ccd 100644 --- a/elasticsearch/_async/client/indices.pyi +++ b/elasticsearch/_async/client/indices.pyi @@ -15,7 +15,8 @@ # specific language governing permissions and limitations # under the License. -from typing import Any, MutableMapping, Optional, Union, Collection +from typing import Any, Collection, MutableMapping, Optional, Union + from .utils import NamespacedClient class IndicesClient(NamespacedClient): @@ -1079,3 +1080,18 @@ class IndicesClient(NamespacedClient): params: Optional[MutableMapping[str, Any]] = ..., headers: Optional[MutableMapping[str, str]] = ... ) -> Any: ... + async def migrate_to_data_stream( + self, + name: Any, + *, + pretty: Optional[bool] = ..., + human: Optional[bool] = ..., + error_trace: Optional[bool] = ..., + format: Optional[str] = ..., + filter_path: Optional[Union[str, Collection[str]]] = ..., + request_timeout: Optional[Union[int, float]] = ..., + ignore: Optional[Union[int, Collection[int]]] = ..., + opaque_id: Optional[str] = ..., + params: Optional[MutableMapping[str, Any]] = ..., + headers: Optional[MutableMapping[str, str]] = ... + ) -> Any: ... diff --git a/elasticsearch/_async/client/ingest.py b/elasticsearch/_async/client/ingest.py index 17fef146..02945fe0 100644 --- a/elasticsearch/_async/client/ingest.py +++ b/elasticsearch/_async/client/ingest.py @@ -15,7 +15,7 @@ # specific language governing permissions and limitations # under the License. -from .utils import NamespacedClient, query_params, _make_path, SKIP_IN_PATH +from .utils import SKIP_IN_PATH, NamespacedClient, _make_path, query_params class IngestClient(NamespacedClient): diff --git a/elasticsearch/_async/client/ingest.pyi b/elasticsearch/_async/client/ingest.pyi index 49b5e6f9..d49a5ac0 100644 --- a/elasticsearch/_async/client/ingest.pyi +++ b/elasticsearch/_async/client/ingest.pyi @@ -15,7 +15,8 @@ # specific language governing permissions and limitations # under the License. -from typing import Any, MutableMapping, Optional, Union, Collection +from typing import Any, Collection, MutableMapping, Optional, Union + from .utils import NamespacedClient class IngestClient(NamespacedClient): diff --git a/elasticsearch/_async/client/license.pyi b/elasticsearch/_async/client/license.pyi index c2306607..ddcb683d 100644 --- a/elasticsearch/_async/client/license.pyi +++ b/elasticsearch/_async/client/license.pyi @@ -15,7 +15,8 @@ # specific language governing permissions and limitations # under the License. -from typing import Any, MutableMapping, Optional, Union, Collection +from typing import Any, Collection, MutableMapping, Optional, Union + from .utils import NamespacedClient class LicenseClient(NamespacedClient): diff --git a/elasticsearch/_async/client/migration.py b/elasticsearch/_async/client/migration.py index 50cfc243..ce23eef1 100644 --- a/elasticsearch/_async/client/migration.py +++ b/elasticsearch/_async/client/migration.py @@ -15,7 +15,7 @@ # specific language governing permissions and limitations # under the License. -from .utils import NamespacedClient, query_params, _make_path +from .utils import NamespacedClient, _make_path, query_params class MigrationClient(NamespacedClient): diff --git a/elasticsearch/_async/client/migration.pyi b/elasticsearch/_async/client/migration.pyi index 230d345a..d0bdef46 100644 --- a/elasticsearch/_async/client/migration.pyi +++ b/elasticsearch/_async/client/migration.pyi @@ -15,7 +15,8 @@ # specific language governing permissions and limitations # under the License. -from typing import Any, MutableMapping, Optional, Union, Collection +from typing import Any, Collection, MutableMapping, Optional, Union + from .utils import NamespacedClient class MigrationClient(NamespacedClient): diff --git a/elasticsearch/_async/client/ml.py b/elasticsearch/_async/client/ml.py index 4ea110e4..469e4554 100644 --- a/elasticsearch/_async/client/ml.py +++ b/elasticsearch/_async/client/ml.py @@ -15,7 +15,7 @@ # specific language governing permissions and limitations # under the License. -from .utils import NamespacedClient, query_params, _make_path, SKIP_IN_PATH, _bulk_body +from .utils import SKIP_IN_PATH, NamespacedClient, _bulk_body, _make_path, query_params class MlClient(NamespacedClient): @@ -255,79 +255,6 @@ class MlClient(NamespacedClient): headers=headers, ) - @query_params( - "charset", - "column_names", - "delimiter", - "explain", - "format", - "grok_pattern", - "has_header_row", - "line_merge_size_limit", - "lines_to_sample", - "quote", - "should_trim_fields", - "timeout", - "timestamp_field", - "timestamp_format", - ) - async def find_file_structure(self, body, params=None, headers=None): - """ - Finds the structure of a text file. The text file must contain data that is - suitable to be ingested into Elasticsearch. - - ``_ - - .. warning:: - - This API is **experimental** so may include breaking changes - or be removed in a future version - - :arg body: The contents of the file to be analyzed - :arg charset: Optional parameter to specify the character set of - the file - :arg column_names: Optional parameter containing a comma - separated list of the column names for a delimited file - :arg delimiter: Optional parameter to specify the delimiter - character for a delimited file - must be a single character - :arg explain: Whether to include a commentary on how the - structure was derived - :arg format: Optional parameter to specify the high level file - format Valid choices: ndjson, xml, delimited, semi_structured_text - :arg grok_pattern: Optional parameter to specify the Grok - pattern that should be used to extract fields from messages in a semi- - structured text file - :arg has_header_row: Optional parameter to specify whether a - delimited file includes the column names in its first row - :arg line_merge_size_limit: Maximum number of characters - permitted in a single message when lines are merged to create messages. - Default: 10000 - :arg lines_to_sample: How many lines of the file should be - included in the analysis Default: 1000 - :arg quote: Optional parameter to specify the quote character - for a delimited file - must be a single character - :arg should_trim_fields: Optional parameter to specify whether - the values between delimiters in a delimited file should have whitespace - trimmed from them - :arg timeout: Timeout after which the analysis will be aborted - Default: 25s - :arg timestamp_field: Optional parameter to specify the - timestamp field in the file - :arg timestamp_format: Optional parameter to specify the - timestamp format in the file - may be either a Joda or Java time format - """ - if body in SKIP_IN_PATH: - raise ValueError("Empty value passed for a required argument 'body'.") - - body = _bulk_body(self.transport.serializer, body) - return await self.transport.perform_request( - "POST", - "/_ml/find_file_structure", - params=params, - headers=headers, - body=body, - ) - @query_params("advance_time", "calc_interim", "end", "skip_time", "start") async def flush_job(self, job_id, body=None, params=None, headers=None): """ diff --git a/elasticsearch/_async/client/ml.pyi b/elasticsearch/_async/client/ml.pyi index f929d581..0c4e9873 100644 --- a/elasticsearch/_async/client/ml.pyi +++ b/elasticsearch/_async/client/ml.pyi @@ -15,7 +15,8 @@ # specific language governing permissions and limitations # under the License. -from typing import Any, MutableMapping, Optional, Union, Collection +from typing import Any, Collection, MutableMapping, Optional, Union + from .utils import NamespacedClient class MlClient(NamespacedClient): @@ -186,34 +187,6 @@ class MlClient(NamespacedClient): params: Optional[MutableMapping[str, Any]] = ..., headers: Optional[MutableMapping[str, str]] = ... ) -> Any: ... - async def find_file_structure( - self, - *, - body: Any, - charset: Optional[Any] = ..., - column_names: Optional[Any] = ..., - delimiter: Optional[Any] = ..., - explain: Optional[Any] = ..., - format: Optional[Any] = ..., - grok_pattern: Optional[Any] = ..., - has_header_row: Optional[Any] = ..., - line_merge_size_limit: Optional[Any] = ..., - lines_to_sample: Optional[Any] = ..., - quote: Optional[Any] = ..., - should_trim_fields: Optional[Any] = ..., - timeout: Optional[Any] = ..., - timestamp_field: Optional[Any] = ..., - timestamp_format: Optional[Any] = ..., - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ... - ) -> Any: ... async def flush_job( self, job_id: Any, diff --git a/elasticsearch/_async/client/monitoring.py b/elasticsearch/_async/client/monitoring.py index 30e40a80..a9971d30 100644 --- a/elasticsearch/_async/client/monitoring.py +++ b/elasticsearch/_async/client/monitoring.py @@ -15,7 +15,7 @@ # specific language governing permissions and limitations # under the License. -from .utils import NamespacedClient, query_params, _make_path, SKIP_IN_PATH, _bulk_body +from .utils import SKIP_IN_PATH, NamespacedClient, _bulk_body, _make_path, query_params class MonitoringClient(NamespacedClient): diff --git a/elasticsearch/_async/client/monitoring.pyi b/elasticsearch/_async/client/monitoring.pyi index 3e2fdfa1..4bae1735 100644 --- a/elasticsearch/_async/client/monitoring.pyi +++ b/elasticsearch/_async/client/monitoring.pyi @@ -15,7 +15,8 @@ # specific language governing permissions and limitations # under the License. -from typing import Any, MutableMapping, Optional, Union, Collection +from typing import Any, Collection, MutableMapping, Optional, Union + from .utils import NamespacedClient class MonitoringClient(NamespacedClient): diff --git a/elasticsearch/_async/client/nodes.py b/elasticsearch/_async/client/nodes.py index b587faa5..71b34c4b 100644 --- a/elasticsearch/_async/client/nodes.py +++ b/elasticsearch/_async/client/nodes.py @@ -15,7 +15,7 @@ # specific language governing permissions and limitations # under the License. -from .utils import NamespacedClient, query_params, _make_path +from .utils import NamespacedClient, _make_path, query_params class NodesClient(NamespacedClient): diff --git a/elasticsearch/_async/client/nodes.pyi b/elasticsearch/_async/client/nodes.pyi index 8785e53e..74ce6847 100644 --- a/elasticsearch/_async/client/nodes.pyi +++ b/elasticsearch/_async/client/nodes.pyi @@ -15,7 +15,8 @@ # specific language governing permissions and limitations # under the License. -from typing import Any, MutableMapping, Optional, Union, Collection +from typing import Any, Collection, MutableMapping, Optional, Union + from .utils import NamespacedClient class NodesClient(NamespacedClient): diff --git a/elasticsearch/_async/client/remote.pyi b/elasticsearch/_async/client/remote.pyi index 599b9c04..05eb62ed 100644 --- a/elasticsearch/_async/client/remote.pyi +++ b/elasticsearch/_async/client/remote.pyi @@ -15,7 +15,8 @@ # specific language governing permissions and limitations # under the License. -from typing import Any, MutableMapping, Optional, Union, Collection +from typing import Any, Collection, MutableMapping, Optional, Union + from .utils import NamespacedClient class RemoteClient(NamespacedClient): diff --git a/elasticsearch/_async/client/rollup.py b/elasticsearch/_async/client/rollup.py index 69e6c888..72754d06 100644 --- a/elasticsearch/_async/client/rollup.py +++ b/elasticsearch/_async/client/rollup.py @@ -15,7 +15,7 @@ # specific language governing permissions and limitations # under the License. -from .utils import NamespacedClient, query_params, _make_path, SKIP_IN_PATH +from .utils import SKIP_IN_PATH, NamespacedClient, _make_path, query_params class RollupClient(NamespacedClient): @@ -218,22 +218,23 @@ class RollupClient(NamespacedClient): ) @query_params() - async def rollup(self, index, body, params=None, headers=None): + async def rollup(self, index, rollup_index, body, params=None, headers=None): """ Rollup an index ``_ :arg index: The index to roll up + :arg rollup_index: The name of the rollup index to create :arg body: The rollup configuration """ - for param in (index, body): + for param in (index, rollup_index, body): if param in SKIP_IN_PATH: raise ValueError("Empty value passed for a required argument.") return await self.transport.perform_request( "POST", - _make_path(index, "_rollup"), + _make_path(index, "_rollup", rollup_index), params=params, headers=headers, body=body, diff --git a/elasticsearch/_async/client/rollup.pyi b/elasticsearch/_async/client/rollup.pyi index bfacd136..ead9a9ff 100644 --- a/elasticsearch/_async/client/rollup.pyi +++ b/elasticsearch/_async/client/rollup.pyi @@ -15,7 +15,8 @@ # specific language governing permissions and limitations # under the License. -from typing import Any, MutableMapping, Optional, Union, Collection +from typing import Any, Collection, MutableMapping, Optional, Union + from .utils import NamespacedClient class RollupClient(NamespacedClient): @@ -149,6 +150,7 @@ class RollupClient(NamespacedClient): async def rollup( self, index: Any, + rollup_index: Any, *, body: Any, pretty: Optional[bool] = ..., diff --git a/elasticsearch/_async/client/searchable_snapshots.py b/elasticsearch/_async/client/searchable_snapshots.py index 087deeca..be09ca68 100644 --- a/elasticsearch/_async/client/searchable_snapshots.py +++ b/elasticsearch/_async/client/searchable_snapshots.py @@ -15,7 +15,7 @@ # specific language governing permissions and limitations # under the License. -from .utils import NamespacedClient, query_params, _make_path, SKIP_IN_PATH +from .utils import SKIP_IN_PATH, NamespacedClient, _make_path, query_params class SearchableSnapshotsClient(NamespacedClient): diff --git a/elasticsearch/_async/client/searchable_snapshots.pyi b/elasticsearch/_async/client/searchable_snapshots.pyi index 94ea4331..6e2414bd 100644 --- a/elasticsearch/_async/client/searchable_snapshots.pyi +++ b/elasticsearch/_async/client/searchable_snapshots.pyi @@ -15,7 +15,8 @@ # specific language governing permissions and limitations # under the License. -from typing import Any, MutableMapping, Optional, Union, Collection +from typing import Any, Collection, MutableMapping, Optional, Union + from .utils import NamespacedClient class SearchableSnapshotsClient(NamespacedClient): diff --git a/elasticsearch/_async/client/security.py b/elasticsearch/_async/client/security.py index 0cbda9e5..75a7283f 100644 --- a/elasticsearch/_async/client/security.py +++ b/elasticsearch/_async/client/security.py @@ -15,7 +15,7 @@ # specific language governing permissions and limitations # under the License. -from .utils import NamespacedClient, query_params, _make_path, SKIP_IN_PATH +from .utils import SKIP_IN_PATH, NamespacedClient, _make_path, query_params class SecurityClient(NamespacedClient): diff --git a/elasticsearch/_async/client/security.pyi b/elasticsearch/_async/client/security.pyi index 05943ba5..dd0506a2 100644 --- a/elasticsearch/_async/client/security.pyi +++ b/elasticsearch/_async/client/security.pyi @@ -15,7 +15,8 @@ # specific language governing permissions and limitations # under the License. -from typing import Any, MutableMapping, Optional, Union, Collection +from typing import Any, Collection, MutableMapping, Optional, Union + from .utils import NamespacedClient class SecurityClient(NamespacedClient): diff --git a/elasticsearch/_async/client/slm.py b/elasticsearch/_async/client/slm.py index ade3140f..5d02ba5f 100644 --- a/elasticsearch/_async/client/slm.py +++ b/elasticsearch/_async/client/slm.py @@ -15,7 +15,7 @@ # specific language governing permissions and limitations # under the License. -from .utils import NamespacedClient, query_params, _make_path, SKIP_IN_PATH +from .utils import SKIP_IN_PATH, NamespacedClient, _make_path, query_params class SlmClient(NamespacedClient): diff --git a/elasticsearch/_async/client/slm.pyi b/elasticsearch/_async/client/slm.pyi index 1bf0d1ef..9fc313a1 100644 --- a/elasticsearch/_async/client/slm.pyi +++ b/elasticsearch/_async/client/slm.pyi @@ -15,7 +15,8 @@ # specific language governing permissions and limitations # under the License. -from typing import Any, MutableMapping, Optional, Union, Collection +from typing import Any, Collection, MutableMapping, Optional, Union + from .utils import NamespacedClient class SlmClient(NamespacedClient): diff --git a/elasticsearch/_async/client/snapshot.py b/elasticsearch/_async/client/snapshot.py index 07451f2f..65f96bc1 100644 --- a/elasticsearch/_async/client/snapshot.py +++ b/elasticsearch/_async/client/snapshot.py @@ -15,7 +15,7 @@ # specific language governing permissions and limitations # under the License. -from .utils import NamespacedClient, query_params, _make_path, SKIP_IN_PATH +from .utils import SKIP_IN_PATH, NamespacedClient, _make_path, query_params class SnapshotClient(NamespacedClient): diff --git a/elasticsearch/_async/client/snapshot.pyi b/elasticsearch/_async/client/snapshot.pyi index ca80bac4..0bc3e7ee 100644 --- a/elasticsearch/_async/client/snapshot.pyi +++ b/elasticsearch/_async/client/snapshot.pyi @@ -15,7 +15,8 @@ # specific language governing permissions and limitations # under the License. -from typing import Any, MutableMapping, Optional, Union, Collection +from typing import Any, Collection, MutableMapping, Optional, Union + from .utils import NamespacedClient class SnapshotClient(NamespacedClient): diff --git a/elasticsearch/_async/client/sql.py b/elasticsearch/_async/client/sql.py index 09dba7cd..017258b1 100644 --- a/elasticsearch/_async/client/sql.py +++ b/elasticsearch/_async/client/sql.py @@ -15,7 +15,7 @@ # specific language governing permissions and limitations # under the License. -from .utils import NamespacedClient, query_params, SKIP_IN_PATH +from .utils import SKIP_IN_PATH, NamespacedClient, query_params class SqlClient(NamespacedClient): diff --git a/elasticsearch/_async/client/sql.pyi b/elasticsearch/_async/client/sql.pyi index cfb8a04f..e1719b7c 100644 --- a/elasticsearch/_async/client/sql.pyi +++ b/elasticsearch/_async/client/sql.pyi @@ -15,7 +15,8 @@ # specific language governing permissions and limitations # under the License. -from typing import Any, MutableMapping, Optional, Union, Collection +from typing import Any, Collection, MutableMapping, Optional, Union + from .utils import NamespacedClient class SqlClient(NamespacedClient): diff --git a/elasticsearch/_async/client/ssl.pyi b/elasticsearch/_async/client/ssl.pyi index c21e689d..b74863eb 100644 --- a/elasticsearch/_async/client/ssl.pyi +++ b/elasticsearch/_async/client/ssl.pyi @@ -15,7 +15,8 @@ # specific language governing permissions and limitations # under the License. -from typing import Any, MutableMapping, Optional, Union, Collection +from typing import Any, Collection, MutableMapping, Optional, Union + from .utils import NamespacedClient class SslClient(NamespacedClient): diff --git a/elasticsearch/_async/client/tasks.py b/elasticsearch/_async/client/tasks.py index f312aa5f..9a990ab4 100644 --- a/elasticsearch/_async/client/tasks.py +++ b/elasticsearch/_async/client/tasks.py @@ -16,7 +16,8 @@ # under the License. import warnings -from .utils import NamespacedClient, query_params, _make_path, SKIP_IN_PATH + +from .utils import SKIP_IN_PATH, NamespacedClient, _make_path, query_params class TasksClient(NamespacedClient): diff --git a/elasticsearch/_async/client/tasks.pyi b/elasticsearch/_async/client/tasks.pyi index 757e6096..7d6f9bad 100644 --- a/elasticsearch/_async/client/tasks.pyi +++ b/elasticsearch/_async/client/tasks.pyi @@ -15,7 +15,8 @@ # specific language governing permissions and limitations # under the License. -from typing import Any, MutableMapping, Optional, Union, Collection +from typing import Any, Collection, MutableMapping, Optional, Union + from .utils import NamespacedClient class TasksClient(NamespacedClient): diff --git a/elasticsearch/_async/client/text_structure.py b/elasticsearch/_async/client/text_structure.py new file mode 100644 index 00000000..1e7dca9f --- /dev/null +++ b/elasticsearch/_async/client/text_structure.py @@ -0,0 +1,93 @@ +# Licensed to Elasticsearch B.V. under one or more contributor +# license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright +# ownership. Elasticsearch B.V. licenses this file to you under +# the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + +from .utils import SKIP_IN_PATH, NamespacedClient, _bulk_body, query_params + + +class TextStructureClient(NamespacedClient): + @query_params( + "charset", + "column_names", + "delimiter", + "explain", + "format", + "grok_pattern", + "has_header_row", + "line_merge_size_limit", + "lines_to_sample", + "quote", + "should_trim_fields", + "timeout", + "timestamp_field", + "timestamp_format", + ) + async def find_structure(self, body, params=None, headers=None): + """ + Finds the structure of a text file. The text file must contain data that is + suitable to be ingested into Elasticsearch. + + ``_ + + .. warning:: + + This API is **experimental** so may include breaking changes + or be removed in a future version + + :arg body: The contents of the file to be analyzed + :arg charset: Optional parameter to specify the character set of + the file + :arg column_names: Optional parameter containing a comma + separated list of the column names for a delimited file + :arg delimiter: Optional parameter to specify the delimiter + character for a delimited file - must be a single character + :arg explain: Whether to include a commentary on how the + structure was derived + :arg format: Optional parameter to specify the high level file + format Valid choices: ndjson, xml, delimited, semi_structured_text + :arg grok_pattern: Optional parameter to specify the Grok + pattern that should be used to extract fields from messages in a semi- + structured text file + :arg has_header_row: Optional parameter to specify whether a + delimited file includes the column names in its first row + :arg line_merge_size_limit: Maximum number of characters + permitted in a single message when lines are merged to create messages. + Default: 10000 + :arg lines_to_sample: How many lines of the file should be + included in the analysis Default: 1000 + :arg quote: Optional parameter to specify the quote character + for a delimited file - must be a single character + :arg should_trim_fields: Optional parameter to specify whether + the values between delimiters in a delimited file should have whitespace + trimmed from them + :arg timeout: Timeout after which the analysis will be aborted + Default: 25s + :arg timestamp_field: Optional parameter to specify the + timestamp field in the file + :arg timestamp_format: Optional parameter to specify the + timestamp format in the file - may be either a Joda or Java time format + """ + if body in SKIP_IN_PATH: + raise ValueError("Empty value passed for a required argument 'body'.") + + body = _bulk_body(self.transport.serializer, body) + return await self.transport.perform_request( + "POST", + "/_text_structure/find_structure", + params=params, + headers=headers, + body=body, + ) diff --git a/elasticsearch/_async/client/text_structure.pyi b/elasticsearch/_async/client/text_structure.pyi new file mode 100644 index 00000000..74e577df --- /dev/null +++ b/elasticsearch/_async/client/text_structure.pyi @@ -0,0 +1,50 @@ +# Licensed to Elasticsearch B.V. under one or more contributor +# license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright +# ownership. Elasticsearch B.V. licenses this file to you under +# the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + +from typing import Any, Collection, MutableMapping, Optional, Union + +from .utils import NamespacedClient + +class TextStructureClient(NamespacedClient): + async def find_structure( + self, + *, + body: Any, + charset: Optional[Any] = ..., + column_names: Optional[Any] = ..., + delimiter: Optional[Any] = ..., + explain: Optional[Any] = ..., + format: Optional[Any] = ..., + grok_pattern: Optional[Any] = ..., + has_header_row: Optional[Any] = ..., + line_merge_size_limit: Optional[Any] = ..., + lines_to_sample: Optional[Any] = ..., + quote: Optional[Any] = ..., + should_trim_fields: Optional[Any] = ..., + timeout: Optional[Any] = ..., + timestamp_field: Optional[Any] = ..., + timestamp_format: Optional[Any] = ..., + pretty: Optional[bool] = ..., + human: Optional[bool] = ..., + error_trace: Optional[bool] = ..., + filter_path: Optional[Union[str, Collection[str]]] = ..., + request_timeout: Optional[Union[int, float]] = ..., + ignore: Optional[Union[int, Collection[int]]] = ..., + opaque_id: Optional[str] = ..., + params: Optional[MutableMapping[str, Any]] = ..., + headers: Optional[MutableMapping[str, str]] = ... + ) -> Any: ... diff --git a/elasticsearch/_async/client/transform.py b/elasticsearch/_async/client/transform.py index 6f4e70d4..ea971301 100644 --- a/elasticsearch/_async/client/transform.py +++ b/elasticsearch/_async/client/transform.py @@ -15,7 +15,7 @@ # specific language governing permissions and limitations # under the License. -from .utils import NamespacedClient, query_params, _make_path, SKIP_IN_PATH +from .utils import SKIP_IN_PATH, NamespacedClient, _make_path, query_params class TransformClient(NamespacedClient): diff --git a/elasticsearch/_async/client/transform.pyi b/elasticsearch/_async/client/transform.pyi index 7726577a..b440d9e1 100644 --- a/elasticsearch/_async/client/transform.pyi +++ b/elasticsearch/_async/client/transform.pyi @@ -15,7 +15,8 @@ # specific language governing permissions and limitations # under the License. -from typing import Any, MutableMapping, Optional, Union, Collection +from typing import Any, Collection, MutableMapping, Optional, Union + from .utils import NamespacedClient class TransformClient(NamespacedClient): diff --git a/elasticsearch/_async/client/utils.py b/elasticsearch/_async/client/utils.py index d38c4eee..e3ac0006 100644 --- a/elasticsearch/_async/client/utils.py +++ b/elasticsearch/_async/client/utils.py @@ -16,11 +16,11 @@ # under the License. from ...client.utils import ( # noqa - _make_path, - _normalize_hosts, - _escape, - _bulk_body, - query_params, SKIP_IN_PATH, NamespacedClient, + _bulk_body, + _escape, + _make_path, + _normalize_hosts, + query_params, ) diff --git a/elasticsearch/_async/client/utils.pyi b/elasticsearch/_async/client/utils.pyi index 9b4501d1..a5c992a0 100644 --- a/elasticsearch/_async/client/utils.pyi +++ b/elasticsearch/_async/client/utils.pyi @@ -15,16 +15,14 @@ # specific language governing permissions and limitations # under the License. -from ...client.utils import ( # noqa - _make_path as _make_path, - _normalize_hosts as _normalize_hosts, - _escape as _escape, - _bulk_body as _bulk_body, - query_params as query_params, - SKIP_IN_PATH as SKIP_IN_PATH, -) -from ..transport import AsyncTransport +from ...client.utils import SKIP_IN_PATH as SKIP_IN_PATH +from ...client.utils import _bulk_body as _bulk_body +from ...client.utils import _escape as _escape +from ...client.utils import _make_path as _make_path # noqa +from ...client.utils import _normalize_hosts as _normalize_hosts +from ...client.utils import query_params as query_params from ..client import AsyncElasticsearch +from ..transport import AsyncTransport class NamespacedClient: client: AsyncElasticsearch diff --git a/elasticsearch/_async/client/watcher.py b/elasticsearch/_async/client/watcher.py index 7cdf16dc..14248093 100644 --- a/elasticsearch/_async/client/watcher.py +++ b/elasticsearch/_async/client/watcher.py @@ -15,7 +15,7 @@ # specific language governing permissions and limitations # under the License. -from .utils import NamespacedClient, query_params, _make_path, SKIP_IN_PATH +from .utils import SKIP_IN_PATH, NamespacedClient, _make_path, query_params class WatcherClient(NamespacedClient): diff --git a/elasticsearch/_async/client/watcher.pyi b/elasticsearch/_async/client/watcher.pyi index 328e3f3b..0344cc57 100644 --- a/elasticsearch/_async/client/watcher.pyi +++ b/elasticsearch/_async/client/watcher.pyi @@ -15,7 +15,8 @@ # specific language governing permissions and limitations # under the License. -from typing import Any, MutableMapping, Optional, Union, Collection +from typing import Any, Collection, MutableMapping, Optional, Union + from .utils import NamespacedClient class WatcherClient(NamespacedClient): diff --git a/elasticsearch/_async/client/xpack.pyi b/elasticsearch/_async/client/xpack.pyi index 103456fe..781854f7 100644 --- a/elasticsearch/_async/client/xpack.pyi +++ b/elasticsearch/_async/client/xpack.pyi @@ -15,7 +15,8 @@ # specific language governing permissions and limitations # under the License. -from typing import Any, MutableMapping, Optional, Union, Collection +from typing import Any, Collection, MutableMapping, Optional, Union + from .utils import NamespacedClient class XPackClient(NamespacedClient): diff --git a/elasticsearch/_async/compat.py b/elasticsearch/_async/compat.py index 1d7a3118..75716138 100644 --- a/elasticsearch/_async/compat.py +++ b/elasticsearch/_async/compat.py @@ -16,6 +16,7 @@ # under the License. import asyncio + from ..compat import * # noqa # Hack supporting Python 3.6 asyncio which didn't have 'get_running_loop()'. diff --git a/elasticsearch/_async/helpers.py b/elasticsearch/_async/helpers.py index 73d90044..b84bfae5 100644 --- a/elasticsearch/_async/helpers.py +++ b/elasticsearch/_async/helpers.py @@ -20,11 +20,10 @@ # See the LICENSE file in the project root for more information import asyncio +import logging -from .client import AsyncElasticsearch # noqa -from ..exceptions import TransportError from ..compat import map - +from ..exceptions import TransportError from ..helpers.actions import ( _ActionChunker, _process_bulk_chunk_error, @@ -32,9 +31,7 @@ from ..helpers.actions import ( expand_action, ) from ..helpers.errors import ScanError - -import logging - +from .client import AsyncElasticsearch # noqa logger = logging.getLogger("elasticsearch.helpers") diff --git a/elasticsearch/_async/helpers.pyi b/elasticsearch/_async/helpers.pyi index dce10602..6028a022 100644 --- a/elasticsearch/_async/helpers.pyi +++ b/elasticsearch/_async/helpers.pyi @@ -15,24 +15,25 @@ # specific language governing permissions and limitations # under the License. +import logging from typing import ( - AsyncGenerator, - Optional, - Union, Any, + AsyncGenerator, + AsyncIterable, + Callable, + Collection, + Dict, + Iterable, + List, Mapping, + Optional, Tuple, TypeVar, - Iterable, - AsyncIterable, - List, - Dict, - Collection, - Callable, + Union, ) -import logging -from .client import AsyncElasticsearch + from ..serializer import Serializer +from .client import AsyncElasticsearch logger: logging.Logger diff --git a/elasticsearch/_async/http_aiohttp.py b/elasticsearch/_async/http_aiohttp.py index 8956ded2..3bbdffcc 100644 --- a/elasticsearch/_async/http_aiohttp.py +++ b/elasticsearch/_async/http_aiohttp.py @@ -16,16 +16,14 @@ # under the License. import asyncio -import ssl import os -import urllib3 # type: ignore +import ssl import warnings -from ._extra_imports import aiohttp_exceptions, aiohttp, yarl -from .compat import get_running_loop -from ..connection.base import ( - Connection, -) + +import urllib3 # type: ignore + from ..compat import urlencode +from ..connection.base import Connection from ..exceptions import ( ConnectionError, ConnectionTimeout, @@ -33,7 +31,8 @@ from ..exceptions import ( SSLError, ) from ..utils import _client_meta_version - +from ._extra_imports import aiohttp, aiohttp_exceptions, yarl +from .compat import get_running_loop # sentinel value for `verify_certs`. # This is used to detect if a user is passing in a value diff --git a/elasticsearch/_async/http_aiohttp.pyi b/elasticsearch/_async/http_aiohttp.pyi index b46d48b0..0ef9e7e5 100644 --- a/elasticsearch/_async/http_aiohttp.pyi +++ b/elasticsearch/_async/http_aiohttp.pyi @@ -15,9 +15,10 @@ # specific language governing permissions and limitations # under the License. -from ._extra_imports import aiohttp # type: ignore -from typing import Optional, Mapping, MutableMapping, Collection, Union, Any, Tuple +from typing import Any, Collection, Mapping, MutableMapping, Optional, Tuple, Union + from ..connection import Connection +from ._extra_imports import aiohttp # type: ignore class AsyncConnection(Connection): async def perform_request( # type: ignore diff --git a/elasticsearch/_async/transport.py b/elasticsearch/_async/transport.py index 672a94c7..f75b79fe 100644 --- a/elasticsearch/_async/transport.py +++ b/elasticsearch/_async/transport.py @@ -17,19 +17,18 @@ import asyncio import logging -from itertools import chain import sys +from itertools import chain +from ..exceptions import ( + ConnectionError, + ConnectionTimeout, + SerializationError, + TransportError, +) +from ..transport import Transport from .compat import get_running_loop from .http_aiohttp import AIOHttpConnection -from ..transport import Transport -from ..exceptions import ( - TransportError, - ConnectionTimeout, - ConnectionError, - SerializationError, -) - logger = logging.getLogger("elasticsearch") diff --git a/elasticsearch/_async/transport.pyi b/elasticsearch/_async/transport.pyi index 56e329f6..16c54b43 100644 --- a/elasticsearch/_async/transport.pyi +++ b/elasticsearch/_async/transport.pyi @@ -15,21 +15,11 @@ # specific language governing permissions and limitations # under the License. -from typing import ( - Callable, - Optional, - Union, - Collection, - Type, - Mapping, - Any, - Dict, - List, -) +from typing import Any, Callable, Collection, Dict, List, Mapping, Optional, Type, Union from ..connection import Connection from ..connection_pool import ConnectionPool -from ..serializer import Serializer, Deserializer +from ..serializer import Deserializer, Serializer class AsyncTransport(object): DEFAULT_CONNECTION_CLASS: Type[Connection] diff --git a/elasticsearch/client/__init__.py b/elasticsearch/client/__init__.py index 34c4923b..ee7f0408 100644 --- a/elasticsearch/client/__init__.py +++ b/elasticsearch/client/__init__.py @@ -17,45 +17,45 @@ # under the License. from __future__ import unicode_literals + import logging from ..transport import Transport, TransportError -from .utils import query_params, _make_path, SKIP_IN_PATH, _bulk_body, _normalize_hosts - from .async_search import AsyncSearchClient from .autoscaling import AutoscalingClient from .cat import CatClient +from .ccr import CcrClient from .cluster import ClusterClient from .dangling_indices import DanglingIndicesClient -from .indices import IndicesClient -from .ingest import IngestClient -from .nodes import NodesClient -from .remote import RemoteClient -from .snapshot import SnapshotClient -from .tasks import TasksClient - -# xpack APIs -from .xpack import XPackClient -from .ccr import CcrClient from .data_frame import Data_FrameClient from .deprecation import DeprecationClient from .enrich import EnrichClient from .eql import EqlClient from .graph import GraphClient from .ilm import IlmClient +from .indices import IndicesClient +from .ingest import IngestClient from .license import LicenseClient from .migration import MigrationClient from .ml import MlClient from .monitoring import MonitoringClient +from .nodes import NodesClient +from .remote import RemoteClient from .rollup import RollupClient from .searchable_snapshots import SearchableSnapshotsClient from .security import SecurityClient from .slm import SlmClient +from .snapshot import SnapshotClient from .sql import SqlClient from .ssl import SslClient +from .tasks import TasksClient +from .text_structure import TextStructureClient from .transform import TransformClient +from .utils import SKIP_IN_PATH, _bulk_body, _make_path, _normalize_hosts, query_params from .watcher import WatcherClient +# xpack APIs +from .xpack import XPackClient logger = logging.getLogger("elasticsearch") @@ -233,6 +233,7 @@ class Elasticsearch(object): self.slm = SlmClient(self) self.sql = SqlClient(self) self.ssl = SslClient(self) + self.text_structure = TextStructureClient(self) self.transform = TransformClient(self) self.watcher = WatcherClient(self) @@ -1524,6 +1525,7 @@ class Elasticsearch(object): "ignore_unavailable", "lenient", "max_concurrent_shard_requests", + "min_compatible_shard_node", "pre_filter_shard_size", "preference", "q", @@ -1604,6 +1606,9 @@ class Elasticsearch(object): shard requests per node this search executes concurrently. This value should be used to limit the impact of the search on the cluster in order to limit the number of concurrent shard requests Default: 5 + :arg min_compatible_shard_node: The minimum compatible version + that all shards involved in search should have for this request to be + successful :arg pre_filter_shard_size: A threshold that enforces a pre- filter roundtrip to prefilter search shards based on query rewriting if the number of shards the search request expands to exceeds the diff --git a/elasticsearch/client/__init__.pyi b/elasticsearch/client/__init__.pyi index c96ad33a..482f6cce 100644 --- a/elasticsearch/client/__init__.pyi +++ b/elasticsearch/client/__init__.pyi @@ -17,43 +17,44 @@ # under the License. from __future__ import unicode_literals + import logging -from typing import Any, MutableMapping, Optional, Type, Union, Collection +from typing import Any, Collection, MutableMapping, Optional, Type, Union from ..transport import Transport - from .async_search import AsyncSearchClient from .autoscaling import AutoscalingClient from .cat import CatClient +from .ccr import CcrClient from .cluster import ClusterClient from .dangling_indices import DanglingIndicesClient -from .indices import IndicesClient -from .ingest import IngestClient -from .nodes import NodesClient -from .remote import RemoteClient -from .snapshot import SnapshotClient -from .tasks import TasksClient - -# xpack APIs -from .xpack import XPackClient -from .ccr import CcrClient from .enrich import EnrichClient from .eql import EqlClient from .graph import GraphClient from .ilm import IlmClient +from .indices import IndicesClient +from .ingest import IngestClient from .license import LicenseClient from .migration import MigrationClient from .ml import MlClient from .monitoring import MonitoringClient +from .nodes import NodesClient +from .remote import RemoteClient from .rollup import RollupClient from .searchable_snapshots import SearchableSnapshotsClient from .security import SecurityClient from .slm import SlmClient +from .snapshot import SnapshotClient from .sql import SqlClient from .ssl import SslClient +from .tasks import TasksClient +from .text_structure import TextStructureClient from .transform import TransformClient from .watcher import WatcherClient +# xpack APIs +from .xpack import XPackClient + logger: logging.Logger class Elasticsearch(object): @@ -88,6 +89,7 @@ class Elasticsearch(object): sql: SqlClient ssl: SslClient transform: TransformClient + text_structure: TextStructureClient watcher: WatcherClient def __init__( self, hosts: Any = ..., transport_class: Type[Transport] = ..., **kwargs: Any @@ -785,6 +787,7 @@ class Elasticsearch(object): ignore_unavailable: Optional[Any] = ..., lenient: Optional[Any] = ..., max_concurrent_shard_requests: Optional[Any] = ..., + min_compatible_shard_node: Optional[Any] = ..., pre_filter_shard_size: Optional[Any] = ..., preference: Optional[Any] = ..., q: Optional[Any] = ..., diff --git a/elasticsearch/client/async_search.py b/elasticsearch/client/async_search.py index 314fe629..bd1aaa1d 100644 --- a/elasticsearch/client/async_search.py +++ b/elasticsearch/client/async_search.py @@ -15,7 +15,7 @@ # specific language governing permissions and limitations # under the License. -from .utils import NamespacedClient, SKIP_IN_PATH, query_params, _make_path +from .utils import SKIP_IN_PATH, NamespacedClient, _make_path, query_params class AsyncSearchClient(NamespacedClient): diff --git a/elasticsearch/client/async_search.pyi b/elasticsearch/client/async_search.pyi index 23d80e43..820620f8 100644 --- a/elasticsearch/client/async_search.pyi +++ b/elasticsearch/client/async_search.pyi @@ -15,7 +15,8 @@ # specific language governing permissions and limitations # under the License. -from typing import Any, MutableMapping, Optional, Union, Collection +from typing import Any, Collection, MutableMapping, Optional, Union + from .utils import NamespacedClient class AsyncSearchClient(NamespacedClient): diff --git a/elasticsearch/client/autoscaling.py b/elasticsearch/client/autoscaling.py index c1cd8bfe..f3a69218 100644 --- a/elasticsearch/client/autoscaling.py +++ b/elasticsearch/client/autoscaling.py @@ -15,22 +15,18 @@ # specific language governing permissions and limitations # under the License. -from .utils import NamespacedClient, query_params, SKIP_IN_PATH, _make_path +from .utils import SKIP_IN_PATH, NamespacedClient, _make_path, query_params class AutoscalingClient(NamespacedClient): @query_params() def delete_autoscaling_policy(self, name, params=None, headers=None): """ - Deletes an autoscaling policy. + Deletes an autoscaling policy. Designed for indirect use by ECE/ESS and ECK. + Direct use is not supported. ``_ - .. warning:: - - This API is **experimental** so may include breaking changes - or be removed in a future version - :arg name: the name of the autoscaling policy """ if name in SKIP_IN_PATH: @@ -46,15 +42,11 @@ class AutoscalingClient(NamespacedClient): @query_params() def get_autoscaling_policy(self, name, params=None, headers=None): """ - Retrieves an autoscaling policy. + Retrieves an autoscaling policy. Designed for indirect use by ECE/ESS and ECK. + Direct use is not supported. ``_ - .. warning:: - - This API is **experimental** so may include breaking changes - or be removed in a future version - :arg name: the name of the autoscaling policy """ if name in SKIP_IN_PATH: @@ -70,15 +62,11 @@ class AutoscalingClient(NamespacedClient): @query_params() def put_autoscaling_policy(self, name, body, params=None, headers=None): """ - Creates a new autoscaling policy. + Creates a new autoscaling policy. Designed for indirect use by ECE/ESS and ECK. + Direct use is not supported. ``_ - .. warning:: - - This API is **experimental** so may include breaking changes - or be removed in a future version - :arg name: the name of the autoscaling policy :arg body: the specification of the autoscaling policy """ @@ -98,14 +86,10 @@ class AutoscalingClient(NamespacedClient): def get_autoscaling_capacity(self, params=None, headers=None): """ Gets the current autoscaling capacity based on the configured autoscaling - policy. + policy. Designed for indirect use by ECE/ESS and ECK. Direct use is not + supported. ``_ - - .. warning:: - - This API is **experimental** so may include breaking changes - or be removed in a future version """ return self.transport.perform_request( "GET", "/_autoscaling/capacity", params=params, headers=headers diff --git a/elasticsearch/client/autoscaling.pyi b/elasticsearch/client/autoscaling.pyi index d9ee4fa1..10dc34f8 100644 --- a/elasticsearch/client/autoscaling.pyi +++ b/elasticsearch/client/autoscaling.pyi @@ -15,7 +15,8 @@ # specific language governing permissions and limitations # under the License. -from typing import Any, MutableMapping, Optional, Union, Collection +from typing import Any, Collection, MutableMapping, Optional, Union + from .utils import NamespacedClient class AutoscalingClient(NamespacedClient): diff --git a/elasticsearch/client/cat.py b/elasticsearch/client/cat.py index 9a1b68a2..287c24d7 100644 --- a/elasticsearch/client/cat.py +++ b/elasticsearch/client/cat.py @@ -15,7 +15,7 @@ # specific language governing permissions and limitations # under the License. -from .utils import NamespacedClient, query_params, _make_path +from .utils import NamespacedClient, _make_path, query_params class CatClient(NamespacedClient): @@ -420,7 +420,9 @@ class CatClient(NamespacedClient): headers=headers, ) - @query_params("format", "h", "help", "local", "master_timeout", "s", "v") + @query_params( + "format", "h", "help", "include_bootstrap", "local", "master_timeout", "s", "v" + ) def plugins(self, params=None, headers=None): """ Returns information about installed plugins across nodes node. @@ -431,6 +433,8 @@ class CatClient(NamespacedClient): yaml :arg h: Comma-separated list of column names to display :arg help: Return help information + :arg include_bootstrap: Include bootstrap plugins in the + response :arg local: Return local information, do not retrieve the state from master node (default: false) :arg master_timeout: Explicit operation timeout for connection @@ -527,8 +531,8 @@ class CatClient(NamespacedClient): "format", "h", "help", - "node_id", - "parent_task", + "nodes", + "parent_task_id", "s", "time", "v", @@ -547,12 +551,11 @@ class CatClient(NamespacedClient): yaml :arg h: Comma-separated list of column names to display :arg help: Return help information - :arg node_id: A comma-separated list of node IDs or names to - limit the returned information; use `_local` to return information from - the node you're connecting to, leave empty to get information from all - nodes - :arg parent_task: Return tasks with specified parent task id. - Set to -1 to return all. + :arg nodes: A comma-separated list of node IDs or names to limit + the returned information; use `_local` to return information from the + node you're connecting to, leave empty to get information from all nodes + :arg parent_task_id: Return tasks with specified parent task id + (node_id:task_number). Set to -1 to return all. :arg s: Comma-separated list of column names or column aliases to sort by :arg time: The unit in which to display time values Valid diff --git a/elasticsearch/client/cat.pyi b/elasticsearch/client/cat.pyi index bf2317e5..f5ef0d49 100644 --- a/elasticsearch/client/cat.pyi +++ b/elasticsearch/client/cat.pyi @@ -15,7 +15,8 @@ # specific language governing permissions and limitations # under the License. -from typing import Any, MutableMapping, Optional, Union, Collection +from typing import Any, Collection, MutableMapping, Optional, Union + from .utils import NamespacedClient class CatClient(NamespacedClient): @@ -322,6 +323,7 @@ class CatClient(NamespacedClient): format: Optional[Any] = ..., h: Optional[Any] = ..., help: Optional[Any] = ..., + include_bootstrap: Optional[Any] = ..., local: Optional[Any] = ..., master_timeout: Optional[Any] = ..., s: Optional[Any] = ..., @@ -406,8 +408,8 @@ class CatClient(NamespacedClient): format: Optional[Any] = ..., h: Optional[Any] = ..., help: Optional[Any] = ..., - node_id: Optional[Any] = ..., - parent_task: Optional[Any] = ..., + nodes: Optional[Any] = ..., + parent_task_id: Optional[Any] = ..., s: Optional[Any] = ..., time: Optional[Any] = ..., v: Optional[Any] = ..., diff --git a/elasticsearch/client/ccr.py b/elasticsearch/client/ccr.py index b7e2046c..fb59ee11 100644 --- a/elasticsearch/client/ccr.py +++ b/elasticsearch/client/ccr.py @@ -15,7 +15,7 @@ # specific language governing permissions and limitations # under the License. -from .utils import NamespacedClient, query_params, _make_path, SKIP_IN_PATH +from .utils import SKIP_IN_PATH, NamespacedClient, _make_path, query_params class CcrClient(NamespacedClient): diff --git a/elasticsearch/client/ccr.pyi b/elasticsearch/client/ccr.pyi index 0d59b77d..f6d09699 100644 --- a/elasticsearch/client/ccr.pyi +++ b/elasticsearch/client/ccr.pyi @@ -15,7 +15,8 @@ # specific language governing permissions and limitations # under the License. -from typing import Any, MutableMapping, Optional, Union, Collection +from typing import Any, Collection, MutableMapping, Optional, Union + from .utils import NamespacedClient class CcrClient(NamespacedClient): diff --git a/elasticsearch/client/cluster.py b/elasticsearch/client/cluster.py index 539e4fc5..40098e70 100644 --- a/elasticsearch/client/cluster.py +++ b/elasticsearch/client/cluster.py @@ -15,7 +15,7 @@ # specific language governing permissions and limitations # under the License. -from .utils import NamespacedClient, query_params, _make_path, SKIP_IN_PATH +from .utils import SKIP_IN_PATH, NamespacedClient, _make_path, query_params class ClusterClient(NamespacedClient): diff --git a/elasticsearch/client/cluster.pyi b/elasticsearch/client/cluster.pyi index 7d2c87d6..e0a29f6e 100644 --- a/elasticsearch/client/cluster.pyi +++ b/elasticsearch/client/cluster.pyi @@ -15,7 +15,8 @@ # specific language governing permissions and limitations # under the License. -from typing import Any, MutableMapping, Optional, Union, Collection +from typing import Any, Collection, MutableMapping, Optional, Union + from .utils import NamespacedClient class ClusterClient(NamespacedClient): diff --git a/elasticsearch/client/dangling_indices.py b/elasticsearch/client/dangling_indices.py index 86c56c50..d92184a0 100644 --- a/elasticsearch/client/dangling_indices.py +++ b/elasticsearch/client/dangling_indices.py @@ -15,7 +15,7 @@ # specific language governing permissions and limitations # under the License. -from .utils import NamespacedClient, SKIP_IN_PATH, query_params, _make_path +from .utils import SKIP_IN_PATH, NamespacedClient, _make_path, query_params class DanglingIndicesClient(NamespacedClient): diff --git a/elasticsearch/client/dangling_indices.pyi b/elasticsearch/client/dangling_indices.pyi index c186bf72..5c7fceee 100644 --- a/elasticsearch/client/dangling_indices.pyi +++ b/elasticsearch/client/dangling_indices.pyi @@ -15,7 +15,8 @@ # specific language governing permissions and limitations # under the License. -from typing import Any, MutableMapping, Optional, Union, Collection +from typing import Any, Collection, MutableMapping, Optional, Union + from .utils import NamespacedClient class DanglingIndicesClient(NamespacedClient): diff --git a/elasticsearch/client/data_frame.py b/elasticsearch/client/data_frame.py index 5d5c2da0..9205a9f6 100644 --- a/elasticsearch/client/data_frame.py +++ b/elasticsearch/client/data_frame.py @@ -15,7 +15,7 @@ # specific language governing permissions and limitations # under the License. -from .utils import NamespacedClient, query_params, _make_path, SKIP_IN_PATH +from .utils import SKIP_IN_PATH, NamespacedClient, _make_path, query_params class Data_FrameClient(NamespacedClient): diff --git a/elasticsearch/client/data_frame.pyi b/elasticsearch/client/data_frame.pyi index 759746c0..b6c6e09f 100644 --- a/elasticsearch/client/data_frame.pyi +++ b/elasticsearch/client/data_frame.pyi @@ -15,7 +15,8 @@ # specific language governing permissions and limitations # under the License. -from typing import Any, MutableMapping, Optional, Union, Collection +from typing import Any, Collection, MutableMapping, Optional, Union + from .utils import NamespacedClient class Data_FrameClient(NamespacedClient): diff --git a/elasticsearch/client/deprecation.py b/elasticsearch/client/deprecation.py index 76d85daf..a0943493 100644 --- a/elasticsearch/client/deprecation.py +++ b/elasticsearch/client/deprecation.py @@ -15,7 +15,7 @@ # specific language governing permissions and limitations # under the License. -from .utils import NamespacedClient, query_params, _make_path +from .utils import NamespacedClient, _make_path, query_params class DeprecationClient(NamespacedClient): diff --git a/elasticsearch/client/deprecation.pyi b/elasticsearch/client/deprecation.pyi index f983ad01..bb3409d1 100644 --- a/elasticsearch/client/deprecation.pyi +++ b/elasticsearch/client/deprecation.pyi @@ -15,7 +15,8 @@ # specific language governing permissions and limitations # under the License. -from typing import Any, MutableMapping, Optional, Union, Collection +from typing import Any, Collection, MutableMapping, Optional, Union + from .utils import NamespacedClient class DeprecationClient(NamespacedClient): diff --git a/elasticsearch/client/enrich.py b/elasticsearch/client/enrich.py index 6edd2ea6..77b4a60e 100644 --- a/elasticsearch/client/enrich.py +++ b/elasticsearch/client/enrich.py @@ -15,7 +15,7 @@ # specific language governing permissions and limitations # under the License. -from .utils import NamespacedClient, query_params, _make_path, SKIP_IN_PATH +from .utils import SKIP_IN_PATH, NamespacedClient, _make_path, query_params class EnrichClient(NamespacedClient): diff --git a/elasticsearch/client/enrich.pyi b/elasticsearch/client/enrich.pyi index 288c3417..3a2642bb 100644 --- a/elasticsearch/client/enrich.pyi +++ b/elasticsearch/client/enrich.pyi @@ -15,7 +15,8 @@ # specific language governing permissions and limitations # under the License. -from typing import Any, MutableMapping, Optional, Union, Collection +from typing import Any, Collection, MutableMapping, Optional, Union + from .utils import NamespacedClient class EnrichClient(NamespacedClient): diff --git a/elasticsearch/client/eql.py b/elasticsearch/client/eql.py index 52b7c143..e031b742 100644 --- a/elasticsearch/client/eql.py +++ b/elasticsearch/client/eql.py @@ -15,7 +15,7 @@ # specific language governing permissions and limitations # under the License. -from .utils import NamespacedClient, SKIP_IN_PATH, query_params, _make_path +from .utils import SKIP_IN_PATH, NamespacedClient, _make_path, query_params class EqlClient(NamespacedClient): @@ -26,11 +26,6 @@ class EqlClient(NamespacedClient): ``_ - .. warning:: - - This API is **beta** so may include breaking changes - or be removed in a future version - :arg index: The name of the index to scope the operation :arg body: Eql request body. Use the `query` to limit the query scope. @@ -62,11 +57,6 @@ class EqlClient(NamespacedClient): ``_ - .. warning:: - - This API is **beta** so may include breaking changes - or be removed in a future version - :arg id: The async search ID """ if id in SKIP_IN_PATH: @@ -84,11 +74,6 @@ class EqlClient(NamespacedClient): ``_ - .. warning:: - - This API is **beta** so may include breaking changes - or be removed in a future version - :arg id: The async search ID :arg keep_alive: Update the time interval in which the results (partial or final) for this search will be available Default: 5d diff --git a/elasticsearch/client/eql.pyi b/elasticsearch/client/eql.pyi index 88bbb089..31edb756 100644 --- a/elasticsearch/client/eql.pyi +++ b/elasticsearch/client/eql.pyi @@ -15,7 +15,8 @@ # specific language governing permissions and limitations # under the License. -from typing import Any, MutableMapping, Optional, Union, Collection +from typing import Any, Collection, MutableMapping, Optional, Union + from .utils import NamespacedClient class EqlClient(NamespacedClient): diff --git a/elasticsearch/client/graph.py b/elasticsearch/client/graph.py index 4203cbd3..dc422ba0 100644 --- a/elasticsearch/client/graph.py +++ b/elasticsearch/client/graph.py @@ -15,7 +15,7 @@ # specific language governing permissions and limitations # under the License. -from .utils import NamespacedClient, query_params, _make_path, SKIP_IN_PATH +from .utils import SKIP_IN_PATH, NamespacedClient, _make_path, query_params class GraphClient(NamespacedClient): diff --git a/elasticsearch/client/graph.pyi b/elasticsearch/client/graph.pyi index a00b25fe..ecc8eef4 100644 --- a/elasticsearch/client/graph.pyi +++ b/elasticsearch/client/graph.pyi @@ -15,7 +15,8 @@ # specific language governing permissions and limitations # under the License. -from typing import Any, MutableMapping, Optional, Union, Collection +from typing import Any, Collection, MutableMapping, Optional, Union + from .utils import NamespacedClient class GraphClient(NamespacedClient): diff --git a/elasticsearch/client/ilm.py b/elasticsearch/client/ilm.py index 677a3a4a..f9a6aaa2 100644 --- a/elasticsearch/client/ilm.py +++ b/elasticsearch/client/ilm.py @@ -15,7 +15,7 @@ # specific language governing permissions and limitations # under the License. -from .utils import NamespacedClient, query_params, _make_path, SKIP_IN_PATH +from .utils import SKIP_IN_PATH, NamespacedClient, _make_path, query_params class IlmClient(NamespacedClient): diff --git a/elasticsearch/client/ilm.pyi b/elasticsearch/client/ilm.pyi index 1a3b473d..d61d32b9 100644 --- a/elasticsearch/client/ilm.pyi +++ b/elasticsearch/client/ilm.pyi @@ -15,7 +15,8 @@ # specific language governing permissions and limitations # under the License. -from typing import Any, MutableMapping, Optional, Union, Collection +from typing import Any, Collection, MutableMapping, Optional, Union + from .utils import NamespacedClient class IlmClient(NamespacedClient): diff --git a/elasticsearch/client/indices.py b/elasticsearch/client/indices.py index a4d32f3f..5b9d798b 100644 --- a/elasticsearch/client/indices.py +++ b/elasticsearch/client/indices.py @@ -15,7 +15,7 @@ # specific language governing permissions and limitations # under the License. -from .utils import NamespacedClient, query_params, _make_path, SKIP_IN_PATH +from .utils import SKIP_IN_PATH, NamespacedClient, _make_path, query_params class IndicesClient(NamespacedClient): @@ -1621,3 +1621,22 @@ class IndicesClient(NamespacedClient): params=params, headers=headers, ) + + @query_params() + def migrate_to_data_stream(self, name, params=None, headers=None): + """ + Migrates an alias to a data stream + + ``_ + + :arg name: The name of the alias to migrate + """ + if name in SKIP_IN_PATH: + raise ValueError("Empty value passed for a required argument 'name'.") + + return self.transport.perform_request( + "POST", + _make_path("_data_stream", "_migrate", name), + params=params, + headers=headers, + ) diff --git a/elasticsearch/client/indices.pyi b/elasticsearch/client/indices.pyi index 95c7f5a6..d72106aa 100644 --- a/elasticsearch/client/indices.pyi +++ b/elasticsearch/client/indices.pyi @@ -15,7 +15,8 @@ # specific language governing permissions and limitations # under the License. -from typing import Any, MutableMapping, Optional, Union, Collection +from typing import Any, Collection, MutableMapping, Optional, Union + from .utils import NamespacedClient class IndicesClient(NamespacedClient): @@ -1079,3 +1080,18 @@ class IndicesClient(NamespacedClient): params: Optional[MutableMapping[str, Any]] = ..., headers: Optional[MutableMapping[str, str]] = ... ) -> Any: ... + def migrate_to_data_stream( + self, + name: Any, + *, + pretty: Optional[bool] = ..., + human: Optional[bool] = ..., + error_trace: Optional[bool] = ..., + format: Optional[str] = ..., + filter_path: Optional[Union[str, Collection[str]]] = ..., + request_timeout: Optional[Union[int, float]] = ..., + ignore: Optional[Union[int, Collection[int]]] = ..., + opaque_id: Optional[str] = ..., + params: Optional[MutableMapping[str, Any]] = ..., + headers: Optional[MutableMapping[str, str]] = ... + ) -> Any: ... diff --git a/elasticsearch/client/ingest.py b/elasticsearch/client/ingest.py index 854aced6..0242585d 100644 --- a/elasticsearch/client/ingest.py +++ b/elasticsearch/client/ingest.py @@ -15,7 +15,7 @@ # specific language governing permissions and limitations # under the License. -from .utils import NamespacedClient, query_params, _make_path, SKIP_IN_PATH +from .utils import SKIP_IN_PATH, NamespacedClient, _make_path, query_params class IngestClient(NamespacedClient): diff --git a/elasticsearch/client/ingest.pyi b/elasticsearch/client/ingest.pyi index 7a9cf610..c54e49c2 100644 --- a/elasticsearch/client/ingest.pyi +++ b/elasticsearch/client/ingest.pyi @@ -15,7 +15,8 @@ # specific language governing permissions and limitations # under the License. -from typing import Any, MutableMapping, Optional, Union, Collection +from typing import Any, Collection, MutableMapping, Optional, Union + from .utils import NamespacedClient class IngestClient(NamespacedClient): diff --git a/elasticsearch/client/license.pyi b/elasticsearch/client/license.pyi index a37a6df2..6cc6237c 100644 --- a/elasticsearch/client/license.pyi +++ b/elasticsearch/client/license.pyi @@ -15,7 +15,8 @@ # specific language governing permissions and limitations # under the License. -from typing import Any, MutableMapping, Optional, Union, Collection +from typing import Any, Collection, MutableMapping, Optional, Union + from .utils import NamespacedClient class LicenseClient(NamespacedClient): diff --git a/elasticsearch/client/migration.py b/elasticsearch/client/migration.py index 60edfe8a..377b6226 100644 --- a/elasticsearch/client/migration.py +++ b/elasticsearch/client/migration.py @@ -15,7 +15,7 @@ # specific language governing permissions and limitations # under the License. -from .utils import NamespacedClient, query_params, _make_path +from .utils import NamespacedClient, _make_path, query_params class MigrationClient(NamespacedClient): diff --git a/elasticsearch/client/migration.pyi b/elasticsearch/client/migration.pyi index fd628b2d..9522627a 100644 --- a/elasticsearch/client/migration.pyi +++ b/elasticsearch/client/migration.pyi @@ -15,7 +15,8 @@ # specific language governing permissions and limitations # under the License. -from typing import Any, MutableMapping, Optional, Union, Collection +from typing import Any, Collection, MutableMapping, Optional, Union + from .utils import NamespacedClient class MigrationClient(NamespacedClient): diff --git a/elasticsearch/client/ml.py b/elasticsearch/client/ml.py index dca7d088..c243e1a8 100644 --- a/elasticsearch/client/ml.py +++ b/elasticsearch/client/ml.py @@ -15,7 +15,7 @@ # specific language governing permissions and limitations # under the License. -from .utils import NamespacedClient, query_params, _make_path, SKIP_IN_PATH, _bulk_body +from .utils import SKIP_IN_PATH, NamespacedClient, _bulk_body, _make_path, query_params class MlClient(NamespacedClient): @@ -247,79 +247,6 @@ class MlClient(NamespacedClient): headers=headers, ) - @query_params( - "charset", - "column_names", - "delimiter", - "explain", - "format", - "grok_pattern", - "has_header_row", - "line_merge_size_limit", - "lines_to_sample", - "quote", - "should_trim_fields", - "timeout", - "timestamp_field", - "timestamp_format", - ) - def find_file_structure(self, body, params=None, headers=None): - """ - Finds the structure of a text file. The text file must contain data that is - suitable to be ingested into Elasticsearch. - - ``_ - - .. warning:: - - This API is **experimental** so may include breaking changes - or be removed in a future version - - :arg body: The contents of the file to be analyzed - :arg charset: Optional parameter to specify the character set of - the file - :arg column_names: Optional parameter containing a comma - separated list of the column names for a delimited file - :arg delimiter: Optional parameter to specify the delimiter - character for a delimited file - must be a single character - :arg explain: Whether to include a commentary on how the - structure was derived - :arg format: Optional parameter to specify the high level file - format Valid choices: ndjson, xml, delimited, semi_structured_text - :arg grok_pattern: Optional parameter to specify the Grok - pattern that should be used to extract fields from messages in a semi- - structured text file - :arg has_header_row: Optional parameter to specify whether a - delimited file includes the column names in its first row - :arg line_merge_size_limit: Maximum number of characters - permitted in a single message when lines are merged to create messages. - Default: 10000 - :arg lines_to_sample: How many lines of the file should be - included in the analysis Default: 1000 - :arg quote: Optional parameter to specify the quote character - for a delimited file - must be a single character - :arg should_trim_fields: Optional parameter to specify whether - the values between delimiters in a delimited file should have whitespace - trimmed from them - :arg timeout: Timeout after which the analysis will be aborted - Default: 25s - :arg timestamp_field: Optional parameter to specify the - timestamp field in the file - :arg timestamp_format: Optional parameter to specify the - timestamp format in the file - may be either a Joda or Java time format - """ - if body in SKIP_IN_PATH: - raise ValueError("Empty value passed for a required argument 'body'.") - - body = _bulk_body(self.transport.serializer, body) - return self.transport.perform_request( - "POST", - "/_ml/find_file_structure", - params=params, - headers=headers, - body=body, - ) - @query_params("advance_time", "calc_interim", "end", "skip_time", "start") def flush_job(self, job_id, body=None, params=None, headers=None): """ diff --git a/elasticsearch/client/ml.pyi b/elasticsearch/client/ml.pyi index e1dec2ad..1284375b 100644 --- a/elasticsearch/client/ml.pyi +++ b/elasticsearch/client/ml.pyi @@ -15,7 +15,8 @@ # specific language governing permissions and limitations # under the License. -from typing import Any, MutableMapping, Optional, Union, Collection +from typing import Any, Collection, MutableMapping, Optional, Union + from .utils import NamespacedClient class MlClient(NamespacedClient): @@ -186,34 +187,6 @@ class MlClient(NamespacedClient): params: Optional[MutableMapping[str, Any]] = ..., headers: Optional[MutableMapping[str, str]] = ... ) -> Any: ... - def find_file_structure( - self, - *, - body: Any, - charset: Optional[Any] = ..., - column_names: Optional[Any] = ..., - delimiter: Optional[Any] = ..., - explain: Optional[Any] = ..., - format: Optional[Any] = ..., - grok_pattern: Optional[Any] = ..., - has_header_row: Optional[Any] = ..., - line_merge_size_limit: Optional[Any] = ..., - lines_to_sample: Optional[Any] = ..., - quote: Optional[Any] = ..., - should_trim_fields: Optional[Any] = ..., - timeout: Optional[Any] = ..., - timestamp_field: Optional[Any] = ..., - timestamp_format: Optional[Any] = ..., - pretty: Optional[bool] = ..., - human: Optional[bool] = ..., - error_trace: Optional[bool] = ..., - filter_path: Optional[Union[str, Collection[str]]] = ..., - request_timeout: Optional[Union[int, float]] = ..., - ignore: Optional[Union[int, Collection[int]]] = ..., - opaque_id: Optional[str] = ..., - params: Optional[MutableMapping[str, Any]] = ..., - headers: Optional[MutableMapping[str, str]] = ... - ) -> Any: ... def flush_job( self, job_id: Any, diff --git a/elasticsearch/client/monitoring.py b/elasticsearch/client/monitoring.py index a9da548b..4e529245 100644 --- a/elasticsearch/client/monitoring.py +++ b/elasticsearch/client/monitoring.py @@ -15,7 +15,7 @@ # specific language governing permissions and limitations # under the License. -from .utils import NamespacedClient, query_params, _make_path, SKIP_IN_PATH, _bulk_body +from .utils import SKIP_IN_PATH, NamespacedClient, _bulk_body, _make_path, query_params class MonitoringClient(NamespacedClient): diff --git a/elasticsearch/client/monitoring.pyi b/elasticsearch/client/monitoring.pyi index 3a9fdbed..1cabf1b3 100644 --- a/elasticsearch/client/monitoring.pyi +++ b/elasticsearch/client/monitoring.pyi @@ -15,7 +15,8 @@ # specific language governing permissions and limitations # under the License. -from typing import Any, MutableMapping, Optional, Union, Collection +from typing import Any, Collection, MutableMapping, Optional, Union + from .utils import NamespacedClient class MonitoringClient(NamespacedClient): diff --git a/elasticsearch/client/nodes.py b/elasticsearch/client/nodes.py index a670e143..d6e5c6e7 100644 --- a/elasticsearch/client/nodes.py +++ b/elasticsearch/client/nodes.py @@ -15,7 +15,7 @@ # specific language governing permissions and limitations # under the License. -from .utils import NamespacedClient, query_params, _make_path +from .utils import NamespacedClient, _make_path, query_params class NodesClient(NamespacedClient): diff --git a/elasticsearch/client/nodes.pyi b/elasticsearch/client/nodes.pyi index 021e816c..4f8b0c33 100644 --- a/elasticsearch/client/nodes.pyi +++ b/elasticsearch/client/nodes.pyi @@ -15,7 +15,8 @@ # specific language governing permissions and limitations # under the License. -from typing import Any, MutableMapping, Optional, Union, Collection +from typing import Any, Collection, MutableMapping, Optional, Union + from .utils import NamespacedClient class NodesClient(NamespacedClient): diff --git a/elasticsearch/client/remote.pyi b/elasticsearch/client/remote.pyi index a624d84e..ca422fcb 100644 --- a/elasticsearch/client/remote.pyi +++ b/elasticsearch/client/remote.pyi @@ -15,7 +15,8 @@ # specific language governing permissions and limitations # under the License. -from typing import Any, MutableMapping, Optional, Union, Collection +from typing import Any, Collection, MutableMapping, Optional, Union + from .utils import NamespacedClient class RemoteClient(NamespacedClient): diff --git a/elasticsearch/client/rollup.py b/elasticsearch/client/rollup.py index 251c04e5..ef120fcb 100644 --- a/elasticsearch/client/rollup.py +++ b/elasticsearch/client/rollup.py @@ -15,7 +15,7 @@ # specific language governing permissions and limitations # under the License. -from .utils import NamespacedClient, query_params, _make_path, SKIP_IN_PATH +from .utils import SKIP_IN_PATH, NamespacedClient, _make_path, query_params class RollupClient(NamespacedClient): @@ -216,22 +216,23 @@ class RollupClient(NamespacedClient): ) @query_params() - def rollup(self, index, body, params=None, headers=None): + def rollup(self, index, rollup_index, body, params=None, headers=None): """ Rollup an index ``_ :arg index: The index to roll up + :arg rollup_index: The name of the rollup index to create :arg body: The rollup configuration """ - for param in (index, body): + for param in (index, rollup_index, body): if param in SKIP_IN_PATH: raise ValueError("Empty value passed for a required argument.") return self.transport.perform_request( "POST", - _make_path(index, "_rollup"), + _make_path(index, "_rollup", rollup_index), params=params, headers=headers, body=body, diff --git a/elasticsearch/client/rollup.pyi b/elasticsearch/client/rollup.pyi index f2ada5db..b8c3282c 100644 --- a/elasticsearch/client/rollup.pyi +++ b/elasticsearch/client/rollup.pyi @@ -15,7 +15,8 @@ # specific language governing permissions and limitations # under the License. -from typing import Any, MutableMapping, Optional, Union, Collection +from typing import Any, Collection, MutableMapping, Optional, Union + from .utils import NamespacedClient class RollupClient(NamespacedClient): @@ -149,6 +150,7 @@ class RollupClient(NamespacedClient): def rollup( self, index: Any, + rollup_index: Any, *, body: Any, pretty: Optional[bool] = ..., diff --git a/elasticsearch/client/searchable_snapshots.py b/elasticsearch/client/searchable_snapshots.py index 7426b4a0..9466a5cb 100644 --- a/elasticsearch/client/searchable_snapshots.py +++ b/elasticsearch/client/searchable_snapshots.py @@ -15,7 +15,7 @@ # specific language governing permissions and limitations # under the License. -from .utils import NamespacedClient, query_params, _make_path, SKIP_IN_PATH +from .utils import SKIP_IN_PATH, NamespacedClient, _make_path, query_params class SearchableSnapshotsClient(NamespacedClient): diff --git a/elasticsearch/client/searchable_snapshots.pyi b/elasticsearch/client/searchable_snapshots.pyi index e488b660..01821f13 100644 --- a/elasticsearch/client/searchable_snapshots.pyi +++ b/elasticsearch/client/searchable_snapshots.pyi @@ -15,7 +15,8 @@ # specific language governing permissions and limitations # under the License. -from typing import Any, MutableMapping, Optional, Union, Collection +from typing import Any, Collection, MutableMapping, Optional, Union + from .utils import NamespacedClient class SearchableSnapshotsClient(NamespacedClient): diff --git a/elasticsearch/client/security.py b/elasticsearch/client/security.py index 91eb1c29..0b1c4c39 100644 --- a/elasticsearch/client/security.py +++ b/elasticsearch/client/security.py @@ -15,7 +15,7 @@ # specific language governing permissions and limitations # under the License. -from .utils import NamespacedClient, query_params, _make_path, SKIP_IN_PATH +from .utils import SKIP_IN_PATH, NamespacedClient, _make_path, query_params class SecurityClient(NamespacedClient): diff --git a/elasticsearch/client/security.pyi b/elasticsearch/client/security.pyi index b1f7cf2a..c1105b6b 100644 --- a/elasticsearch/client/security.pyi +++ b/elasticsearch/client/security.pyi @@ -15,7 +15,8 @@ # specific language governing permissions and limitations # under the License. -from typing import Any, MutableMapping, Optional, Union, Collection +from typing import Any, Collection, MutableMapping, Optional, Union + from .utils import NamespacedClient class SecurityClient(NamespacedClient): diff --git a/elasticsearch/client/slm.py b/elasticsearch/client/slm.py index 4e5690c9..fca5e56f 100644 --- a/elasticsearch/client/slm.py +++ b/elasticsearch/client/slm.py @@ -15,7 +15,7 @@ # specific language governing permissions and limitations # under the License. -from .utils import NamespacedClient, query_params, _make_path, SKIP_IN_PATH +from .utils import SKIP_IN_PATH, NamespacedClient, _make_path, query_params class SlmClient(NamespacedClient): diff --git a/elasticsearch/client/slm.pyi b/elasticsearch/client/slm.pyi index fb0dbe56..2c398850 100644 --- a/elasticsearch/client/slm.pyi +++ b/elasticsearch/client/slm.pyi @@ -15,7 +15,8 @@ # specific language governing permissions and limitations # under the License. -from typing import Any, MutableMapping, Optional, Union, Collection +from typing import Any, Collection, MutableMapping, Optional, Union + from .utils import NamespacedClient class SlmClient(NamespacedClient): diff --git a/elasticsearch/client/snapshot.py b/elasticsearch/client/snapshot.py index 0964e7d8..a007d2dd 100644 --- a/elasticsearch/client/snapshot.py +++ b/elasticsearch/client/snapshot.py @@ -15,7 +15,7 @@ # specific language governing permissions and limitations # under the License. -from .utils import NamespacedClient, query_params, _make_path, SKIP_IN_PATH +from .utils import SKIP_IN_PATH, NamespacedClient, _make_path, query_params class SnapshotClient(NamespacedClient): diff --git a/elasticsearch/client/snapshot.pyi b/elasticsearch/client/snapshot.pyi index 605689da..456ca0cb 100644 --- a/elasticsearch/client/snapshot.pyi +++ b/elasticsearch/client/snapshot.pyi @@ -15,7 +15,8 @@ # specific language governing permissions and limitations # under the License. -from typing import Any, MutableMapping, Optional, Union, Collection +from typing import Any, Collection, MutableMapping, Optional, Union + from .utils import NamespacedClient class SnapshotClient(NamespacedClient): diff --git a/elasticsearch/client/sql.py b/elasticsearch/client/sql.py index 85d8b7c7..8a0def68 100644 --- a/elasticsearch/client/sql.py +++ b/elasticsearch/client/sql.py @@ -15,7 +15,7 @@ # specific language governing permissions and limitations # under the License. -from .utils import NamespacedClient, query_params, SKIP_IN_PATH +from .utils import SKIP_IN_PATH, NamespacedClient, query_params class SqlClient(NamespacedClient): diff --git a/elasticsearch/client/sql.pyi b/elasticsearch/client/sql.pyi index 4fa012c1..7e9933df 100644 --- a/elasticsearch/client/sql.pyi +++ b/elasticsearch/client/sql.pyi @@ -15,7 +15,8 @@ # specific language governing permissions and limitations # under the License. -from typing import Any, MutableMapping, Optional, Union, Collection +from typing import Any, Collection, MutableMapping, Optional, Union + from .utils import NamespacedClient class SqlClient(NamespacedClient): diff --git a/elasticsearch/client/ssl.pyi b/elasticsearch/client/ssl.pyi index 0835b175..89201684 100644 --- a/elasticsearch/client/ssl.pyi +++ b/elasticsearch/client/ssl.pyi @@ -15,7 +15,8 @@ # specific language governing permissions and limitations # under the License. -from typing import Any, MutableMapping, Optional, Union, Collection +from typing import Any, Collection, MutableMapping, Optional, Union + from .utils import NamespacedClient class SslClient(NamespacedClient): diff --git a/elasticsearch/client/tasks.py b/elasticsearch/client/tasks.py index 15feb3d6..bf1fbc18 100644 --- a/elasticsearch/client/tasks.py +++ b/elasticsearch/client/tasks.py @@ -16,7 +16,8 @@ # under the License. import warnings -from .utils import NamespacedClient, query_params, _make_path, SKIP_IN_PATH + +from .utils import SKIP_IN_PATH, NamespacedClient, _make_path, query_params class TasksClient(NamespacedClient): diff --git a/elasticsearch/client/tasks.pyi b/elasticsearch/client/tasks.pyi index f1a68dae..23e61cc0 100644 --- a/elasticsearch/client/tasks.pyi +++ b/elasticsearch/client/tasks.pyi @@ -15,7 +15,8 @@ # specific language governing permissions and limitations # under the License. -from typing import Any, MutableMapping, Optional, Union, Collection +from typing import Any, Collection, MutableMapping, Optional, Union + from .utils import NamespacedClient class TasksClient(NamespacedClient): diff --git a/elasticsearch/client/text_structure.py b/elasticsearch/client/text_structure.py new file mode 100644 index 00000000..00e22309 --- /dev/null +++ b/elasticsearch/client/text_structure.py @@ -0,0 +1,93 @@ +# Licensed to Elasticsearch B.V. under one or more contributor +# license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright +# ownership. Elasticsearch B.V. licenses this file to you under +# the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + +from .utils import SKIP_IN_PATH, NamespacedClient, _bulk_body, query_params + + +class TextStructureClient(NamespacedClient): + @query_params( + "charset", + "column_names", + "delimiter", + "explain", + "format", + "grok_pattern", + "has_header_row", + "line_merge_size_limit", + "lines_to_sample", + "quote", + "should_trim_fields", + "timeout", + "timestamp_field", + "timestamp_format", + ) + def find_structure(self, body, params=None, headers=None): + """ + Finds the structure of a text file. The text file must contain data that is + suitable to be ingested into Elasticsearch. + + ``_ + + .. warning:: + + This API is **experimental** so may include breaking changes + or be removed in a future version + + :arg body: The contents of the file to be analyzed + :arg charset: Optional parameter to specify the character set of + the file + :arg column_names: Optional parameter containing a comma + separated list of the column names for a delimited file + :arg delimiter: Optional parameter to specify the delimiter + character for a delimited file - must be a single character + :arg explain: Whether to include a commentary on how the + structure was derived + :arg format: Optional parameter to specify the high level file + format Valid choices: ndjson, xml, delimited, semi_structured_text + :arg grok_pattern: Optional parameter to specify the Grok + pattern that should be used to extract fields from messages in a semi- + structured text file + :arg has_header_row: Optional parameter to specify whether a + delimited file includes the column names in its first row + :arg line_merge_size_limit: Maximum number of characters + permitted in a single message when lines are merged to create messages. + Default: 10000 + :arg lines_to_sample: How many lines of the file should be + included in the analysis Default: 1000 + :arg quote: Optional parameter to specify the quote character + for a delimited file - must be a single character + :arg should_trim_fields: Optional parameter to specify whether + the values between delimiters in a delimited file should have whitespace + trimmed from them + :arg timeout: Timeout after which the analysis will be aborted + Default: 25s + :arg timestamp_field: Optional parameter to specify the + timestamp field in the file + :arg timestamp_format: Optional parameter to specify the + timestamp format in the file - may be either a Joda or Java time format + """ + if body in SKIP_IN_PATH: + raise ValueError("Empty value passed for a required argument 'body'.") + + body = _bulk_body(self.transport.serializer, body) + return self.transport.perform_request( + "POST", + "/_text_structure/find_structure", + params=params, + headers=headers, + body=body, + ) diff --git a/elasticsearch/client/text_structure.pyi b/elasticsearch/client/text_structure.pyi new file mode 100644 index 00000000..fbe03950 --- /dev/null +++ b/elasticsearch/client/text_structure.pyi @@ -0,0 +1,50 @@ +# Licensed to Elasticsearch B.V. under one or more contributor +# license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright +# ownership. Elasticsearch B.V. licenses this file to you under +# the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + +from typing import Any, Collection, MutableMapping, Optional, Union + +from .utils import NamespacedClient + +class TextStructureClient(NamespacedClient): + def find_structure( + self, + *, + body: Any, + charset: Optional[Any] = ..., + column_names: Optional[Any] = ..., + delimiter: Optional[Any] = ..., + explain: Optional[Any] = ..., + format: Optional[Any] = ..., + grok_pattern: Optional[Any] = ..., + has_header_row: Optional[Any] = ..., + line_merge_size_limit: Optional[Any] = ..., + lines_to_sample: Optional[Any] = ..., + quote: Optional[Any] = ..., + should_trim_fields: Optional[Any] = ..., + timeout: Optional[Any] = ..., + timestamp_field: Optional[Any] = ..., + timestamp_format: Optional[Any] = ..., + pretty: Optional[bool] = ..., + human: Optional[bool] = ..., + error_trace: Optional[bool] = ..., + filter_path: Optional[Union[str, Collection[str]]] = ..., + request_timeout: Optional[Union[int, float]] = ..., + ignore: Optional[Union[int, Collection[int]]] = ..., + opaque_id: Optional[str] = ..., + params: Optional[MutableMapping[str, Any]] = ..., + headers: Optional[MutableMapping[str, str]] = ... + ) -> Any: ... diff --git a/elasticsearch/client/transform.py b/elasticsearch/client/transform.py index 2ecc8f88..94405312 100644 --- a/elasticsearch/client/transform.py +++ b/elasticsearch/client/transform.py @@ -15,7 +15,7 @@ # specific language governing permissions and limitations # under the License. -from .utils import NamespacedClient, query_params, _make_path, SKIP_IN_PATH +from .utils import SKIP_IN_PATH, NamespacedClient, _make_path, query_params class TransformClient(NamespacedClient): diff --git a/elasticsearch/client/transform.pyi b/elasticsearch/client/transform.pyi index 5450af0d..e2c150e4 100644 --- a/elasticsearch/client/transform.pyi +++ b/elasticsearch/client/transform.pyi @@ -15,7 +15,8 @@ # specific language governing permissions and limitations # under the License. -from typing import Any, MutableMapping, Optional, Union, Collection +from typing import Any, Collection, MutableMapping, Optional, Union + from .utils import NamespacedClient class TransformClient(NamespacedClient): diff --git a/elasticsearch/client/utils.py b/elasticsearch/client/utils.py index 63795802..738eccde 100644 --- a/elasticsearch/client/utils.py +++ b/elasticsearch/client/utils.py @@ -20,7 +20,8 @@ from __future__ import unicode_literals import weakref from datetime import date, datetime from functools import wraps -from ..compat import string_types, quote, PY2, unquote, urlparse + +from ..compat import PY2, quote, string_types, unquote, urlparse # parts of URL to be omitted SKIP_IN_PATH = (None, "", b"", [], ()) diff --git a/elasticsearch/client/utils.pyi b/elasticsearch/client/utils.pyi index a5e99d1b..e7ec3cad 100644 --- a/elasticsearch/client/utils.pyi +++ b/elasticsearch/client/utils.pyi @@ -18,16 +18,17 @@ from __future__ import unicode_literals from typing import ( - Collection, Any, - Optional, - Union, + Callable, + Collection, Dict, List, + Optional, Tuple, - Callable, TypeVar, + Union, ) + from ..client import Elasticsearch from ..serializer import Serializer from ..transport import Transport diff --git a/elasticsearch/client/watcher.py b/elasticsearch/client/watcher.py index f01a75f2..80d53ae0 100644 --- a/elasticsearch/client/watcher.py +++ b/elasticsearch/client/watcher.py @@ -15,7 +15,7 @@ # specific language governing permissions and limitations # under the License. -from .utils import NamespacedClient, query_params, _make_path, SKIP_IN_PATH +from .utils import SKIP_IN_PATH, NamespacedClient, _make_path, query_params class WatcherClient(NamespacedClient): diff --git a/elasticsearch/client/watcher.pyi b/elasticsearch/client/watcher.pyi index e33bf4c1..8a42d426 100644 --- a/elasticsearch/client/watcher.pyi +++ b/elasticsearch/client/watcher.pyi @@ -15,7 +15,8 @@ # specific language governing permissions and limitations # under the License. -from typing import Any, MutableMapping, Optional, Union, Collection +from typing import Any, Collection, MutableMapping, Optional, Union + from .utils import NamespacedClient class WatcherClient(NamespacedClient): diff --git a/elasticsearch/client/xpack.pyi b/elasticsearch/client/xpack.pyi index c50e56ab..6d817f33 100644 --- a/elasticsearch/client/xpack.pyi +++ b/elasticsearch/client/xpack.pyi @@ -15,7 +15,8 @@ # specific language governing permissions and limitations # under the License. -from typing import Any, MutableMapping, Optional, Union, Collection +from typing import Any, Collection, MutableMapping, Optional, Union + from .utils import NamespacedClient class XPackClient(NamespacedClient): diff --git a/elasticsearch/compat.py b/elasticsearch/compat.py index d42cb026..644f0d87 100644 --- a/elasticsearch/compat.py +++ b/elasticsearch/compat.py @@ -21,13 +21,14 @@ PY2 = sys.version_info[0] == 2 if PY2: string_types = (basestring,) # noqa: F821 - from urllib import quote_plus, quote, urlencode, unquote - from urlparse import urlparse from itertools import imap as map + from urllib import quote, quote_plus, unquote, urlencode + from Queue import Queue + from urlparse import urlparse else: string_types = str, bytes - from urllib.parse import quote, quote_plus, urlencode, urlparse, unquote + from urllib.parse import quote, quote_plus, unquote, urlencode, urlparse map = map from queue import Queue diff --git a/elasticsearch/compat.pyi b/elasticsearch/compat.pyi index 00eefc9b..c86afbf3 100644 --- a/elasticsearch/compat.pyi +++ b/elasticsearch/compat.pyi @@ -22,23 +22,20 @@ PY2: bool string_types: Tuple[type, ...] if sys.version_info[0] == 2: - from urllib import ( - quote_plus as quote_plus, - quote as quote, - urlencode as urlencode, - unquote as unquote, - ) - from urlparse import urlparse as urlparse from itertools import imap as map + from urllib import quote as quote + from urllib import quote_plus as quote_plus + from urllib import unquote as unquote + from urllib import urlencode as urlencode + from Queue import Queue as Queue + from urlparse import urlparse as urlparse else: - from urllib.parse import ( - quote as quote, - quote_plus as quote_plus, - urlencode as urlencode, - urlparse as urlparse, - unquote as unquote, - ) + from urllib.parse import quote as quote + from urllib.parse import quote_plus as quote_plus + from urllib.parse import unquote as unquote + from urllib.parse import urlencode as urlencode + from urllib.parse import urlparse as urlparse map = map from queue import Queue as Queue diff --git a/elasticsearch/connection/__init__.pyi b/elasticsearch/connection/__init__.pyi index 95a73ddd..6a103138 100644 --- a/elasticsearch/connection/__init__.pyi +++ b/elasticsearch/connection/__init__.pyi @@ -17,7 +17,5 @@ from .base import Connection as Connection from .http_requests import RequestsHttpConnection as RequestsHttpConnection -from .http_urllib3 import ( - Urllib3HttpConnection as Urllib3HttpConnection, - create_ssl_context as create_ssl_context, -) +from .http_urllib3 import Urllib3HttpConnection as Urllib3HttpConnection +from .http_urllib3 import create_ssl_context as create_ssl_context diff --git a/elasticsearch/connection/base.py b/elasticsearch/connection/base.py index ee2cbac0..c4a7bfe8 100644 --- a/elasticsearch/connection/base.py +++ b/elasticsearch/connection/base.py @@ -15,26 +15,26 @@ # specific language governing permissions and limitations # under the License. -import logging import binascii import gzip import io +import logging import re -from platform import python_version import warnings +from platform import python_version try: import simplejson as json except ImportError: import json -from ..exceptions import ( - TransportError, - ImproperlyConfigured, - ElasticsearchWarning, - HTTP_EXCEPTIONS, -) from .. import __versionstr__ +from ..exceptions import ( + HTTP_EXCEPTIONS, + ElasticsearchWarning, + ImproperlyConfigured, + TransportError, +) logger = logging.getLogger("elasticsearch") diff --git a/elasticsearch/connection/base.pyi b/elasticsearch/connection/base.pyi index d2eca4ed..f0149bc0 100644 --- a/elasticsearch/connection/base.pyi +++ b/elasticsearch/connection/base.pyi @@ -16,19 +16,18 @@ # under the License. import logging - from typing import ( - Union, - Optional, - Mapping, - MutableMapping, - Tuple, - List, - NoReturn, - Dict, - Sequence, Any, Collection, + Dict, + List, + Mapping, + MutableMapping, + NoReturn, + Optional, + Sequence, + Tuple, + Union, ) logger: logging.Logger diff --git a/elasticsearch/connection/http_requests.py b/elasticsearch/connection/http_requests.py index 3fab0a9c..4480079f 100644 --- a/elasticsearch/connection/http_requests.py +++ b/elasticsearch/connection/http_requests.py @@ -18,15 +18,15 @@ import time import warnings -from .base import Connection +from ..compat import string_types, urlencode from ..exceptions import ( ConnectionError, - ImproperlyConfigured, ConnectionTimeout, + ImproperlyConfigured, SSLError, ) -from ..compat import urlencode, string_types from ..utils import _client_meta_version +from .base import Connection try: import requests diff --git a/elasticsearch/connection/http_requests.pyi b/elasticsearch/connection/http_requests.pyi index df86edf0..fe3351a5 100644 --- a/elasticsearch/connection/http_requests.pyi +++ b/elasticsearch/connection/http_requests.pyi @@ -15,8 +15,10 @@ # specific language governing permissions and limitations # under the License. -from typing import Optional, Any, Mapping +from typing import Any, Mapping, Optional + import requests + from .base import Connection class RequestsHttpConnection(Connection): diff --git a/elasticsearch/connection/http_urllib3.py b/elasticsearch/connection/http_urllib3.py index 74ab2c20..73a207d0 100644 --- a/elasticsearch/connection/http_urllib3.py +++ b/elasticsearch/connection/http_urllib3.py @@ -15,22 +15,24 @@ # specific language governing permissions and limitations # under the License. -import time import ssl -import urllib3 # type: ignore -from urllib3.exceptions import ReadTimeoutError, SSLError as UrllibSSLError # type: ignore -from urllib3.util.retry import Retry # type: ignore +import time import warnings -from .base import Connection +import urllib3 # type: ignore +from urllib3.exceptions import ReadTimeoutError +from urllib3.exceptions import SSLError as UrllibSSLError # type: ignore +from urllib3.util.retry import Retry # type: ignore + +from ..compat import urlencode from ..exceptions import ( ConnectionError, - ImproperlyConfigured, ConnectionTimeout, + ImproperlyConfigured, SSLError, ) -from ..compat import urlencode from ..utils import _client_meta_version +from .base import Connection # sentinel value for `verify_certs` and `ssl_show_warn`. # This is used to detect if a user is passing in a value diff --git a/elasticsearch/connection/http_urllib3.pyi b/elasticsearch/connection/http_urllib3.pyi index 26b4fc6b..2e1094cc 100644 --- a/elasticsearch/connection/http_urllib3.pyi +++ b/elasticsearch/connection/http_urllib3.pyi @@ -16,8 +16,10 @@ # under the License. import ssl -from typing import Optional, Mapping, Any, Union +from typing import Any, Mapping, Optional, Union + import urllib3 # type: ignore + from .base import Connection def create_ssl_context( diff --git a/elasticsearch/connection_pool.py b/elasticsearch/connection_pool.py index 857e4ab3..9b7a0429 100644 --- a/elasticsearch/connection_pool.py +++ b/elasticsearch/connection_pool.py @@ -15,13 +15,13 @@ # specific language governing permissions and limitations # under the License. -import time -import random import logging +import random import threading +import time try: - from Queue import PriorityQueue, Empty + from Queue import Empty, PriorityQueue except ImportError: from queue import PriorityQueue, Empty diff --git a/elasticsearch/connection_pool.pyi b/elasticsearch/connection_pool.pyi index b35b3e0b..a05810f8 100644 --- a/elasticsearch/connection_pool.pyi +++ b/elasticsearch/connection_pool.pyi @@ -16,7 +16,8 @@ # under the License. import logging -from typing import Sequence, Optional, Type, Any, Union, List, Tuple, Dict +from typing import Any, Dict, List, Optional, Sequence, Tuple, Type, Union + from .connection import Connection try: diff --git a/elasticsearch/exceptions.pyi b/elasticsearch/exceptions.pyi index 27ea277d..fd28fd80 100644 --- a/elasticsearch/exceptions.pyi +++ b/elasticsearch/exceptions.pyi @@ -15,7 +15,7 @@ # specific language governing permissions and limitations # under the License. -from typing import Dict, Union, Any +from typing import Any, Dict, Union class ImproperlyConfigured(Exception): ... class ElasticsearchException(Exception): ... diff --git a/elasticsearch/helpers/__init__.py b/elasticsearch/helpers/__init__.py index 08871a96..a8478be7 100644 --- a/elasticsearch/helpers/__init__.py +++ b/elasticsearch/helpers/__init__.py @@ -16,10 +16,18 @@ # under the License. import sys + +from .actions import ( + _chunk_actions, + _process_bulk_chunk, + bulk, + expand_action, + parallel_bulk, + reindex, + scan, + streaming_bulk, +) from .errors import BulkIndexError, ScanError -from .actions import expand_action, streaming_bulk, bulk, parallel_bulk -from .actions import scan, reindex -from .actions import _chunk_actions, _process_bulk_chunk __all__ = [ "BulkIndexError", @@ -41,9 +49,9 @@ try: raise ImportError from .._async.helpers import ( - async_scan, async_bulk, async_reindex, + async_scan, async_streaming_bulk, ) diff --git a/elasticsearch/helpers/__init__.pyi b/elasticsearch/helpers/__init__.pyi index 7a01f782..648056ab 100644 --- a/elasticsearch/helpers/__init__.pyi +++ b/elasticsearch/helpers/__init__.pyi @@ -16,28 +16,26 @@ # under the License. import sys -from .errors import BulkIndexError as BulkIndexError, ScanError as ScanError -from .actions import ( - expand_action as expand_action, - streaming_bulk as streaming_bulk, - bulk as bulk, - parallel_bulk as parallel_bulk, - scan as scan, - reindex as reindex, - _chunk_actions as _chunk_actions, - _process_bulk_chunk as _process_bulk_chunk, -) + +from .actions import _chunk_actions as _chunk_actions +from .actions import _process_bulk_chunk as _process_bulk_chunk +from .actions import bulk as bulk +from .actions import expand_action as expand_action +from .actions import parallel_bulk as parallel_bulk +from .actions import reindex as reindex +from .actions import scan as scan +from .actions import streaming_bulk as streaming_bulk +from .errors import BulkIndexError as BulkIndexError +from .errors import ScanError as ScanError try: # Asyncio only supported on Python 3.6+ if sys.version_info < (3, 6): raise ImportError - from .._async.helpers import ( - async_scan as async_scan, - async_bulk as async_bulk, - async_reindex as async_reindex, - async_streaming_bulk as async_streaming_bulk, - ) + from .._async.helpers import async_bulk as async_bulk + from .._async.helpers import async_reindex as async_reindex + from .._async.helpers import async_scan as async_scan + from .._async.helpers import async_streaming_bulk as async_streaming_bulk except (ImportError, SyntaxError): pass diff --git a/elasticsearch/helpers/actions.py b/elasticsearch/helpers/actions.py index 33a7608f..228b339d 100644 --- a/elasticsearch/helpers/actions.py +++ b/elasticsearch/helpers/actions.py @@ -15,16 +15,13 @@ # specific language governing permissions and limitations # under the License. -from operator import methodcaller -import time - -from ..exceptions import TransportError -from ..compat import map, string_types, Queue, Mapping - -from .errors import ScanError, BulkIndexError - import logging +import time +from operator import methodcaller +from ..compat import Mapping, Queue, map, string_types +from ..exceptions import TransportError +from .errors import BulkIndexError, ScanError logger = logging.getLogger("elasticsearch.helpers") diff --git a/elasticsearch/helpers/actions.pyi b/elasticsearch/helpers/actions.pyi index e3b7a929..90060c1f 100644 --- a/elasticsearch/helpers/actions.pyi +++ b/elasticsearch/helpers/actions.pyi @@ -15,21 +15,22 @@ # specific language governing permissions and limitations # under the License. -from typing import ( - Generator, - Optional, - Union, - Any, - Mapping, - Tuple, - Iterable, - AsyncIterable, - List, - Collection, - Callable, - Dict, -) import logging +from typing import ( + Any, + AsyncIterable, + Callable, + Collection, + Dict, + Generator, + Iterable, + List, + Mapping, + Optional, + Tuple, + Union, +) + from ..client import Elasticsearch from ..serializer import Serializer diff --git a/elasticsearch/helpers/errors.pyi b/elasticsearch/helpers/errors.pyi index 8dd96fc4..b4af6b78 100644 --- a/elasticsearch/helpers/errors.pyi +++ b/elasticsearch/helpers/errors.pyi @@ -15,7 +15,8 @@ # specific language governing permissions and limitations # under the License. -from typing import List, Any +from typing import Any, List + from ..exceptions import ElasticsearchException class BulkIndexError(ElasticsearchException): diff --git a/elasticsearch/helpers/test.py b/elasticsearch/helpers/test.py index 662a38fc..c201f5b5 100644 --- a/elasticsearch/helpers/test.py +++ b/elasticsearch/helpers/test.py @@ -17,9 +17,9 @@ # type: ignore -import time import os -from unittest import TestCase, SkipTest +import time +from unittest import SkipTest, TestCase from elasticsearch import Elasticsearch from elasticsearch.exceptions import ConnectionError diff --git a/elasticsearch/helpers/test.pyi b/elasticsearch/helpers/test.pyi index 06ff323b..f301b6dd 100644 --- a/elasticsearch/helpers/test.pyi +++ b/elasticsearch/helpers/test.pyi @@ -17,6 +17,7 @@ from typing import Any, Tuple from unittest import TestCase + from ..client import Elasticsearch def get_test_client(nowait: bool = ..., **kwargs: Any) -> Elasticsearch: ... diff --git a/elasticsearch/serializer.py b/elasticsearch/serializer.py index 8d35aba4..1714c600 100644 --- a/elasticsearch/serializer.py +++ b/elasticsearch/serializer.py @@ -24,8 +24,8 @@ import uuid from datetime import date, datetime from decimal import Decimal -from .exceptions import SerializationError, ImproperlyConfigured from .compat import string_types +from .exceptions import ImproperlyConfigured, SerializationError INTEGER_TYPES = () FLOAT_TYPES = (Decimal,) diff --git a/elasticsearch/serializer.pyi b/elasticsearch/serializer.pyi index 441ba1e8..d6a7157c 100644 --- a/elasticsearch/serializer.pyi +++ b/elasticsearch/serializer.pyi @@ -15,7 +15,7 @@ # specific language governing permissions and limitations # under the License. -from typing import Optional, Any, Dict +from typing import Any, Dict, Optional class Serializer(object): mimetype: str diff --git a/elasticsearch/transport.py b/elasticsearch/transport.py index 71ce4424..b9e07a99 100644 --- a/elasticsearch/transport.py +++ b/elasticsearch/transport.py @@ -16,19 +16,19 @@ # under the License. import time -from platform import python_version from itertools import chain +from platform import python_version from ._version import __versionstr__ from .connection import Urllib3HttpConnection from .connection_pool import ConnectionPool, DummyConnectionPool, EmptyConnectionPool -from .serializer import JSONSerializer, Deserializer, DEFAULT_SERIALIZERS from .exceptions import ( ConnectionError, - TransportError, - SerializationError, ConnectionTimeout, + SerializationError, + TransportError, ) +from .serializer import DEFAULT_SERIALIZERS, Deserializer, JSONSerializer from .utils import _client_meta_version diff --git a/elasticsearch/transport.pyi b/elasticsearch/transport.pyi index 07fa6286..5265b51e 100644 --- a/elasticsearch/transport.pyi +++ b/elasticsearch/transport.pyi @@ -15,21 +15,11 @@ # specific language governing permissions and limitations # under the License. -from typing import ( - Callable, - Optional, - Union, - Collection, - Type, - Mapping, - Any, - Dict, - List, -) +from typing import Any, Callable, Collection, Dict, List, Mapping, Optional, Type, Union from .connection import Connection from .connection_pool import ConnectionPool -from .serializer import Serializer, Deserializer +from .serializer import Deserializer, Serializer def get_host_info( node_info: Dict[str, Any], host: Optional[Dict[str, Any]] diff --git a/noxfile.py b/noxfile.py index 4ff8f18c..4f8d5cc7 100644 --- a/noxfile.py +++ b/noxfile.py @@ -17,7 +17,6 @@ import nox - SOURCE_FILES = ( "setup.py", "noxfile.py", @@ -36,9 +35,10 @@ def test(session): @nox.session() -def blacken(session): - session.install("black") +def format(session): + session.install("black", "isort") + session.run("isort", "--profile=black", *SOURCE_FILES) session.run("black", "--target-version=py27", *SOURCE_FILES) session.run("python", "utils/license-headers.py", "fix", *SOURCE_FILES) @@ -47,8 +47,9 @@ def blacken(session): @nox.session() def lint(session): - session.install("flake8", "black", "mypy") + session.install("flake8", "black", "mypy", "isort") + session.run("isort", "--check", "--profile=black", *SOURCE_FILES) session.run("black", "--target-version=py27", "--check", *SOURCE_FILES) session.run("flake8", *SOURCE_FILES) session.run("python", "utils/license-headers.py", "check", *SOURCE_FILES) diff --git a/setup.cfg b/setup.cfg index 470bfade..59d36e29 100644 --- a/setup.cfg +++ b/setup.cfg @@ -14,3 +14,6 @@ ignore = E203, E266, E501, W503 [tool:pytest] junit_family=legacy + +[tool:isort] +profile=black diff --git a/setup.py b/setup.py index 677c3a36..8e68b945 100644 --- a/setup.py +++ b/setup.py @@ -17,8 +17,9 @@ # under the License. import re -from os.path import abspath, join, dirname -from setuptools import setup, find_packages +from os.path import abspath, dirname, join + +from setuptools import find_packages, setup package_name = "elasticsearch" base_dir = abspath(dirname(__file__)) diff --git a/test_elasticsearch/run_tests.py b/test_elasticsearch/run_tests.py index cb556216..3936c437 100755 --- a/test_elasticsearch/run_tests.py +++ b/test_elasticsearch/run_tests.py @@ -18,10 +18,10 @@ from __future__ import print_function +import subprocess import sys from os import environ -from os.path import dirname, join, pardir, abspath, exists -import subprocess +from os.path import abspath, dirname, exists, join, pardir def fetch_es_repo(): @@ -50,8 +50,8 @@ def fetch_es_repo(): if environ.get("TEST_ES_NOFETCH", False): return - from test_elasticsearch.test_server import get_client from test_elasticsearch.test_cases import SkipTest + from test_elasticsearch.test_server import get_client # find out the sha of the running es try: diff --git a/test_elasticsearch/test_async/test_connection.py b/test_elasticsearch/test_async/test_connection.py index 77e4c6d7..1dd31db9 100644 --- a/test_elasticsearch/test_async/test_connection.py +++ b/test_elasticsearch/test_async/test_connection.py @@ -16,18 +16,18 @@ # specific language governing permissions and limitations # under the License. -import ssl import gzip import io -from mock import patch +import ssl import warnings from platform import python_version -import aiohttp -from multidict import CIMultiDict -import pytest -from elasticsearch import AIOHttpConnection -from elasticsearch import __versionstr__ +import aiohttp +import pytest +from mock import patch +from multidict import CIMultiDict + +from elasticsearch import AIOHttpConnection, __versionstr__ pytestmark = pytest.mark.asyncio diff --git a/test_elasticsearch/test_async/test_server/conftest.py b/test_elasticsearch/test_async/test_server/conftest.py index 5d229a1b..cdd414a1 100644 --- a/test_elasticsearch/test_async/test_server/conftest.py +++ b/test_elasticsearch/test_async/test_server/conftest.py @@ -15,10 +15,13 @@ # specific language governing permissions and limitations # under the License. -import os -import pytest import asyncio +import os + +import pytest + import elasticsearch + from ...utils import wipe_cluster pytestmark = pytest.mark.asyncio diff --git a/test_elasticsearch/test_async/test_server/test_clients.py b/test_elasticsearch/test_async/test_server/test_clients.py index f32ba7ee..ba322c79 100644 --- a/test_elasticsearch/test_async/test_server/test_clients.py +++ b/test_elasticsearch/test_async/test_server/test_clients.py @@ -17,6 +17,7 @@ # under the License. from __future__ import unicode_literals + import pytest pytestmark = pytest.mark.asyncio diff --git a/test_elasticsearch/test_async/test_server/test_helpers.py b/test_elasticsearch/test_async/test_server/test_helpers.py index c82a9aab..ef98728b 100644 --- a/test_elasticsearch/test_async/test_server/test_helpers.py +++ b/test_elasticsearch/test_async/test_server/test_helpers.py @@ -19,14 +19,14 @@ # Elasticsearch B.V licenses this file to you under the Apache 2.0 License. # See the LICENSE file in the project root for more information -import pytest import asyncio -from mock import patch, MagicMock -from elasticsearch import helpers, TransportError +import pytest +from mock import MagicMock, patch + +from elasticsearch import TransportError, helpers from elasticsearch.helpers import ScanError - pytestmark = pytest.mark.asyncio diff --git a/test_elasticsearch/test_async/test_server/test_rest_api_spec.py b/test_elasticsearch/test_async/test_server/test_rest_api_spec.py index ffddd454..dad817d6 100644 --- a/test_elasticsearch/test_async/test_server/test_rest_api_spec.py +++ b/test_elasticsearch/test_async/test_server/test_rest_api_spec.py @@ -20,19 +20,21 @@ Dynamically generated set of TestCases based on set of yaml files decribing some integration tests. These files are shared among all official Elasticsearch clients. """ -import pytest -import warnings import inspect +import warnings -from elasticsearch import RequestError, ElasticsearchWarning +import pytest + +from elasticsearch import ElasticsearchWarning, RequestError from elasticsearch.helpers.test import _get_version + from ...test_server.test_rest_api_spec import ( - YamlRunner, + IMPLEMENTED_FEATURES, + PARAMS_RENAMES, + RUN_ASYNC_REST_API_TESTS, YAML_TEST_SPECS, InvalidActionType, - RUN_ASYNC_REST_API_TESTS, - PARAMS_RENAMES, - IMPLEMENTED_FEATURES, + YamlRunner, ) pytestmark = pytest.mark.asyncio diff --git a/test_elasticsearch/test_async/test_transport.py b/test_elasticsearch/test_async/test_transport.py index 2dde5e9e..c7ea0c34 100644 --- a/test_elasticsearch/test_async/test_transport.py +++ b/test_elasticsearch/test_async/test_transport.py @@ -17,18 +17,19 @@ # under the License. from __future__ import unicode_literals -import re + import asyncio import json -from mock import patch +import re + import pytest +from mock import patch from elasticsearch import AsyncTransport from elasticsearch.connection import Connection from elasticsearch.connection_pool import DummyConnectionPool from elasticsearch.exceptions import ConnectionError, TransportError - pytestmark = pytest.mark.asyncio diff --git a/test_elasticsearch/test_cases.py b/test_elasticsearch/test_cases.py index 7dcc32e6..f3fcc025 100644 --- a/test_elasticsearch/test_cases.py +++ b/test_elasticsearch/test_cases.py @@ -16,8 +16,9 @@ # under the License. from collections import defaultdict -from unittest import TestCase from unittest import SkipTest # noqa: F401 +from unittest import TestCase + from elasticsearch import Elasticsearch diff --git a/test_elasticsearch/test_client/__init__.py b/test_elasticsearch/test_client/__init__.py index a77f1dfa..722e245e 100644 --- a/test_elasticsearch/test_client/__init__.py +++ b/test_elasticsearch/test_client/__init__.py @@ -16,11 +16,12 @@ # under the License. from __future__ import unicode_literals + import warnings -from elasticsearch.client import _normalize_hosts, Elasticsearch +from elasticsearch.client import Elasticsearch, _normalize_hosts -from ..test_cases import TestCase, ElasticsearchTestCase +from ..test_cases import ElasticsearchTestCase, TestCase class TestNormalizeHosts(TestCase): diff --git a/test_elasticsearch/test_client/test_overrides.py b/test_elasticsearch/test_client/test_overrides.py index 320fade5..689a3b4c 100644 --- a/test_elasticsearch/test_client/test_overrides.py +++ b/test_elasticsearch/test_client/test_overrides.py @@ -17,6 +17,7 @@ # under the License. import pytest + from test_elasticsearch.test_cases import ElasticsearchTestCase diff --git a/test_elasticsearch/test_client/test_utils.py b/test_elasticsearch/test_client/test_utils.py index 96990e9a..7a737863 100644 --- a/test_elasticsearch/test_client/test_utils.py +++ b/test_elasticsearch/test_client/test_utils.py @@ -18,10 +18,10 @@ from __future__ import unicode_literals -from elasticsearch.client.utils import _bulk_body, _make_path, _escape, query_params +from elasticsearch.client.utils import _bulk_body, _escape, _make_path, query_params from elasticsearch.compat import PY2 -from ..test_cases import TestCase, SkipTest +from ..test_cases import SkipTest, TestCase class TestQueryParams(TestCase): diff --git a/test_elasticsearch/test_connection.py b/test_elasticsearch/test_connection.py index 84b58bb0..eb676f6a 100644 --- a/test_elasticsearch/test_connection.py +++ b/test_elasticsearch/test_connection.py @@ -16,34 +16,33 @@ # specific language governing permissions and limitations # under the License. -import re -import ssl import gzip import io -from mock import Mock, patch -import urllib3 -from urllib3._collections import HTTPHeaderDict +import re +import ssl import warnings -from requests.auth import AuthBase from platform import python_version import pytest +import urllib3 +from mock import Mock, patch +from requests.auth import AuthBase +from urllib3._collections import HTTPHeaderDict -from elasticsearch.exceptions import ( - TransportError, - ConflictError, - RequestError, - NotFoundError, -) +from elasticsearch import __versionstr__ from elasticsearch.connection import ( Connection, RequestsHttpConnection, Urllib3HttpConnection, ) +from elasticsearch.exceptions import ( + ConflictError, + NotFoundError, + RequestError, + TransportError, +) -from elasticsearch import __versionstr__ -from .test_cases import TestCase, SkipTest - +from .test_cases import SkipTest, TestCase CLOUD_ID_PORT_443 = "cluster:d2VzdGV1cm9wZS5henVyZS5lbGFzdGljLWNsb3VkLmNvbTo0NDMkZTdkZTlmMTM0NWU0NDkwMjgzZDkwM2JlNWI2ZjkxOWUk" CLOUD_ID_KIBANA = "cluster:d2VzdGV1cm9wZS5henVyZS5lbGFzdGljLWNsb3VkLmNvbSQ4YWY3ZWUzNTQyMGY0NThlOTAzMDI2YjQwNjQwODFmMiQyMDA2MTU1NmM1NDA0OTg2YmZmOTU3ZDg0YTZlYjUxZg==" diff --git a/test_elasticsearch/test_connection_pool.py b/test_elasticsearch/test_connection_pool.py index 8231a215..adb11bea 100644 --- a/test_elasticsearch/test_connection_pool.py +++ b/test_elasticsearch/test_connection_pool.py @@ -17,12 +17,12 @@ import time +from elasticsearch.connection import Connection from elasticsearch.connection_pool import ( ConnectionPool, - RoundRobinSelector, DummyConnectionPool, + RoundRobinSelector, ) -from elasticsearch.connection import Connection from elasticsearch.exceptions import ImproperlyConfigured from .test_cases import TestCase diff --git a/test_elasticsearch/test_helpers.py b/test_elasticsearch/test_helpers.py index 4eb2017b..e6aee4fe 100644 --- a/test_elasticsearch/test_helpers.py +++ b/test_elasticsearch/test_helpers.py @@ -16,11 +16,13 @@ # specific language governing permissions and limitations # under the License. -import mock -import time import threading +import time + +import mock import pytest -from elasticsearch import helpers, Elasticsearch + +from elasticsearch import Elasticsearch, helpers from elasticsearch.helpers import actions from elasticsearch.serializer import JSONSerializer diff --git a/test_elasticsearch/test_serializer.py b/test_elasticsearch/test_serializer.py index a22c3784..473b8c9d 100644 --- a/test_elasticsearch/test_serializer.py +++ b/test_elasticsearch/test_serializer.py @@ -18,22 +18,21 @@ import sys import uuid - from datetime import datetime from decimal import Decimal import numpy as np import pandas as pd +from elasticsearch.exceptions import ImproperlyConfigured, SerializationError from elasticsearch.serializer import ( - JSONSerializer, - Deserializer, DEFAULT_SERIALIZERS, + Deserializer, + JSONSerializer, TextSerializer, ) -from elasticsearch.exceptions import SerializationError, ImproperlyConfigured -from .test_cases import TestCase, SkipTest +from .test_cases import SkipTest, TestCase class TestJSONSerializer(TestCase): diff --git a/test_elasticsearch/test_server/__init__.py b/test_elasticsearch/test_server/__init__.py index 68b1b307..c9ac5ad5 100644 --- a/test_elasticsearch/test_server/__init__.py +++ b/test_elasticsearch/test_server/__init__.py @@ -16,6 +16,7 @@ # under the License. from unittest import SkipTest + from elasticsearch.helpers import test from elasticsearch.helpers.test import ElasticsearchTestCase as BaseTestCase diff --git a/test_elasticsearch/test_server/conftest.py b/test_elasticsearch/test_server/conftest.py index 55a9379a..4b39ab47 100644 --- a/test_elasticsearch/test_server/conftest.py +++ b/test_elasticsearch/test_server/conftest.py @@ -17,8 +17,11 @@ import os import time + import pytest + import elasticsearch + from ..utils import wipe_cluster diff --git a/test_elasticsearch/test_server/test_helpers.py b/test_elasticsearch/test_server/test_helpers.py index ee642312..43b0efe2 100644 --- a/test_elasticsearch/test_server/test_helpers.py +++ b/test_elasticsearch/test_server/test_helpers.py @@ -17,11 +17,11 @@ from mock import patch -from elasticsearch import helpers, TransportError +from elasticsearch import TransportError, helpers from elasticsearch.helpers import ScanError -from . import ElasticsearchTestCase from ..test_cases import SkipTest +from . import ElasticsearchTestCase class FailingBulkClient(object): diff --git a/test_elasticsearch/test_server/test_rest_api_spec.py b/test_elasticsearch/test_server/test_rest_api_spec.py index dd82e9d8..8ab65b65 100644 --- a/test_elasticsearch/test_server/test_rest_api_spec.py +++ b/test_elasticsearch/test_server/test_rest_api_spec.py @@ -20,16 +20,17 @@ Dynamically generated set of TestCases based on set of yaml files describing some integration tests. These files are shared among all official Elasticsearch clients. """ -import sys -import re import os -from os import walk, environ -from os.path import exists, join, dirname, pardir, relpath -import yaml +import re +import sys import warnings -import pytest +from os import environ, walk +from os.path import dirname, exists, join, pardir, relpath -from elasticsearch import TransportError, RequestError, ElasticsearchWarning +import pytest +import yaml + +from elasticsearch import ElasticsearchWarning, RequestError, TransportError from elasticsearch.compat import string_types from elasticsearch.helpers.test import _get_version diff --git a/test_elasticsearch/test_transport.py b/test_elasticsearch/test_transport.py index 90ca1227..c5cd3f0c 100644 --- a/test_elasticsearch/test_transport.py +++ b/test_elasticsearch/test_transport.py @@ -17,15 +17,17 @@ # under the License. from __future__ import unicode_literals + import json import time + import pytest from mock import patch -from elasticsearch.transport import Transport, get_host_info from elasticsearch.connection import Connection from elasticsearch.connection_pool import DummyConnectionPool from elasticsearch.exceptions import ConnectionError, TransportError +from elasticsearch.transport import Transport, get_host_info from .test_cases import TestCase diff --git a/test_elasticsearch/test_types/aliased_types.py b/test_elasticsearch/test_types/aliased_types.py index 45e28306..f481a0bc 100644 --- a/test_elasticsearch/test_types/aliased_types.py +++ b/test_elasticsearch/test_types/aliased_types.py @@ -15,28 +15,28 @@ # specific language governing permissions and limitations # under the License. -from typing import Generator, Dict, Any, AsyncGenerator +from typing import Any, AsyncGenerator, Dict, Generator + from elasticsearch7 import ( - Elasticsearch, - Transport, - RequestsHttpConnection, - ConnectionPool, + AIOHttpConnection, AsyncElasticsearch, AsyncTransport, - AIOHttpConnection, + ConnectionPool, + Elasticsearch, + RequestsHttpConnection, + Transport, ) from elasticsearch7.helpers import ( - scan, - streaming_bulk, - reindex, - bulk, + async_bulk, + async_reindex, async_scan, async_streaming_bulk, - async_reindex, - async_bulk, + bulk, + reindex, + scan, + streaming_bulk, ) - es = Elasticsearch( [{"host": "localhost", "port": 9443}], transport_class=Transport, diff --git a/test_elasticsearch/test_types/async_types.py b/test_elasticsearch/test_types/async_types.py index f073d8e9..490c8507 100644 --- a/test_elasticsearch/test_types/async_types.py +++ b/test_elasticsearch/test_types/async_types.py @@ -15,21 +15,21 @@ # specific language governing permissions and limitations # under the License. -from typing import AsyncGenerator, Dict, Any +from typing import Any, AsyncGenerator, Dict + from elasticsearch import ( + AIOHttpConnection, AsyncElasticsearch, AsyncTransport, - AIOHttpConnection, ConnectionPool, ) from elasticsearch.helpers import ( + async_bulk, + async_reindex, async_scan, async_streaming_bulk, - async_reindex, - async_bulk, ) - es = AsyncElasticsearch( [{"host": "localhost", "port": 9443}], transport_class=AsyncTransport, diff --git a/test_elasticsearch/test_types/sync_types.py b/test_elasticsearch/test_types/sync_types.py index 9767aa00..d8548d6f 100644 --- a/test_elasticsearch/test_types/sync_types.py +++ b/test_elasticsearch/test_types/sync_types.py @@ -15,15 +15,15 @@ # specific language governing permissions and limitations # under the License. -from typing import Generator, Dict, Any -from elasticsearch import ( - Elasticsearch, - Transport, - RequestsHttpConnection, - ConnectionPool, -) -from elasticsearch.helpers import scan, streaming_bulk, reindex, bulk +from typing import Any, Dict, Generator +from elasticsearch import ( + ConnectionPool, + Elasticsearch, + RequestsHttpConnection, + Transport, +) +from elasticsearch.helpers import bulk, reindex, scan, streaming_bulk es = Elasticsearch( [{"host": "localhost", "port": 9443}], diff --git a/test_elasticsearch/test_utils.py b/test_elasticsearch/test_utils.py index fa9fbf1f..385e97ed 100644 --- a/test_elasticsearch/test_utils.py +++ b/test_elasticsearch/test_utils.py @@ -16,6 +16,7 @@ # under the License. import pytest + from elasticsearch.utils import _client_meta_version diff --git a/test_elasticsearch/utils.py b/test_elasticsearch/utils.py index 6b02be96..02ecea06 100644 --- a/test_elasticsearch/utils.py +++ b/test_elasticsearch/utils.py @@ -17,6 +17,7 @@ import os import time + from elasticsearch import Elasticsearch, NotFoundError, RequestError diff --git a/utils/build-dists.py b/utils/build-dists.py index ecd559db..854add1d 100644 --- a/utils/build-dists.py +++ b/utils/build-dists.py @@ -20,14 +20,13 @@ Can be used for building both 'elasticsearch' and 'elasticsearchX' dists. Only requires 'name' in 'setup.py' and the directory to be changed. """ -import tempfile -import os -import shlex -import sys -import re import contextlib +import os +import re +import shlex import shutil - +import sys +import tempfile base_dir = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) tmp_dir = None diff --git a/utils/generate-api.py b/utils/generate-api.py index dd6503a9..e35010e2 100644 --- a/utils/generate-api.py +++ b/utils/generate-api.py @@ -16,20 +16,18 @@ # specific language governing permissions and limitations # under the License. -import os import json +import os import re -import urllib3 -from itertools import chain from functools import lru_cache - -import black -from click.testing import CliRunner +from itertools import chain from pathlib import Path -from jinja2 import Environment, FileSystemLoader, TemplateNotFound +import black import unasync - +import urllib3 +from click.testing import CliRunner +from jinja2 import Environment, FileSystemLoader, TemplateNotFound http = urllib3.PoolManager() diff --git a/utils/license-headers.py b/utils/license-headers.py index cf587eba..b4fc7432 100644 --- a/utils/license-headers.py +++ b/utils/license-headers.py @@ -23,9 +23,8 @@ error out if 'fix' would have changed the file. import os import re import sys -from typing import List, Iterator from itertools import chain - +from typing import Iterator, List lines_to_keep = ["# -*- coding: utf-8 -*-\n", "#!/usr/bin/env python\n"] license_header_lines = [