|
| 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 | + ) |
0 commit comments