Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Run SO migration after plugins setup phase. #55012

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
5419124
change setClientFactory api to setClientFactoryProvider
pgayvallet Jan 16, 2020
3a45728
cleanup and add test for service
pgayvallet Jan 16, 2020
3b6a092
change the signatures of SO start/setup
pgayvallet Jan 16, 2020
a5e0b12
fix registerCoreContext by accessing stored start contract reference
pgayvallet Jan 17, 2020
8e2394c
move migration inside `start`
pgayvallet Jan 17, 2020
2ebe9dd
adapt and add service tests
pgayvallet Jan 17, 2020
14d36c6
add doc and export new types
pgayvallet Jan 17, 2020
7860fc5
Merge remote-tracking branch 'upstream/master' into kbn-52071-so-migr…
pgayvallet Jan 20, 2020
098b522
adapt plugins code
pgayvallet Jan 20, 2020
a8070c9
update generated doc
pgayvallet Jan 20, 2020
cab3e6c
Merge remote-tracking branch 'upstream/master' into kbn-52071-so-migr…
pgayvallet Jan 21, 2020
fed6d58
better core access
pgayvallet Jan 21, 2020
798deae
address some review comments
pgayvallet Jan 21, 2020
511c4fa
remove parametrized type from SavedObjectsClientFactory, use KibanaRe…
pgayvallet Jan 21, 2020
ceec182
add logs when starting and ending so migration
pgayvallet Jan 21, 2020
e20a6de
Merge remote-tracking branch 'upstream/master' into kbn-52071-so-migr…
pgayvallet Jan 21, 2020
51c0ec0
fix KibanaRequest imports
pgayvallet Jan 21, 2020
d4b16db
Merge remote-tracking branch 'upstream/master' into kbn-52071-so-migr…
pgayvallet Jan 22, 2020
961fec1
NITs and review comments
pgayvallet Jan 22, 2020
8c213a0
fix alerting FTR test
pgayvallet Jan 22, 2020
ba749ba
review comments
pgayvallet Jan 23, 2020
f7a4051
Merge remote-tracking branch 'upstream/master' into kbn-52071-so-migr…
pgayvallet Jan 23, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
450 changes: 226 additions & 224 deletions docs/development/core/server/kibana-plugin-server.md

Large diffs are not rendered by default.

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-server](./kibana-plugin-server.md) &gt; [SavedObjectsClientFactory](./kibana-plugin-server.savedobjectsclientfactory.md)
## SavedObjectsClientFactory type
Describes the factory used to create instances of the Saved Objects Client.
<b>Signature:</b>
```typescript
export declare type SavedObjectsClientFactory<Request = unknown> = ({ request, }: {
request: Request;
}) => SavedObjectsClientContract;
```
<!-- Do not edit this file. It is automatically generated by API Documenter. -->

[Home](./index.md) &gt; [kibana-plugin-server](./kibana-plugin-server.md) &gt; [SavedObjectsClientFactory](./kibana-plugin-server.savedobjectsclientfactory.md)

## SavedObjectsClientFactory type

Describes the factory used to create instances of the Saved Objects Client.

<b>Signature:</b>

```typescript
export declare type SavedObjectsClientFactory = ({ request, }: {
request: KibanaRequest;
}) => SavedObjectsClientContract;
```
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-server](./kibana-plugin-server.md) &gt; [SavedObjectsClientFactoryProvider](./kibana-plugin-server.savedobjectsclientfactoryprovider.md)

## SavedObjectsClientFactoryProvider type

Provider to invoke to retrieve a [SavedObjectsClientFactory](./kibana-plugin-server.savedobjectsclientfactory.md)<!-- -->.

<b>Signature:</b>

```typescript
export declare type SavedObjectsClientFactoryProvider = (repositoryFactory: SavedObjectsRepositoryFactory) => SavedObjectsClientFactory;
```
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
<!-- Do not edit this file. It is automatically generated by API Documenter. -->
[Home](./index.md) &gt; [kibana-plugin-server](./kibana-plugin-server.md) &gt; [SavedObjectsClientWrapperFactory](./kibana-plugin-server.savedobjectsclientwrapperfactory.md)
## SavedObjectsClientWrapperFactory type
Describes the factory used to create instances of Saved Objects Client Wrappers.
<b>Signature:</b>
```typescript
export declare type SavedObjectsClientWrapperFactory<Request = unknown> = (options: SavedObjectsClientWrapperOptions<Request>) => SavedObjectsClientContract;
```
<!-- Do not edit this file. It is automatically generated by API Documenter. -->

[Home](./index.md) &gt; [kibana-plugin-server](./kibana-plugin-server.md) &gt; [SavedObjectsClientWrapperFactory](./kibana-plugin-server.savedobjectsclientwrapperfactory.md)

