Skip to content

Commit c3b8bb8

Browse files
committed
Separate setting __query and __body
1 parent 5ac6428 commit c3b8bb8

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

52 files changed

+1926
-1926
lines changed

elasticsearch/_async/client/__init__.py

Lines changed: 184 additions & 184 deletions
Large diffs are not rendered by default.

elasticsearch/_async/client/async_search.py

Lines changed: 55 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -396,8 +396,8 @@ async def submit(
396396
__path = f"/{_quote(index)}/_async_search"
397397
else:
398398
__path = "/_async_search"
399-
__body: t.Dict[str, t.Any] = {}
400399
__query: t.Dict[str, t.Any] = {}
400+
__body: t.Dict[str, t.Any] = {}
401401
# The 'sort' parameter with a colon can't be encoded to the body.
402402
if sort is not None and (
403403
(isinstance(sort, str) and ":" in sort)
@@ -409,10 +409,6 @@ async def submit(
409409
):
410410
__query["sort"] = sort
411411
sort = None
412-
if aggregations is not None:
413-
__body["aggregations"] = aggregations
414-
if aggs is not None:
415-
__body["aggs"] = aggs
416412
if allow_no_indices is not None:
417413
__query["allow_no_indices"] = allow_no_indices
418414
if allow_partial_search_results is not None:
@@ -425,86 +421,106 @@ async def submit(
425421
__query["batched_reduce_size"] = batched_reduce_size
426422
if ccs_minimize_roundtrips is not None:
427423
__query["ccs_minimize_roundtrips"] = ccs_minimize_roundtrips
428-
if collapse is not None:
429-
__body["collapse"] = collapse
430424
if default_operator is not None:
431425
__query["default_operator"] = default_operator
432426
if df is not None:
433427
__query["df"] = df
434-
if docvalue_fields is not None:
435-
__body["docvalue_fields"] = docvalue_fields
436428
if error_trace is not None:
437429
__query["error_trace"] = error_trace
438430
if expand_wildcards is not None:
439431
__query["expand_wildcards"] = expand_wildcards
440-
if explain is not None:
441-
__body["explain"] = explain
442-
if ext is not None:
443-
__body["ext"] = ext
444-
if fields is not None:
445-
__body["fields"] = fields
446432
if filter_path is not None:
447433
__query["filter_path"] = filter_path
448-
if from_ is not None:
449-
__body["from"] = from_
450-
if highlight is not None:
451-
__body["highlight"] = highlight
452434
if human is not None:
453435
__query["human"] = human
454436
if ignore_throttled is not None:
455437
__query["ignore_throttled"] = ignore_throttled
456438
if ignore_unavailable is not None:
457439
__query["ignore_unavailable"] = ignore_unavailable
458-
if indices_boost is not None:
459-
__body["indices_boost"] = indices_boost
460440
if keep_alive is not None:
461441
__query["keep_alive"] = keep_alive
462442
if keep_on_completion is not None:
463443
__query["keep_on_completion"] = keep_on_completion
464-
if knn is not None:
465-
__body["knn"] = knn
466444
if lenient is not None:
467445
__query["lenient"] = lenient
468446
if max_concurrent_shard_requests is not None:
469447
__query["max_concurrent_shard_requests"] = max_concurrent_shard_requests
470448
if min_compatible_shard_node is not None:
471449
__query["min_compatible_shard_node"] = min_compatible_shard_node
472-
if min_score is not None:
473-
__body["min_score"] = min_score
474-
if pit is not None:
475-
__body["pit"] = pit
476-
if post_filter is not None:
477-
__body["post_filter"] = post_filter
478450
if pre_filter_shard_size is not None:
479451
__query["pre_filter_shard_size"] = pre_filter_shard_size
480452
if preference is not None:
481453
__query["preference"] = preference
482454
if pretty is not None:
483455
__query["pretty"] = pretty
484-
if profile is not None:
485-
__body["profile"] = profile
486456
if q is not None:
487457
__query["q"] = q
488-
if query is not None:
489-
__body["query"] = query
490458
if request_cache is not None:
491459
__query["request_cache"] = request_cache
492-
if rescore is not None:
493-
__body["rescore"] = rescore
494460
if rest_total_hits_as_int is not None:
495461
__query["rest_total_hits_as_int"] = rest_total_hits_as_int
496462
if routing is not None:
497463
__query["routing"] = routing
464+
if scroll is not None:
465+
__query["scroll"] = scroll
466+
if search_type is not None:
467+
__query["search_type"] = search_type
468+
if source_excludes is not None:
469+
__query["_source_excludes"] = source_excludes
470+
if source_includes is not None:
471+
__query["_source_includes"] = source_includes
472+
if suggest_field is not None:
473+
__query["suggest_field"] = suggest_field
474+
if suggest_mode is not None:
475+
__query["suggest_mode"] = suggest_mode
476+
if suggest_size is not None:
477+
__query["suggest_size"] = suggest_size
478+
if suggest_text is not None:
479+
__query["suggest_text"] = suggest_text
480+
if typed_keys is not None:
481+
__query["typed_keys"] = typed_keys
482+
if wait_for_completion_timeout is not None:
483+
__query["wait_for_completion_timeout"] = wait_for_completion_timeout
484+
if aggregations is not None:
485+
__body["aggregations"] = aggregations
486+
if aggs is not None:
487+
__body["aggs"] = aggs
488+
if collapse is not None:
489+
__body["collapse"] = collapse
490+
if docvalue_fields is not None:
491+
__body["docvalue_fields"] = docvalue_fields
492+
if explain is not None:
493+
__body["explain"] = explain
494+
if ext is not None:
495+
__body["ext"] = ext
496+
if fields is not None:
497+
__body["fields"] = fields
498+
if from_ is not None:
499+
__body["from"] = from_
500+
if highlight is not None:
501+
__body["highlight"] = highlight
502+
if indices_boost is not None:
503+
__body["indices_boost"] = indices_boost
504+
if knn is not None:
505+
__body["knn"] = knn
506+
if min_score is not None:
507+
__body["min_score"] = min_score
508+
if pit is not None:
509+
__body["pit"] = pit
510+
if post_filter is not None:
511+
__body["post_filter"] = post_filter
512+
if profile is not None:
513+
__body["profile"] = profile
514+
if query is not None:
515+
__body["query"] = query
516+
if rescore is not None:
517+
__body["rescore"] = rescore
498518
if runtime_mappings is not None:
499519
__body["runtime_mappings"] = runtime_mappings
500520
if script_fields is not None:
501521
__body["script_fields"] = script_fields
502-
if scroll is not None:
503-
__query["scroll"] = scroll
504522
if search_after is not None:
505523
__body["search_after"] = search_after
506-
if search_type is not None:
507-
__query["search_type"] = search_type
508524
if seq_no_primary_term is not None:
509525
__body["seq_no_primary_term"] = seq_no_primary_term
510526
if size is not None:
@@ -515,24 +531,12 @@ async def submit(
515531
__body["sort"] = sort
516532
if source is not None:
517533
__body["_source"] = source
518-
if source_excludes is not None:
519-
__query["_source_excludes"] = source_excludes
520-
if source_includes is not None:
521-
__query["_source_includes"] = source_includes
522534
if stats is not None:
523535
__body["stats"] = stats
524536
if stored_fields is not None:
525537
__body["stored_fields"] = stored_fields
526538
if suggest is not None:
527539
__body["suggest"] = suggest
528-
if suggest_field is not None:
529-
__query["suggest_field"] = suggest_field
530-
if suggest_mode is not None:
531-
__query["suggest_mode"] = suggest_mode
532-
if suggest_size is not None:
533-
__query["suggest_size"] = suggest_size
534-
if suggest_text is not None:
535-
__query["suggest_text"] = suggest_text
536540
if terminate_after is not None:
537541
__body["terminate_after"] = terminate_after
538542
if timeout is not None:
@@ -541,12 +545,8 @@ async def submit(
541545
__body["track_scores"] = track_scores
542546
if track_total_hits is not None:
543547
__body["track_total_hits"] = track_total_hits
544-
if typed_keys is not None:
545-
__query["typed_keys"] = typed_keys
546548
if version is not None:
547549
__body["version"] = version
548-
if wait_for_completion_timeout is not None:
549-
__query["wait_for_completion_timeout"] = wait_for_completion_timeout
550550
if not __body:
551551
__body = None # type: ignore[assignment]
552552
__headers = {"accept": "application/json"}

elasticsearch/_async/client/ccr.py

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,10 @@ async def follow(
123123
__query["filter_path"] = filter_path
124124
if human is not None:
125125
__query["human"] = human
126+
if pretty is not None:
127+
__query["pretty"] = pretty
128+
if wait_for_active_shards is not None:
129+
__query["wait_for_active_shards"] = wait_for_active_shards
126130
if leader_index is not None:
127131
__body["leader_index"] = leader_index
128132
if max_outstanding_read_requests is not None:
@@ -147,14 +151,10 @@ async def follow(
147151
] = max_write_request_operation_count
148152
if max_write_request_size is not None:
149153
__body["max_write_request_size"] = max_write_request_size
150-
if pretty is not None:
151-
__query["pretty"] = pretty
152154
if read_poll_timeout is not None:
153155
__body["read_poll_timeout"] = read_poll_timeout
154156
if remote_cluster is not None:
155157
__body["remote_cluster"] = remote_cluster
156-
if wait_for_active_shards is not None:
157-
__query["wait_for_active_shards"] = wait_for_active_shards
158158
__headers = {"accept": "application/json", "content-type": "application/json"}
159159
return await self.perform_request( # type: ignore[return-value]
160160
"PUT", __path, params=__query, headers=__headers, body=__body
@@ -269,18 +269,18 @@ async def forget_follower(
269269
__query["error_trace"] = error_trace
270270
if filter_path is not None:
271271
__query["filter_path"] = filter_path
272+
if human is not None:
273+
__query["human"] = human
274+
if pretty is not None:
275+
__query["pretty"] = pretty
272276
if follower_cluster is not None:
273277
__body["follower_cluster"] = follower_cluster
274278
if follower_index is not None:
275279
__body["follower_index"] = follower_index
276280
if follower_index_uuid is not None:
277281
__body["follower_index_uuid"] = follower_index_uuid
278-
if human is not None:
279-
__query["human"] = human
280282
if leader_remote_cluster is not None:
281283
__body["leader_remote_cluster"] = leader_remote_cluster
282-
if pretty is not None:
283-
__query["pretty"] = pretty
284284
__headers = {"accept": "application/json", "content-type": "application/json"}
285285
return await self.perform_request( # type: ignore[return-value]
286286
"POST", __path, params=__query, headers=__headers, body=__body
@@ -480,18 +480,20 @@ async def put_auto_follow_pattern(
480480
if remote_cluster is None:
481481
raise ValueError("Empty value passed for parameter 'remote_cluster'")
482482
__path = f"/_ccr/auto_follow/{_quote(name)}"
483-
__body: t.Dict[str, t.Any] = {}
484483
__query: t.Dict[str, t.Any] = {}
485-
if remote_cluster is not None:
486-
__body["remote_cluster"] = remote_cluster
484+
__body: t.Dict[str, t.Any] = {}
487485
if error_trace is not None:
488486
__query["error_trace"] = error_trace
489487
if filter_path is not None:
490488
__query["filter_path"] = filter_path
491-
if follow_index_pattern is not None:
492-
__body["follow_index_pattern"] = follow_index_pattern
493489
if human is not None:
494490
__query["human"] = human
491+
if pretty is not None:
492+
__query["pretty"] = pretty
493+
if remote_cluster is not None:
494+
__body["remote_cluster"] = remote_cluster
495+
if follow_index_pattern is not None:
496+
__body["follow_index_pattern"] = follow_index_pattern
495497
if leader_index_exclusion_patterns is not None:
496498
__body["leader_index_exclusion_patterns"] = leader_index_exclusion_patterns
497499
if leader_index_patterns is not None:
@@ -518,8 +520,6 @@ async def put_auto_follow_pattern(
518520
] = max_write_request_operation_count
519521
if max_write_request_size is not None:
520522
__body["max_write_request_size"] = max_write_request_size
521-
if pretty is not None:
522-
__query["pretty"] = pretty
523523
if read_poll_timeout is not None:
524524
__body["read_poll_timeout"] = read_poll_timeout
525525
if settings is not None:
@@ -618,6 +618,8 @@ async def resume_follow(
618618
__query["filter_path"] = filter_path
619619
if human is not None:
620620
__query["human"] = human
621+
if pretty is not None:
622+
__query["pretty"] = pretty
621623
if max_outstanding_read_requests is not None:
622624
__body["max_outstanding_read_requests"] = max_outstanding_read_requests
623625
if max_outstanding_write_requests is not None:
@@ -640,8 +642,6 @@ async def resume_follow(
640642
] = max_write_request_operation_count
641643
if max_write_request_size is not None:
642644
__body["max_write_request_size"] = max_write_request_size
643-
if pretty is not None:
644-
__query["pretty"] = pretty
645645
if read_poll_timeout is not None:
646646
__body["read_poll_timeout"] = read_poll_timeout
647647
if not __body:

elasticsearch/_async/client/cluster.py

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -59,10 +59,8 @@ async def allocation_explain(
5959
for.
6060
"""
6161
__path = "/_cluster/allocation/explain"
62-
__body: t.Dict[str, t.Any] = {}
6362
__query: t.Dict[str, t.Any] = {}
64-
if current_node is not None:
65-
__body["current_node"] = current_node
63+
__body: t.Dict[str, t.Any] = {}
6664
if error_trace is not None:
6765
__query["error_trace"] = error_trace
6866
if filter_path is not None:
@@ -73,10 +71,12 @@ async def allocation_explain(
7371
__query["include_disk_info"] = include_disk_info
7472
if include_yes_decisions is not None:
7573
__query["include_yes_decisions"] = include_yes_decisions
76-
if index is not None:
77-
__body["index"] = index
7874
if pretty is not None:
7975
__query["pretty"] = pretty
76+
if current_node is not None:
77+
__body["current_node"] = current_node
78+
if index is not None:
79+
__body["index"] = index
8080
if primary is not None:
8181
__body["primary"] = primary
8282
if shard is not None:
@@ -652,12 +652,8 @@ async def put_component_template(
652652
if template is None:
653653
raise ValueError("Empty value passed for parameter 'template'")
654654
__path = f"/_component_template/{_quote(name)}"
655-
__body: t.Dict[str, t.Any] = {}
656655
__query: t.Dict[str, t.Any] = {}
657-
if template is not None:
658-
__body["template"] = template
659-
if allow_auto_create is not None:
660-
__body["allow_auto_create"] = allow_auto_create
656+
__body: t.Dict[str, t.Any] = {}
661657
if create is not None:
662658
__query["create"] = create
663659
if error_trace is not None:
@@ -668,10 +664,14 @@ async def put_component_template(
668664
__query["human"] = human
669665
if master_timeout is not None:
670666
__query["master_timeout"] = master_timeout
671-
if meta is not None:
672-
__body["_meta"] = meta
673667
if pretty is not None:
674668
__query["pretty"] = pretty
669+
if template is not None:
670+
__body["template"] = template
671+
if allow_auto_create is not None:
672+
__body["allow_auto_create"] = allow_auto_create
673+
if meta is not None:
674+
__body["_meta"] = meta
675675
if version is not None:
676676
__body["version"] = version
677677
__headers = {"accept": "application/json", "content-type": "application/json"}
@@ -721,12 +721,12 @@ async def put_settings(
721721
__query["human"] = human
722722
if master_timeout is not None:
723723
__query["master_timeout"] = master_timeout
724-
if persistent is not None:
725-
__body["persistent"] = persistent
726724
if pretty is not None:
727725
__query["pretty"] = pretty
728726
if timeout is not None:
729727
__query["timeout"] = timeout
728+
if persistent is not None:
729+
__body["persistent"] = persistent
730730
if transient is not None:
731731
__body["transient"] = transient
732732
__headers = {"accept": "application/json", "content-type": "application/json"}
@@ -803,10 +803,8 @@ async def reroute(
803803
the timeout expires, the request fails and returns an error.
804804
"""
805805
__path = "/_cluster/reroute"
806-
__body: t.Dict[str, t.Any] = {}
807806
__query: t.Dict[str, t.Any] = {}
808-
if commands is not None:
809-
__body["commands"] = commands
807+
__body: t.Dict[str, t.Any] = {}
810808
if dry_run is not None:
811809
__query["dry_run"] = dry_run
812810
if error_trace is not None:
@@ -827,6 +825,8 @@ async def reroute(
827825
__query["retry_failed"] = retry_failed
828826
if timeout is not None:
829827
__query["timeout"] = timeout
828+
if commands is not None:
829+
__body["commands"] = commands
830830
if not __body:
831831
__body = None # type: ignore[assignment]
832832
__headers = {"accept": "application/json"}

0 commit comments

Comments
 (0)