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

Use API generator. #549

Closed
wants to merge 3 commits into from
Closed
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 @@ -17,6 +17,7 @@ Inspired from [Keep a Changelog](https://keepachangelog.com/en/1.0.0/)
- Generate `cluster` client from API specs ([#530](https://github.com/opensearch-project/opensearch-py/pull/530))
- Generate `nodes` client from API specs ([#514](https://github.com/opensearch-project/opensearch-py/pull/514))
- Generate `cat` client from API specs ([#529](https://github.com/opensearch-project/opensearch-py/pull/529))
- Use API generator for all APIs ([#549](https://github.com/opensearch-project/opensearch-py/pull/549/))
### Deprecated
- Deprecated point-in-time APIs (list_all_point_in_time, create_point_in_time, delete_point_in_time) and Security Client APIs (health_check and update_audit_config) ([#502](https://github.com/opensearch-project/opensearch-py/pull/502))
### Removed
Expand Down
1 change: 1 addition & 0 deletions dev-requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ sphinx<7.3
sphinx_rtd_theme
jinja2
pytz
jsonmerge

# No wheels for Python 3.10 yet!
numpy; python_version<"3.10"
Expand Down
1,097 changes: 532 additions & 565 deletions opensearchpy/_async/client/__init__.py

Large diffs are not rendered by default.

35 changes: 12 additions & 23 deletions opensearchpy/_async/client/__init__.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,15 @@
# specific language governing permissions and limitations
# under the License.

# ----------------------------------------------------
# THIS CODE IS GENERATED AND MANUAL EDITS WILL BE LOST.
#
# To contribute, kindly make essential modifications through either the "opensearch-py client generator":
# https://github.com/opensearch-project/opensearch-py/blob/main/utils/generate-api.py
# or the "OpenSearch API specification" available at:
# https://github.com/opensearch-project/opensearch-api-specification/blob/main/OpenSearch.openapi.json
# -----------------------------------------------------

from __future__ import unicode_literals

import logging
Expand Down Expand Up @@ -333,8 +342,8 @@ class AsyncOpenSearch(object):
self,
id: Any,
*,
master_timeout: Optional[Any] = ...,
cluster_manager_timeout: Optional[Any] = ...,
master_timeout: Optional[Any] = ...,
timeout: Optional[Any] = ...,
pretty: Optional[bool] = ...,
human: Optional[bool] = ...,
Expand Down Expand Up @@ -490,8 +499,8 @@ class AsyncOpenSearch(object):
self,
id: Any,
*,
master_timeout: Optional[Any] = ...,
cluster_manager_timeout: Optional[Any] = ...,
master_timeout: Optional[Any] = ...,
pretty: Optional[bool] = ...,
human: Optional[bool] = ...,
error_trace: Optional[bool] = ...,
Expand Down Expand Up @@ -642,8 +651,8 @@ class AsyncOpenSearch(object):
*,
body: Any,
context: Optional[Any] = ...,
master_timeout: Optional[Any] = ...,
cluster_manager_timeout: Optional[Any] = ...,
master_timeout: Optional[Any] = ...,
timeout: Optional[Any] = ...,
pretty: Optional[bool] = ...,
human: Optional[bool] = ...,
Expand Down Expand Up @@ -802,7 +811,6 @@ class AsyncOpenSearch(object):
ignore_unavailable: Optional[Any] = ...,
lenient: Optional[Any] = ...,
max_concurrent_shard_requests: Optional[Any] = ...,
min_compatible_shard_node: Optional[Any] = ...,
pre_filter_shard_size: Optional[Any] = ...,
preference: Optional[Any] = ...,
q: Optional[Any] = ...,
Expand Down Expand Up @@ -991,7 +999,6 @@ class AsyncOpenSearch(object):
terminate_after: Optional[Any] = ...,
timeout: Optional[Any] = ...,
version: Optional[Any] = ...,
version_type: Optional[Any] = ...,
wait_for_active_shards: Optional[Any] = ...,
wait_for_completion: Optional[Any] = ...,
pretty: Optional[bool] = ...,
Expand Down Expand Up @@ -1128,21 +1135,3 @@ class AsyncOpenSearch(object):
params: Optional[MutableMapping[str, Any]] = ...,
headers: Optional[MutableMapping[str, str]] = ...,
) -> Any: ...
async def terms_enum(
self,
index: Any,
*,
body: Optional[Any] = ...,
pretty: Optional[bool] = ...,
human: Optional[bool] = ...,
error_trace: Optional[bool] = ...,
format: Optional[str] = ...,
filter_path: Optional[Union[str, Collection[str]]] = ...,
request_timeout: Optional[Union[int, float]] = ...,
ignore: Optional[Union[int, Collection[int]]] = ...,
opaque_id: Optional[str] = ...,
http_auth: Optional[Union[str, Tuple[str, str]]] = ...,
api_key: Optional[Union[str, Tuple[str, str]]] = ...,
params: Optional[MutableMapping[str, Any]] = ...,
headers: Optional[MutableMapping[str, str]] = ...,
) -> Any: ...
275 changes: 138 additions & 137 deletions opensearchpy/_async/client/cat.py

Large diffs are not rendered by default.

102 changes: 52 additions & 50 deletions opensearchpy/_async/client/cluster.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,30 +65,30 @@ async def health(self, index=None, params=None, headers=None):
:arg cluster_manager_timeout: Operation timeout for connection
to cluster-manager node.
:arg expand_wildcards: Whether to expand wildcard expression to
concrete indices that are open, closed or both. Valid choices: all,
open, closed, hidden, none
concrete indices that are open, closed or both. Valid choices are all,
open, closed, hidden, none.
:arg level: Specify the level of detail for returned
information. Valid choices: cluster, indices, shards,
awareness_attributes
information. Valid choices are cluster, indices, shards,
awareness_attributes.
:arg local: Return local information, do not retrieve the state
from cluster-manager node. (default: false)
from cluster-manager node. Default is false.
:arg master_timeout (Deprecated: To promote inclusive language,
use 'cluster_manager_timeout' instead): Operation timeout for connection
to master node.
use 'cluster_manager_timeout' instead.): Operation timeout for
connection to master node.
:arg timeout: Operation timeout.
:arg wait_for_active_shards: Wait until the specified number of
shards is active.
:arg wait_for_events: Wait until all currently queued events
with the given priority are processed. Valid choices: immediate,
urgent, high, normal, low, languid
with the given priority are processed. Valid choices are immediate,
urgent, high, normal, low, languid.
:arg wait_for_no_initializing_shards: Whether to wait until
there are no initializing shards in the cluster.
:arg wait_for_no_relocating_shards: Whether to wait until there
are no relocating shards in the cluster.
:arg wait_for_nodes: Wait until the specified number of nodes is
available.
:arg wait_for_status: Wait until cluster is in a specific state.
Valid choices: green, yellow, red
Valid choices are green, yellow, red.
"""
return await self.transport.perform_request(
"GET",
Expand All @@ -107,10 +107,10 @@ async def pending_tasks(self, params=None, headers=None):
:arg cluster_manager_timeout: Operation timeout for connection
to cluster-manager node.
:arg local: Return local information, do not retrieve the state
from cluster-manager node. (default: false)
from cluster-manager node. Default is false.
:arg master_timeout (Deprecated: To promote inclusive language,
use 'cluster_manager_timeout' instead): Operation timeout for connection
to master node.
use 'cluster_manager_timeout' instead.): Operation timeout for
connection to master node.
"""
return await self.transport.perform_request(
"GET", "/_cluster/pending_tasks", params=params, headers=headers
Expand All @@ -133,8 +133,8 @@ async def state(self, metric=None, index=None, params=None, headers=None):


:arg metric: Limit the information returned to the specified
metrics. Valid choices: _all, blocks, metadata, nodes, routing_table,
routing_nodes, master_node, cluster_manager_node, version
metrics. Valid choices are _all, blocks, metadata, nodes, routing_table,
routing_nodes, master_node, cluster_manager_node, version.
:arg index: Comma-separated list of indices; use `_all` or empty
string to perform the operation on all indices.
:arg allow_no_indices: Whether to ignore if a wildcard indices
Expand All @@ -143,17 +143,17 @@ async def state(self, metric=None, index=None, params=None, headers=None):
:arg cluster_manager_timeout: Operation timeout for connection
to cluster-manager node.
:arg expand_wildcards: Whether to expand wildcard expression to
concrete indices that are open, closed or both. Valid choices: all,
open, closed, hidden, none
:arg flat_settings: Return settings in flat format. (default:
false)
concrete indices that are open, closed or both. Valid choices are all,
open, closed, hidden, none.
:arg flat_settings: Return settings in flat format. Default is
false.
:arg ignore_unavailable: Whether specified concrete indices
should be ignored when unavailable (missing or closed).
:arg local: Return local information, do not retrieve the state
from cluster-manager node. (default: false)
from cluster-manager node. Default is false.
:arg master_timeout (Deprecated: To promote inclusive language,
use 'cluster_manager_timeout' instead): Operation timeout for connection
to master node.
use 'cluster_manager_timeout' instead.): Operation timeout for
connection to master node.
:arg wait_for_metadata_version: Wait for the metadata version to
be equal or greater than the specified metadata version.
:arg wait_for_timeout: The maximum time to wait for
Expand All @@ -179,8 +179,8 @@ async def stats(self, node_id=None, params=None, headers=None):
the returned information; use `_local` to return information from the
node you're connecting to, leave empty to get information from all
nodes.
:arg flat_settings: Return settings in flat format. (default:
false)
:arg flat_settings: Return settings in flat format. Default is
false.
:arg timeout: Operation timeout.
"""
return await self.transport.perform_request(
Expand Down Expand Up @@ -215,8 +215,8 @@ async def reroute(self, body=None, params=None, headers=None):
:arg explain: Return an explanation of why the commands can or
cannot be executed.
:arg master_timeout (Deprecated: To promote inclusive language,
use 'cluster_manager_timeout' instead): Operation timeout for connection
to master node.
use 'cluster_manager_timeout' instead.): Operation timeout for
connection to master node.
:arg metric: Limit the information returned to the specified
metrics. Defaults to all but metadata.
:arg retry_failed: Retries allocation of shards that are blocked
Expand All @@ -241,13 +241,13 @@ async def get_settings(self, params=None, headers=None):

:arg cluster_manager_timeout: Operation timeout for connection
to cluster-manager node.
:arg flat_settings: Return settings in flat format. (default:
false)
:arg flat_settings: Return settings in flat format. Default is
false.
:arg include_defaults: Whether to return all default clusters
setting. (default: false)
setting. Default is false.
:arg master_timeout (Deprecated: To promote inclusive language,
use 'cluster_manager_timeout' instead): Operation timeout for connection
to master node.
use 'cluster_manager_timeout' instead.): Operation timeout for
connection to master node.
:arg timeout: Operation timeout.
"""
return await self.transport.perform_request(
Expand All @@ -266,11 +266,11 @@ async def put_settings(self, body, params=None, headers=None):
or `persistent` (survives cluster restart).
:arg cluster_manager_timeout: Operation timeout for connection
to cluster-manager node.
:arg flat_settings: Return settings in flat format. (default:
false)
:arg flat_settings: Return settings in flat format. Default is
false.
:arg master_timeout (Deprecated: To promote inclusive language,
use 'cluster_manager_timeout' instead): Operation timeout for connection
to master node.
use 'cluster_manager_timeout' instead.): Operation timeout for
connection to master node.
:arg timeout: Operation timeout.
"""
if body in SKIP_IN_PATH:
Expand Down Expand Up @@ -299,9 +299,9 @@ async def allocation_explain(self, body=None, params=None, headers=None):
:arg body: The index, shard, and primary flag to explain. Empty
means 'explain the first unassigned shard'
:arg include_disk_info: Return information about disk usage and
shard sizes. (default: false)
shard sizes. Default is false.
:arg include_yes_decisions: Return 'YES' decisions in
explanation. (default: false)
explanation. Default is false.
"""
return await self.transport.perform_request(
"POST",
Expand All @@ -321,8 +321,8 @@ async def delete_component_template(self, name, params=None, headers=None):
:arg cluster_manager_timeout: Operation timeout for connection
to cluster-manager node.
:arg master_timeout (Deprecated: To promote inclusive language,
use 'cluster_manager_timeout' instead): Operation timeout for connection
to master node.
use 'cluster_manager_timeout' instead.): Operation timeout for
connection to master node.
:arg timeout: Operation timeout.
"""
if name in SKIP_IN_PATH:
Expand All @@ -345,10 +345,10 @@ async def get_component_template(self, name=None, params=None, headers=None):
:arg cluster_manager_timeout: Operation timeout for connection
to cluster-manager node.
:arg local: Return local information, do not retrieve the state
from cluster-manager node. (default: false)
from cluster-manager node. Default is false.
:arg master_timeout (Deprecated: To promote inclusive language,
use 'cluster_manager_timeout' instead): Operation timeout for connection
to master node.
use 'cluster_manager_timeout' instead.): Operation timeout for
connection to master node.
"""
return await self.transport.perform_request(
"GET",
Expand All @@ -368,10 +368,10 @@ async def put_component_template(self, name, body, params=None, headers=None):
:arg cluster_manager_timeout: Operation timeout for connection
to cluster-manager node.
:arg create: Whether the index template should only be added if
new or can also replace an existing one. (default: false)
new or can also replace an existing one. Default is false.
:arg master_timeout (Deprecated: To promote inclusive language,
use 'cluster_manager_timeout' instead): Operation timeout for connection
to master node.
use 'cluster_manager_timeout' instead.): Operation timeout for
connection to master node.
:arg timeout: Operation timeout.
"""
for param in (name, body):
Expand All @@ -386,18 +386,20 @@ async def put_component_template(self, name, body, params=None, headers=None):
body=body,
)

@query_params("local", "master_timeout")
@query_params("cluster_manager_timeout", "local", "master_timeout")
async def exists_component_template(self, name, params=None, headers=None):
"""
Returns information about whether a particular component template exist.


:arg name: The name of the template.
:arg cluster_manager_timeout: Operation timeout for connection
to cluster-manager node.
:arg local: Return local information, do not retrieve the state
from cluster-manager node. (default: false)
from cluster-manager node. Default is false.
:arg master_timeout (Deprecated: To promote inclusive language,
use 'cluster_manager_timeout' instead): Operation timeout for connection
to master node.
use 'cluster_manager_timeout' instead.): Operation timeout for
connection to master node.
"""
if name in SKIP_IN_PATH:
raise ValueError("Empty value passed for a required argument 'name'.")
Expand All @@ -417,7 +419,7 @@ async def delete_voting_config_exclusions(self, params=None, headers=None):

:arg wait_for_removal: Specifies whether to wait for all
excluded nodes to be removed from the cluster before clearing the voting
configuration exclusions list. (default: True)
configuration exclusions list. Default is True.
"""
return await self.transport.perform_request(
"DELETE",
Expand Down
1 change: 1 addition & 0 deletions opensearchpy/_async/client/cluster.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -300,6 +300,7 @@ class ClusterClient(NamespacedClient):
self,
name: Any,
*,
cluster_manager_timeout: Optional[Any] = ...,
local: Optional[Any] = ...,
master_timeout: Optional[Any] = ...,
pretty: Optional[bool] = ...,
Expand Down
8 changes: 4 additions & 4 deletions opensearchpy/_async/client/dangling_indices.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,8 @@ async def delete_dangling_index(self, index_uuid, params=None, headers=None):
:arg cluster_manager_timeout: Operation timeout for connection
to cluster-manager node.
:arg master_timeout (Deprecated: To promote inclusive language,
use 'cluster_manager_timeout' instead): Operation timeout for connection
to master node.
use 'cluster_manager_timeout' instead.): Operation timeout for
connection to master node.
:arg timeout: Operation timeout.
"""
if index_uuid in SKIP_IN_PATH:
Expand All @@ -81,8 +81,8 @@ async def import_dangling_index(self, index_uuid, params=None, headers=None):
:arg cluster_manager_timeout: Operation timeout for connection
to cluster-manager node.
:arg master_timeout (Deprecated: To promote inclusive language,
use 'cluster_manager_timeout' instead): Operation timeout for connection
to master node.
use 'cluster_manager_timeout' instead.): Operation timeout for
connection to master node.
:arg timeout: Operation timeout.
"""
if index_uuid in SKIP_IN_PATH:
Expand Down
Loading
Loading