## SavedObjectsClientWrapperFactory type

Describes the factory used to create instances of Saved Objects Client Wrappers.

<b>Signature:</b>

```typescript
export declare type SavedObjectsClientWrapperFactory = (options: SavedObjectsClientWrapperOptions) => SavedObjectsClientContract;
```
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
<!-- Do not edit this file. It is automatically generated by API Documenter. -->
[Home](./index.md) &gt; [kibana-plugin-server](./kibana-plugin-server.md) &gt; [SavedObjectsClientWrapperOptions](./kibana-plugin-server.savedobjectsclientwrapperoptions.md)
## SavedObjectsClientWrapperOptions interface
Options passed to each SavedObjectsClientWrapperFactory to aid in creating the wrapper instance.
<b>Signature:</b>
```typescript
export interface SavedObjectsClientWrapperOptions<Request = unknown>
```
## Properties
| Property | Type | Description |
| --- | --- | --- |
| [client](./kibana-plugin-server.savedobjectsclientwrapperoptions.client.md) | <code>SavedObjectsClientContract</code> | |
| [request](./kibana-plugin-server.savedobjectsclientwrapperoptions.request.md) | <code>Request</code> | |
<!-- Do not edit this file. It is automatically generated by API Documenter. -->

[Home](./index.md) &gt; [kibana-plugin-server](./kibana-plugin-server.md) &gt; [SavedObjectsClientWrapperOptions](./kibana-plugin-server.savedobjectsclientwrapperoptions.md)

## SavedObjectsClientWrapperOptions interface

Options passed to each SavedObjectsClientWrapperFactory to aid in creating the wrapper instance.

<b>Signature:</b>

```typescript
export interface SavedObjectsClientWrapperOptions
```

## Properties

| Property | Type | Description |
| --- | --- | --- |
| [client](./kibana-plugin-server.savedobjectsclientwrapperoptions.client.md) | <code>SavedObjectsClientContract</code> | |
| [request](./kibana-plugin-server.savedobjectsclientwrapperoptions.request.md) | <code>KibanaRequest</code> | |

Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
<!-- Do not edit this file. It is automatically generated by API Documenter. -->
[Home](./index.md) &gt; [kibana-plugin-server](./kibana-plugin-server.md) &gt; [SavedObjectsClientWrapperOptions](./kibana-plugin-server.savedobjectsclientwrapperoptions.md) &gt; [request](./kibana-plugin-server.savedobjectsclientwrapperoptions.request.md)
## SavedObjectsClientWrapperOptions.request property
<b>Signature:</b>
```typescript
request: Request;
```
<!-- Do not edit this file. It is automatically generated by API Documenter. -->

[Home](./index.md) &gt; [kibana-plugin-server](./kibana-plugin-server.md) &gt; [SavedObjectsClientWrapperOptions](./kibana-plugin-server.savedobjectsclientwrapperoptions.md) &gt; [request](./kibana-plugin-server.savedobjectsclientwrapperoptions.request.md)

## SavedObjectsClientWrapperOptions.request property

<b>Signature:</b>

```typescript
request: KibanaRequest;
```
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-server](./kibana-plugin-server.md) &gt; [SavedObjectsRepositoryFactory](./kibana-plugin-server.savedobjectsrepositoryfactory.md) &gt; [createInternalRepository](./kibana-plugin-server.savedobjectsrepositoryfactory.createinternalrepository.md)

## SavedObjectsRepositoryFactory.createInternalRepository property

Creates a [Saved Objects repository](./kibana-plugin-server.isavedobjectsrepository.md) that uses the internal Kibana user for authenticating with Elasticsearch.

<b>Signature:</b>

```typescript
createInternalRepository: (extraTypes?: string[]) => ISavedObjectsRepository;
```
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-server](./kibana-plugin-server.md) &gt; [SavedObjectsRepositoryFactory](./kibana-plugin-server.savedobjectsrepositoryfactory.md) &gt; [createScopedRepository](./kibana-plugin-server.savedobjectsrepositoryfactory.createscopedrepository.md)

## SavedObjectsRepositoryFactory.createScopedRepository property

Creates a [Saved Objects repository](./kibana-plugin-server.isavedobjectsrepository.md) that uses the credentials from the passed in request to authenticate with Elasticsearch.

<b>Signature:</b>

```typescript
createScopedRepository: (req: KibanaRequest, extraTypes?: string[]) => ISavedObjectsRepository;
```
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-server](./kibana-plugin-server.md) &gt; [SavedObjectsRepositoryFactory](./kibana-plugin-server.savedobjectsrepositoryfactory.md)

## SavedObjectsRepositoryFactory interface

