Skip to content

Commit b91acd8

Browse files
authored
Update API to main
1 parent 9dc583f commit b91acd8

File tree

8 files changed

+148
-12
lines changed

8 files changed

+148
-12
lines changed

elasticsearch/_async/client/__init__.py

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1149,7 +1149,7 @@ async def delete_by_query(
11491149
t.Union["t.Literal['dfs_query_then_fetch', 'query_then_fetch']", str]
11501150
] = None,
11511151
slice: t.Optional[t.Mapping[str, t.Any]] = None,
1152-
slices: t.Optional[int] = None,
1152+
slices: t.Optional[t.Union[int, t.Union["t.Literal['auto']", str]]] = None,
11531153
sort: t.Optional[t.Union[t.List[str], t.Tuple[str, ...]]] = None,
11541154
stats: t.Optional[t.Union[t.List[str], t.Tuple[str, ...]]] = None,
11551155
terminate_after: t.Optional[int] = None,
@@ -2529,6 +2529,7 @@ async def msearch(
25292529
pre_filter_shard_size: t.Optional[int] = None,
25302530
pretty: t.Optional[bool] = None,
25312531
rest_total_hits_as_int: t.Optional[bool] = None,
2532+
routing: t.Optional[str] = None,
25322533
search_type: t.Optional[
25332534
t.Union["t.Literal['dfs_query_then_fetch', 'query_then_fetch']", str]
25342535
] = None,
@@ -2568,6 +2569,8 @@ async def msearch(
25682569
filters are mandatory to match but the shard bounds and the query are disjoint.
25692570
:param rest_total_hits_as_int: If true, hits.total are returned as an integer
25702571
in the response. Defaults to false, which returns an object.
2572+
:param routing: Custom routing value used to route search operations to a specific
2573+
shard.
25712574
:param search_type: Indicates whether global term and document frequencies should
25722575
be used when scoring returned documents.
25732576
:param typed_keys: Specifies whether aggregation and suggester names should be
@@ -2606,6 +2609,8 @@ async def msearch(
26062609
__query["pretty"] = pretty
26072610
if rest_total_hits_as_int is not None:
26082611
__query["rest_total_hits_as_int"] = rest_total_hits_as_int
2612+
if routing is not None:
2613+
__query["routing"] = routing
26092614
if search_type is not None:
26102615
__query["search_type"] = search_type
26112616
if typed_keys is not None:
@@ -3036,7 +3041,7 @@ async def reindex(
30363041
script: t.Optional[t.Mapping[str, t.Any]] = None,
30373042
scroll: t.Optional[t.Union[int, str]] = None,
30383043
size: t.Optional[int] = None,
3039-
slices: t.Optional[int] = None,
3044+
slices: t.Optional[t.Union[int, t.Union["t.Literal['auto']", str]]] = None,
30403045
timeout: t.Optional[t.Union[int, str]] = None,
30413046
wait_for_active_shards: t.Optional[
30423047
t.Union[int, t.Union["t.Literal['all', 'index-setting']", str]]
@@ -4530,7 +4535,7 @@ async def update_by_query(
45304535
t.Union["t.Literal['dfs_query_then_fetch', 'query_then_fetch']", str]
45314536
] = None,
45324537
slice: t.Optional[t.Mapping[str, t.Any]] = None,
4533-
slices: t.Optional[int] = None,
4538+
slices: t.Optional[t.Union[int, t.Union["t.Literal['auto']", str]]] = None,
45344539
sort: t.Optional[t.Union[t.List[str], t.Tuple[str, ...]]] = None,
45354540
stats: t.Optional[t.Union[t.List[str], t.Tuple[str, ...]]] = None,
45364541
terminate_after: t.Optional[int] = None,

elasticsearch/_async/client/ingest.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -189,6 +189,7 @@ async def put_pipeline(
189189
t.Union[str, t.Union[t.List[str], t.Tuple[str, ...]]]
190190
] = None,
191191
human: t.Optional[bool] = None,
192+
if_version: t.Optional[int] = None,
192193
master_timeout: t.Optional[t.Union[int, str]] = None,
193194
meta: t.Optional[t.Mapping[str, t.Any]] = None,
194195
on_failure: t.Optional[
@@ -208,6 +209,8 @@ async def put_pipeline(
208209
209210
:param id: ID of the ingest pipeline to create or update.
210211
:param description: Description of the ingest pipeline.
212+
:param if_version: Required version for optimistic concurrency control for pipeline
213+
updates
211214
:param master_timeout: Period to wait for a connection to the master node. If
212215
no response is received before the timeout expires, the request fails and
213216
returns an error.
@@ -240,6 +243,8 @@ async def put_pipeline(
240243
__query["filter_path"] = filter_path
241244
if human is not None:
242245
__query["human"] = human
246+
if if_version is not None:
247+
__query["if_version"] = if_version
243248
if master_timeout is not None:
244249
__query["master_timeout"] = master_timeout
245250
if meta is not None:

elasticsearch/_async/client/ml.py

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1748,6 +1748,58 @@ async def get_memory_stats(
17481748
"GET", __path, params=__query, headers=__headers
17491749
)
17501750

1751+
@_rewrite_parameters()
1752+
async def get_model_snapshot_upgrade_stats(
1753+
self,
1754+
*,
1755+
job_id: str,
1756+
snapshot_id: t.Optional[str] = None,
1757+
allow_no_match: t.Optional[bool] = None,
1758+
error_trace: t.Optional[bool] = None,
1759+
filter_path: t.Optional[
1760+
t.Union[str, t.Union[t.List[str], t.Tuple[str, ...]]]
1761+
] = None,
1762+
human: t.Optional[bool] = None,
1763+
pretty: t.Optional[bool] = None,
1764+
) -> ObjectApiResponse[t.Any]:
1765+
"""
1766+
Gets stats for anomaly detection job model snapshot upgrades that are in progress.
1767+
1768+
`<https://www.elastic.co/guide/en/elasticsearch/reference/master/ml-get-job-model-snapshot-upgrade-stats.html>`_
1769+
1770+
:param job_id: Identifier for the anomaly detection job.
1771+
:param snapshot_id: A numerical character string that uniquely identifies the
1772+
model snapshot. You can get information for multiple snapshots by using a
1773+
comma-separated list or a wildcard expression. You can get all snapshots
1774+
by using `_all`, by specifying `*` as the snapshot ID, or by omitting the
1775+
snapshot ID.
1776+
:param allow_no_match: Specifies what to do when the request: - Contains wildcard
1777+
expressions and there are no jobs that match. - Contains the _all string
1778+
or no identifiers and there are no matches. - Contains wildcard expressions
1779+
and there are only partial matches. The default value is true, which returns
1780+
an empty jobs array when there are no matches and the subset of results when
1781+
there are partial matches. If this parameter is false, the request returns
1782+
a 404 status code when there are no matches or only partial matches.
1783+
"""
1784+
if job_id in SKIP_IN_PATH:
1785+
raise ValueError("Empty value passed for parameter 'job_id'")
1786+
__path = f"/_ml/anomaly_detectors/{_quote(job_id)}/model_snapshots/{_quote(snapshot_id)}/_upgrade/_stats"
1787+
__query: t.Dict[str, t.Any] = {}
1788+
if allow_no_match is not None:
1789+
__query["allow_no_match"] = allow_no_match
1790+
if error_trace is not None:
1791+
__query["error_trace"] = error_trace
1792+
if filter_path is not None:
1793+
__query["filter_path"] = filter_path
1794+
if human is not None:
1795+
__query["human"] = human
1796+
if pretty is not None:
1797+
__query["pretty"] = pretty
1798+
__headers = {"accept": "application/json"}
1799+
return await self.perform_request( # type: ignore[return-value]
1800+
"GET", __path, params=__query, headers=__headers
1801+
)
1802+
17511803
@_rewrite_parameters(
17521804
body_fields=True,
17531805
parameter_aliases={"from": "from_"},

elasticsearch/_async/client/security.py

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -438,13 +438,16 @@ async def create_service_token(
438438
*,
439439
namespace: str,
440440
service: str,
441-
name: str,
441+
name: t.Optional[str] = None,
442442
error_trace: t.Optional[bool] = None,
443443
filter_path: t.Optional[
444444
t.Union[str, t.Union[t.List[str], t.Tuple[str, ...]]]
445445
] = None,
446446
human: t.Optional[bool] = None,
447447
pretty: t.Optional[bool] = None,
448+
refresh: t.Optional[
449+
t.Union["t.Literal['false', 'true', 'wait_for']", bool, str]
450+
] = None,
448451
) -> ObjectApiResponse[t.Any]:
449452
"""
450453
Creates a service account token for access without requiring basic authentication.
@@ -454,13 +457,14 @@ async def create_service_token(
454457
:param namespace: An identifier for the namespace
455458
:param service: An identifier for the service name
456459
:param name: An identifier for the token name
460+
:param refresh: If `true` then refresh the affected shards to make this operation
461+
visible to search, if `wait_for` (the default) then wait for a refresh to
462+
make this operation visible to search, if `false` then do nothing with refreshes.
457463
"""
458464
if namespace in SKIP_IN_PATH:
459465
raise ValueError("Empty value passed for parameter 'namespace'")
460466
if service in SKIP_IN_PATH:
461467
raise ValueError("Empty value passed for parameter 'service'")
462-
if name in SKIP_IN_PATH:
463-
raise ValueError("Empty value passed for parameter 'name'")
464468
if (
465469
namespace not in SKIP_IN_PATH
466470
and service not in SKIP_IN_PATH
@@ -482,6 +486,8 @@ async def create_service_token(
482486
__query["human"] = human
483487
if pretty is not None:
484488
__query["pretty"] = pretty
489+
if refresh is not None:
490+
__query["refresh"] = refresh
485491
__headers = {"accept": "application/json"}
486492
return await self.perform_request( # type: ignore[return-value]
487493
__method, __path, params=__query, headers=__headers

elasticsearch/_sync/client/__init__.py

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1147,7 +1147,7 @@ def delete_by_query(
11471147
t.Union["t.Literal['dfs_query_then_fetch', 'query_then_fetch']", str]
11481148
] = None,
11491149
slice: t.Optional[t.Mapping[str, t.Any]] = None,
1150-
slices: t.Optional[int] = None,
1150+
slices: t.Optional[t.Union[int, t.Union["t.Literal['auto']", str]]] = None,
11511151
sort: t.Optional[t.Union[t.List[str], t.Tuple[str, ...]]] = None,
11521152
stats: t.Optional[t.Union[t.List[str], t.Tuple[str, ...]]] = None,
11531153
terminate_after: t.Optional[int] = None,
@@ -2527,6 +2527,7 @@ def msearch(
25272527
pre_filter_shard_size: t.Optional[int] = None,
25282528
pretty: t.Optional[bool] = None,
25292529
rest_total_hits_as_int: t.Optional[bool] = None,
2530+
routing: t.Optional[str] = None,
25302531
search_type: t.Optional[
25312532
t.Union["t.Literal['dfs_query_then_fetch', 'query_then_fetch']", str]
25322533
] = None,
@@ -2566,6 +2567,8 @@ def msearch(
25662567
filters are mandatory to match but the shard bounds and the query are disjoint.
25672568
:param rest_total_hits_as_int: If true, hits.total are returned as an integer
25682569
in the response. Defaults to false, which returns an object.
2570+
:param routing: Custom routing value used to route search operations to a specific
2571+
shard.
25692572
:param search_type: Indicates whether global term and document frequencies should
25702573
be used when scoring returned documents.
25712574
:param typed_keys: Specifies whether aggregation and suggester names should be
@@ -2604,6 +2607,8 @@ def msearch(
26042607
__query["pretty"] = pretty
26052608
if rest_total_hits_as_int is not None:
26062609
__query["rest_total_hits_as_int"] = rest_total_hits_as_int
2610+
if routing is not None:
2611+
__query["routing"] = routing
26072612
if search_type is not None:
26082613
__query["search_type"] = search_type
26092614
if typed_keys is not None:
@@ -3034,7 +3039,7 @@ def reindex(
30343039
script: t.Optional[t.Mapping[str, t.Any]] = None,
30353040
scroll: t.Optional[t.Union[int, str]] = None,
30363041
size: t.Optional[int] = None,
3037-
slices: t.Optional[int] = None,
3042+
slices: t.Optional[t.Union[int, t.Union["t.Literal['auto']", str]]] = None,
30383043
timeout: t.Optional[t.Union[int, str]] = None,
30393044
wait_for_active_shards: t.Optional[
30403045
t.Union[int, t.Union["t.Literal['all', 'index-setting']", str]]
@@ -4528,7 +4533,7 @@ def update_by_query(
45284533
t.Union["t.Literal['dfs_query_then_fetch', 'query_then_fetch']", str]
45294534
] = None,
45304535
slice: t.Optional[t.Mapping[str, t.Any]] = None,
4531-
slices: t.Optional[int] = None,
4536+
slices: t.Optional[t.Union[int, t.Union["t.Literal['auto']", str]]] = None,
45324537
sort: t.Optional[t.Union[t.List[str], t.Tuple[str, ...]]] = None,
45334538
stats: t.Optional[t.Union[t.List[str], t.Tuple[str, ...]]] = None,
45344539
terminate_after: t.Optional[int] = None,

elasticsearch/_sync/client/ingest.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -189,6 +189,7 @@ def put_pipeline(
189189
t.Union[str, t.Union[t.List[str], t.Tuple[str, ...]]]
190190
] = None,
191191
human: t.Optional[bool] = None,
192+
if_version: t.Optional[int] = None,
192193
master_timeout: t.Optional[t.Union[int, str]] = None,
193194
meta: t.Optional[t.Mapping[str, t.Any]] = None,
194195
on_failure: t.Optional[
@@ -208,6 +209,8 @@ def put_pipeline(
208209
209210
:param id: ID of the ingest pipeline to create or update.
210211
:param description: Description of the ingest pipeline.
212+
:param if_version: Required version for optimistic concurrency control for pipeline
213+
updates
211214
:param master_timeout: Period to wait for a connection to the master node. If
212215
no response is received before the timeout expires, the request fails and
213216
returns an error.
@@ -240,6 +243,8 @@ def put_pipeline(
240243
__query["filter_path"] = filter_path
241244
if human is not None:
242245
__query["human"] = human
246+
if if_version is not None:
247+
__query["if_version"] = if_version
243248
if master_timeout is not None:
244249
__query["master_timeout"] = master_timeout
245250
if meta is not None:

elasticsearch/_sync/client/ml.py

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1748,6 +1748,58 @@ def get_memory_stats(
17481748
"GET", __path, params=__query, headers=__headers
17491749
)
17501750

1751+
@_rewrite_parameters()
1752+
def get_model_snapshot_upgrade_stats(
1753+
self,
1754+
*,
1755+
job_id: str,
1756+
snapshot_id: t.Optional[str] = None,
1757+
allow_no_match: t.Optional[bool] = None,
1758+
error_trace: t.Optional[bool] = None,
1759+
filter_path: t.Optional[
1760+
t.Union[str, t.Union[t.List[str], t.Tuple[str, ...]]]
1761+
] = None,
1762+
human: t.Optional[bool] = None,
1763+
pretty: t.Optional[bool] = None,
1764+
) -> ObjectApiResponse[t.Any]:
1765+
"""
1766+
Gets stats for anomaly detection job model snapshot upgrades that are in progress.
1767+
1768+
`<https://www.elastic.co/guide/en/elasticsearch/reference/master/ml-get-job-model-snapshot-upgrade-stats.html>`_
1769+
1770+
:param job_id: Identifier for the anomaly detection job.
1771+
:param snapshot_id: A numerical character string that uniquely identifies the
1772+
model snapshot. You can get information for multiple snapshots by using a
1773+
comma-separated list or a wildcard expression. You can get all snapshots
1774+
by using `_all`, by specifying `*` as the snapshot ID, or by omitting the
1775+
snapshot ID.
1776+
:param allow_no_match: Specifies what to do when the request: - Contains wildcard
1777+
expressions and there are no jobs that match. - Contains the _all string
1778+
or no identifiers and there are no matches. - Contains wildcard expressions
1779+
and there are only partial matches. The default value is true, which returns
1780+
an empty jobs array when there are no matches and the subset of results when
1781+
there are partial matches. If this parameter is false, the request returns
1782+
a 404 status code when there are no matches or only partial matches.
1783+
"""
1784+
if job_id in SKIP_IN_PATH:
1785+
raise ValueError("Empty value passed for parameter 'job_id'")
1786+
__path = f"/_ml/anomaly_detectors/{_quote(job_id)}/model_snapshots/{_quote(snapshot_id)}/_upgrade/_stats"
1787+
__query: t.Dict[str, t.Any] = {}
1788+
if allow_no_match is not None:
1789+
__query["allow_no_match"] = allow_no_match
1790+
if error_trace is not None:
1791+
__query["error_trace"] = error_trace
1792+
if filter_path is not None:
1793+
__query["filter_path"] = filter_path
1794+
if human is not None:
1795+
__query["human"] = human
1796+
if pretty is not None:
1797+
__query["pretty"] = pretty
1798+
__headers = {"accept": "application/json"}
1799+
return self.perform_request( # type: ignore[return-value]
1800+
"GET", __path, params=__query, headers=__headers
1801+
)
1802+
17511803
@_rewrite_parameters(
17521804
body_fields=True,
17531805
parameter_aliases={"from": "from_"},

elasticsearch/_sync/client/security.py

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -438,13 +438,16 @@ def create_service_token(
438438
*,
439439
namespace: str,
440440
service: str,
441-
name: str,
441+
name: t.Optional[str] = None,
442442
error_trace: t.Optional[bool] = None,
443443
filter_path: t.Optional[
444444
t.Union[str, t.Union[t.List[str], t.Tuple[str, ...]]]
445445
] = None,
446446
human: t.Optional[bool] = None,
447447
pretty: t.Optional[bool] = None,
448+
refresh: t.Optional[
449+
t.Union["t.Literal['false', 'true', 'wait_for']", bool, str]
450+
] = None,
448451
) -> ObjectApiResponse[t.Any]:
449452
"""
450453
Creates a service account token for access without requiring basic authentication.
@@ -454,13 +457,14 @@ def create_service_token(
454457
:param namespace: An identifier for the namespace
455458
:param service: An identifier for the service name
456459
:param name: An identifier for the token name
460+
:param refresh: If `true` then refresh the affected shards to make this operation
461+
visible to search, if `wait_for` (the default) then wait for a refresh to
462+
make this operation visible to search, if `false` then do nothing with refreshes.
457463
"""
458464
if namespace in SKIP_IN_PATH:
459465
raise ValueError("Empty value passed for parameter 'namespace'")
460466
if service in SKIP_IN_PATH:
461467
raise ValueError("Empty value passed for parameter 'service'")
462-
if name in SKIP_IN_PATH:
463-
raise ValueError("Empty value passed for parameter 'name'")
464468
if (
465469
namespace not in SKIP_IN_PATH
466470
and service not in SKIP_IN_PATH
@@ -482,6 +486,8 @@ def create_service_token(
482486
__query["human"] = human
483487
if pretty is not None:
484488
__query["pretty"] = pretty
489+
if refresh is not None:
490+
__query["refresh"] = refresh
485491
__headers = {"accept": "application/json"}
486492
return self.perform_request( # type: ignore[return-value]
487493
__method, __path, params=__query, headers=__headers

0 commit comments

Comments
 (0)