Skip to content

Commit

Permalink
expose static method for so import / export
Browse files Browse the repository at this point in the history
  • Loading branch information
pgayvallet committed Feb 28, 2020
1 parent 5a7e2fb commit 73ff556
Show file tree
Hide file tree
Showing 27 changed files with 173 additions and 25 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<!-- Do not edit this file. It is automatically generated by API Documenter. -->

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

## getSortedObjectsForExport() function

Generates sorted saved object stream to be used for export. See the [options](./kibana-plugin-server.savedobjectsexportoptions.md) for more detailed information.

<b>Signature:</b>

```typescript
export declare function getSortedObjectsForExport({ types, objects, search, savedObjectsClient, exportSizeLimit, includeReferencesDeep, excludeExportDetails, namespace, }: SavedObjectsExportOptions): Promise<import("stream").Readable>;
```

## Parameters

| Parameter | Type | Description |
| --- | --- | --- |
| { types, objects, search, savedObjectsClient, exportSizeLimit, includeReferencesDeep, excludeExportDetails, namespace, } | <code>SavedObjectsExportOptions</code> | |

<b>Returns:</b>

`Promise<import("stream").Readable>`

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

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

## importSavedObjects() function

Import saved objects from given stream. See the [options](./kibana-plugin-server.savedobjectsimportoptions.md) for more detailed information.

<b>Signature:</b>

```typescript
export declare function importSavedObjects({ readStream, objectLimit, overwrite, savedObjectsClient, supportedTypes, namespace, }: SavedObjectsImportOptions): Promise<SavedObjectsImportResponse>;
```

## Parameters

| Parameter | Type | Description |
| --- | --- | --- |
| { readStream, objectLimit, overwrite, savedObjectsClient, supportedTypes, namespace, } | <code>SavedObjectsImportOptions</code> | |

<b>Returns:</b>

`Promise<SavedObjectsImportResponse>`

8 changes: 8 additions & 0 deletions docs/development/core/server/kibana-plugin-server.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,14 @@ The plugin integrates with the core system via lifecycle events: `setup`<!-- -->
| [AuthResultType](./kibana-plugin-server.authresulttype.md) | |
| [AuthStatus](./kibana-plugin-server.authstatus.md) | Status indicating an outcome of the authentication. |

## Functions

| Function | Description |
| --- | --- |
| [getSortedObjectsForExport({ types, objects, search, savedObjectsClient, exportSizeLimit, includeReferencesDeep, excludeExportDetails, namespace, })](./kibana-plugin-server.getsortedobjectsforexport.md) | Generates sorted saved object stream to be used for export. See the [options](./kibana-plugin-server.savedobjectsexportoptions.md) for more detailed information. |
| [importSavedObjects({ readStream, objectLimit, overwrite, savedObjectsClient, supportedTypes, namespace, })](./kibana-plugin-server.importsavedobjects.md) | Import saved objects from given stream. See the [options](./kibana-plugin-server.savedobjectsimportoptions.md) for more detailed information. |
| [resolveImportErrors({ readStream, objectLimit, retries, savedObjectsClient, supportedTypes, namespace, })](./kibana-plugin-server.resolveimporterrors.md) | Resolve and return saved object import errors. See the [options](./kibana-plugin-server.savedobjectsresolveimporterrorsoptions.md) for more detailed informations. |

## Interfaces

| Interface | Description |
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<!-- Do not edit this file. It is automatically generated by API Documenter. -->

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

## resolveImportErrors() function

Resolve and return saved object import errors. See the [options](./kibana-plugin-server.savedobjectsresolveimporterrorsoptions.md) for more detailed informations.

<b>Signature:</b>

```typescript
export declare function resolveImportErrors({ readStream, objectLimit, retries, savedObjectsClient, supportedTypes, namespace, }: SavedObjectsResolveImportErrorsOptions): Promise<SavedObjectsImportResponse>;
```

## Parameters

| Parameter | Type | Description |
| --- | --- | --- |
| { readStream, objectLimit, retries, savedObjectsClient, supportedTypes, namespace, } | <code>SavedObjectsResolveImportErrorsOptions</code> | |

<b>Returns:</b>

`Promise<SavedObjectsImportResponse>`

Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@ export interface SavedObjectsImportOptions

