/*
* Licensed to Elasticsearch B.V. under one or more contributor
* license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright
* ownership. Elasticsearch B.V. licenses this file to you under
* the Apache License, Version 2.0 (the "License"); you may
* not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
///
import { ConnectionOptions as TlsConnectionOptions } from 'tls';
import Transport, {
ApiError,
ApiResponse,
RequestEvent,
TransportRequestParams,
TransportRequestOptions,
nodeFilterFn,
nodeSelectorFn,
generateRequestIdFn,
TransportRequestCallback,
TransportRequestPromise,
RequestBody,
RequestNDBody,
Context
} from './lib/Transport';
import { URL } from 'url';
import Connection, { AgentOptions, agentFn } from './lib/Connection';
import {
ConnectionPool,
BaseConnectionPool,
CloudConnectionPool,
ResurrectEvent,
BasicAuth,
ApiKeyAuth,
BearerAuth
} from './lib/pool';
import Serializer from './lib/Serializer';
import Helpers from './lib/Helpers';
import * as errors from './lib/errors';
import * as estypes from './api/types'
import * as RequestParams from './api/requestParams'
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;
// /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 | false;
nodeFilter?: nodeFilterFn;
nodeSelector?: nodeSelectorFn | string;
headers?: Record;
opaqueIdPrefix?: string;
generateRequestId?: generateRequestIdFn;
name?: string | symbol;
auth?: BasicAuth | ApiKeyAuth | BearerAuth;
context?: Context;
proxy?: string | URL;
enableMetaHeader?: boolean;
cloud?: {
id: string;
// TODO: remove username and password here in 8
username?: string;
password?: string;
};
disablePrototypePoisoningProtection?: boolean | 'proto' | 'constructor';
caFingerprint?: string;
}
declare class Client {
constructor(opts: ClientOptions);
connectionPool: ConnectionPool;
transport: Transport;
serializer: Serializer;
extend(method: string, fn: extendsCallback): void
extend(method: string, opts: { force: boolean }, fn: extendsCallback): void;
helpers: Helpers;
child(opts?: ClientOptions): Client;
close(callback: Function): void;
close(): Promise;
emit(event: string | symbol, ...args: any[]): boolean;
on(event: 'request', listener: (err: ApiError, meta: RequestEvent) => void): this;
on(event: 'response', listener: (err: ApiError, meta: RequestEvent) => void): this;
on(event: 'sniff', listener: (err: ApiError, meta: RequestEvent) => void): this;
on(event: 'resurrect', listener: (err: null, meta: ResurrectEvent) => void): this;
once(event: 'request', listener: (err: ApiError, meta: RequestEvent) => void): this;
once(event: 'response', listener: (err: ApiError, meta: RequestEvent) => void): this;
once(event: 'sniff', listener: (err: ApiError, meta: RequestEvent) => void): this;
once(event: 'resurrect', listener: (err: null, meta: ResurrectEvent) => void): this;
off(event: string | symbol, listener: (...args: any[]) => void): this;
/* GENERATED */
async_search: {
delete, TContext = Context>(params?: RequestParams.AsyncSearchDelete, options?: TransportRequestOptions): TransportRequestPromise>
delete, TContext = Context>(callback: callbackFn): TransportRequestCallback
delete, TContext = Context>(params: RequestParams.AsyncSearchDelete, callback: callbackFn): TransportRequestCallback
delete, TContext = Context>(params: RequestParams.AsyncSearchDelete, options: TransportRequestOptions, callback: callbackFn): TransportRequestCallback
get, TContext = Context>(params?: RequestParams.AsyncSearchGet, options?: TransportRequestOptions): TransportRequestPromise>
get, TContext = Context>(callback: callbackFn): TransportRequestCallback
get, TContext = Context>(params: RequestParams.AsyncSearchGet, callback: callbackFn): TransportRequestCallback
get, TContext = Context>(params: RequestParams.AsyncSearchGet, options: TransportRequestOptions, callback: callbackFn): TransportRequestCallback
status, TContext = Context>(params?: RequestParams.AsyncSearchStatus, options?: TransportRequestOptions): TransportRequestPromise>
status, TContext = Context>(callback: callbackFn): TransportRequestCallback
status, TContext = Context>(params: RequestParams.AsyncSearchStatus, callback: callbackFn): TransportRequestCallback
status, TContext = Context>(params: RequestParams.AsyncSearchStatus, options: TransportRequestOptions, callback: callbackFn): TransportRequestCallback
submit, TRequestBody extends RequestBody = Record, TContext = Context>(params?: RequestParams.AsyncSearchSubmit, options?: TransportRequestOptions): TransportRequestPromise>
submit, TRequestBody extends RequestBody = Record, TContext = Context>(callback: callbackFn): TransportRequestCallback
submit, TRequestBody extends RequestBody = Record, TContext = Context>(params: RequestParams.AsyncSearchSubmit, callback: callbackFn): TransportRequestCallback
submit, TRequestBody extends RequestBody = Record, TContext = Context>(params: RequestParams.AsyncSearchSubmit, options: TransportRequestOptions, callback: callbackFn): TransportRequestCallback
}
asyncSearch: {
delete, TContext = Context>(params?: RequestParams.AsyncSearchDelete, options?: TransportRequestOptions): TransportRequestPromise>
delete, TContext = Context>(callback: callbackFn): TransportRequestCallback
delete, TContext = Context>(params: RequestParams.AsyncSearchDelete, callback: callbackFn): TransportRequestCallback
delete, TContext = Context>(params: RequestParams.AsyncSearchDelete, options: TransportRequestOptions, callback: callbackFn): TransportRequestCallback
get, TContext = Context>(params?: RequestParams.AsyncSearchGet, options?: TransportRequestOptions): TransportRequestPromise>
get, TContext = Context>(callback: callbackFn): TransportRequestCallback
get, TContext = Context>(params: RequestParams.AsyncSearchGet, callback: callbackFn): TransportRequestCallback
get, TContext = Context>(params: RequestParams.AsyncSearchGet, options: TransportRequestOptions, callback: callbackFn): TransportRequestCallback
status, TContext = Context>(params?: RequestParams.AsyncSearchStatus, options?: TransportRequestOptions): TransportRequestPromise>
status, TContext = Context>(callback: callbackFn): TransportRequestCallback
status, TContext = Context>(params: RequestParams.AsyncSearchStatus, callback: callbackFn): TransportRequestCallback
status, TContext = Context>(params: RequestParams.AsyncSearchStatus, options: TransportRequestOptions, callback: callbackFn): TransportRequestCallback
submit, TRequestBody extends RequestBody = Record, TContext = Context>(params?: RequestParams.AsyncSearchSubmit, options?: TransportRequestOptions): TransportRequestPromise>
submit, TRequestBody extends RequestBody = Record, TContext = Context>(callback: callbackFn): TransportRequestCallback
submit, TRequestBody extends RequestBody = Record, TContext = Context>(params: RequestParams.AsyncSearchSubmit, callback: callbackFn): TransportRequestCallback
submit, TRequestBody extends RequestBody = Record, TContext = Context>(params: RequestParams.AsyncSearchSubmit, options: TransportRequestOptions, callback: callbackFn): TransportRequestCallback
}
autoscaling: {
delete_autoscaling_policy, TContext = Context>(params?: RequestParams.AutoscalingDeleteAutoscalingPolicy, options?: TransportRequestOptions): TransportRequestPromise>
delete_autoscaling_policy, TContext = Context>(callback: callbackFn): TransportRequestCallback
delete_autoscaling_policy, TContext = Context>(params: RequestParams.AutoscalingDeleteAutoscalingPolicy, callback: callbackFn): TransportRequestCallback
delete_autoscaling_policy, TContext = Context>(params: RequestParams.AutoscalingDeleteAutoscalingPolicy, options: TransportRequestOptions, callback: callbackFn): TransportRequestCallback
deleteAutoscalingPolicy, TContext = Context>(params?: RequestParams.AutoscalingDeleteAutoscalingPolicy, options?: TransportRequestOptions): TransportRequestPromise>
deleteAutoscalingPolicy, TContext = Context>(callback: callbackFn): TransportRequestCallback
deleteAutoscalingPolicy, TContext = Context>(params: RequestParams.AutoscalingDeleteAutoscalingPolicy, callback: callbackFn): TransportRequestCallback
deleteAutoscalingPolicy, TContext = Context>(params: RequestParams.AutoscalingDeleteAutoscalingPolicy, options: TransportRequestOptions, callback: callbackFn): TransportRequestCallback
get_autoscaling_capacity, TContext = Context>(params?: RequestParams.AutoscalingGetAutoscalingCapacity, options?: TransportRequestOptions): TransportRequestPromise>
get_autoscaling_capacity, TContext = Context>(callback: callbackFn): TransportRequestCallback
get_autoscaling_capacity, TContext = Context>(params: RequestParams.AutoscalingGetAutoscalingCapacity, callback: callbackFn): TransportRequestCallback
get_autoscaling_capacity, TContext = Context>(params: RequestParams.AutoscalingGetAutoscalingCapacity, options: TransportRequestOptions, callback: callbackFn): TransportRequestCallback
getAutoscalingCapacity, TContext = Context>(params?: RequestParams.AutoscalingGetAutoscalingCapacity, options?: TransportRequestOptions): TransportRequestPromise>
getAutoscalingCapacity, TContext = Context>(callback: callbackFn): TransportRequestCallback
getAutoscalingCapacity, TContext = Context>(params: RequestParams.AutoscalingGetAutoscalingCapacity, callback: callbackFn): TransportRequestCallback
getAutoscalingCapacity, TContext = Context>(params: RequestParams.AutoscalingGetAutoscalingCapacity, options: TransportRequestOptions, callback: callbackFn): TransportRequestCallback
get_autoscaling_policy, TContext = Context>(params?: RequestParams.AutoscalingGetAutoscalingPolicy, options?: TransportRequestOptions): TransportRequestPromise>
get_autoscaling_policy, TContext = Context>(callback: callbackFn): TransportRequestCallback
get_autoscaling_policy, TContext = Context>(params: RequestParams.AutoscalingGetAutoscalingPolicy, callback: callbackFn): TransportRequestCallback
get_autoscaling_policy, TContext = Context>(params: RequestParams.AutoscalingGetAutoscalingPolicy, options: TransportRequestOptions, callback: callbackFn): TransportRequestCallback
getAutoscalingPolicy, TContext = Context>(params?: RequestParams.AutoscalingGetAutoscalingPolicy, options?: TransportRequestOptions): TransportRequestPromise>
getAutoscalingPolicy, TContext = Context>(callback: callbackFn): TransportRequestCallback
getAutoscalingPolicy, TContext = Context>(params: RequestParams.AutoscalingGetAutoscalingPolicy, callback: callbackFn): TransportRequestCallback
getAutoscalingPolicy, TContext = Context>(params: RequestParams.AutoscalingGetAutoscalingPolicy, options: TransportRequestOptions, callback: callbackFn): TransportRequestCallback
put_autoscaling_policy, TRequestBody extends RequestBody = Record, TContext = Context>(params?: RequestParams.AutoscalingPutAutoscalingPolicy, options?: TransportRequestOptions): TransportRequestPromise>
put_autoscaling_policy, TRequestBody extends RequestBody = Record, TContext = Context>(callback: callbackFn): TransportRequestCallback
put_autoscaling_policy, TRequestBody extends RequestBody = Record, TContext = Context>(params: RequestParams.AutoscalingPutAutoscalingPolicy, callback: callbackFn): TransportRequestCallback
put_autoscaling_policy, TRequestBody extends RequestBody = Record, TContext = Context>(params: RequestParams.AutoscalingPutAutoscalingPolicy, options: TransportRequestOptions, callback: callbackFn): TransportRequestCallback
putAutoscalingPolicy, TRequestBody extends RequestBody = Record, TContext = Context>(params?: RequestParams.AutoscalingPutAutoscalingPolicy, options?: TransportRequestOptions): TransportRequestPromise>
putAutoscalingPolicy, TRequestBody extends RequestBody = Record, TContext = Context>(callback: callbackFn): TransportRequestCallback
putAutoscalingPolicy, TRequestBody extends RequestBody = Record, TContext = Context>(params: RequestParams.AutoscalingPutAutoscalingPolicy, callback: callbackFn): TransportRequestCallback
putAutoscalingPolicy, TRequestBody extends RequestBody = Record, TContext = Context>(params: RequestParams.AutoscalingPutAutoscalingPolicy, options: TransportRequestOptions, callback: callbackFn): TransportRequestCallback
}
bulk, TRequestBody extends RequestNDBody = Record[], TContext = Context>(params?: RequestParams.Bulk, options?: TransportRequestOptions): TransportRequestPromise>
bulk, TRequestBody extends RequestNDBody = Record[], TContext = Context>(callback: callbackFn): TransportRequestCallback
bulk, TRequestBody extends RequestNDBody = Record[], TContext = Context>(params: RequestParams.Bulk, callback: callbackFn): TransportRequestCallback
bulk, TRequestBody extends RequestNDBody = Record[], TContext = Context>(params: RequestParams.Bulk, options: TransportRequestOptions, callback: callbackFn): TransportRequestCallback
cat: {
aliases, TContext = Context>(params?: RequestParams.CatAliases, options?: TransportRequestOptions): TransportRequestPromise>
aliases, TContext = Context>(callback: callbackFn): TransportRequestCallback
aliases, TContext = Context>(params: RequestParams.CatAliases, callback: callbackFn): TransportRequestCallback
aliases, TContext = Context>(params: RequestParams.CatAliases, options: TransportRequestOptions, callback: callbackFn): TransportRequestCallback
allocation, TContext = Context>(params?: RequestParams.CatAllocation, options?: TransportRequestOptions): TransportRequestPromise>
allocation, TContext = Context>(callback: callbackFn): TransportRequestCallback
allocation, TContext = Context>(params: RequestParams.CatAllocation, callback: callbackFn): TransportRequestCallback
allocation, TContext = Context>(params: RequestParams.CatAllocation, options: TransportRequestOptions, callback: callbackFn): TransportRequestCallback
count, TContext = Context>(params?: RequestParams.CatCount, options?: TransportRequestOptions): TransportRequestPromise>
count, TContext = Context>(callback: callbackFn): TransportRequestCallback
count, TContext = Context>(params: RequestParams.CatCount, callback: callbackFn): TransportRequestCallback
count, TContext = Context>(params: RequestParams.CatCount, options: TransportRequestOptions, callback: callbackFn): TransportRequestCallback
fielddata, TContext = Context>(params?: RequestParams.CatFielddata, options?: TransportRequestOptions): TransportRequestPromise>
fielddata, TContext = Context>(callback: callbackFn): TransportRequestCallback
fielddata, TContext = Context>(params: RequestParams.CatFielddata, callback: callbackFn): TransportRequestCallback
fielddata, TContext = Context>(params: RequestParams.CatFielddata, options: TransportRequestOptions, callback: callbackFn): TransportRequestCallback
health, TContext = Context>(params?: RequestParams.CatHealth, options?: TransportRequestOptions): TransportRequestPromise>
health, TContext = Context>(callback: callbackFn): TransportRequestCallback
health, TContext = Context>(params: RequestParams.CatHealth, callback: callbackFn): TransportRequestCallback
health, TContext = Context>(params: RequestParams.CatHealth, options: TransportRequestOptions, callback: callbackFn): TransportRequestCallback
help, TContext = Context>(params?: RequestParams.CatHelp, options?: TransportRequestOptions): TransportRequestPromise>
help, TContext = Context>(callback: callbackFn): TransportRequestCallback
help, TContext = Context>(params: RequestParams.CatHelp, callback: callbackFn): TransportRequestCallback
help, TContext = Context>(params: RequestParams.CatHelp, options: TransportRequestOptions, callback: callbackFn): TransportRequestCallback
indices, TContext = Context>(params?: RequestParams.CatIndices, options?: TransportRequestOptions): TransportRequestPromise>
indices, TContext = Context>(callback: callbackFn): TransportRequestCallback
indices, TContext = Context>(params: RequestParams.CatIndices, callback: callbackFn): TransportRequestCallback
indices, TContext = Context>(params: RequestParams.CatIndices, options: TransportRequestOptions, callback: callbackFn): TransportRequestCallback
master, TContext = Context>(params?: RequestParams.CatMaster, options?: TransportRequestOptions): TransportRequestPromise>
master, TContext = Context>(callback: callbackFn): TransportRequestCallback
master, TContext = Context>(params: RequestParams.CatMaster, callback: callbackFn): TransportRequestCallback
master, TContext = Context>(params: RequestParams.CatMaster, options: TransportRequestOptions, callback: callbackFn): TransportRequestCallback
ml_data_frame_analytics, TContext = Context>(params?: RequestParams.CatMlDataFrameAnalytics, options?: TransportRequestOptions): TransportRequestPromise>
ml_data_frame_analytics, TContext = Context>(callback: callbackFn): TransportRequestCallback
ml_data_frame_analytics, TContext = Context>(params: RequestParams.CatMlDataFrameAnalytics, callback: callbackFn): TransportRequestCallback
ml_data_frame_analytics, TContext = Context>(params: RequestParams.CatMlDataFrameAnalytics, options: TransportRequestOptions, callback: callbackFn): TransportRequestCallback
mlDataFrameAnalytics, TContext = Context>(params?: RequestParams.CatMlDataFrameAnalytics, options?: TransportRequestOptions): TransportRequestPromise>
mlDataFrameAnalytics, TContext = Context>(callback: callbackFn): TransportRequestCallback
mlDataFrameAnalytics, TContext = Context>(params: RequestParams.CatMlDataFrameAnalytics, callback: callbackFn