Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit e345f66

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

19 files changed

+831
-110
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@4231dad](https://github.com/opensearch-project/opensearch-api-specification/commit/4231dad6981285890f406c99ef55fa54a17d8662)
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

+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

+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/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

‎opensearchpy/_async/plugins/sm.py

+346
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,346 @@
1+
# SPDX-License-Identifier: Apache-2.0
2+
#
3+
# The OpenSearch Contributors require contributions made to
4+
# this file be licensed under the Apache-2.0 license or a
5+
# compatible open source license.
6+
#
7+
# Modifications Copyright OpenSearch Contributors. See
8+
# GitHub history for details.
9+
10+
# ------------------------------------------------------------------------------------------
11+
# THIS CODE IS AUTOMATICALLY GENERATED AND MANUAL EDITS WILL BE LOST
12+
#
13+
# To contribute, kindly make modifications in the opensearch-py client generator
14+
# or in the OpenSearch API specification, and run `nox -rs generate`. See DEVELOPER_GUIDE.md
15+
# and https://github.com/opensearch-project/opensearch-api-specification for details.
16+
# -----------------------------------------------------------------------------------------+
17+
18+
19+
from typing import Any
20+
21+
from ..client.utils import SKIP_IN_PATH, NamespacedClient, _make_path, query_params
22+
23+
24+
class SmClient(NamespacedClient):
25+
@query_params("error_trace", "filter_path", "human", "pretty", "source")
26+
async def create_policy(
27+
self,
28+
policy_name: Any,
29+
body: Any = None,
30+
params: Any = None,
31+
headers: Any = None,
32+
) -> Any:
33+
"""
34+
Creates a snapshot management policy.
35+
36+
37+
:arg policy_name: The name of the snapshot management policy.
38+
:arg error_trace: Whether to include the stack trace of returned
39+
errors. Default is false.
40+
:arg filter_path: Used to reduce the response. This parameter
41+
takes a comma-separated list of filters. It supports using wildcards to
42+
match any field or part of a field’s name. You can also exclude fields
43+
with "-".
44+
:arg human: Whether to return human readable values for
45+
statistics. Default is True.
46+
:arg pretty: Whether to pretty format the returned JSON
47+
response. Default is false.
48+
:arg source: The URL-encoded request definition. Useful for
49+
libraries that do not accept a request body for non-POST requests.
50+
"""
51+
if policy_name in SKIP_IN_PATH:
52+
raise ValueError(
53+
"Empty value passed for a required argument 'policy_name'."
54+
)
55+
56+
return await self.transport.perform_request(
57+
"POST",
58+
_make_path("_plugins", "_sm", "policies", policy_name),
59+
params=params,
60+
headers=headers,
61+
body=body,
62+
)
63+
64+
@query_params("error_trace", "filter_path", "human", "pretty", "source")
65+
async def delete_policy(
66+
self,
67+
policy_name: Any,
68+
params: Any = None,
69+
headers: Any = None,
70+
) -> Any:
71+
"""
72+
Deletes a snapshot management policy.
73+
74+
75+
:arg policy_name: The name of the snapshot management policy.
76+
:arg error_trace: Whether to include the stack trace of returned
77+
errors. Default is false.
78+
:arg filter_path: Used to reduce the response. This parameter
79+
takes a comma-separated list of filters. It supports using wildcards to
80+
match any field or part of a field’s name. You can also exclude fields
81+
with "-".
82+
:arg human: Whether to return human readable values for
83+
statistics. Default is True.
84+
:arg pretty: Whether to pretty format the returned JSON
85+
response. Default is false.
86+
:arg source: The URL-encoded request definition. Useful for
87+
libraries that do not accept a request body for non-POST requests.
88+
"""
89+
if policy_name in SKIP_IN_PATH:
90+
raise ValueError(
91+
"Empty value passed for a required argument 'policy_name'."
92+
)
93+
94+
return await self.transport.perform_request(
95+
"DELETE",
96+
_make_path("_plugins", "_sm", "policies", policy_name),
97+
params=params,
98+
headers=headers,
99+
)
100+
101+
@query_params("error_trace", "filter_path", "human", "pretty", "source")
102+
async def explain_policy(
103+
self,
104+
policy_name: Any,
105+
params: Any = None,
106+
headers: Any = None,
107+
) -> Any:
108+
"""
109+
Explains the state of the snapshot management policy.
110+
111+
112+
:arg policy_name: The name of the snapshot management policy.
113+
:arg error_trace: Whether to include the stack trace of returned
114+
errors. Default is false.
115+
:arg filter_path: Used to reduce the response. This parameter
116+
takes a comma-separated list of filters. It supports using wildcards to
117+
match any field or part of a field’s name. You can also exclude fields
118+
with "-".
119+
:arg human: Whether to return human readable values for
120+
statistics. Default is True.
121+
:arg pretty: Whether to pretty format the returned JSON
122+
response. Default is false.
123+
:arg source: The URL-encoded request definition. Useful for
124+
libraries that do not accept a request body for non-POST requests.
125+
"""
126+
if policy_name in SKIP_IN_PATH:
127+
raise ValueError(
128+
"Empty value passed for a required argument 'policy_name'."
129+
)
130+
131+
return await self.transport.perform_request(
132+
"GET",
133+
_make_path("_plugins", "_sm", "policies", policy_name, "_explain"),
134+
params=params,
135+
headers=headers,
136+
)
137+
138+
@query_params(
139+
"error_trace",
140+
"filter_path",
141+
"from_",
142+
"human",
143+
"pretty",
144+
"queryString",
145+
"size",
146+
"sortField",
147+
"sortOrder",
148+
"source",
149+
)
150+
async def get_policies(
151+
self,
152+
params: Any = None,
153+
headers: Any = None,
154+
) -> Any:
155+
"""
156+
Retrieves all snapshot management policies with optional pagination and
157+
filtering.
158+
159+
160+
:arg error_trace: Whether to include the stack trace of returned
161+
errors. Default is false.
162+
:arg filter_path: Used to reduce the response. This parameter
163+
takes a comma-separated list of filters. It supports using wildcards to
164+
match any field or part of a field’s name. You can also exclude fields
165+
with "-".
166+
:arg from_: The starting index (default: 0)
167+
:arg human: Whether to return human readable values for
168+
statistics. Default is True.
169+
:arg pretty: Whether to pretty format the returned JSON
170+
response. Default is false.
171+
:arg queryString: A query string to filter policies.
172+
:arg size: The number of policies to return.
173+
:arg sortField: The field to sort on.
174+
:arg sortOrder: The order of sorting. Valid choices are asc,
175+
desc.Default is asc.
176+
:arg source: The URL-encoded request definition. Useful for
177+
libraries that do not accept a request body for non-POST requests.
178+
"""
179+
# from is a reserved word so it cannot be used, use from_ instead
180+
if "from_" in params:
181+
params["from"] = params.pop("from_")
182+
183+
return await self.transport.perform_request(
184+
"GET", "/_plugins/_sm/policies", params=params, headers=headers
185+
)
186+
187+
@query_params("error_trace", "filter_path", "human", "pretty", "source")
188+
async def get_policy(
189+
self,
190+
policy_name: Any,
191+
params: Any = None,
192+
headers: Any = None,
193+
) -> Any:
194+
"""
195+
Retrieves a specific snapshot management policy by name.
196+
197+
198+
:arg policy_name: The name of the snapshot management policy.
199+
:arg error_trace: Whether to include the stack trace of returned
200+
errors. Default is false.
201+
:arg filter_path: Used to reduce the response. This parameter
202+
takes a comma-separated list of filters. It supports using wildcards to
203+
match any field or part of a field’s name. You can also exclude fields
204+
with "-".
205+
:arg human: Whether to return human readable values for
206+
statistics. Default is True.
207+
:arg pretty: Whether to pretty format the returned JSON
208+
response. Default is false.
209+
:arg source: The URL-encoded request definition. Useful for
210+
libraries that do not accept a request body for non-POST requests.
211+
"""
212+
if policy_name in SKIP_IN_PATH:
213+
raise ValueError(
214+
"Empty value passed for a required argument 'policy_name'."
215+
)
216+
217+
return await self.transport.perform_request(
218+
"GET",
219+
_make_path("_plugins", "_sm", "policies", policy_name),
220+
params=params,
221+
headers=headers,
222+
)
223+
224+
@query_params("error_trace", "filter_path", "human", "pretty", "source")
225+
async def start_policy(
226+
self,
227+
policy_name: Any,
228+
params: Any = None,
229+
headers: Any = None,
230+
) -> Any:
231+
"""
232+
Starts a snapshot management policy.
233+
234+
235+
:arg policy_name: The name of the snapshot management policy.
236+
:arg error_trace: Whether to include the stack trace of returned
237+
errors. Default is false.
238+
:arg filter_path: Used to reduce the response. This parameter
239+
takes a comma-separated list of filters. It supports using wildcards to
240+
match any field or part of a field’s name. You can also exclude fields
241+
with "-".
242+
:arg human: Whether to return human readable values for
243+
statistics. Default is True.
244+
:arg pretty: Whether to pretty format the returned JSON
245+
response. Default is false.
246+
:arg source: The URL-encoded request definition. Useful for
247+
libraries that do not accept a request body for non-POST requests.
248+
"""
249+
if policy_name in SKIP_IN_PATH:
250+
raise ValueError(
251+
"Empty value passed for a required argument 'policy_name'."
252+
)
253+
254+
return await self.transport.perform_request(
255+
"POST",
256+
_make_path("_plugins", "_sm", "policies", policy_name, "_start"),
257+
params=params,
258+
headers=headers,
259+
)
260+
261+
@query_params("error_trace", "filter_path", "human", "pretty", "source")
262+
async def stop_policy(
263+
self,
264+
policy_name: Any,
265+
params: Any = None,
266+
headers: Any = None,
267+
) -> Any:
268+
"""
269+
Stops a snapshot management policy.
270+
271+
272+
:arg policy_name: The name of the snapshot management policy.
273+
:arg error_trace: Whether to include the stack trace of returned
274+
errors. Default is false.
275+
:arg filter_path: Used to reduce the response. This parameter
276+
takes a comma-separated list of filters. It supports using wildcards to
277+
match any field or part of a field’s name. You can also exclude fields
278+
with "-".
279+
:arg human: Whether to return human readable values for
280+
statistics. Default is True.
281+
:arg pretty: Whether to pretty format the returned JSON
282+
response. Default is false.
283+
:arg source: The URL-encoded request definition. Useful for
284+
libraries that do not accept a request body for non-POST requests.
285+
"""
286+
if policy_name in SKIP_IN_PATH:
287+
raise ValueError(
288+
"Empty value passed for a required argument 'policy_name'."
289+
)
290+
291+
return await self.transport.perform_request(
292+
"POST",
293+
_make_path("_plugins", "_sm", "policies", policy_name, "_stop"),
294+
params=params,
295+
headers=headers,
296+
)
297+
298+
@query_params(
299+
"error_trace",
300+
"filter_path",
301+
"human",
302+
"if_primary_term",
303+
"if_seq_no",
304+
"pretty",
305+
"source",
306+
)
307+
async def update_policy(
308+
self,
309+
policy_name: Any,
310+
body: Any = None,
311+
params: Any = None,
312+
headers: Any = None,
313+
) -> Any:
314+
"""
315+
Updates an existing snapshot management policy. Requires `if_seq_no` and
316+
`if_primary_term`.
317+
318+
319+
:arg policy_name: The name of the snapshot management policy.
320+
:arg error_trace: Whether to include the stack trace of returned
321+
errors. Default is false.
322+
:arg filter_path: Used to reduce the response. This parameter
323+
takes a comma-separated list of filters. It supports using wildcards to
324+
match any field or part of a field’s name. You can also exclude fields
325+
with "-".
326+
:arg human: Whether to return human readable values for
327+
statistics. Default is True.
328+
:arg if_primary_term: The primary term of the policy to update.
329+
:arg if_seq_no: The sequence number of the policy to update.
330+
:arg pretty: Whether to pretty format the returned JSON
331+
response. Default is false.
332+
:arg source: The URL-encoded request definition. Useful for
333+
libraries that do not accept a request body for non-POST requests.
334+
"""
335+
if policy_name in SKIP_IN_PATH:
336+
raise ValueError(
337+
"Empty value passed for a required argument 'policy_name'."
338+
)
339+
340+
return await self.transport.perform_request(
341+
"PUT",
342+
_make_path("_plugins", "_sm", "policies", policy_name),
343+
params=params,
344+
headers=headers,
345+
body=body,
346+
)

‎opensearchpy/client/__init__.py

+15-9
Original file line numberDiff line numberDiff line change
@@ -667,7 +667,7 @@ 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 @@ 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 @@ 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 @@ 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 @@ 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 @@ 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 @@ def search(
24512449
)
24522450
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 @@ 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 @@ def search_shards(
24952497
libraries that do not accept a request body for non-POST requests.
24962498
"""
24972499
return 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 @@ 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/client/cat.py

+39-36
Original file line numberDiff line numberDiff line change
@@ -70,27 +70,29 @@ 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 self.transport.perform_request(
9698
"GET", _make_path("_cat", "aliases", name), params=params, headers=headers
@@ -171,36 +173,37 @@ 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 self.transport.perform_request(
206209
"GET",
@@ -233,32 +236,33 @@ 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 self.transport.perform_request(
264268
"GET", "/_cat/cluster_manager", params=params, headers=headers
@@ -498,8 +502,7 @@ 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/client/cluster.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ 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 self.transport.perform_request(
133133
"GET",

‎opensearchpy/client/indices.py

+7-2
Original file line numberDiff line numberDiff line change
@@ -1638,7 +1638,7 @@ 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 @@ def recovery(
17971797
)
17981798
def upgrade(
17991799
self,
1800+
body: Any = None,
18001801
index: Any = None,
18011802
params: Any = None,
18021803
headers: Any = None,
@@ -1832,7 +1833,11 @@ def upgrade(
18321833
operation has completed before returning. Default is false.
18331834
"""
18341835
return 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/client/list.py

+1-2
Original file line numberDiff line numberDiff line change
@@ -103,8 +103,7 @@ 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/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/plugins/knn.py

+1-4
Original file line numberDiff line numberDiff line change
@@ -310,7 +310,7 @@ def stats(
310310
)
311311
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 @@ 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 self.transport.perform_request(
342339
"POST",
343340
_make_path("_plugins", "_knn", "models", model_id, "_train"),

‎opensearchpy/plugins/observability.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ 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

‎opensearchpy/plugins/sm.py

+346
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,346 @@
1+
# SPDX-License-Identifier: Apache-2.0
2+
#
3+
# The OpenSearch Contributors require contributions made to
4+
# this file be licensed under the Apache-2.0 license or a
5+
# compatible open source license.
6+
#
7+
# Modifications Copyright OpenSearch Contributors. See
8+
# GitHub history for details.
9+
10+
# ------------------------------------------------------------------------------------------
11+
# THIS CODE IS AUTOMATICALLY GENERATED AND MANUAL EDITS WILL BE LOST
12+
#
13+
# To contribute, kindly make modifications in the opensearch-py client generator
14+
# or in the OpenSearch API specification, and run `nox -rs generate`. See DEVELOPER_GUIDE.md
15+
# and https://github.com/opensearch-project/opensearch-api-specification for details.
16+
# -----------------------------------------------------------------------------------------+
17+
18+
19+
from typing import Any
20+
21+
from ..client.utils import SKIP_IN_PATH, NamespacedClient, _make_path, query_params
22+
23+
24+
class SmClient(NamespacedClient):
25+
@query_params("error_trace", "filter_path", "human", "pretty", "source")
26+
def create_policy(
27+
self,
28+
policy_name: Any,
29+
body: Any = None,
30+
params: Any = None,
31+
headers: Any = None,
32+
) -> Any:
33+
"""
34+
Creates a snapshot management policy.
35+
36+
37+
:arg policy_name: The name of the snapshot management policy.
38+
:arg error_trace: Whether to include the stack trace of returned
39+
errors. Default is false.
40+
:arg filter_path: Used to reduce the response. This parameter
41+
takes a comma-separated list of filters. It supports using wildcards to
42+
match any field or part of a field’s name. You can also exclude fields
43+
with "-".
44+
:arg human: Whether to return human readable values for
45+
statistics. Default is True.
46+
:arg pretty: Whether to pretty format the returned JSON
47+
response. Default is false.
48+
:arg source: The URL-encoded request definition. Useful for
49+
libraries that do not accept a request body for non-POST requests.
50+
"""
51+
if policy_name in SKIP_IN_PATH:
52+
raise ValueError(
53+
"Empty value passed for a required argument 'policy_name'."
54+
)
55+
56+
return self.transport.perform_request(
57+
"POST",
58+
_make_path("_plugins", "_sm", "policies", policy_name),
59+
params=params,
60+
headers=headers,
61+
body=body,
62+
)
63+
64+
@query_params("error_trace", "filter_path", "human", "pretty", "source")
65+
def delete_policy(
66+
self,
67+
policy_name: Any,
68+
params: Any = None,
69+
headers: Any = None,
70+
) -> Any:
71+
"""
72+
Deletes a snapshot management policy.
73+
74+
75+
:arg policy_name: The name of the snapshot management policy.
76+
:arg error_trace: Whether to include the stack trace of returned
77+
errors. Default is false.
78+
:arg filter_path: Used to reduce the response. This parameter
79+
takes a comma-separated list of filters. It supports using wildcards to
80+
match any field or part of a field’s name. You can also exclude fields
81+
with "-".
82+
:arg human: Whether to return human readable values for
83+
statistics. Default is True.
84+
:arg pretty: Whether to pretty format the returned JSON
85+
response. Default is false.
86+
:arg source: The URL-encoded request definition. Useful for
87+
libraries that do not accept a request body for non-POST requests.
88+
"""
89+
if policy_name in SKIP_IN_PATH:
90+
raise ValueError(
91+
"Empty value passed for a required argument 'policy_name'."
92+
)
93+
94+
return self.transport.perform_request(
95+
"DELETE",
96+
_make_path("_plugins", "_sm", "policies", policy_name),
97+
params=params,
98+
headers=headers,
99+
)
100+
101+
@query_params("error_trace", "filter_path", "human", "pretty", "source")
102+
def explain_policy(
103+
self,
104+
policy_name: Any,
105+
params: Any = None,
106+
headers: Any = None,
107+
) -> Any:
108+
"""
109+
Explains the state of the snapshot management policy.
110+
111+
112+
:arg policy_name: The name of the snapshot management policy.
113+
:arg error_trace: Whether to include the stack trace of returned
114+
errors. Default is false.
115+
:arg filter_path: Used to reduce the response. This parameter
116+
takes a comma-separated list of filters. It supports using wildcards to
117+
match any field or part of a field’s name. You can also exclude fields
118+
with "-".
119+
:arg human: Whether to return human readable values for
120+
statistics. Default is True.
121+
:arg pretty: Whether to pretty format the returned JSON
122+
response. Default is false.
123+
:arg source: The URL-encoded request definition. Useful for
124+
libraries that do not accept a request body for non-POST requests.
125+
"""
126+
if policy_name in SKIP_IN_PATH:
127+
raise ValueError(
128+
"Empty value passed for a required argument 'policy_name'."
129+
)
130+
131+
return self.transport.perform_request(
132+
"GET",
133+
_make_path("_plugins", "_sm", "policies", policy_name, "_explain"),
134+
params=params,
135+
headers=headers,
136+
)
137+
138+
@query_params(
139+
"error_trace",
140+
"filter_path",
141+
"from_",
142+
"human",
143+
"pretty",
144+
"queryString",
145+
"size",
146+
"sortField",
147+
"sortOrder",
148+
"source",
149+
)
150+
def get_policies(
151+
self,
152+
params: Any = None,
153+
headers: Any = None,
154+
) -> Any:
155+
"""
156+
Retrieves all snapshot management policies with optional pagination and
157+
filtering.
158+
159+
160+
:arg error_trace: Whether to include the stack trace of returned
161+
errors. Default is false.
162+
:arg filter_path: Used to reduce the response. This parameter
163+
takes a comma-separated list of filters. It supports using wildcards to
164+
match any field or part of a field’s name. You can also exclude fields
165+
with "-".
166+
:arg from_: The starting index (default: 0)
167+
:arg human: Whether to return human readable values for
168+
statistics. Default is True.
169+
:arg pretty: Whether to pretty format the returned JSON
170+
response. Default is false.
171+
:arg queryString: A query string to filter policies.
172+
:arg size: The number of policies to return.
173+
:arg sortField: The field to sort on.
174+
:arg sortOrder: The order of sorting. Valid choices are asc,
175+
desc.Default is asc.
176+
:arg source: The URL-encoded request definition. Useful for
177+
libraries that do not accept a request body for non-POST requests.
178+
"""
179+
# from is a reserved word so it cannot be used, use from_ instead
180+
if "from_" in params:
181+
params["from"] = params.pop("from_")
182+
183+
return self.transport.perform_request(
184+
"GET", "/_plugins/_sm/policies", params=params, headers=headers
185+
)
186+
187+
@query_params("error_trace", "filter_path", "human", "pretty", "source")
188+
def get_policy(
189+
self,
190+
policy_name: Any,
191+
params: Any = None,
192+
headers: Any = None,
193+
) -> Any:
194+
"""
195+
Retrieves a specific snapshot management policy by name.
196+
197+
198+
:arg policy_name: The name of the snapshot management policy.
199+
:arg error_trace: Whether to include the stack trace of returned
200+
errors. Default is false.
201+
:arg filter_path: Used to reduce the response. This parameter
202+
takes a comma-separated list of filters. It supports using wildcards to
203+
match any field or part of a field’s name. You can also exclude fields
204+
with "-".
205+
:arg human: Whether to return human readable values for
206+
statistics. Default is True.
207+
:arg pretty: Whether to pretty format the returned JSON
208+
response. Default is false.
209+
:arg source: The URL-encoded request definition. Useful for
210+
libraries that do not accept a request body for non-POST requests.
211+
"""
212+
if policy_name in SKIP_IN_PATH:
213+
raise ValueError(
214+
"Empty value passed for a required argument 'policy_name'."
215+
)
216+
217+
return self.transport.perform_request(
218+
"GET",
219+
_make_path("_plugins", "_sm", "policies", policy_name),
220+
params=params,
221+
headers=headers,
222+
)
223+
224+
@query_params("error_trace", "filter_path", "human", "pretty", "source")
225+
def start_policy(
226+
self,
227+
policy_name: Any,
228+
params: Any = None,
229+
headers: Any = None,
230+
) -> Any:
231+
"""
232+
Starts a snapshot management policy.
233+
234+
235+
:arg policy_name: The name of the snapshot management policy.
236+
:arg error_trace: Whether to include the stack trace of returned
237+
errors. Default is false.
238+
:arg filter_path: Used to reduce the response. This parameter
239+
takes a comma-separated list of filters. It supports using wildcards to
240+
match any field or part of a field’s name. You can also exclude fields
241+
with "-".
242+
:arg human: Whether to return human readable values for
243+
statistics. Default is True.
244+
:arg pretty: Whether to pretty format the returned JSON
245+
response. Default is false.
246+
:arg source: The URL-encoded request definition. Useful for
247+
libraries that do not accept a request body for non-POST requests.
248+
"""
249+
if policy_name in SKIP_IN_PATH:
250+
raise ValueError(
251+
"Empty value passed for a required argument 'policy_name'."
252+
)
253+
254+
return self.transport.perform_request(
255+
"POST",
256+
_make_path("_plugins", "_sm", "policies", policy_name, "_start"),
257+
params=params,
258+
headers=headers,
259+
)
260+
261+
@query_params("error_trace", "filter_path", "human", "pretty", "source")
262+
def stop_policy(
263+
self,
264+
policy_name: Any,
265+
params: Any = None,
266+
headers: Any = None,
267+
) -> Any:
268+
"""
269+
Stops a snapshot management policy.
270+
271+
272+
:arg policy_name: The name of the snapshot management policy.
273+
:arg error_trace: Whether to include the stack trace of returned
274+
errors. Default is false.
275+
:arg filter_path: Used to reduce the response. This parameter
276+
takes a comma-separated list of filters. It supports using wildcards to
277+
match any field or part of a field’s name. You can also exclude fields
278+
with "-".
279+
:arg human: Whether to return human readable values for
280+
statistics. Default is True.
281+
:arg pretty: Whether to pretty format the returned JSON
282+
response. Default is false.
283+
:arg source: The URL-encoded request definition. Useful for
284+
libraries that do not accept a request body for non-POST requests.
285+
"""
286+
if policy_name in SKIP_IN_PATH:
287+
raise ValueError(
288+
"Empty value passed for a required argument 'policy_name'."
289+
)
290+
291+
return self.transport.perform_request(
292+
"POST",
293+
_make_path("_plugins", "_sm", "policies", policy_name, "_stop"),
294+
params=params,
295+
headers=headers,
296+
)
297+
298+
@query_params(
299+
"error_trace",
300+
"filter_path",
301+
"human",
302+
"if_primary_term",
303+
"if_seq_no",
304+
"pretty",
305+
"source",
306+
)
307+
def update_policy(
308+
self,
309+
policy_name: Any,
310+
body: Any = None,
311+
params: Any = None,
312+
headers: Any = None,
313+
) -> Any:
314+
"""
315+
Updates an existing snapshot management policy. Requires `if_seq_no` and
316+
`if_primary_term`.
317+
318+
319+
:arg policy_name: The name of the snapshot management policy.
320+
:arg error_trace: Whether to include the stack trace of returned
321+
errors. Default is false.
322+
:arg filter_path: Used to reduce the response. This parameter
323+
takes a comma-separated list of filters. It supports using wildcards to
324+
match any field or part of a field’s name. You can also exclude fields
325+
with "-".
326+
:arg human: Whether to return human readable values for
327+
statistics. Default is True.
328+
:arg if_primary_term: The primary term of the policy to update.
329+
:arg if_seq_no: The sequence number of the policy to update.
330+
:arg pretty: Whether to pretty format the returned JSON
331+
response. Default is false.
332+
:arg source: The URL-encoded request definition. Useful for
333+
libraries that do not accept a request body for non-POST requests.
334+
"""
335+
if policy_name in SKIP_IN_PATH:
336+
raise ValueError(
337+
"Empty value passed for a required argument 'policy_name'."
338+
)
339+
340+
return self.transport.perform_request(
341+
"PUT",
342+
_make_path("_plugins", "_sm", "policies", policy_name),
343+
params=params,
344+
headers=headers,
345+
body=body,
346+
)

0 commit comments

Comments
 (0)
Please sign in to comment.