Factory provided when invoking a [client factory provider](./kibana-plugin-server.savedobjectsclientfactoryprovider.md) See [SavedObjectsServiceSetup.setClientFactoryProvider](./kibana-plugin-server.savedobjectsservicesetup.setclientfactoryprovider.md)

<b>Signature:</b>

```typescript
export interface SavedObjectsRepositoryFactory
```

## Properties

| Property | Type | Description |
| --- | --- | --- |
| [createInternalRepository](./kibana-plugin-server.savedobjectsrepositoryfactory.createinternalrepository.md) | <code>(extraTypes?: string[]) =&gt; ISavedObjectsRepository</code> | Creates a [Saved Objects repository](./kibana-plugin-server.isavedobjectsrepository.md) that uses the internal Kibana user for authenticating with Elasticsearch. |
| [createScopedRepository](./kibana-plugin-server.savedobjectsrepositoryfactory.createscopedrepository.md) | <code>(req: KibanaRequest, extraTypes?: string[]) =&gt; ISavedObjectsRepository</code> | Creates a [Saved Objects repository](./kibana-plugin-server.isavedobjectsrepository.md) that uses the credentials from the passed in request to authenticate with Elasticsearch. |

Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
<!-- Do not edit this file. It is automatically generated by API Documenter. -->
[Home](./index.md) &gt; [kibana-plugin-server](./kibana-plugin-server.md) &gt; [SavedObjectsServiceSetup](./kibana-plugin-server.savedobjectsservicesetup.md) &gt; [addClientWrapper](./kibana-plugin-server.savedobjectsservicesetup.addclientwrapper.md)
## SavedObjectsServiceSetup.addClientWrapper property
Add a client wrapper with the given priority.
<b>Signature:</b>
```typescript
addClientWrapper: (priority: number, id: string, factory: SavedObjectsClientWrapperFactory<KibanaRequest>) => void;
```
<!-- Do not edit this file. It is automatically generated by API Documenter. -->

[Home](./index.md) &gt; [kibana-plugin-server](./kibana-plugin-server.md) &gt; [SavedObjectsServiceSetup](./kibana-plugin-server.savedobjectsservicesetup.md) &gt; [addClientWrapper](./kibana-plugin-server.savedobjectsservicesetup.addclientwrapper.md)

## SavedObjectsServiceSetup.addClientWrapper property

Add a [client wrapper factory](./kibana-plugin-server.savedobjectsclientwrapperfactory.md) with the given priority.

<b>Signature:</b>

```typescript
addClientWrapper: (priority: number, id: string, factory: SavedObjectsClientWrapperFactory) => void;
```

This file was deleted.

This file was deleted.

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

[Home](./index.md) &gt; [kibana-plugin-server](./kibana-plugin-server.md) &gt; [SavedObjectsServiceSetup](./kibana-plugin-server.savedobjectsservicesetup.md)

## SavedObjectsServiceSetup interface

Saved Objects is Kibana's data persisentence mechanism allowing plugins to use Elasticsearch for storing and querying state. The SavedObjectsServiceSetup API exposes methods for creating and registering Saved Object client wrappers.

<b>Signature:</b>

```typescript
export interface SavedObjectsServiceSetup
```

## Remarks

