// 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
///
import { ConnectionOptions as TlsConnectionOptions } from 'tls';
import Transport, {
ApiError,
ApiResponse,
RequestEvent,
TransportRequestParams,
TransportRequestOptions,
nodeFilterFn,
nodeSelectorFn,
generateRequestIdFn,
TransportRequestCallback,
RequestBody,
RequestNDBody,
ResponseBody
} from './lib/Transport';
import { URL } from 'url';
import Connection, { AgentOptions, agentFn } from './lib/Connection';
import {
ConnectionPool,
BaseConnectionPool,
CloudConnectionPool,
ResurrectEvent,
BasicAuth,
ApiKeyAuth
} from './lib/pool';
import Serializer from './lib/Serializer';
import Helpers from './lib/Helpers';
import * as RequestParams from './api/requestParams';
import * as errors from './lib/errors';
declare type callbackFn = (err: ApiError, result: ApiResponse) => void;
// Extend API
interface ClientExtendsCallbackOptions {
ConfigurationError: errors.ConfigurationError,
makeRequest(params: TransportRequestParams, options?: TransportRequestOptions): Promise | void;
result: {
body: null,
statusCode: null,
headers: null,
warnings: null
}
}
declare type extendsCallback = (options: ClientExtendsCallbackOptions) => any;
interface ClientExtends {
(method: string, fn: extendsCallback): void;
(method: string, opts: { force: boolean }, fn: extendsCallback): void;
}
// /Extend API
interface NodeOptions {
url: URL;
id?: string;
agent?: AgentOptions;
ssl?: TlsConnectionOptions;
headers?: Record;
roles?: {
master: boolean;
data: boolean;
ingest: boolean;
ml: boolean;
}
}
interface ClientOptions {
node?: string | string[] | NodeOptions | NodeOptions[];
nodes?: string | string[] | NodeOptions | NodeOptions[];
Connection?: typeof Connection;
ConnectionPool?: typeof ConnectionPool;
Transport?: typeof Transport;
Serializer?: typeof Serializer;
maxRetries?: number;
requestTimeout?: number;
pingTimeout?: number;
sniffInterval?: number | boolean;
sniffOnStart?: boolean;
sniffEndpoint?: string;
sniffOnConnectionFault?: boolean;
resurrectStrategy?: 'ping' | 'optimistic' | 'none';
suggestCompression?: boolean;
compression?: 'gzip';
ssl?: TlsConnectionOptions;
agent?: AgentOptions | agentFn;
nodeFilter?: nodeFilterFn;
nodeSelector?: nodeSelectorFn | string;
headers?: Record;
opaqueIdPrefix?: string;
generateRequestId?: generateRequestIdFn;
name?: string;
auth?: BasicAuth | ApiKeyAuth;
cloud?: {
id: string;
// TODO: remove username and password here in 8
username?: string;
password?: string;
}
}
declare class Client extends EventEmitter {
constructor(opts?: ClientOptions);
connectionPool: ConnectionPool;
transport: Transport;
serializer: Serializer;
extend: ClientExtends;
helpers: Helpers;
child(opts?: ClientOptions): Client;
close(callback?: Function): Promise | void;
/* GENERATED */
async_search: {
delete(params?: RequestParams.AsyncSearchDelete, options?: TransportRequestOptions): Promise>
delete(callback: callbackFn): TransportRequestCallback
delete(params: RequestParams.AsyncSearchDelete, callback: callbackFn): TransportRequestCallback
delete(params: RequestParams.AsyncSearchDelete, options: TransportRequestOptions, callback: callbackFn): TransportRequestCallback
get(params?: RequestParams.AsyncSearchGet, options?: TransportRequestOptions): Promise>
get(callback: callbackFn): TransportRequestCallback
get(params: RequestParams.AsyncSearchGet, callback: callbackFn): TransportRequestCallback
get(params: RequestParams.AsyncSearchGet, options: TransportRequestOptions, callback: callbackFn): TransportRequestCallback
submit(params?: RequestParams.AsyncSearchSubmit, options?: TransportRequestOptions): Promise>
submit(callback: callbackFn): TransportRequestCallback
submit(params: RequestParams.AsyncSearchSubmit, callback: callbackFn): TransportRequestCallback
submit(params: RequestParams.AsyncSearchSubmit, options: TransportRequestOptions, callback: callbackFn): TransportRequestCallback
}
asyncSearch: {
delete(params?: RequestParams.AsyncSearchDelete, options?: TransportRequestOptions): Promise>
delete(callback: callbackFn): TransportRequestCallback
delete(params: RequestParams.AsyncSearchDelete, callback: callbackFn): TransportRequestCallback
delete(params: RequestParams.AsyncSearchDelete, options: TransportRequestOptions, callback: callbackFn): TransportRequestCallback
get(params?: RequestParams.AsyncSearchGet, options?: TransportRequestOptions): Promise>
get(callback: callbackFn): TransportRequestCallback
get(params: RequestParams.AsyncSearchGet, callback: callbackFn): TransportRequestCallback
get(params: RequestParams.AsyncSearchGet, options: TransportRequestOptions, callback: callbackFn): TransportRequestCallback
submit(params?: RequestParams.AsyncSearchSubmit, options?: TransportRequestOptions): Promise>
submit(callback: callbackFn): TransportRequestCallback
submit(params: RequestParams.AsyncSearchSubmit, callback: callbackFn): TransportRequestCallback
submit(params: RequestParams.AsyncSearchSubmit, options: TransportRequestOptions, callback: callbackFn): TransportRequestCallback
}
autoscaling: {
get_autoscaling_decision(params?: RequestParams.AutoscalingGetAutoscalingDecision, options?: TransportRequestOptions): Promise>
get_autoscaling_decision(callback: callbackFn): TransportRequestCallback
get_autoscaling_decision(params: RequestParams.AutoscalingGetAutoscalingDecision, callback: callbackFn): TransportRequestCallback
get_autoscaling_decision(params: RequestParams.AutoscalingGetAutoscalingDecision, options: TransportRequestOptions, callback: callbackFn): TransportRequestCallback
getAutoscalingDecision(params?: RequestParams.AutoscalingGetAutoscalingDecision, options?: TransportRequestOptions): Promise>
getAutoscalingDecision(callback: callbackFn): TransportRequestCallback
getAutoscalingDecision(params: RequestParams.AutoscalingGetAutoscalingDecision, callback: callbackFn): TransportRequestCallback
getAutoscalingDecision(params: RequestParams.AutoscalingGetAutoscalingDecision, options: TransportRequestOptions, callback: callbackFn): TransportRequestCallback
}
bulk(params?: RequestParams.Bulk, options?: TransportRequestOptions): Promise>
bulk(callback: callbackFn): TransportRequestCallback
bulk(params: RequestParams.Bulk, callback: callbackFn): TransportRequestCallback
bulk(params: RequestParams.Bulk, options: TransportRequestOptions, callback: callbackFn): TransportRequestCallback
cat: {
aliases(params?: RequestParams.CatAliases, options?: TransportRequestOptions): Promise>
aliases(callback: callbackFn): TransportRequestCallback
aliases(params: RequestParams.CatAliases, callback: callbackFn): TransportRequestCallback
aliases(params: RequestParams.CatAliases, options: TransportRequestOptions, callback: callbackFn): TransportRequestCallback
allocation(params?: RequestParams.CatAllocation, options?: TransportRequestOptions): Promise>
allocation(callback: callbackFn): TransportRequestCallback
allocation(params: RequestParams.CatAllocation, callback: callbackFn): TransportRequestCallback
allocation(params: RequestParams.CatAllocation, options: TransportRequestOptions, callback: callbackFn): TransportRequestCallback
count(params?: RequestParams.CatCount, options?: TransportRequestOptions): Promise>
count(callback: callbackFn): TransportRequestCallback
count(params: RequestParams.CatCount, callback: callbackFn): TransportRequestCallback
count(params: RequestParams.CatCount, options: TransportRequestOptions, callback: callbackFn): TransportRequestCallback
fielddata(params?: RequestParams.CatFielddata, options?: TransportRequestOptions): Promise>
fielddata(callback: callbackFn): TransportRequestCallback
fielddata(params: RequestParams.CatFielddata, callback: callbackFn): TransportRequestCallback
fielddata(params: RequestParams.CatFielddata, options: TransportRequestOptions, callback: callbackFn): TransportRequestCallback
health(params?: RequestParams.CatHealth, options?: TransportRequestOptions): Promise>
health(callback: callbackFn): TransportRequestCallback
health(params: RequestParams.CatHealth, callback: callbackFn): TransportRequestCallback
health(params: RequestParams.CatHealth, options: TransportRequestOptions, callback: callbackFn): TransportRequestCallback
help(params?: RequestParams.CatHelp, options?: TransportRequestOptions): Promise>
help(callback: callbackFn): TransportRequestCallback
help(params: RequestParams.CatHelp, callback: callbackFn): TransportRequestCallback
help(params: RequestParams.CatHelp, options: TransportRequestOptions, callback: callbackFn): TransportRequestCallback
indices(params?: RequestParams.CatIndices, options?: TransportRequestOptions): Promise>
indices(callback: callbackFn): TransportRequestCallback
indices(params: RequestParams.CatIndices, callback: callbackFn): TransportRequestCallback
indices(params: RequestParams.CatIndices, options: TransportRequestOptions, callback: callbackFn): TransportRequestCallback
master(params?: RequestParams.CatMaster, options?: TransportRequestOptions): Promise>
master(callback: callbackFn): TransportRequestCallback
master(params: RequestParams.CatMaster, callback: callbackFn): TransportRequestCallback
master(params: RequestParams.CatMaster, options: TransportRequestOptions, callback: callbackFn): TransportRequestCallback
ml_data_frame_analytics(params?: RequestParams.CatMlDataFrameAnalytics, options?: TransportRequestOptions): Promise>
ml_data_frame_analytics(callback: callbackFn): TransportRequestCallback
ml_data_frame_analytics(params: RequestParams.CatMlDataFrameAnalytics, callback: callbackFn): TransportRequestCallback
ml_data_frame_analytics(params: RequestParams.CatMlDataFrameAnalytics, options: TransportRequestOptions, callback: callbackFn): TransportRequestCallback
mlDataFrameAnalytics(params?: RequestParams.CatMlDataFrameAnalytics, options?: TransportRequestOptions): Promise>
mlDataFrameAnalytics(callback: callbackFn): TransportRequestCallback
mlDataFrameAnalytics(params: RequestParams.CatMlDataFrameAnalytics, callback: callbackFn): TransportRequestCallback
mlDataFrameAnalytics(params: RequestParams.CatMlDataFrameAnalytics, options: TransportRequestOptions, callback: callbackFn): TransportRequestCallback
ml_datafeeds(params?: RequestParams.CatMlDatafeeds, options?: TransportRequestOptions): Promise>
ml_datafeeds(callback: callbackFn): TransportRequestCallback
ml_datafeeds(params: RequestParams.CatMlDatafeeds, callback: callbackFn): TransportRequestCallback
ml_datafeeds(params: RequestParams.CatMlDatafeeds, options: TransportRequestOptions, callback: callbackFn): TransportRequestCallback
mlDatafeeds(params?: RequestParams.CatMlDatafeeds, options?: TransportRequestOptions): Promise>
mlDatafeeds(callback: callbackFn): TransportRequestCallback
mlDatafeeds(params: RequestParams.CatMlDatafeeds, callback: callbackFn): TransportRequestCallback
mlDatafeeds(params: RequestParams.CatMlDatafeeds, options: TransportRequestOptions, callback: callbackFn): TransportRequestCallback
ml_jobs(params?: RequestParams.CatMlJobs, options?: TransportRequestOptions): Promise>
ml_jobs(callback: callbackFn): TransportRequestCallback
ml_jobs(params: RequestParams.CatMlJobs, callback: callbackFn): TransportRequestCallback
ml_jobs(params: RequestParams.CatMlJobs, options: TransportRequestOptions, callback: callbackFn): TransportRequestCallback
mlJobs(params?: RequestParams.CatMlJobs, options?: TransportRequestOptions): Promise>
mlJobs(callback: callbackFn): TransportRequestCallback
mlJobs(params: RequestParams.CatMlJobs, callback: callbackFn): TransportRequestCallback
mlJobs(params: RequestParams.CatMlJobs, options: TransportRequestOptions, callback: callbackFn): TransportRequestCallback
ml_trained_models(params?: RequestParams.CatMlTrainedModels, options?: TransportRequestOptions): Promise>
ml_trained_models(callback: callbackFn): TransportRequestCallback
ml_trained_models(params: RequestParams.CatMlTrainedModels, callback: callbackFn): TransportRequestCallback
ml_trained_models(params: RequestParams.CatMlTrainedModels, options: TransportRequestOptions, callback: callbackFn): TransportRequestCallback
mlTrainedModels(params?: RequestParams.CatMlTrainedModels, options?: TransportRequestOptions): Promise>
mlTrainedModels(callback: callbackFn): TransportRequestCallback
mlTrainedModels(params: RequestParams.CatMlTrainedModels, callback: callbackFn): TransportRequestCallback
mlTrainedModels(params: RequestParams.CatMlTrainedModels, options: TransportRequestOptions, callback: callbackFn): TransportRequestCallback
nodeattrs(params?: RequestParams.CatNodeattrs, options?: TransportRequestOptions): Promise>
nodeattrs(callback: callbackFn): TransportRequestCallback
nodeattrs(params: RequestParams.CatNodeattrs, callback: callbackFn): TransportRequestCallback
nodeattrs(params: RequestParams.CatNodeattrs, options: TransportRequestOptions, callback: callbackFn): TransportRequestCallback
nodes(params?: RequestParams.CatNodes, options?: TransportRequestOptions): Promise>
nodes(callback: callbackFn): TransportRequestCallback
nodes(params: RequestParams.CatNodes, callback: callbackFn): TransportRequestCallback
nodes(params: RequestParams.CatNodes, options: TransportRequestOptions, callback: callbackFn): TransportRequestCallback
pending_tasks(params?: RequestParams.CatPendingTasks, options?: TransportRequestOptions): Promise>
pending_tasks(callback: callbackFn): TransportRequestCallback
pending_tasks(params: RequestParams.CatPendingTasks, callback: callbackFn): TransportRequestCallback
pending_tasks(params: RequestParams.CatPendingTasks, options: TransportRequestOptions, callback: callbackFn): TransportRequestCallback
pendingTasks(params?: RequestParams.CatPendingTasks, options?: TransportRequestOptions): Promise>
pendingTasks(callback: callbackFn): TransportRequestCallback
pendingTasks(params: RequestParams.CatPendingTasks, callback: callbackFn): TransportRequestCallback
pendingTasks(params: RequestParams.CatPendingTasks, options: TransportRequestOptions, callback: callbackFn): TransportRequestCallback
plugins(params?: RequestParams.CatPlugins, options?: TransportRequestOptions): Promise>
plugins(callback: callbackFn): TransportRequestCallback
plugins(params: RequestParams.CatPlugins, callback: callbackFn): TransportRequestCallback
plugins(params: RequestParams.CatPlugins, options: TransportRequestOptions, callback: callbackFn