forked from opensearch-project/opensearch-js
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathscriptsPainlessExecute.js
47 lines (39 loc) · 1.47 KB
/
scriptsPainlessExecute.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
/*
* Copyright OpenSearch Contributors
* SPDX-License-Identifier: Apache-2.0
*
* The OpenSearch Contributors require contributions made to
* this file be licensed under the Apache-2.0 license or a
* compatible open source license.
*
*/
/*
* This file was generated from the OpenSearch API Spec. Do NOT edit it
* manually. If you want to make changes, either update the spec or
* modify the API generator.
*/
'use strict';
const { normalizeArguments } = require('../utils');
/**
* Allows an arbitrary script to be executed and a result to be returned.
* <br/> See Also: {@link https://opensearch.org/docs/latest/api-reference/script-apis/exec-script/ - scripts_painless_execute}
*
* @memberOf API-Core
*
* @param {object} [params]
* @param {object} [params.body] - The script to execute
*
* @param {TransportRequestOptions} [options] - Options for {@link Transport#request}
* @param {function} [callback] - Callback that handles errors and response
*
* @returns {{abort: function(), then: function(), catch: function()}|Promise<never>|*}
*/
function scriptsPainlessExecuteFunc(params, options, callback) {
[params, options, callback] = normalizeArguments(params, options, callback);
let { body, ...querystring } = params;
const path = '/_scripts/painless/_execute';
const method = body ? 'POST' : 'GET';
body = body || '';
return this.transport.request({ method, path, querystring, body }, options, callback);
}
module.exports = scriptsPainlessExecuteFunc;