From ebb96e95bf51665649db9eecb415bd5c779c4d47 Mon Sep 17 00:00:00 2001 From: delvedor Date: Fri, 31 Jan 2020 15:27:34 +0100 Subject: [PATCH] API generation --- api/api/cat.ml.jobs.js | 84 ++++++++++++++++ ...{indices.flush_synced.js => eql.search.js} | 45 ++++----- api/api/indices.get_upgrade.js | 11 +-- api/api/indices.upgrade.js | 11 +-- api/api/ml.get_trained_models.js | 3 +- api/api/slm.delete_lifecycle.js | 2 +- api/api/slm.execute_lifecycle.js | 2 +- api/api/slm.get_lifecycle.js | 2 +- api/api/slm.get_stats.js | 2 +- api/api/slm.put_lifecycle.js | 2 +- api/index.js | 8 +- api/requestParams.d.ts | 25 +++-- docs/reference.asciidoc | 95 ++++++++++++++++--- index.d.ts | 8 +- 14 files changed, 229 insertions(+), 71 deletions(-) create mode 100644 api/api/cat.ml.jobs.js rename api/api/{indices.flush_synced.js => eql.search.js} (60%) diff --git a/api/api/cat.ml.jobs.js b/api/api/cat.ml.jobs.js new file mode 100644 index 000000000..c285cd2e3 --- /dev/null +++ b/api/api/cat.ml.jobs.js @@ -0,0 +1,84 @@ +// 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 buildCatMlJobs (opts) { + // eslint-disable-next-line no-unused-vars + const { makeRequest, ConfigurationError, handleError, snakeCaseKeys } = opts + + const acceptedQuerystring = [ + 'allow_no_jobs', + 'bytes', + 'format', + 'h', + 'help', + 's', + 'time', + 'v' + ] + + const snakeCase = { + allowNoJobs: 'allow_no_jobs' + + } + + /** + * Perform a cat.ml.jobs request + * http://www.elastic.co/guide/en/elasticsearch/reference/current/ml-get-job-stats.html + */ + return function catMlJobs (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, jobId, job_id, ...querystring } = params + querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring, warnings) + + var ignore = options.ignore + if (typeof ignore === 'number') { + options.ignore = [ignore] + } + + var path = '' + + if ((job_id || jobId) != null) { + if (method == null) method = 'GET' + path = '/' + '_cat' + '/' + 'ml' + '/' + 'anomaly_detectors' + '/' + encodeURIComponent(job_id || jobId) + } else { + if (method == null) method = 'GET' + path = '/' + '_cat' + '/' + 'ml' + '/' + 'anomaly_detectors' + } + + // build request object + const request = { + method, + path, + body: null, + querystring + } + + options.warnings = warnings.length === 0 ? null : warnings + return makeRequest(request, options, callback) + } +} + +module.exports = buildCatMlJobs diff --git a/api/api/indices.flush_synced.js b/api/api/eql.search.js similarity index 60% rename from api/api/indices.flush_synced.js rename to api/api/eql.search.js index bd0ea4d70..e6ae5fe29 100644 --- a/api/api/indices.flush_synced.js +++ b/api/api/eql.search.js @@ -7,35 +7,23 @@ /* eslint camelcase: 0 */ /* eslint no-unused-vars: 0 */ -function buildIndicesFlushSynced (opts) { +function buildEqlSearch (opts) { // eslint-disable-next-line no-unused-vars const { makeRequest, ConfigurationError, handleError, snakeCaseKeys } = opts const acceptedQuerystring = [ - 'ignore_unavailable', - 'allow_no_indices', - 'expand_wildcards', - 'pretty', - 'human', - 'error_trace', - 'source', - 'filter_path' + ] const snakeCase = { - ignoreUnavailable: 'ignore_unavailable', - allowNoIndices: 'allow_no_indices', - expandWildcards: 'expand_wildcards', - errorTrace: 'error_trace', - filterPath: 'filter_path' + } /** - * Perform a indices.flush_synced request - * Performs a synced flush operation on one or more indices. - * https://www.elastic.co/guide/en/elasticsearch/reference/master/indices-synced-flush-api.html + * Perform a eql.search request + * https://www.elastic.co/guide/en/elasticsearch/reference/current/eql-search.html */ - return function indicesFlushSynced (params, options, callback) { + return function eqlSearch (params, options, callback) { options = options || {} if (typeof options === 'function') { callback = options @@ -47,6 +35,16 @@ function buildIndicesFlushSynced (opts) { options = {} } + // check required parameters + if (params['index'] == null) { + const err = new ConfigurationError('Missing required parameter: index') + 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}`) @@ -64,13 +62,8 @@ function buildIndicesFlushSynced (opts) { var path = '' - if ((index) != null) { - if (method == null) method = body == null ? 'GET' : 'POST' - path = '/' + encodeURIComponent(index) + '/' + '_flush' + '/' + 'synced' - } else { - if (method == null) method = body == null ? 'GET' : 'POST' - path = '/' + '_flush' + '/' + 'synced' - } + if (method == null) method = body == null ? 'GET' : 'POST' + path = '/' + encodeURIComponent(index) + '/' + '_eql' + '/' + 'search' // build request object const request = { @@ -85,4 +78,4 @@ function buildIndicesFlushSynced (opts) { } } -module.exports = buildIndicesFlushSynced +module.exports = buildEqlSearch diff --git a/api/api/indices.get_upgrade.js b/api/api/indices.get_upgrade.js index b4a028ceb..13598cfe1 100644 --- a/api/api/indices.get_upgrade.js +++ b/api/api/indices.get_upgrade.js @@ -32,7 +32,7 @@ function buildIndicesGetUpgrade (opts) { /** * Perform a indices.get_upgrade request - * The _upgrade API is no longer useful and will be removed. + * DEPRECATED Returns a progress status of current upgrade. * https://www.elastic.co/guide/en/elasticsearch/reference/master/indices-upgrade.html */ return function indicesGetUpgrade (params, options, callback) { @@ -64,13 +64,8 @@ function buildIndicesGetUpgrade (opts) { var path = '' - if ((index) != null) { - if (method == null) method = 'GET' - path = '/' + encodeURIComponent(index) + '/' + '_upgrade' - } else { - if (method == null) method = 'GET' - path = '/' + '_upgrade' - } + if (method == null) method = 'GET' + path = '/' + encodeURIComponent(index) + '/' + '_upgrade' // build request object const request = { diff --git a/api/api/indices.upgrade.js b/api/api/indices.upgrade.js index b11d060a8..09a366e93 100644 --- a/api/api/indices.upgrade.js +++ b/api/api/indices.upgrade.js @@ -36,7 +36,7 @@ function buildIndicesUpgrade (opts) { /** * Perform a indices.upgrade request - * The _upgrade API is no longer useful and will be removed. + * DEPRECATED Upgrades to the current version of Lucene. * https://www.elastic.co/guide/en/elasticsearch/reference/master/indices-upgrade.html */ return function indicesUpgrade (params, options, callback) { @@ -68,13 +68,8 @@ function buildIndicesUpgrade (opts) { var path = '' - if ((index) != null) { - if (method == null) method = 'POST' - path = '/' + encodeURIComponent(index) + '/' + '_upgrade' - } else { - if (method == null) method = 'POST' - path = '/' + '_upgrade' - } + if (method == null) method = 'POST' + path = '/' + encodeURIComponent(index) + '/' + '_upgrade' // build request object const request = { diff --git a/api/api/ml.get_trained_models.js b/api/api/ml.get_trained_models.js index e369d43a7..2d89b9cb4 100644 --- a/api/api/ml.get_trained_models.js +++ b/api/api/ml.get_trained_models.js @@ -16,7 +16,8 @@ function buildMlGetTrainedModels (opts) { 'include_model_definition', 'decompress_definition', 'from', - 'size' + 'size', + 'tags' ] const snakeCase = { diff --git a/api/api/slm.delete_lifecycle.js b/api/api/slm.delete_lifecycle.js index d91d346c5..06eee754e 100644 --- a/api/api/slm.delete_lifecycle.js +++ b/api/api/slm.delete_lifecycle.js @@ -21,7 +21,7 @@ function buildSlmDeleteLifecycle (opts) { /** * Perform a slm.delete_lifecycle request - * https://www.elastic.co/guide/en/elasticsearch/reference/current/slm-api-delete.html + * https://www.elastic.co/guide/en/elasticsearch/reference/current/slm-api-delete-policy.html */ return function slmDeleteLifecycle (params, options, callback) { options = options || {} diff --git a/api/api/slm.execute_lifecycle.js b/api/api/slm.execute_lifecycle.js index 0cf464486..b693e53c6 100644 --- a/api/api/slm.execute_lifecycle.js +++ b/api/api/slm.execute_lifecycle.js @@ -21,7 +21,7 @@ function buildSlmExecuteLifecycle (opts) { /** * Perform a slm.execute_lifecycle request - * https://www.elastic.co/guide/en/elasticsearch/reference/current/slm-api-execute.html + * https://www.elastic.co/guide/en/elasticsearch/reference/current/slm-api-execute-policy.html */ return function slmExecuteLifecycle (params, options, callback) { options = options || {} diff --git a/api/api/slm.get_lifecycle.js b/api/api/slm.get_lifecycle.js index 32d03c2f8..2d93aad89 100644 --- a/api/api/slm.get_lifecycle.js +++ b/api/api/slm.get_lifecycle.js @@ -21,7 +21,7 @@ function buildSlmGetLifecycle (opts) { /** * Perform a slm.get_lifecycle request - * https://www.elastic.co/guide/en/elasticsearch/reference/current/slm-api-get.html + * https://www.elastic.co/guide/en/elasticsearch/reference/current/slm-api-get-policy.html */ return function slmGetLifecycle (params, options, callback) { options = options || {} diff --git a/api/api/slm.get_stats.js b/api/api/slm.get_stats.js index 07369f451..2d9a6a1d6 100644 --- a/api/api/slm.get_stats.js +++ b/api/api/slm.get_stats.js @@ -21,7 +21,7 @@ function buildSlmGetStats (opts) { /** * Perform a slm.get_stats request - * https://www.elastic.co/guide/en/elasticsearch/reference/master/slm-get-stats.html + * https://www.elastic.co/guide/en/elasticsearch/reference/master/slm-api-get-stats.html */ return function slmGetStats (params, options, callback) { options = options || {} diff --git a/api/api/slm.put_lifecycle.js b/api/api/slm.put_lifecycle.js index 4d59ebad5..c8091a7dc 100644 --- a/api/api/slm.put_lifecycle.js +++ b/api/api/slm.put_lifecycle.js @@ -21,7 +21,7 @@ function buildSlmPutLifecycle (opts) { /** * Perform a slm.put_lifecycle request - * https://www.elastic.co/guide/en/elasticsearch/reference/current/slm-api-put.html + * https://www.elastic.co/guide/en/elasticsearch/reference/current/slm-api-put-policy.html */ return function slmPutLifecycle (params, options, callback) { options = options || {} diff --git a/api/index.js b/api/index.js index 4f936cf8b..eb53c2c9d 100644 --- a/api/index.js +++ b/api/index.js @@ -26,6 +26,9 @@ function ESAPI (opts) { help: lazyLoad('cat.help', opts), indices: lazyLoad('cat.indices', opts), master: lazyLoad('cat.master', opts), + ml: { + jobs: lazyLoad('cat.ml.jobs', opts) + }, nodeattrs: lazyLoad('cat.nodeattrs', opts), nodes: lazyLoad('cat.nodes', opts), pending_tasks: lazyLoad('cat.pending_tasks', opts), @@ -140,6 +143,9 @@ function ESAPI (opts) { putPolicy: lazyLoad('enrich.put_policy', opts), stats: lazyLoad('enrich.stats', opts) }, + eql: { + search: lazyLoad('eql.search', opts) + }, exists: lazyLoad('exists', opts), exists_source: lazyLoad('exists_source', opts), existsSource: lazyLoad('exists_source', opts), @@ -198,8 +204,6 @@ function ESAPI (opts) { exists_type: lazyLoad('indices.exists_type', opts), existsType: lazyLoad('indices.exists_type', opts), flush: lazyLoad('indices.flush', opts), - flush_synced: lazyLoad('indices.flush_synced', opts), - flushSynced: lazyLoad('indices.flush_synced', opts), forcemerge: lazyLoad('indices.forcemerge', opts), freeze: lazyLoad('indices.freeze', opts), get: lazyLoad('indices.get', opts), diff --git a/api/requestParams.d.ts b/api/requestParams.d.ts index e7dcb111c..23f73cb2f 100644 --- a/api/requestParams.d.ts +++ b/api/requestParams.d.ts @@ -653,13 +653,6 @@ export interface IndicesFlush extends Generic { expand_wildcards?: 'open' | 'closed' | 'none' | 'all'; } -export interface IndicesFlushSynced extends Generic { - index?: string | string[]; - ignore_unavailable?: boolean; - allow_no_indices?: boolean; - expand_wildcards?: 'open' | 'closed' | 'none' | 'all'; -} - export interface IndicesForcemerge extends Generic { index?: string | string[]; flush?: boolean; @@ -1322,6 +1315,18 @@ export interface UpdateByQueryRethrottle extends Generic { requests_per_second: number; } +export interface CatMlJobs extends Generic { + job_id?: string; + allow_no_jobs?: boolean; + bytes?: 'b' | 'k' | 'kb' | 'm' | 'mb' | 'g' | 'gb' | 't' | 'tb' | 'p' | 'pb'; + format?: string; + h?: string | string[]; + help?: boolean; + s?: string | string[]; + time?: 'd (Days)' | 'h (Hours)' | 'm (Minutes)' | 's (Seconds)' | 'ms (Milliseconds)' | 'micros (Microseconds)' | 'nanos (Nanoseconds)'; + v?: boolean; +} + export interface CcrDeleteAutoFollowPattern extends Generic { name: string; } @@ -1446,6 +1451,11 @@ export interface EnrichPutPolicy extends Generic { export interface EnrichStats extends Generic { } +export interface EqlSearch extends Generic { + index: string; + body: T; +} + export interface GraphExplore extends Generic { index: string | string[]; routing?: string; @@ -1793,6 +1803,7 @@ export interface MlGetTrainedModels extends Generic { decompress_definition?: boolean; from?: number; size?: number; + tags?: string | string[]; } export interface MlGetTrainedModelsStats extends Generic { diff --git a/docs/reference.asciidoc b/docs/reference.asciidoc index cc0c8a5ad..0c5ca4d69 100644 --- a/docs/reference.asciidoc +++ b/docs/reference.asciidoc @@ -126,7 +126,7 @@ link:{ref}/docs-bulk.html[Reference] |`string` - Sets the number of shard copies that must be active before proceeding with the bulk operation. Defaults to 1, meaning the primary shard only. Set to `all` for all shard copies, otherwise set to any non-negative value less than or equal to the total number of copies for the shard (number of replicas + 1) |`refresh` -|`'true' \| 'false' \| 'wait_for'` - If `true` then refresh the effected shards to make this operation visible to search, if `wait_for` then wait for a refresh to make this operation visible to search, if `false` (the default) then do nothing with refreshes. +|`'true' \| 'false' \| 'wait_for'` - If `true` then refresh the affected shards to make this operation visible to search, if `wait_for` then wait for a refresh to make this operation visible to search, if `false` (the default) then do nothing with refreshes. |`routing` |`string` - Specific routing value @@ -1510,7 +1510,7 @@ WARNING: This parameter has been deprecated. |`string` - Sets the number of shard copies that must be active before proceeding with the delete operation. Defaults to 1, meaning the primary shard only. Set to `all` for all shard copies, otherwise set to any non-negative value less than or equal to the total number of copies for the shard (number of replicas + 1) |`refresh` -|`'true' \| 'false' \| 'wait_for'` - If `true` then refresh the effected shards to make this operation visible to search, if `wait_for` then wait for a refresh to make this operation visible to search, if `false` (the default) then do nothing with refreshes. +|`'true' \| 'false' \| 'wait_for'` - If `true` then refresh the affected shards to make this operation visible to search, if `wait_for` then wait for a refresh to make this operation visible to search, if `false` (the default) then do nothing with refreshes. |`routing` |`string` - Specific routing value @@ -1658,7 +1658,7 @@ _Default:_ `open` |`boolean` - Specify if request cache should be used for this request or not, defaults to index level setting |`refresh` -|`boolean` - Should the effected indexes be refreshed? +|`boolean` - Should the affected indexes be refreshed? |`timeout` |`string` - Time each individual bulk request should wait for shards that are unavailable. + @@ -4159,7 +4159,7 @@ link:{ref}/docs-reindex.html[Reference] [cols=2*] |=== |`refresh` -|`boolean` - Should the effected indexes be refreshed? +|`boolean` - Should the affected indexes be refreshed? |`timeout` |`string` - Time each individual bulk request should wait for shards that are unavailable. + @@ -5085,7 +5085,7 @@ WARNING: This parameter has been deprecated. |`string` - The script language (default: painless) |`refresh` -|`'true' \| 'false' \| 'wait_for'` - If `true` then refresh the effected shards to make this operation visible to search, if `wait_for` then wait for a refresh to make this operation visible to search, if `false` (the default) then do nothing with refreshes. +|`'true' \| 'false' \| 'wait_for'` - If `true` then refresh the affected shards to make this operation visible to search, if `wait_for` then wait for a refresh to make this operation visible to search, if `false` (the default) then do nothing with refreshes. |`retry_on_conflict` or `retryOnConflict` |`number` - Specify how many times should the operation be retried when a conflict occurs (default: 0) @@ -5241,7 +5241,7 @@ _Default:_ `open` |`boolean` - Specify if request cache should be used for this request or not, defaults to index level setting |`refresh` -|`boolean` - Should the effected indexes be refreshed? +|`boolean` - Should the affected indexes be refreshed? |`timeout` |`string` - Time each individual bulk request should wait for shards that are unavailable. + @@ -5289,6 +5289,54 @@ link:{ref}/docs-update-by-query.html[Reference] |=== +=== cat.ml.jobs + +[source,ts] +---- +client.cat.ml.jobs({ + job_id: string, + allow_no_jobs: boolean, + bytes: 'b' | 'k' | 'kb' | 'm' | 'mb' | 'g' | 'gb' | 't' | 'tb' | 'p' | 'pb', + format: string, + h: string | string[], + help: boolean, + s: string | string[], + time: 'd (Days)' | 'h (Hours)' | 'm (Minutes)' | 's (Seconds)' | 'ms (Milliseconds)' | 'micros (Microseconds)' | 'nanos (Nanoseconds)', + v: boolean +}) +---- +link:{ref}/ml-get-job-stats.html[Reference] +[cols=2*] +|=== +|`job_id` or `jobId` +|`string` - The ID of the jobs stats to fetch + +|`allow_no_jobs` or `allowNoJobs` +|`boolean` - Whether to ignore if a wildcard expression matches no jobs. (This includes `_all` string or when no jobs have been specified) + +|`bytes` +|`'b' \| 'k' \| 'kb' \| 'm' \| 'mb' \| 'g' \| 'gb' \| 't' \| 'tb' \| 'p' \| 'pb'` - The unit in which to display byte values + +|`format` +|`string` - a short version of the Accept header, e.g. json, yaml + +|`h` +|`string \| string[]` - Comma-separated list of column names to display + +|`help` +|`boolean` - Return help information + +|`s` +|`string \| string[]` - Comma-separated list of column names or column aliases to sort by + +|`time` +|`'d (Days)' \| 'h (Hours)' \| 'm (Minutes)' \| 's (Seconds)' \| 'ms (Milliseconds)' \| 'micros (Microseconds)' \| 'nanos (Nanoseconds)'` - The unit in which to display time values + +|`v` +|`boolean` - Verbose mode. Display column headers + +|=== + === ccr.deleteAutoFollowPattern [source,ts] @@ -5776,6 +5824,26 @@ client.enrich.stats() ---- +=== eql.search +*Stability:* beta +[source,ts] +---- +client.eql.search({ + index: string, + body: object +}) +---- +link:{ref}/eql-search.html[Reference] +[cols=2*] +|=== +|`index` +|`string` - The name of the index to scope the operation + +|`body` +|`object` - Eql request body. Use the `query` to limit the query scope. + +|=== + === graph.explore [source,ts] @@ -7129,7 +7197,8 @@ client.ml.getTrainedModels({ include_model_definition: boolean, decompress_definition: boolean, from: number, - size: number + size: number, + tags: string | string[] }) ---- link:{ref}/get-inference.html[Reference] @@ -7156,6 +7225,9 @@ _Default:_ `true` |`number` - specifies a max number of trained models to get + _Default:_ `100` +|`tags` +|`string \| string[]` - A comma-separated list of tags that the model must have. + |=== === ml.getTrainedModelsStats @@ -8388,7 +8460,7 @@ client.slm.executeLifecycle({ policy_id: string }) ---- -link:{ref}/slm-api-execute-lifecycle.html[Reference] +link:{ref}/slm-api-execute-policy.html[Reference] [cols=2*] |=== |`policy_id` or `policyId` @@ -8436,7 +8508,7 @@ link:{ref}/slm-api-get-stats.html[Reference] ---- client.slm.getStatus() ---- -link:{ref}/slm-api-get-status.html[Reference] +link:{ref}/slm-get-status.html[Reference] === slm.putLifecycle @@ -8465,7 +8537,7 @@ link:{ref}/slm-api-put-policy.html[Reference] ---- client.slm.start() ---- -link:{ref}/slm-api-start.html[Reference] +link:{ref}/slm-start.html[Reference] === slm.stop @@ -8474,7 +8546,7 @@ link:{ref}/slm-api-start.html[Reference] ---- client.slm.stop() ---- -link:{ref}/slm-api-stop.html[Reference] +link:{ref}/slm-stop.html[Reference] === sql.clearCursor @@ -8947,4 +9019,3 @@ link:Retrieve information about xpack features usage[Reference] |`string` - Specify timeout for watch write operation |=== - diff --git a/index.d.ts b/index.d.ts index e3c1c2ef5..4ecff10ca 100644 --- a/index.d.ts +++ b/index.d.ts @@ -125,6 +125,9 @@ declare class Client extends EventEmitter { help: ApiMethod indices: ApiMethod master: ApiMethod + ml: { + jobs: ApiMethod + } nodeattrs: ApiMethod nodes: ApiMethod pending_tasks: ApiMethod @@ -239,6 +242,9 @@ declare class Client extends EventEmitter { putPolicy: ApiMethod stats: ApiMethod } + eql: { + search: ApiMethod + } exists: ApiMethod exists_source: ApiMethod existsSource: ApiMethod @@ -297,8 +303,6 @@ declare class Client extends EventEmitter { exists_type: ApiMethod existsType: ApiMethod flush: ApiMethod - flush_synced: ApiMethod - flushSynced: ApiMethod forcemerge: ApiMethod freeze: ApiMethod get: ApiMethod