diff --git a/docs/development/core/server/kibana-plugin-core-server.corestart.elasticsearch.md b/docs/development/core/server/kibana-plugin-core-server.corestart.elasticsearch.md
new file mode 100644
index 0000000000000..d8f518ceebd64
--- /dev/null
+++ b/docs/development/core/server/kibana-plugin-core-server.corestart.elasticsearch.md
@@ -0,0 +1,13 @@
+
+
+[Home](./index.md) > [kibana-plugin-core-server](./kibana-plugin-core-server.md) > [CoreStart](./kibana-plugin-core-server.corestart.md) > [elasticsearch](./kibana-plugin-core-server.corestart.elasticsearch.md)
+
+## CoreStart.elasticsearch property
+
+[ElasticsearchServiceStart](./kibana-plugin-core-server.elasticsearchservicestart.md)
+
+Signature:
+
+```typescript
+elasticsearch: ElasticsearchServiceStart;
+```
diff --git a/docs/development/core/server/kibana-plugin-core-server.corestart.md b/docs/development/core/server/kibana-plugin-core-server.corestart.md
index 24a5c8f213d9f..c50e8924c9dd4 100644
--- a/docs/development/core/server/kibana-plugin-core-server.corestart.md
+++ b/docs/development/core/server/kibana-plugin-core-server.corestart.md
@@ -17,6 +17,7 @@ export interface CoreStart
| Property | Type | Description |
| --- | --- | --- |
| [capabilities](./kibana-plugin-core-server.corestart.capabilities.md) | CapabilitiesStart
| [CapabilitiesStart](./kibana-plugin-core-server.capabilitiesstart.md) |
+| [elasticsearch](./kibana-plugin-core-server.corestart.elasticsearch.md) | ElasticsearchServiceStart
| [ElasticsearchServiceStart](./kibana-plugin-core-server.elasticsearchservicestart.md) |
| [savedObjects](./kibana-plugin-core-server.corestart.savedobjects.md) | SavedObjectsServiceStart
| [SavedObjectsServiceStart](./kibana-plugin-core-server.savedobjectsservicestart.md) |
| [uiSettings](./kibana-plugin-core-server.corestart.uisettings.md) | UiSettingsServiceStart
| [UiSettingsServiceStart](./kibana-plugin-core-server.uisettingsservicestart.md) |
diff --git a/docs/development/core/server/kibana-plugin-core-server.elasticsearchservicesetup.adminclient.md b/docs/development/core/server/kibana-plugin-core-server.elasticsearchservicesetup.adminclient.md
index 24bd42e83186f..3fcb855586129 100644
--- a/docs/development/core/server/kibana-plugin-core-server.elasticsearchservicesetup.adminclient.md
+++ b/docs/development/core/server/kibana-plugin-core-server.elasticsearchservicesetup.adminclient.md
@@ -4,7 +4,12 @@
## ElasticsearchServiceSetup.adminClient property
-A client for the `admin` cluster. All Elasticsearch config value changes are processed under the hood. See [IClusterClient](./kibana-plugin-core-server.iclusterclient.md).
+> Warning: This API is now obsolete.
+>
+> Use [ElasticsearchServiceStart.legacy.client](./kibana-plugin-core-server.elasticsearchservicestart.legacy.md) instead.
+>
+> A client for the `admin` cluster. All Elasticsearch config value changes are processed under the hood. See [IClusterClient](./kibana-plugin-core-server.iclusterclient.md).
+>
Signature:
diff --git a/docs/development/core/server/kibana-plugin-core-server.elasticsearchservicesetup.createclient.md b/docs/development/core/server/kibana-plugin-core-server.elasticsearchservicesetup.createclient.md
index b739578bbdd80..75bf6c6aa461b 100644
--- a/docs/development/core/server/kibana-plugin-core-server.elasticsearchservicesetup.createclient.md
+++ b/docs/development/core/server/kibana-plugin-core-server.elasticsearchservicesetup.createclient.md
@@ -4,7 +4,12 @@
## ElasticsearchServiceSetup.createClient property
-Create application specific Elasticsearch cluster API client with customized config. See [IClusterClient](./kibana-plugin-core-server.iclusterclient.md).
+> Warning: This API is now obsolete.
+>
+> Use [ElasticsearchServiceStart.legacy.createClient](./kibana-plugin-core-server.elasticsearchservicestart.legacy.md) instead.
+>
+> Create application specific Elasticsearch cluster API client with customized config. See [IClusterClient](./kibana-plugin-core-server.iclusterclient.md).
+>
Signature:
diff --git a/docs/development/core/server/kibana-plugin-core-server.elasticsearchservicesetup.dataclient.md b/docs/development/core/server/kibana-plugin-core-server.elasticsearchservicesetup.dataclient.md
index fae5cee79d6e6..867cafa957f42 100644
--- a/docs/development/core/server/kibana-plugin-core-server.elasticsearchservicesetup.dataclient.md
+++ b/docs/development/core/server/kibana-plugin-core-server.elasticsearchservicesetup.dataclient.md
@@ -4,7 +4,12 @@
## ElasticsearchServiceSetup.dataClient property
-A client for the `data` cluster. All Elasticsearch config value changes are processed under the hood. See [IClusterClient](./kibana-plugin-core-server.iclusterclient.md).
+> Warning: This API is now obsolete.
+>
+> Use [ElasticsearchServiceStart.legacy.client](./kibana-plugin-core-server.elasticsearchservicestart.legacy.md) instead.
+>
+> A client for the `data` cluster. All Elasticsearch config value changes are processed under the hood. See [IClusterClient](./kibana-plugin-core-server.iclusterclient.md).
+>
Signature:
diff --git a/docs/development/core/server/kibana-plugin-core-server.elasticsearchservicesetup.md b/docs/development/core/server/kibana-plugin-core-server.elasticsearchservicesetup.md
index 4e4e8b837d909..ee56f8b4a6284 100644
--- a/docs/development/core/server/kibana-plugin-core-server.elasticsearchservicesetup.md
+++ b/docs/development/core/server/kibana-plugin-core-server.elasticsearchservicesetup.md
@@ -15,7 +15,7 @@ export interface ElasticsearchServiceSetup
| Property | Type | Description |
| --- | --- | --- |
-| [adminClient](./kibana-plugin-core-server.elasticsearchservicesetup.adminclient.md) | IClusterClient
| A client for the admin
cluster. All Elasticsearch config value changes are processed under the hood. See [IClusterClient](./kibana-plugin-core-server.iclusterclient.md). |
-| [createClient](./kibana-plugin-core-server.elasticsearchservicesetup.createclient.md) | (type: string, clientConfig?: Partial<ElasticsearchClientConfig>) => ICustomClusterClient
| Create application specific Elasticsearch cluster API client with customized config. See [IClusterClient](./kibana-plugin-core-server.iclusterclient.md). |
-| [dataClient](./kibana-plugin-core-server.elasticsearchservicesetup.dataclient.md) | IClusterClient
| A client for the data
cluster. All Elasticsearch config value changes are processed under the hood. See [IClusterClient](./kibana-plugin-core-server.iclusterclient.md). |
+| [adminClient](./kibana-plugin-core-server.elasticsearchservicesetup.adminclient.md) | IClusterClient
| |
+| [createClient](./kibana-plugin-core-server.elasticsearchservicesetup.createclient.md) | (type: string, clientConfig?: Partial<ElasticsearchClientConfig>) => ICustomClusterClient
| |
+| [dataClient](./kibana-plugin-core-server.elasticsearchservicesetup.dataclient.md) | IClusterClient
| |
diff --git a/docs/development/core/server/kibana-plugin-core-server.elasticsearchservicestart.legacy.md b/docs/development/core/server/kibana-plugin-core-server.elasticsearchservicestart.legacy.md
new file mode 100644
index 0000000000000..08765aaf93d3d
--- /dev/null
+++ b/docs/development/core/server/kibana-plugin-core-server.elasticsearchservicestart.legacy.md
@@ -0,0 +1,14 @@
+
+
+[Home](./index.md) > [kibana-plugin-core-server](./kibana-plugin-core-server.md) > [ElasticsearchServiceStart](./kibana-plugin-core-server.elasticsearchservicestart.md) > [legacy](./kibana-plugin-core-server.elasticsearchservicestart.legacy.md)
+
+## ElasticsearchServiceStart.legacy property
+
+Signature:
+
+```typescript
+legacy: {
+ readonly createClient: (type: string, clientConfig?: Partial) => ICustomClusterClient;
+ readonly client: IClusterClient;
+ };
+```
diff --git a/docs/development/core/server/kibana-plugin-core-server.elasticsearchservicestart.md b/docs/development/core/server/kibana-plugin-core-server.elasticsearchservicestart.md
new file mode 100644
index 0000000000000..39c794af2c881
--- /dev/null
+++ b/docs/development/core/server/kibana-plugin-core-server.elasticsearchservicestart.md
@@ -0,0 +1,19 @@
+
+
+[Home](./index.md) > [kibana-plugin-core-server](./kibana-plugin-core-server.md) > [ElasticsearchServiceStart](./kibana-plugin-core-server.elasticsearchservicestart.md)
+
+## ElasticsearchServiceStart interface
+
+
+Signature:
+
+```typescript
+export interface ElasticsearchServiceStart
+```
+
+## Properties
+
+| Property | Type | Description |
+| --- | --- | --- |
+| [legacy](./kibana-plugin-core-server.elasticsearchservicestart.legacy.md) | {
readonly createClient: (type: string, clientConfig?: Partial<ElasticsearchClientConfig>) => ICustomClusterClient;
readonly client: IClusterClient;
}
| |
+
diff --git a/docs/development/core/server/kibana-plugin-core-server.md b/docs/development/core/server/kibana-plugin-core-server.md
index ec64851e39f78..8a88329031e1f 100644
--- a/docs/development/core/server/kibana-plugin-core-server.md
+++ b/docs/development/core/server/kibana-plugin-core-server.md
@@ -74,6 +74,7 @@ The plugin integrates with the core system via lifecycle events: `setup`
| [DiscoveredPlugin](./kibana-plugin-core-server.discoveredplugin.md) | Small container object used to expose information about discovered plugins that may or may not have been started. |
| [ElasticsearchError](./kibana-plugin-core-server.elasticsearcherror.md) | |
| [ElasticsearchServiceSetup](./kibana-plugin-core-server.elasticsearchservicesetup.md) | |
+| [ElasticsearchServiceStart](./kibana-plugin-core-server.elasticsearchservicestart.md) | |
| [EnvironmentMode](./kibana-plugin-core-server.environmentmode.md) | |
| [ErrorHttpResponseOptions](./kibana-plugin-core-server.errorhttpresponseoptions.md) | HTTP response parameters |
| [FakeRequest](./kibana-plugin-core-server.fakerequest.md) | Fake request object created manually by Kibana plugins. |
diff --git a/src/core/MIGRATION.md b/src/core/MIGRATION.md
index 2de6ef5dd312b..1ca9b63a51d18 100644
--- a/src/core/MIGRATION.md
+++ b/src/core/MIGRATION.md
@@ -45,7 +45,7 @@
- [UI Exports](#ui-exports)
- [How to](#how-to)
- [Configure plugin](#configure-plugin)
- - [Handle plugin configuration deprecations](#handle-plugin-config-deprecations)
+ - [Handle plugin configuration deprecations](#handle-plugin-configuration-deprecations)
- [Use scoped services](#use-scoped-services)
- [Declare a custom scoped service](#declare-a-custom-scoped-service)
- [Mock new platform services in tests](#mock-new-platform-services-in-tests)
@@ -55,7 +55,7 @@
- [Provide Legacy Platform API to the New platform plugin](#provide-legacy-platform-api-to-the-new-platform-plugin)
- [On the server side](#on-the-server-side)
- [On the client side](#on-the-client-side)
- - [Updates an application navlink at runtime](#updates-an-app-navlink-at-runtime)
+ - [Updates an application navlink at runtime](#updates-an-application-navlink-at-runtime)
- [Logging config migration](#logging-config-migration)
Make no mistake, it is going to take a lot of work to move certain plugins to the new platform. Our target is to migrate the entire repo over to the new platform throughout 7.x and to remove the legacy plugin system no later than 8.0, and this is only possible if teams start on the effort now.
@@ -1198,13 +1198,13 @@ In server code, `core` can be accessed from either `server.newPlatform` or `kbnS
| `request.getBasePath()` | [`core.http.basePath.get`](/docs/development/core/server/kibana-plugin-server.httpservicesetup.basepath.md) | |
| `server.plugins.elasticsearch.getCluster('data')` | [`context.core.elasticsearch.dataClient`](/docs/development/core/server/kibana-plugin-server.iscopedclusterclient.md) | |
| `server.plugins.elasticsearch.getCluster('admin')` | [`context.core.elasticsearch.adminClient`](/docs/development/core/server/kibana-plugin-server.iscopedclusterclient.md) | |
-| `server.plugins.elasticsearch.createCluster(...)` | [`core.elasticsearch.createClient`](/docs/development/core/server/kibana-plugin-server.elasticsearchservicesetup.createclient.md) | |
+| `server.plugins.elasticsearch.createCluster(...)` | [`core.elasticsearch.legacy.createClient`](/docs/development/core/server/kibana-plugin-server.elasticsearchservicestart.legacy.md) | |
| `server.savedObjects.setScopedSavedObjectsClientFactory` | [`core.savedObjects.setClientFactoryProvider`](/docs/development/core/server/kibana-plugin-server.savedobjectsservicesetup.setclientfactoryprovider.md) | |
| `server.savedObjects.addScopedSavedObjectsClientWrapperFactory` | [`core.savedObjects.addClientWrapper`](/docs/development/core/server/kibana-plugin-server.savedobjectsservicesetup.addclientwrapper.md) | |
| `server.savedObjects.getSavedObjectsRepository` | [`core.savedObjects.createInternalRepository`](/docs/development/core/server/kibana-plugin-server.savedobjectsservicestart.createinternalrepository.md) [`core.savedObjects.createScopedRepository`](/docs/development/core/server/kibana-plugin-server.savedobjectsservicestart.createscopedrepository.md) | |
| `server.savedObjects.getScopedSavedObjectsClient` | [`core.savedObjects.getScopedClient`](/docs/development/core/server/kibana-plugin-server.savedobjectsservicestart.getscopedclient.md) | |
| `request.getSavedObjectsClient` | [`context.core.savedObjects.client`](/docs/development/core/server/kibana-plugin-server.requesthandlercontext.core.md) | |
-| `request.getUiSettingsService` | [`context.uiSettings.client`](/docs/development/core/server/kibana-plugin-server.iuisettingsclient.md) | |
+| `request.getUiSettingsService` | [`context.core.uiSettings.client`](/docs/development/core/server/kibana-plugin-server.iuisettingsclient.md) | |
| `kibana.Plugin.deprecations` | [Handle plugin configuration deprecations](#handle-plugin-config-deprecations) and [`PluginConfigDescriptor.deprecations`](docs/development/core/server/kibana-plugin-server.pluginconfigdescriptor.md) | Deprecations from New Platform are not applied to legacy configuration |
| `kibana.Plugin.savedObjectSchemas` | [`core.savedObjects.registerType`](docs/development/core/server/kibana-plugin-server.savedobjectsservicesetup.registertype.md) | [Examples](./MIGRATION_EXAMPLES.md#saved-objects-types) |
| `kibana.Plugin.mappings` | [`core.savedObjects.registerType`](docs/development/core/server/kibana-plugin-server.savedobjectsservicesetup.registertype.md) | [Examples](./MIGRATION_EXAMPLES.md#saved-objects-types) |
diff --git a/src/core/server/elasticsearch/elasticsearch_service.mock.ts b/src/core/server/elasticsearch/elasticsearch_service.mock.ts
index b8ad375496544..389d98a0818c8 100644
--- a/src/core/server/elasticsearch/elasticsearch_service.mock.ts
+++ b/src/core/server/elasticsearch/elasticsearch_service.mock.ts
@@ -22,7 +22,11 @@ import { IClusterClient, ICustomClusterClient } from './cluster_client';
import { IScopedClusterClient } from './scoped_cluster_client';
import { ElasticsearchConfig } from './elasticsearch_config';
import { ElasticsearchService } from './elasticsearch_service';
-import { InternalElasticsearchServiceSetup, ElasticsearchServiceSetup } from './types';
+import {
+ InternalElasticsearchServiceSetup,
+ ElasticsearchServiceSetup,
+ ElasticsearchServiceStart,
+} from './types';
import { NodesVersionCompatibility } from './version_check/ensure_es_version';
const createScopedClusterClientMock = (): jest.Mocked => ({
@@ -63,6 +67,26 @@ const createSetupContractMock = () => {
return setupContract;
};
+type MockedElasticSearchServiceStart = {
+ legacy: jest.Mocked;
+} & {
+ legacy: {
+ client: jest.Mocked;
+ };
+};
+
+const createStartContractMock = () => {
+ const startContract: MockedElasticSearchServiceStart = {
+ legacy: {
+ createClient: jest.fn(),
+ client: createClusterClientMock(),
+ },
+ };
+ startContract.legacy.createClient.mockReturnValue(createCustomClusterClientMock());
+ startContract.legacy.client.asScoped.mockReturnValue(createScopedClusterClientMock());
+ return startContract;
+};
+
type MockedInternalElasticSearchServiceSetup = jest.Mocked<
InternalElasticsearchServiceSetup & {
adminClient: jest.Mocked;
@@ -95,6 +119,7 @@ const createMock = () => {
stop: jest.fn(),
};
mocked.setup.mockResolvedValue(createInternalSetupContractMock());
+ mocked.start.mockResolvedValueOnce(createStartContractMock());
mocked.stop.mockResolvedValue();
return mocked;
};
@@ -103,6 +128,7 @@ export const elasticsearchServiceMock = {
create: createMock,
createInternalSetup: createInternalSetupContractMock,
createSetup: createSetupContractMock,
+ createStart: createStartContractMock,
createClusterClient: createClusterClientMock,
createCustomClusterClient: createCustomClusterClientMock,
createScopedClusterClient: createScopedClusterClientMock,
diff --git a/src/core/server/elasticsearch/elasticsearch_service.ts b/src/core/server/elasticsearch/elasticsearch_service.ts
index 6616b42f136c0..b92a6edf778ed 100644
--- a/src/core/server/elasticsearch/elasticsearch_service.ts
+++ b/src/core/server/elasticsearch/elasticsearch_service.ts
@@ -37,7 +37,7 @@ import { ClusterClient, ScopeableRequest } from './cluster_client';
import { ElasticsearchClientConfig } from './elasticsearch_client_config';
import { ElasticsearchConfig, ElasticsearchConfigType } from './elasticsearch_config';
import { InternalHttpServiceSetup, GetAuthHeaders } from '../http/';
-import { InternalElasticsearchServiceSetup } from './types';
+import { InternalElasticsearchServiceSetup, ElasticsearchServiceStart } from './types';
import { CallAPIOptions } from './api_types';
import { pollEsNodesVersion } from './version_check/ensure_es_version';
@@ -53,12 +53,16 @@ interface SetupDeps {
}
/** @internal */
-export class ElasticsearchService implements CoreService {
+export class ElasticsearchService
+ implements CoreService {
private readonly log: Logger;
private readonly config$: Observable;
private subscription: Subscription | undefined;
private stop$ = new Subject();
private kibanaVersion: string;
+ createClient: InternalElasticsearchServiceSetup['createClient'] | undefined;
+ dataClient: InternalElasticsearchServiceSetup['dataClient'] | undefined;
+ adminClient: InternalElasticsearchServiceSetup['adminClient'] | undefined;
constructor(private readonly coreContext: CoreContext) {
this.kibanaVersion = coreContext.env.packageInfo.version;
@@ -111,7 +115,7 @@ export class ElasticsearchService implements CoreService clients.adminClient));
const dataClient$ = clients$.pipe(map(clients => clients.dataClient));
- const adminClient = {
+ this.adminClient = {
async callAsInternalUser(
endpoint: string,
clientParams: Record = {},
@@ -120,9 +124,9 @@ export class ElasticsearchService implements CoreService {
return {
- callAsInternalUser: adminClient.callAsInternalUser,
+ callAsInternalUser: this.adminClient!.callAsInternalUser,
async callAsCurrentUser(
endpoint: string,
clientParams: Record = {},
@@ -136,6 +140,7 @@ export class ElasticsearchService implements CoreService = {}) => {
+ const finalConfig = merge({}, config, clientConfig);
+ return this.createClusterClient(type, finalConfig, deps.http.getAuthHeaders);
+ };
+
return {
legacy: { config$: clients$.pipe(map(clients => clients.config)) },
-
- adminClient,
- dataClient,
esNodesCompatibility$,
-
- createClient: (type: string, clientConfig: Partial = {}) => {
- const finalConfig = merge({}, config, clientConfig);
- return this.createClusterClient(type, finalConfig, deps.http.getAuthHeaders);
- },
+ adminClient: this.adminClient,
+ dataClient,
+ createClient: this.createClient,
};
}
- public async start() {}
+ public async start() {
+ if (typeof this.adminClient === 'undefined' || typeof this.createClient === 'undefined') {
+ throw new Error('ElasticsearchService needs to be setup before calling start');
+ } else {
+ return {
+ legacy: {
+ client: this.adminClient,
+ createClient: this.createClient,
+ },
+ };
+ }
+ }
public async stop() {
this.log.debug('Stopping elasticsearch service');
diff --git a/src/core/server/elasticsearch/types.ts b/src/core/server/elasticsearch/types.ts
index 90cfdcc035d8e..ef8edecfd26ec 100644
--- a/src/core/server/elasticsearch/types.ts
+++ b/src/core/server/elasticsearch/types.ts
@@ -28,6 +28,9 @@ import { NodesVersionCompatibility } from './version_check/ensure_es_version';
*/
export interface ElasticsearchServiceSetup {
/**
+ * @deprecated
+ * Use {@link ElasticsearchServiceStart.legacy | ElasticsearchServiceStart.legacy.createClient} instead.
+ *
* Create application specific Elasticsearch cluster API client with customized config. See {@link IClusterClient}.
*
* @param type Unique identifier of the client
@@ -50,6 +53,9 @@ export interface ElasticsearchServiceSetup {
) => ICustomClusterClient;
/**
+ * @deprecated
+ * Use {@link ElasticsearchServiceStart.legacy | ElasticsearchServiceStart.legacy.client} instead.
+ *
* A client for the `admin` cluster. All Elasticsearch config value changes are processed under the hood.
* See {@link IClusterClient}.
*
@@ -61,6 +67,9 @@ export interface ElasticsearchServiceSetup {
readonly adminClient: IClusterClient;
/**
+ * @deprecated
+ * Use {@link ElasticsearchServiceStart.legacy | ElasticsearchServiceStart.legacy.client} instead.
+ *
* A client for the `data` cluster. All Elasticsearch config value changes are processed under the hood.
* See {@link IClusterClient}.
*
@@ -72,6 +81,46 @@ export interface ElasticsearchServiceSetup {
readonly dataClient: IClusterClient;
}
+/**
+ * @public
+ */
+export interface ElasticsearchServiceStart {
+ legacy: {
+ /**
+ * Create application specific Elasticsearch cluster API client with customized config. See {@link IClusterClient}.
+ *
+ * @param type Unique identifier of the client
+ * @param clientConfig A config consists of Elasticsearch JS client options and
+ * valid sub-set of Elasticsearch service config.
+ * We fill all the missing properties in the `clientConfig` using the default
+ * Elasticsearch config so that we don't depend on default values set and
+ * controlled by underlying Elasticsearch JS client.
+ * We don't run validation against the passed config and expect it to be valid.
+ *
+ * @example
+ * ```js
+ * const client = elasticsearch.createCluster('my-app-name', config);
+ * const data = await client.callAsInternalUser();
+ * ```
+ */
+ readonly createClient: (
+ type: string,
+ clientConfig?: Partial
+ ) => ICustomClusterClient;
+
+ /**
+ * A pre-configured Elasticsearch client. All Elasticsearch config value changes are processed under the hood.
+ * See {@link IClusterClient}.
+ *
+ * @example
+ * ```js
+ * const client = core.elasticsearch.client;
+ * ```
+ */
+ readonly client: IClusterClient;
+ };
+}
+
/** @internal */
export interface InternalElasticsearchServiceSetup extends ElasticsearchServiceSetup {
// Required for the BWC with the legacy Kibana only.
diff --git a/src/core/server/index.ts b/src/core/server/index.ts
index e2faf49ba7a9e..4a1ac8988e4e5 100644
--- a/src/core/server/index.ts
+++ b/src/core/server/index.ts
@@ -43,6 +43,7 @@ import {
ElasticsearchServiceSetup,
IScopedClusterClient,
configSchema as elasticsearchConfigSchema,
+ ElasticsearchServiceStart,
} from './elasticsearch';
import { HttpServiceSetup } from './http';
@@ -93,6 +94,7 @@ export {
ElasticsearchError,
ElasticsearchErrorHelpers,
ElasticsearchServiceSetup,
+ ElasticsearchServiceStart,
APICaller,
FakeRequest,
ScopeableRequest,
@@ -366,6 +368,8 @@ export interface CoreSetup {
export interface CoreStart {
/** {@link CapabilitiesStart} */
capabilities: CapabilitiesStart;
+ /** {@link ElasticsearchServiceStart} */
+ elasticsearch: ElasticsearchServiceStart;
/** {@link SavedObjectsServiceStart} */
savedObjects: SavedObjectsServiceStart;
/** {@link UiSettingsServiceStart} */
diff --git a/src/core/server/internal_types.ts b/src/core/server/internal_types.ts
index 37d1061dc618d..825deea99bc23 100644
--- a/src/core/server/internal_types.ts
+++ b/src/core/server/internal_types.ts
@@ -22,7 +22,7 @@ import { Type } from '@kbn/config-schema';
import { CapabilitiesSetup, CapabilitiesStart } from './capabilities';
import { ConfigDeprecationProvider } from './config';
import { ContextSetup } from './context';
-import { InternalElasticsearchServiceSetup } from './elasticsearch';
+import { InternalElasticsearchServiceSetup, ElasticsearchServiceStart } from './elasticsearch';
import { InternalHttpServiceSetup } from './http';
import {
InternalSavedObjectsServiceSetup,
@@ -49,6 +49,7 @@ export interface InternalCoreSetup {
*/
export interface InternalCoreStart {
capabilities: CapabilitiesStart;
+ elasticsearch: ElasticsearchServiceStart;
savedObjects: InternalSavedObjectsServiceStart;
uiSettings: InternalUiSettingsServiceStart;
}
diff --git a/src/core/server/legacy/legacy_service.test.ts b/src/core/server/legacy/legacy_service.test.ts
index 50468db8a504d..94e86c39289bc 100644
--- a/src/core/server/legacy/legacy_service.test.ts
+++ b/src/core/server/legacy/legacy_service.test.ts
@@ -47,6 +47,7 @@ import { metricsServiceMock } from '../metrics/metrics_service.mock';
import { findLegacyPluginSpecs } from './plugins';
import { LegacyVars, LegacyServiceSetupDeps, LegacyServiceStartDeps } from './types';
import { LegacyService } from './legacy_service';
+import { coreMock } from '../mocks';
const MockKbnServer: jest.Mock = KbnServer as any;
@@ -102,9 +103,8 @@ beforeEach(() => {
startDeps = {
core: {
- capabilities: capabilitiesServiceMock.createStartContract(),
+ ...coreMock.createStart(),
savedObjects: savedObjectsServiceMock.createInternalStartContract(),
- uiSettings: uiSettingsServiceMock.createStartContract(),
plugins: { contracts: new Map() },
},
plugins: {},
diff --git a/src/core/server/legacy/legacy_service.ts b/src/core/server/legacy/legacy_service.ts
index f67148d720446..b19a991fdf0d1 100644
--- a/src/core/server/legacy/legacy_service.ts
+++ b/src/core/server/legacy/legacy_service.ts
@@ -258,6 +258,7 @@ export class LegacyService implements CoreService {
) {
const coreStart: CoreStart = {
capabilities: startDeps.core.capabilities,
+ elasticsearch: startDeps.core.elasticsearch,
savedObjects: {
getScopedClient: startDeps.core.savedObjects.getScopedClient,
createScopedRepository: startDeps.core.savedObjects.createScopedRepository,
diff --git a/src/core/server/mocks.ts b/src/core/server/mocks.ts
index a0bbe623289d8..2aa35dff563f0 100644
--- a/src/core/server/mocks.ts
+++ b/src/core/server/mocks.ts
@@ -141,6 +141,7 @@ function createCoreSetupMock() {
function createCoreStartMock() {
const mock: MockedKeys = {
capabilities: capabilitiesServiceMock.createStartContract(),
+ elasticsearch: elasticsearchServiceMock.createStart(),
savedObjects: savedObjectsServiceMock.createStartContract(),
uiSettings: uiSettingsServiceMock.createStartContract(),
};
@@ -165,6 +166,7 @@ function createInternalCoreSetupMock() {
function createInternalCoreStartMock() {
const startDeps: InternalCoreStart = {
capabilities: capabilitiesServiceMock.createStartContract(),
+ elasticsearch: elasticsearchServiceMock.createStart(),
savedObjects: savedObjectsServiceMock.createInternalStartContract(),
uiSettings: uiSettingsServiceMock.createStartContract(),
};
diff --git a/src/core/server/plugins/plugin_context.ts b/src/core/server/plugins/plugin_context.ts
index b430fd28fb896..32662f07a86f0 100644
--- a/src/core/server/plugins/plugin_context.ts
+++ b/src/core/server/plugins/plugin_context.ts
@@ -206,6 +206,7 @@ export function createPluginStartContext(
capabilities: {
resolveCapabilities: deps.capabilities.resolveCapabilities,
},
+ elasticsearch: deps.elasticsearch,
savedObjects: {
getScopedClient: deps.savedObjects.getScopedClient,
createInternalRepository: deps.savedObjects.createInternalRepository,
diff --git a/src/core/server/server.api.md b/src/core/server/server.api.md
index 86e99e0dab550..9cd0c26ea2497 100644
--- a/src/core/server/server.api.md
+++ b/src/core/server/server.api.md
@@ -647,6 +647,8 @@ export interface CoreStart {
// (undocumented)
capabilities: CapabilitiesStart;
// (undocumented)
+ elasticsearch: ElasticsearchServiceStart;
+ // (undocumented)
savedObjects: SavedObjectsServiceStart;
// (undocumented)
uiSettings: UiSettingsServiceStart;
@@ -774,11 +776,23 @@ export class ElasticsearchErrorHelpers {
// @public (undocumented)
export interface ElasticsearchServiceSetup {
+ // @deprecated (undocumented)
readonly adminClient: IClusterClient;
+ // @deprecated (undocumented)
readonly createClient: (type: string, clientConfig?: Partial) => ICustomClusterClient;
+ // @deprecated (undocumented)
readonly dataClient: IClusterClient;
}
+// @public (undocumented)
+export interface ElasticsearchServiceStart {
+ // (undocumented)
+ legacy: {
+ readonly createClient: (type: string, clientConfig?: Partial) => ICustomClusterClient;
+ readonly client: IClusterClient;
+ };
+}
+
// @public (undocumented)
export interface EnvironmentMode {
// (undocumented)
diff --git a/src/core/server/server.ts b/src/core/server/server.ts
index 792227a05e248..2402504f717ca 100644
--- a/src/core/server/server.ts
+++ b/src/core/server/server.ts
@@ -177,19 +177,17 @@ export class Server {
const savedObjectsStart = await this.savedObjects.start({});
const capabilitiesStart = this.capabilities.start();
const uiSettingsStart = await this.uiSettings.start();
-
- const pluginsStart = await this.plugins.start({
- capabilities: capabilitiesStart,
- savedObjects: savedObjectsStart,
- uiSettings: uiSettingsStart,
- });
+ const elasticsearchStart = await this.elasticsearch.start();
this.coreStart = {
capabilities: capabilitiesStart,
+ elasticsearch: elasticsearchStart,
savedObjects: savedObjectsStart,
uiSettings: uiSettingsStart,
};
+ const pluginsStart = await this.plugins.start(this.coreStart!);
+
await this.legacy.start({
core: {
...this.coreStart,