Note: The Saved Object setup API's should only be used for creating and registering client wrappers. Constructing a Saved Objects client or repository for use within your own plugin won't have any of the registered wrappers applied and is considered an anti-pattern. Use the Saved Objects client from the [SavedObjectsServiceStart\#getScopedClient](./kibana-plugin-server.savedobjectsservicestart.md) method or the [route handler context](./kibana-plugin-server.requesthandlercontext.md) instead.

When plugins access the Saved Objects client, a new client is created using the factory provided to `setClientFactory` and wrapped by all wrappers registered through `addClientWrapper`<!-- -->. To create a factory or wrapper, plugins will have to construct a Saved Objects client. First create a repository by calling `scopedRepository` or `internalRepository` and then use this repository as the argument to the [SavedObjectsClient](./kibana-plugin-server.savedobjectsclient.md) constructor.

## Example

import {<!-- -->SavedObjectsClient, CoreSetup<!-- -->} from 'src/core/server';

export class Plugin() { setup: (core: CoreSetup) =<!-- -->&gt; { core.savedObjects.setClientFactory((<!-- -->{<!-- -->request: KibanaRequest<!-- -->}<!-- -->) =<!-- -->&gt; { return new SavedObjectsClient(core.savedObjects.scopedRepository(request)); }<!-- -->) } }

## Properties

| Property | Type | Description |
| --- | --- | --- |
| [addClientWrapper](./kibana-plugin-server.savedobjectsservicesetup.addclientwrapper.md) | <code>(priority: number, id: string, factory: SavedObjectsClientWrapperFactory&lt;KibanaRequest&gt;) =&gt; void</code> | Add a client wrapper with the given priority. |
| [createInternalRepository](./kibana-plugin-server.savedobjectsservicesetup.createinternalrepository.md) | <code>(extraTypes?: string[]) =&gt; ISavedObjectsRepository</code> | Creates a [Saved Objects repository](./kibana-plugin-server.isavedobjectsrepository.md) that uses the internal Kibana user for authenticating with Elasticsearch. |
| [createScopedRepository](./kibana-plugin-server.savedobjectsservicesetup.createscopedrepository.md) | <code>(req: KibanaRequest, extraTypes?: string[]) =&gt; ISavedObjectsRepository</code> | Creates a [Saved Objects repository](./kibana-plugin-server.isavedobjectsrepository.md) that uses the credentials from the passed in request to authenticate with Elasticsearch. |
| [setClientFactory](./kibana-plugin-server.savedobjectsservicesetup.setclientfactory.md) | <code>(customClientFactory: SavedObjectsClientFactory&lt;KibanaRequest&gt;) =&gt; void</code> | Set a default factory for creating Saved Objects clients. Only one client factory can be set, subsequent calls to this method will fail. |

<!-- Do not edit this file. It is automatically generated by API Documenter. -->

[Home](./index.md) &gt; [kibana-plugin-server](./kibana-plugin-server.md) &gt; [SavedObjectsServiceSetup](./kibana-plugin-server.savedobjectsservicesetup.md)

## SavedObjectsServiceSetup interface

Saved Objects is Kibana's data persistence mechanism allowing plugins to use Elasticsearch for storing and querying state. The SavedObjectsServiceSetup API exposes methods for creating and registering Saved Object client wrappers.

<b>Signature:</b>

```typescript
export interface SavedObjectsServiceSetup
```

## Remarks

Note: The Saved Object setup API's should only be used for creating and registering client wrappers. Constructing a Saved Objects client or repository for use within your own plugin won't have any of the registered wrappers applied and is considered an anti-pattern. Use the Saved Objects client from the [SavedObjectsServiceStart\#getScopedClient](./kibana-plugin-server.savedobjectsservicestart.md) method or the [route handler context](./kibana-plugin-server.requesthandlercontext.md) instead.

When plugins access the Saved Objects client, a new client is created using the factory provided to `setClientFactory` and wrapped by all wrappers registered through `addClientWrapper`<!-- -->. To create a factory or wrapper, plugins will have to construct a Saved Objects client. First create a repository by calling `scopedRepository` or `internalRepository` and then use this repository as the argument to the [SavedObjectsClient](./kibana-plugin-server.savedobjectsclient.md) constructor.

## Example

import { SavedObjectsClient, CoreSetup } from 'src/core/server';

export class Plugin() { setup: (core: CoreSetup) =<!-- -->&gt; { core.savedObjects.setClientFactory((<!-- -->{ request: KibanaRequest }<!-- -->) =<!-- -->&gt; { return new SavedObjectsClient(core.savedObjects.scopedRepository(request)); }<!-- -->) } }

## Properties

| Property | Type | Description |
| --- | --- | --- |
| [addClientWrapper](./kibana-plugin-server.savedobjectsservicesetup.addclientwrapper.md) | <code>(priority: number, id: string, factory: SavedObjectsClientWrapperFactory) =&gt; void</code> | Add a [client wrapper factory](./kibana-plugin-server.savedobjectsclientwrapperfactory.md) with the given priority. |
| [setClientFactoryProvider](./kibana-plugin-server.savedobjectsservicesetup.setclientfactoryprovider.md) | <code>(clientFactoryProvider: SavedObjectsClientFactoryProvider) =&gt; void</code> | Set the default [factory provider](./kibana-plugin-server.savedobjectsclientfactoryprovider.md) for creating Saved Objects clients. Only one provider can be set, subsequent calls to this method will fail. |

This file was deleted.

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-server](./kibana-plugin-server.md) &gt; [SavedObjectsServiceSetup](./kibana-plugin-server.savedobjectsservicesetup.md) &gt; [setClientFactoryProvider](./kibana-plugin-server.savedobjectsservicesetup.setclientfactoryprovider.md)

## SavedObjectsServiceSetup.setClientFactoryProvider property

Set the default [factory provider](./kibana-plugin-server.savedobjectsclientfactoryprovider.md) for creating Saved Objects clients. Only one provider can be set, subsequent calls to this method will fail.

<b>Signature:</b>

```typescript
setClientFactoryProvider: (clientFactoryProvider: SavedObjectsClientFactoryProvider) => void;
```
Loading