API generation

This commit is contained in:
delvedor
2020-03-18 15:05:03 +01:00
parent f1fcf4746d
commit 7e51d4cd8c
8 changed files with 528 additions and 0 deletions

View File

@ -0,0 +1,86 @@
// 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 buildClusterDeleteComponentTemplate (opts) {
// eslint-disable-next-line no-unused-vars
const { makeRequest, ConfigurationError, handleError, snakeCaseKeys } = opts
const acceptedQuerystring = [
'timeout',
'master_timeout',
'pretty',
'human',
'error_trace',
'source',
'filter_path'
]
const snakeCase = {
masterTimeout: 'master_timeout',
errorTrace: 'error_trace',
filterPath: 'filter_path'
}
/**
* Perform a cluster.delete_component_template request
* Deletes a component template
* https://www.elastic.co/guide/en/elasticsearch/reference/master/indices-component-templates.html
*/
return function clusterDeleteComponentTemplate (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 = '/' + '_component_template' + '/' + 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 = buildClusterDeleteComponentTemplate

View File

@ -0,0 +1,85 @@
// 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 buildClusterGetComponentTemplate (opts) {
// eslint-disable-next-line no-unused-vars
const { makeRequest, ConfigurationError, handleError, snakeCaseKeys } = opts
const acceptedQuerystring = [
'master_timeout',
'local',
'pretty',
'human',
'error_trace',
'source',
'filter_path'
]
const snakeCase = {
masterTimeout: 'master_timeout',
errorTrace: 'error_trace',
filterPath: 'filter_path'
}
/**
* Perform a cluster.get_component_template request
* Returns one or more component templates
* https://www.elastic.co/guide/en/elasticsearch/reference/master/indices-component-templates.html
*/
return function clusterGetComponentTemplate (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 = '/' + '_component_template' + '/' + encodeURIComponent(name)
} else {
if (method == null) method = 'GET'
path = '/' + '_component_template'
}
// build request object
const request = {
method,
path,
body: null,
querystring
}
options.warnings = warnings.length === 0 ? null : warnings
return makeRequest(request, options, callback)
}
}
module.exports = buildClusterGetComponentTemplate

View File

@ -0,0 +1,91 @@
// 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 buildClusterPutComponentTemplate (opts) {
// eslint-disable-next-line no-unused-vars
const { makeRequest, ConfigurationError, handleError, snakeCaseKeys } = opts
const acceptedQuerystring = [
'create',
'timeout',
'master_timeout',
'pretty',
'human',
'error_trace',
'source',
'filter_path'
]
const snakeCase = {
masterTimeout: 'master_timeout',
errorTrace: 'error_trace',
filterPath: 'filter_path'
}
/**
* Perform a cluster.put_component_template request
* Creates or updates a component template
* https://www.elastic.co/guide/en/elasticsearch/reference/master/indices-component-templates.html
*/
return function clusterPutComponentTemplate (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 = '/' + '_component_template' + '/' + 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 = buildClusterPutComponentTemplate

View File

@ -0,0 +1,85 @@
// 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 buildTransformCatTransform (opts) {
// eslint-disable-next-line no-unused-vars
const { makeRequest, ConfigurationError, handleError, snakeCaseKeys } = opts
const acceptedQuerystring = [
'from',
'size',
'allow_no_match',
'format',
'h',
'help',
's',
'time',
'v'
]
const snakeCase = {
allowNoMatch: 'allow_no_match'
}
/**
* Perform a transform.cat_transform request
* https://www.elastic.co/guide/en/elasticsearch/reference/current/cat-transform.html
*/
return function transformCatTransform (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, transformId, transform_id, ...querystring } = params
querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring, warnings)
var ignore = options.ignore
if (typeof ignore === 'number') {
options.ignore = [ignore]
}
var path = ''
if ((transform_id || transformId) != null) {
if (method == null) method = 'GET'
path = '/' + '_cat' + '/' + 'transform' + '/' + encodeURIComponent(transform_id || transformId)
} else {
if (method == null) method = 'GET'
path = '/' + '_cat' + '/' + 'transform'
}
// build request object
const request = {
method,
path,
body: null,
querystring
}
options.warnings = warnings.length === 0 ? null : warnings
return makeRequest(request, options, callback)
}
}
module.exports = buildTransformCatTransform

View File

