API generation

This commit is contained in:
delvedor
2019-12-13 09:03:01 +01:00
parent a174ea4721
commit e2ba0634bf
9 changed files with 363 additions and 7 deletions

View File

@ -0,0 +1,76 @@
// 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 buildGetScriptLanguages (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 get_script_languages request
* Returns available script types, languages and contexts
*/
return function getScriptLanguages (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, ...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 = 'GET'
path = '/' + '_script_language'
// build request object
const request = {
method,
path,
body: null,
querystring
}
options.warnings = warnings.length === 0 ? null : warnings
return makeRequest(request, options, callback)
}
}
module.exports = buildGetScriptLanguages

View File

@ -12,11 +12,12 @@ function buildLicenseGet (opts) {
const { makeRequest, ConfigurationError, handleError, snakeCaseKeys } = opts
const acceptedQuerystring = [
'local'
'local',
'accept_enterprise'
]
const snakeCase = {
acceptEnterprise: 'accept_enterprise'
}
/**

71
api/api/slm.get_status.js Normal file
View File

@ -0,0 +1,71 @@
// 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 buildSlmGetStatus (opts) {
// eslint-disable-next-line no-unused-vars
const { makeRequest, ConfigurationError, handleError, snakeCaseKeys } = opts
const acceptedQuerystring = [
]
const snakeCase = {
}
/**
* Perform a slm.get_status request
* https://www.elastic.co/guide/en/elasticsearch/reference/current/slm-get-status.html
*/
return function slmGetStatus (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, ...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 = 'GET'
path = '/' + '_slm' + '/' + 'status'
// build request object
const request = {
method,
path,
body: null,
querystring
}
options.warnings = warnings.length === 0 ? null : warnings
return makeRequest(request, options, callback)
}
}
module.exports = buildSlmGetStatus

71
api/api/slm.start.js Normal file
View File

@ -0,0 +1,71 @@
// 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 buildSlmStart (opts) {
// eslint-disable-next-line no-unused-vars
const { makeRequest, ConfigurationError, handleError, snakeCaseKeys } = opts
const acceptedQuerystring = [
]
const snakeCase = {
}
/**
* Perform a slm.start request
* https://www.elastic.co/guide/en/elasticsearch/reference/current/slm-start.html
*/
return function slmStart (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, ...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 = 'POST'
path = '/' + '_slm' + '/' + 'start'
// build request object
const request = {
method,
path,
body: body || '',
querystring
}
options.warnings = warnings.length === 0 ? null : warnings
return makeRequest(request, options, callback)
}
}
module.exports = buildSlmStart

71
api/api/slm.stop.js Normal file
View File

@ -0,0 +1,71 @@
// 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 buildSlmStop (opts) {
// eslint-disable-next-line no-unused-vars
const { makeRequest, ConfigurationError, handleError, snakeCaseKeys } = opts
const acceptedQuerystring = [
]
const snakeCase = {
}
/**
* Perform a slm.stop request
* https://www.elastic.co/guide/en/elasticsearch/reference/current/slm-stop.html
*/
return function slmStop (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, ...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 = 'POST'
path = '/' + '_slm' + '/' + 'stop'
// build request object
const request = {
method,
path,
body: body || '',
querystring
}
options.warnings = warnings.length === 0 ? null : warnings
return makeRequest(request, options, callback)
}
}
module.exports = buildSlmStop

View File

