From 451feca2e2d508fd746baccbcd42dc66211f7d69 Mon Sep 17 00:00:00 2001 From: Quentin Pradet Date: Thu, 13 Mar 2025 18:17:06 +0400 Subject: [PATCH] Add missing query parameter for CreateRequest --- output/openapi/elasticsearch-openapi.json | 94 +++++++++++++++++-- .../elasticsearch-serverless-openapi.json | 94 +++++++++++++++++-- output/schema/schema-serverless.json | 68 +++++++++++++- output/schema/schema.json | 68 +++++++++++++- output/schema/validation-errors.json | 10 ++ output/typescript/types.ts | 5 + specification/_global/create/CreateRequest.ts | 32 +++++++ 7 files changed, 355 insertions(+), 16 deletions(-) diff --git a/output/openapi/elasticsearch-openapi.json b/output/openapi/elasticsearch-openapi.json index 336cc66db0..f2c2af6f34 100644 --- a/output/openapi/elasticsearch-openapi.json +++ b/output/openapi/elasticsearch-openapi.json @@ -7469,15 +7469,30 @@ { "$ref": "#/components/parameters/create#id" }, + { + "$ref": "#/components/parameters/create#if_primary_term" + }, + { + "$ref": "#/components/parameters/create#if_seq_no" + }, { "$ref": "#/components/parameters/create#include_source_on_error" }, + { + "$ref": "#/components/parameters/create#op_type" + }, { "$ref": "#/components/parameters/create#pipeline" }, { "$ref": "#/components/parameters/create#refresh" }, + { + "$ref": "#/components/parameters/create#require_alias" + }, + { + "$ref": "#/components/parameters/create#require_data_stream" + }, { "$ref": "#/components/parameters/create#routing" }, @@ -7521,15 +7536,30 @@ { "$ref": "#/components/parameters/create#id" }, + { + "$ref": "#/components/parameters/create#if_primary_term" + }, + { + "$ref": "#/components/parameters/create#if_seq_no" + }, { "$ref": "#/components/parameters/create#include_source_on_error" }, + { + "$ref": "#/components/parameters/create#op_type" + }, { "$ref": "#/components/parameters/create#pipeline" }, { "$ref": "#/components/parameters/create#refresh" }, + { + "$ref": "#/components/parameters/create#require_alias" + }, + { + "$ref": "#/components/parameters/create#require_data_stream" + }, { "$ref": "#/components/parameters/create#routing" }, @@ -71414,6 +71444,13 @@ "scheduled" ] }, + "_types:OpType": { + "type": "string", + "enum": [ + "index", + "create" + ] + }, "_types:WriteResponseBase": { "type": "object", "properties": { @@ -73881,13 +73918,6 @@ "phase" ] }, - "_types:OpType": { - "type": "string", - "enum": [ - "index", - "create" - ] - }, "indices.add_block:IndicesBlockOptions": { "type": "string", "enum": [ @@ -104160,6 +104190,26 @@ }, "style": "simple" }, + "create#if_primary_term": { + "in": "query", + "name": "if_primary_term", + "description": "Only perform the operation if the document has this primary term.", + "deprecated": false, + "schema": { + "type": "number" + }, + "style": "form" + }, + "create#if_seq_no": { + "in": "query", + "name": "if_seq_no", + "description": "Only perform the operation if the document has this sequence number.", + "deprecated": false, + "schema": { + "$ref": "#/components/schemas/_types:SequenceNumber" + }, + "style": "form" + }, "create#include_source_on_error": { "in": "query", "name": "include_source_on_error", @@ -104170,6 +104220,16 @@ }, "style": "form" }, + "create#op_type": { + "in": "query", + "name": "op_type", + "description": "Set to `create` to only index the document if it does not already exist (put if absent).\nIf a document with the specified `_id` already exists, the indexing operation will fail.\nThe behavior is the same as using the `/_create` endpoint.\nIf a document ID is specified, this paramater defaults to `index`.\nOtherwise, it defaults to `create`.\nIf the request targets a data stream, an `op_type` of `create` is required.", + "deprecated": false, + "schema": { + "$ref": "#/components/schemas/_types:OpType" + }, + "style": "form" + }, "create#pipeline": { "in": "query", "name": "pipeline", @@ -104190,6 +104250,26 @@ }, "style": "form" }, + "create#require_alias": { + "in": "query", + "name": "require_alias", + "description": "If `true`, the destination must be an index alias.", + "deprecated": false, + "schema": { + "type": "boolean" + }, + "style": "form" + }, + "create#require_data_stream": { + "in": "query", + "name": "require_data_stream", + "description": "If `true`, the request's actions must target a data stream (existing or to be created).", + "deprecated": false, + "schema": { + "type": "boolean" + }, + "style": "form" + }, "create#routing": { "in": "query", "name": "routing", diff --git a/output/openapi/elasticsearch-serverless-openapi.json b/output/openapi/elasticsearch-serverless-openapi.json index 1eb2cb0b98..49e14b0920 100644 --- a/output/openapi/elasticsearch-serverless-openapi.json +++ b/output/openapi/elasticsearch-serverless-openapi.json @@ -3696,15 +3696,30 @@ { "$ref": "#/components/parameters/create#id" }, + { + "$ref": "#/components/parameters/create#if_primary_term" + }, + { + "$ref": "#/components/parameters/create#if_seq_no" + }, { "$ref": "#/components/parameters/create#include_source_on_error" }, + { + "$ref": "#/components/parameters/create#op_type" + }, { "$ref": "#/components/parameters/create#pipeline" }, { "$ref": "#/components/parameters/create#refresh" }, + { + "$ref": "#/components/parameters/create#require_alias" + }, + { + "$ref": "#/components/parameters/create#require_data_stream" + }, { "$ref": "#/components/parameters/create#routing" }, @@ -3748,15 +3763,30 @@ { "$ref": "#/components/parameters/create#id" }, + { + "$ref": "#/components/parameters/create#if_primary_term" + }, + { + "$ref": "#/components/parameters/create#if_seq_no" + }, { "$ref": "#/components/parameters/create#include_source_on_error" }, + { + "$ref": "#/components/parameters/create#op_type" + }, { "$ref": "#/components/parameters/create#pipeline" }, { "$ref": "#/components/parameters/create#refresh" }, + { + "$ref": "#/components/parameters/create#require_alias" + }, + { + "$ref": "#/components/parameters/create#require_data_stream" + }, { "$ref": "#/components/parameters/create#routing" }, @@ -46078,6 +46108,13 @@ "scheduled" ] }, + "_types:OpType": { + "type": "string", + "enum": [ + "index", + "create" + ] + }, "_types:WriteResponseBase": { "type": "object", "properties": { @@ -46790,13 +46827,6 @@ "weight" ] }, - "_types:OpType": { - "type": "string", - "enum": [ - "index", - "create" - ] - }, "indices.add_block:IndicesBlockOptions": { "type": "string", "enum": [ @@ -61389,6 +61419,26 @@ }, "style": "simple" }, + "create#if_primary_term": { + "in": "query", + "name": "if_primary_term", + "description": "Only perform the operation if the document has this primary term.", + "deprecated": false, + "schema": { + "type": "number" + }, + "style": "form" + }, + "create#if_seq_no": { + "in": "query", + "name": "if_seq_no", + "description": "Only perform the operation if the document has this sequence number.", + "deprecated": false, + "schema": { + "$ref": "#/components/schemas/_types:SequenceNumber" + }, + "style": "form" + }, "create#include_source_on_error": { "in": "query", "name": "include_source_on_error", @@ -61399,6 +61449,16 @@ }, "style": "form" }, + "create#op_type": { + "in": "query", + "name": "op_type", + "description": "Set to `create` to only index the document if it does not already exist (put if absent).\nIf a document with the specified `_id` already exists, the indexing operation will fail.\nThe behavior is the same as using the `/_create` endpoint.\nIf a document ID is specified, this paramater defaults to `index`.\nOtherwise, it defaults to `create`.\nIf the request targets a data stream, an `op_type` of `create` is required.", + "deprecated": false, + "schema": { + "$ref": "#/components/schemas/_types:OpType" + }, + "style": "form" + }, "create#pipeline": { "in": "query", "name": "pipeline", @@ -61419,6 +61479,26 @@ }, "style": "form" }, + "create#require_alias": { + "in": "query", + "name": "require_alias", + "description": "If `true`, the destination must be an index alias.", + "deprecated": false, + "schema": { + "type": "boolean" + }, + "style": "form" + }, + "create#require_data_stream": { + "in": "query", + "name": "require_data_stream", + "description": "If `true`, the request's actions must target a data stream (existing or to be created).", + "deprecated": false, + "schema": { + "type": "boolean" + }, + "style": "form" + }, "create#routing": { "in": "query", "name": "routing", diff --git a/output/schema/schema-serverless.json b/output/schema/schema-serverless.json index d3bf0d75a7..3181b9a3b5 100644 --- a/output/schema/schema-serverless.json +++ b/output/schema/schema-serverless.json @@ -16960,6 +16960,34 @@ } ], "query": [ + { + "description": "Only perform the operation if the document has this primary term.", + "extDocId": "optimistic-concurrency", + "extDocUrl": "https://www.elastic.co/guide/en/elasticsearch/reference/current/optimistic-concurrency-control.html", + "name": "if_primary_term", + "required": false, + "type": { + "kind": "instance_of", + "type": { + "name": "long", + "namespace": "_types" + } + } + }, + { + "description": "Only perform the operation if the document has this sequence number.", + "extDocId": "optimistic-concurrency", + "extDocUrl": "https://www.elastic.co/guide/en/elasticsearch/reference/current/optimistic-concurrency-control.html", + "name": "if_seq_no", + "required": false, + "type": { + "kind": "instance_of", + "type": { + "name": "SequenceNumber", + "namespace": "_types" + } + } + }, { "description": "True or false if to include the document source in the error message in case of parsing errors.", "name": "include_source_on_error", @@ -16973,6 +17001,18 @@ } } }, + { + "description": "Set to `create` to only index the document if it does not already exist (put if absent).\nIf a document with the specified `_id` already exists, the indexing operation will fail.\nThe behavior is the same as using the `/_create` endpoint.\nIf a document ID is specified, this paramater defaults to `index`.\nOtherwise, it defaults to `create`.\nIf the request targets a data stream, an `op_type` of `create` is required.", + "name": "op_type", + "required": false, + "type": { + "kind": "instance_of", + "type": { + "name": "OpType", + "namespace": "_types" + } + } + }, { "description": "The ID of the pipeline to use to preprocess incoming documents.\nIf the index has a default ingest pipeline specified, setting the value to `_none` turns off the default ingest pipeline for this request.\nIf a final pipeline is configured, it will always run regardless of the value of this parameter.", "name": "pipeline", @@ -16998,6 +17038,32 @@ } } }, + { + "description": "If `true`, the destination must be an index alias.", + "name": "require_alias", + "required": false, + "serverDefault": false, + "type": { + "kind": "instance_of", + "type": { + "name": "boolean", + "namespace": "_builtins" + } + } + }, + { + "description": "If `true`, the request's actions must target a data stream (existing or to be created).", + "name": "require_data_stream", + "required": false, + "serverDefault": false, + "type": { + "kind": "instance_of", + "type": { + "name": "boolean", + "namespace": "_builtins" + } + } + }, { "description": "A custom value that is used to route operations to a specific shard.", "name": "routing", @@ -17061,7 +17127,7 @@ } } ], - "specLocation": "_global/create/CreateRequest.ts#L32-L189" + "specLocation": "_global/create/CreateRequest.ts#L35-L221" }, { "body": { diff --git a/output/schema/schema.json b/output/schema/schema.json index 94d83cdd24..238546f7a3 100644 --- a/output/schema/schema.json +++ b/output/schema/schema.json @@ -24281,6 +24281,34 @@ } ], "query": [ + { + "description": "Only perform the operation if the document has this primary term.", + "extDocId": "optimistic-concurrency", + "extDocUrl": "https://www.elastic.co/guide/en/elasticsearch/reference/current/optimistic-concurrency-control.html", + "name": "if_primary_term", + "required": false, + "type": { + "kind": "instance_of", + "type": { + "name": "long", + "namespace": "_types" + } + } + }, + { + "description": "Only perform the operation if the document has this sequence number.", + "extDocId": "optimistic-concurrency", + "extDocUrl": "https://www.elastic.co/guide/en/elasticsearch/reference/current/optimistic-concurrency-control.html", + "name": "if_seq_no", + "required": false, + "type": { + "kind": "instance_of", + "type": { + "name": "SequenceNumber", + "namespace": "_types" + } + } + }, { "description": "True or false if to include the document source in the error message in case of parsing errors.", "name": "include_source_on_error", @@ -24294,6 +24322,18 @@ } } }, + { + "description": "Set to `create` to only index the document if it does not already exist (put if absent).\nIf a document with the specified `_id` already exists, the indexing operation will fail.\nThe behavior is the same as using the `/_create` endpoint.\nIf a document ID is specified, this paramater defaults to `index`.\nOtherwise, it defaults to `create`.\nIf the request targets a data stream, an `op_type` of `create` is required.", + "name": "op_type", + "required": false, + "type": { + "kind": "instance_of", + "type": { + "name": "OpType", + "namespace": "_types" + } + } + }, { "description": "The ID of the pipeline to use to preprocess incoming documents.\nIf the index has a default ingest pipeline specified, setting the value to `_none` turns off the default ingest pipeline for this request.\nIf a final pipeline is configured, it will always run regardless of the value of this parameter.", "name": "pipeline", @@ -24319,6 +24359,32 @@ } } }, + { + "description": "If `true`, the destination must be an index alias.", + "name": "require_alias", + "required": false, + "serverDefault": false, + "type": { + "kind": "instance_of", + "type": { + "name": "boolean", + "namespace": "_builtins" + } + } + }, + { + "description": "If `true`, the request's actions must target a data stream (existing or to be created).", + "name": "require_data_stream", + "required": false, + "serverDefault": false, + "type": { + "kind": "instance_of", + "type": { + "name": "boolean", + "namespace": "_builtins" + } + } + }, { "description": "A custom value that is used to route operations to a specific shard.", "name": "routing", @@ -24382,7 +24448,7 @@ } } ], - "specLocation": "_global/create/CreateRequest.ts#L32-L189" + "specLocation": "_global/create/CreateRequest.ts#L35-L221" }, { "kind": "response", diff --git a/output/schema/validation-errors.json b/output/schema/validation-errors.json index ccc576c425..4e8255797a 100644 --- a/output/schema/validation-errors.json +++ b/output/schema/validation-errors.json @@ -48,6 +48,16 @@ ], "response": [] }, + "create": { + "request": [ + "Request: query parameter 'if_primary_term' does not exist in the json spec", + "Request: query parameter 'if_seq_no' does not exist in the json spec", + "Request: query parameter 'op_type' does not exist in the json spec", + "Request: query parameter 'require_alias' does not exist in the json spec", + "Request: query parameter 'require_data_stream' does not exist in the json spec" + ], + "response": [] + }, "eql.search": { "request": [ "Request: query parameter 'allow_no_indices' does not exist in the json spec", diff --git a/output/typescript/types.ts b/output/typescript/types.ts index 0e1eee44f2..3d2865a8dc 100644 --- a/output/typescript/types.ts +++ b/output/typescript/types.ts @@ -159,9 +159,14 @@ export interface CountResponse { export interface CreateRequest extends RequestBase { id: Id index: IndexName + if_primary_term?: long + if_seq_no?: SequenceNumber include_source_on_error?: boolean + op_type?: OpType pipeline?: string refresh?: Refresh + require_alias?: boolean + require_data_stream?: boolean routing?: Routing timeout?: Duration version?: VersionNumber diff --git a/specification/_global/create/CreateRequest.ts b/specification/_global/create/CreateRequest.ts index c7745b1ce5..35dcdcb72d 100644 --- a/specification/_global/create/CreateRequest.ts +++ b/specification/_global/create/CreateRequest.ts @@ -21,12 +21,15 @@ import { RequestBase } from '@_types/Base' import { Id, IndexName, + OpType, Refresh, Routing, + SequenceNumber, VersionNumber, VersionType, WaitForActiveShards } from '@_types/common' +import { long } from '@_types/Numeric' import { Duration } from '@_types/Time' /** @@ -131,11 +134,30 @@ export interface Request extends RequestBase { index: IndexName } query_parameters: { + /** + * Only perform the operation if the document has this primary term. + * @ext_doc_id optimistic-concurrency + */ + if_primary_term?: long + /** + * Only perform the operation if the document has this sequence number. + * @ext_doc_id optimistic-concurrency + */ + if_seq_no?: SequenceNumber /** * True or false if to include the document source in the error message in case of parsing errors. * @server_default true */ include_source_on_error?: boolean + /** + * Set to `create` to only index the document if it does not already exist (put if absent). + * If a document with the specified `_id` already exists, the indexing operation will fail. + * The behavior is the same as using the `/_create` endpoint. + * If a document ID is specified, this paramater defaults to `index`. + * Otherwise, it defaults to `create`. + * If the request targets a data stream, an `op_type` of `create` is required. + */ + op_type?: OpType /** * The ID of the pipeline to use to preprocess incoming documents. * If the index has a default ingest pipeline specified, setting the value to `_none` turns off the default ingest pipeline for this request. @@ -149,6 +171,16 @@ export interface Request extends RequestBase { * @server_default false */ refresh?: Refresh + /** + * If `true`, the destination must be an index alias. + * @server_default false + */ + require_alias?: boolean + /** + * If `true`, the request's actions must target a data stream (existing or to be created). + * @server_default false + */ + require_data_stream?: boolean /** * A custom value that is used to route operations to a specific shard. */