@ -93,11 +93,17 @@ function ESAPI (opts) {
cluster: { cluster: {
allocation_explain: lazyLoad('cluster.allocation_explain', opts), allocation_explain: lazyLoad('cluster.allocation_explain', opts),
allocationExplain: lazyLoad('cluster.allocation_explain', opts), allocationExplain: lazyLoad('cluster.allocation_explain', opts),
delete_component_template: lazyLoad('cluster.delete_component_template', opts),
deleteComponentTemplate: lazyLoad('cluster.delete_component_template', opts),
get_component_template: lazyLoad('cluster.get_component_template', opts),
getComponentTemplate: lazyLoad('cluster.get_component_template', opts),
get_settings: lazyLoad('cluster.get_settings', opts), get_settings: lazyLoad('cluster.get_settings', opts),
getSettings: lazyLoad('cluster.get_settings', opts), getSettings: lazyLoad('cluster.get_settings', opts),
health: lazyLoad('cluster.health', opts), health: lazyLoad('cluster.health', opts),
pending_tasks: lazyLoad('cluster.pending_tasks', opts), pending_tasks: lazyLoad('cluster.pending_tasks', opts),
pendingTasks: lazyLoad('cluster.pending_tasks', opts), pendingTasks: lazyLoad('cluster.pending_tasks', opts),
put_component_template: lazyLoad('cluster.put_component_template', opts),
putComponentTemplate: lazyLoad('cluster.put_component_template', opts),
put_settings: lazyLoad('cluster.put_settings', opts), put_settings: lazyLoad('cluster.put_settings', opts),
putSettings: lazyLoad('cluster.put_settings', opts), putSettings: lazyLoad('cluster.put_settings', opts),
remote_info: lazyLoad('cluster.remote_info', opts), remote_info: lazyLoad('cluster.remote_info', opts),
@ -567,6 +573,8 @@ function ESAPI (opts) {
}, },
termvectors: lazyLoad('termvectors', opts), termvectors: lazyLoad('termvectors', opts),
transform: { transform: {
cat_transform: lazyLoad('transform.cat_transform', opts),
catTransform: lazyLoad('transform.cat_transform', opts),
delete_transform: lazyLoad('transform.delete_transform', opts), delete_transform: lazyLoad('transform.delete_transform', opts),
deleteTransform: lazyLoad('transform.delete_transform', opts), deleteTransform: lazyLoad('transform.delete_transform', opts),
get_transform: lazyLoad('transform.get_transform', opts), get_transform: lazyLoad('transform.get_transform', opts),

View File

@ -260,6 +260,18 @@ export interface ClusterAllocationExplain<T = any> extends Generic {
body?: T; body?: T;
} }
export interface ClusterDeleteComponentTemplate extends Generic {
name: string;
timeout?: string;
master_timeout?: string;
}
export interface ClusterGetComponentTemplate extends Generic {
name?: string | string[];
master_timeout?: string;
local?: boolean;
}
export interface ClusterGetSettings extends Generic { export interface ClusterGetSettings extends Generic {
flat_settings?: boolean; flat_settings?: boolean;
master_timeout?: string; master_timeout?: string;
@ -287,6 +299,14 @@ export interface ClusterPendingTasks extends Generic {
master_timeout?: string; master_timeout?: string;
} }
export interface ClusterPutComponentTemplate<T = any> extends Generic {
name: string;
create?: boolean;
timeout?: string;
master_timeout?: string;
body: T;
}
export interface ClusterPutSettings<T = any> extends Generic { export interface ClusterPutSettings<T = any> extends Generic {
flat_settings?: boolean; flat_settings?: boolean;
master_timeout?: string; master_timeout?: string;
@ -2274,6 +2294,19 @@ export interface SqlTranslate<T = any> extends Generic {
export interface SslCertificates extends Generic { export interface SslCertificates extends Generic {
} }
export interface TransformCatTransform extends Generic {
transform_id?: string;
from?: number;
size?: number;
allow_no_match?: boolean;
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 TransformDeleteTransform extends Generic { export interface TransformDeleteTransform extends Generic {
transform_id: string; transform_id: string;
force?: boolean; force?: boolean;

View File

@ -1085,6 +1085,54 @@ link:{ref}/cluster-allocation-explain.html[Documentation] +
|=== |===
=== cluster.deleteComponentTemplate
[source,ts]
----
client.cluster.deleteComponentTemplate({
name: string,
timeout: string,
master_timeout: string
})
----
link:{ref}/indices-component-templates.html[Documentation] +
[cols=2*]
|===
|`name`
|`string` - The name of the template
|`timeout`
|`string` - Explicit operation timeout
|`master_timeout` or `masterTimeout`
|`string` - Specify timeout for connection to master
|===
=== cluster.getComponentTemplate
[source,ts]
----
client.cluster.getComponentTemplate({
name: string | string[],
master_timeout: string,
local: boolean
})
----
link:{ref}/indices-component-templates.html[Documentation] +
[cols=2*]
|===
|`name`
|`string \| string[]` - The comma separated names of the component templates
|`master_timeout` or `masterTimeout`
|`string` - Explicit operation timeout for connection to master node
|`local`
|`boolean` - Return local information, do not retrieve the state from master node (default: false)
|===
=== cluster.getSettings === cluster.getSettings
[source,ts] [source,ts]
@ -1195,6 +1243,38 @@ link:{ref}/cluster-pending.html[Documentation] +
|=== |===
=== cluster.putComponentTemplate
[source,ts]
----
client.cluster.putComponentTemplate({
name: string,
create: boolean,
timeout: string,
master_timeout: string,
body: object
})
----
link:{ref}/indices-component-templates.html[Documentation] +
[cols=2*]
|===
|`name`
|`string` - The name of the template
|`create`
|`boolean` - Whether the index template should only be added if new or can also replace an existing one
|`timeout`
|`string` - Explicit operation timeout
|`master_timeout` or `masterTimeout`
|`string` - Specify timeout for connection to master
|`body`
|`object` - The template definition
|===
=== cluster.putSettings === cluster.putSettings
[source,ts] [source,ts]
@ -9078,6 +9158,58 @@ client.ssl.certificates()
link:{ref}/security-api-ssl.html[Documentation] + link:{ref}/security-api-ssl.html[Documentation] +
=== transform.catTransform
[source,ts]
----
client.transform.catTransform({
transform_id: string,
from: number,
size: number,
allow_no_match: boolean,
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}/cat-transform.html[Documentation] +
[cols=2*]
|===
|`transform_id` or `transformId`
|`string` - The id of the transform for which to get stats. '_all' or '*' implies all transforms
|`from`
|`number` - skips a number of transform configs, defaults to 0
|`size`
|`number` - specifies a max number of transforms to get, defaults to 100
|`allow_no_match` or `allowNoMatch`
|`boolean` - Whether to ignore if a wildcard expression matches no transforms. (This includes `_all` string or when no transforms have been specified)
|`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
|===
=== transform.deleteTransform === transform.deleteTransform
[source,ts] [source,ts]

8
index.d.ts vendored
View File

@ -192,11 +192,17 @@ declare class Client extends EventEmitter {
cluster: { cluster: {
allocation_explain: ApiMethod<RequestParams.ClusterAllocationExplain> allocation_explain: ApiMethod<RequestParams.ClusterAllocationExplain>
allocationExplain: ApiMethod<RequestParams.ClusterAllocationExplain> allocationExplain: ApiMethod<RequestParams.ClusterAllocationExplain>
delete_component_template: ApiMethod<RequestParams.ClusterDeleteComponentTemplate>
deleteComponentTemplate: ApiMethod<RequestParams.ClusterDeleteComponentTemplate>
get_component_template: ApiMethod<RequestParams.ClusterGetComponentTemplate>
getComponentTemplate: ApiMethod<RequestParams.ClusterGetComponentTemplate>
get_settings: ApiMethod<RequestParams.ClusterGetSettings> get_settings: ApiMethod<RequestParams.ClusterGetSettings>
getSettings: ApiMethod<RequestParams.ClusterGetSettings> getSettings: ApiMethod<RequestParams.ClusterGetSettings>
health: ApiMethod<RequestParams.ClusterHealth> health: ApiMethod<RequestParams.ClusterHealth>
pending_tasks: ApiMethod<RequestParams.ClusterPendingTasks> pending_tasks: ApiMethod<RequestParams.ClusterPendingTasks>
pendingTasks: ApiMethod<RequestParams.ClusterPendingTasks> pendingTasks: ApiMethod<RequestParams.ClusterPendingTasks>
put_component_template: ApiMethod<RequestParams.ClusterPutComponentTemplate>
putComponentTemplate: ApiMethod<RequestParams.ClusterPutComponentTemplate>
put_settings: ApiMethod<RequestParams.ClusterPutSettings> put_settings: ApiMethod<RequestParams.ClusterPutSettings>
putSettings: ApiMethod<RequestParams.ClusterPutSettings> putSettings: ApiMethod<RequestParams.ClusterPutSettings>
remote_info: ApiMethod<RequestParams.ClusterRemoteInfo> remote_info: ApiMethod<RequestParams.ClusterRemoteInfo>
@ -666,6 +672,8 @@ declare class Client extends EventEmitter {
} }
termvectors: ApiMethod<RequestParams.Termvectors> termvectors: ApiMethod<RequestParams.Termvectors>
transform: { transform: {
cat_transform: ApiMethod<RequestParams.TransformCatTransform>
catTransform: ApiMethod<RequestParams.TransformCatTransform>
delete_transform: ApiMethod<RequestParams.TransformDeleteTransform> delete_transform: ApiMethod<RequestParams.TransformDeleteTransform>
deleteTransform: ApiMethod<RequestParams.TransformDeleteTransform> deleteTransform: ApiMethod<RequestParams.TransformDeleteTransform>
get_transform: ApiMethod<RequestParams.TransformGetTransform> get_transform: ApiMethod<RequestParams.TransformGetTransform>