From 43196929a61e54e41ac1c9564d2eb70cecba8da2 Mon Sep 17 00:00:00 2001 From: Florian Bernd Date: Tue, 22 Oct 2024 20:02:24 +0200 Subject: [PATCH] Improve `DataStreamLifecycle` definitions (and related) (#3039) --- .../indices/_types/DataStreamLifecycle.ts | 23 +++++++++++-------- .../IndicesGetDataLifecycleResponse.ts | 4 ++-- .../IndicesPutDataLifecycleRequest.ts | 19 ++++----------- 3 files changed, 20 insertions(+), 26 deletions(-) diff --git a/specification/indices/_types/DataStreamLifecycle.ts b/specification/indices/_types/DataStreamLifecycle.ts index 0c2f9783a2..da8fa4c9b6 100644 --- a/specification/indices/_types/DataStreamLifecycle.ts +++ b/specification/indices/_types/DataStreamLifecycle.ts @@ -26,26 +26,29 @@ import { Duration } from '@_types/Time' * Data stream lifecycle denotes that a data stream is managed by the data stream lifecycle and contains the configuration. */ export class DataStreamLifecycle { - data_retention?: Duration - downsampling?: DataStreamLifecycleDownsampling -} - -/** - * Data stream lifecycle with rollover can be used to display the configuration including the default rollover conditions, - * if asked. - */ -export class DataStreamLifecycleWithRollover { /** * If defined, every document added to this data stream will be stored at least for this time frame. * Any time after this duration the document could be deleted. * When empty, every document in this data stream will be stored indefinitely. */ data_retention?: Duration - /** * The downsampling configuration to execute for the managed backing index after rollover. */ downsampling?: DataStreamLifecycleDownsampling + /** + * 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. + * @server_default true + */ + enabled?: boolean +} + +/** + * Data stream lifecycle with rollover can be used to display the configuration including the default rollover conditions, + * if asked. + */ +export class DataStreamLifecycleWithRollover extends DataStreamLifecycle { /** * The conditions which will trigger the rollover of a backing index as configured by the cluster setting `cluster.lifecycle.default.rollover`. * This property is an implementation detail and it will only be retrieved when the query param `include_defaults` is set to true. diff --git a/specification/indices/get_data_lifecycle/IndicesGetDataLifecycleResponse.ts b/specification/indices/get_data_lifecycle/IndicesGetDataLifecycleResponse.ts index de939e559d..c74defb4ab 100644 --- a/specification/indices/get_data_lifecycle/IndicesGetDataLifecycleResponse.ts +++ b/specification/indices/get_data_lifecycle/IndicesGetDataLifecycleResponse.ts @@ -17,7 +17,7 @@ * under the License. */ -import { DataStreamLifecycle } from '@indices/_types/DataStreamLifecycle' +import { DataStreamLifecycleWithRollover } from '@indices/_types/DataStreamLifecycle' import { DataStreamName } from '@_types/common' export class Response { @@ -26,5 +26,5 @@ export class Response { class DataStreamWithLifecycle { name: DataStreamName - lifecycle?: DataStreamLifecycle + lifecycle?: DataStreamLifecycleWithRollover } diff --git a/specification/indices/put_data_lifecycle/IndicesPutDataLifecycleRequest.ts b/specification/indices/put_data_lifecycle/IndicesPutDataLifecycleRequest.ts index 290d54f235..83041d7525 100644 --- a/specification/indices/put_data_lifecycle/IndicesPutDataLifecycleRequest.ts +++ b/specification/indices/put_data_lifecycle/IndicesPutDataLifecycleRequest.ts @@ -17,7 +17,7 @@ * under the License. */ -import { DataStreamLifecycleDownsampling } from '@indices/_types/DataStreamLifecycleDownsampling' +import { DataStreamLifecycle } from '@indices/_types/DataStreamLifecycle' import { RequestBase } from '@_types/Base' import { DataStreamNames, ExpandWildcards } from '@_types/common' import { Duration } from '@_types/Time' @@ -60,17 +60,8 @@ export interface Request extends RequestBase { */ timeout?: Duration } - body: { - /** - * If defined, every document added to this data stream will be stored at least for this time frame. - * Any time after this duration the document could be deleted. - * When empty, every document in this data stream will be stored indefinitely. - */ - data_retention?: Duration - /** - * If defined, every backing index will execute the configured downsampling configuration after the backing - * index is not the data stream write index anymore. - */ - downsampling?: DataStreamLifecycleDownsampling - } + /** + * @codegen_name lifecycle + */ + body: DataStreamLifecycle }