@@ -4004,91 +4004,37 @@ async def shrink(
4004
4004
path_parts = __path_parts ,
4005
4005
)
4006
4006
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 ()
4020
4008
async def simulate_index_template (
4021
4009
self ,
4022
4010
* ,
4023
4011
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 ,
4028
4012
error_trace : t .Optional [bool ] = None ,
4029
4013
filter_path : t .Optional [t .Union [str , t .Sequence [str ]]] = None ,
4030
4014
human : t .Optional [bool ] = None ,
4031
4015
include_defaults : t .Optional [bool ] = None ,
4032
- index_patterns : t .Optional [t .Union [str , t .Sequence [str ]]] = None ,
4033
4016
master_timeout : t .Optional [
4034
4017
t .Union ["t.Literal[-1]" , "t.Literal[0]" , str ]
4035
4018
] = None ,
4036
- meta : t .Optional [t .Mapping [str , t .Any ]] = None ,
4037
4019
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 ,
4042
4020
) -> ObjectApiResponse [t .Any ]:
4043
4021
"""
4044
4022
Simulate matching the given index name against the index templates in the system
4045
4023
4046
4024
`<https://www.elastic.co/guide/en/elasticsearch/reference/master/indices-simulate-index.html>`_
4047
4025
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
4065
4027
:param include_defaults: If true, returns all relevant default configurations
4066
4028
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.
4069
4029
:param master_timeout: Period to wait for a connection to the master node. If
4070
4030
no response is received before the timeout expires, the request fails and
4071
4031
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.
4083
4032
"""
4084
4033
if name in SKIP_IN_PATH :
4085
4034
raise ValueError ("Empty value passed for parameter 'name'" )
4086
4035
__path_parts : t .Dict [str , str ] = {"name" : _quote (name )}
4087
4036
__path = f'/_index_template/_simulate_index/{ __path_parts ["name" ]} '
4088
4037
__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
4092
4038
if error_trace is not None :
4093
4039
__query ["error_trace" ] = error_trace
4094
4040
if filter_path is not None :
@@ -4101,56 +4047,53 @@ async def simulate_index_template(
4101
4047
__query ["master_timeout" ] = master_timeout
4102
4048
if pretty is not None :
4103
4049
__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]
4123
4050
__headers = {"accept" : "application/json" }
4124
- if __body is not None :
4125
- __headers ["content-type" ] = "application/json"
4126
4051
return await self .perform_request ( # type: ignore[return-value]
4127
4052
"POST" ,
4128
4053
__path ,
4129
4054
params = __query ,
4130
4055
headers = __headers ,
4131
- body = __body ,
4132
4056
endpoint_id = "indices.simulate_index_template" ,
4133
4057
path_parts = __path_parts ,
4134
4058
)
4135
4059
4136
4060
@_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" },
4138
4073
)
4139
4074
async def simulate_template (
4140
4075
self ,
4141
4076
* ,
4142
4077
name : t .Optional [str ] = None ,
4078
+ allow_auto_create : t .Optional [bool ] = None ,
4079
+ composed_of : t .Optional [t .Sequence [str ]] = None ,
4143
4080
create : t .Optional [bool ] = None ,
4081
+ data_stream : t .Optional [t .Mapping [str , t .Any ]] = None ,
4144
4082
error_trace : t .Optional [bool ] = None ,
4145
4083
filter_path : t .Optional [t .Union [str , t .Sequence [str ]]] = None ,
4146
4084
human : t .Optional [bool ] = None ,
4085
+ ignore_missing_component_templates : t .Optional [t .Sequence [str ]] = None ,
4147
4086
include_defaults : t .Optional [bool ] = None ,
4087
+ index_patterns : t .Optional [t .Union [str , t .Sequence [str ]]] = None ,
4148
4088
master_timeout : t .Optional [
4149
4089
t .Union ["t.Literal[-1]" , "t.Literal[0]" , str ]
4150
4090
] = None ,
4091
+ meta : t .Optional [t .Mapping [str , t .Any ]] = None ,
4151
4092
pretty : t .Optional [bool ] = None ,
4093
+ priority : t .Optional [int ] = None ,
4152
4094
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 ,
4154
4097
) -> ObjectApiResponse [t .Any ]:
4155
4098
"""
4156
4099
Simulate resolving the given template name or body
@@ -4160,23 +4103,44 @@ async def simulate_template(
4160
4103
:param name: Name of the index template to simulate. To test a template configuration
4161
4104
before you add it to the cluster, omit this parameter and specify the template
4162
4105
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.
4163
4115
:param create: If true, the template passed in the body is only used if no existing
4164
4116
templates match the same index patterns. If false, the simulation uses the
4165
4117
template with the highest priority. Note that the template is not permanently
4166
4118
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
4167
4125
:param include_defaults: If true, returns all relevant default configurations
4168
4126
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.
4169
4129
:param master_timeout: Period to wait for a connection to the master node. If
4170
4130
no response is received before the timeout expires, the request fails and
4171
4131
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.
4173
4143
"""
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'" )
4180
4144
__path_parts : t .Dict [str , str ]
4181
4145
if name not in SKIP_IN_PATH :
4182
4146
__path_parts = {"name" : _quote (name )}
@@ -4185,6 +4149,7 @@ async def simulate_template(
4185
4149
__path_parts = {}
4186
4150
__path = "/_index_template/_simulate"
4187
4151
__query : t .Dict [str , t .Any ] = {}
4152
+ __body : t .Dict [str , t .Any ] = body if body is not None else {}
4188
4153
if create is not None :
4189
4154
__query ["create" ] = create
4190
4155
if error_trace is not None :
@@ -4199,9 +4164,29 @@ async def simulate_template(
4199
4164
__query ["master_timeout" ] = master_timeout
4200
4165
if pretty is not None :
4201
4166
__query ["pretty" ] = pretty
4202
- __body = template if template is not None else body
4203
4167
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]
4205
4190
__headers = {"accept" : "application/json" }
4206
4191
if __body is not None :
4207
4192
__headers ["content-type" ] = "application/json"
0 commit comments