Skip to content

Commit ec12db4

Browse files
committed
Update generated code to allow using body for required parameters
1 parent cc3fcba commit ec12db4

30 files changed

+228
-216
lines changed

elasticsearch/_async/client/__init__.py

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -759,7 +759,7 @@ async def clear_scroll(
759759
async def close_point_in_time(
760760
self,
761761
*,
762-
id: str,
762+
id: t.Optional[str] = None,
763763
error_trace: t.Optional[bool] = None,
764764
filter_path: t.Optional[t.Union[str, t.Sequence[str]]] = None,
765765
human: t.Optional[bool] = None,
@@ -773,7 +773,7 @@ async def close_point_in_time(
773773
774774
:param id: The ID of the point-in-time.
775775
"""
776-
if id is None:
776+
if id is None and body is None:
777777
raise ValueError("Empty value passed for parameter 'id'")
778778
__path = "/_pit"
779779
__query: t.Dict[str, t.Any] = {}
@@ -2323,7 +2323,7 @@ async def knn_search(
23232323
self,
23242324
*,
23252325
index: t.Union[str, t.Sequence[str]],
2326-
knn: t.Mapping[str, t.Any],
2326+
knn: t.Optional[t.Mapping[str, t.Any]] = None,
23272327
docvalue_fields: t.Optional[t.Sequence[t.Mapping[str, t.Any]]] = None,
23282328
error_trace: t.Optional[bool] = None,
23292329
fields: t.Optional[t.Union[str, t.Sequence[str]]] = None,
@@ -2366,7 +2366,7 @@ async def knn_search(
23662366
"""
23672367
if index in SKIP_IN_PATH:
23682368
raise ValueError("Empty value passed for parameter 'index'")
2369-
if knn is None:
2369+
if knn is None and body is None:
23702370
raise ValueError("Empty value passed for parameter 'knn'")
23712371
__path = f"/{_quote(index)}/_knn_search"
23722372
__query: t.Dict[str, t.Any] = {}
@@ -2888,7 +2888,7 @@ async def put_script(
28882888
self,
28892889
*,
28902890
id: str,
2891-
script: t.Mapping[str, t.Any],
2891+
script: t.Optional[t.Mapping[str, t.Any]] = None,
28922892
context: t.Optional[str] = None,
28932893
error_trace: t.Optional[bool] = None,
28942894
filter_path: t.Optional[t.Union[str, t.Sequence[str]]] = None,
@@ -2920,7 +2920,7 @@ async def put_script(
29202920
"""
29212921
if id in SKIP_IN_PATH:
29222922
raise ValueError("Empty value passed for parameter 'id'")
2923-
if script is None:
2923+
if script is None and body is None:
29242924
raise ValueError("Empty value passed for parameter 'script'")
29252925
if id not in SKIP_IN_PATH and context not in SKIP_IN_PATH:
29262926
__path = f"/_scripts/{_quote(id)}/{_quote(context)}"
@@ -2956,7 +2956,7 @@ async def put_script(
29562956
async def rank_eval(
29572957
self,
29582958
*,
2959-
requests: t.Sequence[t.Mapping[str, t.Any]],
2959+
requests: t.Optional[t.Sequence[t.Mapping[str, t.Any]]] = None,
29602960
index: t.Optional[t.Union[str, t.Sequence[str]]] = None,
29612961
allow_no_indices: t.Optional[bool] = None,
29622962
error_trace: t.Optional[bool] = None,
@@ -3000,7 +3000,7 @@ async def rank_eval(
30003000
:param metric: Definition of the evaluation metric to calculate.
30013001
:param search_type: Search operation type
30023002
"""
3003-
if requests is None:
3003+
if requests is None and body is None:
30043004
raise ValueError("Empty value passed for parameter 'requests'")
30053005
if index not in SKIP_IN_PATH:
30063006
__path = f"/{_quote(index)}/_rank_eval"
@@ -3040,8 +3040,8 @@ async def rank_eval(
30403040
async def reindex(
30413041
self,
30423042
*,
3043-
dest: t.Mapping[str, t.Any],
3044-
source: t.Mapping[str, t.Any],
3043+
dest: t.Optional[t.Mapping[str, t.Any]] = None,
3044+
source: t.Optional[t.Mapping[str, t.Any]] = None,
30453045
conflicts: t.Optional[t.Union["t.Literal['abort', 'proceed']", str]] = None,
30463046
error_trace: t.Optional[bool] = None,
30473047
filter_path: t.Optional[t.Union[str, t.Sequence[str]]] = None,
@@ -3093,9 +3093,9 @@ async def reindex(
30933093
:param wait_for_completion: If `true`, the request blocks until the operation
30943094
is complete.
30953095
"""
3096-
if dest is None:
3096+
if dest is None and body is None:
30973097
raise ValueError("Empty value passed for parameter 'dest'")
3098-
if source is None:
3098+
if source is None and body is None:
30993099
raise ValueError("Empty value passed for parameter 'source'")
31003100
__path = "/_reindex"
31013101
__query: t.Dict[str, t.Any] = {}
@@ -3299,7 +3299,7 @@ async def scripts_painless_execute(
32993299
async def scroll(
33003300
self,
33013301
*,
3302-
scroll_id: str,
3302+
scroll_id: t.Optional[str] = None,
33033303
error_trace: t.Optional[bool] = None,
33043304
filter_path: t.Optional[t.Union[str, t.Sequence[str]]] = None,
33053305
human: t.Optional[bool] = None,
@@ -3319,7 +3319,7 @@ async def scroll(
33193319
is returned as an object.
33203320
:param scroll: Period to retain the search context for scrolling.
33213321
"""
3322-
if scroll_id is None:
3322+
if scroll_id is None and body is None:
33233323
raise ValueError("Empty value passed for parameter 'scroll_id'")
33243324
__path = "/_search/scroll"
33253325
__query: t.Dict[str, t.Any] = {}
@@ -4234,7 +4234,7 @@ async def terms_enum(
42344234
self,
42354235
*,
42364236
index: str,
4237-
field: str,
4237+
field: t.Optional[str] = None,
42384238
case_insensitive: t.Optional[bool] = None,
42394239
error_trace: t.Optional[bool] = None,
42404240
filter_path: t.Optional[t.Union[str, t.Sequence[str]]] = None,
@@ -4273,7 +4273,7 @@ async def terms_enum(
42734273
"""
42744274
if index in SKIP_IN_PATH:
42754275
raise ValueError("Empty value passed for parameter 'index'")
4276-
if field is None:
4276+
if field is None and body is None:
42774277
raise ValueError("Empty value passed for parameter 'field'")
42784278
__path = f"/{_quote(index)}/_terms_enum"
42794279
__query: t.Dict[str, t.Any] = {}

elasticsearch/_async/client/ccr.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -441,7 +441,7 @@ async def put_auto_follow_pattern(
441441
self,
442442
*,
443443
name: str,
444-
remote_cluster: str,
444+
remote_cluster: t.Optional[str] = None,
445445
error_trace: t.Optional[bool] = None,
446446
filter_path: t.Optional[t.Union[str, t.Sequence[str]]] = None,
447447
follow_index_pattern: t.Optional[str] = None,
@@ -518,7 +518,7 @@ async def put_auto_follow_pattern(
518518
"""
519519
if name in SKIP_IN_PATH:
520520
raise ValueError("Empty value passed for parameter 'name'")
521-
if remote_cluster is None:
521+
if remote_cluster is None and body is None:
522522
raise ValueError("Empty value passed for parameter 'remote_cluster'")
523523
__path = f"/_ccr/auto_follow/{_quote(name)}"
524524
__query: t.Dict[str, t.Any] = {}

elasticsearch/_async/client/cluster.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -602,7 +602,7 @@ async def put_component_template(
602602
self,
603603
*,
604604
name: str,
605-
template: t.Mapping[str, t.Any],
605+
template: t.Optional[t.Mapping[str, t.Any]] = None,
606606
allow_auto_create: t.Optional[bool] = None,
607607
create: t.Optional[bool] = None,
608608
error_trace: t.Optional[bool] = None,
@@ -652,7 +652,7 @@ async def put_component_template(
652652
"""
653653
if name in SKIP_IN_PATH:
654654
raise ValueError("Empty value passed for parameter 'name'")
655-
if template is None:
655+
if template is None and body is None:
656656
raise ValueError("Empty value passed for parameter 'template'")
657657
__path = f"/_component_template/{_quote(name)}"
658658
__query: t.Dict[str, t.Any] = {}

elasticsearch/_async/client/eql.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,7 @@ async def search(
166166
self,
167167
*,
168168
index: t.Union[str, t.Sequence[str]],
169-
query: str,
169+
query: t.Optional[str] = None,
170170
allow_no_indices: t.Optional[bool] = None,
171171
case_sensitive: t.Optional[bool] = None,
172172
error_trace: t.Optional[bool] = None,
@@ -235,7 +235,7 @@ async def search(
235235
"""
236236
if index in SKIP_IN_PATH:
237237
raise ValueError("Empty value passed for parameter 'index'")
238-
if query is None:
238+
if query is None and body is None:
239239
raise ValueError("Empty value passed for parameter 'query'")
240240
__path = f"/{_quote(index)}/_eql/search"
241241
__query: t.Dict[str, t.Any] = {}

elasticsearch/_async/client/indices.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2246,7 +2246,7 @@ async def migrate_to_data_stream(
22462246
async def modify_data_stream(
22472247
self,
22482248
*,
2249-
actions: t.Sequence[t.Mapping[str, t.Any]],
2249+
actions: t.Optional[t.Sequence[t.Mapping[str, t.Any]]] = None,
22502250
error_trace: t.Optional[bool] = None,
22512251
filter_path: t.Optional[t.Union[str, t.Sequence[str]]] = None,
22522252
human: t.Optional[bool] = None,
@@ -2260,7 +2260,7 @@ async def modify_data_stream(
22602260
22612261
:param actions: Actions to perform.
22622262
"""
2263-
if actions is None:
2263+
if actions is None and body is None:
22642264
raise ValueError("Empty value passed for parameter 'actions'")
22652265
__path = "/_data_stream/_modify"
22662266
__query: t.Dict[str, t.Any] = {}

elasticsearch/_async/client/ml.py

Lines changed: 26 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -695,8 +695,8 @@ async def estimate_model_memory(
695695
async def evaluate_data_frame(
696696
self,
697697
*,
698-
evaluation: t.Mapping[str, t.Any],
699-
index: str,
698+
evaluation: t.Optional[t.Mapping[str, t.Any]] = None,
699+
index: t.Optional[str] = None,
700700
error_trace: t.Optional[bool] = None,
701701
filter_path: t.Optional[t.Union[str, t.Sequence[str]]] = None,
702702
human: t.Optional[bool] = None,
@@ -714,9 +714,9 @@ async def evaluate_data_frame(
714714
:param query: A query clause that retrieves a subset of data from the source
715715
index.
716716
"""
717-
if evaluation is None:
717+
if evaluation is None and body is None:
718718
raise ValueError("Empty value passed for parameter 'evaluation'")
719-
if index is None:
719+
if index is None and body is None:
720720
raise ValueError("Empty value passed for parameter 'index'")
721721
__path = "/_ml/data_frame/_evaluate"
722722
__query: t.Dict[str, t.Any] = {}
@@ -2219,7 +2219,7 @@ async def infer_trained_model(
22192219
self,
22202220
*,
22212221
model_id: str,
2222-
docs: t.Sequence[t.Mapping[str, t.Any]],
2222+
docs: t.Optional[t.Sequence[t.Mapping[str, t.Any]]] = None,
22232223
error_trace: t.Optional[bool] = None,
22242224
filter_path: t.Optional[t.Union[str, t.Sequence[str]]] = None,
22252225
human: t.Optional[bool] = None,
@@ -2244,7 +2244,7 @@ async def infer_trained_model(
22442244
"""
22452245
if model_id in SKIP_IN_PATH:
22462246
raise ValueError("Empty value passed for parameter 'model_id'")
2247-
if docs is None:
2247+
if docs is None and body is None:
22482248
raise ValueError("Empty value passed for parameter 'docs'")
22492249
__path = f"/_ml/trained_models/{_quote(model_id)}/_infer"
22502250
__query: t.Dict[str, t.Any] = {}
@@ -2352,7 +2352,7 @@ async def post_calendar_events(
23522352
self,
23532353
*,
23542354
calendar_id: str,
2355-
events: t.Sequence[t.Mapping[str, t.Any]],
2355+
events: t.Optional[t.Sequence[t.Mapping[str, t.Any]]] = None,
23562356
error_trace: t.Optional[bool] = None,
23572357
filter_path: t.Optional[t.Union[str, t.Sequence[str]]] = None,
23582358
human: t.Optional[bool] = None,
@@ -2371,7 +2371,7 @@ async def post_calendar_events(
23712371
"""
23722372
if calendar_id in SKIP_IN_PATH:
23732373
raise ValueError("Empty value passed for parameter 'calendar_id'")
2374-
if events is None:
2374+
if events is None and body is None:
23752375
raise ValueError("Empty value passed for parameter 'events'")
23762376
__path = f"/_ml/calendars/{_quote(calendar_id)}/events"
23772377
__query: t.Dict[str, t.Any] = {}
@@ -2678,9 +2678,9 @@ async def put_data_frame_analytics(
26782678
self,
26792679
*,
26802680
id: str,
2681-
analysis: t.Mapping[str, t.Any],
2682-
dest: t.Mapping[str, t.Any],
2683-
source: t.Mapping[str, t.Any],
2681+
analysis: t.Optional[t.Mapping[str, t.Any]] = None,
2682+
dest: t.Optional[t.Mapping[str, t.Any]] = None,
2683+
source: t.Optional[t.Mapping[str, t.Any]] = None,
26842684
allow_lazy_start: t.Optional[bool] = None,
26852685
analyzed_fields: t.Optional[t.Mapping[str, t.Any]] = None,
26862686
description: t.Optional[str] = None,
@@ -2756,11 +2756,11 @@ async def put_data_frame_analytics(
27562756
"""
27572757
if id in SKIP_IN_PATH:
27582758
raise ValueError("Empty value passed for parameter 'id'")
2759-
if analysis is None:
2759+
if analysis is None and body is None:
27602760
raise ValueError("Empty value passed for parameter 'analysis'")
2761-
if dest is None:
2761+
if dest is None and body is None:
27622762
raise ValueError("Empty value passed for parameter 'dest'")
2763-
if source is None:
2763+
if source is None and body is None:
27642764
raise ValueError("Empty value passed for parameter 'source'")
27652765
__path = f"/_ml/data_frame/analytics/{_quote(id)}"
27662766
__query: t.Dict[str, t.Any] = {}
@@ -3057,8 +3057,8 @@ async def put_job(
30573057
self,
30583058
*,
30593059
job_id: str,
3060-
analysis_config: t.Mapping[str, t.Any],
3061-
data_description: t.Mapping[str, t.Any],
3060+
analysis_config: t.Optional[t.Mapping[str, t.Any]] = None,
3061+
data_description: t.Optional[t.Mapping[str, t.Any]] = None,
30623062
allow_lazy_open: t.Optional[bool] = None,
30633063
analysis_limits: t.Optional[t.Mapping[str, t.Any]] = None,
30643064
background_persist_interval: t.Optional[
@@ -3160,9 +3160,9 @@ async def put_job(
31603160
"""
31613161
if job_id in SKIP_IN_PATH:
31623162
raise ValueError("Empty value passed for parameter 'job_id'")
3163-
if analysis_config is None:
3163+
if analysis_config is None and body is None:
31643164
raise ValueError("Empty value passed for parameter 'analysis_config'")
3165-
if data_description is None:
3165+
if data_description is None and body is None:
31663166
raise ValueError("Empty value passed for parameter 'data_description'")
31673167
__path = f"/_ml/anomaly_detectors/{_quote(job_id)}"
31683168
__query: t.Dict[str, t.Any] = {}
@@ -3379,9 +3379,9 @@ async def put_trained_model_definition_part(
33793379
*,
33803380
model_id: str,
33813381
part: int,
3382-
definition: str,
3383-
total_definition_length: int,
3384-
total_parts: int,
3382+
definition: t.Optional[str] = None,
3383+
total_definition_length: t.Optional[int] = None,
3384+
total_parts: t.Optional[int] = None,
33853385
error_trace: t.Optional[bool] = None,
33863386
filter_path: t.Optional[t.Union[str, t.Sequence[str]]] = None,
33873387
human: t.Optional[bool] = None,
@@ -3408,13 +3408,13 @@ async def put_trained_model_definition_part(
34083408
raise ValueError("Empty value passed for parameter 'model_id'")
34093409
if part in SKIP_IN_PATH:
34103410
raise ValueError("Empty value passed for parameter 'part'")
3411-
if definition is None:
3411+
if definition is None and body is None:
34123412
raise ValueError("Empty value passed for parameter 'definition'")
3413-
if total_definition_length is None:
3413+
if total_definition_length is None and body is None:
34143414
raise ValueError(
34153415
"Empty value passed for parameter 'total_definition_length'"
34163416
)
3417-
if total_parts is None:
3417+
if total_parts is None and body is None:
34183418
raise ValueError("Empty value passed for parameter 'total_parts'")
34193419
__path = f"/_ml/trained_models/{_quote(model_id)}/definition/{_quote(part)}"
34203420
__query: t.Dict[str, t.Any] = {}
@@ -3446,7 +3446,7 @@ async def put_trained_model_vocabulary(
34463446
self,
34473447
*,
34483448
model_id: str,
3449-
vocabulary: t.Sequence[str],
3449+
vocabulary: t.Optional[t.Sequence[str]] = None,
34503450
error_trace: t.Optional[bool] = None,
34513451
filter_path: t.Optional[t.Union[str, t.Sequence[str]]] = None,
34523452
human: t.Optional[bool] = None,
@@ -3467,7 +3467,7 @@ async def put_trained_model_vocabulary(
34673467
"""
34683468
if model_id in SKIP_IN_PATH:
34693469
raise ValueError("Empty value passed for parameter 'model_id'")
3470-
if vocabulary is None:
3470+
if vocabulary is None and body is None:
34713471
raise ValueError("Empty value passed for parameter 'vocabulary'")
34723472
__path = f"/_ml/trained_models/{_quote(model_id)}/vocabulary"
34733473
__query: t.Dict[str, t.Any] = {}

elasticsearch/_async/client/query_ruleset.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ async def put(
139139
self,
140140
*,
141141
ruleset_id: str,
142-
rules: t.Sequence[t.Mapping[str, t.Any]],
142+
rules: t.Optional[t.Sequence[t.Mapping[str, t.Any]]] = None,
143143
error_trace: t.Optional[bool] = None,
144144
filter_path: t.Optional[t.Union[str, t.Sequence[str]]] = None,
145145
human: t.Optional[bool] = None,
@@ -157,7 +157,7 @@ async def put(
157157
"""
158158
if ruleset_id in SKIP_IN_PATH:
159159
raise ValueError("Empty value passed for parameter 'ruleset_id'")
160-
if rules is None:
160+
if rules is None and body is None:
161161
raise ValueError("Empty value passed for parameter 'rules'")
162162
__path = f"/_query_rules/{_quote(ruleset_id)}"
163163
__query: t.Dict[str, t.Any] = {}

0 commit comments

Comments
 (0)