| Property | Type | Description |
| --- | --- | --- |
| [namespace](./kibana-plugin-server.savedobjectsimportoptions.namespace.md) | <code>string</code> | |
| [objectLimit](./kibana-plugin-server.savedobjectsimportoptions.objectlimit.md) | <code>number</code> | |
| [overwrite](./kibana-plugin-server.savedobjectsimportoptions.overwrite.md) | <code>boolean</code> | |
| [readStream](./kibana-plugin-server.savedobjectsimportoptions.readstream.md) | <code>Readable</code> | |
| [savedObjectsClient](./kibana-plugin-server.savedobjectsimportoptions.savedobjectsclient.md) | <code>SavedObjectsClientContract</code> | |
| [supportedTypes](./kibana-plugin-server.savedobjectsimportoptions.supportedtypes.md) | <code>string[]</code> | |
| [namespace](./kibana-plugin-server.savedobjectsimportoptions.namespace.md) | <code>string</code> | if specified, will import in given namespace |
| [objectLimit](./kibana-plugin-server.savedobjectsimportoptions.objectlimit.md) | <code>number</code> | The maximum number of object to import |
| [overwrite](./kibana-plugin-server.savedobjectsimportoptions.overwrite.md) | <code>boolean</code> | if true, will override existing object if present |
| [readStream](./kibana-plugin-server.savedobjectsimportoptions.readstream.md) | <code>Readable</code> | The stream of [saved objects](./kibana-plugin-server.savedobject.md) to import |
| [savedObjectsClient](./kibana-plugin-server.savedobjectsimportoptions.savedobjectsclient.md) | <code>SavedObjectsClientContract</code> | client to use to perform the import operation |
| [supportedTypes](./kibana-plugin-server.savedobjectsimportoptions.supportedtypes.md) | <code>string[]</code> | the list of allowed types to import |

Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@

## SavedObjectsImportOptions.namespace property

if specified, will import in given namespace

<b>Signature:</b>

```typescript
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@

## SavedObjectsImportOptions.objectLimit property

The maximum number of object to import

<b>Signature:</b>

```typescript
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@

## SavedObjectsImportOptions.overwrite property

if true, will override existing object if present

<b>Signature:</b>

```typescript
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@

## SavedObjectsImportOptions.readStream property

The stream of [saved objects](./kibana-plugin-server.savedobject.md) to import

<b>Signature:</b>

```typescript
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@

## SavedObjectsImportOptions.savedObjectsClient property

client to use to perform the import operation

<b>Signature:</b>

```typescript
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@

## SavedObjectsImportOptions.supportedTypes property

the list of allowed types to import

<b>Signature:</b>

```typescript
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@ export interface SavedObjectsResolveImportErrorsOptions

| Property | Type | Description |
| --- | --- | --- |
| [namespace](./kibana-plugin-server.savedobjectsresolveimporterrorsoptions.namespace.md) | <code>string</code> | |
| [objectLimit](./kibana-plugin-server.savedobjectsresolveimporterrorsoptions.objectlimit.md) | <code>number</code> | |
| [readStream](./kibana-plugin-server.savedobjectsresolveimporterrorsoptions.readstream.md) | <code>Readable</code> | |
| [retries](./kibana-plugin-server.savedobjectsresolveimporterrorsoptions.retries.md) | <code>SavedObjectsImportRetry[]</code> | |
| [savedObjectsClient](./kibana-plugin-server.savedobjectsresolveimporterrorsoptions.savedobjectsclient.md) | <code>SavedObjectsClientContract</code> | |
| [supportedTypes](./kibana-plugin-server.savedobjectsresolveimporterrorsoptions.supportedtypes.md) | <code>string[]</code> | |
| [namespace](./kibana-plugin-server.savedobjectsresolveimporterrorsoptions.namespace.md) | <code>string</code> | if specified, will import in given namespace |
| [objectLimit](./kibana-plugin-server.savedobjectsresolveimporterrorsoptions.objectlimit.md) | <code>number</code> | The maximum number of object to import |
| [readStream](./kibana-plugin-server.savedobjectsresolveimporterrorsoptions.readstream.md) | <code>Readable</code> | The stream of [saved objects](./kibana-plugin-server.savedobject.md) to resolve errors from |
| [retries](./kibana-plugin-server.savedobjectsresolveimporterrorsoptions.retries.md) | <code>SavedObjectsImportRetry[]</code> | saved object import references to retry |
| [savedObjectsClient](./kibana-plugin-server.savedobjectsresolveimporterrorsoptions.savedobjectsclient.md) | <code>SavedObjectsClientContract</code> | client to use to perform the import operation |
| [supportedTypes](./kibana-plugin-server.savedobjectsresolveimporterrorsoptions.supportedtypes.md) | <code>string[]</code> | the list of allowed types to import |

Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@

## SavedObjectsResolveImportErrorsOptions.namespace property

if specified, will import in given namespace

<b>Signature:</b>

```typescript
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@

## SavedObjectsResolveImportErrorsOptions.objectLimit property

The maximum number of object to import

<b>Signature:</b>

```typescript
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@

## SavedObjectsResolveImportErrorsOptions.readStream property

The stream of [saved objects](./kibana-plugin-server.savedobject.md) to resolve errors from

<b>Signature:</b>

```typescript
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@

## SavedObjectsResolveImportErrorsOptions.retries property

saved object import references to retry

<b>Signature:</b>

```typescript
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@

## SavedObjectsResolveImportErrorsOptions.savedObjectsClient property

client to use to perform the import operation

<b>Signature:</b>

