elasticsearch9 9.0.0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (160) hide show
  1. elasticsearch9/__init__.py +98 -0
  2. elasticsearch9/_async/__init__.py +16 -0
  3. elasticsearch9/_async/client/__init__.py +6531 -0
  4. elasticsearch9/_async/client/_base.py +430 -0
  5. elasticsearch9/_async/client/async_search.py +637 -0
  6. elasticsearch9/_async/client/autoscaling.py +252 -0
  7. elasticsearch9/_async/client/cat.py +2995 -0
  8. elasticsearch9/_async/client/ccr.py +1043 -0
  9. elasticsearch9/_async/client/cluster.py +1223 -0
  10. elasticsearch9/_async/client/connector.py +1978 -0
  11. elasticsearch9/_async/client/dangling_indices.py +192 -0
  12. elasticsearch9/_async/client/enrich.py +291 -0
  13. elasticsearch9/_async/client/eql.py +359 -0
  14. elasticsearch9/_async/client/esql.py +490 -0
  15. elasticsearch9/_async/client/features.py +130 -0
  16. elasticsearch9/_async/client/fleet.py +658 -0
  17. elasticsearch9/_async/client/graph.py +113 -0
  18. elasticsearch9/_async/client/ilm.py +668 -0
  19. elasticsearch9/_async/client/indices.py +5582 -0
  20. elasticsearch9/_async/client/inference.py +2247 -0
  21. elasticsearch9/_async/client/ingest.py +766 -0
  22. elasticsearch9/_async/client/license.py +400 -0
  23. elasticsearch9/_async/client/logstash.py +176 -0
  24. elasticsearch9/_async/client/migration.py +160 -0
  25. elasticsearch9/_async/client/ml.py +5835 -0
  26. elasticsearch9/_async/client/monitoring.py +100 -0
  27. elasticsearch9/_async/client/nodes.py +543 -0
  28. elasticsearch9/_async/client/query_rules.py +485 -0
  29. elasticsearch9/_async/client/rollup.py +616 -0
  30. elasticsearch9/_async/client/search_application.py +574 -0
  31. elasticsearch9/_async/client/searchable_snapshots.py +313 -0
  32. elasticsearch9/_async/client/security.py +4688 -0
  33. elasticsearch9/_async/client/shutdown.py +268 -0
  34. elasticsearch9/_async/client/simulate.py +145 -0
  35. elasticsearch9/_async/client/slm.py +559 -0
  36. elasticsearch9/_async/client/snapshot.py +1338 -0
  37. elasticsearch9/_async/client/sql.py +469 -0
  38. elasticsearch9/_async/client/ssl.py +76 -0
  39. elasticsearch9/_async/client/synonyms.py +413 -0
  40. elasticsearch9/_async/client/tasks.py +295 -0
  41. elasticsearch9/_async/client/text_structure.py +664 -0
  42. elasticsearch9/_async/client/transform.py +922 -0
  43. elasticsearch9/_async/client/utils.py +48 -0
  44. elasticsearch9/_async/client/watcher.py +894 -0
  45. elasticsearch9/_async/client/xpack.py +134 -0
  46. elasticsearch9/_async/helpers.py +596 -0
  47. elasticsearch9/_otel.py +110 -0
  48. elasticsearch9/_sync/__init__.py +16 -0
  49. elasticsearch9/_sync/client/__init__.py +6529 -0
  50. elasticsearch9/_sync/client/_base.py +430 -0
  51. elasticsearch9/_sync/client/async_search.py +637 -0
  52. elasticsearch9/_sync/client/autoscaling.py +252 -0
  53. elasticsearch9/_sync/client/cat.py +2995 -0
  54. elasticsearch9/_sync/client/ccr.py +1043 -0
  55. elasticsearch9/_sync/client/cluster.py +1223 -0
  56. elasticsearch9/_sync/client/connector.py +1978 -0
  57. elasticsearch9/_sync/client/dangling_indices.py +192 -0
  58. elasticsearch9/_sync/client/enrich.py +291 -0
  59. elasticsearch9/_sync/client/eql.py +359 -0
  60. elasticsearch9/_sync/client/esql.py +490 -0
  61. elasticsearch9/_sync/client/features.py +130 -0
  62. elasticsearch9/_sync/client/fleet.py +658 -0
  63. elasticsearch9/_sync/client/graph.py +113 -0
  64. elasticsearch9/_sync/client/ilm.py +668 -0
  65. elasticsearch9/_sync/client/indices.py +5582 -0
  66. elasticsearch9/_sync/client/inference.py +2247 -0
  67. elasticsearch9/_sync/client/ingest.py +766 -0
  68. elasticsearch9/_sync/client/license.py +400 -0
  69. elasticsearch9/_sync/client/logstash.py +176 -0
  70. elasticsearch9/_sync/client/migration.py +160 -0
  71. elasticsearch9/_sync/client/ml.py +5835 -0
  72. elasticsearch9/_sync/client/monitoring.py +100 -0
  73. elasticsearch9/_sync/client/nodes.py +543 -0
  74. elasticsearch9/_sync/client/query_rules.py +485 -0
  75. elasticsearch9/_sync/client/rollup.py +616 -0
  76. elasticsearch9/_sync/client/search_application.py +574 -0
  77. elasticsearch9/_sync/client/searchable_snapshots.py +313 -0
  78. elasticsearch9/_sync/client/security.py +4688 -0
  79. elasticsearch9/_sync/client/shutdown.py +268 -0
  80. elasticsearch9/_sync/client/simulate.py +145 -0
  81. elasticsearch9/_sync/client/slm.py +559 -0
  82. elasticsearch9/_sync/client/snapshot.py +1338 -0
  83. elasticsearch9/_sync/client/sql.py +469 -0
  84. elasticsearch9/_sync/client/ssl.py +76 -0
  85. elasticsearch9/_sync/client/synonyms.py +413 -0
  86. elasticsearch9/_sync/client/tasks.py +295 -0
  87. elasticsearch9/_sync/client/text_structure.py +664 -0
  88. elasticsearch9/_sync/client/transform.py +922 -0
  89. elasticsearch9/_sync/client/utils.py +475 -0
  90. elasticsearch9/_sync/client/watcher.py +894 -0
  91. elasticsearch9/_sync/client/xpack.py +134 -0
  92. elasticsearch9/_utils.py +34 -0
  93. elasticsearch9/_version.py +18 -0
  94. elasticsearch9/client.py +126 -0
  95. elasticsearch9/compat.py +79 -0
  96. elasticsearch9/dsl/__init__.py +203 -0
  97. elasticsearch9/dsl/_async/__init__.py +16 -0
  98. elasticsearch9/dsl/_async/document.py +522 -0
  99. elasticsearch9/dsl/_async/faceted_search.py +50 -0
  100. elasticsearch9/dsl/_async/index.py +639 -0
  101. elasticsearch9/dsl/_async/mapping.py +49 -0
  102. elasticsearch9/dsl/_async/search.py +237 -0
  103. elasticsearch9/dsl/_async/update_by_query.py +47 -0
  104. elasticsearch9/dsl/_sync/__init__.py +16 -0
  105. elasticsearch9/dsl/_sync/document.py +514 -0
  106. elasticsearch9/dsl/_sync/faceted_search.py +50 -0
  107. elasticsearch9/dsl/_sync/index.py +597 -0
  108. elasticsearch9/dsl/_sync/mapping.py +49 -0
  109. elasticsearch9/dsl/_sync/search.py +230 -0
  110. elasticsearch9/dsl/_sync/update_by_query.py +45 -0
  111. elasticsearch9/dsl/aggs.py +3734 -0
  112. elasticsearch9/dsl/analysis.py +341 -0
  113. elasticsearch9/dsl/async_connections.py +37 -0
  114. elasticsearch9/dsl/connections.py +142 -0
  115. elasticsearch9/dsl/document.py +20 -0
  116. elasticsearch9/dsl/document_base.py +444 -0
  117. elasticsearch9/dsl/exceptions.py +32 -0
  118. elasticsearch9/dsl/faceted_search.py +28 -0
  119. elasticsearch9/dsl/faceted_search_base.py +489 -0
  120. elasticsearch9/dsl/field.py +4392 -0
  121. elasticsearch9/dsl/function.py +180 -0
  122. elasticsearch9/dsl/index.py +23 -0
  123. elasticsearch9/dsl/index_base.py +178 -0
  124. elasticsearch9/dsl/mapping.py +19 -0
  125. elasticsearch9/dsl/mapping_base.py +219 -0
  126. elasticsearch9/dsl/query.py +2822 -0
  127. elasticsearch9/dsl/response/__init__.py +388 -0
  128. elasticsearch9/dsl/response/aggs.py +100 -0
  129. elasticsearch9/dsl/response/hit.py +53 -0
  130. elasticsearch9/dsl/search.py +20 -0
  131. elasticsearch9/dsl/search_base.py +1053 -0
  132. elasticsearch9/dsl/serializer.py +34 -0
  133. elasticsearch9/dsl/types.py +6453 -0
  134. elasticsearch9/dsl/update_by_query.py +19 -0
  135. elasticsearch9/dsl/update_by_query_base.py +149 -0
  136. elasticsearch9/dsl/utils.py +687 -0
  137. elasticsearch9/dsl/wrappers.py +144 -0
  138. elasticsearch9/exceptions.py +133 -0
  139. elasticsearch9/helpers/__init__.py +41 -0
  140. elasticsearch9/helpers/actions.py +875 -0
  141. elasticsearch9/helpers/errors.py +40 -0
  142. elasticsearch9/helpers/vectorstore/__init__.py +62 -0
  143. elasticsearch9/helpers/vectorstore/_async/__init__.py +16 -0
  144. elasticsearch9/helpers/vectorstore/_async/_utils.py +39 -0
  145. elasticsearch9/helpers/vectorstore/_async/embedding_service.py +89 -0
  146. elasticsearch9/helpers/vectorstore/_async/strategies.py +487 -0
  147. elasticsearch9/helpers/vectorstore/_async/vectorstore.py +421 -0
  148. elasticsearch9/helpers/vectorstore/_sync/__init__.py +16 -0
  149. elasticsearch9/helpers/vectorstore/_sync/_utils.py +39 -0
  150. elasticsearch9/helpers/vectorstore/_sync/embedding_service.py +89 -0
  151. elasticsearch9/helpers/vectorstore/_sync/strategies.py +487 -0
  152. elasticsearch9/helpers/vectorstore/_sync/vectorstore.py +421 -0
  153. elasticsearch9/helpers/vectorstore/_utils.py +116 -0
  154. elasticsearch9/py.typed +0 -0
  155. elasticsearch9/serializer.py +250 -0
  156. elasticsearch9-9.0.0.dist-info/METADATA +175 -0
  157. elasticsearch9-9.0.0.dist-info/RECORD +160 -0
  158. elasticsearch9-9.0.0.dist-info/WHEEL +4 -0
  159. elasticsearch9-9.0.0.dist-info/licenses/LICENSE +176 -0
  160. elasticsearch9-9.0.0.dist-info/licenses/NOTICE +2 -0
