Skip to content

Commit 21fa13b

Browse files
authored
Use '_sync/_async' to have constant module depth for generated APIs
1 parent db5a77a commit 21fa13b

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

102 files changed

+535
-268
lines changed

elasticsearch/__init__.py

Lines changed: 10 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,15 @@
3232
logger = logging.getLogger("elasticsearch")
3333
logger.addHandler(logging.NullHandler())
3434

35-
from .client import Elasticsearch
36-
from .connection import Connection, RequestsHttpConnection, Urllib3HttpConnection
35+
from ._async.client import AsyncElasticsearch
36+
from ._sync.client import Elasticsearch
37+
from .connection import (
38+
AIOHttpConnection,
39+
AsyncConnection,
40+
Connection,
41+
RequestsHttpConnection,
42+
Urllib3HttpConnection,
43+
)
3744
from .connection_pool import ConnectionPool, ConnectionSelector, RoundRobinSelector
3845
from .exceptions import (
3946
AuthenticationException,
@@ -53,7 +60,7 @@
5360
UnsupportedProductError,
5461
)
5562
from .serializer import JSONSerializer
56-
from .transport import Transport
63+
from .transport import AsyncTransport, Transport
5764

5865
# Only raise one warning per deprecation message so as not
5966
# to spam up the user if the same action is done multiple times.
@@ -85,17 +92,3 @@
8592
"ElasticsearchWarning",
8693
"ElasticsearchDeprecationWarning",
8794
]
88-
89-
try:
90-
from ._async.client import AsyncElasticsearch
91-
from ._async.http_aiohttp import AIOHttpConnection, AsyncConnection
92-
from ._async.transport import AsyncTransport
93-
94-
__all__ += [
95-
"AIOHttpConnection",
96-
"AsyncConnection",
97-
"AsyncTransport",
98-
"AsyncElasticsearch",
99-
]
100-
except ImportError: # pragma: nocover
101-
pass

elasticsearch/__init__.pyi

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,11 @@
1818
import sys
1919
from typing import Tuple
2020

21-
from .client import Elasticsearch as Elasticsearch
21+
from ._async.client import AsyncElasticsearch as AsyncElasticsearch
22+
from ._async.transport import AsyncTransport as AsyncTransport
23+
from ._sync.client import Elasticsearch as Elasticsearch
24+
from .connection import AIOHttpConnection as AIOHttpConnection
25+
from .connection import AsyncConnection as AsyncConnection
2226
from .connection import Connection as Connection
2327
from .connection import RequestsHttpConnection as RequestsHttpConnection
2428
from .connection import Urllib3HttpConnection as Urllib3HttpConnection
@@ -44,13 +48,6 @@ from .exceptions import UnsupportedProductError as UnsupportedProductError
4448
from .serializer import JSONSerializer as JSONSerializer
4549
from .transport import Transport as Transport
4650

47-
try:
48-
from ._async.client import AsyncElasticsearch as AsyncElasticsearch
49-
from ._async.http_aiohttp import AIOHttpConnection as AIOHttpConnection
50-
from ._async.transport import AsyncTransport as AsyncTransport
51-
except ImportError:
52-
pass
53-
5451
VERSION: Tuple[int, int, int]
5552
__version__: Tuple[int, int, int]
5653
__versionstr__: str

elasticsearch/_async/client/__init__.py

Lines changed: 17 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818

1919
import logging
2020

