Skip to content

Commit 2afa704

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

File tree

13 files changed

+747
-26
lines changed

13 files changed

+747
-26
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@6341e87](https://github.com/opensearch-project/opensearch-api-specification/commit/6341e87326b2cbc5659a284b61e0a40b7b89e4ee)
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
### Deprecated

opensearchpy/_async/client/__init__.py

+14-6
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
@@ -2281,7 +2281,7 @@ async def search(
22812281
executing cross-cluster search (CCS) requests. Default is True.
22822282
:arg default_operator: The default operator for query string
22832283
query: AND or OR. This parameter can only be used when the `q` query
2284-
string parameter is specified. Valid choices are and, or.
2284+
string parameter is specified. Valid choices are and, AND, or, OR.
22852285
:arg df: Field to use as default where no field prefix is given
22862286
in the query string. This parameter can only be used when the q query
22872287
string parameter is specified.
@@ -2451,6 +2451,7 @@ async def search(
24512451
)
24522452
async def search_shards(
24532453
self,
2454+
body: Any = None,
24542455
index: Any = None,
24552456
params: Any = None,
24562457
headers: Any = None,
@@ -2460,6 +2461,9 @@ async def search_shards(
24602461
executed against.
24612462
24622463
2464+
:arg body: Defines the parameters that can be used in the
2465+
`search_shards` endpoint request. See documentation for supported query
2466+
syntax.
24632467
:arg index: Returns the indexes and shards that a search request
24642468
would be executed against.
24652469
:arg allow_no_indices: If `false`, the request returns an error
@@ -2495,7 +2499,11 @@ async def search_shards(
24952499
libraries that do not accept a request body for non-POST requests.
24962500
"""
24972501
return await self.transport.perform_request(
2498-
"GET", _make_path(index, "_search_shards"), params=params, headers=headers
2502+
"POST",
2503+
_make_path(index, "_search_shards"),
2504+
params=params,
2505+
headers=headers,
2506+
body=body,
24992507
)
25002508

25012509
@query_params(
@@ -2834,7 +2842,7 @@ async def update_by_query(
28342842
:arg conflicts: What to do if update by query hits version
28352843
conflicts: `abort` or `proceed`. Valid choices are abort, proceed.
28362844
:arg default_operator: The default operator for query string
2837-
query: `AND` or `OR`. Valid choices are and, or.
2845+
query: `AND` or `OR`. Valid choices are and, AND, or, OR.
28382846
:arg df: Field to use as default where no field prefix is given
28392847
in the query string.
28402848
:arg error_trace: Whether to include the stack trace of returned

opensearchpy/_async/client/indices.py

+7-2
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.
@@ -1797,6 +1797,7 @@ async def recovery(
17971797
)
17981798
async def upgrade(
17991799
self,
1800+
body: Any = None,
18001801
index: Any = None,
18011802
params: Any = None,
18021803
headers: Any = None,
@@ -1832,7 +1833,11 @@ async def upgrade(
18321833
operation has completed before returning. Default is false.
18331834
"""
18341835
return await self.transport.perform_request(
1835-
"POST", _make_path(index, "_upgrade"), params=params, headers=headers
1836+
"POST",
1837+
_make_path(index, "_upgrade"),
1838+
params=params,
1839+
headers=headers,
1840+
body=body,
18361841
)
18371842

18381843
@query_params(

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)