/* * 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 } from './lib/pool'; import Serializer from './lib/Serializer'; import Helpers from './lib/Helpers'; import * as errors from './lib/errors'; import ESAPI from './api/esapi' import * as estypes from './api/types' // 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; 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'; } declare class Client extends ESAPI { 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(): Promise; 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; } declare const events: { SERIALIZATION: string; REQUEST: string; DESERIALIZATION: string; RESPONSE: string; SNIFF: string; RESURRECT: string; }; export { Client, Transport, ConnectionPool, BaseConnectionPool, CloudConnectionPool, Connection, Serializer, events, errors, ApiError, ApiResponse, RequestEvent, ResurrectEvent, estypes, ClientOptions, NodeOptions, ClientExtendsCallbackOptions };