21-
from ..transport import AsyncTransport, TransportError
21+
from ...transport import AsyncTransport, TransportError
2222
from .async_search import AsyncSearchClient
2323
from .autoscaling import AutoscalingClient
2424
from .cat import CatClient
@@ -1193,11 +1193,6 @@ async def rank_eval(self, body, index=None, params=None, headers=None):
11931193
11941194
`<https://www.elastic.co/guide/en/elasticsearch/reference/master/search-rank-eval.html>`_
11951195
1196-
.. warning::
1197-
1198-
This API is **experimental** so may include breaking changes
1199-
or be removed in a future version
1200-
12011196
:arg body: The ranking evaluation search definition, including
12021197
search requests, document ratings and ranking metric definition.
12031198
:arg index: A comma-separated list of index names to search; use
@@ -1651,11 +1646,6 @@ async def get_script_context(self, params=None, headers=None):
16511646
Returns all script contexts.
16521647
16531648
`<https://www.elastic.co/guide/en/elasticsearch/painless/master/painless-contexts.html>`_
1654-
1655-
.. warning::
1656-
1657-
This API is **experimental** so may include breaking changes
1658-
or be removed in a future version
16591649
"""
16601650
return await self.transport.perform_request(
16611651
"GET", "/_script_context", params=params, headers=headers
@@ -1667,11 +1657,6 @@ async def get_script_languages(self, params=None, headers=None):
16671657
Returns available script types, languages and contexts
16681658
16691659
`<https://www.elastic.co/guide/en/elasticsearch/reference/master/modules-scripting.html>`_
1670-
1671-
.. warning::
1672-
1673-
This API is **experimental** so may include breaking changes
1674-
or be removed in a future version
16751660
"""
16761661
return await self.transport.perform_request(
16771662
"GET", "/_script_language", params=params, headers=headers
@@ -2050,7 +2035,7 @@ async def close_point_in_time(self, body=None, params=None, headers=None):
20502035
@query_params(
20512036
"expand_wildcards", "ignore_unavailable", "keep_alive", "preference", "routing"
20522037
)
2053-
async def open_point_in_time(self, index=None, params=None, headers=None):
2038+
async def open_point_in_time(self, index, params=None, headers=None):
20542039
"""
20552040
Open a point in time that can be used in subsequent searches
20562041
@@ -2069,6 +2054,9 @@ async def open_point_in_time(self, index=None, params=None, headers=None):
20692054
be performed on (default: random)
20702055
:arg routing: Specific routing value
20712056
"""
2057+
if index in SKIP_IN_PATH:
2058+
raise ValueError("Empty value passed for a required argument 'index'.")
2059+
20722060
return await self.transport.perform_request(
20732061
"POST", _make_path(index, "_pit"), params=params, headers=headers
20742062
)
@@ -2082,11 +2070,6 @@ async def terms_enum(self, index, body=None, params=None, headers=None):
20822070
20832071
`<https://www.elastic.co/guide/en/elasticsearch/reference/master/search-terms-enum.html>`_
20842072
2085-
.. warning::
2086-
2087-
This API is **beta** so may include breaking changes
2088-
or be removed in a future version
2089-
20902073
:arg index: A comma-separated list of index names to search; use
20912074
`_all` or empty string to perform the operation on all indices
20922075
:arg body: field name, string which is the prefix expected in
@@ -2103,7 +2086,14 @@ async def terms_enum(self, index, body=None, params=None, headers=None):
21032086
body=body,
21042087
)
21052088