@@ -0,0 +1,4688 @@
1
+ # Licensed to Elasticsearch B.V. under one or more contributor
2
+ # license agreements. See the NOTICE file distributed with
3
+ # this work for additional information regarding copyright
4
+ # ownership. Elasticsearch B.V. licenses this file to you under
5
+ # the Apache License, Version 2.0 (the "License"); you may
6
+ # not use this file except in compliance with the License.
7
+ # You may obtain a copy of the License at
8
+ #
9
+ # http://www.apache.org/licenses/LICENSE-2.0
10
+ #
11
+ # Unless required by applicable law or agreed to in writing,
12
+ # software distributed under the License is distributed on an
13
+ # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14
+ # KIND, either express or implied. See the License for the
15
+ # specific language governing permissions and limitations
16
+ # under the License.
17
+
18
+ import typing as t
19
+
20
+ from elastic_transport import ObjectApiResponse
21
+
22
+ from ._base import NamespacedClient
23
+ from .utils import SKIP_IN_PATH, _quote, _rewrite_parameters
24
+
25
+
26
+ class SecurityClient(NamespacedClient):
27
+
28
+ @_rewrite_parameters(
29
+ body_fields=("grant_type", "access_token", "password", "username"),
30
+ )
31
+ async def activate_user_profile(
32
+ self,
33
+ *,
34
+ grant_type: t.Optional[
35
+ t.Union[str, t.Literal["access_token", "password"]]
36
+ ] = None,
37
+ access_token: t.Optional[str] = None,
38
+ error_trace: t.Optional[bool] = None,
39
+ filter_path: t.Optional[t.Union[str, t.Sequence[str]]] = None,
40
+ human: t.Optional[bool] = None,
41
+ password: t.Optional[str] = None,
42
+ pretty: t.Optional[bool] = None,
43
+ username: t.Optional[str] = None,
44
+ body: t.Optional[t.Dict[str, t.Any]] = None,
45
+ ) -> ObjectApiResponse[t.Any]:
46
+ """
47
+ .. raw:: html
48
+
49
+ <p>Activate a user profile.</p>
50
+ <p>Create or update a user profile on behalf of another user.</p>
51
+ <p>NOTE: The user profile feature is designed only for use by Kibana and Elastic's Observability, Enterprise Search, and Elastic Security solutions.
52
+ Individual users and external applications should not call this API directly.
53
+ The calling application must have either an <code>access_token</code> or a combination of <code>username</code> and <code>password</code> for the user that the profile document is intended for.
54
+ Elastic reserves the right to change or remove this feature in future releases without prior notice.</p>
55
+ <p>This API creates or updates a profile document for end users with information that is extracted from the user's authentication object including <code>username</code>, <code>full_name,</code> <code>roles</code>, and the authentication realm.
56
+ For example, in the JWT <code>access_token</code> case, the profile user's <code>username</code> is extracted from the JWT token claim pointed to by the <code>claims.principal</code> setting of the JWT realm that authenticated the token.</p>
57
+ <p>When updating a profile document, the API enables the document if it was disabled.
58
+ Any updates do not change existing content for either the <code>labels</code> or <code>data</code> fields.</p>
59
+
60
+
61
+ `<https://www.elastic.co/docs/api/doc/elasticsearch/v9/operation/operation-security-activate-user-profile>`_
62
+
63
+ :param grant_type: The type of grant.
64
+ :param access_token: The user's Elasticsearch access token or JWT. Both `access`
65
+ and `id` JWT token types are supported and they depend on the underlying
66
+ JWT realm configuration. If you specify the `access_token` grant type, this
67
+ parameter is required. It is not valid with other grant types.
68
+ :param password: The user's password. If you specify the `password` grant type,
69
+ this parameter is required. It is not valid with other grant types.
70
+ :param username: The username that identifies the user. If you specify the `password`
71
+ grant type, this parameter is required. It is not valid with other grant
72
+ types.
73
+ """
74
+ if grant_type is None and body is None:
75
+ raise ValueError("Empty value passed for parameter 'grant_type'")
76
+ __path_parts: t.Dict[str, str] = {}
77
+ __path = "/_security/profile/_activate"
78
+ __query: t.Dict[str, t.Any] = {}
79
+ __body: t.Dict[str, t.Any] = body if body is not None else {}
80
+ if error_trace is not None:
81
+ __query["error_trace"] = error_trace
82
+ if filter_path is not None:
83
+ __query["filter_path"] = filter_path
84
+ if human is not None:
85
+ __query["human"] = human
86
+ if pretty is not None:
87
+ __query["pretty"] = pretty
88
+ if not __body:
89
+ if grant_type is not None:
90
+ __body["grant_type"] = grant_type
91
+ if access_token is not None:
92
+ __body["access_token"] = access_token
93
+ if password is not None:
94
+ __body["password"] = password
95
+ if username is not None:
96
+ __body["username"] = username
97
+ __headers = {"accept": "application/json", "content-type": "application/json"}
98
+ return await self.perform_request( # type: ignore[return-value]
99
+ "POST",
100
+ __path,
101
+ params=__query,
102
+ headers=__headers,
103
+ body=__body,
104
+ endpoint_id="security.activate_user_profile",
105
+ path_parts=__path_parts,
106
+ )
107
+
108
+ @_rewrite_parameters()
109
+ async def authenticate(
110
+ self,
111
+ *,
112
+ error_trace: t.Optional[bool] = None,
113
+ filter_path: t.Optional[t.Union[str, t.Sequence[str]]] = None,
114
+ human: t.Optional[bool] = None,
115
+ pretty: t.Optional[bool] = None,
116
+ ) -> ObjectApiResponse[t.Any]:
117
+ """
118
+ .. raw:: html
119
+
120
+ <p>Authenticate a user.</p>
121
+ <p>Authenticates a user and returns information about the authenticated user.
122
+ Include the user information in a <a href="https://en.wikipedia.org/wiki/Basic_access_authentication">basic auth header</a>.
123
+ A successful call returns a JSON structure that shows user information such as their username, the roles that are assigned to the user, any assigned metadata, and information about the realms that authenticated and authorized the user.
124
+ If the user cannot be authenticated, this API returns a 401 status code.</p>
125
+
126
+
127
+ `<https://www.elastic.co/docs/api/doc/elasticsearch/v9/operation/operation-security-authenticate>`_
128
+ """
129
+ __path_parts: t.Dict[str, str] = {}
130
+ __path = "/_security/_authenticate"
131
+ __query: t.Dict[str, t.Any] = {}
132
+ if error_trace is not None:
133
+ __query["error_trace"] = error_trace
134
+ if filter_path is not None:
135
+ __query["filter_path"] = filter_path
136
+ if human is not None:
137
+ __query["human"] = human
138
+ if pretty is not None:
139
+ __query["pretty"] = pretty
140
+ __headers = {"accept": "application/json"}
141
+ return await self.perform_request( # type: ignore[return-value]
142
+ "GET",
143
+ __path,
144
+ params=__query,
145
+ headers=__headers,
146
+ endpoint_id="security.authenticate",
147
+ path_parts=__path_parts,
148
+ )
149
+
150
+ @_rewrite_parameters(
151
+ body_fields=("names",),
152
+ )
153
+ async def bulk_delete_role(
154
+ self,
155
+ *,
156
+ names: t.Optional[t.Sequence[str]] = None,
157
+ error_trace: t.Optional[bool] = None,
158
+ filter_path: t.Optional[t.Union[str, t.Sequence[str]]] = None,
159
+ human: t.Optional[bool] = None,
160
+ pretty: t.Optional[bool] = None,
161
+ refresh: t.Optional[
162
+ t.Union[bool, str, t.Literal["false", "true", "wait_for"]]
163
+ ] = None,
164
+ body: t.Optional[t.Dict[str, t.Any]] = None,
165
+ ) -> ObjectApiResponse[t.Any]:
166
+ """
167
+ .. raw:: html
168
+
169
+ <p>Bulk delete roles.</p>
170
+ <p>The role management APIs are generally the preferred way to manage roles, rather than using file-based role management.
171
+ The bulk delete roles API cannot delete roles that are defined in roles files.</p>
172
+
173
+
174
+ `<https://www.elastic.co/docs/api/doc/elasticsearch/v9/operation/operation-security-bulk-delete-role>`_
175
+
176
+ :param names: An array of role names to delete
177
+ :param refresh: If `true` (the default) then refresh the affected shards to make
178
+ this operation visible to search, if `wait_for` then wait for a refresh to
179
+ make this operation visible to search, if `false` then do nothing with refreshes.
180
+ """
181
+ if names is None and body is None:
182
+ raise ValueError("Empty value passed for parameter 'names'")
183
+ __path_parts: t.Dict[str, str] = {}
184
+ __path = "/_security/role"
185
+ __query: t.Dict[str, t.Any] = {}
186
+ __body: t.Dict[str, t.Any] = body if body is not None else {}
187
+ if error_trace is not None:
188
+ __query["error_trace"] = error_trace
189
+ if filter_path is not None:
190
+ __query["filter_path"] = filter_path
191
+ if human is not None:
192
+ __query["human"] = human
193
+ if pretty is not None:
194
+ __query["pretty"] = pretty
195
+ if refresh is not None:
196
+ __query["refresh"] = refresh
197
+ if not __body:
198
+ if names is not None:
199
+ __body["names"] = names
200
+ __headers = {"accept": "application/json", "content-type": "application/json"}
201
+ return await self.perform_request( # type: ignore[return-value]
202
+ "DELETE",
203
+ __path,
204
+ params=__query,
205
+ headers=__headers,
206
+ body=__body,
207
+ endpoint_id="security.bulk_delete_role",
208
+ path_parts=__path_parts,
209
+ )
210
+
211
+ @_rewrite_parameters(
212
+ body_fields=("roles",),
213
+ )
214
+ async def bulk_put_role(
215
+ self,
216
+ *,
217
+ roles: t.Optional[t.Mapping[str, t.Mapping[str, t.Any]]] = None,
218
+ error_trace: t.Optional[bool] = None,
219
+ filter_path: t.Optional[t.Union[str, t.Sequence[str]]] = None,
220
+ human: t.Optional[bool] = None,
221
+ pretty: t.Optional[bool] = None,
222
+ refresh: t.Optional[
223
+ t.Union[bool, str, t.Literal["false", "true", "wait_for"]]
224
+ ] = None,
225
+ body: t.Optional[t.Dict[str, t.Any]] = None,
226
+ ) -> ObjectApiResponse[t.Any]:
227
+ """
228
+ .. raw:: html
229
+
230
+ <p>Bulk create or update roles.</p>
231
+ <p>The role management APIs are generally the preferred way to manage roles, rather than using file-based role management.
232
+ The bulk create or update roles API cannot update roles that are defined in roles files.</p>
233
+
234
+
235
+ `<https://www.elastic.co/docs/api/doc/elasticsearch/v9/operation/operation-security-bulk-put-role>`_
236
+
237
+ :param roles: A dictionary of role name to RoleDescriptor objects to add or update
238
+ :param refresh: If `true` (the default) then refresh the affected shards to make
239
+ this operation visible to search, if `wait_for` then wait for a refresh to
240
+ make this operation visible to search, if `false` then do nothing with refreshes.
241
+ """
242
+ if roles is None and body is None:
243
+ raise ValueError("Empty value passed for parameter 'roles'")
244
+ __path_parts: t.Dict[str, str] = {}
245
+ __path = "/_security/role"
246
+ __query: t.Dict[str, t.Any] = {}
247
+ __body: t.Dict[str, t.Any] = body if body is not None else {}
248
+ if error_trace is not None:
249
+ __query["error_trace"] = error_trace
250
+ if filter_path is not None:
251
+ __query["filter_path"] = filter_path
252
+ if human is not None:
253
+ __query["human"] = human
254
+ if pretty is not None:
255
+ __query["pretty"] = pretty
256
+ if refresh is not None:
257
+ __query["refresh"] = refresh
258
+ if not __body:
259
+ if roles is not None:
260
+ __body["roles"] = roles
261
+ __headers = {"accept": "application/json", "content-type": "application/json"}
262
+ return await self.perform_request( # type: ignore[return-value]
263
+ "POST",
264
+ __path,
265
+ params=__query,
266
+ headers=__headers,
267
+ body=__body,
268
+ endpoint_id="security.bulk_put_role",
269
+ path_parts=__path_parts,
270
+ )
271
+
272
+ @_rewrite_parameters(
273
+ body_fields=("ids", "expiration", "metadata", "role_descriptors"),
274
+ )
275
+ async def bulk_update_api_keys(
276
+ self,
277
+ *,
278
+ ids: t.Optional[t.Union[str, t.Sequence[str]]] = None,
279
+ error_trace: t.Optional[bool] = None,
280
+ expiration: t.Optional[t.Union[str, t.Literal[-1], t.Literal[0]]] = None,
281
+ filter_path: t.Optional[t.Union[str, t.Sequence[str]]] = None,
282
+ human: t.Optional[bool] = None,
283
+ metadata: t.Optional[t.Mapping[str, t.Any]] = None,
284
+ pretty: t.Optional[bool] = None,
285
+ role_descriptors: t.Optional[t.Mapping[str, t.Mapping[str, t.Any]]] = None,
286
+ body: t.Optional[t.Dict[str, t.Any]] = None,
287
+ ) -> ObjectApiResponse[t.Any]:
288
+ """
289
+ .. raw:: html
290
+
291
+ <p>Bulk update API keys.
292
+ Update the attributes for multiple API keys.</p>
293
+ <p>IMPORTANT: It is not possible to use an API key as the authentication credential for this API. To update API keys, the owner user's credentials are required.</p>
294
+ <p>This API is similar to the update API key API but enables you to apply the same update to multiple API keys in one API call. This operation can greatly improve performance over making individual updates.</p>
295
+ <p>It is not possible to update expired or invalidated API keys.</p>
296
+ <p>This API supports updates to API key access scope, metadata and expiration.
297
+ The access scope of each API key is derived from the <code>role_descriptors</code> you specify in the request and a snapshot of the owner user's permissions at the time of the request.
298
+ The snapshot of the owner's permissions is updated automatically on every call.</p>
299
+ <p>IMPORTANT: If you don't specify <code>role_descriptors</code> in the request, a call to this API might still change an API key's access scope. This change can occur if the owner user's permissions have changed since the API key was created or last modified.</p>
300
+ <p>A successful request returns a JSON structure that contains the IDs of all updated API keys, the IDs of API keys that already had the requested changes and did not require an update, and error details for any failed update.</p>
301
+
302
+
303
+ `<https://www.elastic.co/docs/api/doc/elasticsearch/v9/operation/operation-security-bulk-update-api-keys>`_
304
+
305
+ :param ids: The API key identifiers.
306
+ :param expiration: Expiration time for the API keys. By default, API keys never
307
+ expire. This property can be omitted to leave the value unchanged.
308
+ :param metadata: Arbitrary nested metadata to associate with the API keys. Within
309
+ the `metadata` object, top-level keys beginning with an underscore (`_`)
310
+ are reserved for system usage. Any information specified with this parameter
311
+ fully replaces metadata previously associated with the API key.
312
+ :param role_descriptors: The role descriptors to assign to the API keys. An API
313
+ key's effective permissions are an intersection of its assigned privileges
314
+ and the point-in-time snapshot of permissions of the owner user. You can
315
+ assign new privileges by specifying them in this parameter. To remove assigned
316
+ privileges, supply the `role_descriptors` parameter as an empty object `{}`.
317
+ If an API key has no assigned privileges, it inherits the owner user's full
318
+ permissions. The snapshot of the owner's permissions is always updated, whether
319
+ you supply the `role_descriptors` parameter. The structure of a role descriptor
320
+ is the same as the request for the create API keys API.
321
+ """
322
+ if ids is None and body is None:
323
+ raise ValueError("Empty value passed for parameter 'ids'")
324
+ __path_parts: t.Dict[str, str] = {}
325
+ __path = "/_security/api_key/_bulk_update"
326
+ __query: t.Dict[str, t.Any] = {}
327
+ __body: t.Dict[str, t.Any] = body if body is not None else {}
328
+ if error_trace is not None:
329
+ __query["error_trace"] = error_trace
330
+ if filter_path is not None:
331
+ __query["filter_path"] = filter_path
332
+ if human is not None:
333
+ __query["human"] = human
334
+ if pretty is not None:
335
+ __query["pretty"] = pretty
336
+ if not __body:
337
+ if ids is not None:
338
+ __body["ids"] = ids
339
+ if expiration is not None:
340
+ __body["expiration"] = expiration
341
+ if metadata is not None:
342
+ __body["metadata"] = metadata
343
+ if role_descriptors is not None:
344
+ __body["role_descriptors"] = role_descriptors
345
+ __headers = {"accept": "application/json", "content-type": "application/json"}
346
+ return await self.perform_request( # type: ignore[return-value]
347
+ "POST",
348
+ __path,
349
+ params=__query,
350
+ headers=__headers,
351
+ body=__body,
352
+ endpoint_id="security.bulk_update_api_keys",
353
+ path_parts=__path_parts,
354
+ )
355
+
356
+ @_rewrite_parameters(
357
+ body_fields=("password", "password_hash"),
358
+ )
359
+ async def change_password(
360
+ self,
361
+ *,
362
+ username: t.Optional[str] = None,
363
+ error_trace: t.Optional[bool] = None,
364
+ filter_path: t.Optional[t.Union[str, t.Sequence[str]]] = None,
365
+ human: t.Optional[bool] = None,
366
+ password: t.Optional[str] = None,
367
+ password_hash: t.Optional[str] = None,
368
+ pretty: t.Optional[bool] = None,
369
+ refresh: t.Optional[
370
+ t.Union[bool, str, t.Literal["false", "true", "wait_for"]]
371
+ ] = None,
372
+ body: t.Optional[t.Dict[str, t.Any]] = None,
373
+ ) -> ObjectApiResponse[t.Any]:
374
+ """
375
+ .. raw:: html
376
+
377
+ <p>Change passwords.</p>
378
+ <p>Change the passwords of users in the native realm and built-in users.</p>
379
+
380
+
381
+ `<https://www.elastic.co/docs/api/doc/elasticsearch/v9/operation/operation-security-change-password>`_
382
+
383
+ :param username: The user whose password you want to change. If you do not specify
384
+ this parameter, the password is changed for the current user.
385
+ :param password: The new password value. Passwords must be at least 6 characters
386
+ long.
387
+ :param password_hash: A hash of the new password value. This must be produced
388
+ using the same hashing algorithm as has been configured for password storage.
389
+ For more details, see the explanation of the `xpack.security.authc.password_hashing.algorithm`
390
+ setting.
391
+ :param refresh: If `true` (the default) then refresh the affected shards to make
392
+ this operation visible to search, if `wait_for` then wait for a refresh to
393
+ make this operation visible to search, if `false` then do nothing with refreshes.
394
+ """
395
+ __path_parts: t.Dict[str, str]
396
+ if username not in SKIP_IN_PATH:
397
+ __path_parts = {"username": _quote(username)}
398
+ __path = f'/_security/user/{__path_parts["username"]}/_password'
399
+ else:
400
+ __path_parts = {}
401
+ __path = "/_security/user/_password"
402
+ __query: t.Dict[str, t.Any] = {}
403
+ __body: t.Dict[str, t.Any] = body if body is not None else {}
404
+ if error_trace is not None:
405
+ __query["error_trace"] = error_trace
406
+ if filter_path is not None:
407
+ __query["filter_path"] = filter_path
408
+ if human is not None:
409
+ __query["human"] = human
410
+ if pretty is not None:
411
+ __query["pretty"] = pretty
412
+ if refresh is not None:
413
+ __query["refresh"] = refresh
414
+ if not __body:
415
+ if password is not None:
416
+ __body["password"] = password
417
+ if password_hash is not None:
418
+ __body["password_hash"] = password_hash
419
+ __headers = {"accept": "application/json", "content-type": "application/json"}
420
+ return await self.perform_request( # type: ignore[return-value]
421
+ "PUT",
422
+ __path,
423
+ params=__query,
424
+ headers=__headers,
425
+ body=__body,
426
+ endpoint_id="security.change_password",
427
+ path_parts=__path_parts,
428
+ )
429
+
430
+ @_rewrite_parameters()
431
+ async def clear_api_key_cache(
432
+ self,
433
+ *,
434
+ ids: t.Union[str, t.Sequence[str]],
435
+ error_trace: t.Optional[bool] = None,
436
+ filter_path: t.Optional[t.Union[str, t.Sequence[str]]] = None,
437
+ human: t.Optional[bool] = None,
438
+ pretty: t.Optional[bool] = None,
439
+ ) -> ObjectApiResponse[t.Any]:
440
+ """
441
+ .. raw:: html
442
+
443
+ <p>Clear the API key cache.</p>
444
+ <p>Evict a subset of all entries from the API key cache.
445
+ The cache is also automatically cleared on state changes of the security index.</p>
446
+
447
+
448
+ `<https://www.elastic.co/docs/api/doc/elasticsearch/v9/operation/operation-security-clear-api-key-cache>`_
449
+
450
+ :param ids: Comma-separated list of API key IDs to evict from the API key cache.
451
+ To evict all API keys, use `*`. Does not support other wildcard patterns.
452
+ """
453
+ if ids in SKIP_IN_PATH:
454
+ raise ValueError("Empty value passed for parameter 'ids'")
455
+ __path_parts: t.Dict[str, str] = {"ids": _quote(ids)}
456
+ __path = f'/_security/api_key/{__path_parts["ids"]}/_clear_cache'
457
+ __query: t.Dict[str, t.Any] = {}
458
+ if error_trace is not None:
459
+ __query["error_trace"] = error_trace
460
+ if filter_path is not None:
461
+ __query["filter_path"] = filter_path
462
+ if human is not None:
463
+ __query["human"] = human
464
+ if pretty is not None:
465
+ __query["pretty"] = pretty
466
+ __headers = {"accept": "application/json"}
467
+ return await self.perform_request( # type: ignore[return-value]
468
+ "POST",
469
+ __path,
470
+ params=__query,
471
+ headers=__headers,
472
+ endpoint_id="security.clear_api_key_cache",
473
+ path_parts=__path_parts,
474
+ )
475
+
476
+ @_rewrite_parameters()
477
+ async def clear_cached_privileges(
478
+ self,
479
+ *,
480
+ application: str,
481
+ error_trace: t.Optional[bool] = None,
482
+ filter_path: t.Optional[t.Union[str, t.Sequence[str]]] = None,
483
+ human: t.Optional[bool] = None,
484
+ pretty: t.Optional[bool] = None,
485
+ ) -> ObjectApiResponse[t.Any]:
486
+ """
487
+ .. raw:: html
488
+
489
+ <p>Clear the privileges cache.</p>
490
+ <p>Evict privileges from the native application privilege cache.
491
+ The cache is also automatically cleared for applications that have their privileges updated.</p>
492
+
493
+
494
+ `<https://www.elastic.co/docs/api/doc/elasticsearch/v9/operation/operation-security-clear-cached-privileges>`_
495
+
496
+ :param application: A comma-separated list of applications. To clear all applications,
497
+ use an asterism (`*`). It does not support other wildcard patterns.
498
+ """
499
+ if application in SKIP_IN_PATH:
500
+ raise ValueError("Empty value passed for parameter 'application'")
501
+ __path_parts: t.Dict[str, str] = {"application": _quote(application)}
502
+ __path = f'/_security/privilege/{__path_parts["application"]}/_clear_cache'
503
+ __query: t.Dict[str, t.Any] = {}
504
+ if error_trace is not None:
505
+ __query["error_trace"] = error_trace
506
+ if filter_path is not None:
507
+ __query["filter_path"] = filter_path
508
+ if human is not None:
509
+ __query["human"] = human
510
+ if pretty is not None:
511
+ __query["pretty"] = pretty
512
+ __headers = {"accept": "application/json"}
513
+ return await self.perform_request( # type: ignore[return-value]
514
+ "POST",
515
+ __path,
516
+ params=__query,
517
+ headers=__headers,
518
+ endpoint_id="security.clear_cached_privileges",
519
+ path_parts=__path_parts,
520
+ )
521
+
522
+ @_rewrite_parameters()
523
+ async def clear_cached_realms(
524
+ self,
525
+ *,
526
+ realms: t.Union[str, t.Sequence[str]],
527
+ error_trace: t.Optional[bool] = None,
528
+ filter_path: t.Optional[t.Union[str, t.Sequence[str]]] = None,
529
+ human: t.Optional[bool] = None,
530
+ pretty: t.Optional[bool] = None,
531
+ usernames: t.Optional[t.Sequence[str]] = None,
532
+ ) -> ObjectApiResponse[t.Any]:
533
+ """
534
+ .. raw:: html
535
+
536
+ <p>Clear the user cache.</p>
537
+ <p>Evict users from the user cache.
538
+ You can completely clear the cache or evict specific users.</p>
539
+ <p>User credentials are cached in memory on each node to avoid connecting to a remote authentication service or hitting the disk for every incoming request.
540
+ There are realm settings that you can use to configure the user cache.
541
+ For more information, refer to the documentation about controlling the user cache.</p>
542
+
543
+
544
+ `<https://www.elastic.co/docs/api/doc/elasticsearch/v9/operation/operation-security-clear-cached-realms>`_
545
+
546
+ :param realms: A comma-separated list of realms. To clear all realms, use an
547
+ asterisk (`*`). It does not support other wildcard patterns.
548
+ :param usernames: A comma-separated list of the users to clear from the cache.
549
+ If you do not specify this parameter, the API evicts all users from the user
550
+ cache.
551
+ """
552
+ if realms in SKIP_IN_PATH:
553
+ raise ValueError("Empty value passed for parameter 'realms'")
554
+ __path_parts: t.Dict[str, str] = {"realms": _quote(realms)}
555
+ __path = f'/_security/realm/{__path_parts["realms"]}/_clear_cache'
556
+ __query: t.Dict[str, t.Any] = {}
557
+ if error_trace is not None:
558
+ __query["error_trace"] = error_trace
559
+ if filter_path is not None:
560
+ __query["filter_path"] = filter_path
561
+ if human is not None:
562
+ __query["human"] = human
563
+ if pretty is not None:
564
+ __query["pretty"] = pretty
565
+ if usernames is not None:
566
+ __query["usernames"] = usernames
567
+ __headers = {"accept": "application/json"}
568
+ return await self.perform_request( # type: ignore[return-value]
569
+ "POST",
570
+ __path,
571
+ params=__query,
572
+ headers=__headers,
573
+ endpoint_id="security.clear_cached_realms",
574
+ path_parts=__path_parts,
575
+ )
576
+
577
+ @_rewrite_parameters()
578
+ async def clear_cached_roles(
579
+ self,
580
+ *,
581
+ name: t.Union[str, t.Sequence[str]],
582
+ error_trace: t.Optional[bool] = None,
583
+ filter_path: t.Optional[t.Union[str, t.Sequence[str]]] = None,
584
+ human: t.Optional[bool] = None,
585
+ pretty: t.Optional[bool] = None,
586
+ ) -> ObjectApiResponse[t.Any]:
587
+ """
588
+ .. raw:: html
589
+
590
+ <p>Clear the roles cache.</p>
591
+ <p>Evict roles from the native role cache.</p>
592
+
593
+
594
+ `<https://www.elastic.co/docs/api/doc/elasticsearch/v9/operation/operation-security-clear-cached-roles>`_
595
+
596
+ :param name: A comma-separated list of roles to evict from the role cache. To
597
+ evict all roles, use an asterisk (`*`). It does not support other wildcard
598
+ patterns.
599
+ """
600
+ if name in SKIP_IN_PATH:
601
+ raise ValueError("Empty value passed for parameter 'name'")
602
+ __path_parts: t.Dict[str, str] = {"name": _quote(name)}
603
+ __path = f'/_security/role/{__path_parts["name"]}/_clear_cache'
604
+ __query: t.Dict[str, t.Any] = {}
605
+ if error_trace is not None:
606
+ __query["error_trace"] = error_trace
607
+ if filter_path is not None:
608
+ __query["filter_path"] = filter_path
609
+ if human is not None:
610
+ __query["human"] = human
611
+ if pretty is not None:
612
+ __query["pretty"] = pretty
613
+ __headers = {"accept": "application/json"}
614
+ return await self.perform_request( # type: ignore[return-value]
615
+ "POST",
616
+ __path,
617
+ params=__query,
618
+ headers=__headers,
619
+ endpoint_id="security.clear_cached_roles",
620
+ path_parts=__path_parts,
621
+ )
622
+
623
+ @_rewrite_parameters()
624
+ async def clear_cached_service_tokens(
625
+ self,
626
+ *,
627
+ namespace: str,
628
+ service: str,
629
+ name: t.Union[str, t.Sequence[str]],
630
+ error_trace: t.Optional[bool] = None,
631
+ filter_path: t.Optional[t.Union[str, t.Sequence[str]]] = None,
632
+ human: t.Optional[bool] = None,
633
+ pretty: t.Optional[bool] = None,
634
+ ) -> ObjectApiResponse[t.Any]:
635
+ """
636
+ .. raw:: html
637
+
638
+ <p>Clear service account token caches.</p>
639
+ <p>Evict a subset of all entries from the service account token caches.
640
+ Two separate caches exist for service account tokens: one cache for tokens backed by the <code>service_tokens</code> file, and another for tokens backed by the <code>.security</code> index.
641
+ This API clears matching entries from both caches.</p>
642
+ <p>The cache for service account tokens backed by the <code>.security</code> index is cleared automatically on state changes of the security index.
643
+ The cache for tokens backed by the <code>service_tokens</code> file is cleared automatically on file changes.</p>
644
+
645
+
646
+ `<https://www.elastic.co/docs/api/doc/elasticsearch/v9/operation/operation-security-clear-cached-service-tokens>`_
647
+
648
+ :param namespace: The namespace, which is a top-level grouping of service accounts.
649
+ :param service: The name of the service, which must be unique within its namespace.
650
+ :param name: A comma-separated list of token names to evict from the service
651
+ account token caches. Use a wildcard (`*`) to evict all tokens that belong
652
+ to a service account. It does not support other wildcard patterns.
653
+ """
654
+ if namespace in SKIP_IN_PATH:
655
+ raise ValueError("Empty value passed for parameter 'namespace'")
656
+ if service in SKIP_IN_PATH:
657
+ raise ValueError("Empty value passed for parameter 'service'")
658
+ if name in SKIP_IN_PATH:
659
+ raise ValueError("Empty value passed for parameter 'name'")
660
+ __path_parts: t.Dict[str, str] = {
661
+ "namespace": _quote(namespace),
662
+ "service": _quote(service),
663
+ "name": _quote(name),
664
+ }
665
+ __path = f'/_security/service/{__path_parts["namespace"]}/{__path_parts["service"]}/credential/token/{__path_parts["name"]}/_clear_cache'
666
+ __query: t.Dict[str, t.Any] = {}
667
+ if error_trace is not None:
668
+ __query["error_trace"] = error_trace
669
+ if filter_path is not None:
670
+ __query["filter_path"] = filter_path
671
+ if human is not None:
672
+ __query["human"] = human
673
+ if pretty is not None:
674
+ __query["pretty"] = pretty
675
+ __headers = {"accept": "application/json"}
676
+ return await self.perform_request( # type: ignore[return-value]
677
+ "POST",
678
+ __path,
679
+ params=__query,
680
+ headers=__headers,
681
+ endpoint_id="security.clear_cached_service_tokens",
682
+ path_parts=__path_parts,
683
+ )
684
+
685
+ @_rewrite_parameters(
686
+ body_fields=("expiration", "metadata", "name", "role_descriptors"),
687
+ )
688
+ async def create_api_key(
689
+ self,
690
+ *,
691
+ error_trace: t.Optional[bool] = None,
692
+ expiration: t.Optional[t.Union[str, t.Literal[-1], t.Literal[0]]] = None,
693
+ filter_path: t.Optional[t.Union[str, t.Sequence[str]]] = None,
694
+ human: t.Optional[bool] = None,
695
+ metadata: t.Optional[t.Mapping[str, t.Any]] = None,
696
+ name: t.Optional[str] = None,
697
+ pretty: t.Optional[bool] = None,
698
+ refresh: t.Optional[
699
+ t.Union[bool, str, t.Literal["false", "true", "wait_for"]]
700
+ ] = None,
701
+ role_descriptors: t.Optional[t.Mapping[str, t.Mapping[str, t.Any]]] = None,
702
+ body: t.Optional[t.Dict[str, t.Any]] = None,
703
+ ) -> ObjectApiResponse[t.Any]:
704
+ """
705
+ .. raw:: html
706
+
707
+ <p>Create an API key.</p>
708
+ <p>Create an API key for access without requiring basic authentication.</p>
709
+ <p>IMPORTANT: If the credential that is used to authenticate this request is an API key, the derived API key cannot have any privileges.
710
+ If you specify privileges, the API returns an error.</p>
711
+ <p>A successful request returns a JSON structure that contains the API key, its unique id, and its name.
712
+ If applicable, it also returns expiration information for the API key in milliseconds.</p>
713
+ <p>NOTE: By default, API keys never expire. You can specify expiration information when you create the API keys.</p>
714
+ <p>The API keys are created by the Elasticsearch API key service, which is automatically enabled.
715
+ To configure or turn off the API key service, refer to API key service setting documentation.</p>
716
+
717
+
718
+ `<https://www.elastic.co/docs/api/doc/elasticsearch/v9/operation/operation-security-create-api-key>`_
719
+
720
+ :param expiration: The expiration time for the API key. By default, API keys
721
+ never expire.
722
+ :param metadata: Arbitrary metadata that you want to associate with the API key.
723
+ It supports nested data structure. Within the metadata object, keys beginning
724
+ with `_` are reserved for system usage.
725
+ :param name: A name for the API key.
726
+ :param refresh: If `true` (the default) then refresh the affected shards to make
727
+ this operation visible to search, if `wait_for` then wait for a refresh to
728
+ make this operation visible to search, if `false` then do nothing with refreshes.
729
+ :param role_descriptors: An array of role descriptors for this API key. When
730
+ it is not specified or it is an empty array, the API key will have a point
731
+ in time snapshot of permissions of the authenticated user. If you supply
732
+ role descriptors, the resultant permissions are an intersection of API keys
733
+ permissions and the authenticated user's permissions thereby limiting the
734
+ access scope for API keys. The structure of role descriptor is the same as
735
+ the request for the create role API. For more details, refer to the create
736
+ or update roles API. NOTE: Due to the way in which this permission intersection
737
+ is calculated, it is not possible to create an API key that is a child of
738
+ another API key, unless the derived key is created without any privileges.
739
+ In this case, you must explicitly specify a role descriptor with no privileges.
740
+ The derived API key can be used for authentication; it will not have authority
741
+ to call Elasticsearch APIs.
742
+ """
743
+ __path_parts: t.Dict[str, str] = {}
744
+ __path = "/_security/api_key"
745
+ __query: t.Dict[str, t.Any] = {}
746
+ __body: t.Dict[str, t.Any] = body if body is not None else {}
747
+ if error_trace is not None:
748
+ __query["error_trace"] = error_trace
749
+ if filter_path is not None:
750
+ __query["filter_path"] = filter_path
751
+ if human is not None:
752
+ __query["human"] = human
753
+ if pretty is not None:
754
+ __query["pretty"] = pretty
755
+ if refresh is not None:
756
+ __query["refresh"] = refresh
757
+ if not __body:
758
+ if expiration is not None:
759
+ __body["expiration"] = expiration
760
+ if metadata is not None:
761
+ __body["metadata"] = metadata
762
+ if name is not None:
763
+ __body["name"] = name
764
+ if role_descriptors is not None:
765
+ __body["role_descriptors"] = role_descriptors
766
+ __headers = {"accept": "application/json", "content-type": "application/json"}
767
+ return await self.perform_request( # type: ignore[return-value]
768
+ "PUT",
769
+ __path,
770
+ params=__query,
771
+ headers=__headers,
772
+ body=__body,
773
+ endpoint_id="security.create_api_key",
774
+ path_parts=__path_parts,
775
+ )
776
+
777
+ @_rewrite_parameters(
778
+ body_fields=("access", "name", "expiration", "metadata"),
779
+ )
780
+ async def create_cross_cluster_api_key(
781
+ self,
782
+ *,
783
+ access: t.Optional[t.Mapping[str, t.Any]] = None,
784
+ name: t.Optional[str] = None,
785
+ error_trace: t.Optional[bool] = None,
786
+ expiration: t.Optional[t.Union[str, t.Literal[-1], t.Literal[0]]] = None,
787
+ filter_path: t.Optional[t.Union[str, t.Sequence[str]]] = None,
788
+ human: t.Optional[bool] = None,
789
+ metadata: t.Optional[t.Mapping[str, t.Any]] = None,
790
+ pretty: t.Optional[bool] = None,
791
+ body: t.Optional[t.Dict[str, t.Any]] = None,
792
+ ) -> ObjectApiResponse[t.Any]:
793
+ """
794
+ .. raw:: html
795
+
796
+ <p>Create a cross-cluster API key.</p>
797
+ <p>Create an API key of the <code>cross_cluster</code> type for the API key based remote cluster access.
798
+ A <code>cross_cluster</code> API key cannot be used to authenticate through the REST interface.</p>
799
+ <p>IMPORTANT: To authenticate this request you must use a credential that is not an API key. Even if you use an API key that has the required privilege, the API returns an error.</p>
800
+ <p>Cross-cluster API keys are created by the Elasticsearch API key service, which is automatically enabled.</p>
801
+ <p>NOTE: Unlike REST API keys, a cross-cluster API key does not capture permissions of the authenticated user. The API key’s effective permission is exactly as specified with the <code>access</code> property.</p>
802
+ <p>A successful request returns a JSON structure that contains the API key, its unique ID, and its name. If applicable, it also returns expiration information for the API key in milliseconds.</p>
803
+ <p>By default, API keys never expire. You can specify expiration information when you create the API keys.</p>
804
+ <p>Cross-cluster API keys can only be updated with the update cross-cluster API key API.
805
+ Attempting to update them with the update REST API key API or the bulk update REST API keys API will result in an error.</p>
806
+
807
+
808
+ `<https://www.elastic.co/docs/api/doc/elasticsearch/v9/operation/operation-security-create-cross-cluster-api-key>`_
809
+
810
+ :param access: The access to be granted to this API key. The access is composed
811
+ of permissions for cross-cluster search and cross-cluster replication. At
812
+ least one of them must be specified. NOTE: No explicit privileges should
813
+ be specified for either search or replication access. The creation process
814
+ automatically converts the access specification to a role descriptor which
815
+ has relevant privileges assigned accordingly.
816
+ :param name: Specifies the name for this API key.
817
+ :param expiration: Expiration time for the API key. By default, API keys never
818
+ expire.
819
+ :param metadata: Arbitrary metadata that you want to associate with the API key.
820
+ It supports nested data structure. Within the metadata object, keys beginning
821
+ with `_` are reserved for system usage.
822
+ """
823
+ if access is None and body is None:
824
+ raise ValueError("Empty value passed for parameter 'access'")
825
+ if name is None and body is None:
826
+ raise ValueError("Empty value passed for parameter 'name'")
827
+ __path_parts: t.Dict[str, str] = {}
828
+ __path = "/_security/cross_cluster/api_key"
829
+ __query: t.Dict[str, t.Any] = {}
830
+ __body: t.Dict[str, t.Any] = body if body is not None else {}
831
+ if error_trace is not None:
832
+ __query["error_trace"] = error_trace
833
+ if filter_path is not None:
834
+ __query["filter_path"] = filter_path
835
+ if human is not None:
836
+ __query["human"] = human
837
+ if pretty is not None:
838
+ __query["pretty"] = pretty
839
+ if not __body:
840
+ if access is not None:
841
+ __body["access"] = access
842
+ if name is not None:
843
+ __body["name"] = name
844
+ if expiration is not None:
845
+ __body["expiration"] = expiration
846
+ if metadata is not None:
847
+ __body["metadata"] = metadata
848
+ __headers = {"accept": "application/json", "content-type": "application/json"}
849
+ return await self.perform_request( # type: ignore[return-value]
850
+ "POST",
851
+ __path,
852
+ params=__query,
853
+ headers=__headers,
854
+ body=__body,
855
+ endpoint_id="security.create_cross_cluster_api_key",
856
+ path_parts=__path_parts,
857
+ )
858
+
859
+ @_rewrite_parameters()
860
+ async def create_service_token(
861
+ self,
862
+ *,
863
+ namespace: str,
864
+ service: str,
865
+ name: t.Optional[str] = None,
866
+ error_trace: t.Optional[bool] = None,
867
+ filter_path: t.Optional[t.Union[str, t.Sequence[str]]] = None,
868
+ human: t.Optional[bool] = None,
869
+ pretty: t.Optional[bool] = None,
870
+ refresh: t.Optional[
871
+ t.Union[bool, str, t.Literal["false", "true", "wait_for"]]
872
+ ] = None,
873
+ ) -> ObjectApiResponse[t.Any]:
874
+ """
875
+ .. raw:: html
876
+
877
+ <p>Create a service account token.</p>
878
+ <p>Create a service accounts token for access without requiring basic authentication.</p>
879
+ <p>NOTE: Service account tokens never expire.
880
+ You must actively delete them if they are no longer needed.</p>
881
+
882
+
883
+ `<https://www.elastic.co/docs/api/doc/elasticsearch/v9/operation/operation-security-create-service-token>`_
884
+
885
+ :param namespace: The name of the namespace, which is a top-level grouping of
886
+ service accounts.
887
+ :param service: The name of the service.
888
+ :param name: The name for the service account token. If omitted, a random name
889
+ will be generated. Token names must be at least one and no more than 256
890
+ characters. They can contain alphanumeric characters (a-z, A-Z, 0-9), dashes
891
+ (`-`), and underscores (`_`), but cannot begin with an underscore. NOTE:
892
+ Token names must be unique in the context of the associated service account.
893
+ They must also be globally unique with their fully qualified names, which
894
+ are comprised of the service account principal and token name, such as `<namespace>/<service>/<token-name>`.
895
+ :param refresh: If `true` then refresh the affected shards to make this operation
896
+ visible to search, if `wait_for` (the default) then wait for a refresh to
897
+ make this operation visible to search, if `false` then do nothing with refreshes.
898
+ """
899
+ if namespace in SKIP_IN_PATH:
900
+ raise ValueError("Empty value passed for parameter 'namespace'")
901
+ if service in SKIP_IN_PATH:
902
+ raise ValueError("Empty value passed for parameter 'service'")
903
+ __path_parts: t.Dict[str, str]
904
+ if (
905
+ namespace not in SKIP_IN_PATH
906
+ and service not in SKIP_IN_PATH
907
+ and name not in SKIP_IN_PATH
908
+ ):
909
+ __path_parts = {
910
+ "namespace": _quote(namespace),
911
+ "service": _quote(service),
912
+ "name": _quote(name),
913
+ }
914
+ __path = f'/_security/service/{__path_parts["namespace"]}/{__path_parts["service"]}/credential/token/{__path_parts["name"]}'
915
+ __method = "PUT"
916
+ elif namespace not in SKIP_IN_PATH and service not in SKIP_IN_PATH:
917
+ __path_parts = {"namespace": _quote(namespace), "service": _quote(service)}
918
+ __path = f'/_security/service/{__path_parts["namespace"]}/{__path_parts["service"]}/credential/token'
919
+ __method = "POST"
920
+ else:
921
+ raise ValueError("Couldn't find a path for the given parameters")
922
+ __query: t.Dict[str, t.Any] = {}
923
+ if error_trace is not None:
924
+ __query["error_trace"] = error_trace
925
+ if filter_path is not None:
926
+ __query["filter_path"] = filter_path
927
+ if human is not None:
928
+ __query["human"] = human
929
+ if pretty is not None:
930
+ __query["pretty"] = pretty
931
+ if refresh is not None:
932
+ __query["refresh"] = refresh
933
+ __headers = {"accept": "application/json"}
934
+ return await self.perform_request( # type: ignore[return-value]
935
+ __method,
936
+ __path,
937
+ params=__query,
938
+ headers=__headers,
939
+ endpoint_id="security.create_service_token",
940
+ path_parts=__path_parts,
941
+ )
942
+
943
+ @_rewrite_parameters(
944
+ body_fields=("x509_certificate_chain",),
945
+ )
946
+ async def delegate_pki(
947
+ self,
948
+ *,
949
+ x509_certificate_chain: t.Optional[t.Sequence[str]] = None,
950
+ error_trace: t.Optional[bool] = None,
951
+ filter_path: t.Optional[t.Union[str, t.Sequence[str]]] = None,
952
+ human: t.Optional[bool] = None,
953
+ pretty: t.Optional[bool] = None,
954
+ body: t.Optional[t.Dict[str, t.Any]] = None,
955
+ ) -> ObjectApiResponse[t.Any]:
956
+ """
957
+ .. raw:: html
958
+
959
+ <p>Delegate PKI authentication.</p>
960
+ <p>This API implements the exchange of an X509Certificate chain for an Elasticsearch access token.
961
+ The certificate chain is validated, according to RFC 5280, by sequentially considering the trust configuration of every installed PKI realm that has <code>delegation.enabled</code> set to <code>true</code>.
962
+ A successfully trusted client certificate is also subject to the validation of the subject distinguished name according to thw <code>username_pattern</code> of the respective realm.</p>
963
+ <p>This API is called by smart and trusted proxies, such as Kibana, which terminate the user's TLS session but still want to authenticate the user by using a PKI realm—-​as if the user connected directly to Elasticsearch.</p>
964
+ <p>IMPORTANT: The association between the subject public key in the target certificate and the corresponding private key is not validated.
965
+ This is part of the TLS authentication process and it is delegated to the proxy that calls this API.
966
+ The proxy is trusted to have performed the TLS authentication and this API translates that authentication into an Elasticsearch access token.</p>
967
+
968
+
969
+ `<https://www.elastic.co/docs/api/doc/elasticsearch/v9/operation/operation-security-delegate-pki>`_
970
+
971
+ :param x509_certificate_chain: The X509Certificate chain, which is represented
972
+ as an ordered string array. Each string in the array is a base64-encoded
973
+ (Section 4 of RFC4648 - not base64url-encoded) of the certificate's DER encoding.
974
+ The first element is the target certificate that contains the subject distinguished
975
+ name that is requesting access. This may be followed by additional certificates;
976
+ each subsequent certificate is used to certify the previous one.
977
+ """
978
+ if x509_certificate_chain is None and body is None:
979
+ raise ValueError(
980
+ "Empty value passed for parameter 'x509_certificate_chain'"
981
+ )
982
+ __path_parts: t.Dict[str, str] = {}
983
+ __path = "/_security/delegate_pki"
984
+ __query: t.Dict[str, t.Any] = {}
985
+ __body: t.Dict[str, t.Any] = body if body is not None else {}
986
+ if error_trace is not None:
987
+ __query["error_trace"] = error_trace
988
+ if filter_path is not None:
989
+ __query["filter_path"] = filter_path
990
+ if human is not None:
991
+ __query["human"] = human
992
+ if pretty is not None:
993
+ __query["pretty"] = pretty
994
+ if not __body:
995
+ if x509_certificate_chain is not None:
996
+ __body["x509_certificate_chain"] = x509_certificate_chain
997
+ __headers = {"accept": "application/json", "content-type": "application/json"}
998
+ return await self.perform_request( # type: ignore[return-value]
999
+ "POST",
1000
+ __path,
1001
+ params=__query,
1002
+ headers=__headers,
1003
+ body=__body,
1004
+ endpoint_id="security.delegate_pki",
1005
+ path_parts=__path_parts,
1006
+ )
1007
+
1008
+ @_rewrite_parameters()
1009
+ async def delete_privileges(
1010
+ self,
1011
+ *,
1012
+ application: str,
1013
+ name: t.Union[str, t.Sequence[str]],
1014
+ error_trace: t.Optional[bool] = None,
1015
+ filter_path: t.Optional[t.Union[str, t.Sequence[str]]] = None,
1016
+ human: t.Optional[bool] = None,
1017
+ pretty: t.Optional[bool] = None,
1018
+ refresh: t.Optional[
1019
+ t.Union[bool, str, t.Literal["false", "true", "wait_for"]]
1020
+ ] = None,
1021
+ ) -> ObjectApiResponse[t.Any]:
1022
+ """
1023
+ .. raw:: html
1024
+
1025
+ <p>Delete application privileges.</p>
1026
+ <p>To use this API, you must have one of the following privileges:</p>
1027
+ <ul>
1028
+ <li>The <code>manage_security</code> cluster privilege (or a greater privilege such as <code>all</code>).</li>
1029
+ <li>The &quot;Manage Application Privileges&quot; global privilege for the application being referenced in the request.</li>
1030
+ </ul>
1031
+
1032
+
1033
+ `<https://www.elastic.co/docs/api/doc/elasticsearch/v9/operation/operation-security-delete-privileges>`_
1034
+
1035
+ :param application: The name of the application. Application privileges are always
1036
+ associated with exactly one application.
1037
+ :param name: The name of the privilege.
1038
+ :param refresh: If `true` (the default) then refresh the affected shards to make
1039
+ this operation visible to search, if `wait_for` then wait for a refresh to
1040
+ make this operation visible to search, if `false` then do nothing with refreshes.
1041
+ """
1042
+ if application in SKIP_IN_PATH:
1043
+ raise ValueError("Empty value passed for parameter 'application'")
1044
+ if name in SKIP_IN_PATH:
1045
+ raise ValueError("Empty value passed for parameter 'name'")
1046
+ __path_parts: t.Dict[str, str] = {
1047
+ "application": _quote(application),
1048
+ "name": _quote(name),
1049
+ }
1050
+ __path = (
1051
+ f'/_security/privilege/{__path_parts["application"]}/{__path_parts["name"]}'
1052
+ )
1053
+ __query: t.Dict[str, t.Any] = {}
1054
+ if error_trace is not None:
1055
+ __query["error_trace"] = error_trace
1056
+ if filter_path is not None:
1057
+ __query["filter_path"] = filter_path
1058
+ if human is not None:
1059
+ __query["human"] = human
1060
+ if pretty is not None:
1061
+ __query["pretty"] = pretty
1062
+ if refresh is not None:
1063
+ __query["refresh"] = refresh
1064
+ __headers = {"accept": "application/json"}
1065
+ return await self.perform_request( # type: ignore[return-value]
1066
+ "DELETE",
1067
+ __path,
1068
+ params=__query,
1069
+ headers=__headers,
1070
+ endpoint_id="security.delete_privileges",
1071
+ path_parts=__path_parts,
1072
+ )
1073
+
1074
+ @_rewrite_parameters()
1075
+ async def delete_role(
1076
+ self,
1077
+ *,
1078
+ name: str,
1079
+ error_trace: t.Optional[bool] = None,
1080
+ filter_path: t.Optional[t.Union[str, t.Sequence[str]]] = None,
1081
+ human: t.Optional[bool] = None,
1082
+ pretty: t.Optional[bool] = None,
1083
+ refresh: t.Optional[
1084
+ t.Union[bool, str, t.Literal["false", "true", "wait_for"]]
1085
+ ] = None,
1086
+ ) -> ObjectApiResponse[t.Any]:
1087
+ """
1088
+ .. raw:: html
1089
+
1090
+ <p>Delete roles.</p>
1091
+ <p>Delete roles in the native realm.
1092
+ The role management APIs are generally the preferred way to manage roles, rather than using file-based role management.
1093
+ The delete roles API cannot remove roles that are defined in roles files.</p>
1094
+
1095
+
1096
+ `<https://www.elastic.co/docs/api/doc/elasticsearch/v9/operation/operation-security-delete-role>`_
1097
+
1098
+ :param name: The name of the role.
1099
+ :param refresh: If `true` (the default) then refresh the affected shards to make
1100
+ this operation visible to search, if `wait_for` then wait for a refresh to
1101
+ make this operation visible to search, if `false` then do nothing with refreshes.
1102
+ """
1103
+ if name in SKIP_IN_PATH:
1104
+ raise ValueError("Empty value passed for parameter 'name'")
1105
+ __path_parts: t.Dict[str, str] = {"name": _quote(name)}
1106
+ __path = f'/_security/role/{__path_parts["name"]}'
1107
+ __query: t.Dict[str, t.Any] = {}
1108
+ if error_trace is not None:
1109
+ __query["error_trace"] = error_trace
1110
+ if filter_path is not None:
1111
+ __query["filter_path"] = filter_path
1112
+ if human is not None:
1113
+ __query["human"] = human
1114
+ if pretty is not None:
1115
+ __query["pretty"] = pretty
1116
+ if refresh is not None:
1117
+ __query["refresh"] = refresh
1118
+ __headers = {"accept": "application/json"}
1119
+ return await self.perform_request( # type: ignore[return-value]
1120
+ "DELETE",
1121
+ __path,
1122
+ params=__query,
1123
+ headers=__headers,
1124
+ endpoint_id="security.delete_role",
1125
+ path_parts=__path_parts,
1126
+ )
1127
+
1128
+ @_rewrite_parameters()
1129
+ async def delete_role_mapping(
1130
+ self,
1131
+ *,
1132
+ name: str,
1133
+ error_trace: t.Optional[bool] = None,
1134
+ filter_path: t.Optional[t.Union[str, t.Sequence[str]]] = None,
1135
+ human: t.Optional[bool] = None,
1136
+ pretty: t.Optional[bool] = None,
1137
+ refresh: t.Optional[
1138
+ t.Union[bool, str, t.Literal["false", "true", "wait_for"]]
1139
+ ] = None,
1140
+ ) -> ObjectApiResponse[t.Any]:
1141
+ """
1142
+ .. raw:: html
1143
+
1144
+ <p>Delete role mappings.</p>
1145
+ <p>Role mappings define which roles are assigned to each user.
1146
+ The role mapping APIs are generally the preferred way to manage role mappings rather than using role mapping files.
1147
+ The delete role mappings API cannot remove role mappings that are defined in role mapping files.</p>
1148
+
1149
+
1150
+ `<https://www.elastic.co/docs/api/doc/elasticsearch/v9/operation/operation-security-delete-role-mapping>`_
1151
+
1152
+ :param name: The distinct name that identifies the role mapping. The name is
1153
+ used solely as an identifier to facilitate interaction via the API; it does
1154
+ not affect the behavior of the mapping in any way.
1155
+ :param refresh: If `true` (the default) then refresh the affected shards to make
1156
+ this operation visible to search, if `wait_for` then wait for a refresh to
1157
+ make this operation visible to search, if `false` then do nothing with refreshes.
1158
+ """
1159
+ if name in SKIP_IN_PATH:
1160
+ raise ValueError("Empty value passed for parameter 'name'")
1161
+ __path_parts: t.Dict[str, str] = {"name": _quote(name)}
1162
+ __path = f'/_security/role_mapping/{__path_parts["name"]}'
1163
+ __query: t.Dict[str, t.Any] = {}
1164
+ if error_trace is not None:
1165
+ __query["error_trace"] = error_trace
1166
+ if filter_path is not None:
1167
+ __query["filter_path"] = filter_path
1168
+ if human is not None:
1169
+ __query["human"] = human
1170
+ if pretty is not None:
1171
+ __query["pretty"] = pretty
1172
+ if refresh is not None:
1173
+ __query["refresh"] = refresh
1174
+ __headers = {"accept": "application/json"}
1175
+ return await self.perform_request( # type: ignore[return-value]
1176
+ "DELETE",
1177
+ __path,
1178
+ params=__query,
1179
+ headers=__headers,
1180
+ endpoint_id="security.delete_role_mapping",
1181
+ path_parts=__path_parts,
1182
+ )
1183
+
1184
+ @_rewrite_parameters()
1185
+ async def delete_service_token(
1186
+ self,
1187
+ *,
1188
+ namespace: str,
1189
+ service: str,
1190
+ name: str,
1191
+ error_trace: t.Optional[bool] = None,
1192
+ filter_path: t.Optional[t.Union[str, t.Sequence[str]]] = None,
1193
+ human: t.Optional[bool] = None,
1194
+ pretty: t.Optional[bool] = None,
1195
+ refresh: t.Optional[
1196
+ t.Union[bool, str, t.Literal["false", "true", "wait_for"]]
1197
+ ] = None,
1198
+ ) -> ObjectApiResponse[t.Any]:
1199
+ """
1200
+ .. raw:: html
1201
+
1202
+ <p>Delete service account tokens.</p>
1203
+ <p>Delete service account tokens for a service in a specified namespace.</p>
1204
+
1205
+
1206
+ `<https://www.elastic.co/docs/api/doc/elasticsearch/v9/operation/operation-security-delete-service-token>`_
1207
+
1208
+ :param namespace: The namespace, which is a top-level grouping of service accounts.
1209
+ :param service: The service name.
1210
+ :param name: The name of the service account token.
1211
+ :param refresh: If `true` then refresh the affected shards to make this operation
1212
+ visible to search, if `wait_for` (the default) then wait for a refresh to
1213
+ make this operation visible to search, if `false` then do nothing with refreshes.
1214
+ """
1215
+ if namespace in SKIP_IN_PATH:
1216
+ raise ValueError("Empty value passed for parameter 'namespace'")
1217
+ if service in SKIP_IN_PATH:
1218
+ raise ValueError("Empty value passed for parameter 'service'")
1219
+ if name in SKIP_IN_PATH:
1220
+ raise ValueError("Empty value passed for parameter 'name'")
1221
+ __path_parts: t.Dict[str, str] = {
1222
+ "namespace": _quote(namespace),
1223
+ "service": _quote(service),
1224
+ "name": _quote(name),
1225
+ }
1226
+ __path = f'/_security/service/{__path_parts["namespace"]}/{__path_parts["service"]}/credential/token/{__path_parts["name"]}'
1227
+ __query: t.Dict[str, t.Any] = {}
1228
+ if error_trace is not None:
1229
+ __query["error_trace"] = error_trace
1230
+ if filter_path is not None:
1231
+ __query["filter_path"] = filter_path
1232
+ if human is not None:
1233
+ __query["human"] = human
1234
+ if pretty is not None:
1235
+ __query["pretty"] = pretty
1236
+ if refresh is not None:
1237
+ __query["refresh"] = refresh
1238
+ __headers = {"accept": "application/json"}
1239
+ return await self.perform_request( # type: ignore[return-value]
1240
+ "DELETE",
1241
+ __path,
1242
+ params=__query,
1243
+ headers=__headers,
1244
+ endpoint_id="security.delete_service_token",
1245
+ path_parts=__path_parts,
1246
+ )
1247
+
1248
+ @_rewrite_parameters()
1249
+ async def delete_user(
1250
+ self,
1251
+ *,
1252
+ username: str,
1253
+ error_trace: t.Optional[bool] = None,
1254
+ filter_path: t.Optional[t.Union[str, t.Sequence[str]]] = None,
1255
+ human: t.Optional[bool] = None,
1256
+ pretty: t.Optional[bool] = None,
1257
+ refresh: t.Optional[
1258
+ t.Union[bool, str, t.Literal["false", "true", "wait_for"]]
1259
+ ] = None,
1260
+ ) -> ObjectApiResponse[t.Any]:
1261
+ """
1262
+ .. raw:: html
1263
+
1264
+ <p>Delete users.</p>
1265
+ <p>Delete users from the native realm.</p>
1266
+
1267
+
1268
+ `<https://www.elastic.co/docs/api/doc/elasticsearch/v9/operation/operation-security-delete-user>`_
1269
+
1270
+ :param username: An identifier for the user.
1271
+ :param refresh: If `true` (the default) then refresh the affected shards to make
1272
+ this operation visible to search, if `wait_for` then wait for a refresh to
1273
+ make this operation visible to search, if `false` then do nothing with refreshes.
1274
+ """
1275
+ if username in SKIP_IN_PATH:
1276
+ raise ValueError("Empty value passed for parameter 'username'")
1277
+ __path_parts: t.Dict[str, str] = {"username": _quote(username)}
1278
+ __path = f'/_security/user/{__path_parts["username"]}'
1279
+ __query: t.Dict[str, t.Any] = {}
1280
+ if error_trace is not None:
1281
+ __query["error_trace"] = error_trace
1282
+ if filter_path is not None:
1283
+ __query["filter_path"] = filter_path
1284
+ if human is not None:
1285
+ __query["human"] = human
1286
+ if pretty is not None:
1287
+ __query["pretty"] = pretty
1288
+ if refresh is not None:
1289
+ __query["refresh"] = refresh
1290
+ __headers = {"accept": "application/json"}
1291
+ return await self.perform_request( # type: ignore[return-value]
1292
+ "DELETE",
1293
+ __path,
1294
+ params=__query,
1295
+ headers=__headers,
1296
+ endpoint_id="security.delete_user",
1297
+ path_parts=__path_parts,
1298
+ )
1299
+
1300
+ @_rewrite_parameters()
1301
+ async def disable_user(
1302
+ self,
1303
+ *,
1304
+ username: str,
1305
+ error_trace: t.Optional[bool] = None,
1306
+ filter_path: t.Optional[t.Union[str, t.Sequence[str]]] = None,
1307
+ human: t.Optional[bool] = None,
1308
+ pretty: t.Optional[bool] = None,
1309
+ refresh: t.Optional[
1310
+ t.Union[bool, str, t.Literal["false", "true", "wait_for"]]
1311
+ ] = None,
1312
+ ) -> ObjectApiResponse[t.Any]:
1313
+ """
1314
+ .. raw:: html
1315
+
1316
+ <p>Disable users.</p>
1317
+ <p>Disable users in the native realm.
1318
+ By default, when you create users, they are enabled.
1319
+ You can use this API to revoke a user's access to Elasticsearch.</p>
1320
+
1321
+
1322
+ `<https://www.elastic.co/docs/api/doc/elasticsearch/v9/operation/operation-security-disable-user>`_
1323
+
1324
+ :param username: An identifier for the user.
1325
+ :param refresh: If `true` (the default) then refresh the affected shards to make
1326
+ this operation visible to search, if `wait_for` then wait for a refresh to
1327
+ make this operation visible to search, if `false` then do nothing with refreshes.
1328
+ """
1329
+ if username in SKIP_IN_PATH:
1330
+ raise ValueError("Empty value passed for parameter 'username'")
1331
+ __path_parts: t.Dict[str, str] = {"username": _quote(username)}
1332
+ __path = f'/_security/user/{__path_parts["username"]}/_disable'
1333
+ __query: t.Dict[str, t.Any] = {}
1334
+ if error_trace is not None:
1335
+ __query["error_trace"] = error_trace
1336
+ if filter_path is not None:
1337
+ __query["filter_path"] = filter_path
1338
+ if human is not None:
1339
+ __query["human"] = human
1340
+ if pretty is not None:
1341
+ __query["pretty"] = pretty
1342
+ if refresh is not None:
1343
+ __query["refresh"] = refresh
1344
+ __headers = {"accept": "application/json"}
1345
+ return await self.perform_request( # type: ignore[return-value]
1346
+ "PUT",
1347
+ __path,
1348
+ params=__query,
1349
+ headers=__headers,
1350
+ endpoint_id="security.disable_user",
1351
+ path_parts=__path_parts,
1352
+ )
1353
+
1354
+ @_rewrite_parameters()
1355
+ async def disable_user_profile(
1356
+ self,
1357
+ *,
1358
+ uid: str,
1359
+ error_trace: t.Optional[bool] = None,
1360
+ filter_path: t.Optional[t.Union[str, t.Sequence[str]]] = None,
1361
+ human: t.Optional[bool] = None,
1362
+ pretty: t.Optional[bool] = None,
1363
+ refresh: t.Optional[
1364
+ t.Union[bool, str, t.Literal["false", "true", "wait_for"]]
1365
+ ] = None,
1366
+ ) -> ObjectApiResponse[t.Any]:
1367
+ """
1368
+ .. raw:: html
1369
+
1370
+ <p>Disable a user profile.</p>
1371
+ <p>Disable user profiles so that they are not visible in user profile searches.</p>
1372
+ <p>NOTE: The user profile feature is designed only for use by Kibana and Elastic's Observability, Enterprise Search, and Elastic Security solutions.
1373
+ Individual users and external applications should not call this API directly.
1374
+ Elastic reserves the right to change or remove this feature in future releases without prior notice.</p>
1375
+ <p>When you activate a user profile, its automatically enabled and visible in user profile searches. You can use the disable user profile API to disable a user profile so it’s not visible in these searches.
1376
+ To re-enable a disabled user profile, use the enable user profile API .</p>
1377
+
1378
+
1379
+ `<https://www.elastic.co/docs/api/doc/elasticsearch/v9/operation/operation-security-disable-user-profile>`_
1380
+
1381
+ :param uid: Unique identifier for the user profile.
1382
+ :param refresh: If 'true', Elasticsearch refreshes the affected shards to make
1383
+ this operation visible to search. If 'wait_for', it waits for a refresh to
1384
+ make this operation visible to search. If 'false', it does nothing with refreshes.
1385
+ """
1386
+ if uid in SKIP_IN_PATH:
1387
+ raise ValueError("Empty value passed for parameter 'uid'")
1388
+ __path_parts: t.Dict[str, str] = {"uid": _quote(uid)}
1389
+ __path = f'/_security/profile/{__path_parts["uid"]}/_disable'
1390
+ __query: t.Dict[str, t.Any] = {}
1391
+ if error_trace is not None:
1392
+ __query["error_trace"] = error_trace
1393
+ if filter_path is not None:
1394
+ __query["filter_path"] = filter_path
1395
+ if human is not None:
1396
+ __query["human"] = human
1397
+ if pretty is not None:
1398
+ __query["pretty"] = pretty
1399
+ if refresh is not None:
1400
+ __query["refresh"] = refresh
1401
+ __headers = {"accept": "application/json"}
1402
+ return await self.perform_request( # type: ignore[return-value]
1403
+ "PUT",
1404
+ __path,
1405
+ params=__query,
1406
+ headers=__headers,
1407
+ endpoint_id="security.disable_user_profile",
1408
+ path_parts=__path_parts,
1409
+ )
1410
+
1411
+ @_rewrite_parameters()
1412
+ async def enable_user(
1413
+ self,
1414
+ *,
1415
+ username: str,
1416
+ error_trace: t.Optional[bool] = None,
1417
+ filter_path: t.Optional[t.Union[str, t.Sequence[str]]] = None,
1418
+ human: t.Optional[bool] = None,
1419
+ pretty: t.Optional[bool] = None,
1420
+ refresh: t.Optional[
1421
+ t.Union[bool, str, t.Literal["false", "true", "wait_for"]]
1422
+ ] = None,
1423
+ ) -> ObjectApiResponse[t.Any]:
1424
+ """
1425
+ .. raw:: html
1426
+
1427
+ <p>Enable users.</p>
1428
+ <p>Enable users in the native realm.
1429
+ By default, when you create users, they are enabled.</p>
1430
+
1431
+
1432
+ `<https://www.elastic.co/docs/api/doc/elasticsearch/v9/operation/operation-security-enable-user>`_
1433
+
1434
+ :param username: An identifier for the user.
1435
+ :param refresh: If `true` (the default) then refresh the affected shards to make
1436
+ this operation visible to search, if `wait_for` then wait for a refresh to
1437
+ make this operation visible to search, if `false` then do nothing with refreshes.
1438
+ """
1439
+ if username in SKIP_IN_PATH:
1440
+ raise ValueError("Empty value passed for parameter 'username'")
1441
+ __path_parts: t.Dict[str, str] = {"username": _quote(username)}
1442
+ __path = f'/_security/user/{__path_parts["username"]}/_enable'
1443
+ __query: t.Dict[str, t.Any] = {}
1444
+ if error_trace is not None:
1445
+ __query["error_trace"] = error_trace
1446
+ if filter_path is not None:
1447
+ __query["filter_path"] = filter_path
1448
+ if human is not None:
1449
+ __query["human"] = human
1450
+ if pretty is not None:
1451
+ __query["pretty"] = pretty
1452
+ if refresh is not None:
1453
+ __query["refresh"] = refresh
1454
+ __headers = {"accept": "application/json"}
1455
+ return await self.perform_request( # type: ignore[return-value]
1456
+ "PUT",
1457
+ __path,
1458
+ params=__query,
1459
+ headers=__headers,
1460
+ endpoint_id="security.enable_user",
1461
+ path_parts=__path_parts,
1462
+ )
1463
+
1464
+ @_rewrite_parameters()
1465
+ async def enable_user_profile(
1466
+ self,
1467
+ *,
1468
+ uid: str,
1469
+ error_trace: t.Optional[bool] = None,
1470
+ filter_path: t.Optional[t.Union[str, t.Sequence[str]]] = None,
1471
+ human: t.Optional[bool] = None,
1472
+ pretty: t.Optional[bool] = None,
1473
+ refresh: t.Optional[
1474
+ t.Union[bool, str, t.Literal["false", "true", "wait_for"]]
1475
+ ] = None,
1476
+ ) -> ObjectApiResponse[t.Any]:
1477
+ """
1478
+ .. raw:: html
1479
+
1480
+ <p>Enable a user profile.</p>
1481
+ <p>Enable user profiles to make them visible in user profile searches.</p>
1482
+ <p>NOTE: The user profile feature is designed only for use by Kibana and Elastic's Observability, Enterprise Search, and Elastic Security solutions.
1483
+ Individual users and external applications should not call this API directly.
1484
+ Elastic reserves the right to change or remove this feature in future releases without prior notice.</p>
1485
+ <p>When you activate a user profile, it's automatically enabled and visible in user profile searches.
1486
+ If you later disable the user profile, you can use the enable user profile API to make the profile visible in these searches again.</p>
1487
+
1488
+
1489
+ `<https://www.elastic.co/docs/api/doc/elasticsearch/v9/operation/operation-security-enable-user-profile>`_
1490
+
1491
+ :param uid: A unique identifier for the user profile.
1492
+ :param refresh: If 'true', Elasticsearch refreshes the affected shards to make
1493
+ this operation visible to search. If 'wait_for', it waits for a refresh to
1494
+ make this operation visible to search. If 'false', nothing is done with refreshes.
1495
+ """
1496
+ if uid in SKIP_IN_PATH:
1497
+ raise ValueError("Empty value passed for parameter 'uid'")
1498
+ __path_parts: t.Dict[str, str] = {"uid": _quote(uid)}
1499
+ __path = f'/_security/profile/{__path_parts["uid"]}/_enable'
1500
+ __query: t.Dict[str, t.Any] = {}
1501
+ if error_trace is not None:
1502
+ __query["error_trace"] = error_trace
1503
+ if filter_path is not None:
1504
+ __query["filter_path"] = filter_path
1505
+ if human is not None:
1506
+ __query["human"] = human
1507
+ if pretty is not None:
1508
+ __query["pretty"] = pretty
1509
+ if refresh is not None:
1510
+ __query["refresh"] = refresh
1511
+ __headers = {"accept": "application/json"}
1512
+ return await self.perform_request( # type: ignore[return-value]
1513
+ "PUT",
1514
+ __path,
1515
+ params=__query,
1516
+ headers=__headers,
1517
+ endpoint_id="security.enable_user_profile",
1518
+ path_parts=__path_parts,
1519
+ )
1520
+
1521
+ @_rewrite_parameters()
1522
+ async def enroll_kibana(
1523
+ self,
1524
+ *,
1525
+ error_trace: t.Optional[bool] = None,
1526
+ filter_path: t.Optional[t.Union[str, t.Sequence[str]]] = None,
1527
+ human: t.Optional[bool] = None,
1528
+ pretty: t.Optional[bool] = None,
1529
+ ) -> ObjectApiResponse[t.Any]:
1530
+ """
1531
+ .. raw:: html
1532
+
1533
+ <p>Enroll Kibana.</p>
1534
+ <p>Enable a Kibana instance to configure itself for communication with a secured Elasticsearch cluster.</p>
1535
+ <p>NOTE: This API is currently intended for internal use only by Kibana.
1536
+ Kibana uses this API internally to configure itself for communications with an Elasticsearch cluster that already has security features enabled.</p>
1537
+
1538
+
1539
+ `<https://www.elastic.co/docs/api/doc/elasticsearch/v9/operation/operation-security-enroll-kibana>`_
1540
+ """
1541
+ __path_parts: t.Dict[str, str] = {}
1542
+ __path = "/_security/enroll/kibana"
1543
+ __query: t.Dict[str, t.Any] = {}
1544
+ if error_trace is not None:
1545
+ __query["error_trace"] = error_trace
1546
+ if filter_path is not None:
1547
+ __query["filter_path"] = filter_path
1548
+ if human is not None:
1549
+ __query["human"] = human
1550
+ if pretty is not None:
1551
+ __query["pretty"] = pretty
1552
+ __headers = {"accept": "application/json"}
1553
+ return await self.perform_request( # type: ignore[return-value]
1554
+ "GET",
1555
+ __path,
1556
+ params=__query,
1557
+ headers=__headers,
1558
+ endpoint_id="security.enroll_kibana",
1559
+ path_parts=__path_parts,
1560
+ )
1561
+
1562
+ @_rewrite_parameters()
1563
+ async def enroll_node(
1564
+ self,
1565
+ *,
1566
+ error_trace: t.Optional[bool] = None,
1567
+ filter_path: t.Optional[t.Union[str, t.Sequence[str]]] = None,
1568
+ human: t.Optional[bool] = None,
1569
+ pretty: t.Optional[bool] = None,
1570
+ ) -> ObjectApiResponse[t.Any]:
1571
+ """
1572
+ .. raw:: html
1573
+
1574
+ <p>Enroll a node.</p>
1575
+ <p>Enroll a new node to allow it to join an existing cluster with security features enabled.</p>
1576
+ <p>The response contains all the necessary information for the joining node to bootstrap discovery and security related settings so that it can successfully join the cluster.
1577
+ The response contains key and certificate material that allows the caller to generate valid signed certificates for the HTTP layer of all nodes in the cluster.</p>
1578
+
1579
+
1580
+ `<https://www.elastic.co/docs/api/doc/elasticsearch/v9/operation/operation-security-enroll-node>`_
1581
+ """
1582
+ __path_parts: t.Dict[str, str] = {}
1583
+ __path = "/_security/enroll/node"
1584
+ __query: t.Dict[str, t.Any] = {}
1585
+ if error_trace is not None:
1586
+ __query["error_trace"] = error_trace
1587
+ if filter_path is not None:
1588
+ __query["filter_path"] = filter_path
1589
+ if human is not None:
1590
+ __query["human"] = human
1591
+ if pretty is not None:
1592
+ __query["pretty"] = pretty
1593
+ __headers = {"accept": "application/json"}
1594
+ return await self.perform_request( # type: ignore[return-value]
1595
+ "GET",
1596
+ __path,
1597
+ params=__query,
1598
+ headers=__headers,
1599
+ endpoint_id="security.enroll_node",
1600
+ path_parts=__path_parts,
1601
+ )
1602
+
1603
+ @_rewrite_parameters()
1604
+ async def get_api_key(
1605
+ self,
1606
+ *,
1607
+ active_only: t.Optional[bool] = None,
1608
+ error_trace: t.Optional[bool] = None,
1609
+ filter_path: t.Optional[t.Union[str, t.Sequence[str]]] = None,
1610
+ human: t.Optional[bool] = None,
1611
+ id: t.Optional[str] = None,
1612
+ name: t.Optional[str] = None,
1613
+ owner: t.Optional[bool] = None,
1614
+ pretty: t.Optional[bool] = None,
1615
+ realm_name: t.Optional[str] = None,
1616
+ username: t.Optional[str] = None,
1617
+ with_limited_by: t.Optional[bool] = None,
1618
+ with_profile_uid: t.Optional[bool] = None,
1619
+ ) -> ObjectApiResponse[t.Any]:
1620
+ """
1621
+ .. raw:: html
1622
+
1623
+ <p>Get API key information.</p>
1624
+ <p>Retrieves information for one or more API keys.
1625
+ NOTE: If you have only the <code>manage_own_api_key</code> privilege, this API returns only the API keys that you own.
1626
+ If you have <code>read_security</code>, <code>manage_api_key</code> or greater privileges (including <code>manage_security</code>), this API returns all API keys regardless of ownership.</p>
1627
+
1628
+
1629
+ `<https://www.elastic.co/docs/api/doc/elasticsearch/v9/operation/operation-security-get-api-key>`_
1630
+
1631
+ :param active_only: A boolean flag that can be used to query API keys that are
1632
+ currently active. An API key is considered active if it is neither invalidated,
1633
+ nor expired at query time. You can specify this together with other parameters
1634
+ such as `owner` or `name`. If `active_only` is false, the response will include
1635
+ both active and inactive (expired or invalidated) keys.
1636
+ :param id: An API key id. This parameter cannot be used with any of `name`, `realm_name`
1637
+ or `username`.
1638
+ :param name: An API key name. This parameter cannot be used with any of `id`,
1639
+ `realm_name` or `username`. It supports prefix search with wildcard.
1640
+ :param owner: A boolean flag that can be used to query API keys owned by the
1641
+ currently authenticated user. The `realm_name` or `username` parameters cannot
1642
+ be specified when this parameter is set to `true` as they are assumed to
1643
+ be the currently authenticated ones.
1644
+ :param realm_name: The name of an authentication realm. This parameter cannot
1645
+ be used with either `id` or `name` or when `owner` flag is set to `true`.
1646
+ :param username: The username of a user. This parameter cannot be used with either
1647
+ `id` or `name` or when `owner` flag is set to `true`.
1648
+ :param with_limited_by: Return the snapshot of the owner user's role descriptors
1649
+ associated with the API key. An API key's actual permission is the intersection
1650
+ of its assigned role descriptors and the owner user's role descriptors.
1651
+ :param with_profile_uid: Determines whether to also retrieve the profile uid,
1652
+ for the API key owner principal, if it exists.
1653
+ """
1654
+ __path_parts: t.Dict[str, str] = {}
1655
+ __path = "/_security/api_key"
1656
+ __query: t.Dict[str, t.Any] = {}
1657
+ if active_only is not None:
1658
+ __query["active_only"] = active_only
1659
+ if error_trace is not None:
1660
+ __query["error_trace"] = error_trace
1661
+ if filter_path is not None:
1662
+ __query["filter_path"] = filter_path
1663
+ if human is not None:
1664
+ __query["human"] = human
1665
+ if id is not None:
1666
+ __query["id"] = id
1667
+ if name is not None:
1668
+ __query["name"] = name
1669
+ if owner is not None:
1670
+ __query["owner"] = owner
1671
+ if pretty is not None:
1672
+ __query["pretty"] = pretty
1673
+ if realm_name is not None:
1674
+ __query["realm_name"] = realm_name
1675
+ if username is not None:
1676
+ __query["username"] = username
1677
+ if with_limited_by is not None:
1678
+ __query["with_limited_by"] = with_limited_by
1679
+ if with_profile_uid is not None:
1680
+ __query["with_profile_uid"] = with_profile_uid
1681
+ __headers = {"accept": "application/json"}
1682
+ return await self.perform_request( # type: ignore[return-value]
1683
+ "GET",
1684
+ __path,
1685
+ params=__query,
1686
+ headers=__headers,
1687
+ endpoint_id="security.get_api_key",
1688
+ path_parts=__path_parts,
1689
+ )
1690
+
1691
+ @_rewrite_parameters()
1692
+ async def get_builtin_privileges(
1693
+ self,
1694
+ *,
1695
+ error_trace: t.Optional[bool] = None,
1696
+ filter_path: t.Optional[t.Union[str, t.Sequence[str]]] = None,
1697
+ human: t.Optional[bool] = None,
1698
+ pretty: t.Optional[bool] = None,
1699
+ ) -> ObjectApiResponse[t.Any]:
1700
+ """
1701
+ .. raw:: html
1702
+
1703
+ <p>Get builtin privileges.</p>
1704
+ <p>Get the list of cluster privileges and index privileges that are available in this version of Elasticsearch.</p>
1705
+
1706
+
1707
+ `<https://www.elastic.co/docs/api/doc/elasticsearch/v9/operation/operation-security-get-builtin-privileges>`_
1708
+ """
1709
+ __path_parts: t.Dict[str, str] = {}
1710
+ __path = "/_security/privilege/_builtin"
1711
+ __query: t.Dict[str, t.Any] = {}
1712
+ if error_trace is not None:
1713
+ __query["error_trace"] = error_trace
1714
+ if filter_path is not None:
1715
+ __query["filter_path"] = filter_path
1716
+ if human is not None:
1717
+ __query["human"] = human
1718
+ if pretty is not None:
1719
+ __query["pretty"] = pretty
1720
+ __headers = {"accept": "application/json"}
1721
+ return await self.perform_request( # type: ignore[return-value]
1722
+ "GET",
1723
+ __path,
1724
+ params=__query,
1725
+ headers=__headers,
1726
+ endpoint_id="security.get_builtin_privileges",
1727
+ path_parts=__path_parts,
1728
+ )
1729
+
1730
+ @_rewrite_parameters()
1731
+ async def get_privileges(
1732
+ self,
1733
+ *,
1734
+ application: t.Optional[str] = None,
1735
+ name: t.Optional[t.Union[str, t.Sequence[str]]] = None,
1736
+ error_trace: t.Optional[bool] = None,
1737
+ filter_path: t.Optional[t.Union[str, t.Sequence[str]]] = None,
1738
+ human: t.Optional[bool] = None,
1739
+ pretty: t.Optional[bool] = None,
1740
+ ) -> ObjectApiResponse[t.Any]:
1741
+ """
1742
+ .. raw:: html
1743
+
1744
+ <p>Get application privileges.</p>
1745
+ <p>To use this API, you must have one of the following privileges:</p>
1746
+ <ul>
1747
+ <li>The <code>read_security</code> cluster privilege (or a greater privilege such as <code>manage_security</code> or <code>all</code>).</li>
1748
+ <li>The &quot;Manage Application Privileges&quot; global privilege for the application being referenced in the request.</li>
1749
+ </ul>
1750
+
1751
+
1752
+ `<https://www.elastic.co/docs/api/doc/elasticsearch/v9/operation/operation-security-get-privileges>`_
1753
+
1754
+ :param application: The name of the application. Application privileges are always
1755
+ associated with exactly one application. If you do not specify this parameter,
1756
+ the API returns information about all privileges for all applications.
1757
+ :param name: The name of the privilege. If you do not specify this parameter,
1758
+ the API returns information about all privileges for the requested application.
1759
+ """
1760
+ __path_parts: t.Dict[str, str]
1761
+ if application not in SKIP_IN_PATH and name not in SKIP_IN_PATH:
1762
+ __path_parts = {"application": _quote(application), "name": _quote(name)}
1763
+ __path = f'/_security/privilege/{__path_parts["application"]}/{__path_parts["name"]}'
1764
+ elif application not in SKIP_IN_PATH:
1765
+ __path_parts = {"application": _quote(application)}
1766
+ __path = f'/_security/privilege/{__path_parts["application"]}'
1767
+ else:
1768
+ __path_parts = {}
1769
+ __path = "/_security/privilege"
1770
+ __query: t.Dict[str, t.Any] = {}
1771
+ if error_trace is not None:
1772
+ __query["error_trace"] = error_trace
1773
+ if filter_path is not None:
1774
+ __query["filter_path"] = filter_path
1775
+ if human is not None:
1776
+ __query["human"] = human
1777
+ if pretty is not None:
1778
+ __query["pretty"] = pretty
1779
+ __headers = {"accept": "application/json"}
1780
+ return await self.perform_request( # type: ignore[return-value]
1781
+ "GET",
1782
+ __path,
1783
+ params=__query,
1784
+ headers=__headers,
1785
+ endpoint_id="security.get_privileges",
1786
+ path_parts=__path_parts,
1787
+ )
1788
+
1789
+ @_rewrite_parameters()
1790
+ async def get_role(
1791
+ self,
1792
+ *,
1793
+ name: t.Optional[t.Union[str, t.Sequence[str]]] = None,
1794
+ error_trace: t.Optional[bool] = None,
1795
+ filter_path: t.Optional[t.Union[str, t.Sequence[str]]] = None,
1796
+ human: t.Optional[bool] = None,
1797
+ pretty: t.Optional[bool] = None,
1798
+ ) -> ObjectApiResponse[t.Any]:
1799
+ """
1800
+ .. raw:: html
1801
+
1802
+ <p>Get roles.</p>
1803
+ <p>Get roles in the native realm.
1804
+ The role management APIs are generally the preferred way to manage roles, rather than using file-based role management.
1805
+ The get roles API cannot retrieve roles that are defined in roles files.</p>
1806
+
1807
+
1808
+ `<https://www.elastic.co/docs/api/doc/elasticsearch/v9/operation/operation-security-get-role>`_
1809
+
1810
+ :param name: The name of the role. You can specify multiple roles as a comma-separated
1811
+ list. If you do not specify this parameter, the API returns information about
1812
+ all roles.
1813
+ """
1814
+ __path_parts: t.Dict[str, str]
1815
+ if name not in SKIP_IN_PATH:
1816
+ __path_parts = {"name": _quote(name)}
1817
+ __path = f'/_security/role/{__path_parts["name"]}'
1818
+ else:
1819
+ __path_parts = {}
1820
+ __path = "/_security/role"
1821
+ __query: t.Dict[str, t.Any] = {}
1822
+ if error_trace is not None:
1823
+ __query["error_trace"] = error_trace
1824
+ if filter_path is not None:
1825
+ __query["filter_path"] = filter_path
1826
+ if human is not None:
1827
+ __query["human"] = human
1828
+ if pretty is not None:
1829
+ __query["pretty"] = pretty
1830
+ __headers = {"accept": "application/json"}
1831
+ return await self.perform_request( # type: ignore[return-value]
1832
+ "GET",
1833
+ __path,
1834
+ params=__query,
1835
+ headers=__headers,
1836
+ endpoint_id="security.get_role",
1837
+ path_parts=__path_parts,
1838
+ )
1839
+
1840
+ @_rewrite_parameters()
1841
+ async def get_role_mapping(
1842
+ self,
1843
+ *,
1844
+ name: t.Optional[t.Union[str, t.Sequence[str]]] = None,
1845
+ error_trace: t.Optional[bool] = None,
1846
+ filter_path: t.Optional[t.Union[str, t.Sequence[str]]] = None,
1847
+ human: t.Optional[bool] = None,
1848
+ pretty: t.Optional[bool] = None,
1849
+ ) -> ObjectApiResponse[t.Any]:
1850
+ """
1851
+ .. raw:: html
1852
+
1853
+ <p>Get role mappings.</p>
1854
+ <p>Role mappings define which roles are assigned to each user.
1855
+ The role mapping APIs are generally the preferred way to manage role mappings rather than using role mapping files.
1856
+ The get role mappings API cannot retrieve role mappings that are defined in role mapping files.</p>
1857
+
1858
+
1859
+ `<https://www.elastic.co/docs/api/doc/elasticsearch/v9/operation/operation-security-get-role-mapping>`_
1860
+
1861
+ :param name: The distinct name that identifies the role mapping. The name is
1862
+ used solely as an identifier to facilitate interaction via the API; it does
1863
+ not affect the behavior of the mapping in any way. You can specify multiple
1864
+ mapping names as a comma-separated list. If you do not specify this parameter,
1865
+ the API returns information about all role mappings.
1866
+ """
1867
+ __path_parts: t.Dict[str, str]
1868
+ if name not in SKIP_IN_PATH:
1869
+ __path_parts = {"name": _quote(name)}
1870
+ __path = f'/_security/role_mapping/{__path_parts["name"]}'
1871
+ else:
1872
+ __path_parts = {}
1873
+ __path = "/_security/role_mapping"
1874
+ __query: t.Dict[str, t.Any] = {}
1875
+ if error_trace is not None:
1876
+ __query["error_trace"] = error_trace
1877
+ if filter_path is not None:
1878
+ __query["filter_path"] = filter_path
1879
+ if human is not None:
1880
+ __query["human"] = human
1881
+ if pretty is not None:
1882
+ __query["pretty"] = pretty
1883
+ __headers = {"accept": "application/json"}
1884
+ return await self.perform_request( # type: ignore[return-value]
1885
+ "GET",
1886
+ __path,
1887
+ params=__query,
1888
+ headers=__headers,
1889
+ endpoint_id="security.get_role_mapping",
1890
+ path_parts=__path_parts,
1891
+ )
1892
+
1893
+ @_rewrite_parameters()
1894
+ async def get_service_accounts(
1895
+ self,
1896
+ *,
1897
+ namespace: t.Optional[str] = None,
1898
+ service: t.Optional[str] = None,
1899
+ error_trace: t.Optional[bool] = None,
1900
+ filter_path: t.Optional[t.Union[str, t.Sequence[str]]] = None,
1901
+ human: t.Optional[bool] = None,
1902
+ pretty: t.Optional[bool] = None,
1903
+ ) -> ObjectApiResponse[t.Any]:
1904
+ """
1905
+ .. raw:: html
1906
+
1907
+ <p>Get service accounts.</p>
1908
+ <p>Get a list of service accounts that match the provided path parameters.</p>
1909
+ <p>NOTE: Currently, only the <code>elastic/fleet-server</code> service account is available.</p>
1910
+
1911
+
1912
+ `<https://www.elastic.co/docs/api/doc/elasticsearch/v9/operation/operation-security-get-service-accounts>`_
1913
+
1914
+ :param namespace: The name of the namespace. Omit this parameter to retrieve
1915
+ information about all service accounts. If you omit this parameter, you must
1916
+ also omit the `service` parameter.
1917
+ :param service: The service name. Omit this parameter to retrieve information
1918
+ about all service accounts that belong to the specified `namespace`.
1919
+ """
1920
+ __path_parts: t.Dict[str, str]
1921
+ if namespace not in SKIP_IN_PATH and service not in SKIP_IN_PATH:
1922
+ __path_parts = {"namespace": _quote(namespace), "service": _quote(service)}
1923
+ __path = f'/_security/service/{__path_parts["namespace"]}/{__path_parts["service"]}'
1924
+ elif namespace not in SKIP_IN_PATH:
1925
+ __path_parts = {"namespace": _quote(namespace)}
1926
+ __path = f'/_security/service/{__path_parts["namespace"]}'
1927
+ else:
1928
+ __path_parts = {}
1929
+ __path = "/_security/service"
1930
+ __query: t.Dict[str, t.Any] = {}
1931
+ if error_trace is not None:
1932
+ __query["error_trace"] = error_trace
1933
+ if filter_path is not None:
1934
+ __query["filter_path"] = filter_path
1935
+ if human is not None:
1936
+ __query["human"] = human
1937
+ if pretty is not None:
1938
+ __query["pretty"] = pretty
1939
+ __headers = {"accept": "application/json"}
1940
+ return await self.perform_request( # type: ignore[return-value]
1941
+ "GET",
1942
+ __path,
1943
+ params=__query,
1944
+ headers=__headers,
1945
+ endpoint_id="security.get_service_accounts",
1946
+ path_parts=__path_parts,
1947
+ )
1948
+
1949
+ @_rewrite_parameters()
1950
+ async def get_service_credentials(
1951
+ self,
1952
+ *,
1953
+ namespace: str,
1954
+ service: str,
1955
+ error_trace: t.Optional[bool] = None,
1956
+ filter_path: t.Optional[t.Union[str, t.Sequence[str]]] = None,
1957
+ human: t.Optional[bool] = None,
1958
+ pretty: t.Optional[bool] = None,
1959
+ ) -> ObjectApiResponse[t.Any]:
1960
+ """
1961
+ .. raw:: html
1962
+
1963
+ <p>Get service account credentials.</p>
1964
+ <p>To use this API, you must have at least the <code>read_security</code> cluster privilege (or a greater privilege such as <code>manage_service_account</code> or <code>manage_security</code>).</p>
1965
+ <p>The response includes service account tokens that were created with the create service account tokens API as well as file-backed tokens from all nodes of the cluster.</p>
1966
+ <p>NOTE: For tokens backed by the <code>service_tokens</code> file, the API collects them from all nodes of the cluster.
1967
+ Tokens with the same name from different nodes are assumed to be the same token and are only counted once towards the total number of service tokens.</p>
1968
+
1969
+
1970
+ `<https://www.elastic.co/docs/api/doc/elasticsearch/v9/operation/operation-security-get-service-credentials>`_
1971
+
1972
+ :param namespace: The name of the namespace.
1973
+ :param service: The service name.
1974
+ """
1975
+ if namespace in SKIP_IN_PATH:
1976
+ raise ValueError("Empty value passed for parameter 'namespace'")
1977
+ if service in SKIP_IN_PATH:
1978
+ raise ValueError("Empty value passed for parameter 'service'")
1979
+ __path_parts: t.Dict[str, str] = {
1980
+ "namespace": _quote(namespace),
1981
+ "service": _quote(service),
1982
+ }
1983
+ __path = f'/_security/service/{__path_parts["namespace"]}/{__path_parts["service"]}/credential'
1984
+ __query: t.Dict[str, t.Any] = {}
1985
+ if error_trace is not None:
1986
+ __query["error_trace"] = error_trace
1987
+ if filter_path is not None:
1988
+ __query["filter_path"] = filter_path
1989
+ if human is not None:
1990
+ __query["human"] = human
1991
+ if pretty is not None:
1992
+ __query["pretty"] = pretty
1993
+ __headers = {"accept": "application/json"}
1994
+ return await self.perform_request( # type: ignore[return-value]
1995
+ "GET",
1996
+ __path,
1997
+ params=__query,
1998
+ headers=__headers,
1999
+ endpoint_id="security.get_service_credentials",
2000
+ path_parts=__path_parts,
2001
+ )
2002
+
2003
+ @_rewrite_parameters()
2004
+ async def get_settings(
2005
+ self,
2006
+ *,
2007
+ error_trace: t.Optional[bool] = None,
2008
+ filter_path: t.Optional[t.Union[str, t.Sequence[str]]] = None,
2009
+ human: t.Optional[bool] = None,
2010
+ master_timeout: t.Optional[t.Union[str, t.Literal[-1], t.Literal[0]]] = None,
2011
+ pretty: t.Optional[bool] = None,
2012
+ ) -> ObjectApiResponse[t.Any]:
2013
+ """
2014
+ .. raw:: html
2015
+
2016
+ <p>Get security index settings.</p>
2017
+ <p>Get the user-configurable settings for the security internal index (<code>.security</code> and associated indices).
2018
+ Only a subset of the index settings — those that are user-configurable—will be shown.
2019
+ This includes:</p>
2020
+ <ul>
2021
+ <li><code>index.auto_expand_replicas</code></li>
2022
+ <li><code>index.number_of_replicas</code></li>
2023
+ </ul>
2024
+
2025
+
2026
+ `<https://www.elastic.co/docs/api/doc/elasticsearch/v9/operation/operation-security-get-settings>`_
2027
+
2028
+ :param master_timeout: Period to wait for a connection to the master node. If
2029
+ no response is received before the timeout expires, the request fails and
2030
+ returns an error.
2031
+ """
2032
+ __path_parts: t.Dict[str, str] = {}
2033
+ __path = "/_security/settings"
2034
+ __query: t.Dict[str, t.Any] = {}
2035
+ if error_trace is not None:
2036
+ __query["error_trace"] = error_trace
2037
+ if filter_path is not None:
2038
+ __query["filter_path"] = filter_path
2039
+ if human is not None:
2040
+ __query["human"] = human
2041
+ if master_timeout is not None:
2042
+ __query["master_timeout"] = master_timeout
2043
+ if pretty is not None:
2044
+ __query["pretty"] = pretty
2045
+ __headers = {"accept": "application/json"}
2046
+ return await self.perform_request( # type: ignore[return-value]
2047
+ "GET",
2048
+ __path,
2049
+ params=__query,
2050
+ headers=__headers,
2051
+ endpoint_id="security.get_settings",
2052
+ path_parts=__path_parts,
2053
+ )
2054
+
2055
+ @_rewrite_parameters(
2056
+ body_fields=(
2057
+ "grant_type",
2058
+ "kerberos_ticket",
2059
+ "password",
2060
+ "refresh_token",
2061
+ "scope",
2062
+ "username",
2063
+ ),
2064
+ )
2065
+ async def get_token(
2066
+ self,
2067
+ *,
2068
+ error_trace: t.Optional[bool] = None,
2069
+ filter_path: t.Optional[t.Union[str, t.Sequence[str]]] = None,
2070
+ grant_type: t.Optional[
2071
+ t.Union[
2072
+ str,
2073
+ t.Literal[
2074
+ "_kerberos", "client_credentials", "password", "refresh_token"
2075
+ ],
2076
+ ]
2077
+ ] = None,
2078
+ human: t.Optional[bool] = None,
2079
+ kerberos_ticket: t.Optional[str] = None,
2080
+ password: t.Optional[str] = None,
2081
+ pretty: t.Optional[bool] = None,
2082
+ refresh_token: t.Optional[str] = None,
2083
+ scope: t.Optional[str] = None,
2084
+ username: t.Optional[str] = None,
2085
+ body: t.Optional[t.Dict[str, t.Any]] = None,
2086
+ ) -> ObjectApiResponse[t.Any]:
2087
+ """
2088
+ .. raw:: html
2089
+
2090
+ <p>Get a token.</p>
2091
+ <p>Create a bearer token for access without requiring basic authentication.
2092
+ The tokens are created by the Elasticsearch Token Service, which is automatically enabled when you configure TLS on the HTTP interface.
2093
+ Alternatively, you can explicitly enable the <code>xpack.security.authc.token.enabled</code> setting.
2094
+ When you are running in production mode, a bootstrap check prevents you from enabling the token service unless you also enable TLS on the HTTP interface.</p>
2095
+ <p>The get token API takes the same parameters as a typical OAuth 2.0 token API except for the use of a JSON request body.</p>
2096
+ <p>A successful get token API call returns a JSON structure that contains the access token, the amount of time (seconds) that the token expires in, the type, and the scope if available.</p>
2097
+ <p>The tokens returned by the get token API have a finite period of time for which they are valid and after that time period, they can no longer be used.
2098
+ That time period is defined by the <code>xpack.security.authc.token.timeout</code> setting.
2099
+ If you want to invalidate a token immediately, you can do so by using the invalidate token API.</p>
2100
+
2101
+
2102
+ `<https://www.elastic.co/docs/api/doc/elasticsearch/v9/operation/operation-security-get-token>`_
2103
+
2104
+ :param grant_type: The type of grant. Supported grant types are: `password`,
2105
+ `_kerberos`, `client_credentials`, and `refresh_token`.
2106
+ :param kerberos_ticket: The base64 encoded kerberos ticket. If you specify the
2107
+ `_kerberos` grant type, this parameter is required. This parameter is not
2108
+ valid with any other supported grant type.
2109
+ :param password: The user's password. If you specify the `password` grant type,
2110
+ this parameter is required. This parameter is not valid with any other supported
2111
+ grant type.
2112
+ :param refresh_token: The string that was returned when you created the token,
2113
+ which enables you to extend its life. If you specify the `refresh_token`
2114
+ grant type, this parameter is required. This parameter is not valid with
2115
+ any other supported grant type.
2116
+ :param scope: The scope of the token. Currently tokens are only issued for a
2117
+ scope of FULL regardless of the value sent with the request.
2118
+ :param username: The username that identifies the user. If you specify the `password`
2119
+ grant type, this parameter is required. This parameter is not valid with
2120
+ any other supported grant type.
2121
+ """
2122
+ __path_parts: t.Dict[str, str] = {}
2123
+ __path = "/_security/oauth2/token"
2124
+ __query: t.Dict[str, t.Any] = {}
2125
+ __body: t.Dict[str, t.Any] = body if body is not None else {}
2126
+ if error_trace is not None:
2127
+ __query["error_trace"] = error_trace
2128
+ if filter_path is not None:
2129
+ __query["filter_path"] = filter_path
2130
+ if human is not None:
2131
+ __query["human"] = human
2132
+ if pretty is not None:
2133
+ __query["pretty"] = pretty
2134
+ if not __body:
2135
+ if grant_type is not None:
2136
+ __body["grant_type"] = grant_type
2137
+ if kerberos_ticket is not None:
2138
+ __body["kerberos_ticket"] = kerberos_ticket
2139
+ if password is not None:
2140
+ __body["password"] = password
2141
+ if refresh_token is not None:
2142
+ __body["refresh_token"] = refresh_token
2143
+ if scope is not None:
2144
+ __body["scope"] = scope
2145
+ if username is not None:
2146
+ __body["username"] = username
2147
+ __headers = {"accept": "application/json", "content-type": "application/json"}
2148
+ return await self.perform_request( # type: ignore[return-value]
2149
+ "POST",
2150
+ __path,
2151
+ params=__query,
2152
+ headers=__headers,
2153
+ body=__body,
2154
+ endpoint_id="security.get_token",
2155
+ path_parts=__path_parts,
2156
+ )
2157
+
2158
+ @_rewrite_parameters()
2159
+ async def get_user(
2160
+ self,
2161
+ *,
2162
+ username: t.Optional[t.Union[str, t.Sequence[str]]] = None,
2163
+ error_trace: t.Optional[bool] = None,
2164
+ filter_path: t.Optional[t.Union[str, t.Sequence[str]]] = None,
2165
+ human: t.Optional[bool] = None,
2166
+ pretty: t.Optional[bool] = None,
2167
+ with_profile_uid: t.Optional[bool] = None,
2168
+ ) -> ObjectApiResponse[t.Any]:
2169
+ """
2170
+ .. raw:: html
2171
+
2172
+ <p>Get users.</p>
2173
+ <p>Get information about users in the native realm and built-in users.</p>
2174
+
2175
+
2176
+ `<https://www.elastic.co/docs/api/doc/elasticsearch/v9/operation/operation-security-get-user>`_
2177
+
2178
+ :param username: An identifier for the user. You can specify multiple usernames
2179
+ as a comma-separated list. If you omit this parameter, the API retrieves
2180
+ information about all users.
2181
+ :param with_profile_uid: Determines whether to retrieve the user profile UID,
2182
+ if it exists, for the users.
2183
+ """
2184
+ __path_parts: t.Dict[str, str]
2185
+ if username not in SKIP_IN_PATH:
2186
+ __path_parts = {"username": _quote(username)}
2187
+ __path = f'/_security/user/{__path_parts["username"]}'
2188
+ else:
2189
+ __path_parts = {}
2190
+ __path = "/_security/user"
2191
+ __query: t.Dict[str, t.Any] = {}
2192
+ if error_trace is not None:
2193
+ __query["error_trace"] = error_trace
2194
+ if filter_path is not None:
2195
+ __query["filter_path"] = filter_path
2196
+ if human is not None:
2197
+ __query["human"] = human
2198
+ if pretty is not None:
2199
+ __query["pretty"] = pretty
2200
+ if with_profile_uid is not None:
2201
+ __query["with_profile_uid"] = with_profile_uid
2202
+ __headers = {"accept": "application/json"}
2203
+ return await self.perform_request( # type: ignore[return-value]
2204
+ "GET",
2205
+ __path,
2206
+ params=__query,
2207
+ headers=__headers,
2208
+ endpoint_id="security.get_user",
2209
+ path_parts=__path_parts,
2210
+ )
2211
+
2212
+ @_rewrite_parameters()
2213
+ async def get_user_privileges(
2214
+ self,
2215
+ *,
2216
+ application: t.Optional[str] = None,
2217
+ error_trace: t.Optional[bool] = None,
2218
+ filter_path: t.Optional[t.Union[str, t.Sequence[str]]] = None,
2219
+ human: t.Optional[bool] = None,
2220
+ pretty: t.Optional[bool] = None,
2221
+ priviledge: t.Optional[str] = None,
2222
+ username: t.Optional[t.Union[None, str]] = None,
2223
+ ) -> ObjectApiResponse[t.Any]:
2224
+ """
2225
+ .. raw:: html
2226
+
2227
+ <p>Get user privileges.</p>
2228
+ <p>Get the security privileges for the logged in user.
2229
+ All users can use this API, but only to determine their own privileges.
2230
+ To check the privileges of other users, you must use the run as feature.
2231
+ To check whether a user has a specific list of privileges, use the has privileges API.</p>
2232
+
2233
+
2234
+ `<https://www.elastic.co/docs/api/doc/elasticsearch/v9/operation/operation-security-get-user-privileges>`_
2235
+
2236
+ :param application: The name of the application. Application privileges are always
2237
+ associated with exactly one application. If you do not specify this parameter,
2238
+ the API returns information about all privileges for all applications.
2239
+ :param priviledge: The name of the privilege. If you do not specify this parameter,
2240
+ the API returns information about all privileges for the requested application.
2241
+ :param username:
2242
+ """
2243
+ __path_parts: t.Dict[str, str] = {}
2244
+ __path = "/_security/user/_privileges"
2245
+ __query: t.Dict[str, t.Any] = {}
2246
+ if application is not None:
2247
+ __query["application"] = application
2248
+ if error_trace is not None:
2249
+ __query["error_trace"] = error_trace
2250
+ if filter_path is not None:
2251
+ __query["filter_path"] = filter_path
2252
+ if human is not None:
2253
+ __query["human"] = human
2254
+ if pretty is not None:
2255
+ __query["pretty"] = pretty
2256
+ if priviledge is not None:
2257
+ __query["priviledge"] = priviledge
2258
+ if username is not None:
2259
+ __query["username"] = username
2260
+ __headers = {"accept": "application/json"}
2261
+ return await self.perform_request( # type: ignore[return-value]
2262
+ "GET",
2263
+ __path,
2264
+ params=__query,
2265
+ headers=__headers,
2266
+ endpoint_id="security.get_user_privileges",
2267
+ path_parts=__path_parts,
2268
+ )
2269
+
2270
+ @_rewrite_parameters()
2271
+ async def get_user_profile(
2272
+ self,
2273
+ *,
2274
+ uid: t.Union[str, t.Sequence[str]],
2275
+ data: t.Optional[t.Union[str, t.Sequence[str]]] = None,
2276
+ error_trace: t.Optional[bool] = None,
2277
+ filter_path: t.Optional[t.Union[str, t.Sequence[str]]] = None,
2278
+ human: t.Optional[bool] = None,
2279
+ pretty: t.Optional[bool] = None,
2280
+ ) -> ObjectApiResponse[t.Any]:
2281
+ """
2282
+ .. raw:: html
2283
+
2284
+ <p>Get a user profile.</p>
2285
+ <p>Get a user's profile using the unique profile ID.</p>
2286
+ <p>NOTE: The user profile feature is designed only for use by Kibana and Elastic's Observability, Enterprise Search, and Elastic Security solutions.
2287
+ Individual users and external applications should not call this API directly.
2288
+ Elastic reserves the right to change or remove this feature in future releases without prior notice.</p>
2289
+
2290
+
2291
+ `<https://www.elastic.co/docs/api/doc/elasticsearch/v9/operation/operation-security-get-user-profile>`_
2292
+
2293
+ :param uid: A unique identifier for the user profile.
2294
+ :param data: A comma-separated list of filters for the `data` field of the profile
2295
+ document. To return all content use `data=*`. To return a subset of content
2296
+ use `data=<key>` to retrieve content nested under the specified `<key>`.
2297
+ By default returns no `data` content.
2298
+ """
2299
+ if uid in SKIP_IN_PATH:
2300
+ raise ValueError("Empty value passed for parameter 'uid'")
2301
+ __path_parts: t.Dict[str, str] = {"uid": _quote(uid)}
2302
+ __path = f'/_security/profile/{__path_parts["uid"]}'
2303
+ __query: t.Dict[str, t.Any] = {}
2304
+ if data is not None:
2305
+ __query["data"] = data
2306
+ if error_trace is not None:
2307
+ __query["error_trace"] = error_trace
2308
+ if filter_path is not None:
2309
+ __query["filter_path"] = filter_path
2310
+ if human is not None:
2311
+ __query["human"] = human
2312
+ if pretty is not None:
2313
+ __query["pretty"] = pretty
2314
+ __headers = {"accept": "application/json"}
2315
+ return await self.perform_request( # type: ignore[return-value]
2316
+ "GET",
2317
+ __path,
2318
+ params=__query,
2319
+ headers=__headers,
2320
+ endpoint_id="security.get_user_profile",
2321
+ path_parts=__path_parts,
2322
+ )
2323
+
2324
+ @_rewrite_parameters(
2325
+ body_fields=(
2326
+ "api_key",
2327
+ "grant_type",
2328
+ "access_token",
2329
+ "password",
2330
+ "run_as",
2331
+ "username",
2332
+ ),
2333
+ ignore_deprecated_options={"api_key"},
2334
+ )
2335
+ async def grant_api_key(
2336
+ self,
2337
+ *,
2338
+ api_key: t.Optional[t.Mapping[str, t.Any]] = None,
2339
+ grant_type: t.Optional[
2340
+ t.Union[str, t.Literal["access_token", "password"]]
2341
+ ] = None,
2342
+ access_token: t.Optional[str] = None,
2343
+ error_trace: t.Optional[bool] = None,
2344
+ filter_path: t.Optional[t.Union[str, t.Sequence[str]]] = None,
2345
+ human: t.Optional[bool] = None,
2346
+ password: t.Optional[str] = None,
2347
+ pretty: t.Optional[bool] = None,
2348
+ run_as: t.Optional[str] = None,
2349
+ username: t.Optional[str] = None,
2350
+ body: t.Optional[t.Dict[str, t.Any]] = None,
2351
+ ) -> ObjectApiResponse[t.Any]:
2352
+ """
2353
+ .. raw:: html
2354
+
2355
+ <p>Grant an API key.</p>
2356
+ <p>Create an API key on behalf of another user.
2357
+ This API is similar to the create API keys API, however it creates the API key for a user that is different than the user that runs the API.
2358
+ The caller must have authentication credentials for the user on whose behalf the API key will be created.
2359
+ It is not possible to use this API to create an API key without that user's credentials.
2360
+ The supported user authentication credential types are:</p>
2361
+ <ul>
2362
+ <li>username and password</li>
2363
+ <li>Elasticsearch access tokens</li>
2364
+ <li>JWTs</li>
2365
+ </ul>
2366
+ <p>The user, for whom the authentication credentials is provided, can optionally &quot;run as&quot; (impersonate) another user.
2367
+ In this case, the API key will be created on behalf of the impersonated user.</p>
2368
+ <p>This API is intended be used by applications that need to create and manage API keys for end users, but cannot guarantee that those users have permission to create API keys on their own behalf.
2369
+ The API keys are created by the Elasticsearch API key service, which is automatically enabled.</p>
2370
+ <p>A successful grant API key API call returns a JSON structure that contains the API key, its unique id, and its name.
2371
+ If applicable, it also returns expiration information for the API key in milliseconds.</p>
2372
+ <p>By default, API keys never expire. You can specify expiration information when you create the API keys.</p>
2373
+
2374
+
2375
+ `<https://www.elastic.co/docs/api/doc/elasticsearch/v9/operation/operation-security-grant-api-key>`_
2376
+
2377
+ :param api_key: The API key.
2378
+ :param grant_type: The type of grant. Supported grant types are: `access_token`,
2379
+ `password`.
2380
+ :param access_token: The user's access token. If you specify the `access_token`
2381
+ grant type, this parameter is required. It is not valid with other grant
2382
+ types.
2383
+ :param password: The user's password. If you specify the `password` grant type,
2384
+ this parameter is required. It is not valid with other grant types.
2385
+ :param run_as: The name of the user to be impersonated.
2386
+ :param username: The user name that identifies the user. If you specify the `password`
2387
+ grant type, this parameter is required. It is not valid with other grant
2388
+ types.
2389
+ """
2390
+ if api_key is None and body is None:
2391
+ raise ValueError("Empty value passed for parameter 'api_key'")
2392
+ if grant_type is None and body is None:
2393
+ raise ValueError("Empty value passed for parameter 'grant_type'")
2394
+ __path_parts: t.Dict[str, str] = {}
2395
+ __path = "/_security/api_key/grant"
2396
+ __query: t.Dict[str, t.Any] = {}
2397
+ __body: t.Dict[str, t.Any] = body if body is not None else {}
2398
+ if error_trace is not None:
2399
+ __query["error_trace"] = error_trace
2400
+ if filter_path is not None:
2401
+ __query["filter_path"] = filter_path
2402
+ if human is not None:
2403
+ __query["human"] = human
2404
+ if pretty is not None:
2405
+ __query["pretty"] = pretty
2406
+ if not __body:
2407
+ if api_key is not None:
2408
+ __body["api_key"] = api_key
2409
+ if grant_type is not None:
2410
+ __body["grant_type"] = grant_type
2411
+ if access_token is not None:
2412
+ __body["access_token"] = access_token
2413
+ if password is not None:
2414
+ __body["password"] = password
2415
+ if run_as is not None:
2416
+ __body["run_as"] = run_as
2417
+ if username is not None:
2418
+ __body["username"] = username
2419
+ __headers = {"accept": "application/json", "content-type": "application/json"}
2420
+ return await self.perform_request( # type: ignore[return-value]
2421
+ "POST",
2422
+ __path,
2423
+ params=__query,
2424
+ headers=__headers,
2425
+ body=__body,
2426
+ endpoint_id="security.grant_api_key",
2427
+ path_parts=__path_parts,
2428
+ )
2429
+
2430
+ @_rewrite_parameters(
2431
+ body_fields=("application", "cluster", "index"),
2432
+ )
2433
+ async def has_privileges(
2434
+ self,
2435
+ *,
2436
+ user: t.Optional[str] = None,
2437
+ application: t.Optional[t.Sequence[t.Mapping[str, t.Any]]] = None,
2438
+ cluster: t.Optional[
2439
+ t.Sequence[
2440
+ t.Union[
2441
+ str,
2442
+ t.Literal[
2443
+ "all",
2444
+ "cancel_task",
2445
+ "create_snapshot",
2446
+ "cross_cluster_replication",
2447
+ "cross_cluster_search",
2448
+ "delegate_pki",
2449
+ "grant_api_key",
2450
+ "manage",
2451
+ "manage_api_key",
2452
+ "manage_autoscaling",
2453
+ "manage_behavioral_analytics",
2454
+ "manage_ccr",
2455
+ "manage_data_frame_transforms",
2456
+ "manage_data_stream_global_retention",
2457
+ "manage_enrich",
2458
+ "manage_ilm",
2459
+ "manage_index_templates",
2460
+ "manage_inference",
2461
+ "manage_ingest_pipelines",
2462
+ "manage_logstash_pipelines",
2463
+ "manage_ml",
2464
+ "manage_oidc",
2465
+ "manage_own_api_key",
2466
+ "manage_pipeline",
2467
+ "manage_rollup",
2468
+ "manage_saml",
2469
+ "manage_search_application",
2470
+ "manage_search_query_rules",
2471
+ "manage_search_synonyms",
2472
+ "manage_security",
2473
+ "manage_service_account",
2474
+ "manage_slm",
2475
+ "manage_token",
2476
+ "manage_transform",
2477
+ "manage_user_profile",
2478
+ "manage_watcher",
2479
+ "monitor",
2480
+ "monitor_data_frame_transforms",
2481
+ "monitor_data_stream_global_retention",
2482
+ "monitor_enrich",
2483
+ "monitor_inference",
2484
+ "monitor_ml",
2485
+ "monitor_rollup",
2486
+ "monitor_snapshot",
2487
+ "monitor_stats",
2488
+ "monitor_text_structure",
2489
+ "monitor_transform",
2490
+ "monitor_watcher",
2491
+ "none",
2492
+ "post_behavioral_analytics_event",
2493
+ "read_ccr",
2494
+ "read_fleet_secrets",
2495
+ "read_ilm",
2496
+ "read_pipeline",
2497
+ "read_security",
2498
+ "read_slm",
2499
+ "transport_client",
2500
+ "write_connector_secrets",
2501
+ "write_fleet_secrets",
2502
+ ],
2503
+ ]
2504
+ ]
2505
+ ] = None,
2506
+ error_trace: t.Optional[bool] = None,
2507
+ filter_path: t.Optional[t.Union[str, t.Sequence[str]]] = None,
2508
+ human: t.Optional[bool] = None,
2509
+ index: t.Optional[t.Sequence[t.Mapping[str, t.Any]]] = None,
2510
+ pretty: t.Optional[bool] = None,
2511
+ body: t.Optional[t.Dict[str, t.Any]] = None,
2512
+ ) -> ObjectApiResponse[t.Any]:
2513
+ """
2514
+ .. raw:: html
2515
+
2516
+ <p>Check user privileges.</p>
2517
+ <p>Determine whether the specified user has a specified list of privileges.
2518
+ All users can use this API, but only to determine their own privileges.
2519
+ To check the privileges of other users, you must use the run as feature.</p>
2520
+
2521
+
2522
+ `<https://www.elastic.co/docs/api/doc/elasticsearch/v9/operation/operation-security-has-privileges>`_
2523
+
2524
+ :param user: Username
2525
+ :param application:
2526
+ :param cluster: A list of the cluster privileges that you want to check.
2527
+ :param index:
2528
+ """
2529
+ __path_parts: t.Dict[str, str]
2530
+ if user not in SKIP_IN_PATH:
2531
+ __path_parts = {"user": _quote(user)}
2532
+ __path = f'/_security/user/{__path_parts["user"]}/_has_privileges'
2533
+ else:
2534
+ __path_parts = {}
2535
+ __path = "/_security/user/_has_privileges"
2536
+ __query: t.Dict[str, t.Any] = {}
2537
+ __body: t.Dict[str, t.Any] = body if body is not None else {}
2538
+ if error_trace is not None:
2539
+ __query["error_trace"] = error_trace
2540
+ if filter_path is not None:
2541
+ __query["filter_path"] = filter_path
2542
+ if human is not None:
2543
+ __query["human"] = human
2544
+ if pretty is not None:
2545
+ __query["pretty"] = pretty
2546
+ if not __body:
2547
+ if application is not None:
2548
+ __body["application"] = application
2549
+ if cluster is not None:
2550
+ __body["cluster"] = cluster
2551
+ if index is not None:
2552
+ __body["index"] = index
2553
+ __headers = {"accept": "application/json", "content-type": "application/json"}
2554
+ return await self.perform_request( # type: ignore[return-value]
2555
+ "POST",
2556
+ __path,
2557
+ params=__query,
2558
+ headers=__headers,
2559
+ body=__body,
2560
+ endpoint_id="security.has_privileges",
2561
+ path_parts=__path_parts,
2562
+ )
2563
+
2564
+ @_rewrite_parameters(
2565
+ body_fields=("privileges", "uids"),
2566
+ )
2567
+ async def has_privileges_user_profile(
2568
+ self,
2569
+ *,
2570
+ privileges: t.Optional[t.Mapping[str, t.Any]] = None,
2571
+ uids: t.Optional[t.Sequence[str]] = None,
2572
+ error_trace: t.Optional[bool] = None,
2573
+ filter_path: t.Optional[t.Union[str, t.Sequence[str]]] = None,
2574
+ human: t.Optional[bool] = None,
2575
+ pretty: t.Optional[bool] = None,
2576
+ body: t.Optional[t.Dict[str, t.Any]] = None,
2577
+ ) -> ObjectApiResponse[t.Any]:
2578
+ """
2579
+ .. raw:: html
2580
+
2581
+ <p>Check user profile privileges.</p>
2582
+ <p>Determine whether the users associated with the specified user profile IDs have all the requested privileges.</p>
2583
+ <p>NOTE: The user profile feature is designed only for use by Kibana and Elastic's Observability, Enterprise Search, and Elastic Security solutions. Individual users and external applications should not call this API directly.
2584
+ Elastic reserves the right to change or remove this feature in future releases without prior notice.</p>
2585
+
2586
+
2587
+ `<https://www.elastic.co/docs/api/doc/elasticsearch/v9/operation/operation-security-has-privileges-user-profile>`_
2588
+
2589
+ :param privileges: An object containing all the privileges to be checked.
2590
+ :param uids: A list of profile IDs. The privileges are checked for associated
2591
+ users of the profiles.
2592
+ """
2593
+ if privileges is None and body is None:
2594
+ raise ValueError("Empty value passed for parameter 'privileges'")
2595
+ if uids is None and body is None:
2596
+ raise ValueError("Empty value passed for parameter 'uids'")
2597
+ __path_parts: t.Dict[str, str] = {}
2598
+ __path = "/_security/profile/_has_privileges"
2599
+ __query: t.Dict[str, t.Any] = {}
2600
+ __body: t.Dict[str, t.Any] = body if body is not None else {}
2601
+ if error_trace is not None:
2602
+ __query["error_trace"] = error_trace
2603
+ if filter_path is not None:
2604
+ __query["filter_path"] = filter_path
2605
+ if human is not None:
2606
+ __query["human"] = human
2607
+ if pretty is not None:
2608
+ __query["pretty"] = pretty
2609
+ if not __body:
2610
+ if privileges is not None:
2611
+ __body["privileges"] = privileges
2612
+ if uids is not None:
2613
+ __body["uids"] = uids
2614
+ __headers = {"accept": "application/json", "content-type": "application/json"}
2615
+ return await self.perform_request( # type: ignore[return-value]
2616
+ "POST",
2617
+ __path,
2618
+ params=__query,
2619
+ headers=__headers,
2620
+ body=__body,
2621
+ endpoint_id="security.has_privileges_user_profile",
2622
+ path_parts=__path_parts,
2623
+ )
2624
+
2625
+ @_rewrite_parameters(
2626
+ body_fields=("id", "ids", "name", "owner", "realm_name", "username"),
2627
+ )
2628
+ async def invalidate_api_key(
2629
+ self,
2630
+ *,
2631
+ error_trace: t.Optional[bool] = None,
2632
+ filter_path: t.Optional[t.Union[str, t.Sequence[str]]] = None,
2633
+ human: t.Optional[bool] = None,
2634
+ id: t.Optional[str] = None,
2635
+ ids: t.Optional[t.Sequence[str]] = None,
2636
+ name: t.Optional[str] = None,
2637
+ owner: t.Optional[bool] = None,
2638
+ pretty: t.Optional[bool] = None,
2639
+ realm_name: t.Optional[str] = None,
2640
+ username: t.Optional[str] = None,
2641
+ body: t.Optional[t.Dict[str, t.Any]] = None,
2642
+ ) -> ObjectApiResponse[t.Any]:
2643
+ """
2644
+ .. raw:: html
2645
+
2646
+ <p>Invalidate API keys.</p>
2647
+ <p>This API invalidates API keys created by the create API key or grant API key APIs.
2648
+ Invalidated API keys fail authentication, but they can still be viewed using the get API key information and query API key information APIs, for at least the configured retention period, until they are automatically deleted.</p>
2649
+ <p>To use this API, you must have at least the <code>manage_security</code>, <code>manage_api_key</code>, or <code>manage_own_api_key</code> cluster privileges.
2650
+ The <code>manage_security</code> privilege allows deleting any API key, including both REST and cross cluster API keys.
2651
+ The <code>manage_api_key</code> privilege allows deleting any REST API key, but not cross cluster API keys.
2652
+ The <code>manage_own_api_key</code> only allows deleting REST API keys that are owned by the user.
2653
+ In addition, with the <code>manage_own_api_key</code> privilege, an invalidation request must be issued in one of the three formats:</p>
2654
+ <ul>
2655
+ <li>Set the parameter <code>owner=true</code>.</li>
2656
+ <li>Or, set both <code>username</code> and <code>realm_name</code> to match the user's identity.</li>
2657
+ <li>Or, if the request is issued by an API key, that is to say an API key invalidates itself, specify its ID in the <code>ids</code> field.</li>
2658
+ </ul>
2659
+
2660
+
2661
+ `<https://www.elastic.co/docs/api/doc/elasticsearch/v9/operation/operation-security-invalidate-api-key>`_
2662
+
2663
+ :param id:
2664
+ :param ids: A list of API key ids. This parameter cannot be used with any of
2665
+ `name`, `realm_name`, or `username`.
2666
+ :param name: An API key name. This parameter cannot be used with any of `ids`,
2667
+ `realm_name` or `username`.
2668
+ :param owner: Query API keys owned by the currently authenticated user. The `realm_name`
2669
+ or `username` parameters cannot be specified when this parameter is set to
2670
+ `true` as they are assumed to be the currently authenticated ones. NOTE:
2671
+ At least one of `ids`, `name`, `username`, and `realm_name` must be specified
2672
+ if `owner` is `false`.
2673
+ :param realm_name: The name of an authentication realm. This parameter cannot
2674
+ be used with either `ids` or `name`, or when `owner` flag is set to `true`.
2675
+ :param username: The username of a user. This parameter cannot be used with either
2676
+ `ids` or `name` or when `owner` flag is set to `true`.
2677
+ """
2678
+ __path_parts: t.Dict[str, str] = {}
2679
+ __path = "/_security/api_key"
2680
+ __query: t.Dict[str, t.Any] = {}
2681
+ __body: t.Dict[str, t.Any] = body if body is not None else {}
2682
+ if error_trace is not None:
2683
+ __query["error_trace"] = error_trace
2684
+ if filter_path is not None:
2685
+ __query["filter_path"] = filter_path
2686
+ if human is not None:
2687
+ __query["human"] = human
2688
+ if pretty is not None:
2689
+ __query["pretty"] = pretty
2690
+ if not __body:
2691
+ if id is not None:
2692
+ __body["id"] = id
2693
+ if ids is not None:
2694
+ __body["ids"] = ids
2695
+ if name is not None:
2696
+ __body["name"] = name
2697
+ if owner is not None:
2698
+ __body["owner"] = owner
2699
+ if realm_name is not None:
2700
+ __body["realm_name"] = realm_name
2701
+ if username is not None:
2702
+ __body["username"] = username
2703
+ __headers = {"accept": "application/json", "content-type": "application/json"}
2704
+ return await self.perform_request( # type: ignore[return-value]
2705
+ "DELETE",
2706
+ __path,
2707
+ params=__query,
2708
+ headers=__headers,
2709
+ body=__body,
2710
+ endpoint_id="security.invalidate_api_key",
2711
+ path_parts=__path_parts,
2712
+ )
2713
+
2714
+ @_rewrite_parameters(
2715
+ body_fields=("realm_name", "refresh_token", "token", "username"),
2716
+ )
2717
+ async def invalidate_token(
2718
+ self,
2719
+ *,
2720
+ error_trace: t.Optional[bool] = None,
2721
+ filter_path: t.Optional[t.Union[str, t.Sequence[str]]] = None,
2722
+ human: t.Optional[bool] = None,
2723
+ pretty: t.Optional[bool] = None,
2724
+ realm_name: t.Optional[str] = None,
2725
+ refresh_token: t.Optional[str] = None,
2726
+ token: t.Optional[str] = None,
2727
+ username: t.Optional[str] = None,
2728
+ body: t.Optional[t.Dict[str, t.Any]] = None,
2729
+ ) -> ObjectApiResponse[t.Any]:
2730
+ """
2731
+ .. raw:: html
2732
+
2733
+ <p>Invalidate a token.</p>
2734
+ <p>The access tokens returned by the get token API have a finite period of time for which they are valid.
2735
+ After that time period, they can no longer be used.
2736
+ The time period is defined by the <code>xpack.security.authc.token.timeout</code> setting.</p>
2737
+ <p>The refresh tokens returned by the get token API are only valid for 24 hours.
2738
+ They can also be used exactly once.
2739
+ If you want to invalidate one or more access or refresh tokens immediately, use this invalidate token API.</p>
2740
+ <p>NOTE: While all parameters are optional, at least one of them is required.
2741
+ More specifically, either one of <code>token</code> or <code>refresh_token</code> parameters is required.
2742
+ If none of these two are specified, then <code>realm_name</code> and/or <code>username</code> need to be specified.</p>
2743
+
2744
+
2745
+ `<https://www.elastic.co/docs/api/doc/elasticsearch/v9/operation/operation-security-invalidate-token>`_
2746
+
2747
+ :param realm_name: The name of an authentication realm. This parameter cannot
2748
+ be used with either `refresh_token` or `token`.
2749
+ :param refresh_token: A refresh token. This parameter cannot be used if any of
2750
+ `refresh_token`, `realm_name`, or `username` are used.
2751
+ :param token: An access token. This parameter cannot be used if any of `refresh_token`,
2752
+ `realm_name`, or `username` are used.
2753
+ :param username: The username of a user. This parameter cannot be used with either
2754
+ `refresh_token` or `token`.
2755
+ """
2756
+ __path_parts: t.Dict[str, str] = {}
2757
+ __path = "/_security/oauth2/token"
2758
+ __query: t.Dict[str, t.Any] = {}
2759
+ __body: t.Dict[str, t.Any] = body if body is not None else {}
2760
+ if error_trace is not None:
2761
+ __query["error_trace"] = error_trace
2762
+ if filter_path is not None:
2763
+ __query["filter_path"] = filter_path
2764
+ if human is not None:
2765
+ __query["human"] = human
2766
+ if pretty is not None:
2767
+ __query["pretty"] = pretty
2768
+ if not __body:
2769
+ if realm_name is not None:
2770
+ __body["realm_name"] = realm_name
2771
+ if refresh_token is not None:
2772
+ __body["refresh_token"] = refresh_token
2773
+ if token is not None:
2774
+ __body["token"] = token
2775
+ if username is not None:
2776
+ __body["username"] = username
2777
+ __headers = {"accept": "application/json", "content-type": "application/json"}
2778
+ return await self.perform_request( # type: ignore[return-value]
2779
+ "DELETE",
2780
+ __path,
2781
+ params=__query,
2782
+ headers=__headers,
2783
+ body=__body,
2784
+ endpoint_id="security.invalidate_token",
2785
+ path_parts=__path_parts,
2786
+ )
2787
+
2788
+ @_rewrite_parameters(
2789
+ body_fields=("nonce", "redirect_uri", "state", "realm"),
2790
+ )
2791
+ async def oidc_authenticate(
2792
+ self,
2793
+ *,
2794
+ nonce: t.Optional[str] = None,
2795
+ redirect_uri: t.Optional[str] = None,
2796
+ state: t.Optional[str] = None,
2797
+ error_trace: t.Optional[bool] = None,
2798
+ filter_path: t.Optional[t.Union[str, t.Sequence[str]]] = None,
2799
+ human: t.Optional[bool] = None,
2800
+ pretty: t.Optional[bool] = None,
2801
+ realm: t.Optional[str] = None,
2802
+ body: t.Optional[t.Dict[str, t.Any]] = None,
2803
+ ) -> ObjectApiResponse[t.Any]:
2804
+ """
2805
+ .. raw:: html
2806
+
2807
+ <p>Authenticate OpenID Connect.</p>
2808
+ <p>Exchange an OpenID Connect authentication response message for an Elasticsearch internal access token and refresh token that can be subsequently used for authentication.</p>
2809
+ <p>Elasticsearch exposes all the necessary OpenID Connect related functionality with the OpenID Connect APIs.
2810
+ These APIs are used internally by Kibana in order to provide OpenID Connect based authentication, but can also be used by other, custom web applications or other clients.</p>
2811
+
2812
+
2813
+ `<https://www.elastic.co/docs/api/doc/elasticsearch/v9/operation/operation-security-oidc-authenticate>`_
2814
+
2815
+ :param nonce: Associate a client session with an ID token and mitigate replay
2816
+ attacks. This value needs to be the same as the one that was provided to
2817
+ the `/_security/oidc/prepare` API or the one that was generated by Elasticsearch
2818
+ and included in the response to that call.
2819
+ :param redirect_uri: The URL to which the OpenID Connect Provider redirected
2820
+ the User Agent in response to an authentication request after a successful
2821
+ authentication. This URL must be provided as-is (URL encoded), taken from
2822
+ the body of the response or as the value of a location header in the response
2823
+ from the OpenID Connect Provider.
2824
+ :param state: Maintain state between the authentication request and the response.
2825
+ This value needs to be the same as the one that was provided to the `/_security/oidc/prepare`
2826
+ API or the one that was generated by Elasticsearch and included in the response
2827
+ to that call.
2828
+ :param realm: The name of the OpenID Connect realm. This property is useful in
2829
+ cases where multiple realms are defined.
2830
+ """
2831
+ if nonce is None and body is None:
2832
+ raise ValueError("Empty value passed for parameter 'nonce'")
2833
+ if redirect_uri is None and body is None:
2834
+ raise ValueError("Empty value passed for parameter 'redirect_uri'")
2835
+ if state is None and body is None:
2836
+ raise ValueError("Empty value passed for parameter 'state'")
2837
+ __path_parts: t.Dict[str, str] = {}
2838
+ __path = "/_security/oidc/authenticate"
2839
+ __query: t.Dict[str, t.Any] = {}
2840
+ __body: t.Dict[str, t.Any] = body if body is not None else {}
2841
+ if error_trace is not None:
2842
+ __query["error_trace"] = error_trace
2843
+ if filter_path is not None:
2844
+ __query["filter_path"] = filter_path
2845
+ if human is not None:
2846
+ __query["human"] = human
2847
+ if pretty is not None:
2848
+ __query["pretty"] = pretty
2849
+ if not __body:
2850
+ if nonce is not None:
2851
+ __body["nonce"] = nonce
2852
+ if redirect_uri is not None:
2853
+ __body["redirect_uri"] = redirect_uri
2854
+ if state is not None:
2855
+ __body["state"] = state
2856
+ if realm is not None:
2857
+ __body["realm"] = realm
2858
+ __headers = {"accept": "application/json", "content-type": "application/json"}
2859
+ return await self.perform_request( # type: ignore[return-value]
2860
+ "POST",
2861
+ __path,
2862
+ params=__query,
2863
+ headers=__headers,
2864
+ body=__body,
2865
+ endpoint_id="security.oidc_authenticate",
2866
+ path_parts=__path_parts,
2867
+ )
2868
+
2869
+ @_rewrite_parameters(
2870
+ body_fields=("token", "refresh_token"),
2871
+ )
2872
+ async def oidc_logout(
2873
+ self,
2874
+ *,
2875
+ token: t.Optional[str] = None,
2876
+ error_trace: t.Optional[bool] = None,
2877
+ filter_path: t.Optional[t.Union[str, t.Sequence[str]]] = None,
2878
+ human: t.Optional[bool] = None,
2879
+ pretty: t.Optional[bool] = None,
2880
+ refresh_token: t.Optional[str] = None,
2881
+ body: t.Optional[t.Dict[str, t.Any]] = None,
2882
+ ) -> ObjectApiResponse[t.Any]:
2883
+ """
2884
+ .. raw:: html
2885
+
2886
+ <p>Logout of OpenID Connect.</p>
2887
+ <p>Invalidate an access token and a refresh token that were generated as a response to the <code>/_security/oidc/authenticate</code> API.</p>
2888
+ <p>If the OpenID Connect authentication realm in Elasticsearch is accordingly configured, the response to this call will contain a URI pointing to the end session endpoint of the OpenID Connect Provider in order to perform single logout.</p>
2889
+ <p>Elasticsearch exposes all the necessary OpenID Connect related functionality with the OpenID Connect APIs.
2890
+ These APIs are used internally by Kibana in order to provide OpenID Connect based authentication, but can also be used by other, custom web applications or other clients.</p>
2891
+
2892
+
2893
+ `<https://www.elastic.co/docs/api/doc/elasticsearch/v9/operation/operation-security-oidc-logout>`_
2894
+
2895
+ :param token: The access token to be invalidated.
2896
+ :param refresh_token: The refresh token to be invalidated.
2897
+ """
2898
+ if token is None and body is None:
2899
+ raise ValueError("Empty value passed for parameter 'token'")
2900
+ __path_parts: t.Dict[str, str] = {}
2901
+ __path = "/_security/oidc/logout"
2902
+ __query: t.Dict[str, t.Any] = {}
2903
+ __body: t.Dict[str, t.Any] = body if body is not None else {}
2904
+ if error_trace is not None:
2905
+ __query["error_trace"] = error_trace
2906
+ if filter_path is not None:
2907
+ __query["filter_path"] = filter_path
2908
+ if human is not None:
2909
+ __query["human"] = human
2910
+ if pretty is not None:
2911
+ __query["pretty"] = pretty
2912
+ if not __body:
2913
+ if token is not None:
2914
+ __body["token"] = token
2915
+ if refresh_token is not None:
2916
+ __body["refresh_token"] = refresh_token
2917
+ __headers = {"accept": "application/json", "content-type": "application/json"}
2918
+ return await self.perform_request( # type: ignore[return-value]
2919
+ "POST",
2920
+ __path,
2921
+ params=__query,
2922
+ headers=__headers,
2923
+ body=__body,
2924
+ endpoint_id="security.oidc_logout",
2925
+ path_parts=__path_parts,
2926
+ )
2927
+
2928
+ @_rewrite_parameters(
2929
+ body_fields=("iss", "login_hint", "nonce", "realm", "state"),
2930
+ )
2931
+ async def oidc_prepare_authentication(
2932
+ self,
2933
+ *,
2934
+ error_trace: t.Optional[bool] = None,
2935
+ filter_path: t.Optional[t.Union[str, t.Sequence[str]]] = None,
2936
+ human: t.Optional[bool] = None,
2937
+ iss: t.Optional[str] = None,
2938
+ login_hint: t.Optional[str] = None,
2939
+ nonce: t.Optional[str] = None,
2940
+ pretty: t.Optional[bool] = None,
2941
+ realm: t.Optional[str] = None,
2942
+ state: t.Optional[str] = None,
2943
+ body: t.Optional[t.Dict[str, t.Any]] = None,
2944
+ ) -> ObjectApiResponse[t.Any]:
2945
+ """
2946
+ .. raw:: html
2947
+
2948
+ <p>Prepare OpenID connect authentication.</p>
2949
+ <p>Create an oAuth 2.0 authentication request as a URL string based on the configuration of the OpenID Connect authentication realm in Elasticsearch.</p>
2950
+ <p>The response of this API is a URL pointing to the Authorization Endpoint of the configured OpenID Connect Provider, which can be used to redirect the browser of the user in order to continue the authentication process.</p>
2951
+ <p>Elasticsearch exposes all the necessary OpenID Connect related functionality with the OpenID Connect APIs.
2952
+ These APIs are used internally by Kibana in order to provide OpenID Connect based authentication, but can also be used by other, custom web applications or other clients.</p>
2953
+
2954
+
2955
+ `<https://www.elastic.co/docs/api/doc/elasticsearch/v9/operation/operation-security-oidc-prepare-authentication>`_
2956
+
2957
+ :param iss: In the case of a third party initiated single sign on, this is the
2958
+ issuer identifier for the OP that the RP is to send the authentication request
2959
+ to. It cannot be specified when *realm* is specified. One of *realm* or *iss*
2960
+ is required.
2961
+ :param login_hint: In the case of a third party initiated single sign on, it
2962
+ is a string value that is included in the authentication request as the *login_hint*
2963
+ parameter. This parameter is not valid when *realm* is specified.
2964
+ :param nonce: The value used to associate a client session with an ID token and
2965
+ to mitigate replay attacks. If the caller of the API does not provide a value,
2966
+ Elasticsearch will generate one with sufficient entropy and return it in
2967
+ the response.
2968
+ :param realm: The name of the OpenID Connect realm in Elasticsearch the configuration
2969
+ of which should be used in order to generate the authentication request.
2970
+ It cannot be specified when *iss* is specified. One of *realm* or *iss* is
2971
+ required.
2972
+ :param state: The value used to maintain state between the authentication request
2973
+ and the response, typically used as a Cross-Site Request Forgery mitigation.
2974
+ If the caller of the API does not provide a value, Elasticsearch will generate
2975
+ one with sufficient entropy and return it in the response.
2976
+ """
2977
+ __path_parts: t.Dict[str, str] = {}
2978
+ __path = "/_security/oidc/prepare"
2979
+ __query: t.Dict[str, t.Any] = {}
2980
+ __body: t.Dict[str, t.Any] = body if body is not None else {}
2981
+ if error_trace is not None:
2982
+ __query["error_trace"] = error_trace
2983
+ if filter_path is not None:
2984
+ __query["filter_path"] = filter_path
2985
+ if human is not None:
2986
+ __query["human"] = human
2987
+ if pretty is not None:
2988
+ __query["pretty"] = pretty
2989
+ if not __body:
2990
+ if iss is not None:
2991
+ __body["iss"] = iss
2992
+ if login_hint is not None:
2993
+ __body["login_hint"] = login_hint
2994
+ if nonce is not None:
2995
+ __body["nonce"] = nonce
2996
+ if realm is not None:
2997
+ __body["realm"] = realm
2998
+ if state is not None:
2999
+ __body["state"] = state
3000
+ __headers = {"accept": "application/json", "content-type": "application/json"}
3001
+ return await self.perform_request( # type: ignore[return-value]
3002
+ "POST",
3003
+ __path,
3004
+ params=__query,
3005
+ headers=__headers,
3006
+ body=__body,
3007
+ endpoint_id="security.oidc_prepare_authentication",
3008
+ path_parts=__path_parts,
3009
+ )
3010
+
3011
+ @_rewrite_parameters(
3012
+ body_name="privileges",
3013
+ )
3014
+ async def put_privileges(
3015
+ self,
3016
+ *,
3017
+ privileges: t.Optional[
3018
+ t.Mapping[str, t.Mapping[str, t.Mapping[str, t.Any]]]
3019
+ ] = None,
3020
+ body: t.Optional[t.Mapping[str, t.Mapping[str, t.Mapping[str, t.Any]]]] = None,
3021
+ error_trace: t.Optional[bool] = None,
3022
+ filter_path: t.Optional[t.Union[str, t.Sequence[str]]] = None,
3023
+ human: t.Optional[bool] = None,
3024
+ pretty: t.Optional[bool] = None,
3025
+ refresh: t.Optional[
3026
+ t.Union[bool, str, t.Literal["false", "true", "wait_for"]]
3027
+ ] = None,
3028
+ ) -> ObjectApiResponse[t.Any]:
3029
+ """
3030
+ .. raw:: html
3031
+
3032
+ <p>Create or update application privileges.</p>
3033
+ <p>To use this API, you must have one of the following privileges:</p>
3034
+ <ul>
3035
+ <li>The <code>manage_security</code> cluster privilege (or a greater privilege such as <code>all</code>).</li>
3036
+ <li>The &quot;Manage Application Privileges&quot; global privilege for the application being referenced in the request.</li>
3037
+ </ul>
3038
+ <p>Application names are formed from a prefix, with an optional suffix that conform to the following rules:</p>
3039
+ <ul>
3040
+ <li>The prefix must begin with a lowercase ASCII letter.</li>
3041
+ <li>The prefix must contain only ASCII letters or digits.</li>
3042
+ <li>The prefix must be at least 3 characters long.</li>
3043
+ <li>If the suffix exists, it must begin with either a dash <code>-</code> or <code>_</code>.</li>
3044
+ <li>The suffix cannot contain any of the following characters: <code>\\</code>, <code>/</code>, <code>*</code>, <code>?</code>, <code>&quot;</code>, <code>&lt;</code>, <code>&gt;</code>, <code>|</code>, <code>,</code>, <code>*</code>.</li>
3045
+ <li>No part of the name can contain whitespace.</li>
3046
+ </ul>
3047
+ <p>Privilege names must begin with a lowercase ASCII letter and must contain only ASCII letters and digits along with the characters <code>_</code>, <code>-</code>, and <code>.</code>.</p>
3048
+ <p>Action names can contain any number of printable ASCII characters and must contain at least one of the following characters: <code>/</code>, <code>*</code>, <code>:</code>.</p>
3049
+
3050
+
3051
+ `<https://www.elastic.co/docs/api/doc/elasticsearch/v9/operation/operation-security-put-privileges>`_
3052
+
3053
+ :param privileges:
3054
+ :param refresh: If `true` (the default) then refresh the affected shards to make
3055
+ this operation visible to search, if `wait_for` then wait for a refresh to
3056
+ make this operation visible to search, if `false` then do nothing with refreshes.
3057
+ """
3058
+ if privileges is None and body is None:
3059
+ raise ValueError(
3060
+ "Empty value passed for parameters 'privileges' and 'body', one of them should be set."
3061
+ )
3062
+ elif privileges is not None and body is not None:
3063
+ raise ValueError("Cannot set both 'privileges' and 'body'")
3064
+ __path_parts: t.Dict[str, str] = {}
3065
+ __path = "/_security/privilege"
3066
+ __query: t.Dict[str, t.Any] = {}
3067
+ if error_trace is not None:
3068
+ __query["error_trace"] = error_trace
3069
+ if filter_path is not None:
3070
+ __query["filter_path"] = filter_path
3071
+ if human is not None:
3072
+ __query["human"] = human
3073
+ if pretty is not None:
3074
+ __query["pretty"] = pretty
3075
+ if refresh is not None:
3076
+ __query["refresh"] = refresh
3077
+ __body = privileges if privileges is not None else body
3078
+ __headers = {"accept": "application/json", "content-type": "application/json"}
3079
+ return await self.perform_request( # type: ignore[return-value]
3080
+ "PUT",
3081
+ __path,
3082
+ params=__query,
3083
+ headers=__headers,
3084
+ body=__body,
3085
+ endpoint_id="security.put_privileges",
3086
+ path_parts=__path_parts,
3087
+ )
3088
+
3089
+ @_rewrite_parameters(
3090
+ body_fields=(
3091
+ "applications",
3092
+ "cluster",
3093
+ "description",
3094
+ "global_",
3095
+ "indices",
3096
+ "metadata",
3097
+ "remote_cluster",
3098
+ "remote_indices",
3099
+ "run_as",
3100
+ "transient_metadata",
3101
+ ),
3102
+ parameter_aliases={"global": "global_"},
3103
+ )
3104
+ async def put_role(
3105
+ self,
3106
+ *,
3107
+ name: str,
3108
+ applications: t.Optional[t.Sequence[t.Mapping[str, t.Any]]] = None,
3109
+ cluster: t.Optional[
3110
+ t.Sequence[
3111
+ t.Union[
3112
+ str,
3113
+ t.Literal[
3114
+ "all",
3115
+ "cancel_task",
3116
+ "create_snapshot",
3117
+ "cross_cluster_replication",
3118
+ "cross_cluster_search",
3119
+ "delegate_pki",
3120
+ "grant_api_key",
3121
+ "manage",
3122
+ "manage_api_key",
3123
+ "manage_autoscaling",
3124
+ "manage_behavioral_analytics",
3125
+ "manage_ccr",
3126
+ "manage_data_frame_transforms",
3127
+ "manage_data_stream_global_retention",
3128
+ "manage_enrich",
3129
+ "manage_ilm",
3130
+ "manage_index_templates",
3131
+ "manage_inference",
3132
+ "manage_ingest_pipelines",
3133
+ "manage_logstash_pipelines",
3134
+ "manage_ml",
3135
+ "manage_oidc",
3136
+ "manage_own_api_key",
3137
+ "manage_pipeline",
3138
+ "manage_rollup",
3139
+ "manage_saml",
3140
+ "manage_search_application",
3141
+ "manage_search_query_rules",
3142
+ "manage_search_synonyms",
3143
+ "manage_security",
3144
+ "manage_service_account",
3145
+ "manage_slm",
3146
+ "manage_token",
3147
+ "manage_transform",
3148
+ "manage_user_profile",
3149
+ "manage_watcher",
3150
+ "monitor",
3151
+ "monitor_data_frame_transforms",
3152
+ "monitor_data_stream_global_retention",
3153
+ "monitor_enrich",
3154
+ "monitor_inference",
3155
+ "monitor_ml",
3156
+ "monitor_rollup",
3157
+ "monitor_snapshot",
3158
+ "monitor_stats",
3159
+ "monitor_text_structure",
3160
+ "monitor_transform",
3161
+ "monitor_watcher",
3162
+ "none",
3163
+ "post_behavioral_analytics_event",
3164
+ "read_ccr",
3165
+ "read_fleet_secrets",
3166
+ "read_ilm",
3167
+ "read_pipeline",
3168
+ "read_security",
3169
+ "read_slm",
3170
+ "transport_client",
3171
+ "write_connector_secrets",
3172
+ "write_fleet_secrets",
3173
+ ],
3174
+ ]
3175
+ ]
3176
+ ] = None,
3177
+ description: t.Optional[str] = None,
3178
+ error_trace: t.Optional[bool] = None,
3179
+ filter_path: t.Optional[t.Union[str, t.Sequence[str]]] = None,
3180
+ global_: t.Optional[t.Mapping[str, t.Any]] = None,
3181
+ human: t.Optional[bool] = None,
3182
+ indices: t.Optional[t.Sequence[t.Mapping[str, t.Any]]] = None,
3183
+ metadata: t.Optional[t.Mapping[str, t.Any]] = None,
3184
+ pretty: t.Optional[bool] = None,
3185
+ refresh: t.Optional[
3186
+ t.Union[bool, str, t.Literal["false", "true", "wait_for"]]
3187
+ ] = None,
3188
+ remote_cluster: t.Optional[t.Sequence[t.Mapping[str, t.Any]]] = None,
3189
+ remote_indices: t.Optional[t.Sequence[t.Mapping[str, t.Any]]] = None,
3190
+ run_as: t.Optional[t.Sequence[str]] = None,
3191
+ transient_metadata: t.Optional[t.Mapping[str, t.Any]] = None,
3192
+ body: t.Optional[t.Dict[str, t.Any]] = None,
3193
+ ) -> ObjectApiResponse[t.Any]:
3194
+ """
3195
+ .. raw:: html
3196
+
3197
+ <p>Create or update roles.</p>
3198
+ <p>The role management APIs are generally the preferred way to manage roles in the native realm, rather than using file-based role management.
3199
+ The create or update roles API cannot update roles that are defined in roles files.
3200
+ File-based role management is not available in Elastic Serverless.</p>
3201
+
3202
+
3203
+ `<https://www.elastic.co/docs/api/doc/elasticsearch/v9/operation/operation-security-put-role>`_
3204
+
3205
+ :param name: The name of the role that is being created or updated. On Elasticsearch
3206
+ Serverless, the role name must begin with a letter or digit and can only
3207
+ contain letters, digits and the characters '_', '-', and '.'. Each role must
3208
+ have a unique name, as this will serve as the identifier for that role.
3209
+ :param applications: A list of application privilege entries.
3210
+ :param cluster: A list of cluster privileges. These privileges define the cluster-level
3211
+ actions for users with this role.
3212
+ :param description: Optional description of the role descriptor
3213
+ :param global_: An object defining global privileges. A global privilege is a
3214
+ form of cluster privilege that is request-aware. Support for global privileges
3215
+ is currently limited to the management of application privileges.
3216
+ :param indices: A list of indices permissions entries.
3217
+ :param metadata: Optional metadata. Within the metadata object, keys that begin
3218
+ with an underscore (`_`) are reserved for system use.
3219
+ :param refresh: If `true` (the default) then refresh the affected shards to make
3220
+ this operation visible to search, if `wait_for` then wait for a refresh to
3221
+ make this operation visible to search, if `false` then do nothing with refreshes.
3222
+ :param remote_cluster: A list of remote cluster permissions entries.
3223
+ :param remote_indices: A list of remote indices permissions entries. NOTE: Remote
3224
+ indices are effective for remote clusters configured with the API key based
3225
+ model. They have no effect for remote clusters configured with the certificate
3226
+ based model.
3227
+ :param run_as: A list of users that the owners of this role can impersonate.
3228
+ *Note*: in Serverless, the run-as feature is disabled. For API compatibility,
3229
+ you can still specify an empty `run_as` field, but a non-empty list will
3230
+ be rejected.
3231
+ :param transient_metadata: Indicates roles that might be incompatible with the
3232
+ current cluster license, specifically roles with document and field level
3233
+ security. When the cluster license doesn’t allow certain features for a given
3234
+ role, this parameter is updated dynamically to list the incompatible features.
3235
+ If `enabled` is `false`, the role is ignored, but is still listed in the
3236
+ response from the authenticate API.
3237
+ """
3238
+ if name in SKIP_IN_PATH:
3239
+ raise ValueError("Empty value passed for parameter 'name'")
3240
+ __path_parts: t.Dict[str, str] = {"name": _quote(name)}
3241
+ __path = f'/_security/role/{__path_parts["name"]}'
3242
+ __query: t.Dict[str, t.Any] = {}
3243
+ __body: t.Dict[str, t.Any] = body if body is not None else {}
3244
+ if error_trace is not None:
3245
+ __query["error_trace"] = error_trace
3246
+ if filter_path is not None:
3247
+ __query["filter_path"] = filter_path
3248
+ if human is not None:
3249
+ __query["human"] = human
3250
+ if pretty is not None:
3251
+ __query["pretty"] = pretty
3252
+ if refresh is not None:
3253
+ __query["refresh"] = refresh
3254
+ if not __body:
3255
+ if applications is not None:
3256
+ __body["applications"] = applications
3257
+ if cluster is not None:
3258
+ __body["cluster"] = cluster
3259
+ if description is not None:
3260
+ __body["description"] = description
3261
+ if global_ is not None:
3262
+ __body["global"] = global_
3263
+ if indices is not None:
3264
+ __body["indices"] = indices
3265
+ if metadata is not None:
3266
+ __body["metadata"] = metadata
3267
+ if remote_cluster is not None:
3268
+ __body["remote_cluster"] = remote_cluster
3269
+ if remote_indices is not None:
3270
+ __body["remote_indices"] = remote_indices
3271
+ if run_as is not None:
3272
+ __body["run_as"] = run_as
3273
+ if transient_metadata is not None:
3274
+ __body["transient_metadata"] = transient_metadata
3275
+ __headers = {"accept": "application/json", "content-type": "application/json"}
3276
+ return await self.perform_request( # type: ignore[return-value]
3277
+ "PUT",
3278
+ __path,
3279
+ params=__query,
3280
+ headers=__headers,
3281
+ body=__body,
3282
+ endpoint_id="security.put_role",
3283
+ path_parts=__path_parts,
3284
+ )
3285
+
3286
+ @_rewrite_parameters(
3287
+ body_fields=(
3288
+ "enabled",
3289
+ "metadata",
3290
+ "role_templates",
3291
+ "roles",
3292
+ "rules",
3293
+ "run_as",
3294
+ ),
3295
+ )
3296
+ async def put_role_mapping(
3297
+ self,
3298
+ *,
3299
+ name: str,
3300
+ enabled: t.Optional[bool] = None,
3301
+ error_trace: t.Optional[bool] = None,
3302
+ filter_path: t.Optional[t.Union[str, t.Sequence[str]]] = None,
3303
+ human: t.Optional[bool] = None,
3304
+ metadata: t.Optional[t.Mapping[str, t.Any]] = None,
3305
+ pretty: t.Optional[bool] = None,
3306
+ refresh: t.Optional[
3307
+ t.Union[bool, str, t.Literal["false", "true", "wait_for"]]
3308
+ ] = None,
3309
+ role_templates: t.Optional[t.Sequence[t.Mapping[str, t.Any]]] = None,
3310
+ roles: t.Optional[t.Sequence[str]] = None,
3311
+ rules: t.Optional[t.Mapping[str, t.Any]] = None,
3312
+ run_as: t.Optional[t.Sequence[str]] = None,
3313
+ body: t.Optional[t.Dict[str, t.Any]] = None,
3314
+ ) -> ObjectApiResponse[t.Any]:
3315
+ """
3316
+ .. raw:: html
3317
+
3318
+ <p>Create or update role mappings.</p>
3319
+ <p>Role mappings define which roles are assigned to each user.
3320
+ Each mapping has rules that identify users and a list of roles that are granted to those users.
3321
+ The role mapping APIs are generally the preferred way to manage role mappings rather than using role mapping files. The create or update role mappings API cannot update role mappings that are defined in role mapping files.</p>
3322
+ <p>NOTE: This API does not create roles. Rather, it maps users to existing roles.
3323
+ Roles can be created by using the create or update roles API or roles files.</p>
3324
+ <p><strong>Role templates</strong></p>
3325
+ <p>The most common use for role mappings is to create a mapping from a known value on the user to a fixed role name.
3326
+ For example, all users in the <code>cn=admin,dc=example,dc=com</code> LDAP group should be given the superuser role in Elasticsearch.
3327
+ The <code>roles</code> field is used for this purpose.</p>
3328
+ <p>For more complex needs, it is possible to use Mustache templates to dynamically determine the names of the roles that should be granted to the user.
3329
+ The <code>role_templates</code> field is used for this purpose.</p>
3330
+ <p>NOTE: To use role templates successfully, the relevant scripting feature must be enabled.
3331
+ Otherwise, all attempts to create a role mapping with role templates fail.</p>
3332
+ <p>All of the user fields that are available in the role mapping rules are also available in the role templates.
3333
+ Thus it is possible to assign a user to a role that reflects their username, their groups, or the name of the realm to which they authenticated.</p>
3334
+ <p>By default a template is evaluated to produce a single string that is the name of the role which should be assigned to the user.
3335
+ If the format of the template is set to &quot;json&quot; then the template is expected to produce a JSON string or an array of JSON strings for the role names.</p>
3336
+
3337
+
3338
+ `<https://www.elastic.co/docs/api/doc/elasticsearch/v9/operation/operation-security-put-role-mapping>`_
3339
+
3340
+ :param name: The distinct name that identifies the role mapping. The name is
3341
+ used solely as an identifier to facilitate interaction via the API; it does
3342
+ not affect the behavior of the mapping in any way.
3343
+ :param enabled: Mappings that have `enabled` set to `false` are ignored when
3344
+ role mapping is performed.
3345
+ :param metadata: Additional metadata that helps define which roles are assigned
3346
+ to each user. Within the metadata object, keys beginning with `_` are reserved
3347
+ for system usage.
3348
+ :param refresh: If `true` (the default) then refresh the affected shards to make
3349
+ this operation visible to search, if `wait_for` then wait for a refresh to
3350
+ make this operation visible to search, if `false` then do nothing with refreshes.
3351
+ :param role_templates: A list of Mustache templates that will be evaluated to
3352
+ determine the roles names that should granted to the users that match the
3353
+ role mapping rules. Exactly one of `roles` or `role_templates` must be specified.
3354
+ :param roles: A list of role names that are granted to the users that match the
3355
+ role mapping rules. Exactly one of `roles` or `role_templates` must be specified.
3356
+ :param rules: The rules that determine which users should be matched by the mapping.
3357
+ A rule is a logical condition that is expressed by using a JSON DSL.
3358
+ :param run_as:
3359
+ """
3360
+ if name in SKIP_IN_PATH:
3361
+ raise ValueError("Empty value passed for parameter 'name'")
3362
+ __path_parts: t.Dict[str, str] = {"name": _quote(name)}
3363
+ __path = f'/_security/role_mapping/{__path_parts["name"]}'
3364
+ __query: t.Dict[str, t.Any] = {}
3365
+ __body: t.Dict[str, t.Any] = body if body is not None else {}
3366
+ if error_trace is not None:
3367
+ __query["error_trace"] = error_trace
3368
+ if filter_path is not None:
3369
+ __query["filter_path"] = filter_path
3370
+ if human is not None:
3371
+ __query["human"] = human
3372
+ if pretty is not None:
3373
+ __query["pretty"] = pretty
3374
+ if refresh is not None:
3375
+ __query["refresh"] = refresh
3376
+ if not __body:
3377
+ if enabled is not None:
3378
+ __body["enabled"] = enabled
3379
+ if metadata is not None:
3380
+ __body["metadata"] = metadata
3381
+ if role_templates is not None:
3382
+ __body["role_templates"] = role_templates
3383
+ if roles is not None:
3384
+ __body["roles"] = roles
3385
+ if rules is not None:
3386
+ __body["rules"] = rules
3387
+ if run_as is not None:
3388
+ __body["run_as"] = run_as
3389
+ __headers = {"accept": "application/json", "content-type": "application/json"}
3390
+ return await self.perform_request( # type: ignore[return-value]
3391
+ "PUT",
3392
+ __path,
3393
+ params=__query,
3394
+ headers=__headers,
3395
+ body=__body,
3396
+ endpoint_id="security.put_role_mapping",
3397
+ path_parts=__path_parts,
3398
+ )
3399
+
3400
+ @_rewrite_parameters(
3401
+ body_fields=(
3402
+ "email",
3403
+ "enabled",
3404
+ "full_name",
3405
+ "metadata",
3406
+ "password",
3407
+ "password_hash",
3408
+ "roles",
3409
+ ),
3410
+ )
3411
+ async def put_user(
3412
+ self,
3413
+ *,
3414
+ username: str,
3415
+ email: t.Optional[t.Union[None, str]] = None,
3416
+ enabled: t.Optional[bool] = None,
3417
+ error_trace: t.Optional[bool] = None,
3418
+ filter_path: t.Optional[t.Union[str, t.Sequence[str]]] = None,
3419
+ full_name: t.Optional[t.Union[None, str]] = None,
3420
+ human: t.Optional[bool] = None,
3421
+ metadata: t.Optional[t.Mapping[str, t.Any]] = None,
3422
+ password: t.Optional[str] = None,
3423
+ password_hash: t.Optional[str] = None,
3424
+ pretty: t.Optional[bool] = None,
3425
+ refresh: t.Optional[
3426
+ t.Union[bool, str, t.Literal["false", "true", "wait_for"]]
3427
+ ] = None,
3428
+ roles: t.Optional[t.Sequence[str]] = None,
3429
+ body: t.Optional[t.Dict[str, t.Any]] = None,
3430
+ ) -> ObjectApiResponse[t.Any]:
3431
+ """
3432
+ .. raw:: html
3433
+
3434
+ <p>Create or update users.</p>
3435
+ <p>Add and update users in the native realm.
3436
+ A password is required for adding a new user but is optional when updating an existing user.
3437
+ To change a user's password without updating any other fields, use the change password API.</p>
3438
+
3439
+
3440
+ `<https://www.elastic.co/docs/api/doc/elasticsearch/v9/operation/operation-security-put-user>`_
3441
+
3442
+ :param username: An identifier for the user. NOTE: Usernames must be at least
3443
+ 1 and no more than 507 characters. They can contain alphanumeric characters
3444
+ (a-z, A-Z, 0-9), spaces, punctuation, and printable symbols in the Basic
3445
+ Latin (ASCII) block. Leading or trailing whitespace is not allowed.
3446
+ :param email: The email of the user.
3447
+ :param enabled: Specifies whether the user is enabled.
3448
+ :param full_name: The full name of the user.
3449
+ :param metadata: Arbitrary metadata that you want to associate with the user.
3450
+ :param password: The user's password. Passwords must be at least 6 characters
3451
+ long. When adding a user, one of `password` or `password_hash` is required.
3452
+ When updating an existing user, the password is optional, so that other fields
3453
+ on the user (such as their roles) may be updated without modifying the user's
3454
+ password
3455
+ :param password_hash: A hash of the user's password. This must be produced using
3456
+ the same hashing algorithm as has been configured for password storage. For
3457
+ more details, see the explanation of the `xpack.security.authc.password_hashing.algorithm`
3458
+ setting in the user cache and password hash algorithm documentation. Using
3459
+ this parameter allows the client to pre-hash the password for performance
3460
+ and/or confidentiality reasons. The `password` parameter and the `password_hash`
3461
+ parameter cannot be used in the same request.
3462
+ :param refresh: Valid values are `true`, `false`, and `wait_for`. These values
3463
+ have the same meaning as in the index API, but the default value for this
3464
+ API is true.
3465
+ :param roles: A set of roles the user has. The roles determine the user's access
3466
+ permissions. To create a user without any roles, specify an empty list (`[]`).
3467
+ """
3468
+ if username in SKIP_IN_PATH:
3469
+ raise ValueError("Empty value passed for parameter 'username'")
3470
+ __path_parts: t.Dict[str, str] = {"username": _quote(username)}
3471
+ __path = f'/_security/user/{__path_parts["username"]}'
3472
+ __query: t.Dict[str, t.Any] = {}
3473
+ __body: t.Dict[str, t.Any] = body if body is not None else {}
3474
+ if error_trace is not None:
3475
+ __query["error_trace"] = error_trace
3476
+ if filter_path is not None:
3477
+ __query["filter_path"] = filter_path
3478
+ if human is not None:
3479
+ __query["human"] = human
3480
+ if pretty is not None:
3481
+ __query["pretty"] = pretty
3482
+ if refresh is not None:
3483
+ __query["refresh"] = refresh
3484
+ if not __body:
3485
+ if email is not None:
3486
+ __body["email"] = email
3487
+ if enabled is not None:
3488
+ __body["enabled"] = enabled
3489
+ if full_name is not None:
3490
+ __body["full_name"] = full_name
3491
+ if metadata is not None:
3492
+ __body["metadata"] = metadata
3493
+ if password is not None:
3494
+ __body["password"] = password
3495
+ if password_hash is not None:
3496
+ __body["password_hash"] = password_hash
3497
+ if roles is not None:
3498
+ __body["roles"] = roles
3499
+ __headers = {"accept": "application/json", "content-type": "application/json"}
3500
+ return await self.perform_request( # type: ignore[return-value]
3501
+ "PUT",
3502
+ __path,
3503
+ params=__query,
3504
+ headers=__headers,
3505
+ body=__body,
3506
+ endpoint_id="security.put_user",
3507
+ path_parts=__path_parts,
3508
+ )
3509
+
3510
+ @_rewrite_parameters(
3511
+ body_fields=(
3512
+ "aggregations",
3513
+ "aggs",
3514
+ "from_",
3515
+ "query",
3516
+ "search_after",
3517
+ "size",
3518
+ "sort",
3519
+ ),
3520
+ parameter_aliases={"from": "from_"},
3521
+ )
3522
+ async def query_api_keys(
3523
+ self,
3524
+ *,
3525
+ aggregations: t.Optional[t.Mapping[str, t.Mapping[str, t.Any]]] = None,
3526
+ aggs: t.Optional[t.Mapping[str, t.Mapping[str, t.Any]]] = None,
3527
+ error_trace: t.Optional[bool] = None,
3528
+ filter_path: t.Optional[t.Union[str, t.Sequence[str]]] = None,
3529
+ from_: t.Optional[int] = None,
3530
+ human: t.Optional[bool] = None,
3531
+ pretty: t.Optional[bool] = None,
3532
+ query: t.Optional[t.Mapping[str, t.Any]] = None,
3533
+ search_after: t.Optional[
3534
+ t.Sequence[t.Union[None, bool, float, int, str]]
3535
+ ] = None,
3536
+ size: t.Optional[int] = None,
3537
+ sort: t.Optional[
3538
+ t.Union[
3539
+ t.Sequence[t.Union[str, t.Mapping[str, t.Any]]],
3540
+ t.Union[str, t.Mapping[str, t.Any]],
3541
+ ]
3542
+ ] = None,
3543
+ typed_keys: t.Optional[bool] = None,
3544
+ with_limited_by: t.Optional[bool] = None,
3545
+ with_profile_uid: t.Optional[bool] = None,
3546
+ body: t.Optional[t.Dict[str, t.Any]] = None,
3547
+ ) -> ObjectApiResponse[t.Any]:
3548
+ """
3549
+ .. raw:: html
3550
+
3551
+ <p>Find API keys with a query.</p>
3552
+ <p>Get a paginated list of API keys and their information.
3553
+ You can optionally filter the results with a query.</p>
3554
+ <p>To use this API, you must have at least the <code>manage_own_api_key</code> or the <code>read_security</code> cluster privileges.
3555
+ If you have only the <code>manage_own_api_key</code> privilege, this API returns only the API keys that you own.
3556
+ If you have the <code>read_security</code>, <code>manage_api_key</code>, or greater privileges (including <code>manage_security</code>), this API returns all API keys regardless of ownership.</p>
3557
+
3558
+
3559
+ `<https://www.elastic.co/docs/api/doc/elasticsearch/v9/operation/operation-security-query-api-keys>`_
3560
+
3561
+ :param aggregations: Any aggregations to run over the corpus of returned API
3562
+ keys. Aggregations and queries work together. Aggregations are computed only
3563
+ on the API keys that match the query. This supports only a subset of aggregation
3564
+ types, namely: `terms`, `range`, `date_range`, `missing`, `cardinality`,
3565
+ `value_count`, `composite`, `filter`, and `filters`. Additionally, aggregations
3566
+ only run over the same subset of fields that query works with.
3567
+ :param aggs: Any aggregations to run over the corpus of returned API keys. Aggregations
3568
+ and queries work together. Aggregations are computed only on the API keys
3569
+ that match the query. This supports only a subset of aggregation types, namely:
3570
+ `terms`, `range`, `date_range`, `missing`, `cardinality`, `value_count`,
3571
+ `composite`, `filter`, and `filters`. Additionally, aggregations only run
3572
+ over the same subset of fields that query works with.
3573
+ :param from_: The starting document offset. It must not be negative. By default,
3574
+ you cannot page through more than 10,000 hits using the `from` and `size`
3575
+ parameters. To page through more hits, use the `search_after` parameter.
3576
+ :param query: A query to filter which API keys to return. If the query parameter
3577
+ is missing, it is equivalent to a `match_all` query. The query supports a
3578
+ subset of query types, including `match_all`, `bool`, `term`, `terms`, `match`,
3579
+ `ids`, `prefix`, `wildcard`, `exists`, `range`, and `simple_query_string`.
3580
+ You can query the following public information associated with an API key:
3581
+ `id`, `type`, `name`, `creation`, `expiration`, `invalidated`, `invalidation`,
3582
+ `username`, `realm`, and `metadata`. NOTE: The queryable string values associated
3583
+ with API keys are internally mapped as keywords. Consequently, if no `analyzer`
3584
+ parameter is specified for a `match` query, then the provided match query
3585
+ string is interpreted as a single keyword value. Such a match query is hence
3586
+ equivalent to a `term` query.
3587
+ :param search_after: The search after definition.
3588
+ :param size: The number of hits to return. It must not be negative. The `size`
3589
+ parameter can be set to `0`, in which case no API key matches are returned,
3590
+ only the aggregation results. By default, you cannot page through more than
3591
+ 10,000 hits using the `from` and `size` parameters. To page through more
3592
+ hits, use the `search_after` parameter.
3593
+ :param sort: The sort definition. Other than `id`, all public fields of an API
3594
+ key are eligible for sorting. In addition, sort can also be applied to the
3595
+ `_doc` field to sort by index order.
3596
+ :param typed_keys: Determines whether aggregation names are prefixed by their
3597
+ respective types in the response.
3598
+ :param with_limited_by: Return the snapshot of the owner user's role descriptors
3599
+ associated with the API key. An API key's actual permission is the intersection
3600
+ of its assigned role descriptors and the owner user's role descriptors (effectively
3601
+ limited by it). An API key cannot retrieve any API key’s limited-by role
3602
+ descriptors (including itself) unless it has `manage_api_key` or higher privileges.
3603
+ :param with_profile_uid: Determines whether to also retrieve the profile UID
3604
+ for the API key owner principal. If it exists, the profile UID is returned
3605
+ under the `profile_uid` response field for each API key.
3606
+ """
3607
+ __path_parts: t.Dict[str, str] = {}
3608
+ __path = "/_security/_query/api_key"
3609
+ __query: t.Dict[str, t.Any] = {}
3610
+ __body: t.Dict[str, t.Any] = body if body is not None else {}
3611
+ # The 'sort' parameter with a colon can't be encoded to the body.
3612
+ if sort is not None and (
3613
+ (isinstance(sort, str) and ":" in sort)
3614
+ or (
3615
+ isinstance(sort, (list, tuple))
3616
+ and all(isinstance(_x, str) for _x in sort)
3617
+ and any(":" in _x for _x in sort)
3618
+ )
3619
+ ):
3620
+ __query["sort"] = sort
3621
+ sort = None
3622
+ if error_trace is not None:
3623
+ __query["error_trace"] = error_trace
3624
+ if filter_path is not None:
3625
+ __query["filter_path"] = filter_path
3626
+ if human is not None:
3627
+ __query["human"] = human
3628
+ if pretty is not None:
3629
+ __query["pretty"] = pretty
3630
+ if typed_keys is not None:
3631
+ __query["typed_keys"] = typed_keys
3632
+ if with_limited_by is not None:
3633
+ __query["with_limited_by"] = with_limited_by
3634
+ if with_profile_uid is not None:
3635
+ __query["with_profile_uid"] = with_profile_uid
3636
+ if not __body:
3637
+ if aggregations is not None:
3638
+ __body["aggregations"] = aggregations
3639
+ if aggs is not None:
3640
+ __body["aggs"] = aggs
3641
+ if from_ is not None:
3642
+ __body["from"] = from_
3643
+ if query is not None:
3644
+ __body["query"] = query
3645
+ if search_after is not None:
3646
+ __body["search_after"] = search_after
3647
+ if size is not None:
3648
+ __body["size"] = size
3649
+ if sort is not None:
3650
+ __body["sort"] = sort
3651
+ if not __body:
3652
+ __body = None # type: ignore[assignment]
3653
+ __headers = {"accept": "application/json"}
3654
+ if __body is not None:
3655
+ __headers["content-type"] = "application/json"
3656
+ return await self.perform_request( # type: ignore[return-value]
3657
+ "POST",
3658
+ __path,
3659
+ params=__query,
3660
+ headers=__headers,
3661
+ body=__body,
3662
+ endpoint_id="security.query_api_keys",
3663
+ path_parts=__path_parts,
3664
+ )
3665
+
3666
+ @_rewrite_parameters(
3667
+ body_fields=("from_", "query", "search_after", "size", "sort"),
3668
+ parameter_aliases={"from": "from_"},
3669
+ )
3670
+ async def query_role(
3671
+ self,
3672
+ *,
3673
+ error_trace: t.Optional[bool] = None,
3674
+ filter_path: t.Optional[t.Union[str, t.Sequence[str]]] = None,
3675
+ from_: t.Optional[int] = None,
3676
+ human: t.Optional[bool] = None,
3677
+ pretty: t.Optional[bool] = None,
3678
+ query: t.Optional[t.Mapping[str, t.Any]] = None,
3679
+ search_after: t.Optional[
3680
+ t.Sequence[t.Union[None, bool, float, int, str]]
3681
+ ] = None,
3682
+ size: t.Optional[int] = None,
3683
+ sort: t.Optional[
3684
+ t.Union[
3685
+ t.Sequence[t.Union[str, t.Mapping[str, t.Any]]],
3686
+ t.Union[str, t.Mapping[str, t.Any]],
3687
+ ]
3688
+ ] = None,
3689
+ body: t.Optional[t.Dict[str, t.Any]] = None,
3690
+ ) -> ObjectApiResponse[t.Any]:
3691
+ """
3692
+ .. raw:: html
3693
+
3694
+ <p>Find roles with a query.</p>
3695
+ <p>Get roles in a paginated manner.
3696
+ The role management APIs are generally the preferred way to manage roles, rather than using file-based role management.
3697
+ The query roles API does not retrieve roles that are defined in roles files, nor built-in ones.
3698
+ You can optionally filter the results with a query.
3699
+ Also, the results can be paginated and sorted.</p>
3700
+
3701
+
3702
+ `<https://www.elastic.co/docs/api/doc/elasticsearch/v9/operation/operation-security-query-role>`_
3703
+
3704
+ :param from_: The starting document offset. It must not be negative. By default,
3705
+ you cannot page through more than 10,000 hits using the `from` and `size`
3706
+ parameters. To page through more hits, use the `search_after` parameter.
3707
+ :param query: A query to filter which roles to return. If the query parameter
3708
+ is missing, it is equivalent to a `match_all` query. The query supports a
3709
+ subset of query types, including `match_all`, `bool`, `term`, `terms`, `match`,
3710
+ `ids`, `prefix`, `wildcard`, `exists`, `range`, and `simple_query_string`.
3711
+ You can query the following information associated with roles: `name`, `description`,
3712
+ `metadata`, `applications.application`, `applications.privileges`, and `applications.resources`.
3713
+ :param search_after: The search after definition.
3714
+ :param size: The number of hits to return. It must not be negative. By default,
3715
+ you cannot page through more than 10,000 hits using the `from` and `size`
3716
+ parameters. To page through more hits, use the `search_after` parameter.
3717
+ :param sort: The sort definition. You can sort on `username`, `roles`, or `enabled`.
3718
+ In addition, sort can also be applied to the `_doc` field to sort by index
3719
+ order.
3720
+ """
3721
+ __path_parts: t.Dict[str, str] = {}
3722
+ __path = "/_security/_query/role"
3723
+ __query: t.Dict[str, t.Any] = {}
3724
+ __body: t.Dict[str, t.Any] = body if body is not None else {}
3725
+ if error_trace is not None:
3726
+ __query["error_trace"] = error_trace
3727
+ if filter_path is not None:
3728
+ __query["filter_path"] = filter_path
3729
+ if human is not None:
3730
+ __query["human"] = human
3731
+ if pretty is not None:
3732
+ __query["pretty"] = pretty
3733
+ if not __body:
3734
+ if from_ is not None:
3735
+ __body["from"] = from_
3736
+ if query is not None:
3737
+ __body["query"] = query
3738
+ if search_after is not None:
3739
+ __body["search_after"] = search_after
3740
+ if size is not None:
3741
+ __body["size"] = size
3742
+ if sort is not None:
3743
+ __body["sort"] = sort
3744
+ if not __body:
3745
+ __body = None # type: ignore[assignment]
3746
+ __headers = {"accept": "application/json"}
3747
+ if __body is not None:
3748
+ __headers["content-type"] = "application/json"
3749
+ return await self.perform_request( # type: ignore[return-value]
3750
+ "POST",
3751
+ __path,
3752
+ params=__query,
3753
+ headers=__headers,
3754
+ body=__body,
3755
+ endpoint_id="security.query_role",
3756
+ path_parts=__path_parts,
3757
+ )
3758
+
3759
+ @_rewrite_parameters(
3760
+ body_fields=("from_", "query", "search_after", "size", "sort"),
3761
+ parameter_aliases={"from": "from_"},
3762
+ )
3763
+ async def query_user(
3764
+ self,
3765
+ *,
3766
+ error_trace: t.Optional[bool] = None,
3767
+ filter_path: t.Optional[t.Union[str, t.Sequence[str]]] = None,
3768
+ from_: t.Optional[int] = None,
3769
+ human: t.Optional[bool] = None,
3770
+ pretty: t.Optional[bool] = None,
3771
+ query: t.Optional[t.Mapping[str, t.Any]] = None,
3772
+ search_after: t.Optional[
3773
+ t.Sequence[t.Union[None, bool, float, int, str]]
3774
+ ] = None,
3775
+ size: t.Optional[int] = None,
3776
+ sort: t.Optional[
3777
+ t.Union[
3778
+ t.Sequence[t.Union[str, t.Mapping[str, t.Any]]],
3779
+ t.Union[str, t.Mapping[str, t.Any]],
3780
+ ]
3781
+ ] = None,
3782
+ with_profile_uid: t.Optional[bool] = None,
3783
+ body: t.Optional[t.Dict[str, t.Any]] = None,
3784
+ ) -> ObjectApiResponse[t.Any]:
3785
+ """
3786
+ .. raw:: html
3787
+
3788
+ <p>Find users with a query.</p>
3789
+ <p>Get information for users in a paginated manner.
3790
+ You can optionally filter the results with a query.</p>
3791
+ <p>NOTE: As opposed to the get user API, built-in users are excluded from the result.
3792
+ This API is only for native users.</p>
3793
+
3794
+
3795
+ `<https://www.elastic.co/docs/api/doc/elasticsearch/v9/operation/operation-security-query-user>`_
3796
+
3797
+ :param from_: The starting document offset. It must not be negative. By default,
3798
+ you cannot page through more than 10,000 hits using the `from` and `size`
3799
+ parameters. To page through more hits, use the `search_after` parameter.
3800
+ :param query: A query to filter which users to return. If the query parameter
3801
+ is missing, it is equivalent to a `match_all` query. The query supports a
3802
+ subset of query types, including `match_all`, `bool`, `term`, `terms`, `match`,
3803
+ `ids`, `prefix`, `wildcard`, `exists`, `range`, and `simple_query_string`.
3804
+ You can query the following information associated with user: `username`,
3805
+ `roles`, `enabled`, `full_name`, and `email`.
3806
+ :param search_after: The search after definition
3807
+ :param size: The number of hits to return. It must not be negative. By default,
3808
+ you cannot page through more than 10,000 hits using the `from` and `size`
3809
+ parameters. To page through more hits, use the `search_after` parameter.
3810
+ :param sort: The sort definition. Fields eligible for sorting are: `username`,
3811
+ `roles`, `enabled`. In addition, sort can also be applied to the `_doc` field
3812
+ to sort by index order.
3813
+ :param with_profile_uid: Determines whether to retrieve the user profile UID,
3814
+ if it exists, for the users.
3815
+ """
3816
+ __path_parts: t.Dict[str, str] = {}
3817
+ __path = "/_security/_query/user"
3818
+ __query: t.Dict[str, t.Any] = {}
3819
+ __body: t.Dict[str, t.Any] = body if body is not None else {}
3820
+ if error_trace is not None:
3821
+ __query["error_trace"] = error_trace
3822
+ if filter_path is not None:
3823
+ __query["filter_path"] = filter_path
3824
+ if human is not None:
3825
+ __query["human"] = human
3826
+ if pretty is not None:
3827
+ __query["pretty"] = pretty
3828
+ if with_profile_uid is not None:
3829
+ __query["with_profile_uid"] = with_profile_uid
3830
+ if not __body:
3831
+ if from_ is not None:
3832
+ __body["from"] = from_
3833
+ if query is not None:
3834
+ __body["query"] = query
3835
+ if search_after is not None:
3836
+ __body["search_after"] = search_after
3837
+ if size is not None:
3838
+ __body["size"] = size
3839
+ if sort is not None:
3840
+ __body["sort"] = sort
3841
+ if not __body:
3842
+ __body = None # type: ignore[assignment]
3843
+ __headers = {"accept": "application/json"}
3844
+ if __body is not None:
3845
+ __headers["content-type"] = "application/json"
3846
+ return await self.perform_request( # type: ignore[return-value]
3847
+ "POST",
3848
+ __path,
3849
+ params=__query,
3850
+ headers=__headers,
3851
+ body=__body,
3852
+ endpoint_id="security.query_user",
3853
+ path_parts=__path_parts,
3854
+ )
3855
+
3856
+ @_rewrite_parameters(
3857
+ body_fields=("content", "ids", "realm"),
3858
+ )
3859
+ async def saml_authenticate(
3860
+ self,
3861
+ *,
3862
+ content: t.Optional[str] = None,
3863
+ ids: t.Optional[t.Union[str, t.Sequence[str]]] = None,
3864
+ error_trace: t.Optional[bool] = None,
3865
+ filter_path: t.Optional[t.Union[str, t.Sequence[str]]] = None,
3866
+ human: t.Optional[bool] = None,
3867
+ pretty: t.Optional[bool] = None,
3868
+ realm: t.Optional[str] = None,
3869
+ body: t.Optional[t.Dict[str, t.Any]] = None,
3870
+ ) -> ObjectApiResponse[t.Any]:
3871
+ """
3872
+ .. raw:: html
3873
+
3874
+ <p>Authenticate SAML.</p>
3875
+ <p>Submit a SAML response message to Elasticsearch for consumption.</p>
3876
+ <p>NOTE: This API is intended for use by custom web applications other than Kibana.
3877
+ If you are using Kibana, refer to the documentation for configuring SAML single-sign-on on the Elastic Stack.</p>
3878
+ <p>The SAML message that is submitted can be:</p>
3879
+ <ul>
3880
+ <li>A response to a SAML authentication request that was previously created using the SAML prepare authentication API.</li>
3881
+ <li>An unsolicited SAML message in the case of an IdP-initiated single sign-on (SSO) flow.</li>
3882
+ </ul>
3883
+ <p>In either case, the SAML message needs to be a base64 encoded XML document with a root element of <code>&lt;Response&gt;</code>.</p>
3884
+ <p>After successful validation, Elasticsearch responds with an Elasticsearch internal access token and refresh token that can be subsequently used for authentication.
3885
+ This API endpoint essentially exchanges SAML responses that indicate successful authentication in the IdP for Elasticsearch access and refresh tokens, which can be used for authentication against Elasticsearch.</p>
3886
+
3887
+
3888
+ `<https://www.elastic.co/docs/api/doc/elasticsearch/v9/operation/operation-security-saml-authenticate>`_
3889
+
3890
+ :param content: The SAML response as it was sent by the user's browser, usually
3891
+ a Base64 encoded XML document.
3892
+ :param ids: A JSON array with all the valid SAML Request Ids that the caller
3893
+ of the API has for the current user.
3894
+ :param realm: The name of the realm that should authenticate the SAML response.
3895
+ Useful in cases where many SAML realms are defined.
3896
+ """
3897
+ if content is None and body is None:
3898
+ raise ValueError("Empty value passed for parameter 'content'")
3899
+ if ids is None and body is None:
3900
+ raise ValueError("Empty value passed for parameter 'ids'")
3901
+ __path_parts: t.Dict[str, str] = {}
3902
+ __path = "/_security/saml/authenticate"
3903
+ __query: t.Dict[str, t.Any] = {}
3904
+ __body: t.Dict[str, t.Any] = body if body is not None else {}
3905
+ if error_trace is not None:
3906
+ __query["error_trace"] = error_trace
3907
+ if filter_path is not None:
3908
+ __query["filter_path"] = filter_path
3909
+ if human is not None:
3910
+ __query["human"] = human
3911
+ if pretty is not None:
3912
+ __query["pretty"] = pretty
3913
+ if not __body:
3914
+ if content is not None:
3915
+ __body["content"] = content
3916
+ if ids is not None:
3917
+ __body["ids"] = ids
3918
+ if realm is not None:
3919
+ __body["realm"] = realm
3920
+ __headers = {"accept": "application/json", "content-type": "application/json"}
3921
+ return await self.perform_request( # type: ignore[return-value]
3922
+ "POST",
3923
+ __path,
3924
+ params=__query,
3925
+ headers=__headers,
3926
+ body=__body,
3927
+ endpoint_id="security.saml_authenticate",
3928
+ path_parts=__path_parts,
3929
+ )
3930
+
3931
+ @_rewrite_parameters(
3932
+ body_fields=("ids", "realm", "content", "query_string"),
3933
+ )
3934
+ async def saml_complete_logout(
3935
+ self,
3936
+ *,
3937
+ ids: t.Optional[t.Union[str, t.Sequence[str]]] = None,
3938
+ realm: t.Optional[str] = None,
3939
+ content: t.Optional[str] = None,
3940
+ error_trace: t.Optional[bool] = None,
3941
+ filter_path: t.Optional[t.Union[str, t.Sequence[str]]] = None,
3942
+ human: t.Optional[bool] = None,
3943
+ pretty: t.Optional[bool] = None,
3944
+ query_string: t.Optional[str] = None,
3945
+ body: t.Optional[t.Dict[str, t.Any]] = None,
3946
+ ) -> ObjectApiResponse[t.Any]:
3947
+ """
3948
+ .. raw:: html
3949
+
3950
+ <p>Logout of SAML completely.</p>
3951
+ <p>Verifies the logout response sent from the SAML IdP.</p>
3952
+ <p>NOTE: This API is intended for use by custom web applications other than Kibana.
3953
+ If you are using Kibana, refer to the documentation for configuring SAML single-sign-on on the Elastic Stack.</p>
3954
+ <p>The SAML IdP may send a logout response back to the SP after handling the SP-initiated SAML Single Logout.
3955
+ This API verifies the response by ensuring the content is relevant and validating its signature.
3956
+ An empty response is returned if the verification process is successful.
3957
+ The response can be sent by the IdP with either the HTTP-Redirect or the HTTP-Post binding.
3958
+ The caller of this API must prepare the request accordingly so that this API can handle either of them.</p>
3959
+
3960
+
3961
+ `<https://www.elastic.co/docs/api/doc/elasticsearch/v9/operation/operation-security-saml-complete-logout>`_
3962
+
3963
+ :param ids: A JSON array with all the valid SAML Request Ids that the caller
3964
+ of the API has for the current user.
3965
+ :param realm: The name of the SAML realm in Elasticsearch for which the configuration
3966
+ is used to verify the logout response.
3967
+ :param content: If the SAML IdP sends the logout response with the HTTP-Post
3968
+ binding, this field must be set to the value of the SAMLResponse form parameter
3969
+ from the logout response.
3970
+ :param query_string: If the SAML IdP sends the logout response with the HTTP-Redirect
3971
+ binding, this field must be set to the query string of the redirect URI.
3972
+ """
3973
+ if ids is None and body is None:
3974
+ raise ValueError("Empty value passed for parameter 'ids'")
3975
+ if realm is None and body is None:
3976
+ raise ValueError("Empty value passed for parameter 'realm'")
3977
+ __path_parts: t.Dict[str, str] = {}
3978
+ __path = "/_security/saml/complete_logout"
3979
+ __query: t.Dict[str, t.Any] = {}
3980
+ __body: t.Dict[str, t.Any] = body if body is not None else {}
3981
+ if error_trace is not None:
3982
+ __query["error_trace"] = error_trace
3983
+ if filter_path is not None:
3984
+ __query["filter_path"] = filter_path
3985
+ if human is not None:
3986
+ __query["human"] = human
3987
+ if pretty is not None:
3988
+ __query["pretty"] = pretty
3989
+ if not __body:
3990
+ if ids is not None:
3991
+ __body["ids"] = ids
3992
+ if realm is not None:
3993
+ __body["realm"] = realm
3994
+ if content is not None:
3995
+ __body["content"] = content
3996
+ if query_string is not None:
3997
+ __body["query_string"] = query_string
3998
+ __headers = {"accept": "application/json", "content-type": "application/json"}
3999
+ return await self.perform_request( # type: ignore[return-value]
4000
+ "POST",
4001
+ __path,
4002
+ params=__query,
4003
+ headers=__headers,
4004
+ body=__body,
4005
+ endpoint_id="security.saml_complete_logout",
4006
+ path_parts=__path_parts,
4007
+ )
4008
+
4009
+ @_rewrite_parameters(
4010
+ body_fields=("query_string", "acs", "realm"),
4011
+ )
4012
+ async def saml_invalidate(
4013
+ self,
4014
+ *,
4015
+ query_string: t.Optional[str] = None,
4016
+ acs: t.Optional[str] = None,
4017
+ error_trace: t.Optional[bool] = None,
4018
+ filter_path: t.Optional[t.Union[str, t.Sequence[str]]] = None,
4019
+ human: t.Optional[bool] = None,
4020
+ pretty: t.Optional[bool] = None,
4021
+ realm: t.Optional[str] = None,
4022
+ body: t.Optional[t.Dict[str, t.Any]] = None,
4023
+ ) -> ObjectApiResponse[t.Any]:
4024
+ """
4025
+ .. raw:: html
4026
+
4027
+ <p>Invalidate SAML.</p>
4028
+ <p>Submit a SAML LogoutRequest message to Elasticsearch for consumption.</p>
4029
+ <p>NOTE: This API is intended for use by custom web applications other than Kibana.
4030
+ If you are using Kibana, refer to the documentation for configuring SAML single-sign-on on the Elastic Stack.</p>
4031
+ <p>The logout request comes from the SAML IdP during an IdP initiated Single Logout.
4032
+ The custom web application can use this API to have Elasticsearch process the <code>LogoutRequest</code>.
4033
+ After successful validation of the request, Elasticsearch invalidates the access token and refresh token that corresponds to that specific SAML principal and provides a URL that contains a SAML LogoutResponse message.
4034
+ Thus the user can be redirected back to their IdP.</p>
4035
+
4036
+
4037
+ `<https://www.elastic.co/docs/api/doc/elasticsearch/v9/operation/operation-security-saml-invalidate>`_
4038
+
4039
+ :param query_string: The query part of the URL that the user was redirected to
4040
+ by the SAML IdP to initiate the Single Logout. This query should include
4041
+ a single parameter named `SAMLRequest` that contains a SAML logout request
4042
+ that is deflated and Base64 encoded. If the SAML IdP has signed the logout
4043
+ request, the URL should include two extra parameters named `SigAlg` and `Signature`
4044
+ that contain the algorithm used for the signature and the signature value
4045
+ itself. In order for Elasticsearch to be able to verify the IdP's signature,
4046
+ the value of the `query_string` field must be an exact match to the string
4047
+ provided by the browser. The client application must not attempt to parse
4048
+ or process the string in any way.
4049
+ :param acs: The Assertion Consumer Service URL that matches the one of the SAML
4050
+ realm in Elasticsearch that should be used. You must specify either this
4051
+ parameter or the `realm` parameter.
4052
+ :param realm: The name of the SAML realm in Elasticsearch the configuration.
4053
+ You must specify either this parameter or the `acs` parameter.
4054
+ """
4055
+ if query_string is None and body is None:
4056
+ raise ValueError("Empty value passed for parameter 'query_string'")
4057
+ __path_parts: t.Dict[str, str] = {}
4058
+ __path = "/_security/saml/invalidate"
4059
+ __query: t.Dict[str, t.Any] = {}
4060
+ __body: t.Dict[str, t.Any] = body if body is not None else {}
4061
+ if error_trace is not None:
4062
+ __query["error_trace"] = error_trace
4063
+ if filter_path is not None:
4064
+ __query["filter_path"] = filter_path
4065
+ if human is not None:
4066
+ __query["human"] = human
4067
+ if pretty is not None:
4068
+ __query["pretty"] = pretty
4069
+ if not __body:
4070
+ if query_string is not None:
4071
+ __body["query_string"] = query_string
4072
+ if acs is not None:
4073
+ __body["acs"] = acs
4074
+ if realm is not None:
4075
+ __body["realm"] = realm
4076
+ __headers = {"accept": "application/json", "content-type": "application/json"}
4077
+ return await self.perform_request( # type: ignore[return-value]
4078
+ "POST",
4079
+ __path,
4080
+ params=__query,
4081
+ headers=__headers,
4082
+ body=__body,
4083
+ endpoint_id="security.saml_invalidate",
4084
+ path_parts=__path_parts,
4085
+ )
4086
+
4087
+ @_rewrite_parameters(
4088
+ body_fields=("token", "refresh_token"),
4089
+ )
4090
+ async def saml_logout(
4091
+ self,
4092
+ *,
4093
+ token: t.Optional[str] = None,
4094
+ error_trace: t.Optional[bool] = None,
4095
+ filter_path: t.Optional[t.Union[str, t.Sequence[str]]] = None,
4096
+ human: t.Optional[bool] = None,
4097
+ pretty: t.Optional[bool] = None,
4098
+ refresh_token: t.Optional[str] = None,
4099
+ body: t.Optional[t.Dict[str, t.Any]] = None,
4100
+ ) -> ObjectApiResponse[t.Any]:
4101
+ """
4102
+ .. raw:: html
4103
+
4104
+ <p>Logout of SAML.</p>
4105
+ <p>Submits a request to invalidate an access token and refresh token.</p>
4106
+ <p>NOTE: This API is intended for use by custom web applications other than Kibana.
4107
+ If you are using Kibana, refer to the documentation for configuring SAML single-sign-on on the Elastic Stack.</p>
4108
+ <p>This API invalidates the tokens that were generated for a user by the SAML authenticate API.
4109
+ If the SAML realm in Elasticsearch is configured accordingly and the SAML IdP supports this, the Elasticsearch response contains a URL to redirect the user to the IdP that contains a SAML logout request (starting an SP-initiated SAML Single Logout).</p>
4110
+
4111
+
4112
+ `<https://www.elastic.co/docs/api/doc/elasticsearch/v9/operation/operation-security-saml-logout>`_
4113
+
4114
+ :param token: The access token that was returned as a response to calling the
4115
+ SAML authenticate API. Alternatively, the most recent token that was received
4116
+ after refreshing the original one by using a `refresh_token`.
4117
+ :param refresh_token: The refresh token that was returned as a response to calling
4118
+ the SAML authenticate API. Alternatively, the most recent refresh token that
4119
+ was received after refreshing the original access token.
4120
+ """
4121
+ if token is None and body is None:
4122
+ raise ValueError("Empty value passed for parameter 'token'")
4123
+ __path_parts: t.Dict[str, str] = {}
4124
+ __path = "/_security/saml/logout"
4125
+ __query: t.Dict[str, t.Any] = {}
4126
+ __body: t.Dict[str, t.Any] = body if body is not None else {}
4127
+ if error_trace is not None:
4128
+ __query["error_trace"] = error_trace
4129
+ if filter_path is not None:
4130
+ __query["filter_path"] = filter_path
4131
+ if human is not None:
4132
+ __query["human"] = human
4133
+ if pretty is not None:
4134
+ __query["pretty"] = pretty
4135
+ if not __body:
4136
+ if token is not None:
4137
+ __body["token"] = token
4138
+ if refresh_token is not None:
4139
+ __body["refresh_token"] = refresh_token
4140
+ __headers = {"accept": "application/json", "content-type": "application/json"}
4141
+ return await self.perform_request( # type: ignore[return-value]
4142
+ "POST",
4143
+ __path,
4144
+ params=__query,
4145
+ headers=__headers,
4146
+ body=__body,
4147
+ endpoint_id="security.saml_logout",
4148
+ path_parts=__path_parts,
4149
+ )
4150
+
4151
+ @_rewrite_parameters(
4152
+ body_fields=("acs", "realm", "relay_state"),
4153
+ )
4154
+ async def saml_prepare_authentication(
4155
+ self,
4156
+ *,
4157
+ acs: t.Optional[str] = None,
4158
+ error_trace: t.Optional[bool] = None,
4159
+ filter_path: t.Optional[t.Union[str, t.Sequence[str]]] = None,
4160
+ human: t.Optional[bool] = None,
4161
+ pretty: t.Optional[bool] = None,
4162
+ realm: t.Optional[str] = None,
4163
+ relay_state: t.Optional[str] = None,
4164
+ body: t.Optional[t.Dict[str, t.Any]] = None,
4165
+ ) -> ObjectApiResponse[t.Any]:
4166
+ """
4167
+ .. raw:: html
4168
+
4169
+ <p>Prepare SAML authentication.</p>
4170
+ <p>Create a SAML authentication request (<code>&lt;AuthnRequest&gt;</code>) as a URL string based on the configuration of the respective SAML realm in Elasticsearch.</p>
4171
+ <p>NOTE: This API is intended for use by custom web applications other than Kibana.
4172
+ If you are using Kibana, refer to the documentation for configuring SAML single-sign-on on the Elastic Stack.</p>
4173
+ <p>This API returns a URL pointing to the SAML Identity Provider.
4174
+ You can use the URL to redirect the browser of the user in order to continue the authentication process.
4175
+ The URL includes a single parameter named <code>SAMLRequest</code>, which contains a SAML Authentication request that is deflated and Base64 encoded.
4176
+ If the configuration dictates that SAML authentication requests should be signed, the URL has two extra parameters named <code>SigAlg</code> and <code>Signature</code>.
4177
+ These parameters contain the algorithm used for the signature and the signature value itself.
4178
+ It also returns a random string that uniquely identifies this SAML Authentication request.
4179
+ The caller of this API needs to store this identifier as it needs to be used in a following step of the authentication process.</p>
4180
+
4181
+
4182
+ `<https://www.elastic.co/docs/api/doc/elasticsearch/v9/operation/operation-security-saml-prepare-authentication>`_
4183
+
4184
+ :param acs: The Assertion Consumer Service URL that matches the one of the SAML
4185
+ realms in Elasticsearch. The realm is used to generate the authentication
4186
+ request. You must specify either this parameter or the `realm` parameter.
4187
+ :param realm: The name of the SAML realm in Elasticsearch for which the configuration
4188
+ is used to generate the authentication request. You must specify either this
4189
+ parameter or the `acs` parameter.
4190
+ :param relay_state: A string that will be included in the redirect URL that this
4191
+ API returns as the `RelayState` query parameter. If the Authentication Request
4192
+ is signed, this value is used as part of the signature computation.
4193
+ """
4194
+ __path_parts: t.Dict[str, str] = {}
4195
+ __path = "/_security/saml/prepare"
4196
+ __query: t.Dict[str, t.Any] = {}
4197
+ __body: t.Dict[str, t.Any] = body if body is not None else {}
4198
+ if error_trace is not None:
4199
+ __query["error_trace"] = error_trace
4200
+ if filter_path is not None:
4201
+ __query["filter_path"] = filter_path
4202
+ if human is not None:
4203
+ __query["human"] = human
4204
+ if pretty is not None:
4205
+ __query["pretty"] = pretty
4206
+ if not __body:
4207
+ if acs is not None:
4208
+ __body["acs"] = acs
4209
+ if realm is not None:
4210
+ __body["realm"] = realm
4211
+ if relay_state is not None:
4212
+ __body["relay_state"] = relay_state
4213
+ __headers = {"accept": "application/json", "content-type": "application/json"}
4214
+ return await self.perform_request( # type: ignore[return-value]
4215
+ "POST",
4216
+ __path,
4217
+ params=__query,
4218
+ headers=__headers,
4219
+ body=__body,
4220
+ endpoint_id="security.saml_prepare_authentication",
4221
+ path_parts=__path_parts,
4222
+ )
4223
+
4224
+ @_rewrite_parameters()
4225
+ async def saml_service_provider_metadata(
4226
+ self,
4227
+ *,
4228
+ realm_name: str,
4229
+ error_trace: t.Optional[bool] = None,
4230
+ filter_path: t.Optional[t.Union[str, t.Sequence[str]]] = None,
4231
+ human: t.Optional[bool] = None,
4232
+ pretty: t.Optional[bool] = None,
4233
+ ) -> ObjectApiResponse[t.Any]:
4234
+ """
4235
+ .. raw:: html
4236
+
4237
+ <p>Create SAML service provider metadata.</p>
4238
+ <p>Generate SAML metadata for a SAML 2.0 Service Provider.</p>
4239
+ <p>The SAML 2.0 specification provides a mechanism for Service Providers to describe their capabilities and configuration using a metadata file.
4240
+ This API generates Service Provider metadata based on the configuration of a SAML realm in Elasticsearch.</p>
4241
+
4242
+
4243
+ `<https://www.elastic.co/docs/api/doc/elasticsearch/v9/operation/operation-security-saml-service-provider-metadata>`_
4244
+
4245
+ :param realm_name: The name of the SAML realm in Elasticsearch.
4246
+ """
4247
+ if realm_name in SKIP_IN_PATH:
4248
+ raise ValueError("Empty value passed for parameter 'realm_name'")
4249
+ __path_parts: t.Dict[str, str] = {"realm_name": _quote(realm_name)}
4250
+ __path = f'/_security/saml/metadata/{__path_parts["realm_name"]}'
4251
+ __query: t.Dict[str, t.Any] = {}
4252
+ if error_trace is not None:
4253
+ __query["error_trace"] = error_trace
4254
+ if filter_path is not None:
4255
+ __query["filter_path"] = filter_path
4256
+ if human is not None:
4257
+ __query["human"] = human
4258
+ if pretty is not None:
4259
+ __query["pretty"] = pretty
4260
+ __headers = {"accept": "application/json"}
4261
+ return await self.perform_request( # type: ignore[return-value]
4262
+ "GET",
4263
+ __path,
4264
+ params=__query,
4265
+ headers=__headers,
4266
+ endpoint_id="security.saml_service_provider_metadata",
4267
+ path_parts=__path_parts,
4268
+ )
4269
+
4270
+ @_rewrite_parameters(
4271
+ body_fields=("data", "hint", "name", "size"),
4272
+ )
4273
+ async def suggest_user_profiles(
4274
+ self,
4275
+ *,
4276
+ data: t.Optional[t.Union[str, t.Sequence[str]]] = None,
4277
+ error_trace: t.Optional[bool] = None,
4278
+ filter_path: t.Optional[t.Union[str, t.Sequence[str]]] = None,
4279
+ hint: t.Optional[t.Mapping[str, t.Any]] = None,
4280
+ human: t.Optional[bool] = None,
4281
+ name: t.Optional[str] = None,
4282
+ pretty: t.Optional[bool] = None,
4283
+ size: t.Optional[int] = None,
4284
+ body: t.Optional[t.Dict[str, t.Any]] = None,
4285
+ ) -> ObjectApiResponse[t.Any]:
4286
+ """
4287
+ .. raw:: html
4288
+
4289
+ <p>Suggest a user profile.</p>
4290
+ <p>Get suggestions for user profiles that match specified search criteria.</p>
4291
+ <p>NOTE: The user profile feature is designed only for use by Kibana and Elastic's Observability, Enterprise Search, and Elastic Security solutions.
4292
+ Individual users and external applications should not call this API directly.
4293
+ Elastic reserves the right to change or remove this feature in future releases without prior notice.</p>
4294
+
4295
+
4296
+ `<https://www.elastic.co/docs/api/doc/elasticsearch/v9/operation/operation-security-suggest-user-profiles>`_
4297
+
4298
+ :param data: A comma-separated list of filters for the `data` field of the profile
4299
+ document. To return all content use `data=*`. To return a subset of content,
4300
+ use `data=<key>` to retrieve content nested under the specified `<key>`.
4301
+ By default, the API returns no `data` content. It is an error to specify
4302
+ `data` as both the query parameter and the request body field.
4303
+ :param hint: Extra search criteria to improve relevance of the suggestion result.
4304
+ Profiles matching the spcified hint are ranked higher in the response. Profiles
4305
+ not matching the hint aren't excluded from the response as long as the profile
4306
+ matches the `name` field query.
4307
+ :param name: A query string used to match name-related fields in user profile
4308
+ documents. Name-related fields are the user's `username`, `full_name`, and
4309
+ `email`.
4310
+ :param size: The number of profiles to return.
4311
+ """
4312
+ __path_parts: t.Dict[str, str] = {}
4313
+ __path = "/_security/profile/_suggest"
4314
+ __query: t.Dict[str, t.Any] = {}
4315
+ __body: t.Dict[str, t.Any] = body if body is not None else {}
4316
+ if error_trace is not None:
4317
+ __query["error_trace"] = error_trace
4318
+ if filter_path is not None:
4319
+ __query["filter_path"] = filter_path
4320
+ if human is not None:
4321
+ __query["human"] = human
4322
+ if pretty is not None:
4323
+ __query["pretty"] = pretty
4324
+ if not __body:
4325
+ if data is not None:
4326
+ __body["data"] = data
4327
+ if hint is not None:
4328
+ __body["hint"] = hint
4329
+ if name is not None:
4330
+ __body["name"] = name
4331
+ if size is not None:
4332
+ __body["size"] = size
4333
+ if not __body:
4334
+ __body = None # type: ignore[assignment]
4335
+ __headers = {"accept": "application/json"}
4336
+ if __body is not None:
4337
+ __headers["content-type"] = "application/json"
4338
+ return await self.perform_request( # type: ignore[return-value]
4339
+ "POST",
4340
+ __path,
4341
+ params=__query,
4342
+ headers=__headers,
4343
+ body=__body,
4344
+ endpoint_id="security.suggest_user_profiles",
4345
+ path_parts=__path_parts,
4346
+ )
4347
+
4348
+ @_rewrite_parameters(
4349
+ body_fields=("expiration", "metadata", "role_descriptors"),
4350
+ )
4351
+ async def update_api_key(
4352
+ self,
4353
+ *,
4354
+ id: str,
4355
+ error_trace: t.Optional[bool] = None,
4356
+ expiration: t.Optional[t.Union[str, t.Literal[-1], t.Literal[0]]] = None,
4357
+ filter_path: t.Optional[t.Union[str, t.Sequence[str]]] = None,
4358
+ human: t.Optional[bool] = None,
4359
+ metadata: t.Optional[t.Mapping[str, t.Any]] = None,
4360
+ pretty: t.Optional[bool] = None,
4361
+ role_descriptors: t.Optional[t.Mapping[str, t.Mapping[str, t.Any]]] = None,
4362
+ body: t.Optional[t.Dict[str, t.Any]] = None,
4363
+ ) -> ObjectApiResponse[t.Any]:
4364
+ """
4365
+ .. raw:: html
4366
+
4367
+ <p>Update an API key.</p>
4368
+ <p>Update attributes of an existing API key.
4369
+ This API supports updates to an API key's access scope, expiration, and metadata.</p>
4370
+ <p>To use this API, you must have at least the <code>manage_own_api_key</code> cluster privilege.
4371
+ Users can only update API keys that they created or that were granted to them.
4372
+ To update another user’s API key, use the <code>run_as</code> feature to submit a request on behalf of another user.</p>
4373
+ <p>IMPORTANT: It's not possible to use an API key as the authentication credential for this API. The owner user’s credentials are required.</p>
4374
+ <p>Use this API to update API keys created by the create API key or grant API Key APIs.
4375
+ If you need to apply the same update to many API keys, you can use the bulk update API keys API to reduce overhead.
4376
+ It's not possible to update expired API keys or API keys that have been invalidated by the invalidate API key API.</p>
4377
+ <p>The access scope of an API key is derived from the <code>role_descriptors</code> you specify in the request and a snapshot of the owner user's permissions at the time of the request.
4378
+ The snapshot of the owner's permissions is updated automatically on every call.</p>
4379
+ <p>IMPORTANT: If you don't specify <code>role_descriptors</code> in the request, a call to this API might still change the API key's access scope.
4380
+ This change can occur if the owner user's permissions have changed since the API key was created or last modified.</p>
4381
+
4382
+
4383
+ `<https://www.elastic.co/docs/api/doc/elasticsearch/v9/operation/operation-security-update-api-key>`_
4384
+
4385
+ :param id: The ID of the API key to update.
4386
+ :param expiration: The expiration time for the API key. By default, API keys
4387
+ never expire. This property can be omitted to leave the expiration unchanged.
4388
+ :param metadata: Arbitrary metadata that you want to associate with the API key.
4389
+ It supports a nested data structure. Within the metadata object, keys beginning
4390
+ with `_` are reserved for system usage. When specified, this value fully
4391
+ replaces the metadata previously associated with the API key.
4392
+ :param role_descriptors: The role descriptors to assign to this API key. The
4393
+ API key's effective permissions are an intersection of its assigned privileges
4394
+ and the point in time snapshot of permissions of the owner user. You can
4395
+ assign new privileges by specifying them in this parameter. To remove assigned
4396
+ privileges, you can supply an empty `role_descriptors` parameter, that is
4397
+ to say, an empty object `{}`. If an API key has no assigned privileges, it
4398
+ inherits the owner user's full permissions. The snapshot of the owner's permissions
4399
+ is always updated, whether you supply the `role_descriptors` parameter or
4400
+ not. The structure of a role descriptor is the same as the request for the
4401
+ create API keys API.
4402
+ """
4403
+ if id in SKIP_IN_PATH:
4404
+ raise ValueError("Empty value passed for parameter 'id'")
4405
+ __path_parts: t.Dict[str, str] = {"id": _quote(id)}
4406
+ __path = f'/_security/api_key/{__path_parts["id"]}'
4407
+ __query: t.Dict[str, t.Any] = {}
4408
+ __body: t.Dict[str, t.Any] = body if body is not None else {}
4409
+ if error_trace is not None:
4410
+ __query["error_trace"] = error_trace
4411
+ if filter_path is not None:
4412
+ __query["filter_path"] = filter_path
4413
+ if human is not None:
4414
+ __query["human"] = human
4415
+ if pretty is not None:
4416
+ __query["pretty"] = pretty
4417
+ if not __body:
4418
+ if expiration is not None:
4419
+ __body["expiration"] = expiration
4420
+ if metadata is not None:
4421
+ __body["metadata"] = metadata
4422
+ if role_descriptors is not None:
4423
+ __body["role_descriptors"] = role_descriptors
4424
+ if not __body:
4425
+ __body = None # type: ignore[assignment]
4426
+ __headers = {"accept": "application/json"}
4427
+ if __body is not None:
4428
+ __headers["content-type"] = "application/json"
4429
+ return await self.perform_request( # type: ignore[return-value]
4430
+ "PUT",
4431
+ __path,
4432
+ params=__query,
4433
+ headers=__headers,
4434
+ body=__body,
4435
+ endpoint_id="security.update_api_key",
4436
+ path_parts=__path_parts,
4437
+ )
4438
+
4439
+ @_rewrite_parameters(
4440
+ body_fields=("access", "expiration", "metadata"),
4441
+ )
4442
+ async def update_cross_cluster_api_key(
4443
+ self,
4444
+ *,
4445
+ id: str,
4446
+ access: t.Optional[t.Mapping[str, t.Any]] = None,
4447
+ error_trace: t.Optional[bool] = None,
4448
+ expiration: t.Optional[t.Union[str, t.Literal[-1], t.Literal[0]]] = None,
4449
+ filter_path: t.Optional[t.Union[str, t.Sequence[str]]] = None,
4450
+ human: t.Optional[bool] = None,
4451
+ metadata: t.Optional[t.Mapping[str, t.Any]] = None,
4452
+ pretty: t.Optional[bool] = None,
4453
+ body: t.Optional[t.Dict[str, t.Any]] = None,
4454
+ ) -> ObjectApiResponse[t.Any]:
4455
+ """
4456
+ .. raw:: html
4457
+
4458
+ <p>Update a cross-cluster API key.</p>
4459
+ <p>Update the attributes of an existing cross-cluster API key, which is used for API key based remote cluster access.</p>
4460
+ <p>To use this API, you must have at least the <code>manage_security</code> cluster privilege.
4461
+ Users can only update API keys that they created.
4462
+ To update another user's API key, use the <code>run_as</code> feature to submit a request on behalf of another user.</p>
4463
+ <p>IMPORTANT: It's not possible to use an API key as the authentication credential for this API.
4464
+ To update an API key, the owner user's credentials are required.</p>
4465
+ <p>It's not possible to update expired API keys, or API keys that have been invalidated by the invalidate API key API.</p>
4466
+ <p>This API supports updates to an API key's access scope, metadata, and expiration.
4467
+ The owner user's information, such as the <code>username</code> and <code>realm</code>, is also updated automatically on every call.</p>
4468
+ <p>NOTE: This API cannot update REST API keys, which should be updated by either the update API key or bulk update API keys API.</p>
4469
+
4470
+
4471
+ `<https://www.elastic.co/docs/api/doc/elasticsearch/v9/operation/operation-security-update-cross-cluster-api-key>`_
4472
+
4473
+ :param id: The ID of the cross-cluster API key to update.
4474
+ :param access: The access to be granted to this API key. The access is composed
4475
+ of permissions for cross cluster search and cross cluster replication. At
4476
+ least one of them must be specified. When specified, the new access assignment
4477
+ fully replaces the previously assigned access.
4478
+ :param expiration: The expiration time for the API key. By default, API keys
4479
+ never expire. This property can be omitted to leave the value unchanged.
4480
+ :param metadata: Arbitrary metadata that you want to associate with the API key.
4481
+ It supports nested data structure. Within the metadata object, keys beginning
4482
+ with `_` are reserved for system usage. When specified, this information
4483
+ fully replaces metadata previously associated with the API key.
4484
+ """
4485
+ if id in SKIP_IN_PATH:
4486
+ raise ValueError("Empty value passed for parameter 'id'")
4487
+ if access is None and body is None:
4488
+ raise ValueError("Empty value passed for parameter 'access'")
4489
+ __path_parts: t.Dict[str, str] = {"id": _quote(id)}
4490
+ __path = f'/_security/cross_cluster/api_key/{__path_parts["id"]}'
4491
+ __query: t.Dict[str, t.Any] = {}
4492
+ __body: t.Dict[str, t.Any] = body if body is not None else {}
4493
+ if error_trace is not None:
4494
+ __query["error_trace"] = error_trace
4495
+ if filter_path is not None:
4496
+ __query["filter_path"] = filter_path
4497
+ if human is not None:
4498
+ __query["human"] = human
4499
+ if pretty is not None:
4500
+ __query["pretty"] = pretty
4501
+ if not __body:
4502
+ if access is not None:
4503
+ __body["access"] = access
4504
+ if expiration is not None:
4505
+ __body["expiration"] = expiration
4506
+ if metadata is not None:
4507
+ __body["metadata"] = metadata
4508
+ __headers = {"accept": "application/json", "content-type": "application/json"}
4509
+ return await self.perform_request( # type: ignore[return-value]
4510
+ "PUT",
4511
+ __path,
4512
+ params=__query,
4513
+ headers=__headers,
4514
+ body=__body,
4515
+ endpoint_id="security.update_cross_cluster_api_key",
4516
+ path_parts=__path_parts,
4517
+ )
4518
+
4519
+ @_rewrite_parameters(
4520
+ body_fields=("security", "security_profile", "security_tokens"),
4521
+ parameter_aliases={
4522
+ "security-profile": "security_profile",
4523
+ "security-tokens": "security_tokens",
4524
+ },
4525
+ )
4526
+ async def update_settings(
4527
+ self,
4528
+ *,
4529
+ error_trace: t.Optional[bool] = None,
4530
+ filter_path: t.Optional[t.Union[str, t.Sequence[str]]] = None,
4531
+ human: t.Optional[bool] = None,
4532
+ master_timeout: t.Optional[t.Union[str, t.Literal[-1], t.Literal[0]]] = None,
4533
+ pretty: t.Optional[bool] = None,
4534
+ security: t.Optional[t.Mapping[str, t.Any]] = None,
4535
+ security_profile: t.Optional[t.Mapping[str, t.Any]] = None,
4536
+ security_tokens: t.Optional[t.Mapping[str, t.Any]] = None,
4537
+ timeout: t.Optional[t.Union[str, t.Literal[-1], t.Literal[0]]] = None,
4538
+ body: t.Optional[t.Dict[str, t.Any]] = None,
4539
+ ) -> ObjectApiResponse[t.Any]:
4540
+ """
4541
+ .. raw:: html
4542
+
4543
+ <p>Update security index settings.</p>
4544
+ <p>Update the user-configurable settings for the security internal index (<code>.security</code> and associated indices). Only a subset of settings are allowed to be modified. This includes <code>index.auto_expand_replicas</code> and <code>index.number_of_replicas</code>.</p>
4545
+ <p>NOTE: If <code>index.auto_expand_replicas</code> is set, <code>index.number_of_replicas</code> will be ignored during updates.</p>
4546
+ <p>If a specific index is not in use on the system and settings are provided for it, the request will be rejected.
4547
+ This API does not yet support configuring the settings for indices before they are in use.</p>
4548
+
4549
+
4550
+ `<https://www.elastic.co/docs/api/doc/elasticsearch/v9/operation/operation-security-update-settings>`_
4551
+
4552
+ :param master_timeout: The period to wait for a connection to the master node.
4553
+ If no response is received before the timeout expires, the request fails
4554
+ and returns an error.
4555
+ :param security: Settings for the index used for most security configuration,
4556
+ including native realm users and roles configured with the API.
4557
+ :param security_profile: Settings for the index used to store profile information.
4558
+ :param security_tokens: Settings for the index used to store tokens.
4559
+ :param timeout: The period to wait for a response. If no response is received
4560
+ before the timeout expires, the request fails and returns an error.
4561
+ """
4562
+ __path_parts: t.Dict[str, str] = {}
4563
+ __path = "/_security/settings"
4564
+ __query: t.Dict[str, t.Any] = {}
4565
+ __body: t.Dict[str, t.Any] = body if body is not None else {}
4566
+ if error_trace is not None:
4567
+ __query["error_trace"] = error_trace
4568
+ if filter_path is not None:
4569
+ __query["filter_path"] = filter_path
4570
+ if human is not None:
4571
+ __query["human"] = human
4572
+ if master_timeout is not None:
4573
+ __query["master_timeout"] = master_timeout
4574
+ if pretty is not None:
4575
+ __query["pretty"] = pretty
4576
+ if timeout is not None:
4577
+ __query["timeout"] = timeout
4578
+ if not __body:
4579
+ if security is not None:
4580
+ __body["security"] = security
4581
+ if security_profile is not None:
4582
+ __body["security-profile"] = security_profile
4583
+ if security_tokens is not None:
4584
+ __body["security-tokens"] = security_tokens
4585
+ __headers = {"accept": "application/json", "content-type": "application/json"}
4586
+ return await self.perform_request( # type: ignore[return-value]
4587
+ "PUT",
4588
+ __path,
4589
+ params=__query,
4590
+ headers=__headers,
4591
+ body=__body,
4592
+ endpoint_id="security.update_settings",
4593
+ path_parts=__path_parts,
4594
+ )
4595
+
4596
+ @_rewrite_parameters(
4597
+ body_fields=("data", "labels"),
4598
+ )
4599
+ async def update_user_profile_data(
4600
+ self,
4601
+ *,
4602
+ uid: str,
4603
+ data: t.Optional[t.Mapping[str, t.Any]] = None,
4604
+ error_trace: t.Optional[bool] = None,
4605
+ filter_path: t.Optional[t.Union[str, t.Sequence[str]]] = None,
4606
+ human: t.Optional[bool] = None,
4607
+ if_primary_term: t.Optional[int] = None,
4608
+ if_seq_no: t.Optional[int] = None,
4609
+ labels: t.Optional[t.Mapping[str, t.Any]] = None,
4610
+ pretty: t.Optional[bool] = None,
4611
+ refresh: t.Optional[
4612
+ t.Union[bool, str, t.Literal["false", "true", "wait_for"]]
4613
+ ] = None,
4614
+ body: t.Optional[t.Dict[str, t.Any]] = None,
4615
+ ) -> ObjectApiResponse[t.Any]:
4616
+ """
4617
+ .. raw:: html
4618
+
4619
+ <p>Update user profile data.</p>
4620
+ <p>Update specific data for the user profile that is associated with a unique ID.</p>
4621
+ <p>NOTE: The user profile feature is designed only for use by Kibana and Elastic's Observability, Enterprise Search, and Elastic Security solutions.
4622
+ Individual users and external applications should not call this API directly.
4623
+ Elastic reserves the right to change or remove this feature in future releases without prior notice.</p>
4624
+ <p>To use this API, you must have one of the following privileges:</p>
4625
+ <ul>
4626
+ <li>The <code>manage_user_profile</code> cluster privilege.</li>
4627
+ <li>The <code>update_profile_data</code> global privilege for the namespaces that are referenced in the request.</li>
4628
+ </ul>
4629
+ <p>This API updates the <code>labels</code> and <code>data</code> fields of an existing user profile document with JSON objects.
4630
+ New keys and their values are added to the profile document and conflicting keys are replaced by data that's included in the request.</p>
4631
+ <p>For both labels and data, content is namespaced by the top-level fields.
4632
+ The <code>update_profile_data</code> global privilege grants privileges for updating only the allowed namespaces.</p>
4633
+
4634
+
4635
+ `<https://www.elastic.co/docs/api/doc/elasticsearch/v9/operation/operation-security-update-user-profile-data>`_
4636
+
4637
+ :param uid: A unique identifier for the user profile.
4638
+ :param data: Non-searchable data that you want to associate with the user profile.
4639
+ This field supports a nested data structure. Within the `data` object, top-level
4640
+ keys cannot begin with an underscore (`_`) or contain a period (`.`). The
4641
+ data object is not searchable, but can be retrieved with the get user profile
4642
+ API.
4643
+ :param if_primary_term: Only perform the operation if the document has this primary
4644
+ term.
4645
+ :param if_seq_no: Only perform the operation if the document has this sequence
4646
+ number.
4647
+ :param labels: Searchable data that you want to associate with the user profile.
4648
+ This field supports a nested data structure. Within the labels object, top-level
4649
+ keys cannot begin with an underscore (`_`) or contain a period (`.`).
4650
+ :param refresh: If 'true', Elasticsearch refreshes the affected shards to make
4651
+ this operation visible to search. If 'wait_for', it waits for a refresh to
4652
+ make this operation visible to search. If 'false', nothing is done with refreshes.
4653
+ """
4654
+ if uid in SKIP_IN_PATH:
4655
+ raise ValueError("Empty value passed for parameter 'uid'")
4656
+ __path_parts: t.Dict[str, str] = {"uid": _quote(uid)}
4657
+ __path = f'/_security/profile/{__path_parts["uid"]}/_data'
4658
+ __query: t.Dict[str, t.Any] = {}
4659
+ __body: t.Dict[str, t.Any] = body if body is not None else {}
4660
+ if error_trace is not None:
4661
+ __query["error_trace"] = error_trace
4662
+ if filter_path is not None:
4663
+ __query["filter_path"] = filter_path
4664
+ if human is not None:
4665
+ __query["human"] = human
4666
+ if if_primary_term is not None:
4667
+ __query["if_primary_term"] = if_primary_term
4668
+ if if_seq_no is not None:
4669
+ __query["if_seq_no"] = if_seq_no
4670
+ if pretty is not None:
4671
+ __query["pretty"] = pretty
4672
+ if refresh is not None:
4673
+ __query["refresh"] = refresh
4674
+ if not __body:
4675
+ if data is not None:
4676
+ __body["data"] = data
4677
+ if labels is not None:
4678
+ __body["labels"] = labels
4679
+ __headers = {"accept": "application/json", "content-type": "application/json"}
4680
+ return await self.perform_request( # type: ignore[return-value]
4681
+ "PUT",
4682
+ __path,
4683
+ params=__query,
4684
+ headers=__headers,
4685
+ body=__body,
4686
+ endpoint_id="security.update_user_profile_data",
4687
+ path_parts=__path_parts,
4688
+ )