Skip to content

Commit

Permalink
[Core] Move Saved objects files to core (#38771)
Browse files Browse the repository at this point in the history
* Move src/legacy/server/saved_objects -> src/core/server/saved_objects

* Fix SavedObject import references after moving files to core

* First pass at SavedObjects api docs

* Expose and import all saved object types through core/server

* Don't expose SavedObjectsManagement from core and fix imports

* Improve typings for SavedObject error helpers

* Fix type errors after master merge

* Fix SavedObjectErrorHelpers tests
  • Loading branch information
rudolf authored Jun 18, 2019
1 parent 9d82f65 commit 260d907
Show file tree
Hide file tree
Showing 251 changed files with 2,412 additions and 644 deletions.
16 changes: 16 additions & 0 deletions docs/development/core/server/kibana-plugin-server.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ The plugin integrates with the core system via lifecycle events: `setup`<!-- -->
| [ClusterClient](./kibana-plugin-server.clusterclient.md) | Represents an Elasticsearch cluster API client and 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>). |
| [KibanaRequest](./kibana-plugin-server.kibanarequest.md) | Kibana specific abstraction for an incoming request. |
| [Router](./kibana-plugin-server.router.md) | |
| [SavedObjectsErrorHelpers](./kibana-plugin-server.savedobjectserrorhelpers.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 |

## Interfaces
Expand Down Expand Up @@ -45,6 +46,20 @@ The plugin integrates with the core system via lifecycle events: `setup`<!-- -->
| [PluginsServiceSetup](./kibana-plugin-server.pluginsservicesetup.md) | |
| [PluginsServiceStart](./kibana-plugin-server.pluginsservicestart.md) | |
| [RouteConfigOptions](./kibana-plugin-server.routeconfigoptions.md) | Route specific configuration. |
| [SavedObject](./kibana-plugin-server.savedobject.md) | |
| [SavedObjectAttributes](./kibana-plugin-server.savedobjectattributes.md) | |
| [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) | |
| [SavedObjectsCreateOptions](./kibana-plugin-server.savedobjectscreateoptions.md) | |
| [SavedObjectsFindOptions](./kibana-plugin-server.savedobjectsfindoptions.md) | |
| [SavedObjectsFindResponse](./kibana-plugin-server.savedobjectsfindresponse.md) | |
| [SavedObjectsMigrationVersion](./kibana-plugin-server.savedobjectsmigrationversion.md) | A dictionary of saved object type -<!-- -->&gt; version used to determine what migrations need to be applied to a saved object. |
| [SavedObjectsService](./kibana-plugin-server.savedobjectsservice.md) | |
| [SavedObjectsUpdateOptions](./kibana-plugin-server.savedobjectsupdateoptions.md) | |
| [SavedObjectsUpdateResponse](./kibana-plugin-server.savedobjectsupdateresponse.md) | |
| [SessionStorage](./kibana-plugin-server.sessionstorage.md) | Provides an interface to store and retrieve data across requests. |
| [SessionStorageFactory](./kibana-plugin-server.sessionstoragefactory.md) | SessionStorage factory to bind one to an incoming request |

Expand All @@ -65,4 +80,5 @@ The plugin integrates with the core system via lifecycle events: `setup`<!-- -->
| [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. |
| [RecursiveReadonly](./kibana-plugin-server.recursivereadonly.md) | |
| [RouteMethod](./kibana-plugin-server.routemethod.md) | The set of common HTTP methods supported by Kibana routing. |
| [SavedObjectsClientContract](./kibana-plugin-server.savedobjectsclientcontract.md) | \#\# 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 [SavedObjectsErrorHelpers](./kibana-plugin-server.savedobjectserrorhelpers.md) |

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

[Home](./index.md) &gt; [kibana-plugin-server](./kibana-plugin-server.md) &gt; [SavedObject](./kibana-plugin-server.savedobject.md) &gt; [attributes](./kibana-plugin-server.savedobject.attributes.md)

## SavedObject.attributes property

<b>Signature:</b>

```typescript
attributes: T;
```
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<!-- Do not edit this file. It is automatically generated by API Documenter. -->

[Home](./index.md) &gt; [kibana-plugin-server](./kibana-plugin-server.md) &gt; [SavedObject](./kibana-plugin-server.savedobject.md) &gt; [error](./kibana-plugin-server.savedobject.error.md)

## SavedObject.error property

<b>Signature:</b>

```typescript
error?: {
message: string;
statusCode: number;
};
```
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<!-- Do not edit this file. It is automatically generated by API Documenter. -->

[Home](./index.md) &gt; [kibana-plugin-server](./kibana-plugin-server.md) &gt; [SavedObject](./kibana-plugin-server.savedobject.md) &gt; [id](./kibana-plugin-server.savedobject.id.md)

## SavedObject.id property

<b>Signature:</b>

```typescript
id: string;
```
26 changes: 26 additions & 0 deletions docs/development/core/server/kibana-plugin-server.savedobject.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<!-- Do not edit this file. It is automatically generated by API Documenter. -->

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

## SavedObject interface


<b>Signature:</b>

```typescript
export interface SavedObject<T extends SavedObjectAttributes = any>
```

## Properties

| Property | Type | Description |
| --- | --- | --- |
| [attributes](./kibana-plugin-server.savedobject.attributes.md) | <code>T</code> | |
| [error](./kibana-plugin-server.savedobject.error.md) | <code>{</code><br/><code> message: string;</code><br/><code> statusCode: number;</code><br/><code> }</code> | |
| [id](./kibana-plugin-server.savedobject.id.md) | <code>string</code> | |
| [migrationVersion](./kibana-plugin-server.savedobject.migrationversion.md) | <code>SavedObjectsMigrationVersion</code> | |
| [references](./kibana-plugin-server.savedobject.references.md) | <code>SavedObjectReference[]</code> | |
| [type](./kibana-plugin-server.savedobject.type.md) | <code>string</code> | |
| [updated\_at](./kibana-plugin-server.savedobject.updated_at.md) | <code>string</code> | |
| [version](./kibana-plugin-server.savedobject.version.md) | <code>string</code> | |

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

[Home](./index.md) &gt; [kibana-plugin-server](./kibana-plugin-server.md) &gt; [SavedObject](./kibana-plugin-server.savedobject.md) &gt; [migrationVersion](./kibana-plugin-server.savedobject.migrationversion.md)

## SavedObject.migrationVersion property

<b>Signature:</b>

```typescript
migrationVersion?: SavedObjectsMigrationVersion;
```
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<!-- Do not edit this file. It is automatically generated by API Documenter. -->

[Home](./index.md) &gt; [kibana-plugin-server](./kibana-plugin-server.md) &gt; [SavedObject](./kibana-plugin-server.savedobject.md) &gt; [references](./kibana-plugin-server.savedobject.references.md)

## SavedObject.references property

<b>Signature:</b>

```typescript
references: SavedObjectReference[];
```
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<!-- Do not edit this file. It is automatically generated by API Documenter. -->

[Home](./index.md) &gt; [kibana-plugin-server](./kibana-plugin-server.md) &gt; [SavedObject](./kibana-plugin-server.savedobject.md) &gt; [type](./kibana-plugin-server.savedobject.type.md)

## SavedObject.type property

<b>Signature:</b>

```typescript
type: string;
```
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<!-- Do not edit this file. It is automatically generated by API Documenter. -->

[Home](./index.md) &gt; [kibana-plugin-server](./kibana-plugin-server.md) &gt; [SavedObject](./kibana-plugin-server.savedobject.md) &gt; [updated\_at](./kibana-plugin-server.savedobject.updated_at.md)

## SavedObject.updated\_at property

<b>Signature:</b>

```typescript
updated_at?: string;
```
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<!-- Do not edit this file. It is automatically generated by API Documenter. -->

[Home](./index.md) &gt; [kibana-plugin-server](./kibana-plugin-server.md) &gt; [SavedObject](./kibana-plugin-server.savedobject.md) &gt; [version](./kibana-plugin-server.savedobject.version.md)

## SavedObject.version property

<b>Signature:</b>

```typescript
version?: string;
```
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<!-- Do not edit this file. It is automatically generated by API Documenter. -->

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

## SavedObjectAttributes interface


<b>Signature:</b>

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

[Home](./index.md) &gt; [kibana-plugin-server](./kibana-plugin-server.md) &gt; [SavedObjectReference](./kibana-plugin-server.savedobjectreference.md) &gt; [id](./kibana-plugin-server.savedobjectreference.id.md)

## SavedObjectReference.id property

<b>Signature:</b>

```typescript
id: string;
```
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<!-- Do not edit this file. It is automatically generated by API Documenter. -->

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

## SavedObjectReference interface

A reference to another saved object.

<b>Signature:</b>

```typescript
export interface SavedObjectReference
```

## Properties

| Property | Type | Description |
| --- | --- | --- |
| [id](./kibana-plugin-server.savedobjectreference.id.md) | <code>string</code> | |
| [name](./kibana-plugin-server.savedobjectreference.name.md) | <code>string</code> | |
| [type](./kibana-plugin-server.savedobjectreference.type.md) | <code>string</code> | |

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

[Home](./index.md) &gt; [kibana-plugin-server](./kibana-plugin-server.md) &gt; [SavedObjectReference](./kibana-plugin-server.savedobjectreference.md) &gt; [name](./kibana-plugin-server.savedobjectreference.name.md)

## SavedObjectReference.name property

<b>Signature:</b>

```typescript
name: string;
```
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<!-- Do not edit this file. It is automatically generated by API Documenter. -->

[Home](./index.md) &gt; [kibana-plugin-server](./kibana-plugin-server.md) &gt; [SavedObjectReference](./kibana-plugin-server.savedobjectreference.md) &gt; [type](./kibana-plugin-server.savedobjectreference.type.md)

## SavedObjectReference.type property

<b>Signature:</b>

```typescript
type: string;
```
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<!-- Do not edit this file. It is automatically generated by API Documenter. -->

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

## SavedObjectsBaseOptions interface


<b>Signature:</b>

```typescript
export interface SavedObjectsBaseOptions
```

## Properties

| Property | Type | Description |
| --- | --- | --- |
| [namespace](./kibana-plugin-server.savedobjectsbaseoptions.namespace.md) | <code>string</code> | Specify the namespace for this operation |

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

[Home](./index.md) &gt; [kibana-plugin-server](./kibana-plugin-server.md) &gt; [SavedObjectsBaseOptions](./kibana-plugin-server.savedobjectsbaseoptions.md) &gt; [namespace](./kibana-plugin-server.savedobjectsbaseoptions.namespace.md)

## SavedObjectsBaseOptions.namespace property

Specify the namespace for this operation

<b>Signature:</b>

```typescript
namespace?: string;
```
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<!-- Do not edit this file. It is automatically generated by API Documenter. -->

[Home](./index.md) &gt; [kibana-plugin-server](./kibana-plugin-server.md) &gt; [SavedObjectsBulkCreateObject](./kibana-plugin-server.savedobjectsbulkcreateobject.md) &gt; [attributes](./kibana-plugin-server.savedobjectsbulkcreateobject.attributes.md)

## SavedObjectsBulkCreateObject.attributes property

<b>Signature:</b>

```typescript
attributes: T;
```
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<!-- Do not edit this file. It is automatically generated by API Documenter. -->

[Home](./index.md) &gt; [kibana-plugin-server](./kibana-plugin-server.md) &gt; [SavedObjectsBulkCreateObject](./kibana-plugin-server.savedobjectsbulkcreateobject.md) &gt; [id](./kibana-plugin-server.savedobjectsbulkcreateobject.id.md)

## SavedObjectsBulkCreateObject.id property

<b>Signature:</b>

```typescript
id?: string;
```
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<!-- Do not edit this file. It is automatically generated by API Documenter. -->

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

## SavedObjectsBulkCreateObject interface


<b>Signature:</b>

```typescript
export interface SavedObjectsBulkCreateObject<T extends SavedObjectAttributes = any>
```

## Properties

| Property | Type | Description |
| --- | --- | --- |
| [attributes](./kibana-plugin-server.savedobjectsbulkcreateobject.attributes.md) | <code>T</code> | |
| [id](./kibana-plugin-server.savedobjectsbulkcreateobject.id.md) | <code>string</code> | |
| [migrationVersion](./kibana-plugin-server.savedobjectsbulkcreateobject.migrationversion.md) | <code>SavedObjectsMigrationVersion</code> | |
| [references](./kibana-plugin-server.savedobjectsbulkcreateobject.references.md) | <code>SavedObjectReference[]</code> | |
| [type](./kibana-plugin-server.savedobjectsbulkcreateobject.type.md) | <code>string</code> | |

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

[Home](./index.md) &gt; [kibana-plugin-server](./kibana-plugin-server.md) &gt; [SavedObjectsBulkCreateObject](./kibana-plugin-server.savedobjectsbulkcreateobject.md) &gt; [migrationVersion](./kibana-plugin-server.savedobjectsbulkcreateobject.migrationversion.md)

## SavedObjectsBulkCreateObject.migrationVersion property

<b>Signature:</b>

```typescript
migrationVersion?: SavedObjectsMigrationVersion;
```
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<!-- Do not edit this file. It is automatically generated by API Documenter. -->

[Home](./index.md) &gt; [kibana-plugin-server](./kibana-plugin-server.md) &gt; [SavedObjectsBulkCreateObject](./kibana-plugin-server.savedobjectsbulkcreateobject.md) &gt; [references](./kibana-plugin-server.savedobjectsbulkcreateobject.references.md)

## SavedObjectsBulkCreateObject.references property

<b>Signature:</b>

```typescript
references?: SavedObjectReference[];
```
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<!-- Do not edit this file. It is automatically generated by API Documenter. -->

[Home](./index.md) &gt; [kibana-plugin-server](./kibana-plugin-server.md) &gt; [SavedObjectsBulkCreateObject](./kibana-plugin-server.savedobjectsbulkcreateobject.md) &gt; [type](./kibana-plugin-server.savedobjectsbulkcreateobject.type.md)

## SavedObjectsBulkCreateObject.type property

<b>Signature:</b>

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

[Home](./index.md) &gt; [kibana-plugin-server](./kibana-plugin-server.md) &gt; [SavedObjectsBulkGetObject](./kibana-plugin-server.savedobjectsbulkgetobject.md) &gt; [fields](./kibana-plugin-server.savedobjectsbulkgetobject.fields.md)

## SavedObjectsBulkGetObject.fields property

SavedObject fields to include in the response

<b>Signature:</b>

```typescript
fields?: string[];
```
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<!-- Do not edit this file. It is automatically generated by API Documenter. -->

[Home](./index.md) &gt; [kibana-plugin-server](./kibana-plugin-server.md) &gt; [SavedObjectsBulkGetObject](./kibana-plugin-server.savedobjectsbulkgetobject.md) &gt; [id](./kibana-plugin-server.savedobjectsbulkgetobject.id.md)

## SavedObjectsBulkGetObject.id property

<b>Signature:</b>

```typescript
id: string;
```
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<!-- Do not edit this file. It is automatically generated by API Documenter. -->

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

## SavedObjectsBulkGetObject interface


<b>Signature:</b>

```typescript
export interface SavedObjectsBulkGetObject
```

## Properties

| Property | Type | Description |
| --- | --- | --- |
| [fields](./kibana-plugin-server.savedobjectsbulkgetobject.fields.md) | <code>string[]</code> | SavedObject fields to include in the response |
| [id](./kibana-plugin-server.savedobjectsbulkgetobject.id.md) | <code>string</code> | |
| [type](./kibana-plugin-server.savedobjectsbulkgetobject.type.md) | <code>string</code> | |

Loading

0 comments on commit 260d907

Please sign in to comment.