```typescript
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@

## SavedObjectsResolveImportErrorsOptions.supportedTypes property

the list of allowed types to import

<b>Signature:</b>

```typescript
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; [SavedObjectsServiceSetup](./kibana-plugin-server.savedobjectsservicesetup.md) &gt; [getImportExportObjectLimit](./kibana-plugin-server.savedobjectsservicesetup.getimportexportobjectlimit.md)

## SavedObjectsServiceSetup.getImportExportObjectLimit property

Returns the maximum number of objects allowed for import or export operations.

<b>Signature:</b>

```typescript
getImportExportObjectLimit: () => number;
```
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ export class Plugin() {
| Property | Type | Description |
| --- | --- | --- |
| [addClientWrapper](./kibana-plugin-server.savedobjectsservicesetup.addclientwrapper.md) | <code>(priority: number, id: string, factory: SavedObjectsClientWrapperFactory) =&gt; void</code> | Add a [client wrapper factory](./kibana-plugin-server.savedobjectsclientwrapperfactory.md) with the given priority. |
| [getImportExportObjectLimit](./kibana-plugin-server.savedobjectsservicesetup.getimportexportobjectlimit.md) | <code>() =&gt; number</code> | Returns the maximum number of objects allowed for import or export operations. |
| [registerType](./kibana-plugin-server.savedobjectsservicesetup.registertype.md) | <code>(type: SavedObjectsType) =&gt; void</code> | Register a [savedObjects type](./kibana-plugin-server.savedobjectstype.md) definition.<!-- -->See the [mappings format](./kibana-plugin-server.savedobjectstypemappingdefinition.md) and [migration format](./kibana-plugin-server.savedobjectmigrationmap.md) for more details about these. |
| [setClientFactoryProvider](./kibana-plugin-server.savedobjectsservicesetup.setclientfactoryprovider.md) | <code>(clientFactoryProvider: SavedObjectsClientFactoryProvider) =&gt; void</code> | Set the default [factory provider](./kibana-plugin-server.savedobjectsclientfactoryprovider.md) for creating Saved Objects clients. Only one provider can be set, subsequent calls to this method will fail. |

3 changes: 3 additions & 0 deletions src/core/server/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -229,6 +229,9 @@ export {
SavedObjectsType,
SavedObjectMigrationMap,
SavedObjectMigrationFn,
getSortedObjectsForExport,
importSavedObjects,
resolveImportErrors,
} from './saved_objects';

export {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,12 @@ async function fetchObjectsToExport({
}
}

/**
* Generates sorted saved object stream to be used for export.
* See the {@link SavedObjectsExportOptions | options} for more detailed information.
*
* @public
*/
export async function getSortedObjectsForExport({
types,
objects,
Expand Down
6 changes: 6 additions & 0 deletions src/core/server/saved_objects/import/import_saved_objects.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,12 @@ import {
} from './types';
import { validateReferences } from './validate_references';

/**
* Import saved objects from given stream. See the {@link SavedObjectsImportOptions | options} for more
* detailed information.
*
* @public
*/
export async function importSavedObjects({
readStream,
objectLimit,
Expand Down
6 changes: 6 additions & 0 deletions src/core/server/saved_objects/import/resolve_import_errors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,12 @@ import {
} from './types';
import { validateReferences } from './validate_references';

/**
* Resolve and return saved object import errors.
* See the {@link SavedObjectsResolveImportErrorsOptions | options} for more detailed informations.
*
* @public
*/
export async function resolveImportErrors({
readStream,
objectLimit,
Expand Down
12 changes: 12 additions & 0 deletions src/core/server/saved_objects/import/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -107,11 +107,17 @@ export interface SavedObjectsImportResponse {
* @public
*/
export interface SavedObjectsImportOptions {
/** The stream of {@link SavedObject | saved objects} to import */
readStream: Readable;
/** The maximum number of object to import */
objectLimit: number;
/** if true, will override existing object if present */
overwrite: boolean;
/** client to use to perform the import operation */
savedObjectsClient: SavedObjectsClientContract;
/** the list of allowed types to import */
supportedTypes: string[];
/** if specified, will import in given namespace */
namespace?: string;
}

Expand All @@ -120,10 +126,16 @@ export interface SavedObjectsImportOptions {
* @public
*/
export interface SavedObjectsResolveImportErrorsOptions {
/** The stream of {@link SavedObject | saved objects} to resolve errors from */
readStream: Readable;
/** The maximum number of object to import */
objectLimit: number;
/** client to use to perform the import operation */
savedObjectsClient: SavedObjectsClientContract;
/** saved object import references to retry */
retries: SavedObjectsImportRetry[];
/** the list of allowed types to import */
supportedTypes: string[];
/** if specified, will import in given namespace */
namespace?: string;
}
1 change: 0 additions & 1 deletion src/core/server/saved_objects/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,6 @@ export interface SavedObjectsMigrationVersion {
}

/**
*
* @public
*/
export interface SavedObject<T = unknown> {
Expand Down
Loading

0 comments on commit 73ff556

Please sign in to comment.