Skip to content

Commit

Permalink
Updated opensearch-py to reflect the latest OpenSearch API spec (2024…
Browse files Browse the repository at this point in the history
…-12-10)

Signed-off-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
  • Loading branch information
saimedhi authored and github-actions[bot] committed Dec 10, 2024
1 parent 7815c6a commit 65f5f18
Show file tree
Hide file tree
Showing 13 changed files with 747 additions and 26 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ Inspired from [Keep a Changelog](https://keepachangelog.com/en/1.0.0/)
- Added option to pass custom headers to 'AWSV4SignerAsyncAuth' ([863](https://github.com/opensearch-project/opensearch-py/pull/863))
- Added sync and async sample that uses `search_after` parameter ([859](https://github.com/opensearch-project/opensearch-py/pull/859))
### Updated APIs
- Updated opensearch-py APIs to reflect [opensearch-api-specification@c0237fb](https://github.com/opensearch-project/opensearch-api-specification/commit/c0237fb6e96bb1614c946a51d31a9461ddb4cfdb)
### Changed
- Small refactor of AWS Signer classes for both sync and async clients ([866](https://github.com/opensearch-project/opensearch-py/pull/866))
### Deprecated
Expand Down
20 changes: 14 additions & 6 deletions opensearchpy/_async/client/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -667,7 +667,7 @@ async def count(
specified.
:arg default_operator: The default operator for query string
query: `AND` or `OR`. This parameter can only be used when the `q` query
string parameter is specified. Valid choices are and, or.
string parameter is specified. Valid choices are and, AND, or, OR.
:arg df: Field to use as default where no field prefix is given
in the query string. This parameter can only be used when the `q` query
string parameter is specified.
Expand Down Expand Up @@ -855,7 +855,7 @@ async def delete_by_query(
:arg conflicts: What to do if delete by query hits version
conflicts: `abort` or `proceed`. Valid choices are abort, proceed.
:arg default_operator: The default operator for query string
query: `AND` or `OR`. Valid choices are and, or.
query: `AND` or `OR`. Valid choices are and, AND, or, OR.
:arg df: Field to use as default where no field prefix is given
in the query string.
:arg error_trace: Whether to include the stack trace of returned
Expand Down Expand Up @@ -1225,7 +1225,7 @@ async def explain(
parameter can only be used when the `q` query string parameter is
specified.
:arg default_operator: The default operator for query string
query: `AND` or `OR`. Valid choices are and, or.
query: `AND` or `OR`. Valid choices are and, AND, or, OR.
:arg df: Field to use as default where no field prefix is given
in the query string. Default is _all.
:arg error_trace: Whether to include the stack trace of returned
Expand Down Expand Up @@ -2281,7 +2281,7 @@ async def search(
executing cross-cluster search (CCS) requests. Default is True.
:arg default_operator: The default operator for query string
query: AND or OR. This parameter can only be used when the `q` query
string parameter is specified. Valid choices are and, or.
string parameter is specified. Valid choices are and, AND, or, OR.
:arg df: Field to use as default where no field prefix is given
in the query string. This parameter can only be used when the q query
string parameter is specified.
Expand Down Expand Up @@ -2451,6 +2451,7 @@ async def search(
)
async def search_shards(
self,
body: Any = None,
index: Any = None,
params: Any = None,
headers: Any = None,
Expand All @@ -2460,6 +2461,9 @@ async def search_shards(
executed against.
:arg body: Defines the parameters that can be used in the
`search_shards` endpoint request. See documentation for supported query
syntax.
:arg index: Returns the indexes and shards that a search request
would be executed against.
:arg allow_no_indices: If `false`, the request returns an error
Expand Down Expand Up @@ -2495,7 +2499,11 @@ async def search_shards(
libraries that do not accept a request body for non-POST requests.
"""
return await self.transport.perform_request(
"GET", _make_path(index, "_search_shards"), params=params, headers=headers
"POST",
_make_path(index, "_search_shards"),
params=params,
headers=headers,
body=body,
)

@query_params(
Expand Down Expand Up @@ -2834,7 +2842,7 @@ async def update_by_query(
:arg conflicts: What to do if update by query hits version
conflicts: `abort` or `proceed`. Valid choices are abort, proceed.
:arg default_operator: The default operator for query string
query: `AND` or `OR`. Valid choices are and, or.
query: `AND` or `OR`. Valid choices are and, AND, or, OR.
:arg df: Field to use as default where no field prefix is given
in the query string.
:arg error_trace: Whether to include the stack trace of returned
Expand Down
9 changes: 7 additions & 2 deletions opensearchpy/_async/client/indices.py
Original file line number Diff line number Diff line change
Expand Up @@ -1638,7 +1638,7 @@ async def validate_query(
parameter can only be used when the `q` query string parameter is
specified.
:arg default_operator: The default operator for query string
query: `AND` or `OR`. Valid choices are and, or.
query: `AND` or `OR`. Valid choices are and, AND, or, OR.
:arg df: Field to use as default where no field prefix is given
in the query string. This parameter can only be used when the `q` query
string parameter is specified.
Expand Down Expand Up @@ -1797,6 +1797,7 @@ async def recovery(
)
async def upgrade(
self,
body: Any = None,
index: Any = None,
params: Any = None,
headers: Any = None,
Expand Down Expand Up @@ -1832,7 +1833,11 @@ async def upgrade(
operation has completed before returning. Default is false.
"""
return await self.transport.perform_request(
"POST", _make_path(index, "_upgrade"), params=params, headers=headers
"POST",
_make_path(index, "_upgrade"),
params=params,
headers=headers,
body=body,
)

@query_params(
Expand Down
4 changes: 4 additions & 0 deletions opensearchpy/_async/client/plugins.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,15 @@
from ..plugins.query import QueryClient
from ..plugins.replication import ReplicationClient
from ..plugins.rollups import RollupsClient
from ..plugins.sm import SmClient
from ..plugins.sql import SqlClient
from ..plugins.transforms import TransformsClient
from .client import Client
from .utils import NamespacedClient


class PluginsClient(NamespacedClient):
sm: Any
asynchronous_search: Any
alerting: Any
index_management: Any
Expand All @@ -45,6 +47,7 @@ class PluginsClient(NamespacedClient):
def __init__(self, client: Client) -> None:
super().__init__(client)

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

plugins = [
"sm",
"replication",
"flow_framework",
"asynchronous_search",
Expand Down
5 changes: 1 addition & 4 deletions opensearchpy/_async/plugins/knn.py
Original file line number Diff line number Diff line change
Expand Up @@ -310,7 +310,7 @@ async def stats(
)
async def train_model(
self,
body: Any,
body: Any = None,
model_id: Any = None,
params: Any = None,
headers: Any = None,
Expand All @@ -335,9 +335,6 @@ async def train_model(
:arg source: The URL-encoded request definition. Useful for
libraries that do not accept a request body for non-POST requests.
"""
if body in SKIP_IN_PATH:
raise ValueError("Empty value passed for a required argument 'body'.")

return await self.transport.perform_request(
"POST",
_make_path("_plugins", "_knn", "models", model_id, "_train"),
Expand Down
2 changes: 1 addition & 1 deletion opensearchpy/_async/plugins/observability.py
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ async def get_localstats(
headers: Any = None,
) -> Any:
"""
Retrieves Local Stats of all observability objects.
Retrieves local stats of all observability objects.
:arg error_trace: Whether to include the stack trace of returned
Expand Down
Loading

0 comments on commit 65f5f18

Please sign in to comment.