|
| 1 | +// Licensed to Elasticsearch B.V under one or more agreements. |
| 2 | +// Elasticsearch B.V licenses this file to you under the Apache 2.0 License. |
| 3 | +// See the LICENSE file in the project root for more information |
| 4 | + |
| 5 | +'use strict' |
| 6 | + |
| 7 | +/* eslint camelcase: 0 */ |
| 8 | +/* eslint no-unused-vars: 0 */ |
| 9 | + |
| 10 | +function buildMlDeleteTrainedModel (opts) { |
| 11 | + // eslint-disable-next-line no-unused-vars |
| 12 | + const { makeRequest, ConfigurationError, handleError, snakeCaseKeys } = opts |
| 13 | + |
| 14 | + const acceptedQuerystring = [ |
| 15 | + |
| 16 | + ] |
| 17 | + |
| 18 | + const snakeCase = { |
| 19 | + |
| 20 | + } |
| 21 | + |
| 22 | + /** |
| 23 | + * Perform a ml.delete_trained_model request |
| 24 | + * https://www.elastic.co/guide/en/elasticsearch/reference/current/delete-inference.html |
| 25 | + */ |
| 26 | + return function mlDeleteTrainedModel (params, options, callback) { |
| 27 | + options = options || {} |
| 28 | + if (typeof options === 'function') { |
| 29 | + callback = options |
| 30 | + options = {} |
| 31 | + } |
| 32 | + if (typeof params === 'function' || params == null) { |
| 33 | + callback = params |
| 34 | + params = {} |
| 35 | + options = {} |
| 36 | + } |
| 37 | + |
| 38 | + // check required parameters |
| 39 | + if (params['model_id'] == null && params['modelId'] == null) { |
| 40 | + const err = new ConfigurationError('Missing required parameter: model_id or modelId') |
| 41 | + return handleError(err, callback) |
| 42 | + } |
| 43 | + |
| 44 | + // validate headers object |
| 45 | + if (options.headers != null && typeof options.headers !== 'object') { |
| 46 | + const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`) |
| 47 | + return handleError(err, callback) |
| 48 | + } |
| 49 | + |
| 50 | + var warnings = [] |
| 51 | + var { method, body, modelId, model_id, ...querystring } = params |
| 52 | + querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring, warnings) |
| 53 | + |
| 54 | + var ignore = options.ignore |
| 55 | + if (typeof ignore === 'number') { |
| 56 | + options.ignore = [ignore] |
| 57 | + } |
| 58 | + |
| 59 | + var path = '' |
| 60 | + |
| 61 | + if (method == null) method = 'DELETE' |
| 62 | + path = '/' + '_ml' + '/' + 'inference' + '/' + encodeURIComponent(model_id || modelId) |
| 63 | + |
| 64 | + // build request object |
| 65 | + const request = { |
| 66 | + method, |
| 67 | + path, |
| 68 | + body: body || '', |
| 69 | + querystring |
| 70 | + } |
| 71 | + |
| 72 | + options.warnings = warnings.length === 0 ? null : warnings |
| 73 | + return makeRequest(request, options, callback) |
| 74 | + } |
| 75 | +} |
| 76 | + |
| 77 | +module.exports = buildMlDeleteTrainedModel |
0 commit comments