mirror of
https://github.com/n8n-io/n8n.git
synced 2024-11-14 08:34:07 -08:00
8999403228
* Added 'Source Excludes' and 'Source Includes' options on 'document: getAll' operation * Updated credentials to use new system Co-authored-by: mp <miguel@mconf.com> Co-authored-by: miguel-mconf <107938570+miguel-mconf@users.noreply.github.com> Co-authored-by: Jan Oberhauser <janober@users.noreply.github.com>
54 lines
995 B
TypeScript
54 lines
995 B
TypeScript
import {
|
|
OptionsWithUri,
|
|
} from 'request';
|
|
|
|
import {
|
|
IExecuteFunctions,
|
|
} from 'n8n-core';
|
|
|
|
import {
|
|
IDataObject,
|
|
JsonObject,
|
|
NodeApiError,
|
|
} from 'n8n-workflow';
|
|
|
|
import {
|
|
ElasticsearchApiCredentials,
|
|
} from './types';
|
|
|
|
export async function elasticsearchApiRequest(
|
|
this: IExecuteFunctions,
|
|
method: 'GET' | 'PUT' | 'POST' | 'DELETE',
|
|
endpoint: string,
|
|
body: IDataObject = {},
|
|
qs: IDataObject = {},
|
|
) {
|
|
const {
|
|
baseUrl,
|
|
ignoreSSLIssues,
|
|
} = await this.getCredentials('elasticsearchApi') as ElasticsearchApiCredentials;
|
|
|
|
const options: OptionsWithUri = {
|
|
method,
|
|
body,
|
|
qs,
|
|
uri: `${baseUrl}${endpoint}`,
|
|
json: true,
|
|
rejectUnauthorized: !ignoreSSLIssues,
|
|
};
|
|
|
|
if (!Object.keys(body).length) {
|
|
delete options.body;
|
|
}
|
|
|
|
if (!Object.keys(qs).length) {
|
|
delete options.qs;
|
|
}
|
|
|
|
try {
|
|
return await this.helpers.requestWithAuthentication.call(this, 'elasticsearchApi', options);
|
|
} catch (error) {
|
|
throw new NodeApiError(this.getNode(), error as JsonObject);
|
|
}
|
|
}
|