From 043ff023ada77fcac9e35f95134349591ce123a1 Mon Sep 17 00:00:00 2001 From: ruflin Date: Tue, 17 Dec 2019 09:37:21 +0100 Subject: [PATCH 1/8] [EPM] Implement getConfig for dataset This implements a getConfig method on a dataset object. This allows to build the configuration for each dataset in a package. After the configuration for each dataset is built, this config must be stored in the datasource object. The end goal is store this as the streams in the datasource object. As at the moment we just have a strings I added a `config` field to the datasource which can be used to ship it the agent. This should be cleaned up later again. Configs is an array of strings at the moment as each entry is the input part of the stream. At the moment, it is not stored to the datasource object yet. --- x-pack/legacy/plugins/epm/common/types.ts | 13 ++++++-- .../plugins/epm/server/datasources/create.ts | 32 +++++++++++++++++++ .../epm/server/lib/agent/agent.test.ts | 2 +- .../plugins/epm/server/lib/agent/agent.ts | 15 +++------ .../plugins/ingest/server/libs/types.ts | 1 + 5 files changed, 49 insertions(+), 14 deletions(-) diff --git a/x-pack/legacy/plugins/epm/common/types.ts b/x-pack/legacy/plugins/epm/common/types.ts index 070fc81deef27..ccb165787bc4c 100644 --- a/x-pack/legacy/plugins/epm/common/types.ts +++ b/x-pack/legacy/plugins/epm/common/types.ts @@ -16,7 +16,7 @@ export enum InstallationStatus { } export type ServiceName = 'kibana' | 'elasticsearch'; -export type AssetType = KibanaAssetType | ElasticsearchAssetType; +export type AssetType = KibanaAssetType | ElasticsearchAssetType | AgentAssetType; export enum KibanaAssetType { dashboard = 'dashboard', @@ -31,6 +31,10 @@ export enum ElasticsearchAssetType { ilmPolicy = 'ilm-policy', } +export enum AgentAssetType { + input = 'input', +} + // from /package/{name} // type Package struct at https://github.com/elastic/package-registry/blob/master/util/package.go // https://github.com/elastic/package-registry/blob/master/docs/api/package.json @@ -120,12 +124,17 @@ export interface Dataset { name: string; release: string; ingeset_pipeline: string; - vars: object[]; + vars: VarsEntry[]; type: string; // This is for convenience and not in the output from the registry. When creating a dataset, this info should be added. package: string; } +export interface VarsEntry { + name: string; + default: string; +} + // some properties are optional in Registry responses but required in EPM // internal until we need them interface PackageAdditions { diff --git a/x-pack/legacy/plugins/epm/server/datasources/create.ts b/x-pack/legacy/plugins/epm/server/datasources/create.ts index e11edb960de97..7cc1204bf38d6 100644 --- a/x-pack/legacy/plugins/epm/server/datasources/create.ts +++ b/x-pack/legacy/plugins/epm/server/datasources/create.ts @@ -16,6 +16,7 @@ import { installTemplates } from '../lib/elasticsearch/template/install'; import { getPackageInfo, PackageNotInstalledError } from '../packages'; import * as Registry from '../registry'; import { Request } from '../types'; +import { createInput } from '../lib/agent/agent'; export async function createDatasource(options: { savedObjectsClient: SavedObjectsClientContract; @@ -38,6 +39,14 @@ export async function createDatasource(options: { await baseSetup(callCluster); const pkg = await Registry.fetchInfo(pkgkey); + // Collect the config for each dataset + const configs: string[] = []; + if (pkg.datasets) { + for (const dataset of pkg.datasets) { + configs.push(await getConfig(pkgkey, dataset)); + } + } + await Promise.all([ installTemplates(pkg, callCluster), saveDatasourceReferences({ @@ -184,3 +193,26 @@ async function ingestDatasourceCreate({ }, }).then(response => response.json()); } + +async function getConfig(pkgkey: string, dataset: Dataset): Promise { + const vars = dataset.vars; + + // This searches for the /agent/input.yml file + const paths = await Registry.getArchiveInfo(pkgkey, (entry: Registry.ArchiveEntry) => + isDatasetInput(entry, dataset.name) + ); + + if (paths.length === 1) { + const buffer = Registry.getAsset(paths[0]); + // Load input template from path + return createInput(vars, buffer.toString()); + } + return ''; +} + +const isDatasetInput = ({ path }: Registry.ArchiveEntry, datasetName: string) => { + const pathParts = Registry.pathParts(path); + return !isDirectory({ path }) && pathParts.type === 'input' && pathParts.dataset === datasetName; +}; + +const isDirectory = ({ path }: Registry.ArchiveEntry) => path.endsWith('/'); diff --git a/x-pack/legacy/plugins/epm/server/lib/agent/agent.test.ts b/x-pack/legacy/plugins/epm/server/lib/agent/agent.test.ts index 123f0360ebdad..4f75ba0332418 100644 --- a/x-pack/legacy/plugins/epm/server/lib/agent/agent.test.ts +++ b/x-pack/legacy/plugins/epm/server/lib/agent/agent.test.ts @@ -15,7 +15,7 @@ test('test converting input and manifest into template', () => { ); const inputTemplate = fs.readFileSync(path.join(__dirname, 'tests/input.yml'), 'utf8'); - const output = createInput(manifest, inputTemplate); + const output = createInput(manifest.vars, inputTemplate); // Golden file path const generatedFile = path.join(__dirname, './tests/input.generated.yaml'); diff --git a/x-pack/legacy/plugins/epm/server/lib/agent/agent.ts b/x-pack/legacy/plugins/epm/server/lib/agent/agent.ts index 88d2507df8f21..561a9f43c3fc7 100644 --- a/x-pack/legacy/plugins/epm/server/lib/agent/agent.ts +++ b/x-pack/legacy/plugins/epm/server/lib/agent/agent.ts @@ -5,23 +5,16 @@ */ import Handlebars from 'handlebars'; +import { VarsEntry } from '../../../common/types'; -interface Manifest { - vars: VarsEntry[]; -} - -interface VarsEntry { - name: string; - default: string; -} /** - * This takes a manifest object as input and merges it with the input template. + * This takes a dataset object as input and merges it with the input template. * It returns the resolved template as a string. */ -export function createInput(manifest: Manifest, inputTemplate: string): string { +export function createInput(vars: VarsEntry[], inputTemplate: string): string { const view: Record = {}; - for (const v of manifest.vars) { + for (const v of vars) { view[v.name] = v.default; } diff --git a/x-pack/legacy/plugins/ingest/server/libs/types.ts b/x-pack/legacy/plugins/ingest/server/libs/types.ts index c706804a51d37..e35f306f3f4e1 100644 --- a/x-pack/legacy/plugins/ingest/server/libs/types.ts +++ b/x-pack/legacy/plugins/ingest/server/libs/types.ts @@ -50,6 +50,7 @@ export interface Datasource extends SavedObjectAttributes { package: Package; read_alias?: string; streams: Stream[]; + config: string[]; } /** From bc421210297e93f783295dfd6c2f9b781c31c0d1 Mon Sep 17 00:00:00 2001 From: ruflin Date: Tue, 17 Dec 2019 10:36:48 +0100 Subject: [PATCH 2/8] add inputs --- x-pack/legacy/plugins/epm/server/datasources/create.ts | 10 +++++++--- x-pack/legacy/plugins/ingest/server/libs/types.ts | 3 ++- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/x-pack/legacy/plugins/epm/server/datasources/create.ts b/x-pack/legacy/plugins/epm/server/datasources/create.ts index 7cc1204bf38d6..5cd7ad205ad21 100644 --- a/x-pack/legacy/plugins/epm/server/datasources/create.ts +++ b/x-pack/legacy/plugins/epm/server/datasources/create.ts @@ -40,10 +40,10 @@ export async function createDatasource(options: { const pkg = await Registry.fetchInfo(pkgkey); // Collect the config for each dataset - const configs: string[] = []; + const inputs: string[] = []; if (pkg.datasets) { for (const dataset of pkg.datasets) { - configs.push(await getConfig(pkgkey, dataset)); + inputs.push(await getConfig(pkgkey, dataset)); } } @@ -56,6 +56,7 @@ export async function createDatasource(options: { datasets, toSave, request, + inputs, }), ]); @@ -82,8 +83,9 @@ async function saveDatasourceReferences(options: { datasourceName: string; toSave: AssetReference[]; request: Request; + inputs: string[]; }) { - const { savedObjectsClient, pkg, toSave, datasets, datasourceName, request } = options; + const { savedObjectsClient, pkg, toSave, datasets, datasourceName, request, inputs } = options; const savedDatasource = await getDatasource({ savedObjectsClient, pkg }); const savedAssets = savedDatasource?.package.assets; const assetsReducer = (current: Asset[] = [], pending: Asset) => { @@ -99,6 +101,8 @@ async function saveDatasourceReferences(options: { datasets, assets: toInstall, }); + + datasource.inputs = inputs; // ideally we'd call .create from /x-pack/legacy/plugins/ingest/server/libs/datasources.ts#L22 // or something similar, but it's a class not an object so many pieces are missing // we'd still need `user` from the request object, but that's not terrible diff --git a/x-pack/legacy/plugins/ingest/server/libs/types.ts b/x-pack/legacy/plugins/ingest/server/libs/types.ts index e35f306f3f4e1..ab04b5fa447ad 100644 --- a/x-pack/legacy/plugins/ingest/server/libs/types.ts +++ b/x-pack/legacy/plugins/ingest/server/libs/types.ts @@ -50,7 +50,8 @@ export interface Datasource extends SavedObjectAttributes { package: Package; read_alias?: string; streams: Stream[]; - config: string[]; + // TODO: These are the input parts of the streams. To be remove again when we have the streams + inputs: string[]; } /** From 25e1e42e3ca830200651371eb947592411b83339 Mon Sep 17 00:00:00 2001 From: Nicolas Chaulet Date: Tue, 17 Dec 2019 08:53:09 -0500 Subject: [PATCH 3/8] Build streams --- .../plugins/epm/server/datasources/create.ts | 36 ++++++++----------- 1 file changed, 14 insertions(+), 22 deletions(-) diff --git a/x-pack/legacy/plugins/epm/server/datasources/create.ts b/x-pack/legacy/plugins/epm/server/datasources/create.ts index 5cd7ad205ad21..54f3869b1efb1 100644 --- a/x-pack/legacy/plugins/epm/server/datasources/create.ts +++ b/x-pack/legacy/plugins/epm/server/datasources/create.ts @@ -5,8 +5,9 @@ */ import fetch from 'node-fetch'; +import yaml from 'js-yaml'; import { SavedObjectsClientContract } from 'src/core/server/'; -import { Asset, Datasource, InputType } from '../../../ingest/server/libs/types'; +import { Asset, Datasource, Stream } from '../../../ingest/server/libs/types'; import { SAVED_OBJECT_TYPE_DATASOURCES } from '../../common/constants'; import { AssetReference, Dataset, InstallationStatus, RegistryPackage } from '../../common/types'; import { CallESAsCurrentUser } from '../lib/cluster_access'; @@ -40,10 +41,14 @@ export async function createDatasource(options: { const pkg = await Registry.fetchInfo(pkgkey); // Collect the config for each dataset - const inputs: string[] = []; + const streams: Stream[] = []; if (pkg.datasets) { for (const dataset of pkg.datasets) { - inputs.push(await getConfig(pkgkey, dataset)); + streams.push({ + id: dataset.name, + input: yaml.load(await getConfig(pkgkey, dataset)), + output_id: 'default', + }); } } @@ -56,7 +61,7 @@ export async function createDatasource(options: { datasets, toSave, request, - inputs, + streams, }), ]); @@ -83,9 +88,9 @@ async function saveDatasourceReferences(options: { datasourceName: string; toSave: AssetReference[]; request: Request; - inputs: string[]; + streams: Stream[]; }) { - const { savedObjectsClient, pkg, toSave, datasets, datasourceName, request, inputs } = options; + const { savedObjectsClient, pkg, toSave, datasets, datasourceName, request, streams } = options; const savedDatasource = await getDatasource({ savedObjectsClient, pkg }); const savedAssets = savedDatasource?.package.assets; const assetsReducer = (current: Asset[] = [], pending: Asset) => { @@ -100,9 +105,9 @@ async function saveDatasourceReferences(options: { datasourceName, datasets, assets: toInstall, + streams, }); - datasource.inputs = inputs; // ideally we'd call .create from /x-pack/legacy/plugins/ingest/server/libs/datasources.ts#L22 // or something similar, but it's a class not an object so many pieces are missing // we'd still need `user` from the request object, but that's not terrible @@ -129,6 +134,7 @@ interface CreateFakeDatasource { datasourceName: string; datasets: Dataset[]; assets: Asset[] | undefined; + streams: Stream[]; } function createFakeDatasource({ @@ -136,22 +142,8 @@ function createFakeDatasource({ datasourceName, datasets, assets = [], + streams, }: CreateFakeDatasource): Datasource { - const streams = datasets.map(dataset => ({ - id: dataset.name, - input: { - type: InputType.Log, - config: { config: 'values', go: 'here' }, - ingest_pipelines: ['string'], - id: 'string', - index_template: 'string', - ilm_policy: 'string', - fields: [{}], - }, - config: { config: 'values', go: 'here' }, - output_id: 'output_id', - processors: ['string'], - })); return { id: Registry.pkgToPkgKey(pkg), name: datasourceName, From ac3cd5222fe4b0d661af4c290ffe947f54aab8ef Mon Sep 17 00:00:00 2001 From: Nicolas Chaulet Date: Tue, 17 Dec 2019 09:48:43 -0500 Subject: [PATCH 4/8] Fix fleet policy lib to use streams --- .../plugins/epm/server/datasources/create.ts | 17 +++++++------ .../plugins/fleet/server/libs/policy.ts | 2 +- .../plugins/ingest/server/libs/types.ts | 2 -- .../legacy/plugins/ingest/server/mappings.ts | 24 +------------------ 4 files changed, 12 insertions(+), 33 deletions(-) diff --git a/x-pack/legacy/plugins/epm/server/datasources/create.ts b/x-pack/legacy/plugins/epm/server/datasources/create.ts index 54f3869b1efb1..f1bbe55f9986b 100644 --- a/x-pack/legacy/plugins/epm/server/datasources/create.ts +++ b/x-pack/legacy/plugins/epm/server/datasources/create.ts @@ -44,11 +44,14 @@ export async function createDatasource(options: { const streams: Stream[] = []; if (pkg.datasets) { for (const dataset of pkg.datasets) { - streams.push({ - id: dataset.name, - input: yaml.load(await getConfig(pkgkey, dataset)), - output_id: 'default', - }); + const input = yaml.load(await getConfig(pkgkey, dataset)); + if (input) { + streams.push({ + id: dataset.name, + input, + output_id: 'default', + }); + } } } @@ -178,7 +181,7 @@ async function ingestDatasourceCreate({ const url = `${origin}${basePath}${apiPath}`; const body = { datasource }; delete request.headers['transfer-encoding']; - return fetch(url, { + await fetch(url, { method: 'post', body: JSON.stringify(body), headers: { @@ -187,7 +190,7 @@ async function ingestDatasourceCreate({ // the main (only?) one we want is `authorization` ...request.headers, }, - }).then(response => response.json()); + }); } async function getConfig(pkgkey: string, dataset: Dataset): Promise { diff --git a/x-pack/legacy/plugins/fleet/server/libs/policy.ts b/x-pack/legacy/plugins/fleet/server/libs/policy.ts index 63d21e83e03c2..e2b2944137571 100644 --- a/x-pack/legacy/plugins/fleet/server/libs/policy.ts +++ b/x-pack/legacy/plugins/fleet/server/libs/policy.ts @@ -16,7 +16,7 @@ export class PolicyLib { return flatten( datasources.map((ds: Datasource) => { return ds.streams.map(stream => ({ - ...stream.config, + ...stream.input, id: stream.id, type: stream.input.type as any, output: { use_output: stream.output_id }, diff --git a/x-pack/legacy/plugins/ingest/server/libs/types.ts b/x-pack/legacy/plugins/ingest/server/libs/types.ts index ab04b5fa447ad..c706804a51d37 100644 --- a/x-pack/legacy/plugins/ingest/server/libs/types.ts +++ b/x-pack/legacy/plugins/ingest/server/libs/types.ts @@ -50,8 +50,6 @@ export interface Datasource extends SavedObjectAttributes { package: Package; read_alias?: string; streams: Stream[]; - // TODO: These are the input parts of the streams. To be remove again when we have the streams - inputs: string[]; } /** diff --git a/x-pack/legacy/plugins/ingest/server/mappings.ts b/x-pack/legacy/plugins/ingest/server/mappings.ts index 7596d4b36995b..c00a86b1fae44 100644 --- a/x-pack/legacy/plugins/ingest/server/mappings.ts +++ b/x-pack/legacy/plugins/ingest/server/mappings.ts @@ -79,29 +79,7 @@ export const mappings = { type: 'keyword', }, input: { - properties: { - config: { - type: 'flattened', - }, - fields: { - type: 'flattened', - }, - id: { - type: 'keyword', - }, - ilm_policy: { - type: 'keyword', - }, - index_template: { - type: 'keyword', - }, - ingest_pipelines: { - type: 'keyword', - }, - type: { - type: 'keyword', - }, - }, + type: 'flattened', }, output_id: { type: 'keyword', From ccf1343df90d2d1e811e425cab9131433855346e Mon Sep 17 00:00:00 2001 From: Nicolas Chaulet Date: Tue, 17 Dec 2019 09:51:49 -0500 Subject: [PATCH 5/8] Use selected datasets instead of pkd.datasets --- x-pack/legacy/plugins/epm/server/datasources/create.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/x-pack/legacy/plugins/epm/server/datasources/create.ts b/x-pack/legacy/plugins/epm/server/datasources/create.ts index f1bbe55f9986b..37a167f71ccc5 100644 --- a/x-pack/legacy/plugins/epm/server/datasources/create.ts +++ b/x-pack/legacy/plugins/epm/server/datasources/create.ts @@ -42,8 +42,8 @@ export async function createDatasource(options: { // Collect the config for each dataset const streams: Stream[] = []; - if (pkg.datasets) { - for (const dataset of pkg.datasets) { + if (datasets) { + for (const dataset of datasets) { const input = yaml.load(await getConfig(pkgkey, dataset)); if (input) { streams.push({ From d6ce56a53418f64d6cc74993924ddaf1fd4fb9ef Mon Sep 17 00:00:00 2001 From: Nicolas Chaulet Date: Tue, 17 Dec 2019 10:18:14 -0500 Subject: [PATCH 6/8] Move streams creation to his own function --- .../plugins/epm/server/datasources/create.ts | 32 +++++++++++-------- 1 file changed, 18 insertions(+), 14 deletions(-) diff --git a/x-pack/legacy/plugins/epm/server/datasources/create.ts b/x-pack/legacy/plugins/epm/server/datasources/create.ts index 37a167f71ccc5..0e713bce974e4 100644 --- a/x-pack/legacy/plugins/epm/server/datasources/create.ts +++ b/x-pack/legacy/plugins/epm/server/datasources/create.ts @@ -40,20 +40,7 @@ export async function createDatasource(options: { await baseSetup(callCluster); const pkg = await Registry.fetchInfo(pkgkey); - // Collect the config for each dataset - const streams: Stream[] = []; - if (datasets) { - for (const dataset of datasets) { - const input = yaml.load(await getConfig(pkgkey, dataset)); - if (input) { - streams.push({ - id: dataset.name, - input, - output_id: 'default', - }); - } - } - } + const streams = await getStreams(pkgkey, datasets); await Promise.all([ installTemplates(pkg, callCluster), @@ -120,6 +107,23 @@ async function saveDatasourceReferences(options: { return toInstall; } +async function getStreams(pkgkey: string, datasets: Dataset[]) { + const streams: Stream[] = []; + if (datasets) { + for (const dataset of datasets) { + const input = yaml.load(await getConfig(pkgkey, dataset)); + if (input) { + streams.push({ + id: dataset.name, + input, + output_id: 'default', + }); + } + } + } + return streams; +} + async function getDatasource(options: { savedObjectsClient: SavedObjectsClientContract; pkg: RegistryPackage; From 536668ad7789fb15b75e3cf99994284258e32fd0 Mon Sep 17 00:00:00 2001 From: Nicolas Chaulet Date: Tue, 17 Dec 2019 10:51:11 -0500 Subject: [PATCH 7/8] Fix CI --- x-pack/legacy/plugins/epm/public/constants.ts | 1 + .../server/libs/__snapshots__/policy.test.ts.snap | 11 +++++++++++ 2 files changed, 12 insertions(+) diff --git a/x-pack/legacy/plugins/epm/public/constants.ts b/x-pack/legacy/plugins/epm/public/constants.ts index eea35ba274e98..cb871cb79572b 100644 --- a/x-pack/legacy/plugins/epm/public/constants.ts +++ b/x-pack/legacy/plugins/epm/public/constants.ts @@ -23,6 +23,7 @@ export const AssetTitleMap: Record = { 'index-template': 'Index Template', search: 'Saved Search', visualization: 'Visualization', + input: 'Agent input', }; export const ServiceTitleMap: Record = { diff --git a/x-pack/legacy/plugins/fleet/server/libs/__snapshots__/policy.test.ts.snap b/x-pack/legacy/plugins/fleet/server/libs/__snapshots__/policy.test.ts.snap index 17ac01da211ae..2bf3bf4f4ae28 100644 --- a/x-pack/legacy/plugins/fleet/server/libs/__snapshots__/policy.test.ts.snap +++ b/x-pack/legacy/plugins/fleet/server/libs/__snapshots__/policy.test.ts.snap @@ -15,7 +15,18 @@ Object { }, "streams": Array [ Object { + "config": Object { + "paths": "/var/log/*.log", + }, + "fields": Array [ + Object {}, + ], "id": "string", + "ilm_policy": "string", + "index_template": "string", + "ingest_pipelines": Array [ + "string", + ], "metricsets": Array [ "container", "cpu", From 973aa68c59490a44d0ad2580336ffa7eebb225ca Mon Sep 17 00:00:00 2001 From: Nicolas Chaulet Date: Tue, 17 Dec 2019 14:24:14 -0500 Subject: [PATCH 8/8] Fix slapshot test --- .../default.contract.test.slap_snap | 338 ++++++++++++++++++ 1 file changed, 338 insertions(+) diff --git a/x-pack/legacy/plugins/fleet/server/repositories/enrollment_api_keys/__memorize_snapshots__/default.contract.test.slap_snap b/x-pack/legacy/plugins/fleet/server/repositories/enrollment_api_keys/__memorize_snapshots__/default.contract.test.slap_snap index 5d4cc3f7c35c8..91ff2d47d80f0 100644 --- a/x-pack/legacy/plugins/fleet/server/repositories/enrollment_api_keys/__memorize_snapshots__/default.contract.test.slap_snap +++ b/x-pack/legacy/plugins/fleet/server/repositories/enrollment_api_keys/__memorize_snapshots__/default.contract.test.slap_snap @@ -1031,3 +1031,341 @@ exports['Enrollment api key Repository delete allow to delete a enrollmentApiKey "saved_objects": [] } } + +exports['Enrollment api key Repository create allow to create an enrollment api key - create:enrollment_api_keys (1)'] = { + "results": { + "type": "enrollment_api_keys", + "id": "1502d192-abf0-427b-a272-5656b7d3ad37", + "attributes": { + "created_at": "2019-12-17T19:23:22.719Z", + "api_key_id": "key-id-123", + "policy_id": "policyId", + "active": true, + "enrollment_rules": [] + }, + "references": [], + "updated_at": "2019-12-17T19:23:22.758Z", + "version": "WzIsMV0=" + } +} + +exports['Enrollment api key Repository create allow to create an enrollment api key - get:enrollment_api_keys (2)'] = { + "results": { + "id": "1502d192-abf0-427b-a272-5656b7d3ad37", + "type": "enrollment_api_keys", + "updated_at": "2019-12-17T19:23:22.758Z", + "version": "WzIsMV0=", + "attributes": { + "created_at": "2019-12-17T19:23:22.719Z", + "api_key_id": "key-id-123", + "policy_id": "policyId", + "active": true, + "enrollment_rules": [] + }, + "references": [] + } +} + +exports['Enrollment api key Repository create allow to create an enrollment api key - find:"enrollment_api_keys" (3)'] = { + "results": { + "page": 1, + "per_page": 1000, + "total": 1, + "saved_objects": [ + { + "type": "enrollment_api_keys", + "id": "1502d192-abf0-427b-a272-5656b7d3ad37", + "attributes": { + "created_at": "2019-12-17T19:23:22.719Z", + "api_key_id": "key-id-123", + "policy_id": "policyId", + "active": true, + "enrollment_rules": [] + }, + "references": [], + "updated_at": "2019-12-17T19:23:22.758Z", + "version": "WzIsMV0=" + } + ] + } +} + +exports['Enrollment api key Repository create allow to create an enrollment api key - delete (4)'] = { + "results": {} +} + +exports['Enrollment api key Repository update allow to update a key - create:enrollment_api_keys (1)'] = { + "results": { + "type": "enrollment_api_keys", + "id": "36f0a985-0715-4389-9c3f-842183a9c87e", + "attributes": { + "active": true, + "policy_id": "policyId" + }, + "references": [], + "updated_at": "2019-12-17T19:23:24.959Z", + "version": "WzQsMV0=" + } +} + +exports['Enrollment api key Repository update allow to update a key - update:enrollment_api_keys (2)'] = { + "results": { + "id": "36f0a985-0715-4389-9c3f-842183a9c87e", + "type": "enrollment_api_keys", + "updated_at": "2019-12-17T19:23:25.978Z", + "version": "WzUsMV0=", + "attributes": { + "active": false + } + } +} + +exports['Enrollment api key Repository update allow to update a key - get:enrollment_api_keys (3)'] = { + "results": { + "id": "36f0a985-0715-4389-9c3f-842183a9c87e", + "type": "enrollment_api_keys", + "updated_at": "2019-12-17T19:23:25.978Z", + "version": "WzUsMV0=", + "attributes": { + "active": false, + "policy_id": "policyId" + }, + "references": [] + } +} + +exports['Enrollment api key Repository update allow to update a key - find:"enrollment_api_keys" (4)'] = { + "results": { + "page": 1, + "per_page": 1000, + "total": 1, + "saved_objects": [ + { + "type": "enrollment_api_keys", + "id": "36f0a985-0715-4389-9c3f-842183a9c87e", + "attributes": { + "active": false, + "policy_id": "policyId" + }, + "references": [], + "updated_at": "2019-12-17T19:23:25.978Z", + "version": "WzUsMV0=" + } + ] + } +} + +exports['Enrollment api key Repository update allow to update a key - delete (5)'] = { + "results": {} +} + +exports['Enrollment api key Repository getByApiKeyId allow to find a key - create:enrollment_api_keys (1)'] = { + "results": { + "type": "enrollment_api_keys", + "id": "45c7480b-bcff-4bc2-af75-ade639b31c4d", + "attributes": { + "active": true, + "api_key_id": "api-key-1" + }, + "references": [], + "updated_at": "2019-12-17T19:23:28.003Z", + "version": "WzcsMV0=" + } +} + +exports['Enrollment api key Repository getByApiKeyId allow to find a key - create:enrollment_api_keys (2)'] = { + "results": { + "type": "enrollment_api_keys", + "id": "4c9c1105-8516-491f-9faf-110a6b2c266b", + "attributes": { + "active": true, + "api_key_id": "api-key-2" + }, + "references": [], + "updated_at": "2019-12-17T19:23:28.003Z", + "version": "WzgsMV0=" + } +} + +exports['Enrollment api key Repository getByApiKeyId allow to find a key - find:"enrollment_api_keys" (3)'] = { + "results": { + "page": 1, + "per_page": 20, + "total": 1, + "saved_objects": [ + { + "type": "enrollment_api_keys", + "id": "4c9c1105-8516-491f-9faf-110a6b2c266b", + "attributes": { + "active": true, + "api_key_id": "api-key-2" + }, + "references": [], + "updated_at": "2019-12-17T19:23:28.003Z", + "version": "WzgsMV0=" + } + ] + } +} + +exports['Enrollment api key Repository getByApiKeyId allow to find a key - getDecryptedAsInternalUser:enrollment_api_keys:4c9c1105-8516-491f-9faf-110a6b2c266b (4)'] = { + "results": { + "id": "4c9c1105-8516-491f-9faf-110a6b2c266b", + "type": "enrollment_api_keys", + "updated_at": "2019-12-17T19:23:28.003Z", + "version": "WzgsMV0=", + "attributes": { + "active": true, + "api_key_id": "api-key-2" + }, + "references": [] + } +} + +exports['Enrollment api key Repository getByApiKeyId allow to find a key - find:"enrollment_api_keys" (5)'] = { + "results": { + "page": 1, + "per_page": 1000, + "total": 2, + "saved_objects": [ + { + "type": "enrollment_api_keys", + "id": "45c7480b-bcff-4bc2-af75-ade639b31c4d", + "attributes": { + "active": true, + "api_key_id": "api-key-1" + }, + "references": [], + "updated_at": "2019-12-17T19:23:28.003Z", + "version": "WzcsMV0=" + }, + { + "type": "enrollment_api_keys", + "id": "4c9c1105-8516-491f-9faf-110a6b2c266b", + "attributes": { + "active": true, + "api_key_id": "api-key-2" + }, + "references": [], + "updated_at": "2019-12-17T19:23:28.003Z", + "version": "WzgsMV0=" + } + ] + } +} + +exports['Enrollment api key Repository getByApiKeyId allow to find a key - delete (6)'] = { + "results": {} +} + +exports['Enrollment api key Repository getByApiKeyId allow to find a key - delete (7)'] = { + "results": {} +} + +exports['Enrollment api key Repository getByApiKeyId return null if the key does not exists - create:enrollment_api_keys (2)'] = { + "results": { + "type": "enrollment_api_keys", + "id": "ffac4ee5-fd48-484a-8b7b-7d65be794022", + "attributes": { + "active": true, + "api_key_id": "api-key-2" + }, + "references": [], + "updated_at": "2019-12-17T19:23:31.063Z", + "version": "WzEyLDFd" + } +} + +exports['Enrollment api key Repository getByApiKeyId return null if the key does not exists - create:enrollment_api_keys (1)'] = { + "results": { + "type": "enrollment_api_keys", + "id": "cb24231b-5687-4c02-8e4a-41ec03654541", + "attributes": { + "active": true, + "api_key_id": "api-key-1" + }, + "references": [], + "updated_at": "2019-12-17T19:23:31.063Z", + "version": "WzExLDFd" + } +} + +exports['Enrollment api key Repository getByApiKeyId return null if the key does not exists - find:"enrollment_api_keys" (3)'] = { + "results": { + "page": 1, + "per_page": 20, + "total": 0, + "saved_objects": [] + } +} + +exports['Enrollment api key Repository getByApiKeyId return null if the key does not exists - find:"enrollment_api_keys" (4)'] = { + "results": { + "page": 1, + "per_page": 1000, + "total": 2, + "saved_objects": [ + { + "type": "enrollment_api_keys", + "id": "cb24231b-5687-4c02-8e4a-41ec03654541", + "attributes": { + "active": true, + "api_key_id": "api-key-1" + }, + "references": [], + "updated_at": "2019-12-17T19:23:31.063Z", + "version": "WzExLDFd" + }, + { + "type": "enrollment_api_keys", + "id": "ffac4ee5-fd48-484a-8b7b-7d65be794022", + "attributes": { + "active": true, + "api_key_id": "api-key-2" + }, + "references": [], + "updated_at": "2019-12-17T19:23:31.063Z", + "version": "WzEyLDFd" + } + ] + } +} + +exports['Enrollment api key Repository getByApiKeyId return null if the key does not exists - delete (5)'] = { + "results": {} +} + +exports['Enrollment api key Repository getByApiKeyId return null if the key does not exists - delete (6)'] = { + "results": {} +} + +exports['Enrollment api key Repository delete allow to delete a enrollmentApiKey - create:enrollment_api_keys (1)'] = { + "results": { + "type": "enrollment_api_keys", + "id": "a8861b08-a805-4c74-8618-489ad9dda650", + "attributes": { + "active": true, + "api_key_id": "qwerty" + }, + "references": [], + "updated_at": "2019-12-17T19:23:34.126Z", + "version": "WzE1LDFd" + } +} + +exports['Enrollment api key Repository delete allow to delete a enrollmentApiKey - delete (2)'] = { + "results": {} +} + +exports['Enrollment api key Repository delete allow to delete a enrollmentApiKey - get:enrollment_api_keys (3)'] = { + "results": null +} + +exports['Enrollment api key Repository delete allow to delete a enrollmentApiKey - find:"enrollment_api_keys" (4)'] = { + "results": { + "page": 1, + "per_page": 1000, + "total": 0, + "saved_objects": [] + } +}