Skip to content

Commit

Permalink
[7.x] Move and rename legacy elasticsearch client (#69797) (#70221)
Browse files Browse the repository at this point in the history
* Move and rename legacy elasticsearch client (#69797)

* move last snapshot to inline

* move legacy files to legacy subfolder

* move request types out of legacy

* export Headers from http instead of elasticsearch

* renaming - first pass

* renaming - second pass

* fix core mocks

* adapt new calls

* update generated doc

* fix IT test mocks

* fix new usages
# Conflicts:
#	src/core/server/saved_objects/service/lib/repository.ts
#	x-pack/plugins/event_log/server/es/context.test.ts
#	x-pack/plugins/oss_telemetry/server/test_utils/index.ts
#	x-pack/plugins/upgrade_assistant/server/lib/es_migration_apis.ts

* fix usages
  • Loading branch information
pgayvallet authored Jun 29, 2020
1 parent e0e276e commit ecd2082
Show file tree
Hide file tree
Showing 306 changed files with 1,675 additions and 1,548 deletions.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

```typescript
legacy: {
readonly createClient: (type: string, clientConfig?: Partial<ElasticsearchClientConfig>) => ICustomClusterClient;
readonly client: IClusterClient;
readonly createClient: (type: string, clientConfig?: Partial<LegacyElasticsearchClientConfig>) => ILegacyCustomClusterClient;
readonly client: ILegacyClusterClient;
};
```
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,5 @@ export interface ElasticsearchServiceSetup

| Property | Type | Description |
| --- | --- | --- |
| [legacy](./kibana-plugin-core-server.elasticsearchservicesetup.legacy.md) | <code>{</code><br/><code> readonly createClient: (type: string, clientConfig?: Partial&lt;ElasticsearchClientConfig&gt;) =&gt; ICustomClusterClient;</code><br/><code> readonly client: IClusterClient;</code><br/><code> }</code> | |
| [legacy](./kibana-plugin-core-server.elasticsearchservicesetup.legacy.md) | <code>{</code><br/><code> readonly createClient: (type: string, clientConfig?: Partial&lt;LegacyElasticsearchClientConfig&gt;) =&gt; ILegacyCustomClusterClient;</code><br/><code> readonly client: ILegacyClusterClient;</code><br/><code> }</code> | |

Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

```typescript
legacy: {
readonly createClient: (type: string, clientConfig?: Partial<ElasticsearchClientConfig>) => ICustomClusterClient;
readonly client: IClusterClient;
readonly createClient: (type: string, clientConfig?: Partial<LegacyElasticsearchClientConfig>) => ILegacyCustomClusterClient;
readonly client: ILegacyClusterClient;
};
```
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,5 @@ export interface ElasticsearchServiceStart

| Property | Type | Description |
| --- | --- | --- |
| [legacy](./kibana-plugin-core-server.elasticsearchservicestart.legacy.md) | <code>{</code><br/><code> readonly createClient: (type: string, clientConfig?: Partial&lt;ElasticsearchClientConfig&gt;) =&gt; ICustomClusterClient;</code><br/><code> readonly client: IClusterClient;</code><br/><code> }</code> | |
| [legacy](./kibana-plugin-core-server.elasticsearchservicestart.legacy.md) | <code>{</code><br/><code> readonly createClient: (type: string, clientConfig?: Partial&lt;LegacyElasticsearchClientConfig&gt;) =&gt; ILegacyCustomClusterClient;</code><br/><code> readonly client: ILegacyClusterClient;</code><br/><code> }</code> | |

Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
<!-- Do not edit this file. It is automatically generated by API Documenter. -->

[Home](./index.md) &gt; [kibana-plugin-core-server](./kibana-plugin-core-server.md) &gt; [IClusterClient](./kibana-plugin-core-server.iclusterclient.md)
[Home](./index.md) &gt; [kibana-plugin-core-server](./kibana-plugin-core-server.md) &gt; [ILegacyClusterClient](./kibana-plugin-core-server.ilegacyclusterclient.md)

## IClusterClient type
## ILegacyClusterClient type

Represents an Elasticsearch cluster API client created by the platform. It allows to call API on behalf of the internal Kibana user and the actual user that is derived from the request headers (via `asScoped(...)`<!-- -->).

See [ClusterClient](./kibana-plugin-core-server.clusterclient.md)<!-- -->.
See [LegacyClusterClient](./kibana-plugin-core-server.legacyclusterclient.md)<!-- -->.

<b>Signature:</b>

```typescript
export declare type IClusterClient = Pick<ClusterClient, 'callAsInternalUser' | 'asScoped'>;
export declare type ILegacyClusterClient = Pick<LegacyClusterClient, 'callAsInternalUser' | 'asScoped'>;
```
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
<!-- Do not edit this file. It is automatically generated by API Documenter. -->

[Home](./index.md) &gt; [kibana-plugin-core-server](./kibana-plugin-core-server.md) &gt; [ICustomClusterClient](./kibana-plugin-core-server.icustomclusterclient.md)
[Home](./index.md) &gt; [kibana-plugin-core-server](./kibana-plugin-core-server.md) &gt; [ILegacyCustomClusterClient](./kibana-plugin-core-server.ilegacycustomclusterclient.md)

## ICustomClusterClient type
## ILegacyCustomClusterClient type

Represents an Elasticsearch cluster API client created by a plugin. It allows to call API on behalf of the internal Kibana user and the actual user that is derived from the request headers (via `asScoped(...)`<!-- -->).

See [ClusterClient](./kibana-plugin-core-server.clusterclient.md)<!-- -->.
See [LegacyClusterClient](./kibana-plugin-core-server.legacyclusterclient.md)<!-- -->.

<b>Signature:</b>

```typescript
export declare type ICustomClusterClient = Pick<ClusterClient, 'callAsInternalUser' | 'close' | 'asScoped'>;
export declare type ILegacyCustomClusterClient = Pick<LegacyClusterClient, 'callAsInternalUser' | 'close' | 'asScoped'>;
```
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
<!-- Do not edit this file. It is automatically generated by API Documenter. -->

[Home](./index.md) &gt; [kibana-plugin-core-server](./kibana-plugin-core-server.md) &gt; [IScopedClusterClient](./kibana-plugin-core-server.iscopedclusterclient.md)
[Home](./index.md) &gt; [kibana-plugin-core-server](./kibana-plugin-core-server.md) &gt; [ILegacyScopedClusterClient](./kibana-plugin-core-server.ilegacyscopedclusterclient.md)

## IScopedClusterClient type
## ILegacyScopedClusterClient type

Serves the same purpose as "normal" `ClusterClient` but exposes additional `callAsCurrentUser` method that doesn't use credentials of the Kibana internal user (as `callAsInternalUser` does) to request Elasticsearch API, but rather passes HTTP headers extracted from the current user request to the API.

See [ScopedClusterClient](./kibana-plugin-core-server.scopedclusterclient.md)<!-- -->.
See [LegacyScopedClusterClient](./kibana-plugin-core-server.legacyscopedclusterclient.md)<!-- -->.

<b>Signature:</b>

```typescript
export declare type IScopedClusterClient = Pick<ScopedClusterClient, 'callAsCurrentUser' | 'callAsInternalUser'>;
export declare type ILegacyScopedClusterClient = Pick<LegacyScopedClusterClient, 'callAsCurrentUser' | 'callAsInternalUser'>;
```
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
<!-- Do not edit this file. It is automatically generated by API Documenter. -->

[Home](./index.md) &gt; [kibana-plugin-core-server](./kibana-plugin-core-server.md) &gt; [APICaller](./kibana-plugin-core-server.apicaller.md)
[Home](./index.md) &gt; [kibana-plugin-core-server](./kibana-plugin-core-server.md) &gt; [LegacyAPICaller](./kibana-plugin-core-server.legacyapicaller.md)

## APICaller interface
## LegacyAPICaller interface


<b>Signature:</b>

```typescript
export interface APICaller
export interface LegacyAPICaller
```
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<!-- Do not edit this file. It is automatically generated by API Documenter. -->

[Home](./index.md) &gt; [kibana-plugin-core-server](./kibana-plugin-core-server.md) &gt; [LegacyCallAPIOptions](./kibana-plugin-core-server.legacycallapioptions.md)

## LegacyCallAPIOptions interface

The set of options that defines how API call should be made and result be processed.

<b>Signature:</b>

```typescript
export interface LegacyCallAPIOptions
```

## Properties

| Property | Type | Description |
| --- | --- | --- |
| [signal](./kibana-plugin-core-server.legacycallapioptions.signal.md) | <code>AbortSignal</code> | A signal object that allows you to abort the request via an AbortController object. |
| [wrap401Errors](./kibana-plugin-core-server.legacycallapioptions.wrap401errors.md) | <code>boolean</code> | Indicates whether <code>401 Unauthorized</code> errors returned from the Elasticsearch API should be wrapped into <code>Boom</code> error instances with properly set <code>WWW-Authenticate</code> header that could have been returned by the API itself. If API didn't specify that then <code>Basic realm=&quot;Authorization Required&quot;</code> is used as <code>WWW-Authenticate</code>. |

Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<!-- Do not edit this file. It is automatically generated by API Documenter. -->

[Home](./index.md) &gt; [kibana-plugin-core-server](./kibana-plugin-core-server.md) &gt; [CallAPIOptions](./kibana-plugin-core-server.callapioptions.md) &gt; [signal](./kibana-plugin-core-server.callapioptions.signal.md)
[Home](./index.md) &gt; [kibana-plugin-core-server](./kibana-plugin-core-server.md) &gt; [LegacyCallAPIOptions](./kibana-plugin-core-server.legacycallapioptions.md) &gt; [signal](./kibana-plugin-core-server.legacycallapioptions.signal.md)

## CallAPIOptions.signal property
## LegacyCallAPIOptions.signal property

A signal object that allows you to abort the request via an AbortController object.

Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<!-- Do not edit this file. It is automatically generated by API Documenter. -->

[Home](./index.md) &gt; [kibana-plugin-core-server](./kibana-plugin-core-server.md) &gt; [CallAPIOptions](./kibana-plugin-core-server.callapioptions.md) &gt; [wrap401Errors](./kibana-plugin-core-server.callapioptions.wrap401errors.md)
[Home](./index.md) &gt; [kibana-plugin-core-server](./kibana-plugin-core-server.md) &gt; [LegacyCallAPIOptions](./kibana-plugin-core-server.legacycallapioptions.md) &gt; [wrap401Errors](./kibana-plugin-core-server.legacycallapioptions.wrap401errors.md)

## CallAPIOptions.wrap401Errors property
## LegacyCallAPIOptions.wrap401Errors property

Indicates whether `401 Unauthorized` errors returned from the Elasticsearch API should be wrapped into `Boom` error instances with properly set `WWW-Authenticate` header that could have been returned by the API itself. If API didn't specify that then `Basic realm="Authorization Required"` is used as `WWW-Authenticate`<!-- -->.

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<!-- Do not edit this file. It is automatically generated by API Documenter. -->

[Home](./index.md) &gt; [kibana-plugin-core-server](./kibana-plugin-core-server.md) &gt; [LegacyClusterClient](./kibana-plugin-core-server.legacyclusterclient.md) &gt; [(constructor)](./kibana-plugin-core-server.legacyclusterclient._constructor_.md)

## LegacyClusterClient.(constructor)

Constructs a new instance of the `LegacyClusterClient` class

<b>Signature:</b>

```typescript
constructor(config: LegacyElasticsearchClientConfig, log: Logger, getAuthHeaders?: GetAuthHeaders);
```

## Parameters

| Parameter | Type | Description |
| --- | --- | --- |
| config | <code>LegacyElasticsearchClientConfig</code> | |
| log | <code>Logger</code> | |
| getAuthHeaders | <code>GetAuthHeaders</code> | |

Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<!-- Do not edit this file. It is automatically generated by API Documenter. -->

[Home](./index.md) &gt; [kibana-plugin-core-server](./kibana-plugin-core-server.md) &gt; [LegacyClusterClient](./kibana-plugin-core-server.legacyclusterclient.md) &gt; [asScoped](./kibana-plugin-core-server.legacyclusterclient.asscoped.md)

## LegacyClusterClient.asScoped() method

Creates an instance of [ILegacyScopedClusterClient](./kibana-plugin-core-server.ilegacyscopedclusterclient.md) based on the configuration the current cluster client that exposes additional `callAsCurrentUser` method scoped to the provided req. Consumers shouldn't worry about closing scoped client instances, these will be automatically closed as soon as the original cluster client isn't needed anymore and closed.

<b>Signature:</b>

```typescript
asScoped(request?: ScopeableRequest): ILegacyScopedClusterClient;
```

## Parameters

| Parameter | Type | Description |
| --- | --- | --- |
| request | <code>ScopeableRequest</code> | Request the <code>IScopedClusterClient</code> instance will be scoped to. Supports request optionality, Legacy.Request &amp; FakeRequest for BWC with LegacyPlatform |

<b>Returns:</b>

`ILegacyScopedClusterClient`

Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<!-- Do not edit this file. It is automatically generated by API Documenter. -->

[Home](./index.md) &gt; [kibana-plugin-core-server](./kibana-plugin-core-server.md) &gt; [LegacyClusterClient](./kibana-plugin-core-server.legacyclusterclient.md) &gt; [callAsInternalUser](./kibana-plugin-core-server.legacyclusterclient.callasinternaluser.md)

## LegacyClusterClient.callAsInternalUser property

Calls specified endpoint with provided clientParams on behalf of the Kibana internal user. See [LegacyAPICaller](./kibana-plugin-core-server.legacyapicaller.md)<!-- -->.

<b>Signature:</b>

```typescript
callAsInternalUser: LegacyAPICaller;
```
Loading

0 comments on commit ecd2082

Please sign in to comment.