API generation

This commit is contained in:
delvedor
2019-11-19 19:35:07 +01:00
parent b439b6cb5a
commit f3b044e60c
13 changed files with 348 additions and 42 deletions

View File

@ -12,7 +12,6 @@ function buildIndicesCreate (opts) {
const { makeRequest, ConfigurationError, handleError, snakeCaseKeys } = opts
const acceptedQuerystring = [
'include_type_name',
'wait_for_active_shards',
'timeout',
'master_timeout',
@ -24,7 +23,6 @@ function buildIndicesCreate (opts) {
]
const snakeCase = {
includeTypeName: 'include_type_name',
waitForActiveShards: 'wait_for_active_shards',
masterTimeout: 'master_timeout',
errorTrace: 'error_trace',

View File

@ -12,7 +12,6 @@ function buildIndicesGet (opts) {
const { makeRequest, ConfigurationError, handleError, snakeCaseKeys } = opts
const acceptedQuerystring = [
'include_type_name',
'local',
'ignore_unavailable',
'allow_no_indices',
@ -28,7 +27,6 @@ function buildIndicesGet (opts) {
]
const snakeCase = {
includeTypeName: 'include_type_name',
ignoreUnavailable: 'ignore_unavailable',
allowNoIndices: 'allow_no_indices',
expandWildcards: 'expand_wildcards',

View File

@ -12,7 +12,6 @@ function buildIndicesGetFieldMapping (opts) {
const { makeRequest, ConfigurationError, handleError, snakeCaseKeys } = opts
const acceptedQuerystring = [
'include_type_name',
'include_defaults',
'ignore_unavailable',
'allow_no_indices',
@ -26,7 +25,6 @@ function buildIndicesGetFieldMapping (opts) {
]
const snakeCase = {
includeTypeName: 'include_type_name',
includeDefaults: 'include_defaults',
ignoreUnavailable: 'ignore_unavailable',
allowNoIndices: 'allow_no_indices',

View File

@ -12,7 +12,6 @@ function buildIndicesGetTemplate (opts) {
const { makeRequest, ConfigurationError, handleError, snakeCaseKeys } = opts
const acceptedQuerystring = [
'include_type_name',
'flat_settings',
'master_timeout',
'local',
@ -24,7 +23,6 @@ function buildIndicesGetTemplate (opts) {
]
const snakeCase = {
includeTypeName: 'include_type_name',
flatSettings: 'flat_settings',
masterTimeout: 'master_timeout',
errorTrace: 'error_trace',

View File

@ -12,7 +12,6 @@ function buildIndicesPutTemplate (opts) {
const { makeRequest, ConfigurationError, handleError, snakeCaseKeys } = opts
const acceptedQuerystring = [
'include_type_name',
'order',
'create',
'timeout',
@ -26,7 +25,6 @@ function buildIndicesPutTemplate (opts) {
]
const snakeCase = {
includeTypeName: 'include_type_name',
masterTimeout: 'master_timeout',
flatSettings: 'flat_settings',
errorTrace: 'error_trace',

View File

@ -12,7 +12,6 @@ function buildIndicesRollover (opts) {
const { makeRequest, ConfigurationError, handleError, snakeCaseKeys } = opts
const acceptedQuerystring = [
'include_type_name',
'timeout',
'dry_run',
'master_timeout',
@ -25,7 +24,6 @@ function buildIndicesRollover (opts) {
]
const snakeCase = {
includeTypeName: 'include_type_name',
dryRun: 'dry_run',
masterTimeout: 'master_timeout',
waitForActiveShards: 'wait_for_active_shards',

View File

@ -0,0 +1,77 @@
// 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 buildMlDeleteTrainedModel (opts) {
// eslint-disable-next-line no-unused-vars
const { makeRequest, ConfigurationError, handleError, snakeCaseKeys } = opts
const acceptedQuerystring = [
]
const snakeCase = {
}
/**
* Perform a ml.delete_trained_model request
* TODO
*/
return function mlDeleteTrainedModel (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['model_id'] == null && params['modelId'] == null) {
const err = new ConfigurationError('Missing required parameter: model_id or modelId')
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, modelId, model_id, ...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 = '/' + '_ml' + '/' + 'inference' + '/' + encodeURIComponent(model_id || modelId)
// build request object
const request = {
method,
path,
body: body || '',
querystring
}
options.warnings = warnings.length === 0 ? null : warnings
return makeRequest(request, options, callback)
}
}
module.exports = buildMlDeleteTrainedModel

View File

@ -0,0 +1,81 @@
// 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 buildMlGetTrainedModels (opts) {
// eslint-disable-next-line no-unused-vars
const { makeRequest, ConfigurationError, handleError, snakeCaseKeys } = opts
const acceptedQuerystring = [
'allow_no_match',
'include_model_definition',
'from',
'size'
]
const snakeCase = {
allowNoMatch: 'allow_no_match',
includeModelDefinition: 'include_model_definition'
}
/**
* Perform a ml.get_trained_models request
* TODO
*/
return function mlGetTrainedModels (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, modelId, model_id, ...querystring } = params
querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring, warnings)
var ignore = options.ignore
if (typeof ignore === 'number') {
options.ignore = [ignore]
}
var path = ''
if ((model_id || modelId) != null) {
if (method == null) method = 'GET'
path = '/' + '_ml' + '/' + 'inference' + '/' + encodeURIComponent(model_id || modelId)
} else {
if (method == null) method = 'GET'
path = '/' + '_ml' + '/' + 'inference'
}
// build request object
const request = {
method,
path,
body: null,
querystring
}
options.warnings = warnings.length === 0 ? null : warnings
return makeRequest(request, options, callback)
}
}
module.exports = buildMlGetTrainedModels

View File

@ -0,0 +1,79 @@
// 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 buildMlGetTrainedModelsStats (opts) {
// eslint-disable-next-line no-unused-vars
const { makeRequest, ConfigurationError, handleError, snakeCaseKeys } = opts
const acceptedQuerystring = [
'allow_no_match',
'from',
'size'
]
const snakeCase = {
allowNoMatch: 'allow_no_match'
}
/**
* Perform a ml.get_trained_models_stats request
* TODO
*/
return function mlGetTrainedModelsStats (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, modelId, model_id, ...querystring } = params
querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring, warnings)
var ignore = options.ignore
if (typeof ignore === 'number') {
options.ignore = [ignore]
}
var path = ''
if ((model_id || modelId) != null) {
if (method == null) method = 'GET'
path = '/' + '_ml' + '/' + 'inference' + '/' + encodeURIComponent(model_id || modelId) + '/' + '_stats'
} else {
if (method == null) method = 'GET'
path = '/' + '_ml' + '/' + 'inference' + '/' + '_stats'
}
// build request object
const request = {
method,
path,
body: null,
querystring
}
options.warnings = warnings.length === 0 ? null : warnings
return makeRequest(request, options, callback)
}
}
module.exports = buildMlGetTrainedModelsStats

View File

@ -292,6 +292,8 @@ function ESAPI (opts) {
deleteJob: lazyLoad('ml.delete_job', opts),
delete_model_snapshot: lazyLoad('ml.delete_model_snapshot', opts),
deleteModelSnapshot: lazyLoad('ml.delete_model_snapshot', opts),
delete_trained_model: lazyLoad('ml.delete_trained_model', opts),
deleteTrainedModel: lazyLoad('ml.delete_trained_model', opts),
estimate_memory_usage: lazyLoad('ml.estimate_memory_usage', opts),
estimateMemoryUsage: lazyLoad('ml.estimate_memory_usage', opts),
evaluate_data_frame: lazyLoad('ml.evaluate_data_frame', opts),
@ -331,6 +333,10 @@ function ESAPI (opts) {
getOverallBuckets: lazyLoad('ml.get_overall_buckets', opts),
get_records: lazyLoad('ml.get_records', opts),
getRecords: lazyLoad('ml.get_records', opts),
get_trained_models: lazyLoad('ml.get_trained_models', opts),
getTrainedModels: lazyLoad('ml.get_trained_models', opts),
get_trained_models_stats: lazyLoad('ml.get_trained_models_stats', opts),
getTrainedModelsStats: lazyLoad('ml.get_trained_models_stats', opts),
info: lazyLoad('ml.info', opts),
open_job: lazyLoad('ml.open_job', opts),
openJob: lazyLoad('ml.open_job', opts),

View File

@ -579,7 +579,6 @@ export interface IndicesClose extends Generic {
export interface IndicesCreate<T = any> extends Generic {
index: string;
include_type_name?: boolean;
wait_for_active_shards?: string;
timeout?: string;
master_timeout?: string;
@ -671,7 +670,6 @@ export interface IndicesForcemerge extends Generic {
export interface IndicesGet extends Generic {
index: string | string[];
include_type_name?: boolean;
local?: boolean;
ignore_unavailable?: boolean;
allow_no_indices?: boolean;
@ -693,7 +691,6 @@ export interface IndicesGetAlias extends Generic {
export interface IndicesGetFieldMapping extends Generic {
fields: string | string[];
index?: string | string[];
include_type_name?: boolean;
include_defaults?: boolean;
ignore_unavailable?: boolean;
allow_no_indices?: boolean;
@ -724,7 +721,6 @@ export interface IndicesGetSettings extends Generic {
export interface IndicesGetTemplate extends Generic {
name?: string | string[];
include_type_name?: boolean;
flat_settings?: boolean;
master_timeout?: string;
local?: boolean;
@ -779,7 +775,6 @@ export interface IndicesPutSettings<T = any> extends Generic {
export interface IndicesPutTemplate<T = any> extends Generic {
name: string;
include_type_name?: boolean;
order?: number;
create?: boolean;
timeout?: string;
@ -804,7 +799,6 @@ export interface IndicesRefresh extends Generic {
export interface IndicesRollover<T = any> extends Generic {
alias: string;
new_index?: string;
include_type_name?: boolean;
timeout?: string;
dry_run?: boolean;
master_timeout?: string;
@ -1612,6 +1606,10 @@ export interface MlDeleteModelSnapshot extends Generic {
snapshot_id: string;
}
export interface MlDeleteTrainedModel extends Generic {
model_id: string;
}
export interface MlEstimateMemoryUsage<T = any> extends Generic {
body: T;
}
@ -1783,6 +1781,21 @@ export interface MlGetRecords<T = any> extends Generic {
body?: T;
}
export interface MlGetTrainedModels extends Generic {
model_id?: string;
allow_no_match?: boolean;
include_model_definition?: boolean;
from?: number;
size?: number;
}
export interface MlGetTrainedModelsStats extends Generic {
model_id?: string;
allow_no_match?: boolean;
from?: number;
size?: number;
}
export interface MlInfo extends Generic {
}

View File

@ -2296,7 +2296,6 @@ _Default:_ `open`
----
client.indices.create({
index: string,
include_type_name: boolean,
wait_for_active_shards: string,
timeout: string,
master_timeout: string,
@ -2309,9 +2308,6 @@ link:{ref}/indices-create-index.html[Reference]
|`index`
|`string` - The name of the index
|`include_type_name` or `includeTypeName`
|`boolean` - Whether a type should be expected in the body of the mappings.
|`wait_for_active_shards` or `waitForActiveShards`
|`string` - Set the number of active shards to wait for before the operation returns.
@ -2671,7 +2667,6 @@ _Default:_ `open`
----
client.indices.get({
index: string | string[],
include_type_name: boolean,
local: boolean,
ignore_unavailable: boolean,
allow_no_indices: boolean,
@ -2687,9 +2682,6 @@ link:{ref}/indices-get-index.html[Reference]
|`index`
|`string \| string[]` - A comma-separated list of index names
|`include_type_name` or `includeTypeName`
|`boolean` - Whether to add the type name to the response (default: false)
|`local`
|`boolean` - Return local information, do not retrieve the state from master node (default: false)
@ -2758,7 +2750,6 @@ _Default:_ `all`
client.indices.getFieldMapping({
fields: string | string[],
index: string | string[],
include_type_name: boolean,
include_defaults: boolean,
ignore_unavailable: boolean,
allow_no_indices: boolean,
@ -2775,9 +2766,6 @@ link:{ref}/indices-get-field-mapping.html[Reference]
|`index`
|`string \| string[]` - A comma-separated list of index names
|`include_type_name` or `includeTypeName`
|`boolean` - Whether a type should be returned in the body of the mappings.
|`include_defaults` or `includeDefaults`
|`boolean` - Whether the default mapping values should be returned as well
@ -2888,7 +2876,6 @@ _Default:_ `open,closed`
----
client.indices.getTemplate({
name: string | string[],
include_type_name: boolean,
flat_settings: boolean,
master_timeout: string,
local: boolean
@ -2900,9 +2887,6 @@ link:{ref}/indices-templates.html[Reference]
|`name`
|`string \| string[]` - The comma separated names of the index templates
|`include_type_name` or `includeTypeName`
|`boolean` - Whether a type should be returned in the body of the mappings.
|`flat_settings` or `flatSettings`
|`boolean` - Return settings in flat format (default: false)
@ -3112,7 +3096,6 @@ _Default:_ `open`
----
client.indices.putTemplate({
name: string,
include_type_name: boolean,
order: number,
create: boolean,
timeout: string,
@ -3127,9 +3110,6 @@ link:{ref}/indices-templates.html[Reference]
|`name`
|`string` - The name of the template
|`include_type_name` or `includeTypeName`
|`boolean` - Whether a type should be returned in the body of the mappings.
|`order`
|`number` - The order for this template when merging multiple matching ones (higher numbers are merged later, overriding the lower numbers)
@ -3210,7 +3190,6 @@ _Default:_ `open`
client.indices.rollover({
alias: string,
new_index: string,
include_type_name: boolean,
timeout: string,
dry_run: boolean,
master_timeout: string,
@ -3227,9 +3206,6 @@ link:{ref}/indices-rollover-index.html[Reference]
|`new_index` or `newIndex`
|`string` - The name of the rollover index
|`include_type_name` or `includeTypeName`
|`boolean` - Whether a type should be included in the body of the mappings.
|`timeout`
|`string` - Explicit operation timeout
@ -6425,6 +6401,22 @@ link:{ref}/ml-delete-snapshot.html[Reference]
|===
=== ml.deleteTrainedModel
*Stability:* experimental
[source,ts]
----
client.ml.deleteTrainedModel({
model_id: string
})
----
link:TODO[Reference]
[cols=2*]
|===
|`model_id` or `modelId`
|`string` - The ID of the trained model to delete
|===
=== ml.estimateMemoryUsage
*Stability:* experimental
[source,ts]
@ -7112,6 +7104,70 @@ link:{ref}/ml-get-record.html[Reference]
|===
=== ml.getTrainedModels
*Stability:* experimental
[source,ts]
----
client.ml.getTrainedModels({
model_id: string,
allow_no_match: boolean,
include_model_definition: boolean,
from: number,
size: number
})
----
link:TODO[Reference]
[cols=2*]
|===
|`model_id` or `modelId`
|`string` - The ID of the trained models to fetch
|`allow_no_match` or `allowNoMatch`
|`boolean` - Whether to ignore if a wildcard expression matches no trained models. (This includes `_all` string or when no trained models have been specified) +
_Default:_ `true`
|`include_model_definition` or `includeModelDefinition`
|`boolean` - Should the full model definition be included in the results. These definitions can be large
|`from`
|`number` - skips a number of trained models
|`size`
|`number` - specifies a max number of trained models to get +
_Default:_ `100`
|===
=== ml.getTrainedModelsStats
*Stability:* experimental
[source,ts]
----
client.ml.getTrainedModelsStats({
model_id: string,
allow_no_match: boolean,
from: number,
size: number
})
----
link:TODO[Reference]
[cols=2*]
|===
|`model_id` or `modelId`
|`string` - The ID of the trained models stats to fetch
|`allow_no_match` or `allowNoMatch`
|`boolean` - Whether to ignore if a wildcard expression matches no trained models. (This includes `_all` string or when no trained models have been specified) +
_Default:_ `true`
|`from`
|`number` - skips a number of trained models
|`size`
|`number` - specifies a max number of trained models to get +
_Default:_ `100`
|===
=== ml.info
[source,ts]

6
index.d.ts vendored
View File

@ -390,6 +390,8 @@ declare class Client extends EventEmitter {
deleteJob: ApiMethod<RequestParams.MlDeleteJob>
delete_model_snapshot: ApiMethod<RequestParams.MlDeleteModelSnapshot>
deleteModelSnapshot: ApiMethod<RequestParams.MlDeleteModelSnapshot>
delete_trained_model: ApiMethod<RequestParams.MlDeleteTrainedModel>
deleteTrainedModel: ApiMethod<RequestParams.MlDeleteTrainedModel>
estimate_memory_usage: ApiMethod<RequestParams.MlEstimateMemoryUsage>
estimateMemoryUsage: ApiMethod<RequestParams.MlEstimateMemoryUsage>
evaluate_data_frame: ApiMethod<RequestParams.MlEvaluateDataFrame>
@ -429,6 +431,10 @@ declare class Client extends EventEmitter {
getOverallBuckets: ApiMethod<RequestParams.MlGetOverallBuckets>
get_records: ApiMethod<RequestParams.MlGetRecords>
getRecords: ApiMethod<RequestParams.MlGetRecords>
get_trained_models: ApiMethod<RequestParams.MlGetTrainedModels>
getTrainedModels: ApiMethod<RequestParams.MlGetTrainedModels>
get_trained_models_stats: ApiMethod<RequestParams.MlGetTrainedModelsStats>
getTrainedModelsStats: ApiMethod<RequestParams.MlGetTrainedModelsStats>
info: ApiMethod<RequestParams.MlInfo>
open_job: ApiMethod<RequestParams.MlOpenJob>
openJob: ApiMethod<RequestParams.MlOpenJob>