Skip to content

Commit b755349

Browse files
Auto-generated API code (#2847)
1 parent e3e9f9f commit b755349

File tree

7 files changed

+281
-16
lines changed

7 files changed

+281
-16
lines changed

elasticsearch/_async/client/__init__.py

+28
Original file line numberDiff line numberDiff line change
@@ -1008,12 +1008,17 @@ async def create(
10081008
error_trace: t.Optional[bool] = None,
10091009
filter_path: t.Optional[t.Union[str, t.Sequence[str]]] = None,
10101010
human: t.Optional[bool] = None,
1011+
if_primary_term: t.Optional[int] = None,
1012+
if_seq_no: t.Optional[int] = None,
10111013
include_source_on_error: t.Optional[bool] = None,
1014+
op_type: t.Optional[t.Union[str, t.Literal["create", "index"]]] = None,
10121015
pipeline: t.Optional[str] = None,
10131016
pretty: t.Optional[bool] = None,
10141017
refresh: t.Optional[
10151018
t.Union[bool, str, t.Literal["false", "true", "wait_for"]]
10161019
] = None,
1020+
require_alias: t.Optional[bool] = None,
1021+
require_data_stream: t.Optional[bool] = None,
10171022
routing: t.Optional[str] = None,
10181023
timeout: t.Optional[t.Union[str, t.Literal[-1], t.Literal[0]]] = None,
10191024
version: t.Optional[int] = None,
@@ -1091,8 +1096,18 @@ async def create(
10911096
:param id: A unique identifier for the document. To automatically generate a
10921097
document ID, use the `POST /<target>/_doc/` request format.
10931098
:param document:
1099+
:param if_primary_term: Only perform the operation if the document has this primary
1100+
term.
1101+
:param if_seq_no: Only perform the operation if the document has this sequence
1102+
number.
10941103
:param include_source_on_error: True or false if to include the document source
10951104
in the error message in case of parsing errors.
1105+
:param op_type: Set to `create` to only index the document if it does not already
1106+
exist (put if absent). If a document with the specified `_id` already exists,
1107+
the indexing operation will fail. The behavior is the same as using the `<index>/_create`
1108+
endpoint. If a document ID is specified, this paramater defaults to `index`.
1109+
Otherwise, it defaults to `create`. If the request targets a data stream,
1110+
an `op_type` of `create` is required.
10961111
:param pipeline: The ID of the pipeline to use to preprocess incoming documents.
10971112
If the index has a default ingest pipeline specified, setting the value to
10981113
`_none` turns off the default ingest pipeline for this request. If a final
@@ -1101,6 +1116,9 @@ async def create(
11011116
:param refresh: If `true`, Elasticsearch refreshes the affected shards to make
11021117
this operation visible to search. If `wait_for`, it waits for a refresh to
11031118
make this operation visible to search. If `false`, it does nothing with refreshes.
1119+
:param require_alias: If `true`, the destination must be an index alias.
1120+
:param require_data_stream: If `true`, the request's actions must target a data
1121+
stream (existing or to be created).
11041122
:param routing: A custom value that is used to route operations to a specific
11051123
shard.
11061124
:param timeout: The period the request waits for the following operations: automatic
@@ -1141,14 +1159,24 @@ async def create(
11411159
__query["filter_path"] = filter_path
11421160
if human is not None:
11431161
__query["human"] = human
1162+
if if_primary_term is not None:
1163+
__query["if_primary_term"] = if_primary_term
1164+
if if_seq_no is not None:
1165+
__query["if_seq_no"] = if_seq_no
11441166
if include_source_on_error is not None:
11451167
__query["include_source_on_error"] = include_source_on_error
1168+
if op_type is not None:
1169+
__query["op_type"] = op_type
11461170
if pipeline is not None:
11471171
__query["pipeline"] = pipeline
11481172
if pretty is not None:
11491173
__query["pretty"] = pretty
11501174
if refresh is not None:
11511175
__query["refresh"] = refresh
1176+
if require_alias is not None:
1177+
__query["require_alias"] = require_alias
1178+
if require_data_stream is not None:
1179+
__query["require_data_stream"] = require_data_stream
11521180
if routing is not None:
11531181
__query["routing"] = routing
11541182
if timeout is not None:

elasticsearch/_async/client/inference.py

+100-2
Original file line numberDiff line numberDiff line change
@@ -321,6 +321,104 @@ async def put(
321321
path_parts=__path_parts,
322322
)
323323

324+
@_rewrite_parameters(
325+
body_fields=(
326+
"service",
327+
"service_settings",
328+
"chunking_settings",
329+
"task_settings",
330+
),
331+
)
332+
async def put_openai(
333+
self,
334+
*,
335+
task_type: t.Union[
336+
str, t.Literal["chat_completion", "completion", "text_embedding"]
337+
],
338+
openai_inference_id: str,
339+
service: t.Optional[t.Union[str, t.Literal["openai"]]] = None,
340+
service_settings: t.Optional[t.Mapping[str, t.Any]] = None,
341+
chunking_settings: t.Optional[t.Mapping[str, t.Any]] = None,
342+
error_trace: t.Optional[bool] = None,
343+
filter_path: t.Optional[t.Union[str, t.Sequence[str]]] = None,
344+
human: t.Optional[bool] = None,
345+
pretty: t.Optional[bool] = None,
346+
task_settings: t.Optional[t.Mapping[str, t.Any]] = None,
347+
body: t.Optional[t.Dict[str, t.Any]] = None,
348+
) -> ObjectApiResponse[t.Any]:
349+
"""
350+
.. raw:: html
351+
352+
<p>Create an OpenAI inference endpoint.</p>
353+
<p>Create an inference endpoint to perform an inference task with the <code>openai</code> service.</p>
354+
<p>When you create an inference endpoint, the associated machine learning model is automatically deployed if it is not already running.
355+
After creating the endpoint, wait for the model deployment to complete before using it.
356+
To verify the deployment status, use the get trained model statistics API.
357+
Look for <code>&quot;state&quot;: &quot;fully_allocated&quot;</code> in the response and ensure that the <code>&quot;allocation_count&quot;</code> matches the <code>&quot;target_allocation_count&quot;</code>.
358+
Avoid creating multiple endpoints for the same model unless required, as each endpoint consumes significant resources.</p>
359+
360+
361+
`<https://www.elastic.co/guide/en/elasticsearch/reference/master/infer-service-openai.html>`_
362+
363+
:param task_type: The type of the inference task that the model will perform.
364+
NOTE: The `chat_completion` task type only supports streaming and only through
365+
the _stream API.
366+
:param openai_inference_id: The unique identifier of the inference endpoint.
367+
:param service: The type of service supported for the specified task type. In
368+
this case, `openai`.
369+
:param service_settings: Settings used to install the inference model. These
370+
settings are specific to the `openai` service.
371+
:param chunking_settings: The chunking configuration object.
372+
:param task_settings: Settings to configure the inference task. These settings
373+
are specific to the task type you specified.
374+
"""
375+
if task_type in SKIP_IN_PATH:
376+
raise ValueError("Empty value passed for parameter 'task_type'")
377+
if openai_inference_id in SKIP_IN_PATH:
378+
raise ValueError("Empty value passed for parameter 'openai_inference_id'")
379+
if service is None and body is None:
380+
raise ValueError("Empty value passed for parameter 'service'")
381+
if service_settings is None and body is None:
382+
raise ValueError("Empty value passed for parameter 'service_settings'")
383+
__path_parts: t.Dict[str, str] = {
384+
"task_type": _quote(task_type),
385+
"openai_inference_id": _quote(openai_inference_id),
386+
}
387+
__path = f'/_inference/{__path_parts["task_type"]}/{__path_parts["openai_inference_id"]}'
388+
__query: t.Dict[str, t.Any] = {}
389+
__body: t.Dict[str, t.Any] = body if body is not None else {}
390+
if error_trace is not None:
391+
__query["error_trace"] = error_trace
392+
if filter_path is not None:
393+
__query["filter_path"] = filter_path
394+
if human is not None:
395+
__query["human"] = human
396+
if pretty is not None:
397+
__query["pretty"] = pretty
398+
if not __body:
399+
if service is not None:
400+
__body["service"] = service
401+
if service_settings is not None:
402+
__body["service_settings"] = service_settings
403+
if chunking_settings is not None:
404+
__body["chunking_settings"] = chunking_settings
405+
if task_settings is not None:
406+
__body["task_settings"] = task_settings
407+
if not __body:
408+
__body = None # type: ignore[assignment]
409+
__headers = {"accept": "application/json"}
410+
if __body is not None:
411+
__headers["content-type"] = "application/json"
412+
return await self.perform_request( # type: ignore[return-value]
413+
"PUT",
414+
__path,
415+
params=__query,
416+
headers=__headers,
417+
body=__body,
418+
endpoint_id="inference.put_openai",
419+
path_parts=__path_parts,
420+
)
421+
324422
@_rewrite_parameters(
325423
body_fields=("service", "service_settings"),
326424
)
@@ -341,7 +439,7 @@ async def put_watsonx(
341439
.. raw:: html
342440
343441
<p>Create a Watsonx inference endpoint.</p>
344-
<p>Creates an inference endpoint to perform an inference task with the <code>watsonxai</code> service.
442+
<p>Create an inference endpoint to perform an inference task with the <code>watsonxai</code> service.
345443
You need an IBM Cloud Databases for Elasticsearch deployment to use the <code>watsonxai</code> inference service.
346444
You can provision one through the IBM catalog, the Cloud Databases CLI plug-in, the Cloud Databases API, or Terraform.</p>
347445
<p>When you create an inference endpoint, the associated machine learning model is automatically deployed if it is not already running.
@@ -351,7 +449,7 @@ async def put_watsonx(
351449
Avoid creating multiple endpoints for the same model unless required, as each endpoint consumes significant resources.</p>
352450
353451
354-
`<https://www.elastic.co/guide/en/elasticsearch/reference/master/infer-service-watsonx-ai.html>`_
452+
`<https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-inference-put-watsonx>`_
355453
356454
:param task_type: The task type. The only valid task type for the model to perform
357455
is `text_embedding`.

elasticsearch/_async/client/ml.py

+4-4
Original file line numberDiff line numberDiff line change
@@ -3599,11 +3599,11 @@ async def put_datafeed(
35993599
:param ignore_unavailable: If true, unavailable indices (missing or closed) are
36003600
ignored.
36013601
:param indexes: An array of index names. Wildcards are supported. If any of the
3602-
indices are in remote clusters, the machine learning nodes must have the
3603-
`remote_cluster_client` role.
3602+
indices are in remote clusters, the master nodes and the machine learning
3603+
nodes must have the `remote_cluster_client` role.
36043604
:param indices: An array of index names. Wildcards are supported. If any of the
3605-
indices are in remote clusters, the machine learning nodes must have the
3606-
`remote_cluster_client` role.
3605+
indices are in remote clusters, the master nodes and the machine learning
3606+
nodes must have the `remote_cluster_client` role.
36073607
:param indices_options: Specifies index expansion options that are used during
36083608
search
36093609
:param job_id: Identifier for the anomaly detection job.

elasticsearch/_sync/client/__init__.py

+28
Original file line numberDiff line numberDiff line change
@@ -1006,12 +1006,17 @@ def create(
10061006
error_trace: t.Optional[bool] = None,
10071007
filter_path: t.Optional[t.Union[str, t.Sequence[str]]] = None,
10081008
human: t.Optional[bool] = None,
1009+
if_primary_term: t.Optional[int] = None,
1010+
if_seq_no: t.Optional[int] = None,
10091011
include_source_on_error: t.Optional[bool] = None,
1012+
op_type: t.Optional[t.Union[str, t.Literal["create", "index"]]] = None,
10101013
pipeline: t.Optional[str] = None,
10111014
pretty: t.Optional[bool] = None,
10121015
refresh: t.Optional[
10131016
t.Union[bool, str, t.Literal["false", "true", "wait_for"]]
10141017
] = None,
1018+
require_alias: t.Optional[bool] = None,
1019+
require_data_stream: t.Optional[bool] = None,
10151020
routing: t.Optional[str] = None,
10161021
timeout: t.Optional[t.Union[str, t.Literal[-1], t.Literal[0]]] = None,
10171022
version: t.Optional[int] = None,
@@ -1089,8 +1094,18 @@ def create(
10891094
:param id: A unique identifier for the document. To automatically generate a
10901095
document ID, use the `POST /<target>/_doc/` request format.
10911096
:param document:
1097+
:param if_primary_term: Only perform the operation if the document has this primary
1098+
term.
1099+
:param if_seq_no: Only perform the operation if the document has this sequence
1100+
number.
10921101
:param include_source_on_error: True or false if to include the document source
10931102
in the error message in case of parsing errors.
1103+
:param op_type: Set to `create` to only index the document if it does not already
1104+
exist (put if absent). If a document with the specified `_id` already exists,
1105+
the indexing operation will fail. The behavior is the same as using the `<index>/_create`
1106+
endpoint. If a document ID is specified, this paramater defaults to `index`.
1107+
Otherwise, it defaults to `create`. If the request targets a data stream,
1108+
an `op_type` of `create` is required.
10941109
:param pipeline: The ID of the pipeline to use to preprocess incoming documents.
10951110
If the index has a default ingest pipeline specified, setting the value to
10961111
`_none` turns off the default ingest pipeline for this request. If a final
@@ -1099,6 +1114,9 @@ def create(
10991114
:param refresh: If `true`, Elasticsearch refreshes the affected shards to make
11001115
this operation visible to search. If `wait_for`, it waits for a refresh to
11011116
make this operation visible to search. If `false`, it does nothing with refreshes.
1117+
:param require_alias: If `true`, the destination must be an index alias.
1118+
:param require_data_stream: If `true`, the request's actions must target a data
1119+
stream (existing or to be created).
11021120
:param routing: A custom value that is used to route operations to a specific
11031121
shard.
11041122
:param timeout: The period the request waits for the following operations: automatic
@@ -1139,14 +1157,24 @@ def create(
11391157
__query["filter_path"] = filter_path
11401158
if human is not None:
11411159
__query["human"] = human
1160+
if if_primary_term is not None:
1161+
__query["if_primary_term"] = if_primary_term
1162+
if if_seq_no is not None:
1163+
__query["if_seq_no"] = if_seq_no
11421164
if include_source_on_error is not None:
11431165
__query["include_source_on_error"] = include_source_on_error
1166+
if op_type is not None:
1167+
__query["op_type"] = op_type
11441168
if pipeline is not None:
11451169
__query["pipeline"] = pipeline
11461170
if pretty is not None:
11471171
__query["pretty"] = pretty
11481172
if refresh is not None:
11491173
__query["refresh"] = refresh
1174+
if require_alias is not None:
1175+
__query["require_alias"] = require_alias
1176+
if require_data_stream is not None:
1177+
__query["require_data_stream"] = require_data_stream
11501178
if routing is not None:
11511179
__query["routing"] = routing
11521180
if timeout is not None:

0 commit comments

Comments
 (0)