Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Updated opensearch-py to reflect the latest OpenSearch API spec #864

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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@2dda6e1](https://github.com/opensearch-project/opensearch-api-specification/commit/2dda6e131eb81350eebaaa5e3abb216bb677ea0b)
### Changed
- Small refactor of AWS Signer classes for both sync and async clients ([866](https://github.com/opensearch-project/opensearch-py/pull/866))
- Small refactor to fix overwriting the module files when generating apis ([874](https://github.com/opensearch-project/opensearch-py/pull/874))
Expand Down
86 changes: 32 additions & 54 deletions opensearchpy/_async/client/__init__.py

Large diffs are not rendered by default.

675 changes: 341 additions & 334 deletions opensearchpy/_async/client/cat.py

Large diffs are not rendered by default.

406 changes: 194 additions & 212 deletions opensearchpy/_async/client/cluster.py

Large diffs are not rendered by default.

16 changes: 8 additions & 8 deletions opensearchpy/_async/client/indices.py
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,7 @@ async def create(
:arg wait_for_active_shards: The number of shard copies that
must be active before proceeding with the operation. Set to `all` or
any positive integer up to the total number of shards in the index
(`number_of_replicas+1`). Valid choices are all, index-setting.
(`number_of_replicas+1`).
"""
if index in SKIP_IN_PATH:
raise ValueError("Empty value passed for a required argument 'index'.")
Expand Down Expand Up @@ -300,7 +300,7 @@ async def clone(
:arg wait_for_active_shards: The number of shard copies that
must be active before proceeding with the operation. Set to `all` or any
positive integer up to the total number of shards in the index
(`number_of_replicas+1`). Valid choices are all, index-setting.
(`number_of_replicas+1`).
:arg wait_for_completion: Should this request wait until the
operation has completed before returning. Default is True.
"""
Expand Down Expand Up @@ -459,7 +459,7 @@ async def open(
:arg wait_for_active_shards: The number of shard copies that
must be active before proceeding with the operation. Set to `all` or any
positive integer up to the total number of shards in the index
(`number_of_replicas+1`). Valid choices are all, index-setting.
(`number_of_replicas+1`).
:arg wait_for_completion: Should this request wait until the
operation has completed before returning. Default is True.
"""
Expand Down Expand Up @@ -531,7 +531,7 @@ async def close(
:arg wait_for_active_shards: The number of shard copies that
must be active before proceeding with the operation. Set to `all` or any
positive integer up to the total number of shards in the index
(`number_of_replicas+1`). Valid choices are all, index-setting.
(`number_of_replicas+1`).
"""
if index in SKIP_IN_PATH:
raise ValueError("Empty value passed for a required argument 'index'.")
Expand Down 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 @@ -2053,7 +2053,7 @@ async def shrink(
:arg wait_for_active_shards: The number of shard copies that
must be active before proceeding with the operation. Set to `all` or any
positive integer up to the total number of shards in the index
(`number_of_replicas+1`). Valid choices are all, index-setting.
(`number_of_replicas+1`).
:arg wait_for_completion: Should this request wait until the
operation has completed before returning. Default is True.
"""
Expand Down Expand Up @@ -2128,7 +2128,7 @@ async def split(
:arg wait_for_active_shards: The number of shard copies that
must be active before proceeding with the operation. Set to `all` or any
positive integer up to the total number of shards in the index
(`number_of_replicas+1`). Valid choices are all, index-setting.
(`number_of_replicas+1`).
:arg wait_for_completion: Should this request wait until the
operation has completed before returning. Default is True.
"""
Expand Down Expand Up @@ -2201,7 +2201,7 @@ async def rollover(
:arg wait_for_active_shards: The number of shard copies that
must be active before proceeding with the operation. Set to all or any
positive integer up to the total number of shards in the index
(`number_of_replicas+1`). Valid choices are all, index-setting.
(`number_of_replicas+1`).
"""
if alias in SKIP_IN_PATH:
raise ValueError("Empty value passed for a required argument 'alias'.")
Expand Down
53 changes: 25 additions & 28 deletions opensearchpy/_async/client/ingest.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,14 +56,14 @@ async def get_pipeline(
headers: Any = None,
) -> Any:
"""
Returns a pipeline.
Returns an ingest pipeline.


:arg id: Comma-separated list of pipeline IDs to retrieve.
:arg id: A comma-separated list of pipeline IDs to retrieve.
Wildcard (`*`) expressions are supported. To get all ingest pipelines,
omit this parameter or use `*`.
:arg cluster_manager_timeout: Operation timeout for connection
to cluster-manager node.
:arg cluster_manager_timeout: The amount of time allowed to
establish a connection to the cluster manager node.
:arg error_trace: Whether to include the stack trace of returned
errors. Default is false.
:arg filter_path: Used to reduce the response. This parameter
Expand Down Expand Up @@ -103,13 +103,13 @@ async def put_pipeline(
headers: Any = None,
) -> Any:
"""
Creates or updates a pipeline.
Creates or updates an ingest pipeline.


:arg id: ID of the ingest pipeline to create or update.
:arg body: The ingest definition
:arg cluster_manager_timeout: Operation timeout for connection
to cluster-manager node.
:arg id: The ID of the ingest pipeline.
:arg body: The ingest definition.
:arg cluster_manager_timeout: The amount of time allowed to
establish a connection to the cluster manager node.
:arg error_trace: Whether to include the stack trace of returned
errors. Default is false.
:arg filter_path: Used to reduce the response. This parameter
Expand All @@ -126,9 +126,7 @@ async def put_pipeline(
response. Default is false.
:arg source: The URL-encoded request definition. Useful for
libraries that do not accept a request body for non-POST requests.
:arg timeout: Period to wait for a response. If no response is
received before the timeout expires, the request fails and returns an
error.
:arg timeout: The amount of time to wait for a response.
"""
for param in (id, body):
if param in SKIP_IN_PATH:
Expand Down Expand Up @@ -159,14 +157,14 @@ async def delete_pipeline(
headers: Any = None,
) -> Any:
"""
Deletes a pipeline.
Deletes an ingest pipeline.


:arg id: Pipeline ID or wildcard expression of pipeline IDs used
to limit the request. To delete all ingest pipelines in a cluster, use a
value of `*`.
:arg cluster_manager_timeout: Operation timeout for connection
to cluster-manager node.
:arg id: The pipeline ID or wildcard expression of pipeline IDs
used to limit the request. To delete all ingest pipelines in a cluster,
use a value of `*`.
:arg cluster_manager_timeout: The amount of time allowed to
establish a connection to the cluster manager node.
:arg error_trace: Whether to include the stack trace of returned
errors. Default is false.
:arg filter_path: Used to reduce the response. This parameter
Expand All @@ -183,9 +181,7 @@ async def delete_pipeline(
response. Default is false.
:arg source: The URL-encoded request definition. Useful for
libraries that do not accept a request body for non-POST requests.
:arg timeout: Period to wait for a response. If no response is
received before the timeout expires, the request fails and returns an
error.
:arg timeout: The amount of time to wait for a response.
"""
if id in SKIP_IN_PATH:
raise ValueError("Empty value passed for a required argument 'id'.")
Expand All @@ -206,12 +202,12 @@ async def simulate(
headers: Any = None,
) -> Any:
"""
Allows to simulate a pipeline with example documents.
Simulates an ingest pipeline with example documents.


:arg body: The simulate definition
:arg id: Pipeline to test. If you don't specify a `pipeline` in
the request body, this parameter is required.
:arg id: The pipeline to test. If you don't specify a `pipeline`
in the request body, this parameter is required.
:arg error_trace: Whether to include the stack trace of returned
errors. Default is false.
:arg filter_path: Used to reduce the response. This parameter
Expand All @@ -224,8 +220,8 @@ async def simulate(
response. Default is false.
:arg source: The URL-encoded request definition. Useful for
libraries that do not accept a request body for non-POST requests.
:arg verbose: If `true`, the response includes output data for
each processor in the executed pipeline. Default is false.
:arg verbose: When `true`, the response includes output data for
each processor in the pipeline Default is false.
"""
if body in SKIP_IN_PATH:
raise ValueError("Empty value passed for a required argument 'body'.")
Expand All @@ -245,7 +241,7 @@ async def processor_grok(
headers: Any = None,
) -> Any:
"""
Returns a list of the built-in patterns.
Returns a list of built-in grok patterns.


:arg error_trace: Whether to include the stack trace of returned
Expand All @@ -258,7 +254,8 @@ async def processor_grok(
statistics. Default is True.
:arg pretty: Whether to pretty format the returned JSON
response. Default is false.
:arg s: Sort returned patterns by key name. Default is false.
:arg s: Determines how to sort returned grok patterns by key
name. Default is false.
:arg source: The URL-encoded request definition. Useful for
libraries that do not accept a request body for non-POST requests.
"""
Expand Down
15 changes: 5 additions & 10 deletions opensearchpy/_async/client/list.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,8 +87,7 @@ async def indices(
:arg index: Comma-separated list of data streams, indexes, and
aliases used to limit the request. Supports wildcards (`*`). To target
all data streams and indexes, omit this parameter or use `*` or `_all`.
:arg bytes: The unit used to display byte values. Valid choices
are b, g, gb, k, kb, m, mb, p, pb, t, tb.
:arg bytes: The unit used to display byte values.
:arg cluster_manager_timeout: Operation timeout for connection
to cluster-manager node.
:arg error_trace: Whether to include the stack trace of returned
Expand All @@ -103,8 +102,7 @@ async def indices(
`JSON`, `YAML`.
:arg h: Comma-separated list of column names to display.
:arg health: The health status used to limit returned indexes.
By default, the response includes indexes of any health status. Valid
choices are green, red, yellow.
By default, the response includes indexes of any health status.
:arg help: Return help information. Default is false.
:arg human: Whether to return human readable values for
statistics. Default is True.
Expand All @@ -129,8 +127,7 @@ async def indices(
indexes would be displayed first. Valid choices are asc, desc.
:arg source: The URL-encoded request definition. Useful for
libraries that do not accept a request body for non-POST requests.
:arg time: The unit used to display time values. Valid choices
are d, h, m, micros, ms, nanos, s.
:arg time: The unit used to display time values.
:arg v: Verbose mode. Display column headers. Default is false.
"""
return await self.transport.perform_request(
Expand Down Expand Up @@ -170,8 +167,7 @@ async def shards(
:arg index: A comma-separated list of data streams, indexes, and
aliases used to limit the request. Supports wildcards (`*`). To target
all data streams and indexes, omit this parameter or use `*` or `_all`.
:arg bytes: The unit used to display byte values. Valid choices
are b, g, gb, k, kb, m, mb, p, pb, t, tb.
:arg bytes: The unit used to display byte values.
:arg cluster_manager_timeout: Operation timeout for connection
to cluster-manager node.
:arg error_trace: Whether to include the stack trace of returned
Expand Down Expand Up @@ -202,8 +198,7 @@ async def shards(
shards would be displayed first. Valid choices are asc, desc.
:arg source: The URL-encoded request definition. Useful for
libraries that do not accept a request body for non-POST requests.
:arg time: The unit in which to display time values. Valid
choices are d, h, m, micros, ms, nanos, s.
:arg time: The unit in which to display time values.
:arg v: Verbose mode. Display column headers. Default is false.
"""
return await self.transport.perform_request(
Expand Down
7 changes: 7 additions & 0 deletions opensearchpy/_async/client/plugins.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,20 +15,23 @@
from ..plugins.flow_framework import FlowFrameworkClient
from ..plugins.index_management import IndexManagementClient
from ..plugins.knn import KnnClient
from ..plugins.ltr import LtrClient
from ..plugins.ml import MlClient
from ..plugins.notifications import NotificationsClient
from ..plugins.observability import ObservabilityClient
from ..plugins.ppl import PplClient
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):
ltr: Any
asynchronous_search: Any
alerting: Any
index_management: Any
Expand All @@ -45,6 +48,8 @@ class PluginsClient(NamespacedClient):
def __init__(self, client: Client) -> None:
super().__init__(client)

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

plugins = [
"sm",
"ltr",
"replication",
"flow_framework",
"asynchronous_search",
Expand Down
Loading
Loading