2106-
@query_params("exact_bounds", "extent", "grid_precision", "grid_type", "size")
2089+
@query_params(
2090+
"exact_bounds",
2091+
"extent",
2092+
"grid_precision",
2093+
"grid_type",
2094+
"size",
2095+
"track_total_hits",
2096+
)
21072097
async def search_mvt(
21082098
self, index, field, zoom, x, y, body=None, params=None, headers=None
21092099
):
@@ -2133,9 +2123,12 @@ async def search_mvt(
21332123
:arg grid_precision: Additional zoom levels available through
21342124
the aggs layer. Accepts 0-8. Default: 8
21352125
:arg grid_type: Determines the geometry type for features in the
2136-
aggs layer. Valid choices: grid, point Default: grid
2126+
aggs layer. Valid choices: grid, point, centroid Default: grid
21372127
:arg size: Maximum number of features to return in the hits
21382128
layer. Accepts 0-10000. Default: 10000
2129+
:arg track_total_hits: Indicate if the number of documents that
2130+
match the query should be tracked. A number can also be specified, to
2131+
accurately track the total hit count up to the number.
21392132
"""
21402133
for param in (index, field, zoom, x, y):
21412134
if param in SKIP_IN_PATH:

elasticsearch/_async/client/__init__.pyi

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
import logging
1919
from typing import Any, Collection, MutableMapping, Optional, Tuple, Type, Union
2020

21-
from ..transport import AsyncTransport
21+
from ...transport import AsyncTransport
2222
from .async_search import AsyncSearchClient
2323
from .autoscaling import AutoscalingClient
2424
from .cat import CatClient
@@ -1110,8 +1110,8 @@ class AsyncElasticsearch:
11101110
) -> Any: ...
11111111
async def open_point_in_time(
11121112
self,
1113+
index: Any,
11131114
*,
1114-
index: Optional[Any] = ...,
11151115
expand_wildcards: Optional[Any] = ...,
11161116
ignore_unavailable: Optional[Any] = ...,
11171117
keep_alive: Optional[Any] = ...,
@@ -1162,6 +1162,7 @@ class AsyncElasticsearch:
11621162
grid_precision: Optional[Any] = ...,
11631163
grid_type: Optional[Any] = ...,
11641164
size: Optional[Any] = ...,
1165+
track_total_hits: Optional[Any] = ...,
11651166
pretty: Optional[bool] = ...,
11661167
human: Optional[bool] = ...,
11671168
error_trace: Optional[bool] = ...,

elasticsearch/_async/client/fleet.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,7 @@ async def global_checkpoints(self, index, params=None, headers=None):
2525
Returns the current global checkpoints for an index. This API is design for
2626
internal use by the fleet server project.
2727
28-
.. warning::
29-
30-
This API is **experimental** so may include breaking changes
31-
or be removed in a future version
28+
`<https://www.elastic.co/guide/en/elasticsearch/reference/master/get-global-checkpoints.html>`_
3229
3330
:arg index: The name of the index.
3431
:arg checkpoints: Comma separated list of checkpoints

elasticsearch/_async/client/indices.py

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -274,8 +274,8 @@ async def delete(self, index, params=None, headers=None):
274274
:arg allow_no_indices: Ignore if a wildcard expression resolves
275275
to no concrete indices (default: false)
276276
:arg expand_wildcards: Whether wildcard expressions should get
277-
expanded to open or closed indices (default: open) Valid choices: open,
278-
closed, hidden, none, all Default: open
277+
expanded to open, closed, or hidden indices Valid choices: open,
278+
closed, hidden, none, all Default: open,closed
279279
:arg ignore_unavailable: Ignore unavailable indexes (default:
280280
false)
281281
:arg master_timeout: Specify timeout for connection to master
@@ -1408,11 +1408,6 @@ async def resolve_index(self, name, params=None, headers=None):
14081408
14091409
`<https://www.elastic.co/guide/en/elasticsearch/reference/master/indices-resolve-index-api.html>`_
14101410
1411-
.. warning::
1412-
1413-
This API is **experimental** so may include breaking changes
1414-
or be removed in a future version
1415-
14161411
:arg name: A comma-separated list of names or wildcard
14171412
expressions
14181413
:arg expand_wildcards: Whether wildcard expressions should get

elasticsearch/_async/client/migration.py

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,3 +36,25 @@ async def deprecations(self, index=None, params=None, headers=None):
3636
params=params,
3737
headers=headers,
3838
)
39+
40+
@query_params()
41+
async def get_feature_upgrade_status(self, params=None, headers=None):
42+
"""
43+
Find out whether system features need to be upgraded or not
44+
45+
`<https://www.elastic.co/guide/en/elasticsearch/reference/master/migration-api-feature-upgrade.html>`_
46+
"""
47+
return await self.transport.perform_request(
48+
"GET", "/_migration/system_features", params=params, headers=headers
49+
)
50+
51+
@query_params()
52+
async def post_feature_upgrade(self, params=None, headers=None):
53+
"""
54+
Begin upgrades for system features
55+
56+
`<https://www.elastic.co/guide/en/elasticsearch/reference/master/migration-api-feature-upgrade.html>`_
57+
"""
58+
return await self.transport.perform_request(
59+
"POST", "/_migration/system_features", params=params, headers=headers
60+
)

elasticsearch/_async/client/migration.pyi

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,3 +37,35 @@ class MigrationClient(NamespacedClient):
3737
params: Optional[MutableMapping[str, Any]] = ...,
3838
headers: Optional[MutableMapping[str, str]] = ...,
3939
) -> Any: ...
40+
async def get_feature_upgrade_status(
41+
self,
42+
*,
43+
pretty: Optional[bool] = ...,
44+
human: Optional[bool] = ...,
45+
error_trace: Optional[bool] = ...,
46+
format: Optional[str] = ...,
47+
filter_path: Optional[Union[str, Collection[str]]] = ...,
48+
request_timeout: Optional[Union[int, float]] = ...,
49+
ignore: Optional[Union[int, Collection[int]]] = ...,
50+
opaque_id: Optional[str] = ...,
51+
http_auth: Optional[Union[str, Tuple[str, str]]] = ...,
52+
api_key: Optional[Union[str, Tuple[str, str]]] = ...,
53+
params: Optional[MutableMapping[str, Any]] = ...,
54+
headers: Optional[MutableMapping[str, str]] = ...,
55+
) -> Any: ...
56+
async def post_feature_upgrade(
57+
self,
58+
*,
59+
pretty: Optional[bool] = ...,
60+
human: Optional[bool] = ...,
61+
error_trace: Optional[bool] = ...,
62+
format: Optional[str] = ...,
63+
filter_path: Optional[Union[str, Collection[str]]] = ...,
64+
request_timeout: Optional[Union[int, float]] = ...,
65+
ignore: Optional[Union[int, Collection[int]]] = ...,
66+
opaque_id: Optional[str] = ...,
67+
http_auth: Optional[Union[str, Tuple[str, str]]] = ...,
68+
api_key: Optional[Union[str, Tuple[str, str]]] = ...,
69+
params: Optional[MutableMapping[str, Any]] = ...,
70+
headers: Optional[MutableMapping[str, str]] = ...,
71+
) -> Any: ...

0 commit comments

Comments
 (0)