|
| 1 | +/* |
| 2 | + * Licensed to Elasticsearch B.V. under one or more contributor |
| 3 | + * license agreements. See the NOTICE file distributed with |
| 4 | + * this work for additional information regarding copyright |
| 5 | + * ownership. Elasticsearch B.V. licenses this file to you under |
| 6 | + * the Apache License, Version 2.0 (the "License"); you may |
| 7 | + * not use this file except in compliance with the License. |
| 8 | + * You may obtain a copy of the License at |
| 9 | + * |
| 10 | + * http://www.apache.org/licenses/LICENSE-2.0 |
| 11 | + * |
| 12 | + * Unless required by applicable law or agreed to in writing, |
| 13 | + * software distributed under the License is distributed on an |
| 14 | + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY |
| 15 | + * KIND, either express or implied. See the License for the |
| 16 | + * specific language governing permissions and limitations |
| 17 | + * under the License. |
| 18 | + */ |
| 19 | + |
| 20 | +'use strict' |
| 21 | + |
| 22 | +/* eslint camelcase: 0 */ |
| 23 | +/* eslint no-unused-vars: 0 */ |
| 24 | + |
| 25 | +function buildDataFrameGetDataFrameTransform (opts) { |
| 26 | + // eslint-disable-next-line no-unused-vars |
| 27 | + const { makeRequest, ConfigurationError, handleError, snakeCaseKeys } = opts |
| 28 | + /** |
| 29 | + * Perform a [data_frame.get_data_frame_transform](https://www.elastic.co/guide/en/elasticsearch/reference/current/get-data-frame-transform.html) request |
| 30 | + * |
| 31 | + * @param {string} transform_id - The id or comma delimited list of id expressions of the transforms to get, '_all' or '*' implies get all transforms |
| 32 | + * @param {int} from - skips a number of transform configs, defaults to 0 |
| 33 | + * @param {int} size - specifies a max number of transforms to get, defaults to 100 |
| 34 | + */ |
| 35 | + |
| 36 | + const acceptedQuerystring = [ |
| 37 | + 'from', |
| 38 | + 'size' |
| 39 | + ] |
| 40 | + |
| 41 | + const snakeCase = { |
| 42 | + |
| 43 | + } |
| 44 | + |
| 45 | + return function dataFrameGetDataFrameTransform (params, options, callback) { |
| 46 | + options = options || {} |
| 47 | + if (typeof options === 'function') { |
| 48 | + callback = options |
| 49 | + options = {} |
| 50 | + } |
| 51 | + if (typeof params === 'function' || params == null) { |
| 52 | + callback = params |
| 53 | + params = {} |
| 54 | + options = {} |
| 55 | + } |
| 56 | + |
| 57 | + // check required parameters |
| 58 | + if (params.body != null) { |
| 59 | + const err = new ConfigurationError('This API does not require a body') |
| 60 | + return handleError(err, callback) |
| 61 | + } |
| 62 | + |
| 63 | + // validate headers object |
| 64 | + if (options.headers != null && typeof options.headers !== 'object') { |
| 65 | + const err = new ConfigurationError(`Headers should be an object, instead got: ${typeof options.headers}`) |
| 66 | + return handleError(err, callback) |
| 67 | + } |
| 68 | + |
| 69 | + var warnings = [] |
| 70 | + var { method, body, transformId, transform_id, ...querystring } = params |
| 71 | + querystring = snakeCaseKeys(acceptedQuerystring, snakeCase, querystring, warnings) |
| 72 | + |
| 73 | + if (method == null) { |
| 74 | + method = 'GET' |
| 75 | + } |
| 76 | + |
| 77 | + var ignore = options.ignore |
| 78 | + if (typeof ignore === 'number') { |
| 79 | + options.ignore = [ignore] |
| 80 | + } |
| 81 | + |
| 82 | + var path = '' |
| 83 | + |
| 84 | + if ((transform_id || transformId) != null) { |
| 85 | + path = '/' + '_data_frame' + '/' + 'transforms' + '/' + encodeURIComponent(transform_id || transformId) |
| 86 | + } else { |
| 87 | + path = '/' + '_data_frame' + '/' + 'transforms' |
| 88 | + } |
| 89 | + |
| 90 | + // build request object |
| 91 | + const request = { |
| 92 | + method, |
| 93 | + path, |
| 94 | + body: null, |
| 95 | + querystring |
| 96 | + } |
| 97 | + |
| 98 | + options.warnings = warnings.length === 0 ? null : warnings |
| 99 | + return makeRequest(request, options, callback) |
| 100 | + } |
| 101 | +} |
| 102 | + |
| 103 | +module.exports = buildDataFrameGetDataFrameTransform |
0 commit comments