From 5e4ed3832175c60b4fd9088c6e1f2769c461dcc5 Mon Sep 17 00:00:00 2001 From: gmarouli Date: Fri, 31 Oct 2025 12:53:43 +0200 Subject: [PATCH 1/2] Fix data stream lifecycle type, to correctly handle downsampling. --- output/openapi/elasticsearch-openapi.json | 25 +++--------- .../elasticsearch-serverless-openapi.json | 25 +++--------- output/schema/schema.json | 40 +++++-------------- output/typescript/types.ts | 6 +-- .../indices/_types/DataStreamLifecycle.ts | 6 +-- .../_types/DataStreamLifecycleDownsampling.ts | 27 ------------- 6 files changed, 25 insertions(+), 104 deletions(-) delete mode 100644 specification/indices/_types/DataStreamLifecycleDownsampling.ts diff --git a/output/openapi/elasticsearch-openapi.json b/output/openapi/elasticsearch-openapi.json index 344955ce3c..555aed0ed8 100644 --- a/output/openapi/elasticsearch-openapi.json +++ b/output/openapi/elasticsearch-openapi.json @@ -88389,33 +88389,20 @@ ] }, "downsampling": { - "description": "The downsampling configuration to execute for the managed backing index after rollover.", - "allOf": [ - { - "$ref": "#/components/schemas/indices._types.DataStreamLifecycleDownsampling" - } - ] - }, - "enabled": { - "description": "If defined, it turns data stream lifecycle on/off (`true`/`false`) for this data stream. A data stream lifecycle\nthat's disabled (enabled: `false`) will have no effect on the data stream.", - "default": true, - "type": "boolean" - } - } - }, - "indices._types.DataStreamLifecycleDownsampling": { - "type": "object", - "properties": { - "rounds": { "description": "The list of downsampling rounds to execute as part of this downsampling configuration", "type": "array", "items": { "$ref": "#/components/schemas/indices._types.DownsamplingRound" } + }, + "enabled": { + "description": "If defined, it turns data stream lifecycle on/off (`true`/`false`) for this data stream. A data stream lifecycle\nthat's disabled (enabled: `false`) will have no effect on the data stream.", + "default": true, + "type": "boolean" } }, "required": [ - "rounds" + "downsampling" ] }, "indices._types.DownsamplingRound": { diff --git a/output/openapi/elasticsearch-serverless-openapi.json b/output/openapi/elasticsearch-serverless-openapi.json index 68d188a72e..f23045c60b 100644 --- a/output/openapi/elasticsearch-serverless-openapi.json +++ b/output/openapi/elasticsearch-serverless-openapi.json @@ -60600,33 +60600,20 @@ ] }, "downsampling": { - "description": "The downsampling configuration to execute for the managed backing index after rollover.", - "allOf": [ - { - "$ref": "#/components/schemas/indices._types.DataStreamLifecycleDownsampling" - } - ] - }, - "enabled": { - "description": "If defined, it turns data stream lifecycle on/off (`true`/`false`) for this data stream. A data stream lifecycle\nthat's disabled (enabled: `false`) will have no effect on the data stream.", - "default": true, - "type": "boolean" - } - } - }, - "indices._types.DataStreamLifecycleDownsampling": { - "type": "object", - "properties": { - "rounds": { "description": "The list of downsampling rounds to execute as part of this downsampling configuration", "type": "array", "items": { "$ref": "#/components/schemas/indices._types.DownsamplingRound" } + }, + "enabled": { + "description": "If defined, it turns data stream lifecycle on/off (`true`/`false`) for this data stream. A data stream lifecycle\nthat's disabled (enabled: `false`) will have no effect on the data stream.", + "default": true, + "type": "boolean" } }, "required": [ - "rounds" + "downsampling" ] }, "indices._types.DownsamplingRound": { diff --git a/output/schema/schema.json b/output/schema/schema.json index 10d5e4bda2..b5a7fcfc7b 100644 --- a/output/schema/schema.json +++ b/output/schema/schema.json @@ -149197,14 +149197,17 @@ } }, { - "description": "The downsampling configuration to execute for the managed backing index after rollover.", + "description": "The list of downsampling rounds to execute as part of this downsampling configuration", "name": "downsampling", - "required": false, + "required": true, "type": { - "kind": "instance_of", - "type": { - "name": "DataStreamLifecycleDownsampling", - "namespace": "indices._types" + "kind": "array_of", + "value": { + "kind": "instance_of", + "type": { + "name": "DownsamplingRound", + "namespace": "indices._types" + } } } }, @@ -149224,31 +149227,6 @@ ], "specLocation": "indices/_types/DataStreamLifecycle.ts#L25-L45" }, - { - "kind": "interface", - "name": { - "name": "DataStreamLifecycleDownsampling", - "namespace": "indices._types" - }, - "properties": [ - { - "description": "The list of downsampling rounds to execute as part of this downsampling configuration", - "name": "rounds", - "required": true, - "type": { - "kind": "array_of", - "value": { - "kind": "instance_of", - "type": { - "name": "DownsamplingRound", - "namespace": "indices._types" - } - } - } - } - ], - "specLocation": "indices/_types/DataStreamLifecycleDownsampling.ts#L22-L27" - }, { "kind": "interface", "name": { diff --git a/output/typescript/types.ts b/output/typescript/types.ts index 2bf1edf279..ae961ba8a7 100644 --- a/output/typescript/types.ts +++ b/output/typescript/types.ts @@ -11882,14 +11882,10 @@ export interface IndicesDataStreamIndex { export interface IndicesDataStreamLifecycle { data_retention?: Duration - downsampling?: IndicesDataStreamLifecycleDownsampling + downsampling: IndicesDownsamplingRound[] enabled?: boolean } -export interface IndicesDataStreamLifecycleDownsampling { - rounds: IndicesDownsamplingRound[] -} - export interface IndicesDataStreamLifecycleRolloverConditions { min_age?: Duration max_age?: string diff --git a/specification/indices/_types/DataStreamLifecycle.ts b/specification/indices/_types/DataStreamLifecycle.ts index a9af498a1d..938db41460 100644 --- a/specification/indices/_types/DataStreamLifecycle.ts +++ b/specification/indices/_types/DataStreamLifecycle.ts @@ -20,7 +20,7 @@ import { ByteSize } from '@_types/common' import { long } from '@_types/Numeric' import { Duration } from '@_types/Time' -import { DataStreamLifecycleDownsampling } from '@indices/_types/DataStreamLifecycleDownsampling' +import { DownsamplingRound } from '@indices/_types/DownsamplingRound' /** * Data stream lifecycle denotes that a data stream is managed by the data stream lifecycle and contains the configuration. @@ -33,9 +33,9 @@ export class DataStreamLifecycle { */ data_retention?: Duration /** - * The downsampling configuration to execute for the managed backing index after rollover. + * The list of downsampling rounds to execute as part of this downsampling configuration */ - downsampling?: DataStreamLifecycleDownsampling + downsampling: DownsamplingRound[] /** * If defined, it turns data stream lifecycle on/off (`true`/`false`) for this data stream. A data stream lifecycle * that's disabled (enabled: `false`) will have no effect on the data stream. diff --git a/specification/indices/_types/DataStreamLifecycleDownsampling.ts b/specification/indices/_types/DataStreamLifecycleDownsampling.ts deleted file mode 100644 index 4aad62df47..0000000000 --- a/specification/indices/_types/DataStreamLifecycleDownsampling.ts +++ /dev/null @@ -1,27 +0,0 @@ -/* - * Licensed to Elasticsearch B.V. under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch B.V. licenses this file to you under - * the Apache License, Version 2.0 (the "License"); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -import { DownsamplingRound } from '@indices/_types/DownsamplingRound' - -export class DataStreamLifecycleDownsampling { - /** - * The list of downsampling rounds to execute as part of this downsampling configuration - */ - rounds: DownsamplingRound[] -} From 8fa3d9f05c3474ec59678842215eaeb6284baeb2 Mon Sep 17 00:00:00 2001 From: gmarouli Date: Fri, 31 Oct 2025 12:58:15 +0200 Subject: [PATCH 2/2] Add sampling method to data stream lifecycle --- output/openapi/elasticsearch-openapi.json | 35 +++++++++++++------ .../elasticsearch-serverless-openapi.json | 28 ++++++++++++--- output/schema/schema.json | 34 +++++++++++++++--- output/typescript/types.ts | 4 ++- .../indices/_types/DataStreamLifecycle.ts | 8 ++++- specification/indices/_types/Downsample.ts | 2 +- .../IndicesPutDataLifecycleRequest.ts | 8 ++++- 7 files changed, 95 insertions(+), 24 deletions(-) diff --git a/output/openapi/elasticsearch-openapi.json b/output/openapi/elasticsearch-openapi.json index 555aed0ed8..8cda4cfdc9 100644 --- a/output/openapi/elasticsearch-openapi.json +++ b/output/openapi/elasticsearch-openapi.json @@ -15641,6 +15641,14 @@ "$ref": "#/components/schemas/indices._types.DownsamplingRound" } }, + "downsampling_method": { + "description": "The method used to downsample the data. There are two options `aggregate` and `last_value`. It requires\n`downsampling` to be defined. Defaults to `aggregate`.", + "allOf": [ + { + "$ref": "#/components/schemas/indices._types.SamplingMethod" + } + ] + }, "enabled": { "description": "If defined, it turns data stream lifecycle on/off (`true`/`false`) for this data stream. A data stream lifecycle\nthat's disabled (enabled: `false`) will have no effect on the data stream.", "default": true, @@ -88395,15 +88403,20 @@ "$ref": "#/components/schemas/indices._types.DownsamplingRound" } }, + "downsampling_method": { + "description": "The method used to downsample the data. There are two options `aggregate` and `last_value`. It requires\n`downsampling` to be defined. Defaults to `aggregate`.", + "allOf": [ + { + "$ref": "#/components/schemas/indices._types.SamplingMethod" + } + ] + }, "enabled": { "description": "If defined, it turns data stream lifecycle on/off (`true`/`false`) for this data stream. A data stream lifecycle\nthat's disabled (enabled: `false`) will have no effect on the data stream.", "default": true, "type": "boolean" } - }, - "required": [ - "downsampling" - ] + } }, "indices._types.DownsamplingRound": { "type": "object", @@ -88430,6 +88443,13 @@ "fixed_interval" ] }, + "indices._types.SamplingMethod": { + "type": "string", + "enum": [ + "aggregate", + "last_value" + ] + }, "indices._types.DataStreamOptionsTemplate": { "description": "Data stream options template contains the same information as DataStreamOptions but allows them to be set explicitly to null.", "type": "object", @@ -97148,13 +97168,6 @@ "fixed_interval" ] }, - "indices._types.SamplingMethod": { - "type": "string", - "enum": [ - "aggregate", - "last_value" - ] - }, "indices.explain_data_lifecycle.DataStreamLifecycleExplain": { "type": "object", "properties": { diff --git a/output/openapi/elasticsearch-serverless-openapi.json b/output/openapi/elasticsearch-serverless-openapi.json index f23045c60b..e3a61a9289 100644 --- a/output/openapi/elasticsearch-serverless-openapi.json +++ b/output/openapi/elasticsearch-serverless-openapi.json @@ -9283,6 +9283,14 @@ "$ref": "#/components/schemas/indices._types.DownsamplingRound" } }, + "downsampling_method": { + "description": "The method used to downsample the data. There are two options `aggregate` and `last_value`. It requires\n`downsampling` to be defined. Defaults to `aggregate`.", + "allOf": [ + { + "$ref": "#/components/schemas/indices._types.SamplingMethod" + } + ] + }, "enabled": { "description": "If defined, it turns data stream lifecycle on/off (`true`/`false`) for this data stream. A data stream lifecycle\nthat's disabled (enabled: `false`) will have no effect on the data stream.", "default": true, @@ -60606,15 +60614,20 @@ "$ref": "#/components/schemas/indices._types.DownsamplingRound" } }, + "downsampling_method": { + "description": "The method used to downsample the data. There are two options `aggregate` and `last_value`. It requires\n`downsampling` to be defined. Defaults to `aggregate`.", + "allOf": [ + { + "$ref": "#/components/schemas/indices._types.SamplingMethod" + } + ] + }, "enabled": { "description": "If defined, it turns data stream lifecycle on/off (`true`/`false`) for this data stream. A data stream lifecycle\nthat's disabled (enabled: `false`) will have no effect on the data stream.", "default": true, "type": "boolean" } - }, - "required": [ - "downsampling" - ] + } }, "indices._types.DownsamplingRound": { "type": "object", @@ -60641,6 +60654,13 @@ "fixed_interval" ] }, + "indices._types.SamplingMethod": { + "type": "string", + "enum": [ + "aggregate", + "last_value" + ] + }, "indices._types.DataStreamOptionsTemplate": { "description": "Data stream options template contains the same information as DataStreamOptions but allows them to be set explicitly to null.", "type": "object", diff --git a/output/schema/schema.json b/output/schema/schema.json index b5a7fcfc7b..3556251033 100644 --- a/output/schema/schema.json +++ b/output/schema/schema.json @@ -149199,7 +149199,7 @@ { "description": "The list of downsampling rounds to execute as part of this downsampling configuration", "name": "downsampling", - "required": true, + "required": false, "type": { "kind": "array_of", "value": { @@ -149211,6 +149211,18 @@ } } }, + { + "description": "The method used to downsample the data. There are two options `aggregate` and `last_value`. It requires\n`downsampling` to be defined. Defaults to `aggregate`.", + "name": "downsampling_method", + "required": false, + "type": { + "kind": "instance_of", + "type": { + "name": "SamplingMethod", + "namespace": "indices._types" + } + } + }, { "description": "If defined, it turns data stream lifecycle on/off (`true`/`false`) for this data stream. A data stream lifecycle\nthat's disabled (enabled: `false`) will have no effect on the data stream.", "name": "enabled", @@ -149225,7 +149237,7 @@ } } ], - "specLocation": "indices/_types/DataStreamLifecycle.ts#L25-L45" + "specLocation": "indices/_types/DataStreamLifecycle.ts#L26-L51" }, { "kind": "interface", @@ -149345,7 +149357,7 @@ } } ], - "specLocation": "indices/_types/DataStreamLifecycle.ts#L60-L72" + "specLocation": "indices/_types/DataStreamLifecycle.ts#L66-L78" }, { "kind": "interface", @@ -149374,7 +149386,7 @@ } } ], - "specLocation": "indices/_types/DataStreamLifecycle.ts#L47-L58" + "specLocation": "indices/_types/DataStreamLifecycle.ts#L53-L64" }, { "kind": "interface", @@ -163144,6 +163156,18 @@ } } }, + { + "description": "The method used to downsample the data. There are two options `aggregate` and `last_value`. It requires\n`downsampling` to be defined. Defaults to `aggregate`.", + "name": "downsampling_method", + "required": false, + "type": { + "kind": "instance_of", + "type": { + "name": "SamplingMethod", + "namespace": "indices._types" + } + } + }, { "description": "If defined, it turns data stream lifecycle on/off (`true`/`false`) for this data stream. A data stream lifecycle\nthat's disabled (enabled: `false`) will have no effect on the data stream.", "name": "enabled", @@ -163286,7 +163310,7 @@ } } ], - "specLocation": "indices/put_data_lifecycle/IndicesPutDataLifecycleRequest.ts#L25-L93" + "specLocation": "indices/put_data_lifecycle/IndicesPutDataLifecycleRequest.ts#L26-L99" }, { "kind": "response", diff --git a/output/typescript/types.ts b/output/typescript/types.ts index ae961ba8a7..40c5c57742 100644 --- a/output/typescript/types.ts +++ b/output/typescript/types.ts @@ -11882,7 +11882,8 @@ export interface IndicesDataStreamIndex { export interface IndicesDataStreamLifecycle { data_retention?: Duration - downsampling: IndicesDownsamplingRound[] + downsampling?: IndicesDownsamplingRound[] + downsampling_method?: IndicesSamplingMethod enabled?: boolean } @@ -13154,6 +13155,7 @@ export interface IndicesPutDataLifecycleRequest extends RequestBase { body?: { data_retention?: Duration downsampling?: IndicesDownsamplingRound[] + downsampling_method?: IndicesSamplingMethod enabled?: boolean } } diff --git a/specification/indices/_types/DataStreamLifecycle.ts b/specification/indices/_types/DataStreamLifecycle.ts index 938db41460..35d83906d8 100644 --- a/specification/indices/_types/DataStreamLifecycle.ts +++ b/specification/indices/_types/DataStreamLifecycle.ts @@ -20,6 +20,7 @@ import { ByteSize } from '@_types/common' import { long } from '@_types/Numeric' import { Duration } from '@_types/Time' +import { SamplingMethod } from '@indices/_types/Downsample' import { DownsamplingRound } from '@indices/_types/DownsamplingRound' /** @@ -35,7 +36,12 @@ export class DataStreamLifecycle { /** * The list of downsampling rounds to execute as part of this downsampling configuration */ - downsampling: DownsamplingRound[] + downsampling?: DownsamplingRound[] + /** + * The method used to downsample the data. There are two options `aggregate` and `last_value`. It requires + * `downsampling` to be defined. Defaults to `aggregate`. + */ + downsampling_method?: SamplingMethod /** * If defined, it turns data stream lifecycle on/off (`true`/`false`) for this data stream. A data stream lifecycle * that's disabled (enabled: `false`) will have no effect on the data stream. diff --git a/specification/indices/_types/Downsample.ts b/specification/indices/_types/Downsample.ts index 46fa228a0c..93945a0fdd 100644 --- a/specification/indices/_types/Downsample.ts +++ b/specification/indices/_types/Downsample.ts @@ -30,7 +30,7 @@ export class DownsampleConfig { sampling_method?: SamplingMethod } -enum SamplingMethod { +export enum SamplingMethod { aggregate, last_value } diff --git a/specification/indices/put_data_lifecycle/IndicesPutDataLifecycleRequest.ts b/specification/indices/put_data_lifecycle/IndicesPutDataLifecycleRequest.ts index 32570f3ec2..7fb4a41fd2 100644 --- a/specification/indices/put_data_lifecycle/IndicesPutDataLifecycleRequest.ts +++ b/specification/indices/put_data_lifecycle/IndicesPutDataLifecycleRequest.ts @@ -20,6 +20,7 @@ import { RequestBase } from '@_types/Base' import { DataStreamNames, ExpandWildcards } from '@_types/common' import { Duration } from '@_types/Time' +import { SamplingMethod } from '@indices/_types/Downsample' import { DownsamplingRound } from '@indices/_types/DownsamplingRound' /** @@ -70,7 +71,7 @@ export interface Request extends RequestBase { } /* * This is DataStreamLifecycle from @indices/_types/DataStreamLifecycle.ts, - * but kept as a properties body to avoid a breaking change + * but kept as separate properties to avoid a breaking change */ body: { /** @@ -83,6 +84,11 @@ export interface Request extends RequestBase { * The downsampling configuration to execute for the managed backing index after rollover. */ downsampling?: DownsamplingRound[] + /** + * The method used to downsample the data. There are two options `aggregate` and `last_value`. It requires + * `downsampling` to be defined. Defaults to `aggregate`. + */ + downsampling_method?: SamplingMethod /** * If defined, it turns data stream lifecycle on/off (`true`/`false`) for this data stream. A data stream lifecycle * that's disabled (enabled: `false`) will have no effect on the data stream.