Skip to content

Commit f50ebbb

Browse files
Auto-generated API code
1 parent 9a3277e commit f50ebbb

File tree

2 files changed

+148
-178
lines changed

2 files changed

+148
-178
lines changed

elasticsearch/_async/client/indices.py

Lines changed: 74 additions & 89 deletions
Original file line numberDiff line numberDiff line change
@@ -4004,91 +4004,37 @@ async def shrink(
40044004
path_parts=__path_parts,
40054005
)
40064006

4007-
@_rewrite_parameters(
4008-
body_fields=(
4009-
"allow_auto_create",
4010-
"composed_of",
4011-
"data_stream",
4012-
"index_patterns",
4013-
"meta",
4014-
"priority",
4015-
"template",
4016-
"version",
4017-
),
4018-
parameter_aliases={"_meta": "meta"},
4019-
)
4007+
@_rewrite_parameters()
40204008
async def simulate_index_template(
40214009
self,
40224010
*,
40234011
name: str,
4024-
allow_auto_create: t.Optional[bool] = None,
4025-
composed_of: t.Optional[t.Sequence[str]] = None,
4026-
create: t.Optional[bool] = None,
4027-
data_stream: t.Optional[t.Mapping[str, t.Any]] = None,
40284012
error_trace: t.Optional[bool] = None,
40294013
filter_path: t.Optional[t.Union[str, t.Sequence[str]]] = None,
40304014
human: t.Optional[bool] = None,
40314015
include_defaults: t.Optional[bool] = None,
4032-
index_patterns: t.Optional[t.Union[str, t.Sequence[str]]] = None,
40334016
master_timeout: t.Optional[
40344017
t.Union["t.Literal[-1]", "t.Literal[0]", str]
40354018
] = None,
4036-
meta: t.Optional[t.Mapping[str, t.Any]] = None,
40374019
pretty: t.Optional[bool] = None,
4038-
priority: t.Optional[int] = None,
4039-
template: t.Optional[t.Mapping[str, t.Any]] = None,
4040-
version: t.Optional[int] = None,
4041-
body: t.Optional[t.Dict[str, t.Any]] = None,
40424020
) -> ObjectApiResponse[t.Any]:
40434021
"""
40444022
Simulate matching the given index name against the index templates in the system
40454023
40464024
`<https://www.elastic.co/guide/en/elasticsearch/reference/master/indices-simulate-index.html>`_
40474025
4048-
:param name: Index or template name to simulate
4049-
:param allow_auto_create: This setting overrides the value of the `action.auto_create_index`
4050-
cluster setting. If set to `true` in a template, then indices can be automatically
4051-
created using that template even if auto-creation of indices is disabled
4052-
via `actions.auto_create_index`. If set to `false`, then indices or data
4053-
streams matching the template must always be explicitly created, and may
4054-
never be automatically created.
4055-
:param composed_of: An ordered list of component template names. Component templates
4056-
are merged in the order specified, meaning that the last component template
4057-
specified has the highest precedence.
4058-
:param create: If `true`, the template passed in the body is only used if no
4059-
existing templates match the same index patterns. If `false`, the simulation
4060-
uses the template with the highest priority. Note that the template is not
4061-
permanently added or updated in either case; it is only used for the simulation.
4062-
:param data_stream: If this object is included, the template is used to create
4063-
data streams and their backing indices. Supports an empty object. Data streams
4064-
require a matching index template with a `data_stream` object.
4026+
:param name: Name of the index to simulate
40654027
:param include_defaults: If true, returns all relevant default configurations
40664028
for the index template.
4067-
:param index_patterns: Array of wildcard (`*`) expressions used to match the
4068-
names of data streams and indices during creation.
40694029
:param master_timeout: Period to wait for a connection to the master node. If
40704030
no response is received before the timeout expires, the request fails and
40714031
returns an error.
4072-
:param meta: Optional user metadata about the index template. May have any contents.
4073-
This map is not automatically generated by Elasticsearch.
4074-
:param priority: Priority to determine index template precedence when a new data
4075-
stream or index is created. The index template with the highest priority
4076-
is chosen. If no priority is specified the template is treated as though
4077-
it is of priority 0 (lowest priority). This number is not automatically generated
4078-
by Elasticsearch.
4079-
:param template: Template to be applied. It may optionally include an `aliases`,
4080-
`mappings`, or `settings` configuration.
4081-
:param version: Version number used to manage index templates externally. This
4082-
number is not automatically generated by Elasticsearch.
40834032
"""
40844033
if name in SKIP_IN_PATH:
40854034
raise ValueError("Empty value passed for parameter 'name'")
40864035
__path_parts: t.Dict[str, str] = {"name": _quote(name)}
40874036
__path = f'/_index_template/_simulate_index/{__path_parts["name"]}'
40884037
__query: t.Dict[str, t.Any] = {}
4089-
__body: t.Dict[str, t.Any] = body if body is not None else {}
4090-
if create is not None:
4091-
__query["create"] = create
40924038
if error_trace is not None:
40934039
__query["error_trace"] = error_trace
40944040
if filter_path is not None:
@@ -4101,56 +4047,53 @@ async def simulate_index_template(
41014047
__query["master_timeout"] = master_timeout
41024048
if pretty is not None:
41034049
__query["pretty"] = pretty
4104-
if not __body:
4105-
if allow_auto_create is not None:
4106-
__body["allow_auto_create"] = allow_auto_create
4107-
if composed_of is not None:
4108-
__body["composed_of"] = composed_of
4109-
if data_stream is not None:
4110-
__body["data_stream"] = data_stream
4111-
if index_patterns is not None:
4112-
__body["index_patterns"] = index_patterns
4113-
if meta is not None:
4114-
__body["_meta"] = meta
4115-
if priority is not None:
4116-
__body["priority"] = priority
4117-
if template is not None:
4118-
__body["template"] = template
4119-
if version is not None:
4120-
__body["version"] = version
4121-
if not __body:
4122-
__body = None # type: ignore[assignment]
41234050
__headers = {"accept": "application/json"}
4124-
if __body is not None:
4125-
__headers["content-type"] = "application/json"
41264051
return await self.perform_request( # type: ignore[return-value]
41274052
"POST",
41284053
__path,
41294054
params=__query,
41304055
headers=__headers,
4131-
body=__body,
41324056
endpoint_id="indices.simulate_index_template",
41334057
path_parts=__path_parts,
41344058
)
41354059

41364060
@_rewrite_parameters(
4137-
body_name="template",
4061+
body_fields=(
4062+
"allow_auto_create",
4063+
"composed_of",
4064+
"data_stream",
4065+
"ignore_missing_component_templates",
4066+
"index_patterns",
4067+
"meta",
4068+
"priority",
4069+
"template",
4070+
"version",
4071+
),
4072+
parameter_aliases={"_meta": "meta"},
41384073
)
41394074
async def simulate_template(
41404075
self,
41414076
*,
41424077
name: t.Optional[str] = None,
4078+
allow_auto_create: t.Optional[bool] = None,
4079+
composed_of: t.Optional[t.Sequence[str]] = None,
41434080
create: t.Optional[bool] = None,
4081+
data_stream: t.Optional[t.Mapping[str, t.Any]] = None,
41444082
error_trace: t.Optional[bool] = None,
41454083
filter_path: t.Optional[t.Union[str, t.Sequence[str]]] = None,
41464084
human: t.Optional[bool] = None,
4085+
ignore_missing_component_templates: t.Optional[t.Sequence[str]] = None,
41474086
include_defaults: t.Optional[bool] = None,
4087+
index_patterns: t.Optional[t.Union[str, t.Sequence[str]]] = None,
41484088
master_timeout: t.Optional[
41494089
t.Union["t.Literal[-1]", "t.Literal[0]", str]
41504090
] = None,
4091+
meta: t.Optional[t.Mapping[str, t.Any]] = None,
41514092
pretty: t.Optional[bool] = None,
4093+
priority: t.Optional[int] = None,
41524094
template: t.Optional[t.Mapping[str, t.Any]] = None,
4153-
body: t.Optional[t.Mapping[str, t.Any]] = None,
4095+
version: t.Optional[int] = None,
4096+
body: t.Optional[t.Dict[str, t.Any]] = None,
41544097
) -> ObjectApiResponse[t.Any]:
41554098
"""
41564099
Simulate resolving the given template name or body
@@ -4160,23 +4103,44 @@ async def simulate_template(
41604103
:param name: Name of the index template to simulate. To test a template configuration
41614104
before you add it to the cluster, omit this parameter and specify the template
41624105
configuration in the request body.
4106+
:param allow_auto_create: This setting overrides the value of the `action.auto_create_index`
4107+
cluster setting. If set to `true` in a template, then indices can be automatically
4108+
created using that template even if auto-creation of indices is disabled
4109+
via `actions.auto_create_index`. If set to `false`, then indices or data
4110+
streams matching the template must always be explicitly created, and may
4111+
never be automatically created.
4112+
:param composed_of: An ordered list of component template names. Component templates
4113+
are merged in the order specified, meaning that the last component template
4114+
specified has the highest precedence.
41634115
:param create: If true, the template passed in the body is only used if no existing
41644116
templates match the same index patterns. If false, the simulation uses the
41654117
template with the highest priority. Note that the template is not permanently
41664118
added or updated in either case; it is only used for the simulation.
4119+
:param data_stream: If this object is included, the template is used to create
4120+
data streams and their backing indices. Supports an empty object. Data streams
4121+
require a matching index template with a `data_stream` object.
4122+
:param ignore_missing_component_templates: The configuration option ignore_missing_component_templates
4123+
can be used when an index template references a component template that might
4124+
not exist
41674125
:param include_defaults: If true, returns all relevant default configurations
41684126
for the index template.
4127+
:param index_patterns: Array of wildcard (`*`) expressions used to match the
4128+
names of data streams and indices during creation.
41694129
:param master_timeout: Period to wait for a connection to the master node. If
41704130
no response is received before the timeout expires, the request fails and
41714131
returns an error.
4172-
:param template:
4132+
:param meta: Optional user metadata about the index template. May have any contents.
4133+
This map is not automatically generated by Elasticsearch.
4134+
:param priority: Priority to determine index template precedence when a new data
4135+
stream or index is created. The index template with the highest priority
4136+
is chosen. If no priority is specified the template is treated as though
4137+
it is of priority 0 (lowest priority). This number is not automatically generated
4138+
by Elasticsearch.
4139+
:param template: Template to be applied. It may optionally include an `aliases`,
4140+
`mappings`, or `settings` configuration.
4141+
:param version: Version number used to manage index templates externally. This
4142+
number is not automatically generated by Elasticsearch.
41734143
"""
4174-
if template is None and body is None:
4175-
raise ValueError(
4176-
"Empty value passed for parameters 'template' and 'body', one of them should be set."
4177-
)
4178-
elif template is not None and body is not None:
4179-
raise ValueError("Cannot set both 'template' and 'body'")
41804144
__path_parts: t.Dict[str, str]
41814145
if name not in SKIP_IN_PATH:
41824146
__path_parts = {"name": _quote(name)}
@@ -4185,6 +4149,7 @@ async def simulate_template(
41854149
__path_parts = {}
41864150
__path = "/_index_template/_simulate"
41874151
__query: t.Dict[str, t.Any] = {}
4152+
__body: t.Dict[str, t.Any] = body if body is not None else {}
41884153
if create is not None:
41894154
__query["create"] = create
41904155
if error_trace is not None:
@@ -4199,9 +4164,29 @@ async def simulate_template(
41994164
__query["master_timeout"] = master_timeout
42004165
if pretty is not None:
42014166
__query["pretty"] = pretty
4202-
__body = template if template is not None else body
42034167
if not __body:
4204-
__body = None
4168+
if allow_auto_create is not None:
4169+
__body["allow_auto_create"] = allow_auto_create
4170+
if composed_of is not None:
4171+
__body["composed_of"] = composed_of
4172+
if data_stream is not None:
4173+
__body["data_stream"] = data_stream
4174+
if ignore_missing_component_templates is not None:
4175+
__body["ignore_missing_component_templates"] = (
4176+
ignore_missing_component_templates
4177+
)
4178+
if index_patterns is not None:
4179+
__body["index_patterns"] = index_patterns
4180+
if meta is not None:
4181+
__body["_meta"] = meta
4182+
if priority is not None:
4183+
__body["priority"] = priority
4184+
if template is not None:
4185+
__body["template"] = template
4186+
if version is not None:
4187+
__body["version"] = version
4188+
if not __body:
4189+
__body = None # type: ignore[assignment]
42054190
__headers = {"accept": "application/json"}
42064191
if __body is not None:
42074192
__headers["content-type"] = "application/json"

0 commit comments

Comments
 (0)