mirror of
https://github.com/elastic/kibana.git
synced 2025-04-23 09:19:04 -04:00
* 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
This commit is contained in:
parent
4bdb59a984
commit
76ae43f407
48 changed files with 919 additions and 667 deletions
|
@ -1,224 +1,226 @@
|
|||
<!-- Do not edit this file. It is automatically generated by API Documenter. -->
|
||||
|
||||
[Home](./index.md) > [kibana-plugin-server](./kibana-plugin-server.md)
|
||||
|
||||
## kibana-plugin-server package
|
||||
|
||||
The Kibana Core APIs for server-side plugins.
|
||||
|
||||
A plugin requires a `kibana.json` file at it's root directory that follows [the manfiest schema](./kibana-plugin-server.pluginmanifest.md) to define static plugin information required to load the plugin.
|
||||
|
||||
A plugin's `server/index` file must contain a named import, `plugin`<!-- -->, that implements [PluginInitializer](./kibana-plugin-server.plugininitializer.md) which returns an object that implements [Plugin](./kibana-plugin-server.plugin.md)<!-- -->.
|
||||
|
||||
The plugin integrates with the core system via lifecycle events: `setup`<!-- -->, `start`<!-- -->, and `stop`<!-- -->. In each lifecycle method, the plugin will receive the corresponding core services available (either [CoreSetup](./kibana-plugin-server.coresetup.md) or [CoreStart](./kibana-plugin-server.corestart.md)<!-- -->) and any interfaces returned by dependency plugins' lifecycle method. Anything returned by the plugin's lifecycle method will be exposed to downstream dependencies when their corresponding lifecycle methods are invoked.
|
||||
|
||||
## Classes
|
||||
|
||||
| Class | Description |
|
||||
| --- | --- |
|
||||
| [BasePath](./kibana-plugin-server.basepath.md) | Access or manipulate the Kibana base path |
|
||||
| [ClusterClient](./kibana-plugin-server.clusterclient.md) | 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 <code>asScoped(...)</code>).<!-- -->See [ClusterClient](./kibana-plugin-server.clusterclient.md)<!-- -->. |
|
||||
| [CspConfig](./kibana-plugin-server.cspconfig.md) | CSP configuration for use in Kibana. |
|
||||
| [ElasticsearchErrorHelpers](./kibana-plugin-server.elasticsearcherrorhelpers.md) | Helpers for working with errors returned from the Elasticsearch service.Since the internal data of errors are subject to change, consumers of the Elasticsearch service should always use these helpers to classify errors instead of checking error internals such as <code>body.error.header[WWW-Authenticate]</code> |
|
||||
| [KibanaRequest](./kibana-plugin-server.kibanarequest.md) | Kibana specific abstraction for an incoming request. |
|
||||
| [RouteValidationError](./kibana-plugin-server.routevalidationerror.md) | Error to return when the validation is not successful. |
|
||||
| [SavedObjectsClient](./kibana-plugin-server.savedobjectsclient.md) | |
|
||||
| [SavedObjectsErrorHelpers](./kibana-plugin-server.savedobjectserrorhelpers.md) | |
|
||||
| [SavedObjectsRepository](./kibana-plugin-server.savedobjectsrepository.md) | |
|
||||
| [ScopedClusterClient](./kibana-plugin-server.scopedclusterclient.md) | Serves the same purpose as "normal" <code>ClusterClient</code> but exposes additional <code>callAsCurrentUser</code> method that doesn't use credentials of the Kibana internal user (as <code>callAsInternalUser</code> does) to request Elasticsearch API, but rather passes HTTP headers extracted from the current user request to the API.<!-- -->See [ScopedClusterClient](./kibana-plugin-server.scopedclusterclient.md)<!-- -->. |
|
||||
|
||||
## Enumerations
|
||||
|
||||
| Enumeration | Description |
|
||||
| --- | --- |
|
||||
| [AuthResultType](./kibana-plugin-server.authresulttype.md) | |
|
||||
| [AuthStatus](./kibana-plugin-server.authstatus.md) | Status indicating an outcome of the authentication. |
|
||||
|
||||
## Interfaces
|
||||
|
||||
| Interface | Description |
|
||||
| --- | --- |
|
||||
| [APICaller](./kibana-plugin-server.apicaller.md) | |
|
||||
| [AssistanceAPIResponse](./kibana-plugin-server.assistanceapiresponse.md) | |
|
||||
| [AssistantAPIClientParams](./kibana-plugin-server.assistantapiclientparams.md) | |
|
||||
| [Authenticated](./kibana-plugin-server.authenticated.md) | |
|
||||
| [AuthResultParams](./kibana-plugin-server.authresultparams.md) | Result of an incoming request authentication. |
|
||||
| [AuthToolkit](./kibana-plugin-server.authtoolkit.md) | A tool set defining an outcome of Auth interceptor for incoming request. |
|
||||
| [CallAPIOptions](./kibana-plugin-server.callapioptions.md) | The set of options that defines how API call should be made and result be processed. |
|
||||
| [Capabilities](./kibana-plugin-server.capabilities.md) | The read-only set of capabilities available for the current UI session. Capabilities are simple key-value pairs of (string, boolean), where the string denotes the capability ID, and the boolean is a flag indicating if the capability is enabled or disabled. |
|
||||
| [CapabilitiesSetup](./kibana-plugin-server.capabilitiessetup.md) | APIs to manage the [Capabilities](./kibana-plugin-server.capabilities.md) that will be used by the application.<!-- -->Plugins relying on capabilities to toggle some of their features should register them during the setup phase using the <code>registerProvider</code> method.<!-- -->Plugins having the responsibility to restrict capabilities depending on a given context should register their capabilities switcher using the <code>registerSwitcher</code> method.<!-- -->Refers to the methods documentation for complete description and examples. |
|
||||
| [CapabilitiesStart](./kibana-plugin-server.capabilitiesstart.md) | APIs to access the application [Capabilities](./kibana-plugin-server.capabilities.md)<!-- -->. |
|
||||
| [ConfigDeprecationFactory](./kibana-plugin-server.configdeprecationfactory.md) | Provides helpers to generates the most commonly used [ConfigDeprecation](./kibana-plugin-server.configdeprecation.md) when invoking a [ConfigDeprecationProvider](./kibana-plugin-server.configdeprecationprovider.md)<!-- -->.<!-- -->See methods documentation for more detailed examples. |
|
||||
| [ContextSetup](./kibana-plugin-server.contextsetup.md) | An object that handles registration of context providers and configuring handlers with context. |
|
||||
| [CoreSetup](./kibana-plugin-server.coresetup.md) | Context passed to the plugins <code>setup</code> method. |
|
||||
| [CoreStart](./kibana-plugin-server.corestart.md) | Context passed to the plugins <code>start</code> method. |
|
||||
| [CustomHttpResponseOptions](./kibana-plugin-server.customhttpresponseoptions.md) | HTTP response parameters for a response with adjustable status code. |
|
||||
| [DeprecationAPIClientParams](./kibana-plugin-server.deprecationapiclientparams.md) | |
|
||||
| [DeprecationAPIResponse](./kibana-plugin-server.deprecationapiresponse.md) | |
|
||||
| [DeprecationInfo](./kibana-plugin-server.deprecationinfo.md) | |
|
||||
| [DeprecationSettings](./kibana-plugin-server.deprecationsettings.md) | UiSettings deprecation field options. |
|
||||
| [DiscoveredPlugin](./kibana-plugin-server.discoveredplugin.md) | Small container object used to expose information about discovered plugins that may or may not have been started. |
|
||||
| [ElasticsearchError](./kibana-plugin-server.elasticsearcherror.md) | |
|
||||
| [ElasticsearchServiceSetup](./kibana-plugin-server.elasticsearchservicesetup.md) | |
|
||||
| [EnvironmentMode](./kibana-plugin-server.environmentmode.md) | |
|
||||
| [ErrorHttpResponseOptions](./kibana-plugin-server.errorhttpresponseoptions.md) | HTTP response parameters |
|
||||
| [FakeRequest](./kibana-plugin-server.fakerequest.md) | Fake request object created manually by Kibana plugins. |
|
||||
| [HttpResponseOptions](./kibana-plugin-server.httpresponseoptions.md) | HTTP response parameters |
|
||||
| [HttpServiceSetup](./kibana-plugin-server.httpservicesetup.md) | Kibana HTTP Service provides own abstraction for work with HTTP stack. Plugins don't have direct access to <code>hapi</code> server and its primitives anymore. Moreover, plugins shouldn't rely on the fact that HTTP Service uses one or another library under the hood. This gives the platform flexibility to upgrade or changing our internal HTTP stack without breaking plugins. If the HTTP Service lacks functionality you need, we are happy to discuss and support your needs. |
|
||||
| [HttpServiceStart](./kibana-plugin-server.httpservicestart.md) | |
|
||||
| [IContextContainer](./kibana-plugin-server.icontextcontainer.md) | An object that handles registration of context providers and configuring handlers with context. |
|
||||
| [ICspConfig](./kibana-plugin-server.icspconfig.md) | CSP configuration for use in Kibana. |
|
||||
| [IKibanaResponse](./kibana-plugin-server.ikibanaresponse.md) | A response data object, expected to returned as a result of [RequestHandler](./kibana-plugin-server.requesthandler.md) execution |
|
||||
| [IKibanaSocket](./kibana-plugin-server.ikibanasocket.md) | A tiny abstraction for TCP socket. |
|
||||
| [ImageValidation](./kibana-plugin-server.imagevalidation.md) | |
|
||||
| [IndexSettingsDeprecationInfo](./kibana-plugin-server.indexsettingsdeprecationinfo.md) | |
|
||||
| [IRenderOptions](./kibana-plugin-server.irenderoptions.md) | |
|
||||
| [IRouter](./kibana-plugin-server.irouter.md) | Registers route handlers for specified resource path and method. See [RouteConfig](./kibana-plugin-server.routeconfig.md) and [RequestHandler](./kibana-plugin-server.requesthandler.md) for more information about arguments to route registrations. |
|
||||
| [IScopedRenderingClient](./kibana-plugin-server.iscopedrenderingclient.md) | |
|
||||
| [IUiSettingsClient](./kibana-plugin-server.iuisettingsclient.md) | Server-side client that provides access to the advanced settings stored in elasticsearch. The settings provide control over the behavior of the Kibana application. For example, a user can specify how to display numeric or date fields. Users can adjust the settings via Management UI. |
|
||||
| [KibanaRequestEvents](./kibana-plugin-server.kibanarequestevents.md) | Request events. |
|
||||
| [KibanaRequestRoute](./kibana-plugin-server.kibanarequestroute.md) | Request specific route information exposed to a handler. |
|
||||
| [LegacyRequest](./kibana-plugin-server.legacyrequest.md) | |
|
||||
| [LegacyServiceSetupDeps](./kibana-plugin-server.legacyservicesetupdeps.md) | |
|
||||
| [LegacyServiceStartDeps](./kibana-plugin-server.legacyservicestartdeps.md) | |
|
||||
| [Logger](./kibana-plugin-server.logger.md) | Logger exposes all the necessary methods to log any type of information and this is the interface used by the logging consumers including plugins. |
|
||||
| [LoggerFactory](./kibana-plugin-server.loggerfactory.md) | The single purpose of <code>LoggerFactory</code> interface is to define a way to retrieve a context-based logger instance. |
|
||||
| [LogMeta](./kibana-plugin-server.logmeta.md) | Contextual metadata |
|
||||
| [OnPostAuthToolkit](./kibana-plugin-server.onpostauthtoolkit.md) | A tool set defining an outcome of OnPostAuth interceptor for incoming request. |
|
||||
| [OnPreAuthToolkit](./kibana-plugin-server.onpreauthtoolkit.md) | A tool set defining an outcome of OnPreAuth interceptor for incoming request. |
|
||||
| [OnPreResponseExtensions](./kibana-plugin-server.onpreresponseextensions.md) | Additional data to extend a response. |
|
||||
| [OnPreResponseInfo](./kibana-plugin-server.onpreresponseinfo.md) | Response status code. |
|
||||
| [OnPreResponseToolkit](./kibana-plugin-server.onpreresponsetoolkit.md) | A tool set defining an outcome of OnPreAuth interceptor for incoming request. |
|
||||
| [PackageInfo](./kibana-plugin-server.packageinfo.md) | |
|
||||
| [Plugin](./kibana-plugin-server.plugin.md) | The interface that should be returned by a <code>PluginInitializer</code>. |
|
||||
| [PluginConfigDescriptor](./kibana-plugin-server.pluginconfigdescriptor.md) | Describes a plugin configuration properties. |
|
||||
| [PluginInitializerContext](./kibana-plugin-server.plugininitializercontext.md) | Context that's available to plugins during initialization stage. |
|
||||
| [PluginManifest](./kibana-plugin-server.pluginmanifest.md) | Describes the set of required and optional properties plugin can define in its mandatory JSON manifest file. |
|
||||
| [PluginsServiceSetup](./kibana-plugin-server.pluginsservicesetup.md) | |
|
||||
| [PluginsServiceStart](./kibana-plugin-server.pluginsservicestart.md) | |
|
||||
| [RequestHandlerContext](./kibana-plugin-server.requesthandlercontext.md) | Plugin specific context passed to a route handler.<!-- -->Provides the following clients: - [rendering](./kibana-plugin-server.iscopedrenderingclient.md) - Rendering client which uses the data of the incoming request - [savedObjects.client](./kibana-plugin-server.savedobjectsclient.md) - Saved Objects client which uses the credentials of the incoming request - [elasticsearch.dataClient](./kibana-plugin-server.scopedclusterclient.md) - Elasticsearch data client which uses the credentials of the incoming request - [elasticsearch.adminClient](./kibana-plugin-server.scopedclusterclient.md) - Elasticsearch admin client which uses the credentials of the incoming request - [uiSettings.client](./kibana-plugin-server.iuisettingsclient.md) - uiSettings client which uses the credentials of the incoming request |
|
||||
| [RouteConfig](./kibana-plugin-server.routeconfig.md) | Route specific configuration. |
|
||||
| [RouteConfigOptions](./kibana-plugin-server.routeconfigoptions.md) | Additional route options. |
|
||||
| [RouteConfigOptionsBody](./kibana-plugin-server.routeconfigoptionsbody.md) | Additional body options for a route |
|
||||
| [RouteValidationResultFactory](./kibana-plugin-server.routevalidationresultfactory.md) | Validation result factory to be used in the custom validation function to return the valid data or validation errors<!-- -->See [RouteValidationFunction](./kibana-plugin-server.routevalidationfunction.md)<!-- -->. |
|
||||
| [RouteValidatorConfig](./kibana-plugin-server.routevalidatorconfig.md) | The configuration object to the RouteValidator class. Set <code>params</code>, <code>query</code> and/or <code>body</code> to specify the validation logic to follow for that property. |
|
||||
| [RouteValidatorOptions](./kibana-plugin-server.routevalidatoroptions.md) | Additional options for the RouteValidator class to modify its default behaviour. |
|
||||
| [SavedObject](./kibana-plugin-server.savedobject.md) | |
|
||||
| [SavedObjectAttributes](./kibana-plugin-server.savedobjectattributes.md) | The data for a Saved Object is stored as an object in the <code>attributes</code> property. |
|
||||
| [SavedObjectReference](./kibana-plugin-server.savedobjectreference.md) | A reference to another saved object. |
|
||||
| [SavedObjectsBaseOptions](./kibana-plugin-server.savedobjectsbaseoptions.md) | |
|
||||
| [SavedObjectsBulkCreateObject](./kibana-plugin-server.savedobjectsbulkcreateobject.md) | |
|
||||
| [SavedObjectsBulkGetObject](./kibana-plugin-server.savedobjectsbulkgetobject.md) | |
|
||||
| [SavedObjectsBulkResponse](./kibana-plugin-server.savedobjectsbulkresponse.md) | |
|
||||
| [SavedObjectsBulkUpdateObject](./kibana-plugin-server.savedobjectsbulkupdateobject.md) | |
|
||||
| [SavedObjectsBulkUpdateOptions](./kibana-plugin-server.savedobjectsbulkupdateoptions.md) | |
|
||||
| [SavedObjectsBulkUpdateResponse](./kibana-plugin-server.savedobjectsbulkupdateresponse.md) | |
|
||||
| [SavedObjectsClientProviderOptions](./kibana-plugin-server.savedobjectsclientprovideroptions.md) | Options to control the creation of the Saved Objects Client. |
|
||||
| [SavedObjectsClientWrapperOptions](./kibana-plugin-server.savedobjectsclientwrapperoptions.md) | Options passed to each SavedObjectsClientWrapperFactory to aid in creating the wrapper instance. |
|
||||
| [SavedObjectsCreateOptions](./kibana-plugin-server.savedobjectscreateoptions.md) | |
|
||||
| [SavedObjectsDeleteByNamespaceOptions](./kibana-plugin-server.savedobjectsdeletebynamespaceoptions.md) | |
|
||||
| [SavedObjectsDeleteOptions](./kibana-plugin-server.savedobjectsdeleteoptions.md) | |
|
||||
| [SavedObjectsExportOptions](./kibana-plugin-server.savedobjectsexportoptions.md) | Options controlling the export operation. |
|
||||
| [SavedObjectsExportResultDetails](./kibana-plugin-server.savedobjectsexportresultdetails.md) | Structure of the export result details entry |
|
||||
| [SavedObjectsFindOptions](./kibana-plugin-server.savedobjectsfindoptions.md) | |
|
||||
| [SavedObjectsFindResponse](./kibana-plugin-server.savedobjectsfindresponse.md) | Return type of the Saved Objects <code>find()</code> method.<!-- -->\*Note\*: this type is different between the Public and Server Saved Objects clients. |
|
||||
| [SavedObjectsImportConflictError](./kibana-plugin-server.savedobjectsimportconflicterror.md) | Represents a failure to import due to a conflict. |
|
||||
| [SavedObjectsImportError](./kibana-plugin-server.savedobjectsimporterror.md) | Represents a failure to import. |
|
||||
| [SavedObjectsImportMissingReferencesError](./kibana-plugin-server.savedobjectsimportmissingreferenceserror.md) | Represents a failure to import due to missing references. |
|
||||
| [SavedObjectsImportOptions](./kibana-plugin-server.savedobjectsimportoptions.md) | Options to control the import operation. |
|
||||
| [SavedObjectsImportResponse](./kibana-plugin-server.savedobjectsimportresponse.md) | The response describing the result of an import. |
|
||||
| [SavedObjectsImportRetry](./kibana-plugin-server.savedobjectsimportretry.md) | Describes a retry operation for importing a saved object. |
|
||||
| [SavedObjectsImportUnknownError](./kibana-plugin-server.savedobjectsimportunknownerror.md) | Represents a failure to import due to an unknown reason. |
|
||||
| [SavedObjectsImportUnsupportedTypeError](./kibana-plugin-server.savedobjectsimportunsupportedtypeerror.md) | Represents a failure to import due to having an unsupported saved object type. |
|
||||
| [SavedObjectsIncrementCounterOptions](./kibana-plugin-server.savedobjectsincrementcounteroptions.md) | |
|
||||
| [SavedObjectsMigrationLogger](./kibana-plugin-server.savedobjectsmigrationlogger.md) | |
|
||||
| [SavedObjectsMigrationVersion](./kibana-plugin-server.savedobjectsmigrationversion.md) | Information about the migrations that have been applied to this SavedObject. When Kibana starts up, KibanaMigrator detects outdated documents and migrates them based on this value. For each migration that has been applied, the plugin's name is used as a key and the latest migration version as the value. |
|
||||
| [SavedObjectsRawDoc](./kibana-plugin-server.savedobjectsrawdoc.md) | A raw document as represented directly in the saved object index. |
|
||||
| [SavedObjectsResolveImportErrorsOptions](./kibana-plugin-server.savedobjectsresolveimporterrorsoptions.md) | Options to control the "resolve import" operation. |
|
||||
| [SavedObjectsServiceSetup](./kibana-plugin-server.savedobjectsservicesetup.md) | 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. |
|
||||
| [SavedObjectsServiceStart](./kibana-plugin-server.savedobjectsservicestart.md) | Saved Objects is Kibana's data persisentence mechanism allowing plugins to use Elasticsearch for storing and querying state. The SavedObjectsServiceStart API provides a scoped Saved Objects client for interacting with Saved Objects. |
|
||||
| [SavedObjectsUpdateOptions](./kibana-plugin-server.savedobjectsupdateoptions.md) | |
|
||||
| [SavedObjectsUpdateResponse](./kibana-plugin-server.savedobjectsupdateresponse.md) | |
|
||||
| [SessionCookieValidationResult](./kibana-plugin-server.sessioncookievalidationresult.md) | Return type from a function to validate cookie contents. |
|
||||
| [SessionStorage](./kibana-plugin-server.sessionstorage.md) | Provides an interface to store and retrieve data across requests. |
|
||||
| [SessionStorageCookieOptions](./kibana-plugin-server.sessionstoragecookieoptions.md) | Configuration used to create HTTP session storage based on top of cookie mechanism. |
|
||||
| [SessionStorageFactory](./kibana-plugin-server.sessionstoragefactory.md) | SessionStorage factory to bind one to an incoming request |
|
||||
| [StringValidation](./kibana-plugin-server.stringvalidation.md) | |
|
||||
| [UiSettingsParams](./kibana-plugin-server.uisettingsparams.md) | UiSettings parameters defined by the plugins. |
|
||||
| [UiSettingsServiceSetup](./kibana-plugin-server.uisettingsservicesetup.md) | |
|
||||
| [UiSettingsServiceStart](./kibana-plugin-server.uisettingsservicestart.md) | |
|
||||
| [UserProvidedValues](./kibana-plugin-server.userprovidedvalues.md) | Describes the values explicitly set by user. |
|
||||
| [UuidServiceSetup](./kibana-plugin-server.uuidservicesetup.md) | APIs to access the application's instance uuid. |
|
||||
|
||||
## Variables
|
||||
|
||||
| Variable | Description |
|
||||
| --- | --- |
|
||||
| [kibanaResponseFactory](./kibana-plugin-server.kibanaresponsefactory.md) | Set of helpers used to create <code>KibanaResponse</code> to form HTTP response on an incoming request. Should be returned as a result of [RequestHandler](./kibana-plugin-server.requesthandler.md) execution. |
|
||||
| [validBodyOutput](./kibana-plugin-server.validbodyoutput.md) | The set of valid body.output |
|
||||
|
||||
## Type Aliases
|
||||
|
||||
| Type Alias | Description |
|
||||
| --- | --- |
|
||||
| [AuthenticationHandler](./kibana-plugin-server.authenticationhandler.md) | See [AuthToolkit](./kibana-plugin-server.authtoolkit.md)<!-- -->. |
|
||||
| [AuthHeaders](./kibana-plugin-server.authheaders.md) | Auth Headers map |
|
||||
| [AuthResult](./kibana-plugin-server.authresult.md) | |
|
||||
| [CapabilitiesProvider](./kibana-plugin-server.capabilitiesprovider.md) | See [CapabilitiesSetup](./kibana-plugin-server.capabilitiessetup.md) |
|
||||
| [CapabilitiesSwitcher](./kibana-plugin-server.capabilitiesswitcher.md) | See [CapabilitiesSetup](./kibana-plugin-server.capabilitiessetup.md) |
|
||||
| [ConfigDeprecation](./kibana-plugin-server.configdeprecation.md) | Configuration deprecation returned from [ConfigDeprecationProvider](./kibana-plugin-server.configdeprecationprovider.md) that handles a single deprecation from the configuration. |
|
||||
| [ConfigDeprecationLogger](./kibana-plugin-server.configdeprecationlogger.md) | Logger interface used when invoking a [ConfigDeprecation](./kibana-plugin-server.configdeprecation.md) |
|
||||
| [ConfigDeprecationProvider](./kibana-plugin-server.configdeprecationprovider.md) | A provider that should returns a list of [ConfigDeprecation](./kibana-plugin-server.configdeprecation.md)<!-- -->.<!-- -->See [ConfigDeprecationFactory](./kibana-plugin-server.configdeprecationfactory.md) for more usage examples. |
|
||||
| [ConfigPath](./kibana-plugin-server.configpath.md) | |
|
||||
| [ElasticsearchClientConfig](./kibana-plugin-server.elasticsearchclientconfig.md) | |
|
||||
| [GetAuthHeaders](./kibana-plugin-server.getauthheaders.md) | Get headers to authenticate a user against Elasticsearch. |
|
||||
| [GetAuthState](./kibana-plugin-server.getauthstate.md) | Get authentication state for a request. Returned by <code>auth</code> interceptor. |
|
||||
| [HandlerContextType](./kibana-plugin-server.handlercontexttype.md) | Extracts the type of the first argument of a [HandlerFunction](./kibana-plugin-server.handlerfunction.md) to represent the type of the context. |
|
||||
| [HandlerFunction](./kibana-plugin-server.handlerfunction.md) | A function that accepts a context object and an optional number of additional arguments. Used for the generic types in [IContextContainer](./kibana-plugin-server.icontextcontainer.md) |
|
||||
| [HandlerParameters](./kibana-plugin-server.handlerparameters.md) | Extracts the types of the additional arguments of a [HandlerFunction](./kibana-plugin-server.handlerfunction.md)<!-- -->, excluding the [HandlerContextType](./kibana-plugin-server.handlercontexttype.md)<!-- -->. |
|
||||
| [Headers](./kibana-plugin-server.headers.md) | Http request headers to read. |
|
||||
| [HttpResponsePayload](./kibana-plugin-server.httpresponsepayload.md) | Data send to the client as a response payload. |
|
||||
| [IBasePath](./kibana-plugin-server.ibasepath.md) | Access or manipulate the Kibana base path[BasePath](./kibana-plugin-server.basepath.md) |
|
||||
| [IClusterClient](./kibana-plugin-server.iclusterclient.md) | 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 <code>asScoped(...)</code>).<!-- -->See [ClusterClient](./kibana-plugin-server.clusterclient.md)<!-- -->. |
|
||||
| [IContextProvider](./kibana-plugin-server.icontextprovider.md) | A function that returns a context value for a specific key of given context type. |
|
||||
| [ICustomClusterClient](./kibana-plugin-server.icustomclusterclient.md) | 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 <code>asScoped(...)</code>).<!-- -->See [ClusterClient](./kibana-plugin-server.clusterclient.md)<!-- -->. |
|
||||
| [IsAuthenticated](./kibana-plugin-server.isauthenticated.md) | Return authentication status for a request. |
|
||||
| [ISavedObjectsRepository](./kibana-plugin-server.isavedobjectsrepository.md) | See [SavedObjectsRepository](./kibana-plugin-server.savedobjectsrepository.md) |
|
||||
| [IScopedClusterClient](./kibana-plugin-server.iscopedclusterclient.md) | Serves the same purpose as "normal" <code>ClusterClient</code> but exposes additional <code>callAsCurrentUser</code> method that doesn't use credentials of the Kibana internal user (as <code>callAsInternalUser</code> does) to request Elasticsearch API, but rather passes HTTP headers extracted from the current user request to the API.<!-- -->See [ScopedClusterClient](./kibana-plugin-server.scopedclusterclient.md)<!-- -->. |
|
||||
| [KibanaRequestRouteOptions](./kibana-plugin-server.kibanarequestrouteoptions.md) | Route options: If 'GET' or 'OPTIONS' method, body options won't be returned. |
|
||||
| [KibanaResponseFactory](./kibana-plugin-server.kibanaresponsefactory.md) | Creates an object containing request response payload, HTTP headers, error details, and other data transmitted to the client. |
|
||||
| [KnownHeaders](./kibana-plugin-server.knownheaders.md) | Set of well-known HTTP headers. |
|
||||
| [LifecycleResponseFactory](./kibana-plugin-server.lifecycleresponsefactory.md) | Creates an object containing redirection or error response with error details, HTTP headers, and other data transmitted to the client. |
|
||||
| [MIGRATION\_ASSISTANCE\_INDEX\_ACTION](./kibana-plugin-server.migration_assistance_index_action.md) | |
|
||||
| [MIGRATION\_DEPRECATION\_LEVEL](./kibana-plugin-server.migration_deprecation_level.md) | |
|
||||
| [MutatingOperationRefreshSetting](./kibana-plugin-server.mutatingoperationrefreshsetting.md) | Elasticsearch Refresh setting for mutating operation |
|
||||
| [OnPostAuthHandler](./kibana-plugin-server.onpostauthhandler.md) | See [OnPostAuthToolkit](./kibana-plugin-server.onpostauthtoolkit.md)<!-- -->. |
|
||||
| [OnPreAuthHandler](./kibana-plugin-server.onpreauthhandler.md) | See [OnPreAuthToolkit](./kibana-plugin-server.onpreauthtoolkit.md)<!-- -->. |
|
||||
| [OnPreResponseHandler](./kibana-plugin-server.onpreresponsehandler.md) | See [OnPreAuthToolkit](./kibana-plugin-server.onpreauthtoolkit.md)<!-- -->. |
|
||||
| [PluginConfigSchema](./kibana-plugin-server.pluginconfigschema.md) | Dedicated type for plugin configuration schema. |
|
||||
| [PluginInitializer](./kibana-plugin-server.plugininitializer.md) | The <code>plugin</code> export at the root of a plugin's <code>server</code> directory should conform to this interface. |
|
||||
| [PluginName](./kibana-plugin-server.pluginname.md) | Dedicated type for plugin name/id that is supposed to make Map/Set/Arrays that use it as a key or value more obvious. |
|
||||
| [PluginOpaqueId](./kibana-plugin-server.pluginopaqueid.md) | |
|
||||
| [RecursiveReadonly](./kibana-plugin-server.recursivereadonly.md) | |
|
||||
| [RedirectResponseOptions](./kibana-plugin-server.redirectresponseoptions.md) | HTTP response parameters for redirection response |
|
||||
| [RequestHandler](./kibana-plugin-server.requesthandler.md) | A function executed when route path matched requested resource path. Request handler is expected to return a result of one of [KibanaResponseFactory](./kibana-plugin-server.kibanaresponsefactory.md) functions. |
|
||||
| [RequestHandlerContextContainer](./kibana-plugin-server.requesthandlercontextcontainer.md) | An object that handles registration of http request context providers. |
|
||||
| [RequestHandlerContextProvider](./kibana-plugin-server.requesthandlercontextprovider.md) | Context provider for request handler. Extends request context object with provided functionality or data. |
|
||||
| [ResponseError](./kibana-plugin-server.responseerror.md) | Error message and optional data send to the client in case of error. |
|
||||
| [ResponseErrorAttributes](./kibana-plugin-server.responseerrorattributes.md) | Additional data to provide error details. |
|
||||
| [ResponseHeaders](./kibana-plugin-server.responseheaders.md) | Http response headers to set. |
|
||||
| [RouteContentType](./kibana-plugin-server.routecontenttype.md) | The set of supported parseable Content-Types |
|
||||
| [RouteMethod](./kibana-plugin-server.routemethod.md) | The set of common HTTP methods supported by Kibana routing. |
|
||||
| [RouteRegistrar](./kibana-plugin-server.routeregistrar.md) | Route handler common definition |
|
||||
| [RouteValidationFunction](./kibana-plugin-server.routevalidationfunction.md) | The custom validation function if @<!-- -->kbn/config-schema is not a valid solution for your specific plugin requirements. |
|
||||
| [RouteValidationSpec](./kibana-plugin-server.routevalidationspec.md) | Allowed property validation options: either @<!-- -->kbn/config-schema validations or custom validation functions<!-- -->See [RouteValidationFunction](./kibana-plugin-server.routevalidationfunction.md) for custom validation. |
|
||||
| [RouteValidatorFullConfig](./kibana-plugin-server.routevalidatorfullconfig.md) | Route validations config and options merged into one object |
|
||||
| [SavedObjectAttribute](./kibana-plugin-server.savedobjectattribute.md) | Type definition for a Saved Object attribute value |
|
||||
| [SavedObjectAttributeSingle](./kibana-plugin-server.savedobjectattributesingle.md) | Don't use this type, it's simply a helper type for [SavedObjectAttribute](./kibana-plugin-server.savedobjectattribute.md) |
|
||||
| [SavedObjectsClientContract](./kibana-plugin-server.savedobjectsclientcontract.md) | Saved Objects is Kibana's data persisentence mechanism allowing plugins to use Elasticsearch for storing plugin state.<!-- -->\#\# SavedObjectsClient errors<!-- -->Since the SavedObjectsClient has its hands in everything we are a little paranoid about the way we present errors back to to application code. Ideally, all errors will be either:<!-- -->1. Caused by bad implementation (ie. undefined is not a function) and as such unpredictable 2. An error that has been classified and decorated appropriately by the decorators in [SavedObjectsErrorHelpers](./kibana-plugin-server.savedobjectserrorhelpers.md)<!-- -->Type 1 errors are inevitable, but since all expected/handle-able errors should be Type 2 the <code>isXYZError()</code> helpers exposed at <code>SavedObjectsErrorHelpers</code> should be used to understand and manage error responses from the <code>SavedObjectsClient</code>.<!-- -->Type 2 errors are decorated versions of the source error, so if the elasticsearch client threw an error it will be decorated based on its type. That means that rather than looking for <code>error.body.error.type</code> or doing substring checks on <code>error.body.error.reason</code>, just use the helpers to understand the meaning of the error:<!-- -->\`\`\`<!-- -->js if (SavedObjectsErrorHelpers.isNotFoundError(error)) { // handle 404 }<!-- -->if (SavedObjectsErrorHelpers.isNotAuthorizedError(error)) { // 401 handling should be automatic, but in case you wanted to know }<!-- -->// always rethrow the error unless you handle it throw error; \`\`\`<!-- -->\#\#\# 404s from missing index<!-- -->From the perspective of application code and APIs the SavedObjectsClient is a black box that persists objects. One of the internal details that users have no control over is that we use an elasticsearch index for persistance and that index might be missing.<!-- -->At the time of writing we are in the process of transitioning away from the operating assumption that the SavedObjects index is always available. Part of this transition is handling errors resulting from an index missing. These used to trigger a 500 error in most cases, and in others cause 404s with different error messages.<!-- -->From my (Spencer) perspective, a 404 from the SavedObjectsApi is a 404; The object the request/call was targeting could not be found. This is why \#14141 takes special care to ensure that 404 errors are generic and don't distinguish between index missing or document missing.<!-- -->\#\#\# 503s from missing index<!-- -->Unlike all other methods, create requests are supposed to succeed even when the Kibana index does not exist because it will be automatically created by elasticsearch. When that is not the case it is because Elasticsearch's <code>action.auto_create_index</code> setting prevents it from being created automatically so we throw a special 503 with the intention of informing the user that their Elasticsearch settings need to be updated.<!-- -->See [SavedObjectsClient](./kibana-plugin-server.savedobjectsclient.md) See [SavedObjectsErrorHelpers](./kibana-plugin-server.savedobjectserrorhelpers.md) |
|
||||
| [SavedObjectsClientFactory](./kibana-plugin-server.savedobjectsclientfactory.md) | Describes the factory used to create instances of the Saved Objects Client. |
|
||||
| [SavedObjectsClientWrapperFactory](./kibana-plugin-server.savedobjectsclientwrapperfactory.md) | Describes the factory used to create instances of Saved Objects Client Wrappers. |
|
||||
| [ScopeableRequest](./kibana-plugin-server.scopeablerequest.md) | A user credentials container. It accommodates the necessary auth credentials to impersonate the current user.<!-- -->See [KibanaRequest](./kibana-plugin-server.kibanarequest.md)<!-- -->. |
|
||||
| [SharedGlobalConfig](./kibana-plugin-server.sharedglobalconfig.md) | |
|
||||
| [UiSettingsType](./kibana-plugin-server.uisettingstype.md) | UI element type to represent the settings. |
|
||||
|
||||
<!-- Do not edit this file. It is automatically generated by API Documenter. -->
|
||||
|
||||
[Home](./index.md) > [kibana-plugin-server](./kibana-plugin-server.md)
|
||||
|
||||
## kibana-plugin-server package
|
||||
|
||||
The Kibana Core APIs for server-side plugins.
|
||||
|
||||
A plugin requires a `kibana.json` file at it's root directory that follows [the manfiest schema](./kibana-plugin-server.pluginmanifest.md) to define static plugin information required to load the plugin.
|
||||
|
||||
A plugin's `server/index` file must contain a named import, `plugin`<!-- -->, that implements [PluginInitializer](./kibana-plugin-server.plugininitializer.md) which returns an object that implements [Plugin](./kibana-plugin-server.plugin.md)<!-- -->.
|
||||
|
||||
The plugin integrates with the core system via lifecycle events: `setup`<!-- -->, `start`<!-- -->, and `stop`<!-- -->. In each lifecycle method, the plugin will receive the corresponding core services available (either [CoreSetup](./kibana-plugin-server.coresetup.md) or [CoreStart](./kibana-plugin-server.corestart.md)<!-- -->) and any interfaces returned by dependency plugins' lifecycle method. Anything returned by the plugin's lifecycle method will be exposed to downstream dependencies when their corresponding lifecycle methods are invoked.
|
||||
|
||||
## Classes
|
||||
|
||||
| Class | Description |
|
||||
| --- | --- |
|
||||
| [BasePath](./kibana-plugin-server.basepath.md) | Access or manipulate the Kibana base path |
|
||||
| [ClusterClient](./kibana-plugin-server.clusterclient.md) | 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 <code>asScoped(...)</code>).<!-- -->See [ClusterClient](./kibana-plugin-server.clusterclient.md)<!-- -->. |
|
||||
| [CspConfig](./kibana-plugin-server.cspconfig.md) | CSP configuration for use in Kibana. |
|
||||
| [ElasticsearchErrorHelpers](./kibana-plugin-server.elasticsearcherrorhelpers.md) | Helpers for working with errors returned from the Elasticsearch service.Since the internal data of errors are subject to change, consumers of the Elasticsearch service should always use these helpers to classify errors instead of checking error internals such as <code>body.error.header[WWW-Authenticate]</code> |
|
||||
| [KibanaRequest](./kibana-plugin-server.kibanarequest.md) | Kibana specific abstraction for an incoming request. |
|
||||
| [RouteValidationError](./kibana-plugin-server.routevalidationerror.md) | Error to return when the validation is not successful. |
|
||||
| [SavedObjectsClient](./kibana-plugin-server.savedobjectsclient.md) | |
|
||||
| [SavedObjectsErrorHelpers](./kibana-plugin-server.savedobjectserrorhelpers.md) | |
|
||||
| [SavedObjectsRepository](./kibana-plugin-server.savedobjectsrepository.md) | |
|
||||
| [ScopedClusterClient](./kibana-plugin-server.scopedclusterclient.md) | Serves the same purpose as "normal" <code>ClusterClient</code> but exposes additional <code>callAsCurrentUser</code> method that doesn't use credentials of the Kibana internal user (as <code>callAsInternalUser</code> does) to request Elasticsearch API, but rather passes HTTP headers extracted from the current user request to the API.<!-- -->See [ScopedClusterClient](./kibana-plugin-server.scopedclusterclient.md)<!-- -->. |
|
||||
|
||||
## Enumerations
|
||||
|
||||
| Enumeration | Description |
|
||||
| --- | --- |
|
||||
| [AuthResultType](./kibana-plugin-server.authresulttype.md) | |
|
||||
| [AuthStatus](./kibana-plugin-server.authstatus.md) | Status indicating an outcome of the authentication. |
|
||||
|
||||
## Interfaces
|
||||
|
||||
| Interface | Description |
|
||||
| --- | --- |
|
||||
| [APICaller](./kibana-plugin-server.apicaller.md) | |
|
||||
| [AssistanceAPIResponse](./kibana-plugin-server.assistanceapiresponse.md) | |
|
||||
| [AssistantAPIClientParams](./kibana-plugin-server.assistantapiclientparams.md) | |
|
||||
| [Authenticated](./kibana-plugin-server.authenticated.md) | |
|
||||
| [AuthResultParams](./kibana-plugin-server.authresultparams.md) | Result of an incoming request authentication. |
|
||||
| [AuthToolkit](./kibana-plugin-server.authtoolkit.md) | A tool set defining an outcome of Auth interceptor for incoming request. |
|
||||
| [CallAPIOptions](./kibana-plugin-server.callapioptions.md) | The set of options that defines how API call should be made and result be processed. |
|
||||
| [Capabilities](./kibana-plugin-server.capabilities.md) | The read-only set of capabilities available for the current UI session. Capabilities are simple key-value pairs of (string, boolean), where the string denotes the capability ID, and the boolean is a flag indicating if the capability is enabled or disabled. |
|
||||
| [CapabilitiesSetup](./kibana-plugin-server.capabilitiessetup.md) | APIs to manage the [Capabilities](./kibana-plugin-server.capabilities.md) that will be used by the application.<!-- -->Plugins relying on capabilities to toggle some of their features should register them during the setup phase using the <code>registerProvider</code> method.<!-- -->Plugins having the responsibility to restrict capabilities depending on a given context should register their capabilities switcher using the <code>registerSwitcher</code> method.<!-- -->Refers to the methods documentation for complete description and examples. |
|
||||
| [CapabilitiesStart](./kibana-plugin-server.capabilitiesstart.md) | APIs to access the application [Capabilities](./kibana-plugin-server.capabilities.md)<!-- -->. |
|
||||
| [ConfigDeprecationFactory](./kibana-plugin-server.configdeprecationfactory.md) | Provides helpers to generates the most commonly used [ConfigDeprecation](./kibana-plugin-server.configdeprecation.md) when invoking a [ConfigDeprecationProvider](./kibana-plugin-server.configdeprecationprovider.md)<!-- -->.<!-- -->See methods documentation for more detailed examples. |
|
||||
| [ContextSetup](./kibana-plugin-server.contextsetup.md) | An object that handles registration of context providers and configuring handlers with context. |
|
||||
| [CoreSetup](./kibana-plugin-server.coresetup.md) | Context passed to the plugins <code>setup</code> method. |
|
||||
| [CoreStart](./kibana-plugin-server.corestart.md) | Context passed to the plugins <code>start</code> method. |
|
||||
| [CustomHttpResponseOptions](./kibana-plugin-server.customhttpresponseoptions.md) | HTTP response parameters for a response with adjustable status code. |
|
||||
| [DeprecationAPIClientParams](./kibana-plugin-server.deprecationapiclientparams.md) | |
|
||||
| [DeprecationAPIResponse](./kibana-plugin-server.deprecationapiresponse.md) | |
|
||||
| [DeprecationInfo](./kibana-plugin-server.deprecationinfo.md) | |
|
||||
| [DeprecationSettings](./kibana-plugin-server.deprecationsettings.md) | UiSettings deprecation field options. |
|
||||
| [DiscoveredPlugin](./kibana-plugin-server.discoveredplugin.md) | Small container object used to expose information about discovered plugins that may or may not have been started. |
|
||||
| [ElasticsearchError](./kibana-plugin-server.elasticsearcherror.md) | |
|
||||
| [ElasticsearchServiceSetup](./kibana-plugin-server.elasticsearchservicesetup.md) | |
|
||||
| [EnvironmentMode](./kibana-plugin-server.environmentmode.md) | |
|
||||
| [ErrorHttpResponseOptions](./kibana-plugin-server.errorhttpresponseoptions.md) | HTTP response parameters |
|
||||
| [FakeRequest](./kibana-plugin-server.fakerequest.md) | Fake request object created manually by Kibana plugins. |
|
||||
| [HttpResponseOptions](./kibana-plugin-server.httpresponseoptions.md) | HTTP response parameters |
|
||||
| [HttpServiceSetup](./kibana-plugin-server.httpservicesetup.md) | Kibana HTTP Service provides own abstraction for work with HTTP stack. Plugins don't have direct access to <code>hapi</code> server and its primitives anymore. Moreover, plugins shouldn't rely on the fact that HTTP Service uses one or another library under the hood. This gives the platform flexibility to upgrade or changing our internal HTTP stack without breaking plugins. If the HTTP Service lacks functionality you need, we are happy to discuss and support your needs. |
|
||||
| [HttpServiceStart](./kibana-plugin-server.httpservicestart.md) | |
|
||||
| [IContextContainer](./kibana-plugin-server.icontextcontainer.md) | An object that handles registration of context providers and configuring handlers with context. |
|
||||
| [ICspConfig](./kibana-plugin-server.icspconfig.md) | CSP configuration for use in Kibana. |
|
||||
| [IKibanaResponse](./kibana-plugin-server.ikibanaresponse.md) | A response data object, expected to returned as a result of [RequestHandler](./kibana-plugin-server.requesthandler.md) execution |
|
||||
| [IKibanaSocket](./kibana-plugin-server.ikibanasocket.md) | A tiny abstraction for TCP socket. |
|
||||
| [ImageValidation](./kibana-plugin-server.imagevalidation.md) | |
|
||||
| [IndexSettingsDeprecationInfo](./kibana-plugin-server.indexsettingsdeprecationinfo.md) | |
|
||||
| [IRenderOptions](./kibana-plugin-server.irenderoptions.md) | |
|
||||
| [IRouter](./kibana-plugin-server.irouter.md) | Registers route handlers for specified resource path and method. See [RouteConfig](./kibana-plugin-server.routeconfig.md) and [RequestHandler](./kibana-plugin-server.requesthandler.md) for more information about arguments to route registrations. |
|
||||
| [IScopedRenderingClient](./kibana-plugin-server.iscopedrenderingclient.md) | |
|
||||
| [IUiSettingsClient](./kibana-plugin-server.iuisettingsclient.md) | Server-side client that provides access to the advanced settings stored in elasticsearch. The settings provide control over the behavior of the Kibana application. For example, a user can specify how to display numeric or date fields. Users can adjust the settings via Management UI. |
|
||||
| [KibanaRequestEvents](./kibana-plugin-server.kibanarequestevents.md) | Request events. |
|
||||
| [KibanaRequestRoute](./kibana-plugin-server.kibanarequestroute.md) | Request specific route information exposed to a handler. |
|
||||
| [LegacyRequest](./kibana-plugin-server.legacyrequest.md) | |
|
||||
| [LegacyServiceSetupDeps](./kibana-plugin-server.legacyservicesetupdeps.md) | |
|
||||
| [LegacyServiceStartDeps](./kibana-plugin-server.legacyservicestartdeps.md) | |
|
||||
| [Logger](./kibana-plugin-server.logger.md) | Logger exposes all the necessary methods to log any type of information and this is the interface used by the logging consumers including plugins. |
|
||||
| [LoggerFactory](./kibana-plugin-server.loggerfactory.md) | The single purpose of <code>LoggerFactory</code> interface is to define a way to retrieve a context-based logger instance. |
|
||||
| [LogMeta](./kibana-plugin-server.logmeta.md) | Contextual metadata |
|
||||
| [OnPostAuthToolkit](./kibana-plugin-server.onpostauthtoolkit.md) | A tool set defining an outcome of OnPostAuth interceptor for incoming request. |
|
||||
| [OnPreAuthToolkit](./kibana-plugin-server.onpreauthtoolkit.md) | A tool set defining an outcome of OnPreAuth interceptor for incoming request. |
|
||||
| [OnPreResponseExtensions](./kibana-plugin-server.onpreresponseextensions.md) | Additional data to extend a response. |
|
||||
| [OnPreResponseInfo](./kibana-plugin-server.onpreresponseinfo.md) | Response status code. |
|
||||
| [OnPreResponseToolkit](./kibana-plugin-server.onpreresponsetoolkit.md) | A tool set defining an outcome of OnPreAuth interceptor for incoming request. |
|
||||
| [PackageInfo](./kibana-plugin-server.packageinfo.md) | |
|
||||
| [Plugin](./kibana-plugin-server.plugin.md) | The interface that should be returned by a <code>PluginInitializer</code>. |
|
||||
| [PluginConfigDescriptor](./kibana-plugin-server.pluginconfigdescriptor.md) | Describes a plugin configuration properties. |
|
||||
| [PluginInitializerContext](./kibana-plugin-server.plugininitializercontext.md) | Context that's available to plugins during initialization stage. |
|
||||
| [PluginManifest](./kibana-plugin-server.pluginmanifest.md) | Describes the set of required and optional properties plugin can define in its mandatory JSON manifest file. |
|
||||
| [PluginsServiceSetup](./kibana-plugin-server.pluginsservicesetup.md) | |
|
||||
| [PluginsServiceStart](./kibana-plugin-server.pluginsservicestart.md) | |
|
||||
| [RequestHandlerContext](./kibana-plugin-server.requesthandlercontext.md) | Plugin specific context passed to a route handler.<!-- -->Provides the following clients: - [rendering](./kibana-plugin-server.iscopedrenderingclient.md) - Rendering client which uses the data of the incoming request - [savedObjects.client](./kibana-plugin-server.savedobjectsclient.md) - Saved Objects client which uses the credentials of the incoming request - [elasticsearch.dataClient](./kibana-plugin-server.scopedclusterclient.md) - Elasticsearch data client which uses the credentials of the incoming request - [elasticsearch.adminClient](./kibana-plugin-server.scopedclusterclient.md) - Elasticsearch admin client which uses the credentials of the incoming request - [uiSettings.client](./kibana-plugin-server.iuisettingsclient.md) - uiSettings client which uses the credentials of the incoming request |
|
||||
| [RouteConfig](./kibana-plugin-server.routeconfig.md) | Route specific configuration. |
|
||||
| [RouteConfigOptions](./kibana-plugin-server.routeconfigoptions.md) | Additional route options. |
|
||||
| [RouteConfigOptionsBody](./kibana-plugin-server.routeconfigoptionsbody.md) | Additional body options for a route |
|
||||
| [RouteValidationResultFactory](./kibana-plugin-server.routevalidationresultfactory.md) | Validation result factory to be used in the custom validation function to return the valid data or validation errors<!-- -->See [RouteValidationFunction](./kibana-plugin-server.routevalidationfunction.md)<!-- -->. |
|
||||
| [RouteValidatorConfig](./kibana-plugin-server.routevalidatorconfig.md) | The configuration object to the RouteValidator class. Set <code>params</code>, <code>query</code> and/or <code>body</code> to specify the validation logic to follow for that property. |
|
||||
| [RouteValidatorOptions](./kibana-plugin-server.routevalidatoroptions.md) | Additional options for the RouteValidator class to modify its default behaviour. |
|
||||
| [SavedObject](./kibana-plugin-server.savedobject.md) | |
|
||||
| [SavedObjectAttributes](./kibana-plugin-server.savedobjectattributes.md) | The data for a Saved Object is stored as an object in the <code>attributes</code> property. |
|
||||
| [SavedObjectReference](./kibana-plugin-server.savedobjectreference.md) | A reference to another saved object. |
|
||||
| [SavedObjectsBaseOptions](./kibana-plugin-server.savedobjectsbaseoptions.md) | |
|
||||
| [SavedObjectsBulkCreateObject](./kibana-plugin-server.savedobjectsbulkcreateobject.md) | |
|
||||
| [SavedObjectsBulkGetObject](./kibana-plugin-server.savedobjectsbulkgetobject.md) | |
|
||||
| [SavedObjectsBulkResponse](./kibana-plugin-server.savedobjectsbulkresponse.md) | |
|
||||
| [SavedObjectsBulkUpdateObject](./kibana-plugin-server.savedobjectsbulkupdateobject.md) | |
|
||||
| [SavedObjectsBulkUpdateOptions](./kibana-plugin-server.savedobjectsbulkupdateoptions.md) | |
|
||||
| [SavedObjectsBulkUpdateResponse](./kibana-plugin-server.savedobjectsbulkupdateresponse.md) | |
|
||||
| [SavedObjectsClientProviderOptions](./kibana-plugin-server.savedobjectsclientprovideroptions.md) | Options to control the creation of the Saved Objects Client. |
|
||||
| [SavedObjectsClientWrapperOptions](./kibana-plugin-server.savedobjectsclientwrapperoptions.md) | Options passed to each SavedObjectsClientWrapperFactory to aid in creating the wrapper instance. |
|
||||
| [SavedObjectsCreateOptions](./kibana-plugin-server.savedobjectscreateoptions.md) | |
|
||||
| [SavedObjectsDeleteByNamespaceOptions](./kibana-plugin-server.savedobjectsdeletebynamespaceoptions.md) | |
|
||||
| [SavedObjectsDeleteOptions](./kibana-plugin-server.savedobjectsdeleteoptions.md) | |
|
||||
| [SavedObjectsExportOptions](./kibana-plugin-server.savedobjectsexportoptions.md) | Options controlling the export operation. |
|
||||
| [SavedObjectsExportResultDetails](./kibana-plugin-server.savedobjectsexportresultdetails.md) | Structure of the export result details entry |
|
||||
| [SavedObjectsFindOptions](./kibana-plugin-server.savedobjectsfindoptions.md) | |
|
||||
| [SavedObjectsFindResponse](./kibana-plugin-server.savedobjectsfindresponse.md) | Return type of the Saved Objects <code>find()</code> method.<!-- -->\*Note\*: this type is different between the Public and Server Saved Objects clients. |
|
||||
| [SavedObjectsImportConflictError](./kibana-plugin-server.savedobjectsimportconflicterror.md) | Represents a failure to import due to a conflict. |
|
||||
| [SavedObjectsImportError](./kibana-plugin-server.savedobjectsimporterror.md) | Represents a failure to import. |
|
||||
| [SavedObjectsImportMissingReferencesError](./kibana-plugin-server.savedobjectsimportmissingreferenceserror.md) | Represents a failure to import due to missing references. |
|
||||
| [SavedObjectsImportOptions](./kibana-plugin-server.savedobjectsimportoptions.md) | Options to control the import operation. |
|
||||
| [SavedObjectsImportResponse](./kibana-plugin-server.savedobjectsimportresponse.md) | The response describing the result of an import. |
|
||||
| [SavedObjectsImportRetry](./kibana-plugin-server.savedobjectsimportretry.md) | Describes a retry operation for importing a saved object. |
|
||||
| [SavedObjectsImportUnknownError](./kibana-plugin-server.savedobjectsimportunknownerror.md) | Represents a failure to import due to an unknown reason. |
|
||||
| [SavedObjectsImportUnsupportedTypeError](./kibana-plugin-server.savedobjectsimportunsupportedtypeerror.md) | Represents a failure to import due to having an unsupported saved object type. |
|
||||
| [SavedObjectsIncrementCounterOptions](./kibana-plugin-server.savedobjectsincrementcounteroptions.md) | |
|
||||
| [SavedObjectsMigrationLogger](./kibana-plugin-server.savedobjectsmigrationlogger.md) | |
|
||||
| [SavedObjectsMigrationVersion](./kibana-plugin-server.savedobjectsmigrationversion.md) | Information about the migrations that have been applied to this SavedObject. When Kibana starts up, KibanaMigrator detects outdated documents and migrates them based on this value. For each migration that has been applied, the plugin's name is used as a key and the latest migration version as the value. |
|
||||
| [SavedObjectsRawDoc](./kibana-plugin-server.savedobjectsrawdoc.md) | A raw document as represented directly in the saved object index. |
|
||||
| [SavedObjectsRepositoryFactory](./kibana-plugin-server.savedobjectsrepositoryfactory.md) | Factory provided when invoking a [client factory provider](./kibana-plugin-server.savedobjectsclientfactoryprovider.md) See [SavedObjectsServiceSetup.setClientFactoryProvider](./kibana-plugin-server.savedobjectsservicesetup.setclientfactoryprovider.md) |
|
||||
| [SavedObjectsResolveImportErrorsOptions](./kibana-plugin-server.savedobjectsresolveimporterrorsoptions.md) | Options to control the "resolve import" operation. |
|
||||
| [SavedObjectsServiceSetup](./kibana-plugin-server.savedobjectsservicesetup.md) | 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. |
|
||||
| [SavedObjectsServiceStart](./kibana-plugin-server.savedobjectsservicestart.md) | Saved Objects is Kibana's data persisentence mechanism allowing plugins to use Elasticsearch for storing and querying state. The SavedObjectsServiceStart API provides a scoped Saved Objects client for interacting with Saved Objects. |
|
||||
| [SavedObjectsUpdateOptions](./kibana-plugin-server.savedobjectsupdateoptions.md) | |
|
||||
| [SavedObjectsUpdateResponse](./kibana-plugin-server.savedobjectsupdateresponse.md) | |
|
||||
| [SessionCookieValidationResult](./kibana-plugin-server.sessioncookievalidationresult.md) | Return type from a function to validate cookie contents. |
|
||||
| [SessionStorage](./kibana-plugin-server.sessionstorage.md) | Provides an interface to store and retrieve data across requests. |
|
||||
| [SessionStorageCookieOptions](./kibana-plugin-server.sessionstoragecookieoptions.md) | Configuration used to create HTTP session storage based on top of cookie mechanism. |
|
||||
| [SessionStorageFactory](./kibana-plugin-server.sessionstoragefactory.md) | SessionStorage factory to bind one to an incoming request |
|
||||
| [StringValidation](./kibana-plugin-server.stringvalidation.md) | |
|
||||
| [UiSettingsParams](./kibana-plugin-server.uisettingsparams.md) | UiSettings parameters defined by the plugins. |
|
||||
| [UiSettingsServiceSetup](./kibana-plugin-server.uisettingsservicesetup.md) | |
|
||||
| [UiSettingsServiceStart](./kibana-plugin-server.uisettingsservicestart.md) | |
|
||||
| [UserProvidedValues](./kibana-plugin-server.userprovidedvalues.md) | Describes the values explicitly set by user. |
|
||||
| [UuidServiceSetup](./kibana-plugin-server.uuidservicesetup.md) | APIs to access the application's instance uuid. |
|
||||
|
||||
## Variables
|
||||
|
||||
| Variable | Description |
|
||||
| --- | --- |
|
||||
| [kibanaResponseFactory](./kibana-plugin-server.kibanaresponsefactory.md) | Set of helpers used to create <code>KibanaResponse</code> to form HTTP response on an incoming request. Should be returned as a result of [RequestHandler](./kibana-plugin-server.requesthandler.md) execution. |
|
||||
| [validBodyOutput](./kibana-plugin-server.validbodyoutput.md) | The set of valid body.output |
|
||||
|
||||
## Type Aliases
|
||||
|
||||
| Type Alias | Description |
|
||||
| --- | --- |
|
||||
| [AuthenticationHandler](./kibana-plugin-server.authenticationhandler.md) | See [AuthToolkit](./kibana-plugin-server.authtoolkit.md)<!-- -->. |
|
||||
| [AuthHeaders](./kibana-plugin-server.authheaders.md) | Auth Headers map |
|
||||
| [AuthResult](./kibana-plugin-server.authresult.md) | |
|
||||
| [CapabilitiesProvider](./kibana-plugin-server.capabilitiesprovider.md) | See [CapabilitiesSetup](./kibana-plugin-server.capabilitiessetup.md) |
|
||||
| [CapabilitiesSwitcher](./kibana-plugin-server.capabilitiesswitcher.md) | See [CapabilitiesSetup](./kibana-plugin-server.capabilitiessetup.md) |
|
||||
| [ConfigDeprecation](./kibana-plugin-server.configdeprecation.md) | Configuration deprecation returned from [ConfigDeprecationProvider](./kibana-plugin-server.configdeprecationprovider.md) that handles a single deprecation from the configuration. |
|
||||
| [ConfigDeprecationLogger](./kibana-plugin-server.configdeprecationlogger.md) | Logger interface used when invoking a [ConfigDeprecation](./kibana-plugin-server.configdeprecation.md) |
|
||||
| [ConfigDeprecationProvider](./kibana-plugin-server.configdeprecationprovider.md) | A provider that should returns a list of [ConfigDeprecation](./kibana-plugin-server.configdeprecation.md)<!-- -->.<!-- -->See [ConfigDeprecationFactory](./kibana-plugin-server.configdeprecationfactory.md) for more usage examples. |
|
||||
| [ConfigPath](./kibana-plugin-server.configpath.md) | |
|
||||
| [ElasticsearchClientConfig](./kibana-plugin-server.elasticsearchclientconfig.md) | |
|
||||
| [GetAuthHeaders](./kibana-plugin-server.getauthheaders.md) | Get headers to authenticate a user against Elasticsearch. |
|
||||
| [GetAuthState](./kibana-plugin-server.getauthstate.md) | Get authentication state for a request. Returned by <code>auth</code> interceptor. |
|
||||
| [HandlerContextType](./kibana-plugin-server.handlercontexttype.md) | Extracts the type of the first argument of a [HandlerFunction](./kibana-plugin-server.handlerfunction.md) to represent the type of the context. |
|
||||
| [HandlerFunction](./kibana-plugin-server.handlerfunction.md) | A function that accepts a context object and an optional number of additional arguments. Used for the generic types in [IContextContainer](./kibana-plugin-server.icontextcontainer.md) |
|
||||
| [HandlerParameters](./kibana-plugin-server.handlerparameters.md) | Extracts the types of the additional arguments of a [HandlerFunction](./kibana-plugin-server.handlerfunction.md)<!-- -->, excluding the [HandlerContextType](./kibana-plugin-server.handlercontexttype.md)<!-- -->. |
|
||||
| [Headers](./kibana-plugin-server.headers.md) | Http request headers to read. |
|
||||
| [HttpResponsePayload](./kibana-plugin-server.httpresponsepayload.md) | Data send to the client as a response payload. |
|
||||
| [IBasePath](./kibana-plugin-server.ibasepath.md) | Access or manipulate the Kibana base path[BasePath](./kibana-plugin-server.basepath.md) |
|
||||
| [IClusterClient](./kibana-plugin-server.iclusterclient.md) | 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 <code>asScoped(...)</code>).<!-- -->See [ClusterClient](./kibana-plugin-server.clusterclient.md)<!-- -->. |
|
||||
| [IContextProvider](./kibana-plugin-server.icontextprovider.md) | A function that returns a context value for a specific key of given context type. |
|
||||
| [ICustomClusterClient](./kibana-plugin-server.icustomclusterclient.md) | 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 <code>asScoped(...)</code>).<!-- -->See [ClusterClient](./kibana-plugin-server.clusterclient.md)<!-- -->. |
|
||||
| [IsAuthenticated](./kibana-plugin-server.isauthenticated.md) | Return authentication status for a request. |
|
||||
| [ISavedObjectsRepository](./kibana-plugin-server.isavedobjectsrepository.md) | See [SavedObjectsRepository](./kibana-plugin-server.savedobjectsrepository.md) |
|
||||
| [IScopedClusterClient](./kibana-plugin-server.iscopedclusterclient.md) | Serves the same purpose as "normal" <code>ClusterClient</code> but exposes additional <code>callAsCurrentUser</code> method that doesn't use credentials of the Kibana internal user (as <code>callAsInternalUser</code> does) to request Elasticsearch API, but rather passes HTTP headers extracted from the current user request to the API.<!-- -->See [ScopedClusterClient](./kibana-plugin-server.scopedclusterclient.md)<!-- -->. |
|
||||
| [KibanaRequestRouteOptions](./kibana-plugin-server.kibanarequestrouteoptions.md) | Route options: If 'GET' or 'OPTIONS' method, body options won't be returned. |
|
||||
| [KibanaResponseFactory](./kibana-plugin-server.kibanaresponsefactory.md) | Creates an object containing request response payload, HTTP headers, error details, and other data transmitted to the client. |
|
||||
| [KnownHeaders](./kibana-plugin-server.knownheaders.md) | Set of well-known HTTP headers. |
|
||||
| [LifecycleResponseFactory](./kibana-plugin-server.lifecycleresponsefactory.md) | Creates an object containing redirection or error response with error details, HTTP headers, and other data transmitted to the client. |
|
||||
| [MIGRATION\_ASSISTANCE\_INDEX\_ACTION](./kibana-plugin-server.migration_assistance_index_action.md) | |
|
||||
| [MIGRATION\_DEPRECATION\_LEVEL](./kibana-plugin-server.migration_deprecation_level.md) | |
|
||||
| [MutatingOperationRefreshSetting](./kibana-plugin-server.mutatingoperationrefreshsetting.md) | Elasticsearch Refresh setting for mutating operation |
|
||||
| [OnPostAuthHandler](./kibana-plugin-server.onpostauthhandler.md) | See [OnPostAuthToolkit](./kibana-plugin-server.onpostauthtoolkit.md)<!-- -->. |
|
||||
| [OnPreAuthHandler](./kibana-plugin-server.onpreauthhandler.md) | See [OnPreAuthToolkit](./kibana-plugin-server.onpreauthtoolkit.md)<!-- -->. |
|
||||
| [OnPreResponseHandler](./kibana-plugin-server.onpreresponsehandler.md) | See [OnPreAuthToolkit](./kibana-plugin-server.onpreauthtoolkit.md)<!-- -->. |
|
||||
| [PluginConfigSchema](./kibana-plugin-server.pluginconfigschema.md) | Dedicated type for plugin configuration schema. |
|
||||
| [PluginInitializer](./kibana-plugin-server.plugininitializer.md) | The <code>plugin</code> export at the root of a plugin's <code>server</code> directory should conform to this interface. |
|
||||
| [PluginName](./kibana-plugin-server.pluginname.md) | Dedicated type for plugin name/id that is supposed to make Map/Set/Arrays that use it as a key or value more obvious. |
|
||||
| [PluginOpaqueId](./kibana-plugin-server.pluginopaqueid.md) | |
|
||||
| [RecursiveReadonly](./kibana-plugin-server.recursivereadonly.md) | |
|
||||
| [RedirectResponseOptions](./kibana-plugin-server.redirectresponseoptions.md) | HTTP response parameters for redirection response |
|
||||
| [RequestHandler](./kibana-plugin-server.requesthandler.md) | A function executed when route path matched requested resource path. Request handler is expected to return a result of one of [KibanaResponseFactory](./kibana-plugin-server.kibanaresponsefactory.md) functions. |
|
||||
| [RequestHandlerContextContainer](./kibana-plugin-server.requesthandlercontextcontainer.md) | An object that handles registration of http request context providers. |
|
||||
| [RequestHandlerContextProvider](./kibana-plugin-server.requesthandlercontextprovider.md) | Context provider for request handler. Extends request context object with provided functionality or data. |
|
||||
| [ResponseError](./kibana-plugin-server.responseerror.md) | Error message and optional data send to the client in case of error. |
|
||||
| [ResponseErrorAttributes](./kibana-plugin-server.responseerrorattributes.md) | Additional data to provide error details. |
|
||||
| [ResponseHeaders](./kibana-plugin-server.responseheaders.md) | Http response headers to set. |
|
||||
| [RouteContentType](./kibana-plugin-server.routecontenttype.md) | The set of supported parseable Content-Types |
|
||||
| [RouteMethod](./kibana-plugin-server.routemethod.md) | The set of common HTTP methods supported by Kibana routing. |
|
||||
| [RouteRegistrar](./kibana-plugin-server.routeregistrar.md) | Route handler common definition |
|
||||
| [RouteValidationFunction](./kibana-plugin-server.routevalidationfunction.md) | The custom validation function if @<!-- -->kbn/config-schema is not a valid solution for your specific plugin requirements. |
|
||||
| [RouteValidationSpec](./kibana-plugin-server.routevalidationspec.md) | Allowed property validation options: either @<!-- -->kbn/config-schema validations or custom validation functions<!-- -->See [RouteValidationFunction](./kibana-plugin-server.routevalidationfunction.md) for custom validation. |
|
||||
| [RouteValidatorFullConfig](./kibana-plugin-server.routevalidatorfullconfig.md) | Route validations config and options merged into one object |
|
||||
| [SavedObjectAttribute](./kibana-plugin-server.savedobjectattribute.md) | Type definition for a Saved Object attribute value |
|
||||
| [SavedObjectAttributeSingle](./kibana-plugin-server.savedobjectattributesingle.md) | Don't use this type, it's simply a helper type for [SavedObjectAttribute](./kibana-plugin-server.savedobjectattribute.md) |
|
||||
| [SavedObjectsClientContract](./kibana-plugin-server.savedobjectsclientcontract.md) | Saved Objects is Kibana's data persisentence mechanism allowing plugins to use Elasticsearch for storing plugin state.<!-- -->\#\# SavedObjectsClient errors<!-- -->Since the SavedObjectsClient has its hands in everything we are a little paranoid about the way we present errors back to to application code. Ideally, all errors will be either:<!-- -->1. Caused by bad implementation (ie. undefined is not a function) and as such unpredictable 2. An error that has been classified and decorated appropriately by the decorators in [SavedObjectsErrorHelpers](./kibana-plugin-server.savedobjectserrorhelpers.md)<!-- -->Type 1 errors are inevitable, but since all expected/handle-able errors should be Type 2 the <code>isXYZError()</code> helpers exposed at <code>SavedObjectsErrorHelpers</code> should be used to understand and manage error responses from the <code>SavedObjectsClient</code>.<!-- -->Type 2 errors are decorated versions of the source error, so if the elasticsearch client threw an error it will be decorated based on its type. That means that rather than looking for <code>error.body.error.type</code> or doing substring checks on <code>error.body.error.reason</code>, just use the helpers to understand the meaning of the error:<!-- -->\`\`\`<!-- -->js if (SavedObjectsErrorHelpers.isNotFoundError(error)) { // handle 404 }<!-- -->if (SavedObjectsErrorHelpers.isNotAuthorizedError(error)) { // 401 handling should be automatic, but in case you wanted to know }<!-- -->// always rethrow the error unless you handle it throw error; \`\`\`<!-- -->\#\#\# 404s from missing index<!-- -->From the perspective of application code and APIs the SavedObjectsClient is a black box that persists objects. One of the internal details that users have no control over is that we use an elasticsearch index for persistance and that index might be missing.<!-- -->At the time of writing we are in the process of transitioning away from the operating assumption that the SavedObjects index is always available. Part of this transition is handling errors resulting from an index missing. These used to trigger a 500 error in most cases, and in others cause 404s with different error messages.<!-- -->From my (Spencer) perspective, a 404 from the SavedObjectsApi is a 404; The object the request/call was targeting could not be found. This is why \#14141 takes special care to ensure that 404 errors are generic and don't distinguish between index missing or document missing.<!-- -->\#\#\# 503s from missing index<!-- -->Unlike all other methods, create requests are supposed to succeed even when the Kibana index does not exist because it will be automatically created by elasticsearch. When that is not the case it is because Elasticsearch's <code>action.auto_create_index</code> setting prevents it from being created automatically so we throw a special 503 with the intention of informing the user that their Elasticsearch settings need to be updated.<!-- -->See [SavedObjectsClient](./kibana-plugin-server.savedobjectsclient.md) See [SavedObjectsErrorHelpers](./kibana-plugin-server.savedobjectserrorhelpers.md) |
|
||||
| [SavedObjectsClientFactory](./kibana-plugin-server.savedobjectsclientfactory.md) | Describes the factory used to create instances of the Saved Objects Client. |
|
||||
| [SavedObjectsClientFactoryProvider](./kibana-plugin-server.savedobjectsclientfactoryprovider.md) | Provider to invoke to retrieve a [SavedObjectsClientFactory](./kibana-plugin-server.savedobjectsclientfactory.md)<!-- -->. |
|
||||
| [SavedObjectsClientWrapperFactory](./kibana-plugin-server.savedobjectsclientwrapperfactory.md) | Describes the factory used to create instances of Saved Objects Client Wrappers. |
|
||||
| [ScopeableRequest](./kibana-plugin-server.scopeablerequest.md) | A user credentials container. It accommodates the necessary auth credentials to impersonate the current user.<!-- -->See [KibanaRequest](./kibana-plugin-server.kibanarequest.md)<!-- -->. |
|
||||
| [SharedGlobalConfig](./kibana-plugin-server.sharedglobalconfig.md) | |
|
||||
| [UiSettingsType](./kibana-plugin-server.uisettingstype.md) | UI element type to represent the settings. |
|
||||
|
||||
|
|
|
@ -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;
|
||||
```
|
||||
|
|
|
@ -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;
|
||||
```
|
|
@ -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;
|
||||
```
|
||||
|
|
|
@ -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> | |
|
||||
|
||||
|
|
|
@ -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;
|
||||
```
|
||||
|
|
|
@ -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;
|
||||
```
|
|
@ -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;
|
||||
```
|
|
@ -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. |
|
||||
|
|
@ -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;
|
||||
```
|
||||
|
|
|
@ -1,18 +0,0 @@
|
|||
<!-- 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) > [createInternalRepository](./kibana-plugin-server.savedobjectsservicesetup.createinternalrepository.md)
|
||||
|
||||
## SavedObjectsServiceSetup.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;
|
||||
```
|
||||
|
||||
## Remarks
|
||||
|
||||
The repository should only be used for creating and registering a client factory or client wrapper. Using the repository directly for interacting with Saved Objects is 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.
|
||||
|
|
@ -1,18 +0,0 @@
|
|||
<!-- 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) > [createScopedRepository](./kibana-plugin-server.savedobjectsservicesetup.createscopedrepository.md)
|
||||
|
||||
## SavedObjectsServiceSetup.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;
|
||||
```
|
||||
|
||||
## Remarks
|
||||
|
||||
The repository should only be used for creating and registering a client factory or client wrapper. Using the repository directly for interacting with Saved Objects is 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.
|
||||
|
|
@ -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. |
|
||||
|
||||
|
|
|
@ -1,13 +0,0 @@
|
|||
<!-- 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) > [setClientFactory](./kibana-plugin-server.savedobjectsservicesetup.setclientfactory.md)
|
||||
|
||||
## SavedObjectsServiceSetup.setClientFactory property
|
||||
|
||||
Set a default factory for creating Saved Objects clients. Only one client factory can be set, subsequent calls to this method will fail.
|
||||
|
||||
<b>Signature:</b>
|
||||
|
||||
```typescript
|
||||
setClientFactory: (customClientFactory: SavedObjectsClientFactory<KibanaRequest>) => void;
|
||||
```
|
|
@ -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;
|
||||
```
|
|
@ -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) > [SavedObjectsServiceStart](./kibana-plugin-server.savedobjectsservicestart.md) > [createInternalRepository](./kibana-plugin-server.savedobjectsservicestart.createinternalrepository.md)
|
||||
|
||||
## SavedObjectsServiceStart.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;
|
||||
```
|
|
@ -0,0 +1,18 @@
|
|||
<!-- Do not edit this file. It is automatically generated by API Documenter. -->
|
||||
|
||||
[Home](./index.md) > [kibana-plugin-server](./kibana-plugin-server.md) > [SavedObjectsServiceStart](./kibana-plugin-server.savedobjectsservicestart.md) > [createScopedRepository](./kibana-plugin-server.savedobjectsservicestart.createscopedrepository.md)
|
||||
|
||||
## SavedObjectsServiceStart.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;
|
||||
```
|
||||
|
||||
## Remarks
|
||||
|
||||
Prefer using `getScopedClient`<!-- -->. This should only be used when using methods not exposed on [SavedObjectsClientContract](./kibana-plugin-server.savedobjectsclientcontract.md)
|
||||
|
|
@ -1,20 +1,22 @@
|
|||
<!-- Do not edit this file. It is automatically generated by API Documenter. -->
|
||||
|
||||
[Home](./index.md) > [kibana-plugin-server](./kibana-plugin-server.md) > [SavedObjectsServiceStart](./kibana-plugin-server.savedobjectsservicestart.md)
|
||||
|
||||
## SavedObjectsServiceStart interface
|
||||
|
||||
Saved Objects is Kibana's data persisentence mechanism allowing plugins to use Elasticsearch for storing and querying state. The SavedObjectsServiceStart API provides a scoped Saved Objects client for interacting with Saved Objects.
|
||||
|
||||
<b>Signature:</b>
|
||||
|
||||
```typescript
|
||||
export interface SavedObjectsServiceStart
|
||||
```
|
||||
|
||||
## Properties
|
||||
|
||||
| Property | Type | Description |
|
||||
| --- | --- | --- |
|
||||
| [getScopedClient](./kibana-plugin-server.savedobjectsservicestart.getscopedclient.md) | <code>(req: KibanaRequest, options?: SavedObjectsClientProviderOptions) => SavedObjectsClientContract</code> | Creates a [Saved Objects client](./kibana-plugin-server.savedobjectsclientcontract.md) that uses the credentials from the passed in request to authenticate with Elasticsearch. If other plugins have registered Saved Objects client wrappers, these will be applied to extend the functionality of the client.<!-- -->A client that is already scoped to the incoming request is also exposed from the route handler context see [RequestHandlerContext](./kibana-plugin-server.requesthandlercontext.md)<!-- -->. |
|
||||
|
||||
<!-- Do not edit this file. It is automatically generated by API Documenter. -->
|
||||
|
||||
[Home](./index.md) > [kibana-plugin-server](./kibana-plugin-server.md) > [SavedObjectsServiceStart](./kibana-plugin-server.savedobjectsservicestart.md)
|
||||
|
||||
## SavedObjectsServiceStart interface
|
||||
|
||||
Saved Objects is Kibana's data persisentence mechanism allowing plugins to use Elasticsearch for storing and querying state. The SavedObjectsServiceStart API provides a scoped Saved Objects client for interacting with Saved Objects.
|
||||
|
||||
<b>Signature:</b>
|
||||
|
||||
```typescript
|
||||
export interface SavedObjectsServiceStart
|
||||
```
|
||||
|
||||
## Properties
|
||||
|
||||
| Property | Type | Description |
|
||||
| --- | --- | --- |
|
||||
| [createInternalRepository](./kibana-plugin-server.savedobjectsservicestart.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.savedobjectsservicestart.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. |
|
||||
| [getScopedClient](./kibana-plugin-server.savedobjectsservicestart.getscopedclient.md) | <code>(req: KibanaRequest, options?: SavedObjectsClientProviderOptions) => SavedObjectsClientContract</code> | Creates a [Saved Objects client](./kibana-plugin-server.savedobjectsclientcontract.md) that uses the credentials from the passed in request to authenticate with Elasticsearch. If other plugins have registered Saved Objects client wrappers, these will be applied to extend the functionality of the client.<!-- -->A client that is already scoped to the incoming request is also exposed from the route handler context see [RequestHandlerContext](./kibana-plugin-server.requesthandlercontext.md)<!-- -->. |
|
||||
|
||||
|
|
|
@ -22,6 +22,7 @@ import { defer, throwError, iif, timer } from 'rxjs';
|
|||
import * as legacyElasticsearch from 'elasticsearch';
|
||||
|
||||
import { CallAPIOptions } from '.';
|
||||
import { APICaller } from './api_types';
|
||||
import { Logger } from '../logging';
|
||||
|
||||
const esErrors = legacyElasticsearch.errors;
|
||||
|
@ -34,15 +35,11 @@ const esErrors = legacyElasticsearch.errors;
|
|||
* different error is received.
|
||||
*
|
||||
* @param apiCaller
|
||||
* @param log
|
||||
* @param delay
|
||||
*/
|
||||
|
||||
// TODO: Replace with APICaller from './scoped_cluster_client' once #46668 is merged
|
||||
export function migrationsRetryCallCluster(
|
||||
apiCaller: (
|
||||
endpoint: string,
|
||||
clientParams: Record<string, any>,
|
||||
options?: CallAPIOptions
|
||||
) => Promise<any>,
|
||||
apiCaller: APICaller,
|
||||
log: Logger,
|
||||
delay: number = 2500
|
||||
) {
|
||||
|
|
|
@ -180,6 +180,7 @@ export {
|
|||
SavedObjectsClientWrapperFactory,
|
||||
SavedObjectsClientWrapperOptions,
|
||||
SavedObjectsClientFactory,
|
||||
SavedObjectsClientFactoryProvider,
|
||||
SavedObjectsCreateOptions,
|
||||
SavedObjectsErrorHelpers,
|
||||
SavedObjectsExportOptions,
|
||||
|
@ -195,6 +196,7 @@ export {
|
|||
SavedObjectsImportUnsupportedTypeError,
|
||||
SavedObjectsMigrationLogger,
|
||||
SavedObjectsRawDoc,
|
||||
SavedObjectsRepositoryFactory,
|
||||
SavedObjectsResolveImportErrorsOptions,
|
||||
SavedObjectsSchema,
|
||||
SavedObjectsSerializer,
|
||||
|
|
|
@ -258,7 +258,11 @@ export class LegacyService implements CoreService {
|
|||
) {
|
||||
const coreStart: CoreStart = {
|
||||
capabilities: startDeps.core.capabilities,
|
||||
savedObjects: { getScopedClient: startDeps.core.savedObjects.getScopedClient },
|
||||
savedObjects: {
|
||||
getScopedClient: startDeps.core.savedObjects.getScopedClient,
|
||||
createScopedRepository: startDeps.core.savedObjects.createScopedRepository,
|
||||
createInternalRepository: startDeps.core.savedObjects.createInternalRepository,
|
||||
},
|
||||
uiSettings: { asScopedToClient: startDeps.core.uiSettings.asScopedToClient },
|
||||
};
|
||||
|
||||
|
@ -286,10 +290,8 @@ export class LegacyService implements CoreService {
|
|||
isTlsEnabled: setupDeps.core.http.isTlsEnabled,
|
||||
},
|
||||
savedObjects: {
|
||||
setClientFactory: setupDeps.core.savedObjects.setClientFactory,
|
||||
setClientFactoryProvider: setupDeps.core.savedObjects.setClientFactoryProvider,
|
||||
addClientWrapper: setupDeps.core.savedObjects.addClientWrapper,
|
||||
createInternalRepository: setupDeps.core.savedObjects.createInternalRepository,
|
||||
createScopedRepository: setupDeps.core.savedObjects.createScopedRepository,
|
||||
},
|
||||
uiSettings: {
|
||||
register: setupDeps.core.uiSettings.register,
|
||||
|
|
|
@ -165,10 +165,8 @@ export function createPluginSetupContext<TPlugin, TPluginDependencies>(
|
|||
isTlsEnabled: deps.http.isTlsEnabled,
|
||||
},
|
||||
savedObjects: {
|
||||
setClientFactory: deps.savedObjects.setClientFactory,
|
||||
setClientFactoryProvider: deps.savedObjects.setClientFactoryProvider,
|
||||
addClientWrapper: deps.savedObjects.addClientWrapper,
|
||||
createInternalRepository: deps.savedObjects.createInternalRepository,
|
||||
createScopedRepository: deps.savedObjects.createScopedRepository,
|
||||
},
|
||||
uiSettings: {
|
||||
register: deps.uiSettings.register,
|
||||
|
@ -203,6 +201,8 @@ export function createPluginStartContext<TPlugin, TPluginDependencies>(
|
|||
},
|
||||
savedObjects: {
|
||||
getScopedClient: deps.savedObjects.getScopedClient,
|
||||
createInternalRepository: deps.savedObjects.createInternalRepository,
|
||||
createScopedRepository: deps.savedObjects.createScopedRepository,
|
||||
},
|
||||
uiSettings: {
|
||||
asScopedToClient: deps.uiSettings.asScopedToClient,
|
||||
|
|
|
@ -41,6 +41,7 @@ export {
|
|||
SavedObjectsServiceStart,
|
||||
SavedObjectsServiceSetup,
|
||||
InternalSavedObjectsServiceSetup,
|
||||
SavedObjectsRepositoryFactory,
|
||||
} from './saved_objects_service';
|
||||
|
||||
export {
|
||||
|
|
|
@ -33,29 +33,27 @@ const createStartContractMock = () => {
|
|||
const startContract: jest.Mocked<InternalSavedObjectsServiceStart> = {
|
||||
clientProvider: savedObjectsClientProviderMock.create(),
|
||||
getScopedClient: jest.fn(),
|
||||
createInternalRepository: jest.fn(),
|
||||
createScopedRepository: jest.fn(),
|
||||
migrator: mockKibanaMigrator.create(),
|
||||
};
|
||||
|
||||
startContract.getScopedClient.mockReturnValue(savedObjectsClientMock.create());
|
||||
startContract.createInternalRepository.mockReturnValue(savedObjectsRepositoryMock.create());
|
||||
startContract.createScopedRepository.mockReturnValue(savedObjectsRepositoryMock.create());
|
||||
|
||||
return startContract;
|
||||
};
|
||||
|
||||
const createSetupContractMock = () => {
|
||||
const setupContract: jest.Mocked<InternalSavedObjectsServiceSetup> = {
|
||||
getScopedClient: jest.fn(),
|
||||
setClientFactory: jest.fn(),
|
||||
setClientFactoryProvider: jest.fn(),
|
||||
addClientWrapper: jest.fn(),
|
||||
createInternalRepository: jest.fn(),
|
||||
createScopedRepository: jest.fn(),
|
||||
};
|
||||
|
||||
setupContract.getScopedClient.mockReturnValue(savedObjectsClientMock.create());
|
||||
setupContract.createInternalRepository.mockReturnValue(savedObjectsRepositoryMock.create());
|
||||
setupContract.createScopedRepository.mockReturnValue(savedObjectsRepositoryMock.create());
|
||||
|
||||
return setupContract;
|
||||
};
|
||||
|
||||
const createsavedObjectsServiceMock = () => {
|
||||
const createSavedObjectsServiceMock = () => {
|
||||
const mocked: jest.Mocked<SavedObjectsServiceContract> = {
|
||||
setup: jest.fn(),
|
||||
start: jest.fn(),
|
||||
|
@ -69,7 +67,7 @@ const createsavedObjectsServiceMock = () => {
|
|||
};
|
||||
|
||||
export const savedObjectsServiceMock = {
|
||||
create: createsavedObjectsServiceMock,
|
||||
create: createSavedObjectsServiceMock,
|
||||
createSetupContract: createSetupContractMock,
|
||||
createStartContract: createStartContractMock,
|
||||
};
|
||||
|
|
|
@ -0,0 +1,32 @@
|
|||
/*
|
||||
* 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 { mockKibanaMigrator } from './migrations/kibana/kibana_migrator.mock';
|
||||
import { savedObjectsClientProviderMock } from './service/lib/scoped_client_provider.mock';
|
||||
|
||||
export const migratorInstanceMock = mockKibanaMigrator.create();
|
||||
export const KibanaMigratorMock = jest.fn().mockImplementation(() => migratorInstanceMock);
|
||||
jest.doMock('./migrations/kibana/kibana_migrator', () => ({
|
||||
KibanaMigrator: KibanaMigratorMock,
|
||||
}));
|
||||
|
||||
export const clientProviderInstanceMock = savedObjectsClientProviderMock.create();
|
||||
jest.doMock('./service/lib/scoped_client_provider', () => ({
|
||||
SavedObjectsClientProvider: jest.fn().mockImplementation(() => clientProviderInstanceMock),
|
||||
}));
|
|
@ -17,95 +17,149 @@
|
|||
* under the License.
|
||||
*/
|
||||
|
||||
jest.mock('./migrations/kibana/kibana_migrator');
|
||||
import {
|
||||
KibanaMigratorMock,
|
||||
migratorInstanceMock,
|
||||
clientProviderInstanceMock,
|
||||
} from './saved_objects_service.test.mocks';
|
||||
|
||||
import { SavedObjectsService, SavedObjectsSetupDeps } from './saved_objects_service';
|
||||
import { SavedObjectsService } from './saved_objects_service';
|
||||
import { mockCoreContext } from '../core_context.mock';
|
||||
// @ts-ignore Typescript doesn't know about the jest mock
|
||||
import { KibanaMigrator, mockKibanaMigratorInstance } from './migrations/kibana/kibana_migrator';
|
||||
import * as legacyElasticsearch from 'elasticsearch';
|
||||
import { Env } from '../config';
|
||||
import { configServiceMock } from '../mocks';
|
||||
|
||||
afterEach(() => {
|
||||
jest.clearAllMocks();
|
||||
});
|
||||
import { elasticsearchServiceMock } from '../elasticsearch/elasticsearch_service.mock';
|
||||
import { legacyServiceMock } from '../legacy/legacy_service.mock';
|
||||
import { SavedObjectsClientFactoryProvider } from './service/lib';
|
||||
|
||||
describe('SavedObjectsService', () => {
|
||||
const createSetupDeps = () => {
|
||||
return {
|
||||
elasticsearch: elasticsearchServiceMock.createInternalSetup(),
|
||||
legacyPlugins: legacyServiceMock.createDiscoverPlugins(),
|
||||
};
|
||||
};
|
||||
|
||||
afterEach(() => {
|
||||
jest.clearAllMocks();
|
||||
});
|
||||
|
||||
describe('#setup()', () => {
|
||||
it('creates a KibanaMigrator which retries NoConnections errors from callAsInternalUser', async () => {
|
||||
const coreContext = mockCoreContext.create();
|
||||
let i = 0;
|
||||
const clusterClient = {
|
||||
callAsInternalUser: jest
|
||||
.fn()
|
||||
.mockImplementation(() =>
|
||||
i++ <= 2
|
||||
? Promise.reject(new legacyElasticsearch.errors.NoConnections())
|
||||
: Promise.resolve('success')
|
||||
),
|
||||
};
|
||||
describe('#setClientFactoryProvider', () => {
|
||||
it('registers the factory to the clientProvider', async () => {
|
||||
const coreContext = mockCoreContext.create();
|
||||
const soService = new SavedObjectsService(coreContext);
|
||||
const setup = await soService.setup(createSetupDeps());
|
||||
|
||||
const soService = new SavedObjectsService(coreContext);
|
||||
const coreSetup = ({
|
||||
elasticsearch: { adminClient: clusterClient },
|
||||
legacyPlugins: { uiExports: { savedObjectMappings: [] }, pluginExtendedConfig: {} },
|
||||
} as unknown) as SavedObjectsSetupDeps;
|
||||
const factory = jest.fn();
|
||||
const factoryProvider: SavedObjectsClientFactoryProvider = () => factory;
|
||||
|
||||
await soService.setup(coreSetup, 1);
|
||||
setup.setClientFactoryProvider(factoryProvider);
|
||||
|
||||
return expect((KibanaMigrator as jest.Mock).mock.calls[0][0].callCluster()).resolves.toMatch(
|
||||
'success'
|
||||
);
|
||||
await soService.start({});
|
||||
|
||||
expect(clientProviderInstanceMock.setClientFactory).toHaveBeenCalledWith(factory);
|
||||
});
|
||||
it('throws if a factory is already registered', async () => {
|
||||
const coreContext = mockCoreContext.create();
|
||||
const soService = new SavedObjectsService(coreContext);
|
||||
const setup = await soService.setup(createSetupDeps());
|
||||
|
||||
const firstFactory = () => jest.fn();
|
||||
const secondFactory = () => jest.fn();
|
||||
|
||||
setup.setClientFactoryProvider(firstFactory);
|
||||
|
||||
expect(() => {
|
||||
setup.setClientFactoryProvider(secondFactory);
|
||||
}).toThrowErrorMatchingInlineSnapshot(
|
||||
`"custom client factory is already set, and can only be set once"`
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
describe('#addClientWrapper', () => {
|
||||
it('registers the wrapper to the clientProvider', async () => {
|
||||
const coreContext = mockCoreContext.create();
|
||||
const soService = new SavedObjectsService(coreContext);
|
||||
const setup = await soService.setup(createSetupDeps());
|
||||
|
||||
const wrapperA = jest.fn();
|
||||
const wrapperB = jest.fn();
|
||||
|
||||
setup.addClientWrapper(1, 'A', wrapperA);
|
||||
setup.addClientWrapper(2, 'B', wrapperB);
|
||||
|
||||
await soService.start({});
|
||||
|
||||
expect(clientProviderInstanceMock.addClientWrapperFactory).toHaveBeenCalledTimes(2);
|
||||
expect(clientProviderInstanceMock.addClientWrapperFactory).toHaveBeenCalledWith(
|
||||
1,
|
||||
'A',
|
||||
wrapperA
|
||||
);
|
||||
expect(clientProviderInstanceMock.addClientWrapperFactory).toHaveBeenCalledWith(
|
||||
2,
|
||||
'B',
|
||||
wrapperB
|
||||
);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('#start()', () => {
|
||||
it('creates a KibanaMigrator which retries NoConnections errors from callAsInternalUser', async () => {
|
||||
const coreContext = mockCoreContext.create();
|
||||
|
||||
const soService = new SavedObjectsService(coreContext);
|
||||
const coreSetup = createSetupDeps();
|
||||
|
||||
let i = 0;
|
||||
coreSetup.elasticsearch.adminClient.callAsInternalUser = jest
|
||||
.fn()
|
||||
.mockImplementation(() =>
|
||||
i++ <= 2
|
||||
? Promise.reject(new legacyElasticsearch.errors.NoConnections())
|
||||
: Promise.resolve('success')
|
||||
);
|
||||
|
||||
await soService.setup(coreSetup);
|
||||
await soService.start({}, 1);
|
||||
|
||||
return expect(KibanaMigratorMock.mock.calls[0][0].callCluster()).resolves.toMatch('success');
|
||||
});
|
||||
|
||||
it('skips KibanaMigrator migrations when --optimize=true', async () => {
|
||||
const coreContext = mockCoreContext.create({
|
||||
env: ({ cliArgs: { optimize: true }, packageInfo: { version: 'x.x.x' } } as unknown) as Env,
|
||||
});
|
||||
const soService = new SavedObjectsService(coreContext);
|
||||
const coreSetup = ({
|
||||
elasticsearch: { adminClient: { callAsInternalUser: jest.fn() } },
|
||||
legacyPlugins: { uiExports: {}, pluginExtendedConfig: {} },
|
||||
} as unknown) as SavedObjectsSetupDeps;
|
||||
|
||||
await soService.setup(coreSetup);
|
||||
await soService.setup(createSetupDeps());
|
||||
await soService.start({});
|
||||
expect(mockKibanaMigratorInstance.runMigrations).toHaveBeenCalledWith(true);
|
||||
expect(migratorInstanceMock.runMigrations).toHaveBeenCalledWith(true);
|
||||
});
|
||||
|
||||
it('skips KibanaMigrator migrations when migrations.skip=true', async () => {
|
||||
const configService = configServiceMock.create({ atPath: { skip: true } });
|
||||
const coreContext = mockCoreContext.create({ configService });
|
||||
const soService = new SavedObjectsService(coreContext);
|
||||
const coreSetup = ({
|
||||
elasticsearch: { adminClient: { callAsInternalUser: jest.fn() } },
|
||||
legacyPlugins: { uiExports: {}, pluginExtendedConfig: {} },
|
||||
} as unknown) as SavedObjectsSetupDeps;
|
||||
|
||||
await soService.setup(coreSetup);
|
||||
await soService.setup(createSetupDeps());
|
||||
await soService.start({});
|
||||
expect(mockKibanaMigratorInstance.runMigrations).toHaveBeenCalledWith(true);
|
||||
expect(migratorInstanceMock.runMigrations).toHaveBeenCalledWith(true);
|
||||
});
|
||||
|
||||
it('resolves with KibanaMigrator after waiting for migrations to complete', async () => {
|
||||
const configService = configServiceMock.create({ atPath: { skip: false } });
|
||||
const coreContext = mockCoreContext.create({ configService });
|
||||
const soService = new SavedObjectsService(coreContext);
|
||||
const coreSetup = ({
|
||||
elasticsearch: { adminClient: { callAsInternalUser: jest.fn() } },
|
||||
legacyPlugins: { uiExports: {}, pluginExtendedConfig: {} },
|
||||
} as unknown) as SavedObjectsSetupDeps;
|
||||
|
||||
await soService.setup(coreSetup);
|
||||
expect(mockKibanaMigratorInstance.runMigrations).toHaveBeenCalledTimes(0);
|
||||
await soService.setup(createSetupDeps());
|
||||
expect(migratorInstanceMock.runMigrations).toHaveBeenCalledTimes(0);
|
||||
|
||||
const startContract = await soService.start({});
|
||||
expect(startContract.migrator).toBe(mockKibanaMigratorInstance);
|
||||
expect(mockKibanaMigratorInstance.runMigrations).toHaveBeenCalledWith(false);
|
||||
expect(mockKibanaMigratorInstance.runMigrations).toHaveBeenCalledTimes(1);
|
||||
expect(startContract.migrator).toBe(migratorInstanceMock);
|
||||
expect(migratorInstanceMock.runMigrations).toHaveBeenCalledWith(false);
|
||||
expect(migratorInstanceMock.runMigrations).toHaveBeenCalledTimes(1);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
|
|
@ -37,13 +37,17 @@ import { KibanaRequest } from '../http';
|
|||
import { SavedObjectsClientContract } from './types';
|
||||
import { ISavedObjectsRepository, SavedObjectsRepository } from './service/lib/repository';
|
||||
import {
|
||||
SavedObjectsClientFactory,
|
||||
SavedObjectsClientFactoryProvider,
|
||||
SavedObjectsClientWrapperFactory,
|
||||
} from './service/lib/scoped_client_provider';
|
||||
import { Logger } from '..';
|
||||
import { Logger } from '../logging';
|
||||
import { SavedObjectsMapping } from './mappings';
|
||||
import { MigrationDefinition } from './migrations/core/document_migrator';
|
||||
import { SavedObjectsSchemaDefinition } from './schema';
|
||||
import { PropertyValidators } from './validation';
|
||||
|
||||
/**
|
||||
* Saved Objects is Kibana's data persisentence mechanism allowing plugins to
|
||||
* 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.
|
||||
|
@ -66,11 +70,11 @@ import { Logger } from '..';
|
|||
* constructor.
|
||||
*
|
||||
* @example
|
||||
* import {SavedObjectsClient, CoreSetup} from 'src/core/server';
|
||||
* import { SavedObjectsClient, CoreSetup } from 'src/core/server';
|
||||
*
|
||||
* export class Plugin() {
|
||||
* setup: (core: CoreSetup) => {
|
||||
* core.savedObjects.setClientFactory(({request: KibanaRequest}) => {
|
||||
* core.savedObjects.setClientFactory(({ request: KibanaRequest }) => {
|
||||
* return new SavedObjectsClient(core.savedObjects.scopedRepository(request));
|
||||
* })
|
||||
* }
|
||||
|
@ -80,61 +84,25 @@ import { Logger } from '..';
|
|||
*/
|
||||
export interface SavedObjectsServiceSetup {
|
||||
/**
|
||||
* Set a default factory for creating Saved Objects clients. Only one client
|
||||
* factory can be set, subsequent calls to this method will fail.
|
||||
* Set the default {@link SavedObjectsClientFactoryProvider | factory provider} for creating Saved Objects clients.
|
||||
* Only one provider can be set, subsequent calls to this method will fail.
|
||||
*/
|
||||
setClientFactory: (customClientFactory: SavedObjectsClientFactory<KibanaRequest>) => void;
|
||||
setClientFactoryProvider: (clientFactoryProvider: SavedObjectsClientFactoryProvider) => void;
|
||||
|
||||
/**
|
||||
* Add a client wrapper with the given priority.
|
||||
* Add a {@link SavedObjectsClientWrapperFactory | client wrapper factory} with the given priority.
|
||||
*/
|
||||
addClientWrapper: (
|
||||
priority: number,
|
||||
id: string,
|
||||
factory: SavedObjectsClientWrapperFactory<KibanaRequest>
|
||||
factory: SavedObjectsClientWrapperFactory
|
||||
) => void;
|
||||
|
||||
/**
|
||||
* Creates a {@link ISavedObjectsRepository | Saved Objects repository} that
|
||||
* uses the credentials from the passed in request to authenticate with
|
||||
* Elasticsearch.
|
||||
*
|
||||
* @remarks
|
||||
* The repository should only be used for creating and registering a client
|
||||
* factory or client wrapper. Using the repository directly for interacting
|
||||
* with Saved Objects is an anti-pattern. Use the Saved Objects client from
|
||||
* the
|
||||
* {@link SavedObjectsServiceStart | SavedObjectsServiceStart#getScopedClient }
|
||||
* method or the {@link RequestHandlerContext | route handler context}
|
||||
* instead.
|
||||
*/
|
||||
createScopedRepository: (req: KibanaRequest, extraTypes?: string[]) => ISavedObjectsRepository;
|
||||
|
||||
/**
|
||||
* Creates a {@link ISavedObjectsRepository | Saved Objects repository} that
|
||||
* uses the internal Kibana user for authenticating with Elasticsearch.
|
||||
*
|
||||
* @remarks
|
||||
* The repository should only be used for creating and registering a client
|
||||
* factory or client wrapper. Using the repository directly for interacting
|
||||
* with Saved Objects is an anti-pattern. Use the Saved Objects client from
|
||||
* the
|
||||
* {@link SavedObjectsServiceStart | SavedObjectsServiceStart#getScopedClient }
|
||||
* method or the {@link RequestHandlerContext | route handler context}
|
||||
* instead.
|
||||
*/
|
||||
createInternalRepository: (extraTypes?: string[]) => ISavedObjectsRepository;
|
||||
}
|
||||
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
export interface InternalSavedObjectsServiceSetup extends SavedObjectsServiceSetup {
|
||||
getScopedClient: (
|
||||
req: KibanaRequest,
|
||||
options?: SavedObjectsClientProviderOptions
|
||||
) => SavedObjectsClientContract;
|
||||
}
|
||||
export type InternalSavedObjectsServiceSetup = SavedObjectsServiceSetup;
|
||||
|
||||
/**
|
||||
* Saved Objects is Kibana's data persisentence mechanism allowing plugins to
|
||||
|
@ -158,6 +126,26 @@ export interface SavedObjectsServiceStart {
|
|||
req: KibanaRequest,
|
||||
options?: SavedObjectsClientProviderOptions
|
||||
) => SavedObjectsClientContract;
|
||||
/**
|
||||
* Creates a {@link ISavedObjectsRepository | Saved Objects repository} that
|
||||
* uses the credentials from the passed in request to authenticate with
|
||||
* Elasticsearch.
|
||||
*
|
||||
* @param req - The request to create the scoped repository from.
|
||||
* @param extraTypes - A list of additional hidden types the repository should have access to.
|
||||
*
|
||||
* @remarks
|
||||
* Prefer using `getScopedClient`. This should only be used when using methods
|
||||
* not exposed on {@link SavedObjectsClientContract}
|
||||
*/
|
||||
createScopedRepository: (req: KibanaRequest, extraTypes?: string[]) => ISavedObjectsRepository;
|
||||
/**
|
||||
* Creates a {@link ISavedObjectsRepository | Saved Objects repository} that
|
||||
* uses the internal Kibana user for authenticating with Elasticsearch.
|
||||
*
|
||||
* @param extraTypes - A list of additional hidden types the repository should have access to.
|
||||
*/
|
||||
createInternalRepository: (extraTypes?: string[]) => ISavedObjectsRepository;
|
||||
}
|
||||
|
||||
export interface InternalSavedObjectsServiceStart extends SavedObjectsServiceStart {
|
||||
|
@ -171,109 +159,120 @@ export interface InternalSavedObjectsServiceStart extends SavedObjectsServiceSta
|
|||
clientProvider: ISavedObjectsClientProvider;
|
||||
}
|
||||
|
||||
/**
|
||||
* Factory provided when invoking a {@link SavedObjectsClientFactoryProvider | client factory provider}
|
||||
* See {@link SavedObjectsServiceSetup.setClientFactoryProvider}
|
||||
*
|
||||
* @public
|
||||
*/
|
||||
export interface SavedObjectsRepositoryFactory {
|
||||
/**
|
||||
* Creates a {@link ISavedObjectsRepository | Saved Objects repository} that
|
||||
* uses the credentials from the passed in request to authenticate with
|
||||
* Elasticsearch.
|
||||
*
|
||||
* @param extraTypes - A list of additional hidden types the repository should have access to.
|
||||
*/
|
||||
createScopedRepository: (req: KibanaRequest, extraTypes?: string[]) => ISavedObjectsRepository;
|
||||
/**
|
||||
* Creates a {@link ISavedObjectsRepository | Saved Objects repository} that
|
||||
* uses the internal Kibana user for authenticating with Elasticsearch.
|
||||
*
|
||||
* @param extraTypes - A list of additional hidden types the repository should have access to.
|
||||
*/
|
||||
createInternalRepository: (extraTypes?: string[]) => ISavedObjectsRepository;
|
||||
}
|
||||
|
||||
/** @internal */
|
||||
export interface SavedObjectsSetupDeps {
|
||||
legacyPlugins: LegacyServiceDiscoverPlugins;
|
||||
elasticsearch: InternalElasticsearchServiceSetup;
|
||||
}
|
||||
|
||||
interface WrappedClientFactoryWrapper {
|
||||
priority: number;
|
||||
id: string;
|
||||
factory: SavedObjectsClientWrapperFactory;
|
||||
}
|
||||
|
||||
/** @internal */
|
||||
// eslint-disable-next-line @typescript-eslint/no-empty-interface
|
||||
export interface SavedObjectsStartDeps {}
|
||||
|
||||
export class SavedObjectsService
|
||||
implements CoreService<InternalSavedObjectsServiceSetup, InternalSavedObjectsServiceStart> {
|
||||
private migrator: KibanaMigrator | undefined;
|
||||
private logger: Logger;
|
||||
private clientProvider: ISavedObjectsClientProvider<KibanaRequest> | undefined;
|
||||
|
||||
private setupDeps?: SavedObjectsSetupDeps;
|
||||
private clientFactoryProvider?: SavedObjectsClientFactoryProvider;
|
||||
private clientFactoryWrappers: WrappedClientFactoryWrapper[] = [];
|
||||
|
||||
private mappings: SavedObjectsMapping[] = [];
|
||||
private migrations: MigrationDefinition = {};
|
||||
private schemas: SavedObjectsSchemaDefinition = {};
|
||||
private validations: PropertyValidators = {};
|
||||
|
||||
constructor(private readonly coreContext: CoreContext) {
|
||||
this.logger = coreContext.logger.get('savedobjects-service');
|
||||
}
|
||||
|
||||
public async setup(
|
||||
setupDeps: SavedObjectsSetupDeps,
|
||||
migrationsRetryDelay?: number
|
||||
): Promise<InternalSavedObjectsServiceSetup> {
|
||||
public async setup(setupDeps: SavedObjectsSetupDeps): Promise<InternalSavedObjectsServiceSetup> {
|
||||
this.logger.debug('Setting up SavedObjects service');
|
||||
|
||||
this.setupDeps = setupDeps;
|
||||
|
||||
const {
|
||||
savedObjectSchemas: savedObjectsSchemasDefinition,
|
||||
savedObjectMappings,
|
||||
savedObjectMigrations,
|
||||
savedObjectValidations,
|
||||
} = setupDeps.legacyPlugins.uiExports;
|
||||
|
||||
const savedObjectSchemas = new SavedObjectsSchema(savedObjectsSchemasDefinition);
|
||||
|
||||
const kibanaConfig = await this.coreContext.configService
|
||||
.atPath<KibanaConfigType>('kibana')
|
||||
.pipe(first())
|
||||
.toPromise();
|
||||
|
||||
const savedObjectsConfig = await this.coreContext.configService
|
||||
.atPath<SavedObjectsConfigType>('migrations')
|
||||
.pipe(first())
|
||||
.toPromise();
|
||||
|
||||
const adminClient = setupDeps.elasticsearch.adminClient;
|
||||
|
||||
const migrator = (this.migrator = new KibanaMigrator({
|
||||
savedObjectSchemas,
|
||||
savedObjectMappings,
|
||||
savedObjectMigrations,
|
||||
savedObjectValidations,
|
||||
logger: this.coreContext.logger.get('migrations'),
|
||||
kibanaVersion: this.coreContext.env.packageInfo.version,
|
||||
config: setupDeps.legacyPlugins.pluginExtendedConfig,
|
||||
savedObjectsConfig,
|
||||
kibanaConfig,
|
||||
callCluster: migrationsRetryCallCluster(
|
||||
adminClient.callAsInternalUser,
|
||||
this.coreContext.logger.get('migrations'),
|
||||
migrationsRetryDelay
|
||||
),
|
||||
}));
|
||||
|
||||
const createSORepository = (callCluster: APICaller, extraTypes: string[] = []) => {
|
||||
return SavedObjectsRepository.createRepository(
|
||||
migrator,
|
||||
savedObjectSchemas,
|
||||
setupDeps.legacyPlugins.pluginExtendedConfig,
|
||||
kibanaConfig.index,
|
||||
callCluster,
|
||||
extraTypes
|
||||
);
|
||||
};
|
||||
|
||||
this.clientProvider = new SavedObjectsClientProvider<KibanaRequest>({
|
||||
defaultClientFactory({ request }) {
|
||||
const repository = createSORepository(adminClient.asScoped(request).callAsCurrentUser);
|
||||
return new SavedObjectsClient(repository);
|
||||
},
|
||||
});
|
||||
this.mappings = savedObjectMappings;
|
||||
this.migrations = savedObjectMigrations;
|
||||
this.schemas = savedObjectsSchemasDefinition;
|
||||
this.validations = savedObjectValidations;
|
||||
|
||||
return {
|
||||
getScopedClient: this.clientProvider.getClient.bind(this.clientProvider),
|
||||
setClientFactory: this.clientProvider.setClientFactory.bind(this.clientProvider),
|
||||
addClientWrapper: this.clientProvider.addClientWrapperFactory.bind(this.clientProvider),
|
||||
createInternalRepository: (extraTypes?: string[]) =>
|
||||
createSORepository(adminClient.callAsInternalUser, extraTypes),
|
||||
createScopedRepository: (req: KibanaRequest, extraTypes?: string[]) =>
|
||||
createSORepository(adminClient.asScoped(req).callAsCurrentUser, extraTypes),
|
||||
setClientFactoryProvider: provider => {
|
||||
if (this.clientFactoryProvider) {
|
||||
throw new Error('custom client factory is already set, and can only be set once');
|
||||
}
|
||||
this.clientFactoryProvider = provider;
|
||||
},
|
||||
addClientWrapper: (priority, id, factory) => {
|
||||
this.clientFactoryWrappers.push({
|
||||
priority,
|
||||
id,
|
||||
factory,
|
||||
});
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
public async start(core: SavedObjectsStartDeps): Promise<InternalSavedObjectsServiceStart> {
|
||||
if (!this.clientProvider) {
|
||||
public async start(
|
||||
core: SavedObjectsStartDeps,
|
||||
migrationsRetryDelay?: number
|
||||
): Promise<InternalSavedObjectsServiceStart> {
|
||||
if (!this.setupDeps) {
|
||||
throw new Error('#setup() needs to be run first');
|
||||
}
|
||||
|
||||
this.logger.debug('Starting SavedObjects service');
|
||||
|
||||
const kibanaConfig = await this.coreContext.configService
|
||||
.atPath<KibanaConfigType>('kibana')
|
||||
.pipe(first())
|
||||
.toPromise();
|
||||
const savedObjectsConfig = await this.coreContext.configService
|
||||
.atPath<SavedObjectsConfigType>('migrations')
|
||||
.pipe(first())
|
||||
.toPromise();
|
||||
const adminClient = this.setupDeps!.elasticsearch.adminClient;
|
||||
const migrator = this.createMigrator(kibanaConfig, savedObjectsConfig, migrationsRetryDelay);
|
||||
|
||||
/**
|
||||
* Note: We want to ensure that migrations have completed before
|
||||
* continuing with further Core startup steps that might use SavedObjects
|
||||
* continuing with further Core start steps that might use SavedObjects
|
||||
* such as running the legacy server, legacy plugins and allowing incoming
|
||||
* HTTP requests.
|
||||
*
|
||||
|
@ -282,19 +281,78 @@ export class SavedObjectsService
|
|||
* So, when the `migrations.skip` is true, we skip migrations altogether.
|
||||
*/
|
||||
const cliArgs = this.coreContext.env.cliArgs;
|
||||
const savedObjectsConfig = await this.coreContext.configService
|
||||
.atPath<SavedObjectsConfigType>('migrations')
|
||||
.pipe(first())
|
||||
.toPromise();
|
||||
const skipMigrations = cliArgs.optimize || savedObjectsConfig.skip;
|
||||
await this.migrator!.runMigrations(skipMigrations);
|
||||
|
||||
this.logger.debug('Starting saved objects migration');
|
||||
await migrator.runMigrations(skipMigrations);
|
||||
this.logger.debug('Saved objects migration completed');
|
||||
|
||||
const createRepository = (callCluster: APICaller, extraTypes: string[] = []) => {
|
||||
return SavedObjectsRepository.createRepository(
|
||||
migrator,
|
||||
new SavedObjectsSchema(this.schemas),
|
||||
this.setupDeps!.legacyPlugins.pluginExtendedConfig,
|
||||
kibanaConfig.index,
|
||||
callCluster,
|
||||
extraTypes
|
||||
);
|
||||
};
|
||||
|
||||
const repositoryFactory: SavedObjectsRepositoryFactory = {
|
||||
createInternalRepository: (extraTypes?: string[]) =>
|
||||
createRepository(adminClient.callAsInternalUser, extraTypes),
|
||||
createScopedRepository: (req: KibanaRequest, extraTypes?: string[]) =>
|
||||
createRepository(adminClient.asScoped(req).callAsCurrentUser, extraTypes),
|
||||
};
|
||||
|
||||
const clientProvider = new SavedObjectsClientProvider({
|
||||
defaultClientFactory({ request }) {
|
||||
const repository = repositoryFactory.createScopedRepository(request);
|
||||
return new SavedObjectsClient(repository);
|
||||
},
|
||||
});
|
||||
if (this.clientFactoryProvider) {
|
||||
const clientFactory = this.clientFactoryProvider(repositoryFactory);
|
||||
clientProvider.setClientFactory(clientFactory);
|
||||
}
|
||||
this.clientFactoryWrappers.forEach(({ id, factory, priority }) => {
|
||||
clientProvider.addClientWrapperFactory(priority, id, factory);
|
||||
});
|
||||
|
||||
return {
|
||||
migrator: this.migrator!,
|
||||
clientProvider: this.clientProvider,
|
||||
getScopedClient: this.clientProvider.getClient.bind(this.clientProvider),
|
||||
migrator,
|
||||
clientProvider,
|
||||
getScopedClient: clientProvider.getClient.bind(clientProvider),
|
||||
createScopedRepository: repositoryFactory.createScopedRepository,
|
||||
createInternalRepository: repositoryFactory.createInternalRepository,
|
||||
};
|
||||
}
|
||||
|
||||
public async stop() {}
|
||||
|
||||
private createMigrator(
|
||||
kibanaConfig: KibanaConfigType,
|
||||
savedObjectsConfig: SavedObjectsConfigType,
|
||||
migrationsRetryDelay?: number
|
||||
): KibanaMigrator {
|
||||
const savedObjectSchemas = new SavedObjectsSchema(this.schemas);
|
||||
const adminClient = this.setupDeps!.elasticsearch.adminClient;
|
||||
|
||||
return new KibanaMigrator({
|
||||
savedObjectSchemas,
|
||||
savedObjectMappings: this.mappings,
|
||||
savedObjectMigrations: this.migrations,
|
||||
savedObjectValidations: this.validations,
|
||||
logger: this.coreContext.logger.get('migrations'),
|
||||
kibanaVersion: this.coreContext.env.packageInfo.version,
|
||||
config: this.setupDeps!.legacyPlugins.pluginExtendedConfig,
|
||||
savedObjectsConfig,
|
||||
kibanaConfig,
|
||||
callCluster: migrationsRetryCallCluster(
|
||||
adminClient.callAsInternalUser,
|
||||
this.coreContext.logger.get('migrations'),
|
||||
migrationsRetryDelay
|
||||
),
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
|
@ -29,13 +29,11 @@ import { SavedObjectsResolveImportErrorsOptions } from '../import/types';
|
|||
* @internal
|
||||
* @deprecated
|
||||
*/
|
||||
export interface SavedObjectsLegacyService<Request = any> {
|
||||
export interface SavedObjectsLegacyService {
|
||||
// ATTENTION: these types are incomplete
|
||||
addScopedSavedObjectsClientWrapperFactory: SavedObjectsClientProvider<
|
||||
Request
|
||||
>['addClientWrapperFactory'];
|
||||
setScopedSavedObjectsClientFactory: SavedObjectsClientProvider<Request>['setClientFactory'];
|
||||
getScopedSavedObjectsClient: SavedObjectsClientProvider<Request>['getClient'];
|
||||
addScopedSavedObjectsClientWrapperFactory: SavedObjectsClientProvider['addClientWrapperFactory'];
|
||||
setScopedSavedObjectsClientFactory: SavedObjectsClientProvider['setClientFactory'];
|
||||
getScopedSavedObjectsClient: SavedObjectsClientProvider['getClient'];
|
||||
SavedObjectsClient: typeof SavedObjectsClient;
|
||||
types: string[];
|
||||
schema: SavedObjectsSchema;
|
||||
|
@ -59,6 +57,7 @@ export {
|
|||
SavedObjectsClientWrapperOptions,
|
||||
SavedObjectsErrorHelpers,
|
||||
SavedObjectsClientFactory,
|
||||
SavedObjectsClientFactoryProvider,
|
||||
} from './lib';
|
||||
|
||||
export * from './saved_objects_client';
|
||||
|
|
|
@ -26,6 +26,7 @@ export {
|
|||
SavedObjectsClientProvider,
|
||||
SavedObjectsClientProviderOptions,
|
||||
SavedObjectsClientFactory,
|
||||
SavedObjectsClientFactoryProvider,
|
||||
} from './scoped_client_provider';
|
||||
|
||||
export { SavedObjectsErrorHelpers } from './errors';
|
||||
|
|
|
@ -18,34 +18,44 @@
|
|||
*/
|
||||
import { PriorityCollection } from './priority_collection';
|
||||
import { SavedObjectsClientContract } from '../../types';
|
||||
import { SavedObjectsRepositoryFactory } from '../../saved_objects_service';
|
||||
import { KibanaRequest } from '../../../http';
|
||||
|
||||
/**
|
||||
* Options passed to each SavedObjectsClientWrapperFactory to aid in creating the wrapper instance.
|
||||
* @public
|
||||
*/
|
||||
export interface SavedObjectsClientWrapperOptions<Request = unknown> {
|
||||
export interface SavedObjectsClientWrapperOptions {
|
||||
client: SavedObjectsClientContract;
|
||||
request: Request;
|
||||
request: KibanaRequest;
|
||||
}
|
||||
|
||||
/**
|
||||
* Describes the factory used to create instances of Saved Objects Client Wrappers.
|
||||
* @public
|
||||
*/
|
||||
export type SavedObjectsClientWrapperFactory<Request = unknown> = (
|
||||
options: SavedObjectsClientWrapperOptions<Request>
|
||||
export type SavedObjectsClientWrapperFactory = (
|
||||
options: SavedObjectsClientWrapperOptions
|
||||
) => SavedObjectsClientContract;
|
||||
|
||||
/**
|
||||
* Describes the factory used to create instances of the Saved Objects Client.
|
||||
* @public
|
||||
*/
|
||||
export type SavedObjectsClientFactory<Request = unknown> = ({
|
||||
export type SavedObjectsClientFactory = ({
|
||||
request,
|
||||
}: {
|
||||
request: Request;
|
||||
request: KibanaRequest;
|
||||
}) => SavedObjectsClientContract;
|
||||
|
||||
/**
|
||||
* Provider to invoke to retrieve a {@link SavedObjectsClientFactory}.
|
||||
* @public
|
||||
*/
|
||||
export type SavedObjectsClientFactoryProvider = (
|
||||
repositoryFactory: SavedObjectsRepositoryFactory
|
||||
) => SavedObjectsClientFactory;
|
||||
|
||||
/**
|
||||
* Options to control the creation of the Saved Objects Client.
|
||||
* @public
|
||||
|
@ -57,8 +67,8 @@ export interface SavedObjectsClientProviderOptions {
|
|||
/**
|
||||
* @internal
|
||||
*/
|
||||
export type ISavedObjectsClientProvider<T = unknown> = Pick<
|
||||
SavedObjectsClientProvider<T>,
|
||||
export type ISavedObjectsClientProvider = Pick<
|
||||
SavedObjectsClientProvider,
|
||||
keyof SavedObjectsClientProvider
|
||||
>;
|
||||
|
||||
|
@ -67,26 +77,22 @@ export type ISavedObjectsClientProvider<T = unknown> = Pick<
|
|||
*
|
||||
* @internal
|
||||
*/
|
||||
export class SavedObjectsClientProvider<Request = unknown> {
|
||||
export class SavedObjectsClientProvider {
|
||||
private readonly _wrapperFactories = new PriorityCollection<{
|
||||
id: string;
|
||||
factory: SavedObjectsClientWrapperFactory<Request>;
|
||||
factory: SavedObjectsClientWrapperFactory;
|
||||
}>();
|
||||
private _clientFactory: SavedObjectsClientFactory<Request>;
|
||||
private readonly _originalClientFactory: SavedObjectsClientFactory<Request>;
|
||||
private _clientFactory: SavedObjectsClientFactory;
|
||||
private readonly _originalClientFactory: SavedObjectsClientFactory;
|
||||
|
||||
constructor({
|
||||
defaultClientFactory,
|
||||
}: {
|
||||
defaultClientFactory: SavedObjectsClientFactory<Request>;
|
||||
}) {
|
||||
constructor({ defaultClientFactory }: { defaultClientFactory: SavedObjectsClientFactory }) {
|
||||
this._originalClientFactory = this._clientFactory = defaultClientFactory;
|
||||
}
|
||||
|
||||
addClientWrapperFactory(
|
||||
priority: number,
|
||||
id: string,
|
||||
factory: SavedObjectsClientWrapperFactory<Request>
|
||||
factory: SavedObjectsClientWrapperFactory
|
||||
): void {
|
||||
if (this._wrapperFactories.has(entry => entry.id === id)) {
|
||||
throw new Error(`wrapper factory with id ${id} is already defined`);
|
||||
|
@ -95,7 +101,7 @@ export class SavedObjectsClientProvider<Request = unknown> {
|
|||
this._wrapperFactories.add(priority, { id, factory });
|
||||
}
|
||||
|
||||
setClientFactory(customClientFactory: SavedObjectsClientFactory<Request>) {
|
||||
setClientFactory(customClientFactory: SavedObjectsClientFactory) {
|
||||
if (this._clientFactory !== this._originalClientFactory) {
|
||||
throw new Error(`custom client factory is already set, unable to replace the current one`);
|
||||
}
|
||||
|
@ -104,7 +110,7 @@ export class SavedObjectsClientProvider<Request = unknown> {
|
|||
}
|
||||
|
||||
getClient(
|
||||
request: Request,
|
||||
request: KibanaRequest,
|
||||
options: SavedObjectsClientProviderOptions = {}
|
||||
): SavedObjectsClientContract {
|
||||
const client = this._clientFactory({
|
||||
|
|
|
@ -1498,10 +1498,13 @@ export class SavedObjectsClient {
|
|||
export type SavedObjectsClientContract = Pick<SavedObjectsClient, keyof SavedObjectsClient>;
|
||||
|
||||
// @public
|
||||
export type SavedObjectsClientFactory<Request = unknown> = ({ request, }: {
|
||||
request: Request;
|
||||
export type SavedObjectsClientFactory = ({ request, }: {
|
||||
request: KibanaRequest;
|
||||
}) => SavedObjectsClientContract;
|
||||
|
||||
// @public
|
||||
export type SavedObjectsClientFactoryProvider = (repositoryFactory: SavedObjectsRepositoryFactory) => SavedObjectsClientFactory;
|
||||
|
||||
// @public
|
||||
export interface SavedObjectsClientProviderOptions {
|
||||
// (undocumented)
|
||||
|
@ -1509,14 +1512,14 @@ export interface SavedObjectsClientProviderOptions {
|
|||
}
|
||||
|
||||
// @public
|
||||
export type SavedObjectsClientWrapperFactory<Request = unknown> = (options: SavedObjectsClientWrapperOptions<Request>) => SavedObjectsClientContract;
|
||||
export type SavedObjectsClientWrapperFactory = (options: SavedObjectsClientWrapperOptions) => SavedObjectsClientContract;
|
||||
|
||||
// @public
|
||||
export interface SavedObjectsClientWrapperOptions<Request = unknown> {
|
||||
export interface SavedObjectsClientWrapperOptions {
|
||||
// (undocumented)
|
||||
client: SavedObjectsClientContract;
|
||||
// (undocumented)
|
||||
request: Request;
|
||||
request: KibanaRequest;
|
||||
}
|
||||
|
||||
// @public (undocumented)
|
||||
|
@ -1752,15 +1755,15 @@ export interface SavedObjectsIncrementCounterOptions extends SavedObjectsBaseOpt
|
|||
}
|
||||
|
||||
// @internal @deprecated (undocumented)
|
||||
export interface SavedObjectsLegacyService<Request = any> {
|
||||
export interface SavedObjectsLegacyService {
|
||||
// Warning: (ae-forgotten-export) The symbol "SavedObjectsClientProvider" needs to be exported by the entry point index.d.ts
|
||||
//
|
||||
// (undocumented)
|
||||
addScopedSavedObjectsClientWrapperFactory: SavedObjectsClientProvider<Request>['addClientWrapperFactory'];
|
||||
addScopedSavedObjectsClientWrapperFactory: SavedObjectsClientProvider['addClientWrapperFactory'];
|
||||
// (undocumented)
|
||||
getSavedObjectsRepository(...rest: any[]): any;
|
||||
// (undocumented)
|
||||
getScopedSavedObjectsClient: SavedObjectsClientProvider<Request>['getClient'];
|
||||
getScopedSavedObjectsClient: SavedObjectsClientProvider['getClient'];
|
||||
// (undocumented)
|
||||
importExport: {
|
||||
objectLimit: number;
|
||||
|
@ -1773,7 +1776,7 @@ export interface SavedObjectsLegacyService<Request = any> {
|
|||
// (undocumented)
|
||||
schema: SavedObjectsSchema;
|
||||
// (undocumented)
|
||||
setScopedSavedObjectsClientFactory: SavedObjectsClientProvider<Request>['setClientFactory'];
|
||||
setScopedSavedObjectsClientFactory: SavedObjectsClientProvider['setClientFactory'];
|
||||
// (undocumented)
|
||||
types: string[];
|
||||
}
|
||||
|
@ -1836,6 +1839,12 @@ export class SavedObjectsRepository {
|
|||
update<T extends SavedObjectAttributes = any>(type: string, id: string, attributes: Partial<T>, options?: SavedObjectsUpdateOptions): Promise<SavedObjectsUpdateResponse<T>>;
|
||||
}
|
||||
|
||||
// @public
|
||||
export interface SavedObjectsRepositoryFactory {
|
||||
createInternalRepository: (extraTypes?: string[]) => ISavedObjectsRepository;
|
||||
createScopedRepository: (req: KibanaRequest, extraTypes?: string[]) => ISavedObjectsRepository;
|
||||
}
|
||||
|
||||
// @public
|
||||
export interface SavedObjectsResolveImportErrorsOptions {
|
||||
// (undocumented)
|
||||
|
@ -1878,14 +1887,14 @@ export class SavedObjectsSerializer {
|
|||
|
||||
// @public
|
||||
export interface SavedObjectsServiceSetup {
|
||||
addClientWrapper: (priority: number, id: string, factory: SavedObjectsClientWrapperFactory<KibanaRequest>) => void;
|
||||
createInternalRepository: (extraTypes?: string[]) => ISavedObjectsRepository;
|
||||
createScopedRepository: (req: KibanaRequest, extraTypes?: string[]) => ISavedObjectsRepository;
|
||||
setClientFactory: (customClientFactory: SavedObjectsClientFactory<KibanaRequest>) => void;
|
||||
addClientWrapper: (priority: number, id: string, factory: SavedObjectsClientWrapperFactory) => void;
|
||||
setClientFactoryProvider: (clientFactoryProvider: SavedObjectsClientFactoryProvider) => void;
|
||||
}
|
||||
|
||||
// @public
|
||||
export interface SavedObjectsServiceStart {
|
||||
createInternalRepository: (extraTypes?: string[]) => ISavedObjectsRepository;
|
||||
createScopedRepository: (req: KibanaRequest, extraTypes?: string[]) => ISavedObjectsRepository;
|
||||
getScopedClient: (req: KibanaRequest, options?: SavedObjectsClientProviderOptions) => SavedObjectsClientContract;
|
||||
}
|
||||
|
||||
|
|
|
@ -47,7 +47,7 @@ import { config as uiSettingsConfig } from './ui_settings';
|
|||
import { mapToObject } from '../utils';
|
||||
import { ContextService } from './context';
|
||||
import { RequestHandlerContext } from '.';
|
||||
import { InternalCoreSetup } from './internal_types';
|
||||
import { InternalCoreSetup, InternalCoreStart } from './internal_types';
|
||||
import { CapabilitiesService } from './capabilities';
|
||||
import { UuidService } from './uuid';
|
||||
|
||||
|
@ -68,6 +68,8 @@ export class Server {
|
|||
private readonly uiSettings: UiSettingsService;
|
||||
private readonly uuid: UuidService;
|
||||
|
||||
private coreStart?: InternalCoreStart;
|
||||
|
||||
constructor(
|
||||
rawConfigProvider: RawConfigurationProvider,
|
||||
public readonly env: Env,
|
||||
|
@ -174,21 +176,24 @@ export class Server {
|
|||
uiSettings: uiSettingsStart,
|
||||
});
|
||||
|
||||
const coreStart = {
|
||||
this.coreStart = {
|
||||
capabilities: capabilitiesStart,
|
||||
savedObjects: savedObjectsStart,
|
||||
uiSettings: uiSettingsStart,
|
||||
plugins: pluginsStart,
|
||||
};
|
||||
|
||||
await this.legacy.start({
|
||||
core: coreStart,
|
||||
core: {
|
||||
...this.coreStart,
|
||||
plugins: pluginsStart,
|
||||
},
|
||||
plugins: mapToObject(pluginsStart.contracts),
|
||||
});
|
||||
|
||||
await this.http.start();
|
||||
await this.rendering.start();
|
||||
|
||||
return coreStart;
|
||||
return this.coreStart;
|
||||
}
|
||||
|
||||
public async stop() {
|
||||
|
@ -215,7 +220,7 @@ export class Server {
|
|||
coreId,
|
||||
'core',
|
||||
async (context, req, res): Promise<RequestHandlerContext['core']> => {
|
||||
const savedObjectsClient = coreSetup.savedObjects.getScopedClient(req);
|
||||
const savedObjectsClient = this.coreStart!.savedObjects.getScopedClient(req);
|
||||
const uiSettingsClient = coreSetup.uiSettings.asScopedToClient(savedObjectsClient);
|
||||
|
||||
return {
|
||||
|
|
|
@ -27,6 +27,7 @@ import {
|
|||
} from '../../../../../test_utils/kbn_server';
|
||||
import { createOrUpgradeSavedConfig } from '../create_or_upgrade_saved_config';
|
||||
import { loggingServiceMock } from '../../../logging/logging_service.mock';
|
||||
import { httpServerMock } from '../../../http/http_server.mocks';
|
||||
|
||||
const logger = loggingServiceMock.create().get();
|
||||
describe('createOrUpgradeSavedConfig()', () => {
|
||||
|
@ -48,7 +49,9 @@ describe('createOrUpgradeSavedConfig()', () => {
|
|||
kbnServer = kbn.kbnServer;
|
||||
|
||||
const savedObjects = kbnServer.server.savedObjects;
|
||||
savedObjectsClient = savedObjects.getScopedSavedObjectsClient({});
|
||||
savedObjectsClient = savedObjects.getScopedSavedObjectsClient(
|
||||
httpServerMock.createKibanaRequest()
|
||||
);
|
||||
|
||||
await savedObjectsClient.bulkCreate([
|
||||
{
|
||||
|
|
|
@ -26,6 +26,7 @@ import {
|
|||
TestUtils,
|
||||
} from '../../../../../test_utils/kbn_server';
|
||||
import { APICaller } from '../../../elasticsearch/';
|
||||
import { httpServerMock } from '../../../http/http_server.mocks';
|
||||
|
||||
let servers: TestUtils;
|
||||
let esServer: TestElasticsearchUtils;
|
||||
|
@ -83,7 +84,9 @@ export function getServices() {
|
|||
const callCluster = esServer.es.getCallCluster();
|
||||
|
||||
const savedObjects = kbnServer.server.savedObjects;
|
||||
const savedObjectsClient = savedObjects.getScopedSavedObjectsClient({});
|
||||
const savedObjectsClient = savedObjects.getScopedSavedObjectsClient(
|
||||
httpServerMock.createKibanaRequest()
|
||||
);
|
||||
|
||||
const uiSettings = kbnServer.server.uiSettingsServiceFactory({
|
||||
savedObjectsClient,
|
||||
|
|
|
@ -32,7 +32,7 @@ export async function getTranslationCount(loader: any, locale: string): Promise<
|
|||
|
||||
export function createCollectorFetch(server: Server) {
|
||||
return async function fetchUsageStats(): Promise<UsageStats> {
|
||||
const internalRepo = server.newPlatform.setup.core.savedObjects.createInternalRepository();
|
||||
const internalRepo = server.newPlatform.start.core.savedObjects.createInternalRepository();
|
||||
const uiSettingsClient = server.newPlatform.start.core.uiSettings.asScopedToClient(
|
||||
new SavedObjectsClient(internalRepo)
|
||||
);
|
||||
|
|
|
@ -27,12 +27,12 @@ export class KqlTelemetryService implements Plugin<void> {
|
|||
constructor(private initializerContext: PluginInitializerContext) {}
|
||||
|
||||
public setup(
|
||||
{ http, savedObjects }: CoreSetup,
|
||||
{ http, getStartServices }: CoreSetup,
|
||||
{ usageCollection }: { usageCollection?: UsageCollectionSetup }
|
||||
) {
|
||||
registerKqlTelemetryRoute(
|
||||
http.createRouter(),
|
||||
savedObjects,
|
||||
getStartServices,
|
||||
this.initializerContext.logger.get('data', 'kql-telemetry')
|
||||
);
|
||||
|
||||
|
|
|
@ -22,7 +22,7 @@ import { schema } from '@kbn/config-schema';
|
|||
|
||||
export function registerKqlTelemetryRoute(
|
||||
router: IRouter,
|
||||
savedObjects: CoreSetup['savedObjects'],
|
||||
getStartServices: CoreSetup['getStartServices'],
|
||||
logger: Logger
|
||||
) {
|
||||
router.post(
|
||||
|
@ -35,6 +35,7 @@ export function registerKqlTelemetryRoute(
|
|||
},
|
||||
},
|
||||
async (context, request, response) => {
|
||||
const [{ savedObjects }] = await getStartServices();
|
||||
const internalRepository = savedObjects.createScopedRepository(request);
|
||||
|
||||
const {
|
||||
|
|
|
@ -51,7 +51,7 @@ export class SampleDataRegistry {
|
|||
makeSampleDataUsageCollector(usageCollections, this.initContext);
|
||||
}
|
||||
const usageTracker = usage(
|
||||
core.savedObjects,
|
||||
core.getStartServices().then(([coreStart]) => coreStart.savedObjects),
|
||||
this.initContext.logger.get('sample_data', 'telemetry')
|
||||
);
|
||||
const router = core.http.createRouter();
|
||||
|
|
|
@ -17,7 +17,7 @@
|
|||
* under the License.
|
||||
*/
|
||||
|
||||
import { Logger, SavedObjectsServiceSetup } from 'kibana/server';
|
||||
import { Logger, SavedObjectsServiceStart } from 'kibana/server';
|
||||
|
||||
const SAVED_OBJECT_ID = 'sample-data-telemetry';
|
||||
|
||||
|
@ -27,7 +27,7 @@ export interface SampleDataUsageTracker {
|
|||
}
|
||||
|
||||
export function usage(
|
||||
savedObjects: SavedObjectsServiceSetup,
|
||||
savedObjects: Promise<SavedObjectsServiceStart>,
|
||||
logger: Logger
|
||||
): SampleDataUsageTracker {
|
||||
const handleIncrementError = (err: Error) => {
|
||||
|
@ -37,11 +37,12 @@ export function usage(
|
|||
logger.warn(`saved objects repository incrementCounter encountered an error: ${err}`);
|
||||
};
|
||||
|
||||
const internalRepository = savedObjects.createInternalRepository();
|
||||
const internalRepositoryPromise = savedObjects.then(so => so.createInternalRepository());
|
||||
|
||||
return {
|
||||
addInstall: async (dataSet: string) => {
|
||||
try {
|
||||
const internalRepository = await internalRepositoryPromise;
|
||||
await internalRepository.incrementCounter(SAVED_OBJECT_ID, dataSet, `installCount`);
|
||||
} catch (err) {
|
||||
handleIncrementError(err);
|
||||
|
@ -49,6 +50,7 @@ export function usage(
|
|||
},
|
||||
addUninstall: async (dataSet: string) => {
|
||||
try {
|
||||
const internalRepository = await internalRepositoryPromise;
|
||||
await internalRepository.incrementCounter(SAVED_OBJECT_ID, dataSet, `unInstallCount`);
|
||||
} catch (err) {
|
||||
handleIncrementError(err);
|
||||
|
|
|
@ -64,11 +64,14 @@ export class ValidationTelemetryService implements Plugin<ValidationTelemetrySer
|
|||
})
|
||||
);
|
||||
}
|
||||
const internalRepository = core.savedObjects.createInternalRepository();
|
||||
const internalRepositoryPromise = core
|
||||
.getStartServices()
|
||||
.then(([start]) => start.savedObjects.createInternalRepository());
|
||||
|
||||
return {
|
||||
logFailedValidation: async () => {
|
||||
try {
|
||||
const internalRepository = await internalRepositoryPromise;
|
||||
await internalRepository.incrementCounter(
|
||||
'tsvb-validation-telemetry',
|
||||
'tsvb-validation-telemetry',
|
||||
|
|
|
@ -128,11 +128,12 @@ export class Plugin {
|
|||
|
||||
this.taskRunnerFactory.initialize({
|
||||
logger: this.logger,
|
||||
getServices(request: Hapi.Request): Services {
|
||||
getServices(rawRequest: Hapi.Request): Services {
|
||||
const request = KibanaRequest.from(rawRequest);
|
||||
return {
|
||||
callCluster: (...args) =>
|
||||
adminClient!.asScoped(KibanaRequest.from(request)).callAsCurrentUser(...args),
|
||||
savedObjectsClient: core.savedObjects.getScopedSavedObjectsClient(request),
|
||||
callCluster: (...args) => adminClient!.asScoped(request).callAsCurrentUser(...args),
|
||||
// rawRequest is actually a fake request, converting it to KibanaRequest causes issue in SO access
|
||||
savedObjectsClient: core.savedObjects.getScopedSavedObjectsClient(rawRequest as any),
|
||||
};
|
||||
},
|
||||
spaceIdToNamespace,
|
||||
|
|
|
@ -5,6 +5,8 @@
|
|||
*/
|
||||
|
||||
import { i18n } from '@kbn/i18n';
|
||||
// eslint-disable-next-line @kbn/eslint/no-restricted-paths
|
||||
import { KibanaRequest } from '../../../../../../../src/core/server';
|
||||
import {
|
||||
ExecuteJobFactory,
|
||||
ESQueueWorkerExecuteFn,
|
||||
|
@ -82,7 +84,9 @@ export const executeJobFactory: ExecuteJobFactory<ESQueueWorkerExecuteFn<
|
|||
return callWithRequest(fakeRequest, endpoint, clientParams, options);
|
||||
};
|
||||
const savedObjects = server.savedObjects;
|
||||
const savedObjectsClient = savedObjects.getScopedSavedObjectsClient(fakeRequest);
|
||||
const savedObjectsClient = savedObjects.getScopedSavedObjectsClient(
|
||||
(fakeRequest as unknown) as KibanaRequest
|
||||
);
|
||||
const uiConfig = server.uiSettingsServiceFactory({
|
||||
savedObjectsClient,
|
||||
});
|
||||
|
|
|
@ -4,6 +4,8 @@
|
|||
* you may not use this file except in compliance with the Elastic License.
|
||||
*/
|
||||
|
||||
// eslint-disable-next-line @kbn/eslint/no-restricted-paths
|
||||
import { KibanaRequest } from '../../../../../../../../src/core/server';
|
||||
import { createGenerateCsv } from '../../../csv/server/lib/generate_csv';
|
||||
import { CancellationToken } from '../../../../common/cancellation_token';
|
||||
import { ServerFacade, RequestFacade, Logger } from '../../../../types';
|
||||
|
@ -61,7 +63,9 @@ export async function generateCsvSearch(
|
|||
jobParams: JobParamsDiscoverCsv
|
||||
): Promise<CsvResultFromSearch> {
|
||||
const { savedObjects, uiSettingsServiceFactory } = server;
|
||||
const savedObjectsClient = savedObjects.getScopedSavedObjectsClient(req.getRawRequest());
|
||||
const savedObjectsClient = savedObjects.getScopedSavedObjectsClient(
|
||||
KibanaRequest.from(req.getRawRequest())
|
||||
);
|
||||
const { indexPatternSavedObjectId, timerange } = searchPanel;
|
||||
const savedSearchObjectAttr = searchPanel.attributes as SavedSearchObjectAttributes;
|
||||
const { indexPatternSavedObject } = await getDataSource(
|
||||
|
|
|
@ -48,7 +48,7 @@ export interface UptimeCoreSetup {
|
|||
}
|
||||
|
||||
export interface UptimeCorePlugins {
|
||||
savedObjects: SavedObjectsLegacyService<any>;
|
||||
savedObjects: SavedObjectsLegacyService;
|
||||
usageCollection: UsageCollectionSetup;
|
||||
xpack: any;
|
||||
}
|
||||
|
|
|
@ -71,7 +71,11 @@ export class Plugin {
|
|||
)
|
||||
);
|
||||
|
||||
this.savedObjectsSetup = setupSavedObjects({ service, savedObjects: core.savedObjects });
|
||||
this.savedObjectsSetup = setupSavedObjects({
|
||||
service,
|
||||
savedObjects: core.savedObjects,
|
||||
getStartServices: core.getStartServices,
|
||||
});
|
||||
|
||||
return {
|
||||
registerType: (typeRegistration: EncryptedSavedObjectTypeRegistration) =>
|
||||
|
|
|
@ -16,6 +16,7 @@ import { EncryptedSavedObjectsClientWrapper } from './encrypted_saved_objects_cl
|
|||
interface SetupSavedObjectsParams {
|
||||
service: PublicMethodsOf<EncryptedSavedObjectsService>;
|
||||
savedObjects: CoreSetup['savedObjects'];
|
||||
getStartServices: CoreSetup['getStartServices'];
|
||||
}
|
||||
|
||||
export interface SavedObjectsSetup {
|
||||
|
@ -29,6 +30,7 @@ export interface SavedObjectsSetup {
|
|||
export function setupSavedObjects({
|
||||
service,
|
||||
savedObjects,
|
||||
getStartServices,
|
||||
}: SetupSavedObjectsParams): SavedObjectsSetup {
|
||||
// Register custom saved object client that will encrypt, decrypt and strip saved object
|
||||
// attributes where appropriate for any saved object repository request. We choose max possible
|
||||
|
@ -41,13 +43,16 @@ export function setupSavedObjects({
|
|||
({ client: baseClient }) => new EncryptedSavedObjectsClientWrapper({ baseClient, service })
|
||||
);
|
||||
|
||||
const internalRepository = savedObjects.createInternalRepository();
|
||||
const internalRepositoryPromise = getStartServices().then(([core]) =>
|
||||
core.savedObjects.createInternalRepository()
|
||||
);
|
||||
return {
|
||||
getDecryptedAsInternalUser: async <T extends SavedObjectAttributes = any>(
|
||||
type: string,
|
||||
id: string,
|
||||
options?: SavedObjectsBaseOptions
|
||||
): Promise<SavedObject<T>> => {
|
||||
const internalRepository = await internalRepositoryPromise;
|
||||
const savedObject = await internalRepository.get(type, id, options);
|
||||
return {
|
||||
...savedObject,
|
||||
|
|
|
@ -24,12 +24,12 @@ export function setupSavedObjects({ auditLogger, authz, savedObjects }: SetupSav
|
|||
const getKibanaRequest = (request: KibanaRequest | LegacyRequest) =>
|
||||
request instanceof KibanaRequest ? request : KibanaRequest.from(request);
|
||||
|
||||
savedObjects.setClientFactory(({ request }) => {
|
||||
savedObjects.setClientFactoryProvider(repositoryFactory => ({ request }) => {
|
||||
const kibanaRequest = getKibanaRequest(request);
|
||||
return new SavedObjectsClient(
|
||||
authz.mode.useRbacForRequest(kibanaRequest)
|
||||
? savedObjects.createInternalRepository()
|
||||
: savedObjects.createScopedRepository(kibanaRequest)
|
||||
? repositoryFactory.createInternalRepository()
|
||||
: repositoryFactory.createScopedRepository(kibanaRequest)
|
||||
);
|
||||
});
|
||||
|
||||
|
|
|
@ -38,12 +38,13 @@ export class TaskManagerPlugin
|
|||
public setup(core: CoreSetup, plugins: any): TaskManagerSetupContract {
|
||||
const logger = this.initContext.logger.get('taskManager');
|
||||
const config$ = this.initContext.config.create<TaskManagerConfig>();
|
||||
const savedObjectsRepository = core.savedObjects.createInternalRepository(['task']);
|
||||
const elasticsearch = core.elasticsearch.adminClient;
|
||||
return {
|
||||
config$,
|
||||
registerLegacyAPI: once((__LEGACY: PluginLegacyDependencies) => {
|
||||
config$.subscribe(async config => {
|
||||
const [{ savedObjects }] = await core.getStartServices();
|
||||
const savedObjectsRepository = savedObjects.createInternalRepository(['task']);
|
||||
this.legacyTaskManager$.next(
|
||||
createTaskManager(core, {
|
||||
logger,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue