From 76b67594422d09369da6fb931f56f177066fc903 Mon Sep 17 00:00:00 2001 From: pgayvallet Date: Fri, 3 Jul 2020 13:44:49 +0200 Subject: [PATCH] Remove generated facade, use ES Client directly --- ...tils-common-state_containers.comparator.md | 2 +- ...a_utils-common-state_containers.connect.md | 2 +- ...state_containers.createstatecontainer_1.md | 2 +- ...state_containers.createstatecontainer_2.md | 2 +- ...ners.createstatecontaineroptions.freeze.md | 2 +- ..._containers.createstatecontaineroptions.md | 2 +- ...ns-kibana_utils-common-state_containers.md | 12 +- ...tate_containers.reduxlikestatecontainer.md | 2 +- ...-common-state_containers.statecontainer.md | 2 +- .../kibana_utils/public/state_sync/index.md | 2 +- ...ic-state_sync.ikbnurlstatestorage.flush.md | 2 +- ...s-public-state_sync.ikbnurlstatestorage.md | 8 +- ...-state_sync.inullablebasestatecontainer.md | 2 +- ...-public-state_sync.istatestorage.cancel.md | 2 +- ...a_utils-public-state_sync.istatestorage.md | 2 +- ...-plugins-kibana_utils-public-state_sync.md | 12 +- ...ibana_utils-public-state_sync.syncstate.md | 16 +- .../client/client_facade.mock.ts | 416 ---- .../elasticsearch/client/client_facade.ts | 1858 ----------------- .../client/cluster_client.test.mocks.ts | 5 - .../client/cluster_client.test.ts | 167 +- .../elasticsearch/client/cluster_client.ts | 44 +- .../client/get_client_facade.test.ts | 87 - .../elasticsearch/client/get_client_facade.ts | 534 ----- src/core/server/elasticsearch/client/index.ts | 2 +- .../server/elasticsearch/client/mocks.test.ts | 60 + src/core/server/elasticsearch/client/mocks.ts | 59 +- .../client/scoped_cluster_client.test.ts | 8 +- .../client/scoped_cluster_client.ts | 14 +- .../core/server/elasticsearch/client/types.ts | 25 +- src/core/server/elasticsearch/index.ts | 2 +- src/core/server/server.api.md | 7 +- src/dev/generate_es_client.ts | 151 -- 33 files changed, 317 insertions(+), 3196 deletions(-) delete mode 100644 src/core/server/elasticsearch/client/client_facade.mock.ts delete mode 100644 src/core/server/elasticsearch/client/client_facade.ts delete mode 100644 src/core/server/elasticsearch/client/get_client_facade.test.ts delete mode 100644 src/core/server/elasticsearch/client/get_client_facade.ts create mode 100644 src/core/server/elasticsearch/client/mocks.test.ts rename scripts/generate_es_client.js => src/core/server/elasticsearch/client/types.ts (59%) delete mode 100644 src/dev/generate_es_client.ts diff --git a/docs/development/plugins/kibana_utils/common/state_containers/kibana-plugin-plugins-kibana_utils-common-state_containers.comparator.md b/docs/development/plugins/kibana_utils/common/state_containers/kibana-plugin-plugins-kibana_utils-common-state_containers.comparator.md index 12af33756fb19d2..f429866848aa4db 100644 --- a/docs/development/plugins/kibana_utils/common/state_containers/kibana-plugin-plugins-kibana_utils-common-state_containers.comparator.md +++ b/docs/development/plugins/kibana_utils/common/state_containers/kibana-plugin-plugins-kibana_utils-common-state_containers.comparator.md @@ -4,7 +4,7 @@ ## Comparator type -Used to compare state. see [useContainerSelector](./kibana-plugin-plugins-kibana_utils-common-state_containers.usecontainerselector.md) +Used to compare state, see [useContainerSelector](./kibana-plugin-plugins-kibana_utils-common-state_containers.usecontainerselector.md). Signature: diff --git a/docs/development/plugins/kibana_utils/common/state_containers/kibana-plugin-plugins-kibana_utils-common-state_containers.connect.md b/docs/development/plugins/kibana_utils/common/state_containers/kibana-plugin-plugins-kibana_utils-common-state_containers.connect.md index e05f1fb392fe6e0..ca68c47ddaa7e7b 100644 --- a/docs/development/plugins/kibana_utils/common/state_containers/kibana-plugin-plugins-kibana_utils-common-state_containers.connect.md +++ b/docs/development/plugins/kibana_utils/common/state_containers/kibana-plugin-plugins-kibana_utils-common-state_containers.connect.md @@ -4,7 +4,7 @@ ## Connect type -Similar to `connect` from react-redux, allows to map state from state container to component's props +Similar to `connect` from react-redux, allows to map state from state container to component's props. Signature: diff --git a/docs/development/plugins/kibana_utils/common/state_containers/kibana-plugin-plugins-kibana_utils-common-state_containers.createstatecontainer_1.md b/docs/development/plugins/kibana_utils/common/state_containers/kibana-plugin-plugins-kibana_utils-common-state_containers.createstatecontainer_1.md index 794bf63588312f2..8aadd0a234a8af5 100644 --- a/docs/development/plugins/kibana_utils/common/state_containers/kibana-plugin-plugins-kibana_utils-common-state_containers.createstatecontainer_1.md +++ b/docs/development/plugins/kibana_utils/common/state_containers/kibana-plugin-plugins-kibana_utils-common-state_containers.createstatecontainer_1.md @@ -4,7 +4,7 @@ ## createStateContainer() function -Creates a state container with transitions, but without selectors +Creates a state container with transitions, but without selectors. Signature: diff --git a/docs/development/plugins/kibana_utils/common/state_containers/kibana-plugin-plugins-kibana_utils-common-state_containers.createstatecontainer_2.md b/docs/development/plugins/kibana_utils/common/state_containers/kibana-plugin-plugins-kibana_utils-common-state_containers.createstatecontainer_2.md index 1946baae202f1df..bb06ca18e808adb 100644 --- a/docs/development/plugins/kibana_utils/common/state_containers/kibana-plugin-plugins-kibana_utils-common-state_containers.createstatecontainer_2.md +++ b/docs/development/plugins/kibana_utils/common/state_containers/kibana-plugin-plugins-kibana_utils-common-state_containers.createstatecontainer_2.md @@ -4,7 +4,7 @@ ## createStateContainer() function -Creates a state container with transitions and selectors +Creates a state container with transitions and selectors. Signature: diff --git a/docs/development/plugins/kibana_utils/common/state_containers/kibana-plugin-plugins-kibana_utils-common-state_containers.createstatecontaineroptions.freeze.md b/docs/development/plugins/kibana_utils/common/state_containers/kibana-plugin-plugins-kibana_utils-common-state_containers.createstatecontaineroptions.freeze.md index 4f772c7c54d084d..0b05775ad1458f4 100644 --- a/docs/development/plugins/kibana_utils/common/state_containers/kibana-plugin-plugins-kibana_utils-common-state_containers.createstatecontaineroptions.freeze.md +++ b/docs/development/plugins/kibana_utils/common/state_containers/kibana-plugin-plugins-kibana_utils-common-state_containers.createstatecontaineroptions.freeze.md @@ -4,7 +4,7 @@ ## CreateStateContainerOptions.freeze property -Function to use when freezing state. Supply identity function. If not provided, default deepFreeze is use. +Function to use when freezing state. Supply identity function. If not provided, default `deepFreeze` is used. Signature: diff --git a/docs/development/plugins/kibana_utils/common/state_containers/kibana-plugin-plugins-kibana_utils-common-state_containers.createstatecontaineroptions.md b/docs/development/plugins/kibana_utils/common/state_containers/kibana-plugin-plugins-kibana_utils-common-state_containers.createstatecontaineroptions.md index d328d306e93e1d9..8dba1b647edf405 100644 --- a/docs/development/plugins/kibana_utils/common/state_containers/kibana-plugin-plugins-kibana_utils-common-state_containers.createstatecontaineroptions.md +++ b/docs/development/plugins/kibana_utils/common/state_containers/kibana-plugin-plugins-kibana_utils-common-state_containers.createstatecontaineroptions.md @@ -16,5 +16,5 @@ export interface CreateStateContainerOptions | Property | Type | Description | | --- | --- | --- | -| [freeze](./kibana-plugin-plugins-kibana_utils-common-state_containers.createstatecontaineroptions.freeze.md) | <T>(state: T) => T | Function to use when freezing state. Supply identity function. If not provided, default deepFreeze is use. | +| [freeze](./kibana-plugin-plugins-kibana_utils-common-state_containers.createstatecontaineroptions.freeze.md) | <T>(state: T) => T | Function to use when freezing state. Supply identity function. If not provided, default deepFreeze is used. | diff --git a/docs/development/plugins/kibana_utils/common/state_containers/kibana-plugin-plugins-kibana_utils-common-state_containers.md b/docs/development/plugins/kibana_utils/common/state_containers/kibana-plugin-plugins-kibana_utils-common-state_containers.md index e74ff2c6885be1e..7cabb72cecb31d1 100644 --- a/docs/development/plugins/kibana_utils/common/state_containers/kibana-plugin-plugins-kibana_utils-common-state_containers.md +++ b/docs/development/plugins/kibana_utils/common/state_containers/kibana-plugin-plugins-kibana_utils-common-state_containers.md @@ -11,8 +11,8 @@ State containers are Redux-store-like objects meant to help you manage state in | Function | Description | | --- | --- | | [createStateContainer(defaultState)](./kibana-plugin-plugins-kibana_utils-common-state_containers.createstatecontainer.md) | Creates a state container without transitions and without selectors. | -| [createStateContainer(defaultState, pureTransitions)](./kibana-plugin-plugins-kibana_utils-common-state_containers.createstatecontainer_1.md) | Creates a state container with transitions, but without selectors | -| [createStateContainer(defaultState, pureTransitions, pureSelectors, options)](./kibana-plugin-plugins-kibana_utils-common-state_containers.createstatecontainer_2.md) | Creates a state container with transitions and selectors | +| [createStateContainer(defaultState, pureTransitions)](./kibana-plugin-plugins-kibana_utils-common-state_containers.createstatecontainer_1.md) | Creates a state container with transitions, but without selectors. | +| [createStateContainer(defaultState, pureTransitions, pureSelectors, options)](./kibana-plugin-plugins-kibana_utils-common-state_containers.createstatecontainer_2.md) | Creates a state container with transitions and selectors. | ## Interfaces @@ -20,8 +20,8 @@ State containers are Redux-store-like objects meant to help you manage state in | --- | --- | | [BaseStateContainer](./kibana-plugin-plugins-kibana_utils-common-state_containers.basestatecontainer.md) | Base state container shape without transitions or selectors | | [CreateStateContainerOptions](./kibana-plugin-plugins-kibana_utils-common-state_containers.createstatecontaineroptions.md) | State container options | -| [ReduxLikeStateContainer](./kibana-plugin-plugins-kibana_utils-common-state_containers.reduxlikestatecontainer.md) | Fully featured state container which matches Redux store interface. Extends [StateContainer](./kibana-plugin-plugins-kibana_utils-common-state_containers.statecontainer.md) Allows to use state container with redux libraries | -| [StateContainer](./kibana-plugin-plugins-kibana_utils-common-state_containers.statecontainer.md) | Fully featured state container with [Selectors](./kibana-plugin-plugins-kibana_utils-common-state_containers.selector.md) and . Extends [BaseStateContainer](./kibana-plugin-plugins-kibana_utils-common-state_containers.basestatecontainer.md) | +| [ReduxLikeStateContainer](./kibana-plugin-plugins-kibana_utils-common-state_containers.reduxlikestatecontainer.md) | Fully featured state container which matches Redux store interface. Extends [StateContainer](./kibana-plugin-plugins-kibana_utils-common-state_containers.statecontainer.md). Allows to use state container with redux libraries. | +| [StateContainer](./kibana-plugin-plugins-kibana_utils-common-state_containers.statecontainer.md) | Fully featured state container with [Selectors](./kibana-plugin-plugins-kibana_utils-common-state_containers.selector.md) and . Extends [BaseStateContainer](./kibana-plugin-plugins-kibana_utils-common-state_containers.basestatecontainer.md). | ## Variables @@ -36,8 +36,8 @@ State containers are Redux-store-like objects meant to help you manage state in | Type Alias | Description | | --- | --- | | [BaseState](./kibana-plugin-plugins-kibana_utils-common-state_containers.basestate.md) | Base [StateContainer](./kibana-plugin-plugins-kibana_utils-common-state_containers.statecontainer.md) state shape | -| [Comparator](./kibana-plugin-plugins-kibana_utils-common-state_containers.comparator.md) | Used to compare state. see [useContainerSelector](./kibana-plugin-plugins-kibana_utils-common-state_containers.usecontainerselector.md) | -| [Connect](./kibana-plugin-plugins-kibana_utils-common-state_containers.connect.md) | Similar to connect from react-redux, allows to map state from state container to component's props | +| [Comparator](./kibana-plugin-plugins-kibana_utils-common-state_containers.comparator.md) | Used to compare state, see [useContainerSelector](./kibana-plugin-plugins-kibana_utils-common-state_containers.usecontainerselector.md). | +| [Connect](./kibana-plugin-plugins-kibana_utils-common-state_containers.connect.md) | Similar to connect from react-redux, allows to map state from state container to component's props. | | [Dispatch](./kibana-plugin-plugins-kibana_utils-common-state_containers.dispatch.md) | Redux like dispatch | | [EnsurePureSelector](./kibana-plugin-plugins-kibana_utils-common-state_containers.ensurepureselector.md) | | | [EnsurePureTransition](./kibana-plugin-plugins-kibana_utils-common-state_containers.ensurepuretransition.md) | | diff --git a/docs/development/plugins/kibana_utils/common/state_containers/kibana-plugin-plugins-kibana_utils-common-state_containers.reduxlikestatecontainer.md b/docs/development/plugins/kibana_utils/common/state_containers/kibana-plugin-plugins-kibana_utils-common-state_containers.reduxlikestatecontainer.md index 0e08119c1eae442..1229f4c2998f85f 100644 --- a/docs/development/plugins/kibana_utils/common/state_containers/kibana-plugin-plugins-kibana_utils-common-state_containers.reduxlikestatecontainer.md +++ b/docs/development/plugins/kibana_utils/common/state_containers/kibana-plugin-plugins-kibana_utils-common-state_containers.reduxlikestatecontainer.md @@ -4,7 +4,7 @@ ## ReduxLikeStateContainer interface -Fully featured state container which matches Redux store interface. Extends [StateContainer](./kibana-plugin-plugins-kibana_utils-common-state_containers.statecontainer.md) Allows to use state container with redux libraries +Fully featured state container which matches Redux store interface. Extends [StateContainer](./kibana-plugin-plugins-kibana_utils-common-state_containers.statecontainer.md). Allows to use state container with redux libraries. Signature: diff --git a/docs/development/plugins/kibana_utils/common/state_containers/kibana-plugin-plugins-kibana_utils-common-state_containers.statecontainer.md b/docs/development/plugins/kibana_utils/common/state_containers/kibana-plugin-plugins-kibana_utils-common-state_containers.statecontainer.md index 23ec1c8e5be0106..5d47540c824b0aa 100644 --- a/docs/development/plugins/kibana_utils/common/state_containers/kibana-plugin-plugins-kibana_utils-common-state_containers.statecontainer.md +++ b/docs/development/plugins/kibana_utils/common/state_containers/kibana-plugin-plugins-kibana_utils-common-state_containers.statecontainer.md @@ -4,7 +4,7 @@ ## StateContainer interface -Fully featured state container with [Selectors](./kibana-plugin-plugins-kibana_utils-common-state_containers.selector.md) and . Extends [BaseStateContainer](./kibana-plugin-plugins-kibana_utils-common-state_containers.basestatecontainer.md) +Fully featured state container with [Selectors](./kibana-plugin-plugins-kibana_utils-common-state_containers.selector.md) and . Extends [BaseStateContainer](./kibana-plugin-plugins-kibana_utils-common-state_containers.basestatecontainer.md). Signature: diff --git a/docs/development/plugins/kibana_utils/public/state_sync/index.md b/docs/development/plugins/kibana_utils/public/state_sync/index.md index 4b345d9130bd543..5625e4a4b5eb859 100644 --- a/docs/development/plugins/kibana_utils/public/state_sync/index.md +++ b/docs/development/plugins/kibana_utils/public/state_sync/index.md @@ -8,5 +8,5 @@ | Package | Description | | --- | --- | -| [kibana-plugin-plugins-kibana\_utils-public-state\_sync](./kibana-plugin-plugins-kibana_utils-public-state_sync.md) | State syncing utilities are a set of helpers for syncing your application state with URL or browser storage.They are designed to work together with state containers (). But state containers are not required.State syncing utilities include:- util which: - Subscribes to state changes and pushes them to state storage. - Optionally subscribes to state storage changes and pushes them to state. - Two types of storage compatible with syncState: - - Serializes state and persists it to URL's query param in rison or hashed format. Listens for state updates in the URL and pushes them back to state. - - Serializes state and persists it to browser storage.Refer [here](https://github.com/elastic/kibana/tree/master/src/plugins/kibana_utils/docs/state_sync) for a complete guide and examples | +| [kibana-plugin-plugins-kibana\_utils-public-state\_sync](./kibana-plugin-plugins-kibana_utils-public-state_sync.md) | State syncing utilities are a set of helpers for syncing your application state with browser URL or browser storage.They are designed to work together with [state containers](https://github.com/elastic/kibana/tree/master/src/plugins/kibana_utils/docs/state_containers). But state containers are not required.State syncing utilities include:\* util which: \* Subscribes to state changes and pushes them to state storage. \* Optionally subscribes to state storage changes and pushes them to state. \* Two types of storages compatible with syncState: \* - Serializes state and persists it to URL's query param in rison or hashed format. Listens for state updates in the URL and pushes them back to state. \* - Serializes state and persists it to browser storage.Refer [here](https://github.com/elastic/kibana/tree/master/src/plugins/kibana_utils/docs/state_sync) for a complete guide and examples. | diff --git a/docs/development/plugins/kibana_utils/public/state_sync/kibana-plugin-plugins-kibana_utils-public-state_sync.ikbnurlstatestorage.flush.md b/docs/development/plugins/kibana_utils/public/state_sync/kibana-plugin-plugins-kibana_utils-public-state_sync.ikbnurlstatestorage.flush.md index e0e6aa9be4368b9..dfeef1cdce22c6f 100644 --- a/docs/development/plugins/kibana_utils/public/state_sync/kibana-plugin-plugins-kibana_utils-public-state_sync.ikbnurlstatestorage.flush.md +++ b/docs/development/plugins/kibana_utils/public/state_sync/kibana-plugin-plugins-kibana_utils-public-state_sync.ikbnurlstatestorage.flush.md @@ -4,7 +4,7 @@ ## IKbnUrlStateStorage.flush property -synchronously runs any pending url updates returned boolean indicates if change occurred +Synchronously runs any pending url updates, returned boolean indicates if change occurred. Signature: diff --git a/docs/development/plugins/kibana_utils/public/state_sync/kibana-plugin-plugins-kibana_utils-public-state_sync.ikbnurlstatestorage.md b/docs/development/plugins/kibana_utils/public/state_sync/kibana-plugin-plugins-kibana_utils-public-state_sync.ikbnurlstatestorage.md index 56cefebd2acfe63..371f7b7c15362e9 100644 --- a/docs/development/plugins/kibana_utils/public/state_sync/kibana-plugin-plugins-kibana_utils-public-state_sync.ikbnurlstatestorage.md +++ b/docs/development/plugins/kibana_utils/public/state_sync/kibana-plugin-plugins-kibana_utils-public-state_sync.ikbnurlstatestorage.md @@ -4,7 +4,11 @@ ## IKbnUrlStateStorage interface -KbnUrlStateStorage is a state storage for [syncState()](./kibana-plugin-plugins-kibana_utils-public-state_sync.syncstate.md) utility which: 1. Keeps state in sync with the URL. 2. Serializes data and stores it in the URL in one of the supported formats: \* Rison encoded. \* Hashed URL: In URL we store only the hash from the serialized state, but the state itself is stored in sessionStorage. See kibana's advanced option for more context state:storeInSessionStorage 3. Takes care of listening to the URL updates and notifies state about the updates. 4. Takes care of batching URL updates to prevent redundant browser history records. [GUIDE](https://github.com/elastic/kibana/blob/master/src/plugins/kibana_utils/docs/state_sync/storages/kbn_url_storage.md) +KbnUrlStateStorage is a state storage for [syncState()](./kibana-plugin-plugins-kibana_utils-public-state_sync.syncstate.md) utility which: + +1. Keeps state in sync with the URL. 2. Serializes data and stores it in the URL in one of the supported formats: \* Rison encoded. \* Hashed URL: In URL we store only the hash from the serialized state, but the state itself is stored in sessionStorage. See Kibana's `state:storeInSessionStorage` advanced option for more context. 3. Takes care of listening to the URL updates and notifies state about the updates. 4. Takes care of batching URL updates to prevent redundant browser history records. + +[Refer to this guide for more info](https://github.com/elastic/kibana/blob/master/src/plugins/kibana_utils/docs/state_sync/storages/kbn_url_storage.md) Signature: @@ -18,7 +22,7 @@ export interface IKbnUrlStateStorage extends IStateStorage | --- | --- | --- | | [cancel](./kibana-plugin-plugins-kibana_utils-public-state_sync.ikbnurlstatestorage.cancel.md) | () => void | cancels any pending url updates | | [change$](./kibana-plugin-plugins-kibana_utils-public-state_sync.ikbnurlstatestorage.change_.md) | <State = unknown>(key: string) => Observable<State | null> | | -| [flush](./kibana-plugin-plugins-kibana_utils-public-state_sync.ikbnurlstatestorage.flush.md) | (opts?: {
replace?: boolean;
}) => boolean | synchronously runs any pending url updates returned boolean indicates if change occurred | +| [flush](./kibana-plugin-plugins-kibana_utils-public-state_sync.ikbnurlstatestorage.flush.md) | (opts?: {
replace?: boolean;
}) => boolean | Synchronously runs any pending url updates, returned boolean indicates if change occurred. | | [get](./kibana-plugin-plugins-kibana_utils-public-state_sync.ikbnurlstatestorage.get.md) | <State = unknown>(key: string) => State | null | | | [set](./kibana-plugin-plugins-kibana_utils-public-state_sync.ikbnurlstatestorage.set.md) | <State>(key: string, state: State, opts?: {
replace: boolean;
}) => Promise<string | undefined> | | diff --git a/docs/development/plugins/kibana_utils/public/state_sync/kibana-plugin-plugins-kibana_utils-public-state_sync.inullablebasestatecontainer.md b/docs/development/plugins/kibana_utils/public/state_sync/kibana-plugin-plugins-kibana_utils-public-state_sync.inullablebasestatecontainer.md index ca69609936405cb..d81694484c3c0b8 100644 --- a/docs/development/plugins/kibana_utils/public/state_sync/kibana-plugin-plugins-kibana_utils-public-state_sync.inullablebasestatecontainer.md +++ b/docs/development/plugins/kibana_utils/public/state_sync/kibana-plugin-plugins-kibana_utils-public-state_sync.inullablebasestatecontainer.md @@ -14,7 +14,7 @@ export interface INullableBaseStateContainer extends Ba ## Remarks -State container for stateSync() have to accept "null" for example, set() implementation could handle null and fallback to some default state this is required to handle edge case, when state in storage becomes empty and syncing is in progress. state container will be notified about about storage becoming empty with null passed in +State container for `stateSync()` have to accept `null` for example, `set()` implementation could handle null and fallback to some default state this is required to handle edge case, when state in storage becomes empty and syncing is in progress. State container will be notified about about storage becoming empty with null passed in. ## Properties diff --git a/docs/development/plugins/kibana_utils/public/state_sync/kibana-plugin-plugins-kibana_utils-public-state_sync.istatestorage.cancel.md b/docs/development/plugins/kibana_utils/public/state_sync/kibana-plugin-plugins-kibana_utils-public-state_sync.istatestorage.cancel.md index ce771d52a6e60f7..13bacfae9ef56c7 100644 --- a/docs/development/plugins/kibana_utils/public/state_sync/kibana-plugin-plugins-kibana_utils-public-state_sync.istatestorage.cancel.md +++ b/docs/development/plugins/kibana_utils/public/state_sync/kibana-plugin-plugins-kibana_utils-public-state_sync.istatestorage.cancel.md @@ -4,7 +4,7 @@ ## IStateStorage.cancel property -Optional method to cancel any pending activity syncState() will call it, if it is provided by IStateStorage +Optional method to cancel any pending activity [syncState()](./kibana-plugin-plugins-kibana_utils-public-state_sync.syncstate.md) will call it during destroy, if it is provided by IStateStorage Signature: diff --git a/docs/development/plugins/kibana_utils/public/state_sync/kibana-plugin-plugins-kibana_utils-public-state_sync.istatestorage.md b/docs/development/plugins/kibana_utils/public/state_sync/kibana-plugin-plugins-kibana_utils-public-state_sync.istatestorage.md index 2c34a185fb7b12e..82f7949dfdc0392 100644 --- a/docs/development/plugins/kibana_utils/public/state_sync/kibana-plugin-plugins-kibana_utils-public-state_sync.istatestorage.md +++ b/docs/development/plugins/kibana_utils/public/state_sync/kibana-plugin-plugins-kibana_utils-public-state_sync.istatestorage.md @@ -18,7 +18,7 @@ export interface IStateStorage | Property | Type | Description | | --- | --- | --- | -| [cancel](./kibana-plugin-plugins-kibana_utils-public-state_sync.istatestorage.cancel.md) | () => void | Optional method to cancel any pending activity syncState() will call it, if it is provided by IStateStorage | +| [cancel](./kibana-plugin-plugins-kibana_utils-public-state_sync.istatestorage.cancel.md) | () => void | Optional method to cancel any pending activity [syncState()](./kibana-plugin-plugins-kibana_utils-public-state_sync.syncstate.md) will call it during destroy, if it is provided by IStateStorage | | [change$](./kibana-plugin-plugins-kibana_utils-public-state_sync.istatestorage.change_.md) | <State = unknown>(key: string) => Observable<State | null> | Should notify when the stored state has changed | | [get](./kibana-plugin-plugins-kibana_utils-public-state_sync.istatestorage.get.md) | <State = unknown>(key: string) => State | null | Should retrieve state from the storage and deserialize it | | [set](./kibana-plugin-plugins-kibana_utils-public-state_sync.istatestorage.set.md) | <State>(key: string, state: State) => any | Take in a state object, should serialise and persist | diff --git a/docs/development/plugins/kibana_utils/public/state_sync/kibana-plugin-plugins-kibana_utils-public-state_sync.md b/docs/development/plugins/kibana_utils/public/state_sync/kibana-plugin-plugins-kibana_utils-public-state_sync.md index 2b02c98e0d60538..52919f78a035c48 100644 --- a/docs/development/plugins/kibana_utils/public/state_sync/kibana-plugin-plugins-kibana_utils-public-state_sync.md +++ b/docs/development/plugins/kibana_utils/public/state_sync/kibana-plugin-plugins-kibana_utils-public-state_sync.md @@ -4,28 +4,28 @@ ## kibana-plugin-plugins-kibana\_utils-public-state\_sync package -State syncing utilities are a set of helpers for syncing your application state with URL or browser storage. +State syncing utilities are a set of helpers for syncing your application state with browser URL or browser storage. -They are designed to work together with state containers (). But state containers are not required. +They are designed to work together with [state containers](https://github.com/elastic/kibana/tree/master/src/plugins/kibana_utils/docs/state_containers). But state containers are not required. State syncing utilities include: -- [syncState()](./kibana-plugin-plugins-kibana_utils-public-state_sync.syncstate.md) util which: - Subscribes to state changes and pushes them to state storage. - Optionally subscribes to state storage changes and pushes them to state. - Two types of storage compatible with `syncState`: - [IKbnUrlStateStorage](./kibana-plugin-plugins-kibana_utils-public-state_sync.ikbnurlstatestorage.md) - Serializes state and persists it to URL's query param in rison or hashed format. Listens for state updates in the URL and pushes them back to state. - [ISessionStorageStateStorage](./kibana-plugin-plugins-kibana_utils-public-state_sync.isessionstoragestatestorage.md) - Serializes state and persists it to browser storage. +\*[syncState()](./kibana-plugin-plugins-kibana_utils-public-state_sync.syncstate.md) util which: \* Subscribes to state changes and pushes them to state storage. \* Optionally subscribes to state storage changes and pushes them to state. \* Two types of storages compatible with `syncState`: \* [IKbnUrlStateStorage](./kibana-plugin-plugins-kibana_utils-public-state_sync.ikbnurlstatestorage.md) - Serializes state and persists it to URL's query param in rison or hashed format. Listens for state updates in the URL and pushes them back to state. \* [ISessionStorageStateStorage](./kibana-plugin-plugins-kibana_utils-public-state_sync.isessionstoragestatestorage.md) - Serializes state and persists it to browser storage. -Refer [here](https://github.com/elastic/kibana/tree/master/src/plugins/kibana_utils/docs/state_sync) for a complete guide and examples +Refer [here](https://github.com/elastic/kibana/tree/master/src/plugins/kibana_utils/docs/state_sync) for a complete guide and examples. ## Functions | Function | Description | | --- | --- | -| [syncState({ storageKey, stateStorage, stateContainer, })](./kibana-plugin-plugins-kibana_utils-public-state_sync.syncstate.md) | Utility for syncing application state wrapped in state container with some kind of storage (e.g. URL) Refer [here](https://github.com/elastic/kibana/tree/master/src/plugins/kibana_utils/docs/state_sync) for a complete guide and examples | +| [syncState({ storageKey, stateStorage, stateContainer, })](./kibana-plugin-plugins-kibana_utils-public-state_sync.syncstate.md) | Utility for syncing application state wrapped in state container with some kind of storage (e.g. URL)Go [here](https://github.com/elastic/kibana/tree/master/src/plugins/kibana_utils/docs/state_sync) for a complete guide and examples. | | [syncStates(stateSyncConfigs)](./kibana-plugin-plugins-kibana_utils-public-state_sync.syncstates.md) | | ## Interfaces | Interface | Description | | --- | --- | -| [IKbnUrlStateStorage](./kibana-plugin-plugins-kibana_utils-public-state_sync.ikbnurlstatestorage.md) | KbnUrlStateStorage is a state storage for [syncState()](./kibana-plugin-plugins-kibana_utils-public-state_sync.syncstate.md) utility which: 1. Keeps state in sync with the URL. 2. Serializes data and stores it in the URL in one of the supported formats: \* Rison encoded. \* Hashed URL: In URL we store only the hash from the serialized state, but the state itself is stored in sessionStorage. See kibana's advanced option for more context state:storeInSessionStorage 3. Takes care of listening to the URL updates and notifies state about the updates. 4. Takes care of batching URL updates to prevent redundant browser history records. [GUIDE](https://github.com/elastic/kibana/blob/master/src/plugins/kibana_utils/docs/state_sync/storages/kbn_url_storage.md) | +| [IKbnUrlStateStorage](./kibana-plugin-plugins-kibana_utils-public-state_sync.ikbnurlstatestorage.md) | KbnUrlStateStorage is a state storage for [syncState()](./kibana-plugin-plugins-kibana_utils-public-state_sync.syncstate.md) utility which:1. Keeps state in sync with the URL. 2. Serializes data and stores it in the URL in one of the supported formats: \* Rison encoded. \* Hashed URL: In URL we store only the hash from the serialized state, but the state itself is stored in sessionStorage. See Kibana's state:storeInSessionStorage advanced option for more context. 3. Takes care of listening to the URL updates and notifies state about the updates. 4. Takes care of batching URL updates to prevent redundant browser history records.[Refer to this guide for more info](https://github.com/elastic/kibana/blob/master/src/plugins/kibana_utils/docs/state_sync/storages/kbn_url_storage.md) | | [INullableBaseStateContainer](./kibana-plugin-plugins-kibana_utils-public-state_sync.inullablebasestatecontainer.md) | Extension of with one constraint: set state should handle null as incoming state | | [ISessionStorageStateStorage](./kibana-plugin-plugins-kibana_utils-public-state_sync.isessionstoragestatestorage.md) | [IStateStorage](./kibana-plugin-plugins-kibana_utils-public-state_sync.istatestorage.md) for storing state in browser [guide](https://github.com/elastic/kibana/blob/master/src/plugins/kibana_utils/docs/state_sync/storages/session_storage.md) | | [IStateStorage](./kibana-plugin-plugins-kibana_utils-public-state_sync.istatestorage.md) | Any StateStorage have to implement IStateStorage interface StateStorage is responsible for: \* state serialisation / deserialization \* persisting to and retrieving from storageFor an example take a look at already implemented [IKbnUrlStateStorage](./kibana-plugin-plugins-kibana_utils-public-state_sync.ikbnurlstatestorage.md) and [ISessionStorageStateStorage](./kibana-plugin-plugins-kibana_utils-public-state_sync.isessionstoragestatestorage.md) state storages | diff --git a/docs/development/plugins/kibana_utils/public/state_sync/kibana-plugin-plugins-kibana_utils-public-state_sync.syncstate.md b/docs/development/plugins/kibana_utils/public/state_sync/kibana-plugin-plugins-kibana_utils-public-state_sync.syncstate.md index d095c3fffc512a4..10dc4d0e1874601 100644 --- a/docs/development/plugins/kibana_utils/public/state_sync/kibana-plugin-plugins-kibana_utils-public-state_sync.syncstate.md +++ b/docs/development/plugins/kibana_utils/public/state_sync/kibana-plugin-plugins-kibana_utils-public-state_sync.syncstate.md @@ -4,7 +4,9 @@ ## syncState() function -Utility for syncing application state wrapped in state container with some kind of storage (e.g. URL) Refer [here](https://github.com/elastic/kibana/tree/master/src/plugins/kibana_utils/docs/state_sync) for a complete guide and examples +Utility for syncing application state wrapped in state container with some kind of storage (e.g. URL) + +Go [here](https://github.com/elastic/kibana/tree/master/src/plugins/kibana_utils/docs/state_sync) for a complete guide and examples. Signature: @@ -24,13 +26,9 @@ export declare function syncState ({ tab: s.tab }); diff --git a/src/core/server/elasticsearch/client/client_facade.mock.ts b/src/core/server/elasticsearch/client/client_facade.mock.ts deleted file mode 100644 index f629d9fbbe04bfa..000000000000000 --- a/src/core/server/elasticsearch/client/client_facade.mock.ts +++ /dev/null @@ -1,416 +0,0 @@ -/* - * 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 { ClientFacade } from './client_facade'; - -const createFacadeMock = () => { - const mock: DeeplyMockedKeys = { - transport: { - request: jest.fn(), - }, - /* GENERATED */ - asyncSearch: { - delete: jest.fn(), - get: jest.fn(), - submit: jest.fn(), - }, - autoscaling: { - deleteAutoscalingPolicy: jest.fn(), - getAutoscalingDecision: jest.fn(), - getAutoscalingPolicy: jest.fn(), - putAutoscalingPolicy: jest.fn(), - }, - bulk: jest.fn(), - cat: { - aliases: jest.fn(), - allocation: jest.fn(), - count: jest.fn(), - fielddata: jest.fn(), - health: jest.fn(), - help: jest.fn(), - indices: jest.fn(), - master: jest.fn(), - mlDataFrameAnalytics: jest.fn(), - mlDatafeeds: jest.fn(), - mlJobs: jest.fn(), - mlTrainedModels: jest.fn(), - nodeattrs: jest.fn(), - nodes: jest.fn(), - pendingTasks: jest.fn(), - plugins: jest.fn(), - recovery: jest.fn(), - repositories: jest.fn(), - segments: jest.fn(), - shards: jest.fn(), - snapshots: jest.fn(), - tasks: jest.fn(), - templates: jest.fn(), - threadPool: jest.fn(), - transforms: jest.fn(), - }, - ccr: { - deleteAutoFollowPattern: jest.fn(), - follow: jest.fn(), - followInfo: jest.fn(), - followStats: jest.fn(), - forgetFollower: jest.fn(), - getAutoFollowPattern: jest.fn(), - pauseAutoFollowPattern: jest.fn(), - pauseFollow: jest.fn(), - putAutoFollowPattern: jest.fn(), - resumeAutoFollowPattern: jest.fn(), - resumeFollow: jest.fn(), - stats: jest.fn(), - unfollow: jest.fn(), - }, - clearScroll: jest.fn(), - cluster: { - allocationExplain: jest.fn(), - deleteComponentTemplate: jest.fn(), - deleteVotingConfigExclusions: jest.fn(), - existsComponentTemplate: jest.fn(), - getComponentTemplate: jest.fn(), - getSettings: jest.fn(), - health: jest.fn(), - pendingTasks: jest.fn(), - postVotingConfigExclusions: jest.fn(), - putComponentTemplate: jest.fn(), - putSettings: jest.fn(), - remoteInfo: jest.fn(), - reroute: jest.fn(), - state: jest.fn(), - stats: jest.fn(), - }, - count: jest.fn(), - create: jest.fn(), - delete: jest.fn(), - deleteByQuery: jest.fn(), - deleteByQueryRethrottle: jest.fn(), - deleteScript: jest.fn(), - enrich: { - deletePolicy: jest.fn(), - executePolicy: jest.fn(), - getPolicy: jest.fn(), - putPolicy: jest.fn(), - stats: jest.fn(), - }, - eql: { - search: jest.fn(), - }, - exists: jest.fn(), - existsSource: jest.fn(), - explain: jest.fn(), - fieldCaps: jest.fn(), - get: jest.fn(), - getScript: jest.fn(), - getScriptContext: jest.fn(), - getScriptLanguages: jest.fn(), - getSource: jest.fn(), - graph: { - explore: jest.fn(), - }, - ilm: { - deleteLifecycle: jest.fn(), - explainLifecycle: jest.fn(), - getLifecycle: jest.fn(), - getStatus: jest.fn(), - moveToStep: jest.fn(), - putLifecycle: jest.fn(), - removePolicy: jest.fn(), - retry: jest.fn(), - start: jest.fn(), - stop: jest.fn(), - }, - index: jest.fn(), - indices: { - analyze: jest.fn(), - clearCache: jest.fn(), - clone: jest.fn(), - close: jest.fn(), - create: jest.fn(), - createDataStream: jest.fn(), - delete: jest.fn(), - deleteAlias: jest.fn(), - deleteDataStream: jest.fn(), - deleteIndexTemplate: jest.fn(), - deleteTemplate: jest.fn(), - exists: jest.fn(), - existsAlias: jest.fn(), - existsIndexTemplate: jest.fn(), - existsTemplate: jest.fn(), - existsType: jest.fn(), - flush: jest.fn(), - flushSynced: jest.fn(), - forcemerge: jest.fn(), - freeze: jest.fn(), - get: jest.fn(), - getAlias: jest.fn(), - getDataStreams: jest.fn(), - getFieldMapping: jest.fn(), - getIndexTemplate: jest.fn(), - getMapping: jest.fn(), - getSettings: jest.fn(), - getTemplate: jest.fn(), - getUpgrade: jest.fn(), - open: jest.fn(), - putAlias: jest.fn(), - putIndexTemplate: jest.fn(), - putMapping: jest.fn(), - putSettings: jest.fn(), - putTemplate: jest.fn(), - recovery: jest.fn(), - refresh: jest.fn(), - reloadSearchAnalyzers: jest.fn(), - rollover: jest.fn(), - segments: jest.fn(), - shardStores: jest.fn(), - shrink: jest.fn(), - simulateIndexTemplate: jest.fn(), - split: jest.fn(), - stats: jest.fn(), - unfreeze: jest.fn(), - updateAliases: jest.fn(), - upgrade: jest.fn(), - validateQuery: jest.fn(), - }, - info: jest.fn(), - ingest: { - deletePipeline: jest.fn(), - getPipeline: jest.fn(), - processorGrok: jest.fn(), - putPipeline: jest.fn(), - simulate: jest.fn(), - }, - license: { - delete: jest.fn(), - get: jest.fn(), - getBasicStatus: jest.fn(), - getTrialStatus: jest.fn(), - post: jest.fn(), - postStartBasic: jest.fn(), - postStartTrial: jest.fn(), - }, - mget: jest.fn(), - migration: { - deprecations: jest.fn(), - }, - ml: { - closeJob: jest.fn(), - deleteCalendar: jest.fn(), - deleteCalendarEvent: jest.fn(), - deleteCalendarJob: jest.fn(), - deleteDataFrameAnalytics: jest.fn(), - deleteDatafeed: jest.fn(), - deleteExpiredData: jest.fn(), - deleteFilter: jest.fn(), - deleteForecast: jest.fn(), - deleteJob: jest.fn(), - deleteModelSnapshot: jest.fn(), - deleteTrainedModel: jest.fn(), - estimateModelMemory: jest.fn(), - evaluateDataFrame: jest.fn(), - explainDataFrameAnalytics: jest.fn(), - findFileStructure: jest.fn(), - flushJob: jest.fn(), - forecast: jest.fn(), - getBuckets: jest.fn(), - getCalendarEvents: jest.fn(), - getCalendars: jest.fn(), - getCategories: jest.fn(), - getDataFrameAnalytics: jest.fn(), - getDataFrameAnalyticsStats: jest.fn(), - getDatafeedStats: jest.fn(), - getDatafeeds: jest.fn(), - getFilters: jest.fn(), - getInfluencers: jest.fn(), - getJobStats: jest.fn(), - getJobs: jest.fn(), - getModelSnapshots: jest.fn(), - getOverallBuckets: jest.fn(), - getRecords: jest.fn(), - getTrainedModels: jest.fn(), - getTrainedModelsStats: jest.fn(), - info: jest.fn(), - openJob: jest.fn(), - postCalendarEvents: jest.fn(), - postData: jest.fn(), - previewDatafeed: jest.fn(), - putCalendar: jest.fn(), - putCalendarJob: jest.fn(), - putDataFrameAnalytics: jest.fn(), - putDatafeed: jest.fn(), - putFilter: jest.fn(), - putJob: jest.fn(), - putTrainedModel: jest.fn(), - revertModelSnapshot: jest.fn(), - setUpgradeMode: jest.fn(), - startDataFrameAnalytics: jest.fn(), - startDatafeed: jest.fn(), - stopDataFrameAnalytics: jest.fn(), - stopDatafeed: jest.fn(), - updateDatafeed: jest.fn(), - updateFilter: jest.fn(), - updateJob: jest.fn(), - updateModelSnapshot: jest.fn(), - validate: jest.fn(), - validateDetector: jest.fn(), - }, - monitoring: { - bulk: jest.fn(), - }, - msearch: jest.fn(), - msearchTemplate: jest.fn(), - mtermvectors: jest.fn(), - nodes: { - hotThreads: jest.fn(), - info: jest.fn(), - reloadSecureSettings: jest.fn(), - stats: jest.fn(), - usage: jest.fn(), - }, - ping: jest.fn(), - putScript: jest.fn(), - rankEval: jest.fn(), - reindex: jest.fn(), - reindexRethrottle: jest.fn(), - renderSearchTemplate: jest.fn(), - rollup: { - deleteJob: jest.fn(), - getJobs: jest.fn(), - getRollupCaps: jest.fn(), - getRollupIndexCaps: jest.fn(), - putJob: jest.fn(), - rollupSearch: jest.fn(), - startJob: jest.fn(), - stopJob: jest.fn(), - }, - scriptsPainlessExecute: jest.fn(), - scroll: jest.fn(), - search: jest.fn(), - searchShards: jest.fn(), - searchTemplate: jest.fn(), - searchableSnapshots: { - clearCache: jest.fn(), - mount: jest.fn(), - repositoryStats: jest.fn(), - stats: jest.fn(), - }, - security: { - authenticate: jest.fn(), - changePassword: jest.fn(), - clearCachedRealms: jest.fn(), - clearCachedRoles: jest.fn(), - createApiKey: jest.fn(), - deletePrivileges: jest.fn(), - deleteRole: jest.fn(), - deleteRoleMapping: jest.fn(), - deleteUser: jest.fn(), - disableUser: jest.fn(), - enableUser: jest.fn(), - getApiKey: jest.fn(), - getBuiltinPrivileges: jest.fn(), - getPrivileges: jest.fn(), - getRole: jest.fn(), - getRoleMapping: jest.fn(), - getToken: jest.fn(), - getUser: jest.fn(), - getUserPrivileges: jest.fn(), - hasPrivileges: jest.fn(), - invalidateApiKey: jest.fn(), - invalidateToken: jest.fn(), - putPrivileges: jest.fn(), - putRole: jest.fn(), - putRoleMapping: jest.fn(), - putUser: jest.fn(), - }, - slm: { - deleteLifecycle: jest.fn(), - executeLifecycle: jest.fn(), - executeRetention: jest.fn(), - getLifecycle: jest.fn(), - getStats: jest.fn(), - getStatus: jest.fn(), - putLifecycle: jest.fn(), - start: jest.fn(), - stop: jest.fn(), - }, - snapshot: { - cleanupRepository: jest.fn(), - create: jest.fn(), - createRepository: jest.fn(), - delete: jest.fn(), - deleteRepository: jest.fn(), - get: jest.fn(), - getRepository: jest.fn(), - restore: jest.fn(), - status: jest.fn(), - verifyRepository: jest.fn(), - }, - sql: { - clearCursor: jest.fn(), - query: jest.fn(), - translate: jest.fn(), - }, - ssl: { - certificates: jest.fn(), - }, - tasks: { - cancel: jest.fn(), - get: jest.fn(), - list: jest.fn(), - }, - termvectors: jest.fn(), - transform: { - deleteTransform: jest.fn(), - getTransform: jest.fn(), - getTransformStats: jest.fn(), - previewTransform: jest.fn(), - putTransform: jest.fn(), - startTransform: jest.fn(), - stopTransform: jest.fn(), - updateTransform: jest.fn(), - }, - update: jest.fn(), - updateByQuery: jest.fn(), - updateByQueryRethrottle: jest.fn(), - watcher: { - ackWatch: jest.fn(), - activateWatch: jest.fn(), - deactivateWatch: jest.fn(), - deleteWatch: jest.fn(), - executeWatch: jest.fn(), - getWatch: jest.fn(), - putWatch: jest.fn(), - start: jest.fn(), - stats: jest.fn(), - stop: jest.fn(), - }, - xpack: { - info: jest.fn(), - usage: jest.fn(), - }, - /* /GENERATED */ - }; - - return mock; -}; - -export const clientFacadeMock = { - create: createFacadeMock, -}; diff --git a/src/core/server/elasticsearch/client/client_facade.ts b/src/core/server/elasticsearch/client/client_facade.ts deleted file mode 100644 index 0e7b12337853c8d..000000000000000 --- a/src/core/server/elasticsearch/client/client_facade.ts +++ /dev/null @@ -1,1858 +0,0 @@ -/* - * 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 { ApiResponse } from '@elastic/elasticsearch'; -import { - RequestBody, - RequestNDBody, - TransportRequestOptions, - TransportRequestParams, - TransportRequestPromise, -} from '@elastic/elasticsearch/lib/Transport'; -import * as RequestParams from '@elastic/elasticsearch/api/requestParams'; - -/** - * Facade used to query the elasticsearch cluster. - * - * @public - */ -export interface ClientFacade { - transport: { - request( - params: TransportRequestParams, - options?: TransportRequestOptions - ): Promise; - }; - /* GENERATED */ - asyncSearch: { - delete, TContext = unknown>( - params?: RequestParams.AsyncSearchDelete, - options?: TransportRequestOptions - ): TransportRequestPromise>; - get, TContext = unknown>( - params?: RequestParams.AsyncSearchGet, - options?: TransportRequestOptions - ): TransportRequestPromise>; - submit< - TResponse = Record, - TRequestBody extends RequestBody = Record, - TContext = unknown - >( - params?: RequestParams.AsyncSearchSubmit, - options?: TransportRequestOptions - ): TransportRequestPromise>; - }; - autoscaling: { - deleteAutoscalingPolicy, TContext = unknown>( - params?: RequestParams.AutoscalingDeleteAutoscalingPolicy, - options?: TransportRequestOptions - ): TransportRequestPromise>; - getAutoscalingDecision, TContext = unknown>( - params?: RequestParams.AutoscalingGetAutoscalingDecision, - options?: TransportRequestOptions - ): TransportRequestPromise>; - getAutoscalingPolicy, TContext = unknown>( - params?: RequestParams.AutoscalingGetAutoscalingPolicy, - options?: TransportRequestOptions - ): TransportRequestPromise>; - putAutoscalingPolicy< - TResponse = Record, - TRequestBody extends RequestBody = Record, - TContext = unknown - >( - params?: RequestParams.AutoscalingPutAutoscalingPolicy, - options?: TransportRequestOptions - ): TransportRequestPromise>; - }; - bulk< - TResponse = Record, - TRequestBody extends RequestNDBody = Array>, - TContext = unknown - >( - params?: RequestParams.Bulk, - options?: TransportRequestOptions - ): TransportRequestPromise>; - cat: { - aliases, TContext = unknown>( - params?: RequestParams.CatAliases, - options?: TransportRequestOptions - ): TransportRequestPromise>; - allocation, TContext = unknown>( - params?: RequestParams.CatAllocation, - options?: TransportRequestOptions - ): TransportRequestPromise>; - count, TContext = unknown>( - params?: RequestParams.CatCount, - options?: TransportRequestOptions - ): TransportRequestPromise>; - fielddata, TContext = unknown>( - params?: RequestParams.CatFielddata, - options?: TransportRequestOptions - ): TransportRequestPromise>; - health, TContext = unknown>( - params?: RequestParams.CatHealth, - options?: TransportRequestOptions - ): TransportRequestPromise>; - help, TContext = unknown>( - params?: RequestParams.CatHelp, - options?: TransportRequestOptions - ): TransportRequestPromise>; - indices, TContext = unknown>( - params?: RequestParams.CatIndices, - options?: TransportRequestOptions - ): TransportRequestPromise>; - master, TContext = unknown>( - params?: RequestParams.CatMaster, - options?: TransportRequestOptions - ): TransportRequestPromise>; - mlDataFrameAnalytics, TContext = unknown>( - params?: RequestParams.CatMlDataFrameAnalytics, - options?: TransportRequestOptions - ): TransportRequestPromise>; - mlDatafeeds, TContext = unknown>( - params?: RequestParams.CatMlDatafeeds, - options?: TransportRequestOptions - ): TransportRequestPromise>; - mlJobs, TContext = unknown>( - params?: RequestParams.CatMlJobs, - options?: TransportRequestOptions - ): TransportRequestPromise>; - mlTrainedModels, TContext = unknown>( - params?: RequestParams.CatMlTrainedModels, - options?: TransportRequestOptions - ): TransportRequestPromise>; - nodeattrs, TContext = unknown>( - params?: RequestParams.CatNodeattrs, - options?: TransportRequestOptions - ): TransportRequestPromise>; - nodes, TContext = unknown>( - params?: RequestParams.CatNodes, - options?: TransportRequestOptions - ): TransportRequestPromise>; - pendingTasks, TContext = unknown>( - params?: RequestParams.CatPendingTasks, - options?: TransportRequestOptions - ): TransportRequestPromise>; - plugins, TContext = unknown>( - params?: RequestParams.CatPlugins, - options?: TransportRequestOptions - ): TransportRequestPromise>; - recovery, TContext = unknown>( - params?: RequestParams.CatRecovery, - options?: TransportRequestOptions - ): TransportRequestPromise>; - repositories, TContext = unknown>( - params?: RequestParams.CatRepositories, - options?: TransportRequestOptions - ): TransportRequestPromise>; - segments, TContext = unknown>( - params?: RequestParams.CatSegments, - options?: TransportRequestOptions - ): TransportRequestPromise>; - shards, TContext = unknown>( - params?: RequestParams.CatShards, - options?: TransportRequestOptions - ): TransportRequestPromise>; - snapshots, TContext = unknown>( - params?: RequestParams.CatSnapshots, - options?: TransportRequestOptions - ): TransportRequestPromise>; - tasks, TContext = unknown>( - params?: RequestParams.CatTasks, - options?: TransportRequestOptions - ): TransportRequestPromise>; - templates, TContext = unknown>( - params?: RequestParams.CatTemplates, - options?: TransportRequestOptions - ): TransportRequestPromise>; - threadPool, TContext = unknown>( - params?: RequestParams.CatThreadPool, - options?: TransportRequestOptions - ): TransportRequestPromise>; - transforms, TContext = unknown>( - params?: RequestParams.CatTransforms, - options?: TransportRequestOptions - ): TransportRequestPromise>; - }; - ccr: { - deleteAutoFollowPattern, TContext = unknown>( - params?: RequestParams.CcrDeleteAutoFollowPattern, - options?: TransportRequestOptions - ): TransportRequestPromise>; - follow< - TResponse = Record, - TRequestBody extends RequestBody = Record, - TContext = unknown - >( - params?: RequestParams.CcrFollow, - options?: TransportRequestOptions - ): TransportRequestPromise>; - followInfo, TContext = unknown>( - params?: RequestParams.CcrFollowInfo, - options?: TransportRequestOptions - ): TransportRequestPromise>; - followStats, TContext = unknown>( - params?: RequestParams.CcrFollowStats, - options?: TransportRequestOptions - ): TransportRequestPromise>; - forgetFollower< - TResponse = Record, - TRequestBody extends RequestBody = Record, - TContext = unknown - >( - params?: RequestParams.CcrForgetFollower, - options?: TransportRequestOptions - ): TransportRequestPromise>; - getAutoFollowPattern, TContext = unknown>( - params?: RequestParams.CcrGetAutoFollowPattern, - options?: TransportRequestOptions - ): TransportRequestPromise>; - pauseAutoFollowPattern, TContext = unknown>( - params?: RequestParams.CcrPauseAutoFollowPattern, - options?: TransportRequestOptions - ): TransportRequestPromise>; - pauseFollow, TContext = unknown>( - params?: RequestParams.CcrPauseFollow, - options?: TransportRequestOptions - ): TransportRequestPromise>; - putAutoFollowPattern< - TResponse = Record, - TRequestBody extends RequestBody = Record, - TContext = unknown - >( - params?: RequestParams.CcrPutAutoFollowPattern, - options?: TransportRequestOptions - ): TransportRequestPromise>; - resumeAutoFollowPattern, TContext = unknown>( - params?: RequestParams.CcrResumeAutoFollowPattern, - options?: TransportRequestOptions - ): TransportRequestPromise>; - resumeFollow< - TResponse = Record, - TRequestBody extends RequestBody = Record, - TContext = unknown - >( - params?: RequestParams.CcrResumeFollow, - options?: TransportRequestOptions - ): TransportRequestPromise>; - stats, TContext = unknown>( - params?: RequestParams.CcrStats, - options?: TransportRequestOptions - ): TransportRequestPromise>; - unfollow, TContext = unknown>( - params?: RequestParams.CcrUnfollow, - options?: TransportRequestOptions - ): TransportRequestPromise>; - }; - clearScroll< - TResponse = Record, - TRequestBody extends RequestBody = Record, - TContext = unknown - >( - params?: RequestParams.ClearScroll, - options?: TransportRequestOptions - ): TransportRequestPromise>; - cluster: { - allocationExplain< - TResponse = Record, - TRequestBody extends RequestBody = Record, - TContext = unknown - >( - params?: RequestParams.ClusterAllocationExplain, - options?: TransportRequestOptions - ): TransportRequestPromise>; - deleteComponentTemplate, TContext = unknown>( - params?: RequestParams.ClusterDeleteComponentTemplate, - options?: TransportRequestOptions - ): TransportRequestPromise>; - deleteVotingConfigExclusions, TContext = unknown>( - params?: RequestParams.ClusterDeleteVotingConfigExclusions, - options?: TransportRequestOptions - ): TransportRequestPromise>; - existsComponentTemplate, TContext = unknown>( - params?: RequestParams.ClusterExistsComponentTemplate, - options?: TransportRequestOptions - ): TransportRequestPromise>; - getComponentTemplate, TContext = unknown>( - params?: RequestParams.ClusterGetComponentTemplate, - options?: TransportRequestOptions - ): TransportRequestPromise>; - getSettings, TContext = unknown>( - params?: RequestParams.ClusterGetSettings, - options?: TransportRequestOptions - ): TransportRequestPromise>; - health, TContext = unknown>( - params?: RequestParams.ClusterHealth, - options?: TransportRequestOptions - ): TransportRequestPromise>; - pendingTasks, TContext = unknown>( - params?: RequestParams.ClusterPendingTasks, - options?: TransportRequestOptions - ): TransportRequestPromise>; - postVotingConfigExclusions, TContext = unknown>( - params?: RequestParams.ClusterPostVotingConfigExclusions, - options?: TransportRequestOptions - ): TransportRequestPromise>; - putComponentTemplate< - TResponse = Record, - TRequestBody extends RequestBody = Record, - TContext = unknown - >( - params?: RequestParams.ClusterPutComponentTemplate, - options?: TransportRequestOptions - ): TransportRequestPromise>; - putSettings< - TResponse = Record, - TRequestBody extends RequestBody = Record, - TContext = unknown - >( - params?: RequestParams.ClusterPutSettings, - options?: TransportRequestOptions - ): TransportRequestPromise>; - remoteInfo, TContext = unknown>( - params?: RequestParams.ClusterRemoteInfo, - options?: TransportRequestOptions - ): TransportRequestPromise>; - reroute< - TResponse = Record, - TRequestBody extends RequestBody = Record, - TContext = unknown - >( - params?: RequestParams.ClusterReroute, - options?: TransportRequestOptions - ): TransportRequestPromise>; - state, TContext = unknown>( - params?: RequestParams.ClusterState, - options?: TransportRequestOptions - ): TransportRequestPromise>; - stats, TContext = unknown>( - params?: RequestParams.ClusterStats, - options?: TransportRequestOptions - ): TransportRequestPromise>; - }; - count< - TResponse = Record, - TRequestBody extends RequestBody = Record, - TContext = unknown - >( - params?: RequestParams.Count, - options?: TransportRequestOptions - ): TransportRequestPromise>; - create< - TResponse = Record, - TRequestBody extends RequestBody = Record, - TContext = unknown - >( - params?: RequestParams.Create, - options?: TransportRequestOptions - ): TransportRequestPromise>; - delete, TContext = unknown>( - params?: RequestParams.Delete, - options?: TransportRequestOptions - ): TransportRequestPromise>; - deleteByQuery< - TResponse = Record, - TRequestBody extends RequestBody = Record, - TContext = unknown - >( - params?: RequestParams.DeleteByQuery, - options?: TransportRequestOptions - ): TransportRequestPromise>; - deleteByQueryRethrottle, TContext = unknown>( - params?: RequestParams.DeleteByQueryRethrottle, - options?: TransportRequestOptions - ): TransportRequestPromise>; - deleteScript, TContext = unknown>( - params?: RequestParams.DeleteScript, - options?: TransportRequestOptions - ): TransportRequestPromise>; - enrich: { - deletePolicy, TContext = unknown>( - params?: RequestParams.EnrichDeletePolicy, - options?: TransportRequestOptions - ): TransportRequestPromise>; - executePolicy, TContext = unknown>( - params?: RequestParams.EnrichExecutePolicy, - options?: TransportRequestOptions - ): TransportRequestPromise>; - getPolicy, TContext = unknown>( - params?: RequestParams.EnrichGetPolicy, - options?: TransportRequestOptions - ): TransportRequestPromise>; - putPolicy< - TResponse = Record, - TRequestBody extends RequestBody = Record, - TContext = unknown - >( - params?: RequestParams.EnrichPutPolicy, - options?: TransportRequestOptions - ): TransportRequestPromise>; - stats, TContext = unknown>( - params?: RequestParams.EnrichStats, - options?: TransportRequestOptions - ): TransportRequestPromise>; - }; - eql: { - search< - TResponse = Record, - TRequestBody extends RequestBody = Record, - TContext = unknown - >( - params?: RequestParams.EqlSearch, - options?: TransportRequestOptions - ): TransportRequestPromise>; - }; - exists, TContext = unknown>( - params?: RequestParams.Exists, - options?: TransportRequestOptions - ): TransportRequestPromise>; - existsSource, TContext = unknown>( - params?: RequestParams.ExistsSource, - options?: TransportRequestOptions - ): TransportRequestPromise>; - explain< - TResponse = Record, - TRequestBody extends RequestBody = Record, - TContext = unknown - >( - params?: RequestParams.Explain, - options?: TransportRequestOptions - ): TransportRequestPromise>; - fieldCaps, TContext = unknown>( - params?: RequestParams.FieldCaps, - options?: TransportRequestOptions - ): TransportRequestPromise>; - get, TContext = unknown>( - params?: RequestParams.Get, - options?: TransportRequestOptions - ): TransportRequestPromise>; - getScript, TContext = unknown>( - params?: RequestParams.GetScript, - options?: TransportRequestOptions - ): TransportRequestPromise>; - getScriptContext, TContext = unknown>( - params?: RequestParams.GetScriptContext, - options?: TransportRequestOptions - ): TransportRequestPromise>; - getScriptLanguages, TContext = unknown>( - params?: RequestParams.GetScriptLanguages, - options?: TransportRequestOptions - ): TransportRequestPromise>; - getSource, TContext = unknown>( - params?: RequestParams.GetSource, - options?: TransportRequestOptions - ): TransportRequestPromise>; - graph: { - explore< - TResponse = Record, - TRequestBody extends RequestBody = Record, - TContext = unknown - >( - params?: RequestParams.GraphExplore, - options?: TransportRequestOptions - ): TransportRequestPromise>; - }; - ilm: { - deleteLifecycle, TContext = unknown>( - params?: RequestParams.IlmDeleteLifecycle, - options?: TransportRequestOptions - ): TransportRequestPromise>; - explainLifecycle, TContext = unknown>( - params?: RequestParams.IlmExplainLifecycle, - options?: TransportRequestOptions - ): TransportRequestPromise>; - getLifecycle, TContext = unknown>( - params?: RequestParams.IlmGetLifecycle, - options?: TransportRequestOptions - ): TransportRequestPromise>; - getStatus, TContext = unknown>( - params?: RequestParams.IlmGetStatus, - options?: TransportRequestOptions - ): TransportRequestPromise>; - moveToStep< - TResponse = Record, - TRequestBody extends RequestBody = Record, - TContext = unknown - >( - params?: RequestParams.IlmMoveToStep, - options?: TransportRequestOptions - ): TransportRequestPromise>; - putLifecycle< - TResponse = Record, - TRequestBody extends RequestBody = Record, - TContext = unknown - >( - params?: RequestParams.IlmPutLifecycle, - options?: TransportRequestOptions - ): TransportRequestPromise>; - removePolicy, TContext = unknown>( - params?: RequestParams.IlmRemovePolicy, - options?: TransportRequestOptions - ): TransportRequestPromise>; - retry, TContext = unknown>( - params?: RequestParams.IlmRetry, - options?: TransportRequestOptions - ): TransportRequestPromise>; - start, TContext = unknown>( - params?: RequestParams.IlmStart, - options?: TransportRequestOptions - ): TransportRequestPromise>; - stop, TContext = unknown>( - params?: RequestParams.IlmStop, - options?: TransportRequestOptions - ): TransportRequestPromise>; - }; - index< - TResponse = Record, - TRequestBody extends RequestBody = Record, - TContext = unknown - >( - params?: RequestParams.Index, - options?: TransportRequestOptions - ): TransportRequestPromise>; - indices: { - analyze< - TResponse = Record, - TRequestBody extends RequestBody = Record, - TContext = unknown - >( - params?: RequestParams.IndicesAnalyze, - options?: TransportRequestOptions - ): TransportRequestPromise>; - clearCache, TContext = unknown>( - params?: RequestParams.IndicesClearCache, - options?: TransportRequestOptions - ): TransportRequestPromise>; - clone< - TResponse = Record, - TRequestBody extends RequestBody = Record, - TContext = unknown - >( - params?: RequestParams.IndicesClone, - options?: TransportRequestOptions - ): TransportRequestPromise>; - close, TContext = unknown>( - params?: RequestParams.IndicesClose, - options?: TransportRequestOptions - ): TransportRequestPromise>; - create< - TResponse = Record, - TRequestBody extends RequestBody = Record, - TContext = unknown - >( - params?: RequestParams.IndicesCreate, - options?: TransportRequestOptions - ): TransportRequestPromise>; - createDataStream< - TResponse = Record, - TRequestBody extends RequestBody = Record, - TContext = unknown - >( - params?: RequestParams.IndicesCreateDataStream, - options?: TransportRequestOptions - ): TransportRequestPromise>; - delete, TContext = unknown>( - params?: RequestParams.IndicesDelete, - options?: TransportRequestOptions - ): TransportRequestPromise>; - deleteAlias, TContext = unknown>( - params?: RequestParams.IndicesDeleteAlias, - options?: TransportRequestOptions - ): TransportRequestPromise>; - deleteDataStream, TContext = unknown>( - params?: RequestParams.IndicesDeleteDataStream, - options?: TransportRequestOptions - ): TransportRequestPromise>; - deleteIndexTemplate, TContext = unknown>( - params?: RequestParams.IndicesDeleteIndexTemplate, - options?: TransportRequestOptions - ): TransportRequestPromise>; - deleteTemplate, TContext = unknown>( - params?: RequestParams.IndicesDeleteTemplate, - options?: TransportRequestOptions - ): TransportRequestPromise>; - exists, TContext = unknown>( - params?: RequestParams.IndicesExists, - options?: TransportRequestOptions - ): TransportRequestPromise>; - existsAlias, TContext = unknown>( - params?: RequestParams.IndicesExistsAlias, - options?: TransportRequestOptions - ): TransportRequestPromise>; - existsIndexTemplate, TContext = unknown>( - params?: RequestParams.IndicesExistsIndexTemplate, - options?: TransportRequestOptions - ): TransportRequestPromise>; - existsTemplate, TContext = unknown>( - params?: RequestParams.IndicesExistsTemplate, - options?: TransportRequestOptions - ): TransportRequestPromise>; - existsType, TContext = unknown>( - params?: RequestParams.IndicesExistsType, - options?: TransportRequestOptions - ): TransportRequestPromise>; - flush, TContext = unknown>( - params?: RequestParams.IndicesFlush, - options?: TransportRequestOptions - ): TransportRequestPromise>; - flushSynced, TContext = unknown>( - params?: RequestParams.IndicesFlushSynced, - options?: TransportRequestOptions - ): TransportRequestPromise>; - forcemerge, TContext = unknown>( - params?: RequestParams.IndicesForcemerge, - options?: TransportRequestOptions - ): TransportRequestPromise>; - freeze, TContext = unknown>( - params?: RequestParams.IndicesFreeze, - options?: TransportRequestOptions - ): TransportRequestPromise>; - get, TContext = unknown>( - params?: RequestParams.IndicesGet, - options?: TransportRequestOptions - ): TransportRequestPromise>; - getAlias, TContext = unknown>( - params?: RequestParams.IndicesGetAlias, - options?: TransportRequestOptions - ): TransportRequestPromise>; - getDataStreams, TContext = unknown>( - params?: RequestParams.IndicesGetDataStreams, - options?: TransportRequestOptions - ): TransportRequestPromise>; - getFieldMapping, TContext = unknown>( - params?: RequestParams.IndicesGetFieldMapping, - options?: TransportRequestOptions - ): TransportRequestPromise>; - getIndexTemplate, TContext = unknown>( - params?: RequestParams.IndicesGetIndexTemplate, - options?: TransportRequestOptions - ): TransportRequestPromise>; - getMapping, TContext = unknown>( - params?: RequestParams.IndicesGetMapping, - options?: TransportRequestOptions - ): TransportRequestPromise>; - getSettings, TContext = unknown>( - params?: RequestParams.IndicesGetSettings, - options?: TransportRequestOptions - ): TransportRequestPromise>; - getTemplate, TContext = unknown>( - params?: RequestParams.IndicesGetTemplate, - options?: TransportRequestOptions - ): TransportRequestPromise>; - getUpgrade, TContext = unknown>( - params?: RequestParams.IndicesGetUpgrade, - options?: TransportRequestOptions - ): TransportRequestPromise>; - open, TContext = unknown>( - params?: RequestParams.IndicesOpen, - options?: TransportRequestOptions - ): TransportRequestPromise>; - putAlias< - TResponse = Record, - TRequestBody extends RequestBody = Record, - TContext = unknown - >( - params?: RequestParams.IndicesPutAlias, - options?: TransportRequestOptions - ): TransportRequestPromise>; - putIndexTemplate< - TResponse = Record, - TRequestBody extends RequestBody = Record, - TContext = unknown - >( - params?: RequestParams.IndicesPutIndexTemplate, - options?: TransportRequestOptions - ): TransportRequestPromise>; - putMapping< - TResponse = Record, - TRequestBody extends RequestBody = Record, - TContext = unknown - >( - params?: RequestParams.IndicesPutMapping, - options?: TransportRequestOptions - ): TransportRequestPromise>; - putSettings< - TResponse = Record, - TRequestBody extends RequestBody = Record, - TContext = unknown - >( - params?: RequestParams.IndicesPutSettings, - options?: TransportRequestOptions - ): TransportRequestPromise>; - putTemplate< - TResponse = Record, - TRequestBody extends RequestBody = Record, - TContext = unknown - >( - params?: RequestParams.IndicesPutTemplate, - options?: TransportRequestOptions - ): TransportRequestPromise>; - recovery, TContext = unknown>( - params?: RequestParams.IndicesRecovery, - options?: TransportRequestOptions - ): TransportRequestPromise>; - refresh, TContext = unknown>( - params?: RequestParams.IndicesRefresh, - options?: TransportRequestOptions - ): TransportRequestPromise>; - reloadSearchAnalyzers, TContext = unknown>( - params?: RequestParams.IndicesReloadSearchAnalyzers, - options?: TransportRequestOptions - ): TransportRequestPromise>; - rollover< - TResponse = Record, - TRequestBody extends RequestBody = Record, - TContext = unknown - >( - params?: RequestParams.IndicesRollover, - options?: TransportRequestOptions - ): TransportRequestPromise>; - segments, TContext = unknown>( - params?: RequestParams.IndicesSegments, - options?: TransportRequestOptions - ): TransportRequestPromise>; - shardStores, TContext = unknown>( - params?: RequestParams.IndicesShardStores, - options?: TransportRequestOptions - ): TransportRequestPromise>; - shrink< - TResponse = Record, - TRequestBody extends RequestBody = Record, - TContext = unknown - >( - params?: RequestParams.IndicesShrink, - options?: TransportRequestOptions - ): TransportRequestPromise>; - simulateIndexTemplate< - TResponse = Record, - TRequestBody extends RequestBody = Record, - TContext = unknown - >( - params?: RequestParams.IndicesSimulateIndexTemplate, - options?: TransportRequestOptions - ): TransportRequestPromise>; - split< - TResponse = Record, - TRequestBody extends RequestBody = Record, - TContext = unknown - >( - params?: RequestParams.IndicesSplit, - options?: TransportRequestOptions - ): TransportRequestPromise>; - stats, TContext = unknown>( - params?: RequestParams.IndicesStats, - options?: TransportRequestOptions - ): TransportRequestPromise>; - unfreeze, TContext = unknown>( - params?: RequestParams.IndicesUnfreeze, - options?: TransportRequestOptions - ): TransportRequestPromise>; - updateAliases< - TResponse = Record, - TRequestBody extends RequestBody = Record, - TContext = unknown - >( - params?: RequestParams.IndicesUpdateAliases, - options?: TransportRequestOptions - ): TransportRequestPromise>; - upgrade, TContext = unknown>( - params?: RequestParams.IndicesUpgrade, - options?: TransportRequestOptions - ): TransportRequestPromise>; - validateQuery< - TResponse = Record, - TRequestBody extends RequestBody = Record, - TContext = unknown - >( - params?: RequestParams.IndicesValidateQuery, - options?: TransportRequestOptions - ): TransportRequestPromise>; - }; - info, TContext = unknown>( - params?: RequestParams.Info, - options?: TransportRequestOptions - ): TransportRequestPromise>; - ingest: { - deletePipeline, TContext = unknown>( - params?: RequestParams.IngestDeletePipeline, - options?: TransportRequestOptions - ): TransportRequestPromise>; - getPipeline, TContext = unknown>( - params?: RequestParams.IngestGetPipeline, - options?: TransportRequestOptions - ): TransportRequestPromise>; - processorGrok, TContext = unknown>( - params?: RequestParams.IngestProcessorGrok, - options?: TransportRequestOptions - ): TransportRequestPromise>; - putPipeline< - TResponse = Record, - TRequestBody extends RequestBody = Record, - TContext = unknown - >( - params?: RequestParams.IngestPutPipeline, - options?: TransportRequestOptions - ): TransportRequestPromise>; - simulate< - TResponse = Record, - TRequestBody extends RequestBody = Record, - TContext = unknown - >( - params?: RequestParams.IngestSimulate, - options?: TransportRequestOptions - ): TransportRequestPromise>; - }; - license: { - delete, TContext = unknown>( - params?: RequestParams.LicenseDelete, - options?: TransportRequestOptions - ): TransportRequestPromise>; - get, TContext = unknown>( - params?: RequestParams.LicenseGet, - options?: TransportRequestOptions - ): TransportRequestPromise>; - getBasicStatus, TContext = unknown>( - params?: RequestParams.LicenseGetBasicStatus, - options?: TransportRequestOptions - ): TransportRequestPromise>; - getTrialStatus, TContext = unknown>( - params?: RequestParams.LicenseGetTrialStatus, - options?: TransportRequestOptions - ): TransportRequestPromise>; - post< - TResponse = Record, - TRequestBody extends RequestBody = Record, - TContext = unknown - >( - params?: RequestParams.LicensePost, - options?: TransportRequestOptions - ): TransportRequestPromise>; - postStartBasic, TContext = unknown>( - params?: RequestParams.LicensePostStartBasic, - options?: TransportRequestOptions - ): TransportRequestPromise>; - postStartTrial, TContext = unknown>( - params?: RequestParams.LicensePostStartTrial, - options?: TransportRequestOptions - ): TransportRequestPromise>; - }; - mget< - TResponse = Record, - TRequestBody extends RequestBody = Record, - TContext = unknown - >( - params?: RequestParams.Mget, - options?: TransportRequestOptions - ): TransportRequestPromise>; - migration: { - deprecations, TContext = unknown>( - params?: RequestParams.MigrationDeprecations, - options?: TransportRequestOptions - ): TransportRequestPromise>; - }; - ml: { - closeJob< - TResponse = Record, - TRequestBody extends RequestBody = Record, - TContext = unknown - >( - params?: RequestParams.MlCloseJob, - options?: TransportRequestOptions - ): TransportRequestPromise>; - deleteCalendar, TContext = unknown>( - params?: RequestParams.MlDeleteCalendar, - options?: TransportRequestOptions - ): TransportRequestPromise>; - deleteCalendarEvent, TContext = unknown>( - params?: RequestParams.MlDeleteCalendarEvent, - options?: TransportRequestOptions - ): TransportRequestPromise>; - deleteCalendarJob, TContext = unknown>( - params?: RequestParams.MlDeleteCalendarJob, - options?: TransportRequestOptions - ): TransportRequestPromise>; - deleteDataFrameAnalytics, TContext = unknown>( - params?: RequestParams.MlDeleteDataFrameAnalytics, - options?: TransportRequestOptions - ): TransportRequestPromise>; - deleteDatafeed, TContext = unknown>( - params?: RequestParams.MlDeleteDatafeed, - options?: TransportRequestOptions - ): TransportRequestPromise>; - deleteExpiredData< - TResponse = Record, - TRequestBody extends RequestBody = Record, - TContext = unknown - >( - params?: RequestParams.MlDeleteExpiredData, - options?: TransportRequestOptions - ): TransportRequestPromise>; - deleteFilter, TContext = unknown>( - params?: RequestParams.MlDeleteFilter, - options?: TransportRequestOptions - ): TransportRequestPromise>; - deleteForecast, TContext = unknown>( - params?: RequestParams.MlDeleteForecast, - options?: TransportRequestOptions - ): TransportRequestPromise>; - deleteJob, TContext = unknown>( - params?: RequestParams.MlDeleteJob, - options?: TransportRequestOptions - ): TransportRequestPromise>; - deleteModelSnapshot, TContext = unknown>( - params?: RequestParams.MlDeleteModelSnapshot, - options?: TransportRequestOptions - ): TransportRequestPromise>; - deleteTrainedModel, TContext = unknown>( - params?: RequestParams.MlDeleteTrainedModel, - options?: TransportRequestOptions - ): TransportRequestPromise>; - estimateModelMemory< - TResponse = Record, - TRequestBody extends RequestBody = Record, - TContext = unknown - >( - params?: RequestParams.MlEstimateModelMemory, - options?: TransportRequestOptions - ): TransportRequestPromise>; - evaluateDataFrame< - TResponse = Record, - TRequestBody extends RequestBody = Record, - TContext = unknown - >( - params?: RequestParams.MlEvaluateDataFrame, - options?: TransportRequestOptions - ): TransportRequestPromise>; - explainDataFrameAnalytics< - TResponse = Record, - TRequestBody extends RequestBody = Record, - TContext = unknown - >( - params?: RequestParams.MlExplainDataFrameAnalytics, - options?: TransportRequestOptions - ): TransportRequestPromise>; - findFileStructure< - TResponse = Record, - TRequestBody extends RequestNDBody = Array>, - TContext = unknown - >( - params?: RequestParams.MlFindFileStructure, - options?: TransportRequestOptions - ): TransportRequestPromise>; - flushJob< - TResponse = Record, - TRequestBody extends RequestBody = Record, - TContext = unknown - >( - params?: RequestParams.MlFlushJob, - options?: TransportRequestOptions - ): TransportRequestPromise>; - forecast, TContext = unknown>( - params?: RequestParams.MlForecast, - options?: TransportRequestOptions - ): TransportRequestPromise>; - getBuckets< - TResponse = Record, - TRequestBody extends RequestBody = Record, - TContext = unknown - >( - params?: RequestParams.MlGetBuckets, - options?: TransportRequestOptions - ): TransportRequestPromise>; - getCalendarEvents, TContext = unknown>( - params?: RequestParams.MlGetCalendarEvents, - options?: TransportRequestOptions - ): TransportRequestPromise>; - getCalendars< - TResponse = Record, - TRequestBody extends RequestBody = Record, - TContext = unknown - >( - params?: RequestParams.MlGetCalendars, - options?: TransportRequestOptions - ): TransportRequestPromise>; - getCategories< - TResponse = Record, - TRequestBody extends RequestBody = Record, - TContext = unknown - >( - params?: RequestParams.MlGetCategories, - options?: TransportRequestOptions - ): TransportRequestPromise>; - getDataFrameAnalytics, TContext = unknown>( - params?: RequestParams.MlGetDataFrameAnalytics, - options?: TransportRequestOptions - ): TransportRequestPromise>; - getDataFrameAnalyticsStats, TContext = unknown>( - params?: RequestParams.MlGetDataFrameAnalyticsStats, - options?: TransportRequestOptions - ): TransportRequestPromise>; - getDatafeedStats, TContext = unknown>( - params?: RequestParams.MlGetDatafeedStats, - options?: TransportRequestOptions - ): TransportRequestPromise>; - getDatafeeds, TContext = unknown>( - params?: RequestParams.MlGetDatafeeds, - options?: TransportRequestOptions - ): TransportRequestPromise>; - getFilters, TContext = unknown>( - params?: RequestParams.MlGetFilters, - options?: TransportRequestOptions - ): TransportRequestPromise>; - getInfluencers< - TResponse = Record, - TRequestBody extends RequestBody = Record, - TContext = unknown - >( - params?: RequestParams.MlGetInfluencers, - options?: TransportRequestOptions - ): TransportRequestPromise>; - getJobStats, TContext = unknown>( - params?: RequestParams.MlGetJobStats, - options?: TransportRequestOptions - ): TransportRequestPromise>; - getJobs, TContext = unknown>( - params?: RequestParams.MlGetJobs, - options?: TransportRequestOptions - ): TransportRequestPromise>; - getModelSnapshots< - TResponse = Record, - TRequestBody extends RequestBody = Record, - TContext = unknown - >( - params?: RequestParams.MlGetModelSnapshots, - options?: TransportRequestOptions - ): TransportRequestPromise>; - getOverallBuckets< - TResponse = Record, - TRequestBody extends RequestBody = Record, - TContext = unknown - >( - params?: RequestParams.MlGetOverallBuckets, - options?: TransportRequestOptions - ): TransportRequestPromise>; - getRecords< - TResponse = Record, - TRequestBody extends RequestBody = Record, - TContext = unknown - >( - params?: RequestParams.MlGetRecords, - options?: TransportRequestOptions - ): TransportRequestPromise>; - getTrainedModels, TContext = unknown>( - params?: RequestParams.MlGetTrainedModels, - options?: TransportRequestOptions - ): TransportRequestPromise>; - getTrainedModelsStats, TContext = unknown>( - params?: RequestParams.MlGetTrainedModelsStats, - options?: TransportRequestOptions - ): TransportRequestPromise>; - info, TContext = unknown>( - params?: RequestParams.MlInfo, - options?: TransportRequestOptions - ): TransportRequestPromise>; - openJob, TContext = unknown>( - params?: RequestParams.MlOpenJob, - options?: TransportRequestOptions - ): TransportRequestPromise>; - postCalendarEvents< - TResponse = Record, - TRequestBody extends RequestBody = Record, - TContext = unknown - >( - params?: RequestParams.MlPostCalendarEvents, - options?: TransportRequestOptions - ): TransportRequestPromise>; - postData< - TResponse = Record, - TRequestBody extends RequestBody = Record, - TContext = unknown - >( - params?: RequestParams.MlPostData, - options?: TransportRequestOptions - ): TransportRequestPromise>; - previewDatafeed, TContext = unknown>( - params?: RequestParams.MlPreviewDatafeed, - options?: TransportRequestOptions - ): TransportRequestPromise>; - putCalendar< - TResponse = Record, - TRequestBody extends RequestBody = Record, - TContext = unknown - >( - params?: RequestParams.MlPutCalendar, - options?: TransportRequestOptions - ): TransportRequestPromise>; - putCalendarJob, TContext = unknown>( - params?: RequestParams.MlPutCalendarJob, - options?: TransportRequestOptions - ): TransportRequestPromise>; - putDataFrameAnalytics< - TResponse = Record, - TRequestBody extends RequestBody = Record, - TContext = unknown - >( - params?: RequestParams.MlPutDataFrameAnalytics, - options?: TransportRequestOptions - ): TransportRequestPromise>; - putDatafeed< - TResponse = Record, - TRequestBody extends RequestBody = Record, - TContext = unknown - >( - params?: RequestParams.MlPutDatafeed, - options?: TransportRequestOptions - ): TransportRequestPromise>; - putFilter< - TResponse = Record, - TRequestBody extends RequestBody = Record, - TContext = unknown - >( - params?: RequestParams.MlPutFilter, - options?: TransportRequestOptions - ): TransportRequestPromise>; - putJob< - TResponse = Record, - TRequestBody extends RequestBody = Record, - TContext = unknown - >( - params?: RequestParams.MlPutJob, - options?: TransportRequestOptions - ): TransportRequestPromise>; - putTrainedModel< - TResponse = Record, - TRequestBody extends RequestBody = Record, - TContext = unknown - >( - params?: RequestParams.MlPutTrainedModel, - options?: TransportRequestOptions - ): TransportRequestPromise>; - revertModelSnapshot< - TResponse = Record, - TRequestBody extends RequestBody = Record, - TContext = unknown - >( - params?: RequestParams.MlRevertModelSnapshot, - options?: TransportRequestOptions - ): TransportRequestPromise>; - setUpgradeMode, TContext = unknown>( - params?: RequestParams.MlSetUpgradeMode, - options?: TransportRequestOptions - ): TransportRequestPromise>; - startDataFrameAnalytics< - TResponse = Record, - TRequestBody extends RequestBody = Record, - TContext = unknown - >( - params?: RequestParams.MlStartDataFrameAnalytics, - options?: TransportRequestOptions - ): TransportRequestPromise>; - startDatafeed< - TResponse = Record, - TRequestBody extends RequestBody = Record, - TContext = unknown - >( - params?: RequestParams.MlStartDatafeed, - options?: TransportRequestOptions - ): TransportRequestPromise>; - stopDataFrameAnalytics< - TResponse = Record, - TRequestBody extends RequestBody = Record, - TContext = unknown - >( - params?: RequestParams.MlStopDataFrameAnalytics, - options?: TransportRequestOptions - ): TransportRequestPromise>; - stopDatafeed, TContext = unknown>( - params?: RequestParams.MlStopDatafeed, - options?: TransportRequestOptions - ): TransportRequestPromise>; - updateDatafeed< - TResponse = Record, - TRequestBody extends RequestBody = Record, - TContext = unknown - >( - params?: RequestParams.MlUpdateDatafeed, - options?: TransportRequestOptions - ): TransportRequestPromise>; - updateFilter< - TResponse = Record, - TRequestBody extends RequestBody = Record, - TContext = unknown - >( - params?: RequestParams.MlUpdateFilter, - options?: TransportRequestOptions - ): TransportRequestPromise>; - updateJob< - TResponse = Record, - TRequestBody extends RequestBody = Record, - TContext = unknown - >( - params?: RequestParams.MlUpdateJob, - options?: TransportRequestOptions - ): TransportRequestPromise>; - updateModelSnapshot< - TResponse = Record, - TRequestBody extends RequestBody = Record, - TContext = unknown - >( - params?: RequestParams.MlUpdateModelSnapshot, - options?: TransportRequestOptions - ): TransportRequestPromise>; - validate< - TResponse = Record, - TRequestBody extends RequestBody = Record, - TContext = unknown - >( - params?: RequestParams.MlValidate, - options?: TransportRequestOptions - ): TransportRequestPromise>; - validateDetector< - TResponse = Record, - TRequestBody extends RequestBody = Record, - TContext = unknown - >( - params?: RequestParams.MlValidateDetector, - options?: TransportRequestOptions - ): TransportRequestPromise>; - }; - monitoring: { - bulk< - TResponse = Record, - TRequestBody extends RequestNDBody = Array>, - TContext = unknown - >( - params?: RequestParams.MonitoringBulk, - options?: TransportRequestOptions - ): TransportRequestPromise>; - }; - msearch< - TResponse = Record, - TRequestBody extends RequestNDBody = Array>, - TContext = unknown - >( - params?: RequestParams.Msearch, - options?: TransportRequestOptions - ): TransportRequestPromise>; - msearchTemplate< - TResponse = Record, - TRequestBody extends RequestNDBody = Array>, - TContext = unknown - >( - params?: RequestParams.MsearchTemplate, - options?: TransportRequestOptions - ): TransportRequestPromise>; - mtermvectors< - TResponse = Record, - TRequestBody extends RequestBody = Record, - TContext = unknown - >( - params?: RequestParams.Mtermvectors, - options?: TransportRequestOptions - ): TransportRequestPromise>; - nodes: { - hotThreads, TContext = unknown>( - params?: RequestParams.NodesHotThreads, - options?: TransportRequestOptions - ): TransportRequestPromise>; - info, TContext = unknown>( - params?: RequestParams.NodesInfo, - options?: TransportRequestOptions - ): TransportRequestPromise>; - reloadSecureSettings< - TResponse = Record, - TRequestBody extends RequestBody = Record, - TContext = unknown - >( - params?: RequestParams.NodesReloadSecureSettings, - options?: TransportRequestOptions - ): TransportRequestPromise>; - stats, TContext = unknown>( - params?: RequestParams.NodesStats, - options?: TransportRequestOptions - ): TransportRequestPromise>; - usage, TContext = unknown>( - params?: RequestParams.NodesUsage, - options?: TransportRequestOptions - ): TransportRequestPromise>; - }; - ping, TContext = unknown>( - params?: RequestParams.Ping, - options?: TransportRequestOptions - ): TransportRequestPromise>; - putScript< - TResponse = Record, - TRequestBody extends RequestBody = Record, - TContext = unknown - >( - params?: RequestParams.PutScript, - options?: TransportRequestOptions - ): TransportRequestPromise>; - rankEval< - TResponse = Record, - TRequestBody extends RequestBody = Record, - TContext = unknown - >( - params?: RequestParams.RankEval, - options?: TransportRequestOptions - ): TransportRequestPromise>; - reindex< - TResponse = Record, - TRequestBody extends RequestBody = Record, - TContext = unknown - >( - params?: RequestParams.Reindex, - options?: TransportRequestOptions - ): TransportRequestPromise>; - reindexRethrottle, TContext = unknown>( - params?: RequestParams.ReindexRethrottle, - options?: TransportRequestOptions - ): TransportRequestPromise>; - renderSearchTemplate< - TResponse = Record, - TRequestBody extends RequestBody = Record, - TContext = unknown - >( - params?: RequestParams.RenderSearchTemplate, - options?: TransportRequestOptions - ): TransportRequestPromise>; - rollup: { - deleteJob, TContext = unknown>( - params?: RequestParams.RollupDeleteJob, - options?: TransportRequestOptions - ): TransportRequestPromise>; - getJobs, TContext = unknown>( - params?: RequestParams.RollupGetJobs, - options?: TransportRequestOptions - ): TransportRequestPromise>; - getRollupCaps, TContext = unknown>( - params?: RequestParams.RollupGetRollupCaps, - options?: TransportRequestOptions - ): TransportRequestPromise>; - getRollupIndexCaps, TContext = unknown>( - params?: RequestParams.RollupGetRollupIndexCaps, - options?: TransportRequestOptions - ): TransportRequestPromise>; - putJob< - TResponse = Record, - TRequestBody extends RequestBody = Record, - TContext = unknown - >( - params?: RequestParams.RollupPutJob, - options?: TransportRequestOptions - ): TransportRequestPromise>; - rollupSearch< - TResponse = Record, - TRequestBody extends RequestBody = Record, - TContext = unknown - >( - params?: RequestParams.RollupRollupSearch, - options?: TransportRequestOptions - ): TransportRequestPromise>; - startJob, TContext = unknown>( - params?: RequestParams.RollupStartJob, - options?: TransportRequestOptions - ): TransportRequestPromise>; - stopJob, TContext = unknown>( - params?: RequestParams.RollupStopJob, - options?: TransportRequestOptions - ): TransportRequestPromise>; - }; - scriptsPainlessExecute< - TResponse = Record, - TRequestBody extends RequestBody = Record, - TContext = unknown - >( - params?: RequestParams.ScriptsPainlessExecute, - options?: TransportRequestOptions - ): TransportRequestPromise>; - scroll< - TResponse = Record, - TRequestBody extends RequestBody = Record, - TContext = unknown - >( - params?: RequestParams.Scroll, - options?: TransportRequestOptions - ): TransportRequestPromise>; - search< - TResponse = Record, - TRequestBody extends RequestBody = Record, - TContext = unknown - >( - params?: RequestParams.Search, - options?: TransportRequestOptions - ): TransportRequestPromise>; - searchShards, TContext = unknown>( - params?: RequestParams.SearchShards, - options?: TransportRequestOptions - ): TransportRequestPromise>; - searchTemplate< - TResponse = Record, - TRequestBody extends RequestBody = Record, - TContext = unknown - >( - params?: RequestParams.SearchTemplate, - options?: TransportRequestOptions - ): TransportRequestPromise>; - searchableSnapshots: { - clearCache, TContext = unknown>( - params?: RequestParams.SearchableSnapshotsClearCache, - options?: TransportRequestOptions - ): TransportRequestPromise>; - mount< - TResponse = Record, - TRequestBody extends RequestBody = Record, - TContext = unknown - >( - params?: RequestParams.SearchableSnapshotsMount, - options?: TransportRequestOptions - ): TransportRequestPromise>; - repositoryStats, TContext = unknown>( - params?: RequestParams.SearchableSnapshotsRepositoryStats, - options?: TransportRequestOptions - ): TransportRequestPromise>; - stats, TContext = unknown>( - params?: RequestParams.SearchableSnapshotsStats, - options?: TransportRequestOptions - ): TransportRequestPromise>; - }; - security: { - authenticate, TContext = unknown>( - params?: RequestParams.SecurityAuthenticate, - options?: TransportRequestOptions - ): TransportRequestPromise>; - changePassword< - TResponse = Record, - TRequestBody extends RequestBody = Record, - TContext = unknown - >( - params?: RequestParams.SecurityChangePassword, - options?: TransportRequestOptions - ): TransportRequestPromise>; - clearCachedRealms, TContext = unknown>( - params?: RequestParams.SecurityClearCachedRealms, - options?: TransportRequestOptions - ): TransportRequestPromise>; - clearCachedRoles, TContext = unknown>( - params?: RequestParams.SecurityClearCachedRoles, - options?: TransportRequestOptions - ): TransportRequestPromise>; - createApiKey< - TResponse = Record, - TRequestBody extends RequestBody = Record, - TContext = unknown - >( - params?: RequestParams.SecurityCreateApiKey, - options?: TransportRequestOptions - ): TransportRequestPromise>; - deletePrivileges, TContext = unknown>( - params?: RequestParams.SecurityDeletePrivileges, - options?: TransportRequestOptions - ): TransportRequestPromise>; - deleteRole, TContext = unknown>( - params?: RequestParams.SecurityDeleteRole, - options?: TransportRequestOptions - ): TransportRequestPromise>; - deleteRoleMapping, TContext = unknown>( - params?: RequestParams.SecurityDeleteRoleMapping, - options?: TransportRequestOptions - ): TransportRequestPromise>; - deleteUser, TContext = unknown>( - params?: RequestParams.SecurityDeleteUser, - options?: TransportRequestOptions - ): TransportRequestPromise>; - disableUser, TContext = unknown>( - params?: RequestParams.SecurityDisableUser, - options?: TransportRequestOptions - ): TransportRequestPromise>; - enableUser, TContext = unknown>( - params?: RequestParams.SecurityEnableUser, - options?: TransportRequestOptions - ): TransportRequestPromise>; - getApiKey, TContext = unknown>( - params?: RequestParams.SecurityGetApiKey, - options?: TransportRequestOptions - ): TransportRequestPromise>; - getBuiltinPrivileges, TContext = unknown>( - params?: RequestParams.SecurityGetBuiltinPrivileges, - options?: TransportRequestOptions - ): TransportRequestPromise>; - getPrivileges, TContext = unknown>( - params?: RequestParams.SecurityGetPrivileges, - options?: TransportRequestOptions - ): TransportRequestPromise>; - getRole, TContext = unknown>( - params?: RequestParams.SecurityGetRole, - options?: TransportRequestOptions - ): TransportRequestPromise>; - getRoleMapping, TContext = unknown>( - params?: RequestParams.SecurityGetRoleMapping, - options?: TransportRequestOptions - ): TransportRequestPromise>; - getToken< - TResponse = Record, - TRequestBody extends RequestBody = Record, - TContext = unknown - >( - params?: RequestParams.SecurityGetToken, - options?: TransportRequestOptions - ): TransportRequestPromise>; - getUser, TContext = unknown>( - params?: RequestParams.SecurityGetUser, - options?: TransportRequestOptions - ): TransportRequestPromise>; - getUserPrivileges, TContext = unknown>( - params?: RequestParams.SecurityGetUserPrivileges, - options?: TransportRequestOptions - ): TransportRequestPromise>; - hasPrivileges< - TResponse = Record, - TRequestBody extends RequestBody = Record, - TContext = unknown - >( - params?: RequestParams.SecurityHasPrivileges, - options?: TransportRequestOptions - ): TransportRequestPromise>; - invalidateApiKey< - TResponse = Record, - TRequestBody extends RequestBody = Record, - TContext = unknown - >( - params?: RequestParams.SecurityInvalidateApiKey, - options?: TransportRequestOptions - ): TransportRequestPromise>; - invalidateToken< - TResponse = Record, - TRequestBody extends RequestBody = Record, - TContext = unknown - >( - params?: RequestParams.SecurityInvalidateToken, - options?: TransportRequestOptions - ): TransportRequestPromise>; - putPrivileges< - TResponse = Record, - TRequestBody extends RequestBody = Record, - TContext = unknown - >( - params?: RequestParams.SecurityPutPrivileges, - options?: TransportRequestOptions - ): TransportRequestPromise>; - putRole< - TResponse = Record, - TRequestBody extends RequestBody = Record, - TContext = unknown - >( - params?: RequestParams.SecurityPutRole, - options?: TransportRequestOptions - ): TransportRequestPromise>; - putRoleMapping< - TResponse = Record, - TRequestBody extends RequestBody = Record, - TContext = unknown - >( - params?: RequestParams.SecurityPutRoleMapping, - options?: TransportRequestOptions - ): TransportRequestPromise>; - putUser< - TResponse = Record, - TRequestBody extends RequestBody = Record, - TContext = unknown - >( - params?: RequestParams.SecurityPutUser, - options?: TransportRequestOptions - ): TransportRequestPromise>; - }; - slm: { - deleteLifecycle, TContext = unknown>( - params?: RequestParams.SlmDeleteLifecycle, - options?: TransportRequestOptions - ): TransportRequestPromise>; - executeLifecycle, TContext = unknown>( - params?: RequestParams.SlmExecuteLifecycle, - options?: TransportRequestOptions - ): TransportRequestPromise>; - executeRetention, TContext = unknown>( - params?: RequestParams.SlmExecuteRetention, - options?: TransportRequestOptions - ): TransportRequestPromise>; - getLifecycle, TContext = unknown>( - params?: RequestParams.SlmGetLifecycle, - options?: TransportRequestOptions - ): TransportRequestPromise>; - getStats, TContext = unknown>( - params?: RequestParams.SlmGetStats, - options?: TransportRequestOptions - ): TransportRequestPromise>; - getStatus, TContext = unknown>( - params?: RequestParams.SlmGetStatus, - options?: TransportRequestOptions - ): TransportRequestPromise>; - putLifecycle< - TResponse = Record, - TRequestBody extends RequestBody = Record, - TContext = unknown - >( - params?: RequestParams.SlmPutLifecycle, - options?: TransportRequestOptions - ): TransportRequestPromise>; - start, TContext = unknown>( - params?: RequestParams.SlmStart, - options?: TransportRequestOptions - ): TransportRequestPromise>; - stop, TContext = unknown>( - params?: RequestParams.SlmStop, - options?: TransportRequestOptions - ): TransportRequestPromise>; - }; - snapshot: { - cleanupRepository, TContext = unknown>( - params?: RequestParams.SnapshotCleanupRepository, - options?: TransportRequestOptions - ): TransportRequestPromise>; - create< - TResponse = Record, - TRequestBody extends RequestBody = Record, - TContext = unknown - >( - params?: RequestParams.SnapshotCreate, - options?: TransportRequestOptions - ): TransportRequestPromise>; - createRepository< - TResponse = Record, - TRequestBody extends RequestBody = Record, - TContext = unknown - >( - params?: RequestParams.SnapshotCreateRepository, - options?: TransportRequestOptions - ): TransportRequestPromise>; - delete, TContext = unknown>( - params?: RequestParams.SnapshotDelete, - options?: TransportRequestOptions - ): TransportRequestPromise>; - deleteRepository, TContext = unknown>( - params?: RequestParams.SnapshotDeleteRepository, - options?: TransportRequestOptions - ): TransportRequestPromise>; - get, TContext = unknown>( - params?: RequestParams.SnapshotGet, - options?: TransportRequestOptions - ): TransportRequestPromise>; - getRepository, TContext = unknown>( - params?: RequestParams.SnapshotGetRepository, - options?: TransportRequestOptions - ): TransportRequestPromise>; - restore< - TResponse = Record, - TRequestBody extends RequestBody = Record, - TContext = unknown - >( - params?: RequestParams.SnapshotRestore, - options?: TransportRequestOptions - ): TransportRequestPromise>; - status, TContext = unknown>( - params?: RequestParams.SnapshotStatus, - options?: TransportRequestOptions - ): TransportRequestPromise>; - verifyRepository, TContext = unknown>( - params?: RequestParams.SnapshotVerifyRepository, - options?: TransportRequestOptions - ): TransportRequestPromise>; - }; - sql: { - clearCursor< - TResponse = Record, - TRequestBody extends RequestBody = Record, - TContext = unknown - >( - params?: RequestParams.SqlClearCursor, - options?: TransportRequestOptions - ): TransportRequestPromise>; - query< - TResponse = Record, - TRequestBody extends RequestBody = Record, - TContext = unknown - >( - params?: RequestParams.SqlQuery, - options?: TransportRequestOptions - ): TransportRequestPromise>; - translate< - TResponse = Record, - TRequestBody extends RequestBody = Record, - TContext = unknown - >( - params?: RequestParams.SqlTranslate, - options?: TransportRequestOptions - ): TransportRequestPromise>; - }; - ssl: { - certificates, TContext = unknown>( - params?: RequestParams.SslCertificates, - options?: TransportRequestOptions - ): TransportRequestPromise>; - }; - tasks: { - cancel, TContext = unknown>( - params?: RequestParams.TasksCancel, - options?: TransportRequestOptions - ): TransportRequestPromise>; - get, TContext = unknown>( - params?: RequestParams.TasksGet, - options?: TransportRequestOptions - ): TransportRequestPromise>; - list, TContext = unknown>( - params?: RequestParams.TasksList, - options?: TransportRequestOptions - ): TransportRequestPromise>; - }; - termvectors< - TResponse = Record, - TRequestBody extends RequestBody = Record, - TContext = unknown - >( - params?: RequestParams.Termvectors, - options?: TransportRequestOptions - ): TransportRequestPromise>; - transform: { - deleteTransform, TContext = unknown>( - params?: RequestParams.TransformDeleteTransform, - options?: TransportRequestOptions - ): TransportRequestPromise>; - getTransform, TContext = unknown>( - params?: RequestParams.TransformGetTransform, - options?: TransportRequestOptions - ): TransportRequestPromise>; - getTransformStats, TContext = unknown>( - params?: RequestParams.TransformGetTransformStats, - options?: TransportRequestOptions - ): TransportRequestPromise>; - previewTransform< - TResponse = Record, - TRequestBody extends RequestBody = Record, - TContext = unknown - >( - params?: RequestParams.TransformPreviewTransform, - options?: TransportRequestOptions - ): TransportRequestPromise>; - putTransform< - TResponse = Record, - TRequestBody extends RequestBody = Record, - TContext = unknown - >( - params?: RequestParams.TransformPutTransform, - options?: TransportRequestOptions - ): TransportRequestPromise>; - startTransform, TContext = unknown>( - params?: RequestParams.TransformStartTransform, - options?: TransportRequestOptions - ): TransportRequestPromise>; - stopTransform, TContext = unknown>( - params?: RequestParams.TransformStopTransform, - options?: TransportRequestOptions - ): TransportRequestPromise>; - updateTransform< - TResponse = Record, - TRequestBody extends RequestBody = Record, - TContext = unknown - >( - params?: RequestParams.TransformUpdateTransform, - options?: TransportRequestOptions - ): TransportRequestPromise>; - }; - update< - TResponse = Record, - TRequestBody extends RequestBody = Record, - TContext = unknown - >( - params?: RequestParams.Update, - options?: TransportRequestOptions - ): TransportRequestPromise>; - updateByQuery< - TResponse = Record, - TRequestBody extends RequestBody = Record, - TContext = unknown - >( - params?: RequestParams.UpdateByQuery, - options?: TransportRequestOptions - ): TransportRequestPromise>; - updateByQueryRethrottle, TContext = unknown>( - params?: RequestParams.UpdateByQueryRethrottle, - options?: TransportRequestOptions - ): TransportRequestPromise>; - watcher: { - ackWatch, TContext = unknown>( - params?: RequestParams.WatcherAckWatch, - options?: TransportRequestOptions - ): TransportRequestPromise>; - activateWatch, TContext = unknown>( - params?: RequestParams.WatcherActivateWatch, - options?: TransportRequestOptions - ): TransportRequestPromise>; - deactivateWatch, TContext = unknown>( - params?: RequestParams.WatcherDeactivateWatch, - options?: TransportRequestOptions - ): TransportRequestPromise>; - deleteWatch, TContext = unknown>( - params?: RequestParams.WatcherDeleteWatch, - options?: TransportRequestOptions - ): TransportRequestPromise>; - executeWatch< - TResponse = Record, - TRequestBody extends RequestBody = Record, - TContext = unknown - >( - params?: RequestParams.WatcherExecuteWatch, - options?: TransportRequestOptions - ): TransportRequestPromise>; - getWatch, TContext = unknown>( - params?: RequestParams.WatcherGetWatch, - options?: TransportRequestOptions - ): TransportRequestPromise>; - putWatch< - TResponse = Record, - TRequestBody extends RequestBody = Record, - TContext = unknown - >( - params?: RequestParams.WatcherPutWatch, - options?: TransportRequestOptions - ): TransportRequestPromise>; - start, TContext = unknown>( - params?: RequestParams.WatcherStart, - options?: TransportRequestOptions - ): TransportRequestPromise>; - stats, TContext = unknown>( - params?: RequestParams.WatcherStats, - options?: TransportRequestOptions - ): TransportRequestPromise>; - stop, TContext = unknown>( - params?: RequestParams.WatcherStop, - options?: TransportRequestOptions - ): TransportRequestPromise>; - }; - xpack: { - info, TContext = unknown>( - params?: RequestParams.XpackInfo, - options?: TransportRequestOptions - ): TransportRequestPromise>; - usage, TContext = unknown>( - params?: RequestParams.XpackUsage, - options?: TransportRequestOptions - ): TransportRequestPromise>; - }; - /* /GENERATED */ -} diff --git a/src/core/server/elasticsearch/client/cluster_client.test.mocks.ts b/src/core/server/elasticsearch/client/cluster_client.test.mocks.ts index 35d0093c16189bc..e08c0d55b455197 100644 --- a/src/core/server/elasticsearch/client/cluster_client.test.mocks.ts +++ b/src/core/server/elasticsearch/client/cluster_client.test.mocks.ts @@ -21,8 +21,3 @@ export const configureClientMock = jest.fn(); jest.doMock('./configure_client', () => ({ configureClient: configureClientMock, })); - -export const getClientFacadeMock = jest.fn(); -jest.doMock('./get_client_facade', () => ({ - getClientFacade: getClientFacadeMock, -})); diff --git a/src/core/server/elasticsearch/client/cluster_client.test.ts b/src/core/server/elasticsearch/client/cluster_client.test.ts index e02d16b3049a4c5..0d2274b67e8fe1e 100644 --- a/src/core/server/elasticsearch/client/cluster_client.test.ts +++ b/src/core/server/elasticsearch/client/cluster_client.test.ts @@ -17,8 +17,7 @@ * under the License. */ -import type { Client } from '@elastic/elasticsearch'; -import { configureClientMock, getClientFacadeMock } from './cluster_client.test.mocks'; +import { configureClientMock } from './cluster_client.test.mocks'; import { loggingSystemMock } from '../../logging/logging_system.mock'; import { httpServerMock } from '../../http/http_server.mocks'; import { GetAuthHeaders } from '../../http'; @@ -26,12 +25,6 @@ import { elasticsearchClientMock } from './mocks'; import { ClusterClient } from './cluster_client'; import { ElasticsearchClientConfig } from './client_config'; -const createClientMock = (): jest.Mocked => { - return ({ - close: jest.fn(), - } as unknown) as jest.Mocked; -}; - const createConfig = ( parts: Partial = {} ): ElasticsearchClientConfig => { @@ -50,15 +43,13 @@ const createConfig = ( describe('ClusterClient', () => { let logger: ReturnType; let getAuthHeaders: jest.MockedFunction; - let internalClient: jest.Mocked; - let scopedClient: jest.Mocked; - let internalFacade: ReturnType; + let internalClient: ReturnType; + let scopedClient: ReturnType; beforeEach(() => { logger = loggingSystemMock.createLogger(); - internalClient = createClientMock(); - scopedClient = createClientMock(); - internalFacade = elasticsearchClientMock.createFacade(); + internalClient = elasticsearchClientMock.createInternalClient(); + scopedClient = elasticsearchClientMock.createInternalClient(); getAuthHeaders = jest.fn().mockImplementation(() => ({ authorization: 'auth', foo: 'bar', @@ -67,18 +58,10 @@ describe('ClusterClient', () => { configureClientMock.mockImplementation((config, { scoped = false }) => { return scoped ? scopedClient : internalClient; }); - - getClientFacadeMock.mockImplementation((client) => { - if (client === internalClient) { - return internalFacade; - } - return elasticsearchClientMock.createFacade(); - }); }); afterEach(() => { configureClientMock.mockReset(); - getClientFacadeMock.mockReset(); }); it('creates a single internal and scoped client during initialization', () => { @@ -89,19 +72,13 @@ describe('ClusterClient', () => { expect(configureClientMock).toHaveBeenCalledTimes(2); expect(configureClientMock).toHaveBeenCalledWith(config, { logger }); expect(configureClientMock).toHaveBeenCalledWith(config, { logger, scoped: true }); - - expect(getClientFacadeMock).toHaveBeenCalledTimes(1); - expect(getClientFacadeMock).toHaveBeenCalledWith(internalClient); }); describe('#asInternalUser', () => { - it('returns the facade using the internal client', () => { + it('returns the internal client', () => { const clusterClient = new ClusterClient(createConfig(), logger, getAuthHeaders); - getClientFacadeMock.mockClear(); - - expect(clusterClient.asInternalUser()).toBe(internalFacade); - expect(getClientFacadeMock).not.toHaveBeenCalled(); + expect(clusterClient.asInternalUser()).toBe(internalClient); }); }); @@ -110,33 +87,29 @@ describe('ClusterClient', () => { const clusterClient = new ClusterClient(createConfig(), logger, getAuthHeaders); const request = httpServerMock.createKibanaRequest(); - getClientFacadeMock.mockClear(); - const scopedClusterClient = clusterClient.asScoped(request); - expect(getClientFacadeMock).toHaveBeenCalledTimes(1); - expect(getClientFacadeMock).toHaveBeenCalledWith(scopedClient, expect.any(Object)); + expect(scopedClient.child).toHaveBeenCalledTimes(1); + expect(scopedClient.child).toHaveBeenCalledWith({ headers: expect.any(Object) }); expect(scopedClusterClient.asInternalUser()).toBe(clusterClient.asInternalUser()); - expect(scopedClusterClient.asCurrentUser()).toBe(getClientFacadeMock.mock.results[0].value); + expect(scopedClusterClient.asCurrentUser()).toBe(scopedClient.child.mock.results[0].value); }); - it('returns a distinct facade on each call', () => { + it('returns a distinct scoped cluster client on each call', () => { const clusterClient = new ClusterClient(createConfig(), logger, getAuthHeaders); const request = httpServerMock.createKibanaRequest(); - getClientFacadeMock.mockClear(); - const scopedClusterClient1 = clusterClient.asScoped(request); const scopedClusterClient2 = clusterClient.asScoped(request); - expect(getClientFacadeMock).toHaveBeenCalledTimes(2); + expect(scopedClient.child).toHaveBeenCalledTimes(2); expect(scopedClusterClient1).not.toBe(scopedClusterClient2); expect(scopedClusterClient1.asInternalUser()).toBe(scopedClusterClient2.asInternalUser()); }); - it('creates a scoped facade with filtered request headers', () => { + it('creates a scoped client with filtered request headers', () => { const config = createConfig({ requestHeadersWhitelist: ['foo'], }); @@ -150,13 +123,11 @@ describe('ClusterClient', () => { }, }); - getClientFacadeMock.mockClear(); - clusterClient.asScoped(request); - expect(getClientFacadeMock).toHaveBeenCalledTimes(1); - expect(getClientFacadeMock).toHaveBeenCalledWith(scopedClient, { - foo: 'bar', + expect(scopedClient.child).toHaveBeenCalledTimes(1); + expect(scopedClient.child).toHaveBeenCalledWith({ + headers: { foo: 'bar' }, }); }); @@ -172,13 +143,11 @@ describe('ClusterClient', () => { const clusterClient = new ClusterClient(config, logger, getAuthHeaders); const request = httpServerMock.createKibanaRequest({}); - getClientFacadeMock.mockClear(); - clusterClient.asScoped(request); - expect(getClientFacadeMock).toHaveBeenCalledTimes(1); - expect(getClientFacadeMock).toHaveBeenCalledWith(scopedClient, { - authorization: 'auth', + expect(scopedClient.child).toHaveBeenCalledTimes(1); + expect(scopedClient.child).toHaveBeenCalledWith({ + headers: { authorization: 'auth' }, }); }); @@ -198,13 +167,87 @@ describe('ClusterClient', () => { }, }); - getClientFacadeMock.mockClear(); + clusterClient.asScoped(request); + + expect(scopedClient.child).toHaveBeenCalledTimes(1); + expect(scopedClient.child).toHaveBeenCalledWith({ + headers: { authorization: 'auth' }, + }); + }); + + it('includes the `customHeaders` from the config when creating the child client', () => { + const config = createConfig({ + customHeaders: { + foo: 'bar', + hello: 'dolly', + }, + requestHeadersWhitelist: ['authorization'], + }); + getAuthHeaders.mockReturnValue({}); + + const clusterClient = new ClusterClient(config, logger, getAuthHeaders); + const request = httpServerMock.createKibanaRequest({}); clusterClient.asScoped(request); - expect(getClientFacadeMock).toHaveBeenCalledTimes(1); - expect(getClientFacadeMock).toHaveBeenCalledWith(scopedClient, { - authorization: 'auth', + expect(scopedClient.child).toHaveBeenCalledTimes(1); + expect(scopedClient.child).toHaveBeenCalledWith({ + headers: { + foo: 'bar', + hello: 'dolly', + }, + }); + }); + + it('respect the precedence of auth headers over config headers', () => { + const config = createConfig({ + customHeaders: { + foo: 'config', + hello: 'dolly', + }, + requestHeadersWhitelist: ['foo'], + }); + getAuthHeaders.mockReturnValue({ + foo: 'auth', + }); + + const clusterClient = new ClusterClient(config, logger, getAuthHeaders); + const request = httpServerMock.createKibanaRequest({}); + + clusterClient.asScoped(request); + + expect(scopedClient.child).toHaveBeenCalledTimes(1); + expect(scopedClient.child).toHaveBeenCalledWith({ + headers: { + foo: 'auth', + hello: 'dolly', + }, + }); + }); + + it('respect the precedence of request headers over config headers', () => { + const config = createConfig({ + customHeaders: { + foo: 'config', + hello: 'dolly', + }, + requestHeadersWhitelist: ['foo'], + }); + getAuthHeaders.mockReturnValue({}); + + const clusterClient = new ClusterClient(config, logger, getAuthHeaders); + const request = httpServerMock.createKibanaRequest({ + headers: { foo: 'request' }, + }); + + clusterClient.asScoped(request); + + expect(scopedClient.child).toHaveBeenCalledTimes(1); + expect(scopedClient.child).toHaveBeenCalledWith({ + headers: { + foo: 'request', + hello: 'dolly', + }, }); }); @@ -222,13 +265,11 @@ describe('ClusterClient', () => { }, }; - getClientFacadeMock.mockClear(); - clusterClient.asScoped(request); - expect(getClientFacadeMock).toHaveBeenCalledTimes(1); - expect(getClientFacadeMock).toHaveBeenCalledWith(scopedClient, { - authorization: 'auth', + expect(scopedClient.child).toHaveBeenCalledTimes(1); + expect(scopedClient.child).toHaveBeenCalledWith({ + headers: { authorization: 'auth' }, }); }); @@ -248,13 +289,11 @@ describe('ClusterClient', () => { }, }; - getClientFacadeMock.mockClear(); - clusterClient.asScoped(request); - expect(getClientFacadeMock).toHaveBeenCalledTimes(1); - expect(getClientFacadeMock).toHaveBeenCalledWith(scopedClient, { - foo: 'bar', + expect(scopedClient.child).toHaveBeenCalledTimes(1); + expect(scopedClient.child).toHaveBeenCalledWith({ + headers: { foo: 'bar' }, }); }); }); diff --git a/src/core/server/elasticsearch/client/cluster_client.ts b/src/core/server/elasticsearch/client/cluster_client.ts index fae0be98ee0e884..0638efc1d813319 100644 --- a/src/core/server/elasticsearch/client/cluster_client.ts +++ b/src/core/server/elasticsearch/client/cluster_client.ts @@ -22,8 +22,7 @@ import { Logger } from '../../logging'; import { GetAuthHeaders, isRealRequest, Headers } from '../../http'; import { ensureRawRequest, filterHeaders } from '../../http/router'; import { ScopeableRequest } from '../types'; -import { getClientFacade } from './get_client_facade'; -import { ClientFacade } from './client_facade'; +import { ElasticSearchClient } from './types'; import { configureClient } from './configure_client'; import { ElasticsearchClientConfig } from './client_config'; import { ScopedClusterClient, IScopedClusterClient } from './scoped_cluster_client'; @@ -39,9 +38,9 @@ const noop = () => undefined; **/ export interface IClusterClient { /** - * Returns a {@link ClientFacade | facade} to be used to query the ES cluster on behalf of the Kibana internal user + * Returns a {@link ElasticSearchClient | client} to be used to query the ES cluster on behalf of the Kibana internal user */ - asInternalUser: () => ClientFacade; + asInternalUser: () => ElasticSearchClient; /** * Creates a {@link IScopedClusterClient | scoped cluster client} bound to given {@link ScopeableRequest | request} */ @@ -64,9 +63,8 @@ export interface ICustomClusterClient extends IClusterClient { /** @internal **/ export class ClusterClient implements IClusterClient, ICustomClusterClient { private readonly internalClient: Client; - private readonly scopedClient: Client; + private readonly rootScopedClient: Client; - private readonly internalFacade: ClientFacade; private isClosed = false; constructor( @@ -75,18 +73,19 @@ export class ClusterClient implements IClusterClient, ICustomClusterClient { private readonly getAuthHeaders: GetAuthHeaders = noop ) { this.internalClient = configureClient(config, { logger }); - this.internalFacade = getClientFacade(this.internalClient); - this.scopedClient = configureClient(config, { logger, scoped: true }); + this.rootScopedClient = configureClient(config, { logger, scoped: true }); } asInternalUser() { - return this.internalFacade; + return this.internalClient; } asScoped(request: ScopeableRequest) { - const headers = this.getScopedHeaders(request); - const scopedWrapper = getClientFacade(this.scopedClient, headers); - return new ScopedClusterClient(this.internalFacade, scopedWrapper); + const scopedHeaders = this.getScopedHeaders(request); + const scopedClient = this.rootScopedClient.child({ + headers: scopedHeaders, + }); + return new ScopedClusterClient(this.internalClient, scopedClient); } public close() { @@ -96,16 +95,25 @@ export class ClusterClient implements IClusterClient, ICustomClusterClient { this.isClosed = true; this.internalClient.close(); - this.scopedClient.close(); + this.rootScopedClient.close(); } private getScopedHeaders(request: ScopeableRequest): Headers { - if (!isRealRequest(request)) { - return filterHeaders(request?.headers ?? {}, this.config.requestHeadersWhitelist); + let scopedHeaders: Headers; + if (isRealRequest(request)) { + const authHeaders = this.getAuthHeaders(request); + const requestHeaders = ensureRawRequest(request).headers; + scopedHeaders = filterHeaders( + { ...requestHeaders, ...authHeaders }, + this.config.requestHeadersWhitelist + ); + } else { + scopedHeaders = filterHeaders(request?.headers ?? {}, this.config.requestHeadersWhitelist); } - const authHeaders = this.getAuthHeaders(request); - const headers = ensureRawRequest(request).headers; - return filterHeaders({ ...headers, ...authHeaders }, this.config.requestHeadersWhitelist); + return { + ...this.config.customHeaders, + ...scopedHeaders, + }; } } diff --git a/src/core/server/elasticsearch/client/get_client_facade.test.ts b/src/core/server/elasticsearch/client/get_client_facade.test.ts deleted file mode 100644 index 12160acfc435c1c..000000000000000 --- a/src/core/server/elasticsearch/client/get_client_facade.test.ts +++ /dev/null @@ -1,87 +0,0 @@ -/* - * 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 { Client } from '@elastic/elasticsearch'; -import { getClientFacade } from './get_client_facade'; - -// note this is only a partial version of the Client API -// as the facade is generated from our script, we can assume it is safe to -// only test behavior from arbitrary picked methods -// it also avoid to generate yet another file with a -// fully mocked `Client` interface -const getClientMock = (): DeeplyMockedKeys => { - return { - transport: { - request: jest.fn(), - }, - search: jest.fn(), - } as any; -}; - -describe('getClientFacade', () => { - let client: DeeplyMockedKeys; - - beforeEach(() => { - client = getClientMock(); - }); - - it('calls the client with correct parameters', () => { - const facade = getClientFacade(client, {}); - - facade.search({ from: 12, preference: 'pref' }, { maxRetries: 42 }); - - expect(client.search).toHaveBeenCalledTimes(1); - expect(client.search).toHaveBeenCalledWith( - { from: 12, preference: 'pref' }, - { maxRetries: 42, headers: {} } - ); - }); - - it('adds the facade headers to the `options.headers`', () => { - const facade = getClientFacade(client, { foo: 'bar', authorization: 'go' }); - - facade.search({}); - - expect(client.search).toHaveBeenCalledWith(expect.any(Object), { - headers: { foo: 'bar', authorization: 'go' }, - }); - }); - - it('respects the caller headers precedence', () => { - const facade = getClientFacade(client, { foo: 'facade', authorization: 'go' }); - - facade.search( - {}, - { - headers: { - foo: 'caller', - bar: 'true', - }, - } - ); - - expect(client.search).toHaveBeenCalledWith(expect.any(Object), { - headers: { - foo: 'caller', - authorization: 'go', - bar: 'true', - }, - }); - }); -}); diff --git a/src/core/server/elasticsearch/client/get_client_facade.ts b/src/core/server/elasticsearch/client/get_client_facade.ts deleted file mode 100644 index 8818fbf01390c95..000000000000000 --- a/src/core/server/elasticsearch/client/get_client_facade.ts +++ /dev/null @@ -1,534 +0,0 @@ -/* - * 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 { Client } from '@elastic/elasticsearch'; -import { TransportRequestOptions } from '@elastic/elasticsearch/lib/Transport'; -import { Headers } from '../../http/router'; -import { ClientFacade } from './client_facade'; - -/** - * Returns a {@link ClientFacade | facade} to be used to query given es client. - * - * This is used both for the internal client and the scoped ones. authorization header - * must be passed when creating a scoped facade. - * - * @internal - */ -export const getClientFacade = (client: Client, headers: Headers = {}): ClientFacade => { - // do not rename or change this method signature without adapting the API generation script - // at `src/dev/generate_es_client.ts` - const addHeaders = (options?: TransportRequestOptions): TransportRequestOptions => { - if (!options) { - return { - headers, - }; - } - return { - ...options, - headers: { - ...headers, - ...options.headers, - }, - }; - }; - - return { - transport: { - request: (params, options) => client.transport.request(params, addHeaders(options)), - }, - /* GENERATED */ - asyncSearch: { - delete: (params, options) => client.asyncSearch.delete(params, addHeaders(options)), - get: (params, options) => client.asyncSearch.get(params, addHeaders(options)), - submit: (params, options) => client.asyncSearch.submit(params, addHeaders(options)), - }, - autoscaling: { - deleteAutoscalingPolicy: (params, options) => - client.autoscaling.deleteAutoscalingPolicy(params, addHeaders(options)), - getAutoscalingDecision: (params, options) => - client.autoscaling.getAutoscalingDecision(params, addHeaders(options)), - getAutoscalingPolicy: (params, options) => - client.autoscaling.getAutoscalingPolicy(params, addHeaders(options)), - putAutoscalingPolicy: (params, options) => - client.autoscaling.putAutoscalingPolicy(params, addHeaders(options)), - }, - bulk: (params, options) => client.bulk(params, addHeaders(options)), - cat: { - aliases: (params, options) => client.cat.aliases(params, addHeaders(options)), - allocation: (params, options) => client.cat.allocation(params, addHeaders(options)), - count: (params, options) => client.cat.count(params, addHeaders(options)), - fielddata: (params, options) => client.cat.fielddata(params, addHeaders(options)), - health: (params, options) => client.cat.health(params, addHeaders(options)), - help: (params, options) => client.cat.help(params, addHeaders(options)), - indices: (params, options) => client.cat.indices(params, addHeaders(options)), - master: (params, options) => client.cat.master(params, addHeaders(options)), - mlDataFrameAnalytics: (params, options) => - client.cat.mlDataFrameAnalytics(params, addHeaders(options)), - mlDatafeeds: (params, options) => client.cat.mlDatafeeds(params, addHeaders(options)), - mlJobs: (params, options) => client.cat.mlJobs(params, addHeaders(options)), - mlTrainedModels: (params, options) => client.cat.mlTrainedModels(params, addHeaders(options)), - nodeattrs: (params, options) => client.cat.nodeattrs(params, addHeaders(options)), - nodes: (params, options) => client.cat.nodes(params, addHeaders(options)), - pendingTasks: (params, options) => client.cat.pendingTasks(params, addHeaders(options)), - plugins: (params, options) => client.cat.plugins(params, addHeaders(options)), - recovery: (params, options) => client.cat.recovery(params, addHeaders(options)), - repositories: (params, options) => client.cat.repositories(params, addHeaders(options)), - segments: (params, options) => client.cat.segments(params, addHeaders(options)), - shards: (params, options) => client.cat.shards(params, addHeaders(options)), - snapshots: (params, options) => client.cat.snapshots(params, addHeaders(options)), - tasks: (params, options) => client.cat.tasks(params, addHeaders(options)), - templates: (params, options) => client.cat.templates(params, addHeaders(options)), - threadPool: (params, options) => client.cat.threadPool(params, addHeaders(options)), - transforms: (params, options) => client.cat.transforms(params, addHeaders(options)), - }, - ccr: { - deleteAutoFollowPattern: (params, options) => - client.ccr.deleteAutoFollowPattern(params, addHeaders(options)), - follow: (params, options) => client.ccr.follow(params, addHeaders(options)), - followInfo: (params, options) => client.ccr.followInfo(params, addHeaders(options)), - followStats: (params, options) => client.ccr.followStats(params, addHeaders(options)), - forgetFollower: (params, options) => client.ccr.forgetFollower(params, addHeaders(options)), - getAutoFollowPattern: (params, options) => - client.ccr.getAutoFollowPattern(params, addHeaders(options)), - pauseAutoFollowPattern: (params, options) => - client.ccr.pauseAutoFollowPattern(params, addHeaders(options)), - pauseFollow: (params, options) => client.ccr.pauseFollow(params, addHeaders(options)), - putAutoFollowPattern: (params, options) => - client.ccr.putAutoFollowPattern(params, addHeaders(options)), - resumeAutoFollowPattern: (params, options) => - client.ccr.resumeAutoFollowPattern(params, addHeaders(options)), - resumeFollow: (params, options) => client.ccr.resumeFollow(params, addHeaders(options)), - stats: (params, options) => client.ccr.stats(params, addHeaders(options)), - unfollow: (params, options) => client.ccr.unfollow(params, addHeaders(options)), - }, - clearScroll: (params, options) => client.clearScroll(params, addHeaders(options)), - cluster: { - allocationExplain: (params, options) => - client.cluster.allocationExplain(params, addHeaders(options)), - deleteComponentTemplate: (params, options) => - client.cluster.deleteComponentTemplate(params, addHeaders(options)), - deleteVotingConfigExclusions: (params, options) => - client.cluster.deleteVotingConfigExclusions(params, addHeaders(options)), - existsComponentTemplate: (params, options) => - client.cluster.existsComponentTemplate(params, addHeaders(options)), - getComponentTemplate: (params, options) => - client.cluster.getComponentTemplate(params, addHeaders(options)), - getSettings: (params, options) => client.cluster.getSettings(params, addHeaders(options)), - health: (params, options) => client.cluster.health(params, addHeaders(options)), - pendingTasks: (params, options) => client.cluster.pendingTasks(params, addHeaders(options)), - postVotingConfigExclusions: (params, options) => - client.cluster.postVotingConfigExclusions(params, addHeaders(options)), - putComponentTemplate: (params, options) => - client.cluster.putComponentTemplate(params, addHeaders(options)), - putSettings: (params, options) => client.cluster.putSettings(params, addHeaders(options)), - remoteInfo: (params, options) => client.cluster.remoteInfo(params, addHeaders(options)), - reroute: (params, options) => client.cluster.reroute(params, addHeaders(options)), - state: (params, options) => client.cluster.state(params, addHeaders(options)), - stats: (params, options) => client.cluster.stats(params, addHeaders(options)), - }, - count: (params, options) => client.count(params, addHeaders(options)), - create: (params, options) => client.create(params, addHeaders(options)), - delete: (params, options) => client.delete(params, addHeaders(options)), - deleteByQuery: (params, options) => client.deleteByQuery(params, addHeaders(options)), - deleteByQueryRethrottle: (params, options) => - client.deleteByQueryRethrottle(params, addHeaders(options)), - deleteScript: (params, options) => client.deleteScript(params, addHeaders(options)), - enrich: { - deletePolicy: (params, options) => client.enrich.deletePolicy(params, addHeaders(options)), - executePolicy: (params, options) => client.enrich.executePolicy(params, addHeaders(options)), - getPolicy: (params, options) => client.enrich.getPolicy(params, addHeaders(options)), - putPolicy: (params, options) => client.enrich.putPolicy(params, addHeaders(options)), - stats: (params, options) => client.enrich.stats(params, addHeaders(options)), - }, - eql: { - search: (params, options) => client.eql.search(params, addHeaders(options)), - }, - exists: (params, options) => client.exists(params, addHeaders(options)), - existsSource: (params, options) => client.existsSource(params, addHeaders(options)), - explain: (params, options) => client.explain(params, addHeaders(options)), - fieldCaps: (params, options) => client.fieldCaps(params, addHeaders(options)), - get: (params, options) => client.get(params, addHeaders(options)), - getScript: (params, options) => client.getScript(params, addHeaders(options)), - getScriptContext: (params, options) => client.getScriptContext(params, addHeaders(options)), - getScriptLanguages: (params, options) => client.getScriptLanguages(params, addHeaders(options)), - getSource: (params, options) => client.getSource(params, addHeaders(options)), - graph: { - explore: (params, options) => client.graph.explore(params, addHeaders(options)), - }, - ilm: { - deleteLifecycle: (params, options) => client.ilm.deleteLifecycle(params, addHeaders(options)), - explainLifecycle: (params, options) => - client.ilm.explainLifecycle(params, addHeaders(options)), - getLifecycle: (params, options) => client.ilm.getLifecycle(params, addHeaders(options)), - getStatus: (params, options) => client.ilm.getStatus(params, addHeaders(options)), - moveToStep: (params, options) => client.ilm.moveToStep(params, addHeaders(options)), - putLifecycle: (params, options) => client.ilm.putLifecycle(params, addHeaders(options)), - removePolicy: (params, options) => client.ilm.removePolicy(params, addHeaders(options)), - retry: (params, options) => client.ilm.retry(params, addHeaders(options)), - start: (params, options) => client.ilm.start(params, addHeaders(options)), - stop: (params, options) => client.ilm.stop(params, addHeaders(options)), - }, - index: (params, options) => client.index(params, addHeaders(options)), - indices: { - analyze: (params, options) => client.indices.analyze(params, addHeaders(options)), - clearCache: (params, options) => client.indices.clearCache(params, addHeaders(options)), - clone: (params, options) => client.indices.clone(params, addHeaders(options)), - close: (params, options) => client.indices.close(params, addHeaders(options)), - create: (params, options) => client.indices.create(params, addHeaders(options)), - createDataStream: (params, options) => - client.indices.createDataStream(params, addHeaders(options)), - delete: (params, options) => client.indices.delete(params, addHeaders(options)), - deleteAlias: (params, options) => client.indices.deleteAlias(params, addHeaders(options)), - deleteDataStream: (params, options) => - client.indices.deleteDataStream(params, addHeaders(options)), - deleteIndexTemplate: (params, options) => - client.indices.deleteIndexTemplate(params, addHeaders(options)), - deleteTemplate: (params, options) => - client.indices.deleteTemplate(params, addHeaders(options)), - exists: (params, options) => client.indices.exists(params, addHeaders(options)), - existsAlias: (params, options) => client.indices.existsAlias(params, addHeaders(options)), - existsIndexTemplate: (params, options) => - client.indices.existsIndexTemplate(params, addHeaders(options)), - existsTemplate: (params, options) => - client.indices.existsTemplate(params, addHeaders(options)), - existsType: (params, options) => client.indices.existsType(params, addHeaders(options)), - flush: (params, options) => client.indices.flush(params, addHeaders(options)), - flushSynced: (params, options) => client.indices.flushSynced(params, addHeaders(options)), - forcemerge: (params, options) => client.indices.forcemerge(params, addHeaders(options)), - freeze: (params, options) => client.indices.freeze(params, addHeaders(options)), - get: (params, options) => client.indices.get(params, addHeaders(options)), - getAlias: (params, options) => client.indices.getAlias(params, addHeaders(options)), - getDataStreams: (params, options) => - client.indices.getDataStreams(params, addHeaders(options)), - getFieldMapping: (params, options) => - client.indices.getFieldMapping(params, addHeaders(options)), - getIndexTemplate: (params, options) => - client.indices.getIndexTemplate(params, addHeaders(options)), - getMapping: (params, options) => client.indices.getMapping(params, addHeaders(options)), - getSettings: (params, options) => client.indices.getSettings(params, addHeaders(options)), - getTemplate: (params, options) => client.indices.getTemplate(params, addHeaders(options)), - getUpgrade: (params, options) => client.indices.getUpgrade(params, addHeaders(options)), - open: (params, options) => client.indices.open(params, addHeaders(options)), - putAlias: (params, options) => client.indices.putAlias(params, addHeaders(options)), - putIndexTemplate: (params, options) => - client.indices.putIndexTemplate(params, addHeaders(options)), - putMapping: (params, options) => client.indices.putMapping(params, addHeaders(options)), - putSettings: (params, options) => client.indices.putSettings(params, addHeaders(options)), - putTemplate: (params, options) => client.indices.putTemplate(params, addHeaders(options)), - recovery: (params, options) => client.indices.recovery(params, addHeaders(options)), - refresh: (params, options) => client.indices.refresh(params, addHeaders(options)), - reloadSearchAnalyzers: (params, options) => - client.indices.reloadSearchAnalyzers(params, addHeaders(options)), - rollover: (params, options) => client.indices.rollover(params, addHeaders(options)), - segments: (params, options) => client.indices.segments(params, addHeaders(options)), - shardStores: (params, options) => client.indices.shardStores(params, addHeaders(options)), - shrink: (params, options) => client.indices.shrink(params, addHeaders(options)), - simulateIndexTemplate: (params, options) => - client.indices.simulateIndexTemplate(params, addHeaders(options)), - split: (params, options) => client.indices.split(params, addHeaders(options)), - stats: (params, options) => client.indices.stats(params, addHeaders(options)), - unfreeze: (params, options) => client.indices.unfreeze(params, addHeaders(options)), - updateAliases: (params, options) => client.indices.updateAliases(params, addHeaders(options)), - upgrade: (params, options) => client.indices.upgrade(params, addHeaders(options)), - validateQuery: (params, options) => client.indices.validateQuery(params, addHeaders(options)), - }, - info: (params, options) => client.info(params, addHeaders(options)), - ingest: { - deletePipeline: (params, options) => - client.ingest.deletePipeline(params, addHeaders(options)), - getPipeline: (params, options) => client.ingest.getPipeline(params, addHeaders(options)), - processorGrok: (params, options) => client.ingest.processorGrok(params, addHeaders(options)), - putPipeline: (params, options) => client.ingest.putPipeline(params, addHeaders(options)), - simulate: (params, options) => client.ingest.simulate(params, addHeaders(options)), - }, - license: { - delete: (params, options) => client.license.delete(params, addHeaders(options)), - get: (params, options) => client.license.get(params, addHeaders(options)), - getBasicStatus: (params, options) => - client.license.getBasicStatus(params, addHeaders(options)), - getTrialStatus: (params, options) => - client.license.getTrialStatus(params, addHeaders(options)), - post: (params, options) => client.license.post(params, addHeaders(options)), - postStartBasic: (params, options) => - client.license.postStartBasic(params, addHeaders(options)), - postStartTrial: (params, options) => - client.license.postStartTrial(params, addHeaders(options)), - }, - mget: (params, options) => client.mget(params, addHeaders(options)), - migration: { - deprecations: (params, options) => client.migration.deprecations(params, addHeaders(options)), - }, - ml: { - closeJob: (params, options) => client.ml.closeJob(params, addHeaders(options)), - deleteCalendar: (params, options) => client.ml.deleteCalendar(params, addHeaders(options)), - deleteCalendarEvent: (params, options) => - client.ml.deleteCalendarEvent(params, addHeaders(options)), - deleteCalendarJob: (params, options) => - client.ml.deleteCalendarJob(params, addHeaders(options)), - deleteDataFrameAnalytics: (params, options) => - client.ml.deleteDataFrameAnalytics(params, addHeaders(options)), - deleteDatafeed: (params, options) => client.ml.deleteDatafeed(params, addHeaders(options)), - deleteExpiredData: (params, options) => - client.ml.deleteExpiredData(params, addHeaders(options)), - deleteFilter: (params, options) => client.ml.deleteFilter(params, addHeaders(options)), - deleteForecast: (params, options) => client.ml.deleteForecast(params, addHeaders(options)), - deleteJob: (params, options) => client.ml.deleteJob(params, addHeaders(options)), - deleteModelSnapshot: (params, options) => - client.ml.deleteModelSnapshot(params, addHeaders(options)), - deleteTrainedModel: (params, options) => - client.ml.deleteTrainedModel(params, addHeaders(options)), - estimateModelMemory: (params, options) => - client.ml.estimateModelMemory(params, addHeaders(options)), - evaluateDataFrame: (params, options) => - client.ml.evaluateDataFrame(params, addHeaders(options)), - explainDataFrameAnalytics: (params, options) => - client.ml.explainDataFrameAnalytics(params, addHeaders(options)), - findFileStructure: (params, options) => - client.ml.findFileStructure(params, addHeaders(options)), - flushJob: (params, options) => client.ml.flushJob(params, addHeaders(options)), - forecast: (params, options) => client.ml.forecast(params, addHeaders(options)), - getBuckets: (params, options) => client.ml.getBuckets(params, addHeaders(options)), - getCalendarEvents: (params, options) => - client.ml.getCalendarEvents(params, addHeaders(options)), - getCalendars: (params, options) => client.ml.getCalendars(params, addHeaders(options)), - getCategories: (params, options) => client.ml.getCategories(params, addHeaders(options)), - getDataFrameAnalytics: (params, options) => - client.ml.getDataFrameAnalytics(params, addHeaders(options)), - getDataFrameAnalyticsStats: (params, options) => - client.ml.getDataFrameAnalyticsStats(params, addHeaders(options)), - getDatafeedStats: (params, options) => - client.ml.getDatafeedStats(params, addHeaders(options)), - getDatafeeds: (params, options) => client.ml.getDatafeeds(params, addHeaders(options)), - getFilters: (params, options) => client.ml.getFilters(params, addHeaders(options)), - getInfluencers: (params, options) => client.ml.getInfluencers(params, addHeaders(options)), - getJobStats: (params, options) => client.ml.getJobStats(params, addHeaders(options)), - getJobs: (params, options) => client.ml.getJobs(params, addHeaders(options)), - getModelSnapshots: (params, options) => - client.ml.getModelSnapshots(params, addHeaders(options)), - getOverallBuckets: (params, options) => - client.ml.getOverallBuckets(params, addHeaders(options)), - getRecords: (params, options) => client.ml.getRecords(params, addHeaders(options)), - getTrainedModels: (params, options) => - client.ml.getTrainedModels(params, addHeaders(options)), - getTrainedModelsStats: (params, options) => - client.ml.getTrainedModelsStats(params, addHeaders(options)), - info: (params, options) => client.ml.info(params, addHeaders(options)), - openJob: (params, options) => client.ml.openJob(params, addHeaders(options)), - postCalendarEvents: (params, options) => - client.ml.postCalendarEvents(params, addHeaders(options)), - postData: (params, options) => client.ml.postData(params, addHeaders(options)), - previewDatafeed: (params, options) => client.ml.previewDatafeed(params, addHeaders(options)), - putCalendar: (params, options) => client.ml.putCalendar(params, addHeaders(options)), - putCalendarJob: (params, options) => client.ml.putCalendarJob(params, addHeaders(options)), - putDataFrameAnalytics: (params, options) => - client.ml.putDataFrameAnalytics(params, addHeaders(options)), - putDatafeed: (params, options) => client.ml.putDatafeed(params, addHeaders(options)), - putFilter: (params, options) => client.ml.putFilter(params, addHeaders(options)), - putJob: (params, options) => client.ml.putJob(params, addHeaders(options)), - putTrainedModel: (params, options) => client.ml.putTrainedModel(params, addHeaders(options)), - revertModelSnapshot: (params, options) => - client.ml.revertModelSnapshot(params, addHeaders(options)), - setUpgradeMode: (params, options) => client.ml.setUpgradeMode(params, addHeaders(options)), - startDataFrameAnalytics: (params, options) => - client.ml.startDataFrameAnalytics(params, addHeaders(options)), - startDatafeed: (params, options) => client.ml.startDatafeed(params, addHeaders(options)), - stopDataFrameAnalytics: (params, options) => - client.ml.stopDataFrameAnalytics(params, addHeaders(options)), - stopDatafeed: (params, options) => client.ml.stopDatafeed(params, addHeaders(options)), - updateDatafeed: (params, options) => client.ml.updateDatafeed(params, addHeaders(options)), - updateFilter: (params, options) => client.ml.updateFilter(params, addHeaders(options)), - updateJob: (params, options) => client.ml.updateJob(params, addHeaders(options)), - updateModelSnapshot: (params, options) => - client.ml.updateModelSnapshot(params, addHeaders(options)), - validate: (params, options) => client.ml.validate(params, addHeaders(options)), - validateDetector: (params, options) => - client.ml.validateDetector(params, addHeaders(options)), - }, - monitoring: { - bulk: (params, options) => client.monitoring.bulk(params, addHeaders(options)), - }, - msearch: (params, options) => client.msearch(params, addHeaders(options)), - msearchTemplate: (params, options) => client.msearchTemplate(params, addHeaders(options)), - mtermvectors: (params, options) => client.mtermvectors(params, addHeaders(options)), - nodes: { - hotThreads: (params, options) => client.nodes.hotThreads(params, addHeaders(options)), - info: (params, options) => client.nodes.info(params, addHeaders(options)), - reloadSecureSettings: (params, options) => - client.nodes.reloadSecureSettings(params, addHeaders(options)), - stats: (params, options) => client.nodes.stats(params, addHeaders(options)), - usage: (params, options) => client.nodes.usage(params, addHeaders(options)), - }, - ping: (params, options) => client.ping(params, addHeaders(options)), - putScript: (params, options) => client.putScript(params, addHeaders(options)), - rankEval: (params, options) => client.rankEval(params, addHeaders(options)), - reindex: (params, options) => client.reindex(params, addHeaders(options)), - reindexRethrottle: (params, options) => client.reindexRethrottle(params, addHeaders(options)), - renderSearchTemplate: (params, options) => - client.renderSearchTemplate(params, addHeaders(options)), - rollup: { - deleteJob: (params, options) => client.rollup.deleteJob(params, addHeaders(options)), - getJobs: (params, options) => client.rollup.getJobs(params, addHeaders(options)), - getRollupCaps: (params, options) => client.rollup.getRollupCaps(params, addHeaders(options)), - getRollupIndexCaps: (params, options) => - client.rollup.getRollupIndexCaps(params, addHeaders(options)), - putJob: (params, options) => client.rollup.putJob(params, addHeaders(options)), - rollupSearch: (params, options) => client.rollup.rollupSearch(params, addHeaders(options)), - startJob: (params, options) => client.rollup.startJob(params, addHeaders(options)), - stopJob: (params, options) => client.rollup.stopJob(params, addHeaders(options)), - }, - scriptsPainlessExecute: (params, options) => - client.scriptsPainlessExecute(params, addHeaders(options)), - scroll: (params, options) => client.scroll(params, addHeaders(options)), - search: (params, options) => client.search(params, addHeaders(options)), - searchShards: (params, options) => client.searchShards(params, addHeaders(options)), - searchTemplate: (params, options) => client.searchTemplate(params, addHeaders(options)), - searchableSnapshots: { - clearCache: (params, options) => - client.searchableSnapshots.clearCache(params, addHeaders(options)), - mount: (params, options) => client.searchableSnapshots.mount(params, addHeaders(options)), - repositoryStats: (params, options) => - client.searchableSnapshots.repositoryStats(params, addHeaders(options)), - stats: (params, options) => client.searchableSnapshots.stats(params, addHeaders(options)), - }, - security: { - authenticate: (params, options) => client.security.authenticate(params, addHeaders(options)), - changePassword: (params, options) => - client.security.changePassword(params, addHeaders(options)), - clearCachedRealms: (params, options) => - client.security.clearCachedRealms(params, addHeaders(options)), - clearCachedRoles: (params, options) => - client.security.clearCachedRoles(params, addHeaders(options)), - createApiKey: (params, options) => client.security.createApiKey(params, addHeaders(options)), - deletePrivileges: (params, options) => - client.security.deletePrivileges(params, addHeaders(options)), - deleteRole: (params, options) => client.security.deleteRole(params, addHeaders(options)), - deleteRoleMapping: (params, options) => - client.security.deleteRoleMapping(params, addHeaders(options)), - deleteUser: (params, options) => client.security.deleteUser(params, addHeaders(options)), - disableUser: (params, options) => client.security.disableUser(params, addHeaders(options)), - enableUser: (params, options) => client.security.enableUser(params, addHeaders(options)), - getApiKey: (params, options) => client.security.getApiKey(params, addHeaders(options)), - getBuiltinPrivileges: (params, options) => - client.security.getBuiltinPrivileges(params, addHeaders(options)), - getPrivileges: (params, options) => - client.security.getPrivileges(params, addHeaders(options)), - getRole: (params, options) => client.security.getRole(params, addHeaders(options)), - getRoleMapping: (params, options) => - client.security.getRoleMapping(params, addHeaders(options)), - getToken: (params, options) => client.security.getToken(params, addHeaders(options)), - getUser: (params, options) => client.security.getUser(params, addHeaders(options)), - getUserPrivileges: (params, options) => - client.security.getUserPrivileges(params, addHeaders(options)), - hasPrivileges: (params, options) => - client.security.hasPrivileges(params, addHeaders(options)), - invalidateApiKey: (params, options) => - client.security.invalidateApiKey(params, addHeaders(options)), - invalidateToken: (params, options) => - client.security.invalidateToken(params, addHeaders(options)), - putPrivileges: (params, options) => - client.security.putPrivileges(params, addHeaders(options)), - putRole: (params, options) => client.security.putRole(params, addHeaders(options)), - putRoleMapping: (params, options) => - client.security.putRoleMapping(params, addHeaders(options)), - putUser: (params, options) => client.security.putUser(params, addHeaders(options)), - }, - slm: { - deleteLifecycle: (params, options) => client.slm.deleteLifecycle(params, addHeaders(options)), - executeLifecycle: (params, options) => - client.slm.executeLifecycle(params, addHeaders(options)), - executeRetention: (params, options) => - client.slm.executeRetention(params, addHeaders(options)), - getLifecycle: (params, options) => client.slm.getLifecycle(params, addHeaders(options)), - getStats: (params, options) => client.slm.getStats(params, addHeaders(options)), - getStatus: (params, options) => client.slm.getStatus(params, addHeaders(options)), - putLifecycle: (params, options) => client.slm.putLifecycle(params, addHeaders(options)), - start: (params, options) => client.slm.start(params, addHeaders(options)), - stop: (params, options) => client.slm.stop(params, addHeaders(options)), - }, - snapshot: { - cleanupRepository: (params, options) => - client.snapshot.cleanupRepository(params, addHeaders(options)), - create: (params, options) => client.snapshot.create(params, addHeaders(options)), - createRepository: (params, options) => - client.snapshot.createRepository(params, addHeaders(options)), - delete: (params, options) => client.snapshot.delete(params, addHeaders(options)), - deleteRepository: (params, options) => - client.snapshot.deleteRepository(params, addHeaders(options)), - get: (params, options) => client.snapshot.get(params, addHeaders(options)), - getRepository: (params, options) => - client.snapshot.getRepository(params, addHeaders(options)), - restore: (params, options) => client.snapshot.restore(params, addHeaders(options)), - status: (params, options) => client.snapshot.status(params, addHeaders(options)), - verifyRepository: (params, options) => - client.snapshot.verifyRepository(params, addHeaders(options)), - }, - sql: { - clearCursor: (params, options) => client.sql.clearCursor(params, addHeaders(options)), - query: (params, options) => client.sql.query(params, addHeaders(options)), - translate: (params, options) => client.sql.translate(params, addHeaders(options)), - }, - ssl: { - certificates: (params, options) => client.ssl.certificates(params, addHeaders(options)), - }, - tasks: { - cancel: (params, options) => client.tasks.cancel(params, addHeaders(options)), - get: (params, options) => client.tasks.get(params, addHeaders(options)), - list: (params, options) => client.tasks.list(params, addHeaders(options)), - }, - termvectors: (params, options) => client.termvectors(params, addHeaders(options)), - transform: { - deleteTransform: (params, options) => - client.transform.deleteTransform(params, addHeaders(options)), - getTransform: (params, options) => client.transform.getTransform(params, addHeaders(options)), - getTransformStats: (params, options) => - client.transform.getTransformStats(params, addHeaders(options)), - previewTransform: (params, options) => - client.transform.previewTransform(params, addHeaders(options)), - putTransform: (params, options) => client.transform.putTransform(params, addHeaders(options)), - startTransform: (params, options) => - client.transform.startTransform(params, addHeaders(options)), - stopTransform: (params, options) => - client.transform.stopTransform(params, addHeaders(options)), - updateTransform: (params, options) => - client.transform.updateTransform(params, addHeaders(options)), - }, - update: (params, options) => client.update(params, addHeaders(options)), - updateByQuery: (params, options) => client.updateByQuery(params, addHeaders(options)), - updateByQueryRethrottle: (params, options) => - client.updateByQueryRethrottle(params, addHeaders(options)), - watcher: { - ackWatch: (params, options) => client.watcher.ackWatch(params, addHeaders(options)), - activateWatch: (params, options) => client.watcher.activateWatch(params, addHeaders(options)), - deactivateWatch: (params, options) => - client.watcher.deactivateWatch(params, addHeaders(options)), - deleteWatch: (params, options) => client.watcher.deleteWatch(params, addHeaders(options)), - executeWatch: (params, options) => client.watcher.executeWatch(params, addHeaders(options)), - getWatch: (params, options) => client.watcher.getWatch(params, addHeaders(options)), - putWatch: (params, options) => client.watcher.putWatch(params, addHeaders(options)), - start: (params, options) => client.watcher.start(params, addHeaders(options)), - stats: (params, options) => client.watcher.stats(params, addHeaders(options)), - stop: (params, options) => client.watcher.stop(params, addHeaders(options)), - }, - xpack: { - info: (params, options) => client.xpack.info(params, addHeaders(options)), - usage: (params, options) => client.xpack.usage(params, addHeaders(options)), - }, - /* /GENERATED */ - }; -}; diff --git a/src/core/server/elasticsearch/client/index.ts b/src/core/server/elasticsearch/client/index.ts index 5a81f0e296e9bb4..1a2f1f013d69f67 100644 --- a/src/core/server/elasticsearch/client/index.ts +++ b/src/core/server/elasticsearch/client/index.ts @@ -17,8 +17,8 @@ * under the License. */ +export { ElasticSearchClient } from './types'; export { IScopedClusterClient, ScopedClusterClient } from './scoped_cluster_client'; -export { ClientFacade } from './client_facade'; export { ElasticsearchClientConfig } from './client_config'; export { IClusterClient, ICustomClusterClient, ClusterClient } from './cluster_client'; export { configureClient } from './configure_client'; diff --git a/src/core/server/elasticsearch/client/mocks.test.ts b/src/core/server/elasticsearch/client/mocks.test.ts new file mode 100644 index 000000000000000..b882f8d0c5d79cd --- /dev/null +++ b/src/core/server/elasticsearch/client/mocks.test.ts @@ -0,0 +1,60 @@ +/* + * 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 { elasticsearchClientMock } from './mocks'; + +describe('Mocked client', () => { + let client: ReturnType; + + const expectMocked = (fn: jest.MockedFunction | undefined) => { + expect(fn).toBeDefined(); + expect(fn.mockReturnValue).toEqual(expect.any(Function)); + }; + + beforeEach(() => { + client = elasticsearchClientMock.createInternalClient(); + }); + + it('`transport.request` should be mocked', () => { + expectMocked(client.transport.request); + }); + + it('root level API methods should be mocked', () => { + expectMocked(client.bulk); + expectMocked(client.search); + }); + + it('nested level API methods should be mocked', () => { + expectMocked(client.asyncSearch.get); + expectMocked(client.nodes.info); + }); + + it('`close` should be mocked', () => { + expectMocked(client.close); + }); + + it('`child` should be mocked and return a mocked Client', () => { + expectMocked(client.child); + + const child = client.child(); + + expect(child).not.toBe(client); + expectMocked(child.search); + }); +}); diff --git a/src/core/server/elasticsearch/client/mocks.ts b/src/core/server/elasticsearch/client/mocks.ts index 377830351eff546..2816389d003cd91 100644 --- a/src/core/server/elasticsearch/client/mocks.ts +++ b/src/core/server/elasticsearch/client/mocks.ts @@ -17,20 +17,64 @@ * under the License. */ -import { ApiResponse } from '@elastic/elasticsearch'; +import { Client, ApiResponse } from '@elastic/elasticsearch'; import { TransportRequestPromise } from '@elastic/elasticsearch/lib/Transport'; -import { clientFacadeMock } from './client_facade.mock'; +import { ElasticSearchClient } from './types'; import { IScopedClusterClient } from './scoped_cluster_client'; import { IClusterClient, ICustomClusterClient } from './cluster_client'; +const createInternalClientMock = (): DeeplyMockedKeys => { + // we mimic 'reflection' on a concrete instance of the client to generate the mocked functions. + const client = new Client({ + node: 'http://localhost', + }) as any; + + const blackListedProps = [ + '_events', + '_eventsCount', + '_maxListeners', + 'name', + 'serializer', + 'connectionPool', + 'transport', + 'helpers', + ]; + + const mockify = (obj: Record, blacklist: string[] = []) => { + Object.keys(obj) + .filter((key) => !blacklist.includes(key)) + .forEach((key) => { + const propType = typeof obj[key]; + if (propType === 'function') { + obj[key] = jest.fn(); + } else if (propType === 'object' && obj[key] != null) { + mockify(obj[key]); + } + }); + }; + + mockify(client, blackListedProps); + + client.transport = { + request: jest.fn(), + }; + client.close = jest.fn(); + client.child = jest.fn().mockImplementation(() => createInternalClientMock()); + + return (client as unknown) as DeeplyMockedKeys; +}; + +const createClientMock = (): DeeplyMockedKeys => + (createInternalClientMock() as unknown) as DeeplyMockedKeys; + const createScopedClusterClientMock = () => { const mock: jest.Mocked = { asInternalUser: jest.fn(), asCurrentUser: jest.fn(), }; - mock.asInternalUser.mockReturnValue(clientFacadeMock.create()); - mock.asCurrentUser.mockReturnValue(clientFacadeMock.create()); + mock.asInternalUser.mockReturnValue(createClientMock()); + mock.asCurrentUser.mockReturnValue(createClientMock()); return mock; }; @@ -41,7 +85,7 @@ const createClusterClientMock = () => { asScoped: jest.fn(), }; - mock.asInternalUser.mockReturnValue(clientFacadeMock.create()); + mock.asInternalUser.mockReturnValue(createClientMock()); mock.asScoped.mockReturnValue(createScopedClusterClientMock()); return mock; @@ -54,7 +98,7 @@ const createCustomClusterClientMock = () => { close: jest.fn(), }; - mock.asInternalUser.mockReturnValue(clientFacadeMock.create()); + mock.asInternalUser.mockReturnValue(createClientMock()); mock.asScoped.mockReturnValue(createScopedClusterClientMock()); return mock; @@ -88,7 +132,8 @@ export const elasticsearchClientMock = { createClusterClient: createClusterClientMock, createCustomClusterClient: createCustomClusterClientMock, createScopedClusterClient: createScopedClusterClientMock, - createFacade: clientFacadeMock.create, + createElasticSearchClient: createClientMock, + createInternalClient: createInternalClientMock, createClientResponse: createMockedClientResponse, createClientError: createMockedClientError, }; diff --git a/src/core/server/elasticsearch/client/scoped_cluster_client.test.ts b/src/core/server/elasticsearch/client/scoped_cluster_client.test.ts index c7d9b9ba9e303e9..ec5b92a2b2b9998 100644 --- a/src/core/server/elasticsearch/client/scoped_cluster_client.test.ts +++ b/src/core/server/elasticsearch/client/scoped_cluster_client.test.ts @@ -22,8 +22,8 @@ import { ScopedClusterClient } from './scoped_cluster_client'; describe('ScopedClusterClient', () => { it('uses the internal client passed in the constructor', () => { - const internalClient = elasticsearchClientMock.createFacade(); - const scopedClient = elasticsearchClientMock.createFacade(); + const internalClient = elasticsearchClientMock.createElasticSearchClient(); + const scopedClient = elasticsearchClientMock.createElasticSearchClient(); const scopedClusterClient = new ScopedClusterClient(internalClient, scopedClient); @@ -31,8 +31,8 @@ describe('ScopedClusterClient', () => { }); it('uses the scoped client passed in the constructor', () => { - const internalClient = elasticsearchClientMock.createFacade(); - const scopedClient = elasticsearchClientMock.createFacade(); + const internalClient = elasticsearchClientMock.createElasticSearchClient(); + const scopedClient = elasticsearchClientMock.createElasticSearchClient(); const scopedClusterClient = new ScopedClusterClient(internalClient, scopedClient); diff --git a/src/core/server/elasticsearch/client/scoped_cluster_client.ts b/src/core/server/elasticsearch/client/scoped_cluster_client.ts index d0ed122bada69bc..2f30deedaf92868 100644 --- a/src/core/server/elasticsearch/client/scoped_cluster_client.ts +++ b/src/core/server/elasticsearch/client/scoped_cluster_client.ts @@ -17,7 +17,7 @@ * under the License. */ -import { ClientFacade } from './client_facade'; +import { ElasticSearchClient } from './types'; /** * Serves the same purpose as the normal {@link ClusterClient | cluster client} but exposes @@ -29,22 +29,22 @@ import { ClientFacade } from './client_facade'; **/ export interface IScopedClusterClient { /** - * Returns a {@link ClientFacade | client facade} to be used to query the elasticsearch cluster + * Returns a {@link ElasticSearchClient | client} to be used to query the elasticsearch cluster * on behalf of the internal Kibana user. */ - asInternalUser: () => ClientFacade; + asInternalUser: () => ElasticSearchClient; /** - * Returns a {@link ClientFacade | client facade} to be used to query the elasticsearch cluster + * Returns a {@link ElasticSearchClient | client} to be used to query the elasticsearch cluster * on behalf of the user that initiated the request to the Kibana server. */ - asCurrentUser: () => ClientFacade; + asCurrentUser: () => ElasticSearchClient; } /** @internal **/ export class ScopedClusterClient implements IScopedClusterClient { constructor( - private readonly internalClient: ClientFacade, - private readonly scopedClient: ClientFacade + private readonly internalClient: ElasticSearchClient, + private readonly scopedClient: ElasticSearchClient ) {} asInternalUser() { diff --git a/scripts/generate_es_client.js b/src/core/server/elasticsearch/client/types.ts similarity index 59% rename from scripts/generate_es_client.js rename to src/core/server/elasticsearch/client/types.ts index 5d7845c933bff0b..6e93c2dddaa224e 100644 --- a/scripts/generate_es_client.js +++ b/src/core/server/elasticsearch/client/types.ts @@ -17,5 +17,26 @@ * under the License. */ -require('../src/setup_node_env'); -require('../src/dev/generate_es_client'); +import type { Client } from '@elastic/elasticsearch'; +import type { + ApiResponse, + TransportRequestOptions, + TransportRequestParams, +} from '@elastic/elasticsearch/lib/Transport'; + +/** + * Client used to query the elasticsearch cluster. + * + * @public + */ +export type ElasticSearchClient = Omit< + Client, + 'connectionPool' | 'transport' | 'serializer' | 'extend' | 'helpers' | 'child' | 'close' +> & { + transport: { + request( + params: TransportRequestParams, + options?: TransportRequestOptions + ): Promise; + }; +}; diff --git a/src/core/server/elasticsearch/index.ts b/src/core/server/elasticsearch/index.ts index 4392aa61d2657f6..c5ee9f5e3d17b05 100644 --- a/src/core/server/elasticsearch/index.ts +++ b/src/core/server/elasticsearch/index.ts @@ -34,6 +34,6 @@ export { IClusterClient, ICustomClusterClient, ElasticsearchClientConfig, - ClientFacade, + ElasticSearchClient, IScopedClusterClient, } from './client'; diff --git a/src/core/server/server.api.md b/src/core/server/server.api.md index da58c1129a6e135..0aecb61fc445322 100644 --- a/src/core/server/server.api.md +++ b/src/core/server/server.api.md @@ -4,7 +4,7 @@ ```ts -import { ApiResponse } from '@elastic/elasticsearch'; +import { ApiResponse } from '@elastic/elasticsearch/lib/Transport'; import Boom from 'boom'; import { BulkIndexDocumentsParams } from 'elasticsearch'; import { CatAliasesParams } from 'elasticsearch'; @@ -22,6 +22,7 @@ import { CatTasksParams } from 'elasticsearch'; import { CatThreadPoolParams } from 'elasticsearch'; import { ClearScrollParams } from 'elasticsearch'; import { Client } from 'elasticsearch'; +import { Client as Client_2 } from '@elastic/elasticsearch'; import { ClientOptions } from '@elastic/elasticsearch'; import { ClusterAllocationExplainParams } from 'elasticsearch'; import { ClusterGetSettingsParams } from 'elasticsearch'; @@ -115,9 +116,6 @@ import { ReindexParams } from 'elasticsearch'; import { ReindexRethrottleParams } from 'elasticsearch'; import { RenderSearchTemplateParams } from 'elasticsearch'; import { Request } from 'hapi'; -import { RequestBody } from '@elastic/elasticsearch/lib/Transport'; -import { RequestNDBody } from '@elastic/elasticsearch/lib/Transport'; -import * as RequestParams from '@elastic/elasticsearch/api/requestParams'; import { ResponseObject } from 'hapi'; import { ResponseToolkit } from 'hapi'; import { SchemaTypeError } from '@kbn/config-schema'; @@ -145,7 +143,6 @@ import { TasksListParams } from 'elasticsearch'; import { TermvectorsParams } from 'elasticsearch'; import { TransportRequestOptions } from '@elastic/elasticsearch/lib/Transport'; import { TransportRequestParams } from '@elastic/elasticsearch/lib/Transport'; -import { TransportRequestPromise } from '@elastic/elasticsearch/lib/Transport'; import { Type } from '@kbn/config-schema'; import { TypeOf } from '@kbn/config-schema'; import { UpdateDocumentByQueryParams } from 'elasticsearch'; diff --git a/src/dev/generate_es_client.ts b/src/dev/generate_es_client.ts deleted file mode 100644 index 55a403d820d8b3f..000000000000000 --- a/src/dev/generate_es_client.ts +++ /dev/null @@ -1,151 +0,0 @@ -/* - * 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 { resolve, join } from 'path'; -import fs from 'fs'; - -const REPO_ROOT = resolve(__dirname, '../../'); -const GENERATION_START_SYMBOL = '/* GENERATED */'; -const GENERATION_END_SYMBOL = '/* /GENERATED */'; - -const sourceFile = join(REPO_ROOT, 'node_modules', '@elastic', 'elasticsearch', 'index.d.ts'); - -const targetFolder = join(REPO_ROOT, 'src', 'core', 'server', 'elasticsearch', 'client'); -const apiFile = join(targetFolder, 'client_facade.ts'); -const implemFile = join(targetFolder, 'get_client_facade.ts'); -const mockFile = join(targetFolder, 'client_facade.mock.ts'); - -const generate = () => { - const clientAPI = readClientAPI(); - const { api, impl, mock } = processClientAPI(clientAPI); - - writeFacadeAPI(api); - writeWrapperDefinition(impl); - writeMockDefinition(mock); - - // apply es-lint to the generated file - // as indentation may not be correct, and some of our lint rules are not respected by the es lib. - process.argv.push('--fix'); - process.argv.push(apiFile); - process.argv.push(implemFile); - process.argv.push(mockFile); - require('./run_eslint'); -}; - -const apiLineRegexp = /^([a-zA-Z_]*)[<]/; -const callbackApiRegexp = /TransportRequestCallback/; - -const blockStartRegexp = /^([a-zA-Z_]*)[:][ ][{]$/; -const blockEndRegexp = /^[}]$/; - -const processClientAPI = (rawContent: string) => { - const apiLines: string[] = []; - const implementationLines: string[] = []; - const mockLines: string[] = []; - - let currentBlock: string | null = null; - let inDeletedBlock = false; - - rawContent - .split('\n') - .map((line) => line.trim()) - .forEach((line) => { - const blockStartMatch = blockStartRegexp.exec(line); - - // start of a block of API, I.E : `asyncSearch: {` - if (blockStartMatch) { - currentBlock = blockStartMatch[1]; - if (currentBlock.includes('_')) { - inDeletedBlock = true; - } else { - // add `[blockName]: {` to both API and implementation - apiLines.push(line); - implementationLines.push(line); - mockLines.push(line); - } - } else if (blockEndRegexp.test(line)) { - if (!inDeletedBlock) { - apiLines.push('}'); - implementationLines.push('},'); - mockLines.push('},'); - } - currentBlock = null; - inDeletedBlock = false; - } else { - const isApiLineMatch = apiLineRegexp.exec(line); - const isCallbackApi = callbackApiRegexp.test(line); - if (isApiLineMatch && !isCallbackApi && !inDeletedBlock) { - const apiName = isApiLineMatch[1]; - if (!apiName.includes('_')) { - apiLines.push(line); - implementationLines.push( - `${apiName}: (params, options) => client${ - currentBlock ? '.' + currentBlock : '' - }.${apiName}(params, addHeaders(options)),` - ); - mockLines.push(`${apiName}: jest.fn(),`); - } - } - } - }); - - return { - api: apiLines.join('\n'), - impl: implementationLines.join('\n'), - mock: mockLines.join('\n'), - }; -}; - -const readClientAPI = (): string => { - const sourceFileContent = fs.readFileSync(sourceFile).toString('utf-8'); - return sourceFileContent.substring( - sourceFileContent.indexOf(GENERATION_START_SYMBOL) + GENERATION_START_SYMBOL.length, - sourceFileContent.indexOf(GENERATION_END_SYMBOL) - ); -}; - -const writeFacadeAPI = (apiDefinition: string) => { - injectGeneratedContent(apiFile, apiDefinition); -}; - -const writeWrapperDefinition = (implemDefinition: string) => { - injectGeneratedContent(implemFile, implemDefinition); -}; - -const writeMockDefinition = (mockDefinition: string) => { - injectGeneratedContent(mockFile, mockDefinition); -}; - -const injectGeneratedContent = (filepath: string, injectedContent: string) => { - const fileContent = fs.readFileSync(filepath, 'utf-8').toString(); - - const newFileContent = - fileContent.slice( - 0, - fileContent.indexOf(GENERATION_START_SYMBOL) + GENERATION_START_SYMBOL.length - ) + - `\n` + - injectedContent + - `\n` + - fileContent.slice(fileContent.indexOf(GENERATION_END_SYMBOL)); - - fs.writeFileSync(filepath, newFileContent); -}; - -generate();