-
Notifications
You must be signed in to change notification settings - Fork 8.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
* change setClientFactory api to setClientFactoryProvider * cleanup and add test for service * change the signatures of SO start/setup * fix registerCoreContext by accessing stored start contract reference * move migration inside `start` * adapt and add service tests * add doc and export new types * adapt plugins code * update generated doc * better core access * address some review comments * remove parametrized type from SavedObjectsClientFactory, use KibanaRequest instead * add logs when starting and ending so migration * fix KibanaRequest imports * NITs and review comments * fix alerting FTR test * review comments
- Loading branch information
1 parent
4bdb59a
commit 76ae43f
Showing
48 changed files
with
913 additions
and
661 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
30 changes: 15 additions & 15 deletions
30
docs/development/core/server/kibana-plugin-server.savedobjectsclientfactory.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) > [kibana-plugin-server](./kibana-plugin-server.md) > [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) > [kibana-plugin-server](./kibana-plugin-server.md) > [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; | ||
``` |
13 changes: 13 additions & 0 deletions
13
...velopment/core/server/kibana-plugin-server.savedobjectsclientfactoryprovider.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) > [kibana-plugin-server](./kibana-plugin-server.md) > [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; | ||
``` |
26 changes: 13 additions & 13 deletions
26
...evelopment/core/server/kibana-plugin-server.savedobjectsclientwrapperfactory.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) > [kibana-plugin-server](./kibana-plugin-server.md) > [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) > [kibana-plugin-server](./kibana-plugin-server.md) > [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; | ||
``` |
42 changes: 21 additions & 21 deletions
42
...evelopment/core/server/kibana-plugin-server.savedobjectsclientwrapperoptions.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) > [kibana-plugin-server](./kibana-plugin-server.md) > [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) > [kibana-plugin-server](./kibana-plugin-server.md) > [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> | | | ||
|
22 changes: 11 additions & 11 deletions
22
...nt/core/server/kibana-plugin-server.savedobjectsclientwrapperoptions.request.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) > [kibana-plugin-server](./kibana-plugin-server.md) > [SavedObjectsClientWrapperOptions](./kibana-plugin-server.savedobjectsclientwrapperoptions.md) > [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) > [kibana-plugin-server](./kibana-plugin-server.md) > [SavedObjectsClientWrapperOptions](./kibana-plugin-server.savedobjectsclientwrapperoptions.md) > [request](./kibana-plugin-server.savedobjectsclientwrapperoptions.request.md) | ||
|
||
## SavedObjectsClientWrapperOptions.request property | ||
|
||
<b>Signature:</b> | ||
|
||
```typescript | ||
request: KibanaRequest; | ||
``` |
13 changes: 13 additions & 0 deletions
13
.../kibana-plugin-server.savedobjectsrepositoryfactory.createinternalrepository.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) > [kibana-plugin-server](./kibana-plugin-server.md) > [SavedObjectsRepositoryFactory](./kibana-plugin-server.savedobjectsrepositoryfactory.md) > [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; | ||
``` |
13 changes: 13 additions & 0 deletions
13
...er/kibana-plugin-server.savedobjectsrepositoryfactory.createscopedrepository.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) > [kibana-plugin-server](./kibana-plugin-server.md) > [SavedObjectsRepositoryFactory](./kibana-plugin-server.savedobjectsrepositoryfactory.md) > [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; | ||
``` |
21 changes: 21 additions & 0 deletions
21
docs/development/core/server/kibana-plugin-server.savedobjectsrepositoryfactory.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) > [kibana-plugin-server](./kibana-plugin-server.md) > [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[]) => 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[]) => 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. | | ||
|
26 changes: 13 additions & 13 deletions
26
...t/core/server/kibana-plugin-server.savedobjectsservicesetup.addclientwrapper.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) > [kibana-plugin-server](./kibana-plugin-server.md) > [SavedObjectsServiceSetup](./kibana-plugin-server.savedobjectsservicesetup.md) > [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) > [kibana-plugin-server](./kibana-plugin-server.md) > [SavedObjectsServiceSetup](./kibana-plugin-server.savedobjectsservicesetup.md) > [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; | ||
``` |
18 changes: 0 additions & 18 deletions
18
...erver/kibana-plugin-server.savedobjectsservicesetup.createinternalrepository.md
This file was deleted.
Oops, something went wrong.
18 changes: 0 additions & 18 deletions
18
.../server/kibana-plugin-server.savedobjectsservicesetup.createscopedrepository.md
This file was deleted.
Oops, something went wrong.
68 changes: 33 additions & 35 deletions
68
docs/development/core/server/kibana-plugin-server.savedobjectsservicesetup.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) > [kibana-plugin-server](./kibana-plugin-server.md) > [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) =<!-- -->> { core.savedObjects.setClientFactory((<!-- -->{<!-- -->request: KibanaRequest<!-- -->}<!-- -->) =<!-- -->> { 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<KibanaRequest>) => void</code> | Add a client wrapper with the given priority. | | ||
| [createInternalRepository](./kibana-plugin-server.savedobjectsservicesetup.createinternalrepository.md) | <code>(extraTypes?: string[]) => 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[]) => 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<KibanaRequest>) => 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) > [kibana-plugin-server](./kibana-plugin-server.md) > [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) =<!-- -->> { core.savedObjects.setClientFactory((<!-- -->{ request: KibanaRequest }<!-- -->) =<!-- -->> { 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) => 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) => 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. | | ||
|
13 changes: 0 additions & 13 deletions
13
...t/core/server/kibana-plugin-server.savedobjectsservicesetup.setclientfactory.md
This file was deleted.
Oops, something went wrong.
13 changes: 13 additions & 0 deletions
13
...erver/kibana-plugin-server.savedobjectsservicesetup.setclientfactoryprovider.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) > [kibana-plugin-server](./kibana-plugin-server.md) > [SavedObjectsServiceSetup](./kibana-plugin-server.savedobjectsservicesetup.md) > [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; | ||
``` |
Oops, something went wrong.