Skip to content

Commit

Permalink
Ignore missing references on saved object exports (#47685)
Browse files Browse the repository at this point in the history
* add saved object export details in ndjson response

Signed-off-by: pgayvallet <[email protected]>

* update core doc

Signed-off-by: pgayvallet <[email protected]>

* exclude export details for space copy

Signed-off-by: pgayvallet <[email protected]>

* fixing tests

Signed-off-by: pgayvallet <[email protected]>

* display warning instead of success if export contains missing refs

Signed-off-by: pgayvallet <[email protected]>

* nits/typo

Signed-off-by: pgayvallet <[email protected]>

* properly updates api integration tests

Signed-off-by: pgayvallet <[email protected]>

* fix typings

Signed-off-by: pgayvallet <[email protected]>

* add test on objects_table component

Signed-off-by: pgayvallet <[email protected]>

* remove added translations from jp/cn bundles

Signed-off-by: pgayvallet <[email protected]>

* restoring line feeds

Signed-off-by: pgayvallet <[email protected]>

* improve doc and user alert message

Signed-off-by: pgayvallet <[email protected]>

* restoring line feeds on server.api.md

Signed-off-by: pgayvallet <[email protected]>

* warning test label

Signed-off-by: pgayvallet <[email protected]>
  • Loading branch information
pgayvallet authored and rudolf committed Oct 16, 2019
1 parent b8647ae commit 7df981f
Show file tree
Hide file tree
Showing 34 changed files with 1,085 additions and 456 deletions.
48 changes: 47 additions & 1 deletion docs/api/saved-objects/export.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,29 @@ experimental[] Retrieve a set of saved objects that you want to import into {kib
`includeReferencesDeep`::
(Optional, boolean) Includes all of the referenced objects in the exported objects.

`excludeExportDetails`::
(Optional, boolean) Do not add export details entry at the end of the stream.

TIP: You must include `type` or `objects` in the request body.

[[saved-objects-api-export-request-response-body]]
==== Response body

The format of the response body includes newline delimited JSON.
The format of the response body is newline delimited JSON. Each exported object is exported as a valid JSON record and separated by the newline character '\n'.

When `excludeExportDetails=false` (the default) we append an export result details record at the end of the file after all the saved object records. The export result details object has the following format:

[source,json]
--------------------------------------------------
{
"exportedCount": 27,
"missingRefCount": 2,
"missingReferences": [
{ "id": "an-id", "type": "visualisation"},
{ "id": "another-id", "type": "index-pattern"}
]
}
--------------------------------------------------

[[export-objects-api-create-request-codes]]
==== Response code
Expand All @@ -50,6 +67,18 @@ POST api/saved_objects/_export
--------------------------------------------------
// KIBANA

Export all index pattern saved objects and exclude the export summary from the stream:

[source,js]
--------------------------------------------------
POST api/saved_objects/_export
{
"type": "index-pattern",
"excludeExportDetails": true
}
--------------------------------------------------
// KIBANA

Export a specific saved object:

[source,js]
Expand All @@ -65,3 +94,20 @@ POST api/saved_objects/_export
}
--------------------------------------------------
// KIBANA

Export a specific saved object and it's related objects :

[source,js]
--------------------------------------------------
POST api/saved_objects/_export
{
"objects": [
{
"type": "dashboard",
"id": "be3733a0-9efe-11e7-acb3-3dab96693fab"
}
],
"includeReferencesDeep": true
}
--------------------------------------------------
// KIBANA
1 change: 1 addition & 0 deletions docs/development/core/server/kibana-plugin-server.md
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@ The plugin integrates with the core system via lifecycle events: `setup`<!-- -->
| [SavedObjectsClientWrapperOptions](./kibana-plugin-server.savedobjectsclientwrapperoptions.md) | Options passed to each SavedObjectsClientWrapperFactory to aid in creating the wrapper instance. |
| [SavedObjectsCreateOptions](./kibana-plugin-server.savedobjectscreateoptions.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. |
Expand Down
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; [SavedObjectsExportOptions](./kibana-plugin-server.savedobjectsexportoptions.md) &gt; [excludeExportDetails](./kibana-plugin-server.savedobjectsexportoptions.excludeexportdetails.md)

## SavedObjectsExportOptions.excludeExportDetails property

flag to not append [export details](./kibana-plugin-server.savedobjectsexportresultdetails.md) to the end of the export stream.

<b>Signature:</b>

```typescript
excludeExportDetails?: boolean;
```
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

## SavedObjectsExportOptions.includeReferencesDeep property

flag to also include all related saved objects in the export response.
flag to also include all related saved objects in the export stream.

<b>Signature:</b>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,9 @@ export interface SavedObjectsExportOptions

| Property | Type | Description |
| --- | --- | --- |
| [excludeExportDetails](./kibana-plugin-server.savedobjectsexportoptions.excludeexportdetails.md) | <code>boolean</code> | flag to not append [export details](./kibana-plugin-server.savedobjectsexportresultdetails.md) to the end of the export stream. |
| [exportSizeLimit](./kibana-plugin-server.savedobjectsexportoptions.exportsizelimit.md) | <code>number</code> | the maximum number of objects to export. |
| [includeReferencesDeep](./kibana-plugin-server.savedobjectsexportoptions.includereferencesdeep.md) | <code>boolean</code> | flag to also include all related saved objects in the export response. |
| [includeReferencesDeep](./kibana-plugin-server.savedobjectsexportoptions.includereferencesdeep.md) | <code>boolean</code> | flag to also include all related saved objects in the export stream. |
| [namespace](./kibana-plugin-server.savedobjectsexportoptions.namespace.md) | <code>string</code> | optional namespace to override the namespace used by the savedObjectsClient. |
| [objects](./kibana-plugin-server.savedobjectsexportoptions.objects.md) | <code>Array&lt;{</code><br/><code> id: string;</code><br/><code> type: string;</code><br/><code> }&gt;</code> | optional array of objects to export. |
| [savedObjectsClient](./kibana-plugin-server.savedobjectsexportoptions.savedobjectsclient.md) | <code>SavedObjectsClientContract</code> | an instance of the SavedObjectsClient. |
Expand Down
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; [SavedObjectsExportResultDetails](./kibana-plugin-server.savedobjectsexportresultdetails.md) &gt; [exportedCount](./kibana-plugin-server.savedobjectsexportresultdetails.exportedcount.md)

## SavedObjectsExportResultDetails.exportedCount property

number of successfully exported objects

<b>Signature:</b>

```typescript
exportedCount: number;
```
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; [SavedObjectsExportResultDetails](./kibana-plugin-server.savedobjectsexportresultdetails.md)

## SavedObjectsExportResultDetails interface

Structure of the export result details entry

<b>Signature:</b>

```typescript
export interface SavedObjectsExportResultDetails
```

## Properties

| Property | Type | Description |
| --- | --- | --- |
| [exportedCount](./kibana-plugin-server.savedobjectsexportresultdetails.exportedcount.md) | <code>number</code> | number of successfully exported objects |
| [missingRefCount](./kibana-plugin-server.savedobjectsexportresultdetails.missingrefcount.md) | <code>number</code> | number of missing references |
| [missingReferences](./kibana-plugin-server.savedobjectsexportresultdetails.missingreferences.md) | <code>Array&lt;{</code><br/><code> id: string;</code><br/><code> type: string;</code><br/><code> }&gt;</code> | missing references details |

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; [SavedObjectsExportResultDetails](./kibana-plugin-server.savedobjectsexportresultdetails.md) &gt; [missingRefCount](./kibana-plugin-server.savedobjectsexportresultdetails.missingrefcount.md)

## SavedObjectsExportResultDetails.missingRefCount property

number of missing references

<b>Signature:</b>

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

[Home](./index.md) &gt; [kibana-plugin-server](./kibana-plugin-server.md) &gt; [SavedObjectsExportResultDetails](./kibana-plugin-server.savedobjectsexportresultdetails.md) &gt; [missingReferences](./kibana-plugin-server.savedobjectsexportresultdetails.missingreferences.md)

## SavedObjectsExportResultDetails.missingReferences property

missing references details

<b>Signature:</b>

```typescript
missingReferences: Array<{
id: string;
type: string;
}>;
```
1 change: 1 addition & 0 deletions src/core/server/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,7 @@ export {
SavedObjectsCreateOptions,
SavedObjectsErrorHelpers,
SavedObjectsExportOptions,
SavedObjectsExportResultDetails,
SavedObjectsFindResponse,
SavedObjectsImportConflictError,
SavedObjectsImportError,
Expand Down
Loading

0 comments on commit 7df981f

Please sign in to comment.