@ -151,6 +151,8 @@ function ESAPI (opts) {
getScript: lazyLoad('get_script', opts),
get_script_context: lazyLoad('get_script_context', opts),
getScriptContext: lazyLoad('get_script_context', opts),
get_script_languages: lazyLoad('get_script_languages', opts),
getScriptLanguages: lazyLoad('get_script_languages', opts),
get_source: lazyLoad('get_source', opts),
getSource: lazyLoad('get_source', opts),
graph: {
@ -498,8 +500,12 @@ function ESAPI (opts) {
getLifecycle: lazyLoad('slm.get_lifecycle', opts),
get_stats: lazyLoad('slm.get_stats', opts),
getStats: lazyLoad('slm.get_stats', opts),
get_status: lazyLoad('slm.get_status', opts),
getStatus: lazyLoad('slm.get_status', opts),
put_lifecycle: lazyLoad('slm.put_lifecycle', opts),
putLifecycle: lazyLoad('slm.put_lifecycle', opts)
putLifecycle: lazyLoad('slm.put_lifecycle', opts),
start: lazyLoad('slm.start', opts),
stop: lazyLoad('slm.stop', opts)
},
snapshot: {
cleanup_repository: lazyLoad('snapshot.cleanup_repository', opts),

View File

@ -87,7 +87,7 @@ export interface CatHelp extends Generic {
export interface CatIndices extends Generic {
index?: string | string[];
format?: string;
bytes?: 'b' | 'k' | 'm' | 'g';
bytes?: 'b' | 'k' | 'kb' | 'm' | 'mb' | 'g' | 'gb' | 't' | 'tb' | 'p' | 'pb';
local?: boolean;
master_timeout?: string;
h?: string | string[];
@ -510,6 +510,9 @@ export interface GetScript extends Generic {
export interface GetScriptContext extends Generic {
}
export interface GetScriptLanguages extends Generic {
}
export interface GetSource extends Generic {
id: string;
index: string;
@ -1524,6 +1527,7 @@ export interface LicenseDelete extends Generic {
export interface LicenseGet extends Generic {
local?: boolean;
accept_enterprise?: boolean;
}
export interface LicenseGetBasicStatus extends Generic {
@ -2110,11 +2114,20 @@ export interface SlmGetLifecycle extends Generic {
export interface SlmGetStats extends Generic {
}
export interface SlmGetStatus extends Generic {
}
export interface SlmPutLifecycle<T = any> extends Generic {
policy_id: string;
body?: T;
}
export interface SlmStart extends Generic {
}
export interface SlmStop extends Generic {
}
export interface SqlClearCursor<T = any> extends Generic {
body: T;
}

View File

@ -357,7 +357,7 @@ link:{ref}/cat.html[Reference]
client.cat.indices({
index: string | string[],
format: string,
bytes: 'b' | 'k' | 'm' | 'g',
bytes: 'b' | 'k' | 'kb' | 'm' | 'mb' | 'g' | 'gb' | 't' | 'tb' | 'p' | 'pb',
local: boolean,
master_timeout: string,
h: string | string[],
@ -380,7 +380,7 @@ link:{ref}/cat-indices.html[Reference]
|`string` - a short version of the Accept header, e.g. json, yaml
|`bytes`
|`'b' \| 'k' \| 'm' \| 'g'` - The unit in which to display byte values
|`'b' \| 'k' \| 'kb' \| 'm' \| 'mb' \| 'g' \| 'gb' \| 't' \| 'tb' \| 'p' \| 'pb'` - The unit in which to display byte values
|`local`
|`boolean` - Return local information, do not retrieve the state from master node (default: false)
@ -2028,6 +2028,14 @@ client.getScriptContext()
----
=== getScriptLanguages
*Stability:* experimental
[source,ts]
----
client.getScriptLanguages()
----
=== getSource
[source,ts]
@ -6083,7 +6091,8 @@ link:{ref}/delete-license.html[Reference]
[source,ts]
----
client.license.get({
local: boolean
local: boolean,
accept_enterprise: boolean
})
----
link:{ref}/get-license.html[Reference]
@ -6092,6 +6101,11 @@ link:{ref}/get-license.html[Reference]
|`local`
|`boolean` - Return local information, do not retrieve the state from master node (default: false)
|`accept_enterprise` or `acceptEnterprise`
|`boolean` - Supported for backwards compatibility with 7.x. If this param is used it must be set to true +
WARNING: This parameter has been deprecated.
|===
=== license.getBasicStatus
@ -8394,6 +8408,15 @@ client.slm.getStats()
link:{ref}/slm-get-stats.html[Reference]
=== slm.getStatus
[source,ts]
----
client.slm.getStatus()
----
link:{ref}/slm-get-status.html[Reference]
=== slm.putLifecycle
[source,ts]
@ -8414,6 +8437,24 @@ link:{ref}/slm-api-put.html[Reference]
|===
=== slm.start
[source,ts]
----
client.slm.start()
----
link:{ref}/slm-start.html[Reference]
=== slm.stop
[source,ts]
----
client.slm.stop()
----
link:{ref}/slm-stop.html[Reference]
=== sql.clearCursor
[source,ts]

6
index.d.ts vendored
View File

@ -250,6 +250,8 @@ declare class Client extends EventEmitter {
getScript: ApiMethod<RequestParams.GetScript>
get_script_context: ApiMethod<RequestParams.GetScriptContext>
getScriptContext: ApiMethod<RequestParams.GetScriptContext>
get_script_languages: ApiMethod<RequestParams.GetScriptLanguages>
getScriptLanguages: ApiMethod<RequestParams.GetScriptLanguages>
get_source: ApiMethod<RequestParams.GetSource>
getSource: ApiMethod<RequestParams.GetSource>
graph: {
@ -597,8 +599,12 @@ declare class Client extends EventEmitter {
getLifecycle: ApiMethod<RequestParams.SlmGetLifecycle>
get_stats: ApiMethod<RequestParams.SlmGetStats>
getStats: ApiMethod<RequestParams.SlmGetStats>
get_status: ApiMethod<RequestParams.SlmGetStatus>
getStatus: ApiMethod<RequestParams.SlmGetStatus>
put_lifecycle: ApiMethod<RequestParams.SlmPutLifecycle>
putLifecycle: ApiMethod<RequestParams.SlmPutLifecycle>
start: ApiMethod<RequestParams.SlmStart>
stop: ApiMethod<RequestParams.SlmStop>
}
snapshot: {
cleanup_repository: ApiMethod<RequestParams.SnapshotCleanupRepository>