Skip to content

Commit 4f2ccca

Browse files
saimedhigithub-actions[bot]
authored andcommitted
Updated opensearch-py to reflect the latest OpenSearch API spec (2024-12-22)
Signed-off-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
1 parent 4091816 commit 4f2ccca

19 files changed

+819
-108
lines changed

CHANGELOG.md

+1
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ Inspired from [Keep a Changelog](https://keepachangelog.com/en/1.0.0/)
66
- Added option to pass custom headers to 'AWSV4SignerAsyncAuth' ([863](https://github.com/opensearch-project/opensearch-py/pull/863))
77
- Added sync and async sample that uses `search_after` parameter ([859](https://github.com/opensearch-project/opensearch-py/pull/859))
88
### Updated APIs
9+
- Updated opensearch-py APIs to reflect [opensearch-api-specification@edf9d6f](https://github.com/opensearch-project/opensearch-api-specification/commit/edf9d6f0dbf1068345b58cb9e2c3464fa9839226)
910
### Changed
1011
- Small refactor of AWS Signer classes for both sync and async clients ([866](https://github.com/opensearch-project/opensearch-py/pull/866))
1112
- Small refactor to fix overwriting the module files when generating apis ([874](https://github.com/opensearch-project/opensearch-py/pull/874))

opensearchpy/_async/client/__init__.py

+15-9
Original file line numberDiff line numberDiff line change
@@ -667,7 +667,7 @@ async def count(
667667
specified.
668668
:arg default_operator: The default operator for query string
669669
query: `AND` or `OR`. This parameter can only be used when the `q` query
670-
string parameter is specified. Valid choices are and, or.
670+
string parameter is specified. Valid choices are and, AND, or, OR.
671671
:arg df: Field to use as default where no field prefix is given
672672
in the query string. This parameter can only be used when the `q` query
673673
string parameter is specified.
@@ -855,7 +855,7 @@ async def delete_by_query(
855855
:arg conflicts: What to do if delete by query hits version
856856
conflicts: `abort` or `proceed`. Valid choices are abort, proceed.
857857
:arg default_operator: The default operator for query string
858-
query: `AND` or `OR`. Valid choices are and, or.
858+
query: `AND` or `OR`. Valid choices are and, AND, or, OR.
859859
:arg df: Field to use as default where no field prefix is given
860860
in the query string.
861861
:arg error_trace: Whether to include the stack trace of returned
@@ -1225,7 +1225,7 @@ async def explain(
12251225
parameter can only be used when the `q` query string parameter is
12261226
specified.
12271227
:arg default_operator: The default operator for query string
1228-
query: `AND` or `OR`. Valid choices are and, or.
1228+
query: `AND` or `OR`. Valid choices are and, AND, or, OR.
12291229
:arg df: Field to use as default where no field prefix is given
12301230
in the query string. Default is _all.
12311231
:arg error_trace: Whether to include the stack trace of returned
@@ -2020,7 +2020,7 @@ async def reindex_rethrottle(
20202020
headers: Any = None,
20212021
) -> Any:
20222022
"""
2023-
Changes the number of requests per second for a particular Reindex operation.
2023+
Changes the number of requests per second for a particular reindex operation.
20242024
20252025
20262026
:arg task_id: Identifier for the task.
@@ -2138,8 +2138,6 @@ async def scroll(
21382138
Allows to retrieve a large numbers of results from a single search request.
21392139
21402140
2141-
:arg body: The scroll ID if not passed by URL or query
2142-
parameter.
21432141
:arg scroll_id: The scroll ID for scrolled search
21442142
:arg error_trace: Whether to include the stack trace of returned
21452143
errors. Default is false.
@@ -2281,7 +2279,7 @@ async def search(
22812279
executing cross-cluster search (CCS) requests. Default is True.
22822280
:arg default_operator: The default operator for query string
22832281
query: AND or OR. This parameter can only be used when the `q` query
2284-
string parameter is specified. Valid choices are and, or.
2282+
string parameter is specified. Valid choices are and, AND, or, OR.
22852283
:arg df: Field to use as default where no field prefix is given
22862284
in the query string. This parameter can only be used when the q query
22872285
string parameter is specified.
@@ -2451,6 +2449,7 @@ async def search(
24512449
)
24522450
async def search_shards(
24532451
self,
2452+
body: Any = None,
24542453
index: Any = None,
24552454
params: Any = None,
24562455
headers: Any = None,
@@ -2460,6 +2459,9 @@ async def search_shards(
24602459
executed against.
24612460
24622461
2462+
:arg body: Defines the parameters that can be used in the
2463+
`search_shards` endpoint request. See documentation for supported query
2464+
syntax.
24632465
:arg index: Returns the indexes and shards that a search request
24642466
would be executed against.
24652467
:arg allow_no_indices: If `false`, the request returns an error
@@ -2495,7 +2497,11 @@ async def search_shards(
24952497
libraries that do not accept a request body for non-POST requests.
24962498
"""
24972499
return await self.transport.perform_request(
2498-
"GET", _make_path(index, "_search_shards"), params=params, headers=headers
2500+
"POST",
2501+
_make_path(index, "_search_shards"),
2502+
params=params,
2503+
headers=headers,
2504+
body=body,
24992505
)
25002506

25012507
@query_params(
@@ -2834,7 +2840,7 @@ async def update_by_query(
28342840
:arg conflicts: What to do if update by query hits version
28352841
conflicts: `abort` or `proceed`. Valid choices are abort, proceed.
28362842
:arg default_operator: The default operator for query string
2837-
query: `AND` or `OR`. Valid choices are and, or.
2843+
query: `AND` or `OR`. Valid choices are and, AND, or, OR.
28382844
:arg df: Field to use as default where no field prefix is given
28392845
in the query string.
28402846
:arg error_trace: Whether to include the stack trace of returned

opensearchpy/_async/client/cat.py

+39-36
Original file line numberDiff line numberDiff line change
@@ -70,27 +70,29 @@ async def aliases(
7070
or use `*` or `_all`.
7171
:arg error_trace: Whether to include the stack trace of returned
7272
errors. Default is false.
73-
:arg expand_wildcards: Whether to expand wildcard expression to
74-
concrete indexes that are open, closed or both.
73+
:arg expand_wildcards: Expands wildcard expressions to concrete
74+
indexes. Combine multiple values with commas. Supported values are
75+
`all`, `open`, `closed`, `hidden`, and `none`.
7576
:arg filter_path: Used to reduce the response. This parameter
7677
takes a comma-separated list of filters. It supports using wildcards to
7778
match any field or part of a field’s name. You can also exclude fields
7879
with "-".
79-
:arg format: A short version of the Accept header (for example,
80-
`json`, `yaml`).
81-
:arg h: Comma-separated list of column names to display.
82-
:arg help: Return help information. Default is false.
80+
:arg format: A short version of the `Accept` header, such as
81+
`json` or `yaml`.
82+
:arg h: A comma-separated list of column names to display.
83+
:arg help: Returns help information. Default is false.
8384
:arg human: Whether to return human readable values for
8485
statistics. Default is True.
85-
:arg local: Return local information, do not retrieve the state
86-
from cluster-manager node. Default is false.
86+
:arg local: Whether to return information from the local node
87+
only instead of from the cluster manager node. Default is false.
8788
:arg pretty: Whether to pretty format the returned JSON
8889
response. Default is false.
89-
:arg s: Comma-separated list of column names or column aliases
90+
:arg s: A comma-separated list of column names or column aliases
9091
to sort by.
9192
:arg source: The URL-encoded request definition. Useful for
9293
libraries that do not accept a request body for non-POST requests.
93-
:arg v: Verbose mode. Display column headers. Default is false.
94+
:arg v: Enables verbose mode, which displays column headers.
95+
Default is false.
9496
"""
9597
return await self.transport.perform_request(
9698
"GET", _make_path("_cat", "aliases", name), params=params, headers=headers
@@ -171,36 +173,37 @@ async def allocation(
171173
much disk space they are using.
172174
173175
174-
:arg node_id: Comma-separated list of node identifiers or names
175-
used to limit the returned information.
176-
:arg bytes: The unit used to display byte values. Valid choices
176+
:arg node_id: A comma-separated list of node IDs or names used
177+
to limit the returned information.
178+
:arg bytes: The units used to display byte values. Valid choices
177179
are b, g, gb, k, kb, m, mb, p, pb, t, tb.
178-
:arg cluster_manager_timeout: Operation timeout for connection
179-
to cluster-manager node.
180+
:arg cluster_manager_timeout: A timeout for connection to the
181+
cluster manager node.
180182
:arg error_trace: Whether to include the stack trace of returned
181183
errors. Default is false.
182184
:arg filter_path: Used to reduce the response. This parameter
183185
takes a comma-separated list of filters. It supports using wildcards to
184186
match any field or part of a field’s name. You can also exclude fields
185187
with "-".
186-
:arg format: A short version of the Accept header (for example,
187-
`json`, `yaml`).
188-
:arg h: Comma-separated list of column names to display.
189-
:arg help: Return help information. Default is false.
188+
:arg format: A short version of the HTTP `Accept` header, such
189+
as `json` or `yaml`.
190+
:arg h: A comma-separated list of column names to display.
191+
:arg help: Returns help information. Default is false.
190192
:arg human: Whether to return human readable values for
191193
statistics. Default is True.
192-
:arg local: Return local information, do not retrieve the state
193-
from cluster-manager node. Default is false.
194+
:arg local: Returns local information but does not retrieve the
195+
state from cluster-manager node. Default is false.
194196
:arg master_timeout (Deprecated: To promote inclusive language,
195-
use `cluster_manager_timeout` instead.): Operation timeout for
196-
connection to cluster-manager node.
197+
use `cluster_manager_timeout` instead.): A timeout for connection to the
198+
cluster manager node.
197199
:arg pretty: Whether to pretty format the returned JSON
198200
response. Default is false.
199-
:arg s: Comma-separated list of column names or column aliases
201+
:arg s: A comma-separated list of column names or column aliases
200202
to sort by.
201203
:arg source: The URL-encoded request definition. Useful for
202204
libraries that do not accept a request body for non-POST requests.
203-
:arg v: Verbose mode. Display column headers. Default is false.
205+
:arg v: Enables verbose mode, which displays column headers.
206+
Default is false.
204207
"""
205208
return await self.transport.perform_request(
206209
"GET",
@@ -233,32 +236,33 @@ async def cluster_manager(
233236
Returns information about the cluster-manager node.
234237
235238
236-
:arg cluster_manager_timeout: Operation timeout for connection
237-
to cluster-manager node.
239+
:arg cluster_manager_timeout: A timeout for connection to the
240+
cluster manager node.
238241
:arg error_trace: Whether to include the stack trace of returned
239242
errors. Default is false.
240243
:arg filter_path: Used to reduce the response. This parameter
241244
takes a comma-separated list of filters. It supports using wildcards to
242245
match any field or part of a field’s name. You can also exclude fields
243246
with "-".
244-
:arg format: A short version of the Accept header (for example,
245-
`json`, `yaml`).
246-
:arg h: Comma-separated list of column names to display.
247+
:arg format: A short version of the HTTP `Accept` header, such
248+
as `json` or `yaml`.
249+
:arg h: A comma-separated list of column names to display.
247250
:arg help: Return help information. Default is false.
248251
:arg human: Whether to return human readable values for
249252
statistics. Default is True.
250253
:arg local: Return local information, do not retrieve the state
251254
from cluster-manager node. Default is false.
252255
:arg master_timeout (Deprecated: To promote inclusive language,
253-
use `cluster_manager_timeout` instead.): Operation timeout for
254-
connection to cluster-manager node.
256+
use `cluster_manager_timeout` instead.): A timeout for connection to the
257+
cluster manager node.
255258
:arg pretty: Whether to pretty format the returned JSON
256259
response. Default is false.
257-
:arg s: Comma-separated list of column names or column aliases
260+
:arg s: A comma-separated list of column names or column aliases
258261
to sort by.
259262
:arg source: The URL-encoded request definition. Useful for
260263
libraries that do not accept a request body for non-POST requests.
261-
:arg v: Verbose mode. Display column headers. Default is false.
264+
:arg v: Enables verbose mode, which displays column headers.
265+
Default is false.
262266
"""
263267
return await self.transport.perform_request(
264268
"GET", "/_cat/cluster_manager", params=params, headers=headers
@@ -498,8 +502,7 @@ async def indices(
498502
`json`, `yaml`).
499503
:arg h: Comma-separated list of column names to display.
500504
:arg health: The health status used to limit returned indexes.
501-
By default, the response includes indexes of any health status. Valid
502-
choices are green, red, yellow.
505+
By default, the response includes indexes of any health status.
503506
:arg help: Return help information. Default is false.
504507
:arg human: Whether to return human readable values for
505508
statistics. Default is True.

opensearchpy/_async/client/cluster.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ async def health(
127127
:arg wait_for_status: One of green, yellow or red. Will wait
128128
(until the timeout provided) until the status of the cluster changes to
129129
the one provided or better, i.e. green > yellow > red. By default, will
130-
not wait for any status. Valid choices are green, red, yellow.
130+
not wait for any status.
131131
"""
132132
return await self.transport.perform_request(
133133
"GET",

opensearchpy/_async/client/indices.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1638,7 +1638,7 @@ async def validate_query(
16381638
parameter can only be used when the `q` query string parameter is
16391639
specified.
16401640
:arg default_operator: The default operator for query string
1641-
query: `AND` or `OR`. Valid choices are and, or.
1641+
query: `AND` or `OR`. Valid choices are and, AND, or, OR.
16421642
:arg df: Field to use as default where no field prefix is given
16431643
in the query string. This parameter can only be used when the `q` query
16441644
string parameter is specified.

opensearchpy/_async/client/list.py

+1-2
Original file line numberDiff line numberDiff line change
@@ -103,8 +103,7 @@ async def indices(
103103
`JSON`, `YAML`.
104104
:arg h: Comma-separated list of column names to display.
105105
:arg health: The health status used to limit returned indexes.
106-
By default, the response includes indexes of any health status. Valid
107-
choices are green, red, yellow.
106+
By default, the response includes indexes of any health status.
108107
:arg help: Return help information. Default is false.
109108
:arg human: Whether to return human readable values for
110109
statistics. Default is True.

opensearchpy/_async/client/plugins.py

+4
Original file line numberDiff line numberDiff line change
@@ -22,13 +22,15 @@
2222
from ..plugins.query import QueryClient
2323
from ..plugins.replication import ReplicationClient
2424
from ..plugins.rollups import RollupsClient
25+
from ..plugins.sm import SmClient
2526
from ..plugins.sql import SqlClient
2627
from ..plugins.transforms import TransformsClient
2728
from .client import Client
2829
from .utils import NamespacedClient
2930

3031

3132
class PluginsClient(NamespacedClient):
33+
sm: Any
3234
asynchronous_search: Any
3335
alerting: Any
3436
index_management: Any
@@ -45,6 +47,7 @@ class PluginsClient(NamespacedClient):
4547
def __init__(self, client: Client) -> None:
4648
super().__init__(client)
4749

50+
self.sm = SmClient(client)
4851
self.replication = ReplicationClient(client)
4952
self.flow_framework = FlowFrameworkClient(client)
5053
self.asynchronous_search = AsynchronousSearchClient(client)
@@ -66,6 +69,7 @@ def _dynamic_lookup(self, client: Any) -> None:
6669
# Issue : https://github.com/opensearch-project/opensearch-py/issues/90#issuecomment-1003396742
6770

6871
plugins = [
72+
"sm",
6973
"replication",
7074
"flow_framework",
7175
"asynchronous_search",

opensearchpy/_async/plugins/knn.py

+1-4
Original file line numberDiff line numberDiff line change
@@ -310,7 +310,7 @@ async def stats(
310310
)
311311
async def train_model(
312312
self,
313-
body: Any,
313+
body: Any = None,
314314
model_id: Any = None,
315315
params: Any = None,
316316
headers: Any = None,
@@ -335,9 +335,6 @@ async def train_model(
335335
:arg source: The URL-encoded request definition. Useful for
336336
libraries that do not accept a request body for non-POST requests.
337337
"""
338-
if body in SKIP_IN_PATH:
339-
raise ValueError("Empty value passed for a required argument 'body'.")
340-
341338
return await self.transport.perform_request(
342339
"POST",
343340
_make_path("_plugins", "_knn", "models", model_id, "_train"),

opensearchpy/_async/plugins/observability.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ async def get_localstats(
135135
headers: Any = None,
136136
) -> Any:
137137
"""
138-
Retrieves Local Stats of all observability objects.
138+
Retrieves local stats of all observability objects.
139139
140140
141141
:arg error_trace: Whether to include the stack trace of returned

0 commit comments

Comments
 (0)