// 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 { EventEmitter } from 'events';
import { ConnectionOptions as TlsConnectionOptions } from 'tls';
import Transport, {
ApiResponse,
RequestEvent,
TransportRequestParams,
TransportRequestOptions,
nodeFilterFn,
nodeSelectorFn,
generateRequestIdFn,
TransportRequestCallback
} from './lib/Transport';
import { URL } from 'url';
import Connection, { AgentOptions, agentFn } from './lib/Connection';
import ConnectionPool, { ResurrectEvent } from './lib/ConnectionPool';
import Serializer from './lib/Serializer';
import * as RequestParams from './api/requestParams';
import * as errors from './lib/errors';
declare type anyObject = {
[key: string]: any;
};
declare type callbackFn = (err: Error | null, result: ApiResponse) => void;
interface ApiMethod {
// Promise API
(): Promise>;
(params: TParams): Promise>;
(params: TParams, options: TransportRequestOptions): Promise>;
// Callback API
(callback: callbackFn): TransportRequestCallback;
(params: TParams, callback: callbackFn): TransportRequestCallback;
(params: TParams, options: TransportRequestOptions, callback: callbackFn): TransportRequestCallback;
}
// 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?: anyObject;
roles?: {
master: boolean;
data: boolean;
ingest: boolean;
ml: boolean;
}
}
interface ClientOptions {
node?: string | string[] | NodeOptions | NodeOptions[];
nodes?: string | string[];
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?: anyObject;
generateRequestId?: generateRequestIdFn;
name?: string;
cloud?: {
id: string;
username: string;
password: string;
}
}
declare class Client extends EventEmitter {
constructor(opts?: ClientOptions);
connectionPool: ConnectionPool;
transport: Transport;
serializer: Serializer;
extend: ClientExtends;
child(opts?: ClientOptions): Client;
close(callback?: Function): Promise | void;
/* GENERATED */
bulk: ApiMethod
cat: {
aliases: ApiMethod
allocation: ApiMethod
count: ApiMethod
fielddata: ApiMethod
health: ApiMethod
help: ApiMethod
indices: ApiMethod
master: ApiMethod
nodeattrs: ApiMethod
nodes: ApiMethod
pending_tasks: ApiMethod
pendingTasks: ApiMethod
plugins: ApiMethod
recovery: ApiMethod
repositories: ApiMethod
segments: ApiMethod
shards: ApiMethod
snapshots: ApiMethod
tasks: ApiMethod
templates: ApiMethod
thread_pool: ApiMethod
threadPool: ApiMethod
}
clear_scroll: ApiMethod
clearScroll: ApiMethod
cluster: {
allocation_explain: ApiMethod
allocationExplain: ApiMethod
get_settings: ApiMethod
getSettings: ApiMethod
health: ApiMethod
pending_tasks: ApiMethod
pendingTasks: ApiMethod
put_settings: ApiMethod
putSettings: ApiMethod
remote_info: ApiMethod
remoteInfo: ApiMethod
reroute: ApiMethod
state: ApiMethod
stats: ApiMethod
}
count: ApiMethod
count_percolate: ApiMethod
countPercolate: ApiMethod
create: ApiMethod
delete: ApiMethod
delete_by_query: ApiMethod
deleteByQuery: ApiMethod
delete_script: ApiMethod
deleteScript: ApiMethod
delete_template: ApiMethod
deleteTemplate: ApiMethod
exists: ApiMethod
exists_source: ApiMethod
existsSource: ApiMethod
explain: ApiMethod
field_caps: ApiMethod
fieldCaps: ApiMethod
field_stats: ApiMethod
fieldStats: ApiMethod
get: ApiMethod
get_script: ApiMethod
getScript: ApiMethod
get_source: ApiMethod
getSource: ApiMethod
get_template: ApiMethod
getTemplate: ApiMethod
index: ApiMethod
indices: {
analyze: ApiMethod
clear_cache: ApiMethod
clearCache: ApiMethod
close: ApiMethod
create: ApiMethod
delete: ApiMethod
delete_alias: ApiMethod
deleteAlias: ApiMethod
delete_template: ApiMethod
deleteTemplate: ApiMethod
exists: ApiMethod
exists_alias: ApiMethod
existsAlias: ApiMethod
exists_template: ApiMethod
existsTemplate: ApiMethod
exists_type: ApiMethod
existsType: ApiMethod
flush: ApiMethod
flush_synced: ApiMethod
flushSynced: ApiMethod
forcemerge: ApiMethod
get: ApiMethod
get_alias: ApiMethod
getAlias: ApiMethod
get_field_mapping: ApiMethod
getFieldMapping: ApiMethod
get_mapping: ApiMethod
getMapping: ApiMethod
get_settings: ApiMethod
getSettings: ApiMethod
get_template: ApiMethod
getTemplate: ApiMethod
get_upgrade: ApiMethod
getUpgrade: ApiMethod
open: ApiMethod
put_alias: ApiMethod
putAlias: ApiMethod
put_mapping: ApiMethod
putMapping: ApiMethod
put_settings: ApiMethod
putSettings: ApiMethod
put_template: ApiMethod
putTemplate: ApiMethod
recovery: ApiMethod
refresh: ApiMethod
rollover: ApiMethod
segments: ApiMethod
shard_stores: ApiMethod
shardStores: ApiMethod
shrink: ApiMethod
stats: ApiMethod
update_aliases: ApiMethod
updateAliases: ApiMethod
upgrade: ApiMethod
validate_query: ApiMethod
validateQuery: ApiMethod
}
info: ApiMethod
ingest: {
delete_pipeline: ApiMethod
deletePipeline: ApiMethod
get_pipeline: ApiMethod
getPipeline: ApiMethod
processor_grok: ApiMethod
processorGrok: ApiMethod
put_pipeline: ApiMethod
putPipeline: ApiMethod
simulate: ApiMethod
}
mget: ApiMethod
mpercolate: ApiMethod
msearch: ApiMethod
msearch_template: ApiMethod
msearchTemplate: ApiMethod
mtermvectors: ApiMethod
nodes: {
hot_threads: ApiMethod
hotThreads: ApiMethod
info: ApiMethod
stats: ApiMethod
}
percolate: ApiMethod
ping: ApiMethod
put_script: ApiMethod
putScript: ApiMethod
put_template: ApiMethod
putTemplate: ApiMethod
reindex: ApiMethod
reindex_rethrottle: ApiMethod
reindexRethrottle: ApiMethod
render_search_template: ApiMethod
renderSearchTemplate: ApiMethod
scroll: ApiMethod
search: ApiMethod
search_shards: ApiMethod
searchShards: ApiMethod
search_template: ApiMethod
searchTemplate: ApiMethod
snapshot: {
create: ApiMethod
create_repository: ApiMethod
createRepository: ApiMethod
delete: ApiMethod
delete_repository: ApiMethod
deleteRepository: ApiMethod
get: ApiMethod
get_repository: ApiMethod
getRepository: ApiMethod
restore: ApiMethod
status: ApiMethod
verify_repository: ApiMethod
verifyRepository: ApiMethod
}
suggest: ApiMethod
tasks: {
cancel: ApiMethod
get: ApiMethod
list: ApiMethod
}
termvectors: ApiMethod
update: ApiMethod
update_by_query: ApiMethod
updateByQuery: ApiMethod
/* /GENERATED */
}
declare const events: {
RESPONSE: string;
REQUEST: string;
SNIFF: string;
RESURRECT: string;
};
export {
Client,
Transport,
ConnectionPool,
Connection,
Serializer,
events,
errors,
ApiResponse,
RequestEvent,
ResurrectEvent,
RequestParams,
ClientOptions,
NodeOptions,
ClientExtendsCallbackOptions
};