diff --git a/api/api/indices.create_data_stream.js b/api/api/indices.create_data_stream.js new file mode 100644 index 000000000..b3dd2e717 --- /dev/null +++ b/api/api/indices.create_data_stream.js @@ -0,0 +1,87 @@ +// Licensed to Elasticsearch B.V under one or more agreements. +// Elasticsearch B.V licenses this file to you under the Apache 2.0 License. +// See the LICENSE file in the project root for more information + +'use strict' + +/* eslint camelcase: 0 */ +/* eslint no-unused-vars: 0 */ + +function buildIndicesCreateDataStream (opts) { + // eslint-disable-next-line no-unused-vars + const { makeRequest, ConfigurationError, handleError, snakeCaseKeys } = opts + + const acceptedQuerystring = [ + 'pretty', + 'human', + 'error_trace', + 'source', + 'filter_path' + ] + + const snakeCase = { + errorTrace: 'error_trace', + filterPath: 'filter_path' + } + + /** + * Perform a indices.create_data_stream request + * Creates or updates a data stream + * https://www.elastic.co/guide/en/elasticsearch/reference/master/data-streams.html + */ + return function indicesCreateDataStream (params, options, callback) { + options = options || {} + if (typeof options === 'function') { + callback = options + options = {} + } + if (typeof params === 'function' || params == null) { + callback = params + params = {} + options = {} + } + + // check required parameters + if (params['name'] == null) { + const err = new ConfigurationError('Missing required parameter: name') + return handleError(err, callback) + } + if (params['body'] == null) { + const err = new ConfigurationError('Missing required parameter: body') + return handleError(err, callback) + } + + // validate headers object + if (options.headers != null && typeof options.headers !== 'object') { + const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`) + return handleError(err, callback) + } + + var warnings = [] + var { method, body, name, ...querystring } = params + querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring, warnings) + + var ignore = options.ignore + if (typeof ignore === 'number') { + options.ignore = [ignore] + } + + var path = '' + + if (method == null) method = 'PUT' + path = '/' + '_data_stream' + '/' + encodeURIComponent(name) + + // build request object + const request = { + method, + path, + body: body || '', + querystring + } + + options.warnings = warnings.length === 0 ? null : warnings + return makeRequest(request, options, callback) + } +} + +module.exports = buildIndicesCreateDataStream diff --git a/api/api/indices.delete_data_stream.js b/api/api/indices.delete_data_stream.js new file mode 100644 index 000000000..10e5d6fe1 --- /dev/null +++ b/api/api/indices.delete_data_stream.js @@ -0,0 +1,83 @@ +// Licensed to Elasticsearch B.V under one or more agreements. +// Elasticsearch B.V licenses this file to you under the Apache 2.0 License. +// See the LICENSE file in the project root for more information + +'use strict' + +/* eslint camelcase: 0 */ +/* eslint no-unused-vars: 0 */ + +function buildIndicesDeleteDataStream (opts) { + // eslint-disable-next-line no-unused-vars + const { makeRequest, ConfigurationError, handleError, snakeCaseKeys } = opts + + const acceptedQuerystring = [ + 'pretty', + 'human', + 'error_trace', + 'source', + 'filter_path' + ] + + const snakeCase = { + errorTrace: 'error_trace', + filterPath: 'filter_path' + } + + /** + * Perform a indices.delete_data_stream request + * Deletes a data stream. + * https://www.elastic.co/guide/en/elasticsearch/reference/master/data-streams.html + */ + return function indicesDeleteDataStream (params, options, callback) { + options = options || {} + if (typeof options === 'function') { + callback = options + options = {} + } + if (typeof params === 'function' || params == null) { + callback = params + params = {} + options = {} + } + + // check required parameters + if (params['name'] == null) { + const err = new ConfigurationError('Missing required parameter: name') + return handleError(err, callback) + } + + // validate headers object + if (options.headers != null && typeof options.headers !== 'object') { + const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`) + return handleError(err, callback) + } + + var warnings = [] + var { method, body, name, ...querystring } = params + querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring, warnings) + + var ignore = options.ignore + if (typeof ignore === 'number') { + options.ignore = [ignore] + } + + var path = '' + + if (method == null) method = 'DELETE' + path = '/' + '_data_stream' + '/' + encodeURIComponent(name) + + // build request object + const request = { + method, + path, + body: body || '', + querystring + } + + options.warnings = warnings.length === 0 ? null : warnings + return makeRequest(request, options, callback) + } +} + +module.exports = buildIndicesDeleteDataStream diff --git a/api/api/indices.get_data_streams.js b/api/api/indices.get_data_streams.js new file mode 100644 index 000000000..9bf2b59a6 --- /dev/null +++ b/api/api/indices.get_data_streams.js @@ -0,0 +1,82 @@ +// Licensed to Elasticsearch B.V under one or more agreements. +// Elasticsearch B.V licenses this file to you under the Apache 2.0 License. +// See the LICENSE file in the project root for more information + +'use strict' + +/* eslint camelcase: 0 */ +/* eslint no-unused-vars: 0 */ + +function buildIndicesGetDataStreams (opts) { + // eslint-disable-next-line no-unused-vars + const { makeRequest, ConfigurationError, handleError, snakeCaseKeys } = opts + + const acceptedQuerystring = [ + 'pretty', + 'human', + 'error_trace', + 'source', + 'filter_path' + ] + + const snakeCase = { + errorTrace: 'error_trace', + filterPath: 'filter_path' + } + + /** + * Perform a indices.get_data_streams request + * Returns data streams. + * https://www.elastic.co/guide/en/elasticsearch/reference/master/data-streams.html + */ + return function indicesGetDataStreams (params, options, callback) { + options = options || {} + if (typeof options === 'function') { + callback = options + options = {} + } + if (typeof params === 'function' || params == null) { + callback = params + params = {} + options = {} + } + + // validate headers object + if (options.headers != null && typeof options.headers !== 'object') { + const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`) + return handleError(err, callback) + } + + var warnings = [] + var { method, body, name, ...querystring } = params + querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring, warnings) + + var ignore = options.ignore + if (typeof ignore === 'number') { + options.ignore = [ignore] + } + + var path = '' + + if ((name) != null) { + if (method == null) method = 'GET' + path = '/' + '_data_streams' + '/' + encodeURIComponent(name) + } else { + if (method == null) method = 'GET' + path = '/' + '_data_streams' + } + + // build request object + const request = { + method, + path, + body: null, + querystring + } + + options.warnings = warnings.length === 0 ? null : warnings + return makeRequest(request, options, callback) + } +} + +module.exports = buildIndicesGetDataStreams diff --git a/api/index.js b/api/index.js index 07d12fd3e..bee5b18be 100644 --- a/api/index.js +++ b/api/index.js @@ -216,9 +216,13 @@ function ESAPI (opts) { clone: lazyLoad('indices.clone', opts), close: lazyLoad('indices.close', opts), create: lazyLoad('indices.create', opts), + create_data_stream: lazyLoad('indices.create_data_stream', opts), + createDataStream: lazyLoad('indices.create_data_stream', opts), delete: lazyLoad('indices.delete', opts), delete_alias: lazyLoad('indices.delete_alias', opts), deleteAlias: lazyLoad('indices.delete_alias', opts), + delete_data_stream: lazyLoad('indices.delete_data_stream', opts), + deleteDataStream: lazyLoad('indices.delete_data_stream', opts), delete_template: lazyLoad('indices.delete_template', opts), deleteTemplate: lazyLoad('indices.delete_template', opts), exists: lazyLoad('indices.exists', opts), @@ -234,6 +238,8 @@ function ESAPI (opts) { get: lazyLoad('indices.get', opts), get_alias: lazyLoad('indices.get_alias', opts), getAlias: lazyLoad('indices.get_alias', opts), + get_data_streams: lazyLoad('indices.get_data_streams', opts), + getDataStreams: lazyLoad('indices.get_data_streams', opts), get_field_mapping: lazyLoad('indices.get_field_mapping', opts), getFieldMapping: lazyLoad('indices.get_field_mapping', opts), get_mapping: lazyLoad('indices.get_mapping', opts), diff --git a/api/requestParams.d.ts b/api/requestParams.d.ts index 4394ce596..b5b0003a2 100644 --- a/api/requestParams.d.ts +++ b/api/requestParams.d.ts @@ -609,6 +609,11 @@ export interface IndicesCreate extends Generic { body?: T; } +export interface IndicesCreateDataStream extends Generic { + name: string; + body: T; +} + export interface IndicesDelete extends Generic { index: string | string[]; timeout?: string; @@ -625,6 +630,10 @@ export interface IndicesDeleteAlias extends Generic { master_timeout?: string; } +export interface IndicesDeleteDataStream extends Generic { + name: string; +} + export interface IndicesDeleteTemplate extends Generic { name: string; timeout?: string; @@ -705,6 +714,10 @@ export interface IndicesGetAlias extends Generic { local?: boolean; } +export interface IndicesGetDataStreams extends Generic { + name?: string | string[]; +} + export interface IndicesGetFieldMapping extends Generic { fields: string | string[]; index?: string | string[]; diff --git a/docs/reference.asciidoc b/docs/reference.asciidoc index 0a49cab42..4dc60c406 100644 --- a/docs/reference.asciidoc +++ b/docs/reference.asciidoc @@ -2445,6 +2445,26 @@ link:{ref}/indices-create-index.html[Documentation] + |=== +=== indices.createDataStream +*Stability:* experimental +[source,ts] +---- +client.indices.createDataStream({ + name: string, + body: object +}) +---- +link:{ref}/data-streams.html[Documentation] + +[cols=2*] +|=== +|`name` +|`string` - The name of the data stream + +|`body` +|`object` - The data stream definition + +|=== + === indices.delete [source,ts] @@ -2510,6 +2530,22 @@ link:{ref}/indices-aliases.html[Documentation] + |=== +=== indices.deleteDataStream +*Stability:* experimental +[source,ts] +---- +client.indices.deleteDataStream({ + name: string +}) +---- +link:{ref}/data-streams.html[Documentation] + +[cols=2*] +|=== +|`name` +|`string` - The name of the data stream + +|=== + === indices.deleteTemplate [source,ts] @@ -2837,6 +2873,22 @@ _Default:_ `all` |=== +=== indices.getDataStreams +*Stability:* experimental +[source,ts] +---- +client.indices.getDataStreams({ + name: string | string[] +}) +---- +link:{ref}/data-streams.html[Documentation] + +[cols=2*] +|=== +|`name` +|`string \| string[]` - The comma separated names of data streams + +|=== + === indices.getFieldMapping [source,ts] diff --git a/index.d.ts b/index.d.ts index 11043c8b2..fa8cf44d6 100644 --- a/index.d.ts +++ b/index.d.ts @@ -315,9 +315,13 @@ declare class Client extends EventEmitter { clone: ApiMethod close: ApiMethod create: ApiMethod + create_data_stream: ApiMethod + createDataStream: ApiMethod delete: ApiMethod delete_alias: ApiMethod deleteAlias: ApiMethod + delete_data_stream: ApiMethod + deleteDataStream: ApiMethod delete_template: ApiMethod deleteTemplate: ApiMethod exists: ApiMethod @@ -333,6 +337,8 @@ declare class Client extends EventEmitter { get: ApiMethod get_alias: ApiMethod getAlias: ApiMethod + get_data_streams: ApiMethod + getDataStreams: ApiMethod get_field_mapping: ApiMethod getFieldMapping: ApiMethod get_mapping: ApiMethod