API generation

This commit is contained in:
delvedor
2020-01-31 15:27:34 +01:00
parent 5f1edbb199
commit ebb96e95bf
14 changed files with 229 additions and 71 deletions

84
api/api/cat.ml.jobs.js Normal file
View File

@ -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

View File

@ -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

View File

@ -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 = {

View File

@ -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 = {

View File

@ -16,7 +16,8 @@ function buildMlGetTrainedModels (opts) {
'include_model_definition',
'decompress_definition',
'from',
'size'
'size',
'tags'
]
const snakeCase = {

View File

@ -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 || {}

View File

@ -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 || {}

View File

@ -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 || {}

View File

@ -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 || {}

View File

@ -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 || {}

View File

@ -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),

View File

@ -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<T = any> extends Generic {
export interface EnrichStats extends Generic {
}
export interface EqlSearch<T = any> extends Generic {
index: string;
body: T;
}
export interface GraphExplore<T = any> 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 {

View File

@ -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
|===

8
index.d.ts vendored
View File

@ -125,6 +125,9 @@ declare class Client extends EventEmitter {
help: ApiMethod<RequestParams.CatHelp>
indices: ApiMethod<RequestParams.CatIndices>
master: ApiMethod<RequestParams.CatMaster>
ml: {
jobs: ApiMethod<RequestParams.CatMlJobs>
}
nodeattrs: ApiMethod<RequestParams.CatNodeattrs>
nodes: ApiMethod<RequestParams.CatNodes>
pending_tasks: ApiMethod<RequestParams.CatPendingTasks>
@ -239,6 +242,9 @@ declare class Client extends EventEmitter {
putPolicy: ApiMethod<RequestParams.EnrichPutPolicy>
stats: ApiMethod<RequestParams.EnrichStats>
}
eql: {
search: ApiMethod<RequestParams.EqlSearch>
}
exists: ApiMethod<RequestParams.Exists>
exists_source: ApiMethod<RequestParams.ExistsSource>
existsSource: ApiMethod<RequestParams.ExistsSource>
@ -297,8 +303,6 @@ declare class Client extends EventEmitter {
exists_type: ApiMethod<RequestParams.IndicesExistsType>
existsType: ApiMethod<RequestParams.IndicesExistsType>
flush: ApiMethod<RequestParams.IndicesFlush>
flush_synced: ApiMethod<RequestParams.IndicesFlushSynced>
flushSynced: ApiMethod<RequestParams.IndicesFlushSynced>
forcemerge: ApiMethod<RequestParams.IndicesForcemerge>
freeze: ApiMethod<RequestParams.IndicesFreeze>
get: ApiMethod<RequestParams.IndicesGet>