From f7ef2548574c09d508532ffd84535ca2f04a1a02 Mon Sep 17 00:00:00 2001 From: Jen Huang Date: Fri, 26 Jun 2020 13:01:25 -0700 Subject: [PATCH 01/16] Rename `datasource` saved object to `package_config` (SO type `ingest-datasource` to `ingest-package-config`) and adjust mappings: - Remove unused `processors` field on input & stream levels - Remove unnecessary `enabled` field on package config & input levels - Rename `agent_stream` field to `compiled_stream` - Reorder other fields so that important fields are closer to top & similar fields are grouped together Also, - Remove 7.9.0 migrations as we are not supporting an upgrade path from experimental to beta release --- .../ingest_manager/common/constants/index.ts | 2 +- .../{datasource.ts => package_config.ts} | 2 +- .../ingest_manager/common/types/models/epm.ts | 53 +++++++++++++++++++ .../ingest_manager/constants/index.ts | 2 +- .../epm/screens/detail/settings_panel.tsx | 4 +- .../ingest_manager/server/constants/index.ts | 2 +- .../plugins/ingest_manager/server/plugin.ts | 4 +- .../server/saved_objects/index.ts | 39 +++++--------- .../migrations/agent_config_v790.ts | 24 --------- .../migrations/datasources_v790.ts | 43 --------------- .../server/services/datasource.ts | 4 +- .../server/services/epm/packages/remove.ts | 4 +- 12 files changed, 79 insertions(+), 104 deletions(-) rename x-pack/plugins/ingest_manager/common/constants/{datasource.ts => package_config.ts} (76%) delete mode 100644 x-pack/plugins/ingest_manager/server/saved_objects/migrations/agent_config_v790.ts delete mode 100644 x-pack/plugins/ingest_manager/server/saved_objects/migrations/datasources_v790.ts diff --git a/x-pack/plugins/ingest_manager/common/constants/index.ts b/x-pack/plugins/ingest_manager/common/constants/index.ts index 6a2e559bbbe4f..ed01fcdd316a3 100644 --- a/x-pack/plugins/ingest_manager/common/constants/index.ts +++ b/x-pack/plugins/ingest_manager/common/constants/index.ts @@ -8,7 +8,7 @@ export * from './routes'; export * from './agent'; export * from './agent_config'; -export * from './datasource'; +export * from './package_config'; export * from './epm'; export * from './output'; export * from './enrollment_api_key'; diff --git a/x-pack/plugins/ingest_manager/common/constants/datasource.ts b/x-pack/plugins/ingest_manager/common/constants/package_config.ts similarity index 76% rename from x-pack/plugins/ingest_manager/common/constants/datasource.ts rename to x-pack/plugins/ingest_manager/common/constants/package_config.ts index 08113cff53bda..0c961db405562 100644 --- a/x-pack/plugins/ingest_manager/common/constants/datasource.ts +++ b/x-pack/plugins/ingest_manager/common/constants/package_config.ts @@ -4,4 +4,4 @@ * you may not use this file except in compliance with the Elastic License. */ -export const DATASOURCE_SAVED_OBJECT_TYPE = 'ingest-datasources'; +export const PACKAGE_CONFIG_SAVED_OBJECT_TYPE = 'ingest-package-config'; diff --git a/x-pack/plugins/ingest_manager/common/types/models/epm.ts b/x-pack/plugins/ingest_manager/common/types/models/epm.ts index f45924c30faad..370e1df102b94 100644 --- a/x-pack/plugins/ingest_manager/common/types/models/epm.ts +++ b/x-pack/plugins/ingest_manager/common/types/models/epm.ts @@ -282,3 +282,56 @@ export interface TemplateRef { templateName: string; indexTemplate: IndexTemplate; } + +type FullAgentConfig = { + id: string; + outputs: { + [x: string]: { + [x: string]: any; + type: OutputType; + hosts?: string[] | undefined; + ca_sha256?: string | undefined; + api_key?: string | undefined; + }; + }; + inputs: { + [x: string]: any; + id: string; + name: string; + type: string; + dataset: { + namespace: string; + }; + use_output: string; + meta?: + | { + [x: string]: unknown; + package?: + | { + name: string; + version: string; + } + | undefined; + } + | undefined; + streams: { + [x: string]: any; + id: string; + processors?: string[] | undefined; + dataset: { + name: string; + }; + }[]; + }[]; + revision?: number | undefined; + settings?: + | { + monitoring: { + use_output?: string | undefined; + enabled: boolean; + metrics: boolean; + logs: boolean; + }; + } + | undefined; +}; diff --git a/x-pack/plugins/ingest_manager/public/applications/ingest_manager/constants/index.ts b/x-pack/plugins/ingest_manager/public/applications/ingest_manager/constants/index.ts index 2936eea21805d..d31d66d889c96 100644 --- a/x-pack/plugins/ingest_manager/public/applications/ingest_manager/constants/index.ts +++ b/x-pack/plugins/ingest_manager/public/applications/ingest_manager/constants/index.ts @@ -11,7 +11,7 @@ export { AGENT_EVENT_SAVED_OBJECT_TYPE, AGENT_SAVED_OBJECT_TYPE, ENROLLMENT_API_KEYS_SAVED_OBJECT_TYPE, - DATASOURCE_SAVED_OBJECT_TYPE, + PACKAGE_CONFIG_SAVED_OBJECT_TYPE, } from '../../../../common'; export * from './page_paths'; diff --git a/x-pack/plugins/ingest_manager/public/applications/ingest_manager/sections/epm/screens/detail/settings_panel.tsx b/x-pack/plugins/ingest_manager/public/applications/ingest_manager/sections/epm/screens/detail/settings_panel.tsx index 986b946131e33..52d2cd0bcc314 100644 --- a/x-pack/plugins/ingest_manager/public/applications/ingest_manager/sections/epm/screens/detail/settings_panel.tsx +++ b/x-pack/plugins/ingest_manager/public/applications/ingest_manager/sections/epm/screens/detail/settings_panel.tsx @@ -11,7 +11,7 @@ import { EuiSpacer } from '@elastic/eui'; import styled from 'styled-components'; import { InstallStatus, PackageInfo } from '../../../../types'; import { useGetDatasources } from '../../../../hooks'; -import { DATASOURCE_SAVED_OBJECT_TYPE } from '../../../../constants'; +import { PACKAGE_CONFIG_SAVED_OBJECT_TYPE } from '../../../../constants'; import { useGetPackageInstallStatus } from '../../hooks'; import { InstallationButton } from './installation_button'; import { UpdateIcon } from '../../components/icons'; @@ -49,7 +49,7 @@ export const SettingsPanel = ( const { data: datasourcesData } = useGetDatasources({ perPage: 0, page: 1, - kuery: `${DATASOURCE_SAVED_OBJECT_TYPE}.package.name:${props.name}`, + kuery: `${PACKAGE_CONFIG_SAVED_OBJECT_TYPE}.package.name:${props.name}`, }); const { status: installationStatus, version: installedVersion } = getPackageInstallStatus(name); const packageHasDatasources = !!datasourcesData?.total; diff --git a/x-pack/plugins/ingest_manager/server/constants/index.ts b/x-pack/plugins/ingest_manager/server/constants/index.ts index ebcce6320ec4b..2efbdef56f488 100644 --- a/x-pack/plugins/ingest_manager/server/constants/index.ts +++ b/x-pack/plugins/ingest_manager/server/constants/index.ts @@ -31,7 +31,7 @@ export { AGENT_EVENT_SAVED_OBJECT_TYPE, AGENT_ACTION_SAVED_OBJECT_TYPE, AGENT_CONFIG_SAVED_OBJECT_TYPE, - DATASOURCE_SAVED_OBJECT_TYPE, + PACKAGE_CONFIG_SAVED_OBJECT_TYPE, OUTPUT_SAVED_OBJECT_TYPE, PACKAGES_SAVED_OBJECT_TYPE, INDEX_PATTERN_SAVED_OBJECT_TYPE, diff --git a/x-pack/plugins/ingest_manager/server/plugin.ts b/x-pack/plugins/ingest_manager/server/plugin.ts index 1ae9528f34410..9943726be5be4 100644 --- a/x-pack/plugins/ingest_manager/server/plugin.ts +++ b/x-pack/plugins/ingest_manager/server/plugin.ts @@ -25,7 +25,7 @@ import { PLUGIN_ID, OUTPUT_SAVED_OBJECT_TYPE, AGENT_CONFIG_SAVED_OBJECT_TYPE, - DATASOURCE_SAVED_OBJECT_TYPE, + PACKAGE_CONFIG_SAVED_OBJECT_TYPE, PACKAGES_SAVED_OBJECT_TYPE, AGENT_SAVED_OBJECT_TYPE, AGENT_EVENT_SAVED_OBJECT_TYPE, @@ -91,7 +91,7 @@ export type IngestManagerSetupContract = void; const allSavedObjectTypes = [ OUTPUT_SAVED_OBJECT_TYPE, AGENT_CONFIG_SAVED_OBJECT_TYPE, - DATASOURCE_SAVED_OBJECT_TYPE, + PACKAGE_CONFIG_SAVED_OBJECT_TYPE, PACKAGES_SAVED_OBJECT_TYPE, AGENT_SAVED_OBJECT_TYPE, AGENT_EVENT_SAVED_OBJECT_TYPE, diff --git a/x-pack/plugins/ingest_manager/server/saved_objects/index.ts b/x-pack/plugins/ingest_manager/server/saved_objects/index.ts index 43b7606a3ce9e..6aa747259b7ad 100644 --- a/x-pack/plugins/ingest_manager/server/saved_objects/index.ts +++ b/x-pack/plugins/ingest_manager/server/saved_objects/index.ts @@ -9,7 +9,7 @@ import { EncryptedSavedObjectsPluginSetup } from '../../../encrypted_saved_objec import { OUTPUT_SAVED_OBJECT_TYPE, AGENT_CONFIG_SAVED_OBJECT_TYPE, - DATASOURCE_SAVED_OBJECT_TYPE, + PACKAGE_CONFIG_SAVED_OBJECT_TYPE, PACKAGES_SAVED_OBJECT_TYPE, AGENT_SAVED_OBJECT_TYPE, AGENT_EVENT_SAVED_OBJECT_TYPE, @@ -17,14 +17,13 @@ import { ENROLLMENT_API_KEYS_SAVED_OBJECT_TYPE, GLOBAL_SETTINGS_SAVED_OBJECT_TYPE, } from '../constants'; -import { migrateDatasourcesToV790 } from './migrations/datasources_v790'; -import { migrateAgentConfigToV790 } from './migrations/agent_config_v790'; + /* * Saved object types and mappings * - * Please update typings in `/common/types` if mappings are updated. + * Please update typings in `/common/types` as well as + * schemas in `/server/types` if mappings are updated. */ - const savedObjectTypes: { [key: string]: SavedObjectsType } = { [GLOBAL_SETTINGS_SAVED_OBJECT_TYPE]: { name: GLOBAL_SETTINGS_SAVED_OBJECT_TYPE, @@ -121,20 +120,17 @@ const savedObjectTypes: { [key: string]: SavedObjectsType } = { properties: { id: { type: 'keyword' }, name: { type: 'text' }, - is_default: { type: 'boolean' }, - namespace: { type: 'keyword' }, description: { type: 'text' }, + namespace: { type: 'keyword' }, + is_default: { type: 'boolean' }, status: { type: 'keyword' }, - datasources: { type: 'keyword' }, + package_configs: { type: 'keyword' }, + revision: { type: 'integer' }, updated_at: { type: 'date' }, updated_by: { type: 'keyword' }, - revision: { type: 'integer' }, monitoring_enabled: { type: 'keyword' }, }, }, - migrations: { - '7.9.0': migrateAgentConfigToV790, - }, }, [ENROLLMENT_API_KEYS_SAVED_OBJECT_TYPE]: { name: ENROLLMENT_API_KEYS_SAVED_OBJECT_TYPE, @@ -177,8 +173,8 @@ const savedObjectTypes: { [key: string]: SavedObjectsType } = { }, }, }, - [DATASOURCE_SAVED_OBJECT_TYPE]: { - name: DATASOURCE_SAVED_OBJECT_TYPE, + [PACKAGE_CONFIG_SAVED_OBJECT_TYPE]: { + name: PACKAGE_CONFIG_SAVED_OBJECT_TYPE, hidden: false, namespaceType: 'agnostic', management: { @@ -190,7 +186,7 @@ const savedObjectTypes: { [key: string]: SavedObjectsType } = { description: { type: 'text' }, namespace: { type: 'keyword' }, config_id: { type: 'keyword' }, - enabled: { type: 'boolean' }, + output_id: { type: 'keyword' }, package: { properties: { name: { type: 'keyword' }, @@ -198,15 +194,12 @@ const savedObjectTypes: { [key: string]: SavedObjectsType } = { version: { type: 'keyword' }, }, }, - output_id: { type: 'keyword' }, inputs: { type: 'nested', properties: { type: { type: 'keyword' }, - enabled: { type: 'boolean' }, - processors: { type: 'keyword' }, - config: { type: 'flattened' }, vars: { type: 'flattened' }, + config: { type: 'flattened' }, streams: { type: 'nested', properties: { @@ -218,10 +211,9 @@ const savedObjectTypes: { [key: string]: SavedObjectsType } = { type: { type: 'keyword' }, }, }, - processors: { type: 'keyword' }, - config: { type: 'flattened' }, - agent_stream: { type: 'flattened' }, vars: { type: 'flattened' }, + config: { type: 'flattened' }, + compiled_stream: { type: 'flattened' }, }, }, }, @@ -233,9 +225,6 @@ const savedObjectTypes: { [key: string]: SavedObjectsType } = { created_by: { type: 'keyword' }, }, }, - migrations: { - '7.9.0': migrateDatasourcesToV790, - }, }, [PACKAGES_SAVED_OBJECT_TYPE]: { name: PACKAGES_SAVED_OBJECT_TYPE, diff --git a/x-pack/plugins/ingest_manager/server/saved_objects/migrations/agent_config_v790.ts b/x-pack/plugins/ingest_manager/server/saved_objects/migrations/agent_config_v790.ts deleted file mode 100644 index 0c850f2c25fbf..0000000000000 --- a/x-pack/plugins/ingest_manager/server/saved_objects/migrations/agent_config_v790.ts +++ /dev/null @@ -1,24 +0,0 @@ -/* - * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one - * or more contributor license agreements. Licensed under the Elastic License; - * you may not use this file except in compliance with the Elastic License. - */ - -import { SavedObjectMigrationFn } from 'kibana/server'; -import { cloneDeep } from 'lodash'; -import { AgentConfig } from '../../types'; - -type Pre790AgentConfig = Exclude & { - updated_on: string; -}; - -export const migrateAgentConfigToV790: SavedObjectMigrationFn = ( - doc -) => { - const updatedAgentConfig = cloneDeep(doc); - - updatedAgentConfig.attributes.updated_at = doc.attributes.updated_on; - delete updatedAgentConfig.attributes.updated_on; - - return updatedAgentConfig; -}; diff --git a/x-pack/plugins/ingest_manager/server/saved_objects/migrations/datasources_v790.ts b/x-pack/plugins/ingest_manager/server/saved_objects/migrations/datasources_v790.ts deleted file mode 100644 index d1e4b29daefc6..0000000000000 --- a/x-pack/plugins/ingest_manager/server/saved_objects/migrations/datasources_v790.ts +++ /dev/null @@ -1,43 +0,0 @@ -/* - * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one - * or more contributor license agreements. Licensed under the Elastic License; - * you may not use this file except in compliance with the Elastic License. - */ - -import { SavedObjectMigrationFn } from 'kibana/server'; -import { cloneDeep } from 'lodash'; -import { Datasource, DatasourceInput, DatasourceInputStream } from '../../types'; - -type Pre790Datasource = Exclude< - Datasource, - 'created_at' | 'created_by' | 'updated_at' | 'updated_by' -> & { - inputs: Array< - Exclude & { - streams: Array< - Exclude & { - dataset: string; - } - >; - } - >; -}; - -export const migrateDatasourcesToV790: SavedObjectMigrationFn = ( - doc -) => { - const updatedDatasource = cloneDeep(doc); - const defDate = new Date().toISOString(); - - updatedDatasource.attributes.created_by = 'system'; - updatedDatasource.attributes.created_at = updatedDatasource?.updated_at ?? defDate; - updatedDatasource.attributes.updated_by = 'system'; - updatedDatasource.attributes.updated_at = updatedDatasource?.updated_at ?? defDate; - updatedDatasource.attributes.inputs.forEach((input) => { - input.streams.forEach((stream) => { - stream.dataset = { name: (stream.dataset as unknown) as string, type: '' }; - }); - }); - - return updatedDatasource; -}; diff --git a/x-pack/plugins/ingest_manager/server/services/datasource.ts b/x-pack/plugins/ingest_manager/server/services/datasource.ts index fecec0c463459..b73d3d3d19803 100644 --- a/x-pack/plugins/ingest_manager/server/services/datasource.ts +++ b/x-pack/plugins/ingest_manager/server/services/datasource.ts @@ -12,7 +12,7 @@ import { DatasourceInputStream, PackageInfo, } from '../../common'; -import { DATASOURCE_SAVED_OBJECT_TYPE } from '../constants'; +import { PACKAGE_CONFIG_SAVED_OBJECT_TYPE } from '../constants'; import { NewDatasource, Datasource, @@ -27,7 +27,7 @@ import { getPackageInfo, getInstallation } from './epm/packages'; import { getAssetsData } from './epm/packages/assets'; import { createStream } from './epm/agent/agent'; -const SAVED_OBJECT_TYPE = DATASOURCE_SAVED_OBJECT_TYPE; +const SAVED_OBJECT_TYPE = PACKAGE_CONFIG_SAVED_OBJECT_TYPE; function getDataset(st: string) { return st.split('.')[1]; diff --git a/x-pack/plugins/ingest_manager/server/services/epm/packages/remove.ts b/x-pack/plugins/ingest_manager/server/services/epm/packages/remove.ts index 9b506a2d055a7..a5650f6cfa871 100644 --- a/x-pack/plugins/ingest_manager/server/services/epm/packages/remove.ts +++ b/x-pack/plugins/ingest_manager/server/services/epm/packages/remove.ts @@ -6,7 +6,7 @@ import { SavedObjectsClientContract } from 'src/core/server'; import Boom from 'boom'; -import { PACKAGES_SAVED_OBJECT_TYPE, DATASOURCE_SAVED_OBJECT_TYPE } from '../../../constants'; +import { PACKAGES_SAVED_OBJECT_TYPE, PACKAGE_CONFIG_SAVED_OBJECT_TYPE } from '../../../constants'; import { AssetReference, AssetType, ElasticsearchAssetType } from '../../../types'; import { CallESAsCurrentUser } from '../../../types'; import { getInstallation, savedObjectTypes } from './index'; @@ -28,7 +28,7 @@ export async function removeInstallation(options: { const installedObjects = installation.installed || []; const { total } = await datasourceService.list(savedObjectsClient, { - kuery: `${DATASOURCE_SAVED_OBJECT_TYPE}.package.name:${pkgName}`, + kuery: `${PACKAGE_CONFIG_SAVED_OBJECT_TYPE}.package.name:${pkgName}`, page: 0, perPage: 0, }); From 482eebbb97d69a168c96f8a291bc885f2c45b8b1 Mon Sep 17 00:00:00 2001 From: Jen Huang Date: Fri, 26 Jun 2020 13:03:54 -0700 Subject: [PATCH 02/16] Pluralize `ingest-package-configs` for consistency --- .../plugins/ingest_manager/common/constants/package_config.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/x-pack/plugins/ingest_manager/common/constants/package_config.ts b/x-pack/plugins/ingest_manager/common/constants/package_config.ts index 0c961db405562..e7d5ef67f7253 100644 --- a/x-pack/plugins/ingest_manager/common/constants/package_config.ts +++ b/x-pack/plugins/ingest_manager/common/constants/package_config.ts @@ -4,4 +4,4 @@ * you may not use this file except in compliance with the Elastic License. */ -export const PACKAGE_CONFIG_SAVED_OBJECT_TYPE = 'ingest-package-config'; +export const PACKAGE_CONFIG_SAVED_OBJECT_TYPE = 'ingest-package-configs'; From f000015604b78fdf3c075c1c64b85bdd9346a013 Mon Sep 17 00:00:00 2001 From: Jen Huang Date: Fri, 26 Jun 2020 13:48:56 -0700 Subject: [PATCH 03/16] Rename `Datasource`-related types to `PackageConfig`, update all references (does not include actual type definition changes yet) --- .../datasources_to_agent_inputs.test.ts | 6 +- .../services/datasources_to_agent_inputs.ts | 4 +- .../common/services/package_to_config.ts | 34 ++++----- .../common/types/models/agent_config.ts | 8 +-- .../common/types/models/datasource.ts | 70 ------------------- .../ingest_manager/common/types/models/epm.ts | 53 -------------- .../common/types/models/index.ts | 2 +- .../common/types/models/package_config.ts | 70 +++++++++++++++++++ .../common/types/rest_spec/datasource.ts | 12 ++-- .../custom_configure_datasource.tsx | 4 +- .../components/datasource_input_config.tsx | 6 +- .../components/datasource_input_panel.tsx | 14 ++-- .../datasource_input_stream_config.tsx | 14 ++-- .../create_datasource_page/index.tsx | 8 +-- .../services/validate_datasource.test.ts | 6 +- .../services/validate_datasource.ts | 16 ++--- .../step_configure_datasource.tsx | 8 +-- .../step_define_datasource.tsx | 8 +-- .../datasources/datasources_table.tsx | 6 +- .../components/datasources/index.tsx | 4 +- .../edit_datasource_page/index.tsx | 8 +-- .../agent_config_datasource_badges.tsx | 4 +- .../ingest_manager/types/index.ts | 10 +-- .../types/intra_app_route_state.ts | 4 +- x-pack/plugins/ingest_manager/public/index.ts | 2 +- .../plugins/ingest_manager/server/plugin.ts | 4 +- .../server/routes/agent_config/handlers.ts | 33 ++++----- .../server/routes/datasource/handlers.ts | 6 +- .../server/services/agent_config.ts | 8 +-- .../server/services/datasource.ts | 59 ++++++++-------- .../server/services/epm/agent/agent.ts | 6 +- .../ingest_manager/server/services/setup.ts | 4 +- .../ingest_manager/server/types/index.tsx | 10 +-- .../common/endpoint/types.ts | 8 +-- .../policy/store/policy_list/index.test.ts | 14 ++-- .../store/policy_list/services/ingest.test.ts | 6 +- .../store/policy_list/services/ingest.ts | 4 +- .../server/endpoint/ingest_integration.ts | 6 +- 38 files changed, 252 insertions(+), 297 deletions(-) delete mode 100644 x-pack/plugins/ingest_manager/common/types/models/datasource.ts create mode 100644 x-pack/plugins/ingest_manager/common/types/models/package_config.ts diff --git a/x-pack/plugins/ingest_manager/common/services/datasources_to_agent_inputs.test.ts b/x-pack/plugins/ingest_manager/common/services/datasources_to_agent_inputs.test.ts index 538951ff10399..11b0378eda571 100644 --- a/x-pack/plugins/ingest_manager/common/services/datasources_to_agent_inputs.test.ts +++ b/x-pack/plugins/ingest_manager/common/services/datasources_to_agent_inputs.test.ts @@ -3,11 +3,11 @@ * or more contributor license agreements. Licensed under the Elastic License; * you may not use this file except in compliance with the Elastic License. */ -import { Datasource, DatasourceInput } from '../types'; +import { PackageConfig, PackageConfigInput } from '../types'; import { storedDatasourcesToAgentInputs } from './datasources_to_agent_inputs'; describe('Ingest Manager - storedDatasourcesToAgentInputs', () => { - const mockDatasource: Datasource = { + const mockDatasource: PackageConfig = { id: 'some-uuid', name: 'mock-datasource', description: '', @@ -23,7 +23,7 @@ describe('Ingest Manager - storedDatasourcesToAgentInputs', () => { revision: 1, }; - const mockInput: DatasourceInput = { + const mockInput: PackageConfigInput = { type: 'test-logs', enabled: true, vars: { diff --git a/x-pack/plugins/ingest_manager/common/services/datasources_to_agent_inputs.ts b/x-pack/plugins/ingest_manager/common/services/datasources_to_agent_inputs.ts index c6c5d784396db..12e2994a9f306 100644 --- a/x-pack/plugins/ingest_manager/common/services/datasources_to_agent_inputs.ts +++ b/x-pack/plugins/ingest_manager/common/services/datasources_to_agent_inputs.ts @@ -3,11 +3,11 @@ * or more contributor license agreements. Licensed under the Elastic License; * you may not use this file except in compliance with the Elastic License. */ -import { Datasource, FullAgentConfigInput, FullAgentConfigInputStream } from '../types'; +import { PackageConfig, FullAgentConfigInput, FullAgentConfigInputStream } from '../types'; import { DEFAULT_OUTPUT } from '../constants'; export const storedDatasourcesToAgentInputs = ( - datasources: Datasource[] + datasources: PackageConfig[] ): FullAgentConfigInput[] => { const fullInputs: FullAgentConfigInput[] = []; diff --git a/x-pack/plugins/ingest_manager/common/services/package_to_config.ts b/x-pack/plugins/ingest_manager/common/services/package_to_config.ts index 1817077e97f9c..f5661d7677f5e 100644 --- a/x-pack/plugins/ingest_manager/common/services/package_to_config.ts +++ b/x-pack/plugins/ingest_manager/common/services/package_to_config.ts @@ -8,12 +8,12 @@ import { RegistryConfigTemplate, RegistryVarsEntry, RegistryStream, - Datasource, - DatasourceConfigRecord, - DatasourceConfigRecordEntry, - DatasourceInput, - DatasourceInputStream, - NewDatasource, + PackageConfig, + PackageConfigConfigRecord, + PackageConfigConfigRecordEntry, + PackageConfigInput, + PackageConfigInputStream, + NewPackageConfig, } from '../types'; const getStreamsForInputType = ( @@ -42,8 +42,10 @@ const getStreamsForInputType = ( /* * This service creates a datasource inputs definition from defaults provided in package info */ -export const packageToConfigDatasourceInputs = (packageInfo: PackageInfo): Datasource['inputs'] => { - const inputs: Datasource['inputs'] = []; +export const packageToConfigDatasourceInputs = ( + packageInfo: PackageInfo +): PackageConfig['inputs'] => { + const inputs: PackageConfig['inputs'] = []; // Assume package will only ever ship one datasource for now const packageDatasource: RegistryConfigTemplate | null = @@ -57,10 +59,10 @@ export const packageToConfigDatasourceInputs = (packageInfo: PackageInfo): Datas packageDatasource.inputs.forEach((packageInput) => { // Reduces registry var def into config object entry const varsReducer = ( - configObject: DatasourceConfigRecord, + configObject: PackageConfigConfigRecord, registryVar: RegistryVarsEntry - ): DatasourceConfigRecord => { - const configEntry: DatasourceConfigRecordEntry = { + ): PackageConfigConfigRecord => { + const configEntry: PackageConfigConfigRecordEntry = { value: !registryVar.default && registryVar.multi ? [] : registryVar.default, }; if (registryVar.type) { @@ -71,11 +73,11 @@ export const packageToConfigDatasourceInputs = (packageInfo: PackageInfo): Datas }; // Map each package input stream into datasource input stream - const streams: DatasourceInputStream[] = getStreamsForInputType( + const streams: PackageConfigInputStream[] = getStreamsForInputType( packageInput.type, packageInfo ).map((packageStream) => { - const stream: DatasourceInputStream = { + const stream: PackageConfigInputStream = { id: `${packageInput.type}-${packageStream.dataset.name}`, enabled: packageStream.enabled === false ? false : true, dataset: { @@ -89,7 +91,7 @@ export const packageToConfigDatasourceInputs = (packageInfo: PackageInfo): Datas return stream; }); - const input: DatasourceInput = { + const input: PackageConfigInput = { type: packageInput.type, enabled: streams.length ? !!streams.find((stream) => stream.enabled) : true, streams, @@ -107,7 +109,7 @@ export const packageToConfigDatasourceInputs = (packageInfo: PackageInfo): Datas }; /** - * Builds a `NewDatasource` structure based on a package + * Builds a `NewPackageConfig` structure based on a package * * @param packageInfo * @param configId @@ -121,7 +123,7 @@ export const packageToConfigDatasource = ( datasourceName?: string, namespace?: string, description?: string -): NewDatasource => { +): NewPackageConfig => { return { name: datasourceName || `${packageInfo.name}-1`, namespace, diff --git a/x-pack/plugins/ingest_manager/common/types/models/agent_config.ts b/x-pack/plugins/ingest_manager/common/types/models/agent_config.ts index 0d7dc13af7a30..721120c832d15 100644 --- a/x-pack/plugins/ingest_manager/common/types/models/agent_config.ts +++ b/x-pack/plugins/ingest_manager/common/types/models/agent_config.ts @@ -3,7 +3,7 @@ * or more contributor license agreements. Licensed under the Elastic License; * you may not use this file except in compliance with the Elastic License. */ -import { Datasource, DatasourcePackage, DatasourceInputStream } from './datasource'; +import { PackageConfig, PackageConfigPackage, PackageConfigInputStream } from './package_config'; import { Output } from './output'; export enum AgentConfigStatus { @@ -22,7 +22,7 @@ export interface NewAgentConfig { export interface AgentConfig extends NewAgentConfig { id: string; status: AgentConfigStatus; - datasources: string[] | Datasource[]; + datasources: string[] | PackageConfig[]; updated_at: string; updated_by: string; revision: number; @@ -30,7 +30,7 @@ export interface AgentConfig extends NewAgentConfig { export type AgentConfigSOAttributes = Omit; -export type FullAgentConfigInputStream = Pick & { +export type FullAgentConfigInputStream = Pick & { dataset: { name: string }; [key: string]: any; }; @@ -42,7 +42,7 @@ export interface FullAgentConfigInput { dataset: { namespace: string }; use_output: string; meta?: { - package?: Pick; + package?: Pick; [key: string]: unknown; }; streams: FullAgentConfigInputStream[]; diff --git a/x-pack/plugins/ingest_manager/common/types/models/datasource.ts b/x-pack/plugins/ingest_manager/common/types/models/datasource.ts deleted file mode 100644 index aae65bb003995..0000000000000 --- a/x-pack/plugins/ingest_manager/common/types/models/datasource.ts +++ /dev/null @@ -1,70 +0,0 @@ -/* - * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one - * or more contributor license agreements. Licensed under the Elastic License; - * you may not use this file except in compliance with the Elastic License. - */ - -export interface DatasourcePackage { - name: string; - title: string; - version: string; -} - -export interface DatasourceConfigRecordEntry { - type?: string; - value?: any; -} - -export type DatasourceConfigRecord = Record; - -export interface NewDatasourceInputStream { - id: string; - enabled: boolean; - dataset: { - name: string; - type: string; - }; - processors?: string[]; - config?: DatasourceConfigRecord; - vars?: DatasourceConfigRecord; -} - -export interface DatasourceInputStream extends NewDatasourceInputStream { - agent_stream?: any; -} - -export interface NewDatasourceInput { - type: string; - enabled: boolean; - processors?: string[]; - config?: DatasourceConfigRecord; - vars?: DatasourceConfigRecord; - streams: NewDatasourceInputStream[]; -} - -export interface DatasourceInput extends Omit { - streams: DatasourceInputStream[]; -} - -export interface NewDatasource { - name: string; - description?: string; - namespace?: string; - config_id: string; - enabled: boolean; - package?: DatasourcePackage; - output_id: string; - inputs: NewDatasourceInput[]; -} - -export interface Datasource extends Omit { - id: string; - inputs: DatasourceInput[]; - revision: number; - updated_at: string; - updated_by: string; - created_at: string; - created_by: string; -} - -export type DatasourceSOAttributes = Omit; diff --git a/x-pack/plugins/ingest_manager/common/types/models/epm.ts b/x-pack/plugins/ingest_manager/common/types/models/epm.ts index 370e1df102b94..f45924c30faad 100644 --- a/x-pack/plugins/ingest_manager/common/types/models/epm.ts +++ b/x-pack/plugins/ingest_manager/common/types/models/epm.ts @@ -282,56 +282,3 @@ export interface TemplateRef { templateName: string; indexTemplate: IndexTemplate; } - -type FullAgentConfig = { - id: string; - outputs: { - [x: string]: { - [x: string]: any; - type: OutputType; - hosts?: string[] | undefined; - ca_sha256?: string | undefined; - api_key?: string | undefined; - }; - }; - inputs: { - [x: string]: any; - id: string; - name: string; - type: string; - dataset: { - namespace: string; - }; - use_output: string; - meta?: - | { - [x: string]: unknown; - package?: - | { - name: string; - version: string; - } - | undefined; - } - | undefined; - streams: { - [x: string]: any; - id: string; - processors?: string[] | undefined; - dataset: { - name: string; - }; - }[]; - }[]; - revision?: number | undefined; - settings?: - | { - monitoring: { - use_output?: string | undefined; - enabled: boolean; - metrics: boolean; - logs: boolean; - }; - } - | undefined; -}; diff --git a/x-pack/plugins/ingest_manager/common/types/models/index.ts b/x-pack/plugins/ingest_manager/common/types/models/index.ts index 2310fdd54a719..8ad716a4ba768 100644 --- a/x-pack/plugins/ingest_manager/common/types/models/index.ts +++ b/x-pack/plugins/ingest_manager/common/types/models/index.ts @@ -6,7 +6,7 @@ export * from './agent'; export * from './agent_config'; -export * from './datasource'; +export * from './package_config'; export * from './data_stream'; export * from './output'; export * from './epm'; diff --git a/x-pack/plugins/ingest_manager/common/types/models/package_config.ts b/x-pack/plugins/ingest_manager/common/types/models/package_config.ts new file mode 100644 index 0000000000000..f6300d35def05 --- /dev/null +++ b/x-pack/plugins/ingest_manager/common/types/models/package_config.ts @@ -0,0 +1,70 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License; + * you may not use this file except in compliance with the Elastic License. + */ + +export interface PackageConfigPackage { + name: string; + title: string; + version: string; +} + +export interface PackageConfigConfigRecordEntry { + type?: string; + value?: any; +} + +export type PackageConfigConfigRecord = Record; + +export interface NewPackageConfigInputStream { + id: string; + enabled: boolean; + dataset: { + name: string; + type: string; + }; + processors?: string[]; + config?: PackageConfigConfigRecord; + vars?: PackageConfigConfigRecord; +} + +export interface PackageConfigInputStream extends NewPackageConfigInputStream { + agent_stream?: any; +} + +export interface NewPackageConfigInput { + type: string; + enabled: boolean; + processors?: string[]; + config?: PackageConfigConfigRecord; + vars?: PackageConfigConfigRecord; + streams: NewPackageConfigInputStream[]; +} + +export interface PackageConfigInput extends Omit { + streams: PackageConfigInputStream[]; +} + +export interface NewPackageConfig { + name: string; + description?: string; + namespace?: string; + config_id: string; + enabled: boolean; + package?: PackageConfigPackage; + output_id: string; + inputs: NewPackageConfigInput[]; +} + +export interface PackageConfig extends Omit { + id: string; + inputs: PackageConfigInput[]; + revision: number; + updated_at: string; + updated_by: string; + created_at: string; + created_by: string; +} + +export type PackageConfigSOAttributes = Omit; diff --git a/x-pack/plugins/ingest_manager/common/types/rest_spec/datasource.ts b/x-pack/plugins/ingest_manager/common/types/rest_spec/datasource.ts index 61f1f15d49259..8d7d9cb38e74e 100644 --- a/x-pack/plugins/ingest_manager/common/types/rest_spec/datasource.ts +++ b/x-pack/plugins/ingest_manager/common/types/rest_spec/datasource.ts @@ -3,7 +3,7 @@ * or more contributor license agreements. Licensed under the Elastic License; * you may not use this file except in compliance with the Elastic License. */ -import { Datasource, NewDatasource } from '../models'; +import { PackageConfig, NewPackageConfig } from '../models'; export interface GetDatasourcesRequest { query: { @@ -14,7 +14,7 @@ export interface GetDatasourcesRequest { } export interface GetDatasourcesResponse { - items: Datasource[]; + items: PackageConfig[]; total: number; page: number; perPage: number; @@ -28,21 +28,21 @@ export interface GetOneDatasourceRequest { } export interface GetOneDatasourceResponse { - item: Datasource; + item: PackageConfig; success: boolean; } export interface CreateDatasourceRequest { - body: NewDatasource; + body: NewPackageConfig; } export interface CreateDatasourceResponse { - item: Datasource; + item: PackageConfig; success: boolean; } export type UpdateDatasourceRequest = GetOneDatasourceRequest & { - body: NewDatasource; + body: NewPackageConfig; }; export type UpdateDatasourceResponse = CreateDatasourceResponse; diff --git a/x-pack/plugins/ingest_manager/public/applications/ingest_manager/sections/agent_config/create_datasource_page/components/custom_configure_datasource.tsx b/x-pack/plugins/ingest_manager/public/applications/ingest_manager/sections/agent_config/create_datasource_page/components/custom_configure_datasource.tsx index 4263feb7cd8c7..4cdc0d20fac39 100644 --- a/x-pack/plugins/ingest_manager/public/applications/ingest_manager/sections/agent_config/create_datasource_page/components/custom_configure_datasource.tsx +++ b/x-pack/plugins/ingest_manager/public/applications/ingest_manager/sections/agent_config/create_datasource_page/components/custom_configure_datasource.tsx @@ -6,13 +6,13 @@ import React from 'react'; import { FormattedMessage } from '@kbn/i18n/react'; import { EuiEmptyPrompt, EuiText } from '@elastic/eui'; -import { NewDatasource } from '../../../../types'; +import { NewPackageConfig } from '../../../../types'; import { CreateDatasourceFrom } from '../types'; export interface CustomConfigureDatasourceProps { packageName: string; from: CreateDatasourceFrom; - datasource: NewDatasource; + datasource: NewPackageConfig; datasourceId?: string; } diff --git a/x-pack/plugins/ingest_manager/public/applications/ingest_manager/sections/agent_config/create_datasource_page/components/datasource_input_config.tsx b/x-pack/plugins/ingest_manager/public/applications/ingest_manager/sections/agent_config/create_datasource_page/components/datasource_input_config.tsx index 6eed7e74d6bc6..3e74a394f8a7d 100644 --- a/x-pack/plugins/ingest_manager/public/applications/ingest_manager/sections/agent_config/create_datasource_page/components/datasource_input_config.tsx +++ b/x-pack/plugins/ingest_manager/public/applications/ingest_manager/sections/agent_config/create_datasource_page/components/datasource_input_config.tsx @@ -15,14 +15,14 @@ import { EuiTitle, EuiIconTip, } from '@elastic/eui'; -import { DatasourceInput, RegistryVarsEntry } from '../../../../types'; +import { PackageConfigInput, RegistryVarsEntry } from '../../../../types'; import { isAdvancedVar, DatasourceConfigValidationResults, validationHasErrors } from '../services'; import { DatasourceInputVarField } from './datasource_input_var_field'; export const DatasourceInputConfig: React.FunctionComponent<{ packageInputVars?: RegistryVarsEntry[]; - datasourceInput: DatasourceInput; - updateDatasourceInput: (updatedInput: Partial) => void; + datasourceInput: PackageConfigInput; + updateDatasourceInput: (updatedInput: Partial) => void; inputVarsValidationResults: DatasourceConfigValidationResults; forceShowErrors?: boolean; }> = ({ diff --git a/x-pack/plugins/ingest_manager/public/applications/ingest_manager/sections/agent_config/create_datasource_page/components/datasource_input_panel.tsx b/x-pack/plugins/ingest_manager/public/applications/ingest_manager/sections/agent_config/create_datasource_page/components/datasource_input_panel.tsx index 6f6fa5aaa7f3e..4dc2b6ed73404 100644 --- a/x-pack/plugins/ingest_manager/public/applications/ingest_manager/sections/agent_config/create_datasource_page/components/datasource_input_panel.tsx +++ b/x-pack/plugins/ingest_manager/public/applications/ingest_manager/sections/agent_config/create_datasource_page/components/datasource_input_panel.tsx @@ -20,8 +20,8 @@ import { EuiIconTip, } from '@elastic/eui'; import { - DatasourceInput, - DatasourceInputStream, + PackageConfigInput, + PackageConfigInputStream, RegistryInput, RegistryStream, } from '../../../../types'; @@ -38,8 +38,8 @@ const FlushHorizontalRule = styled(EuiHorizontalRule)` export const DatasourceInputPanel: React.FunctionComponent<{ packageInput: RegistryInput; packageInputStreams: Array; - datasourceInput: DatasourceInput; - updateDatasourceInput: (updatedInput: Partial) => void; + datasourceInput: PackageConfigInput; + updateDatasourceInput: (updatedInput: Partial) => void; inputValidationResults: DatasourceInputValidationResults; forceShowErrors?: boolean; }> = ({ @@ -184,7 +184,9 @@ export const DatasourceInputPanel: React.FunctionComponent<{ ) => { + updatePackageConfigInputStream={( + updatedStream: Partial + ) => { const indexOfUpdatedStream = datasourceInput.streams.findIndex( (stream) => stream.dataset.name === packageInputStream.dataset.name ); @@ -194,7 +196,7 @@ export const DatasourceInputPanel: React.FunctionComponent<{ ...updatedStream, }; - const updatedInput: Partial = { + const updatedInput: Partial = { streams: newStreams, }; diff --git a/x-pack/plugins/ingest_manager/public/applications/ingest_manager/sections/agent_config/create_datasource_page/components/datasource_input_stream_config.tsx b/x-pack/plugins/ingest_manager/public/applications/ingest_manager/sections/agent_config/create_datasource_page/components/datasource_input_stream_config.tsx index f697ef736ef70..436f652143285 100644 --- a/x-pack/plugins/ingest_manager/public/applications/ingest_manager/sections/agent_config/create_datasource_page/components/datasource_input_stream_config.tsx +++ b/x-pack/plugins/ingest_manager/public/applications/ingest_manager/sections/agent_config/create_datasource_page/components/datasource_input_stream_config.tsx @@ -16,20 +16,20 @@ import { EuiTextColor, EuiIconTip, } from '@elastic/eui'; -import { DatasourceInputStream, RegistryStream, RegistryVarsEntry } from '../../../../types'; +import { PackageConfigInputStream, RegistryStream, RegistryVarsEntry } from '../../../../types'; import { isAdvancedVar, DatasourceConfigValidationResults, validationHasErrors } from '../services'; import { DatasourceInputVarField } from './datasource_input_var_field'; export const DatasourceInputStreamConfig: React.FunctionComponent<{ packageInputStream: RegistryStream; - datasourceInputStream: DatasourceInputStream; - updateDatasourceInputStream: (updatedStream: Partial) => void; + datasourceInputStream: PackageConfigInputStream; + updatePackageConfigInputStream: (updatedStream: Partial) => void; inputStreamValidationResults: DatasourceConfigValidationResults; forceShowErrors?: boolean; }> = ({ packageInputStream, datasourceInputStream, - updateDatasourceInputStream, + updatePackageConfigInputStream, inputStreamValidationResults, forceShowErrors, }) => { @@ -83,7 +83,7 @@ export const DatasourceInputStreamConfig: React.FunctionComponent<{ checked={datasourceInputStream.enabled} onChange={(e) => { const enabled = e.target.checked; - updateDatasourceInputStream({ + updatePackageConfigInputStream({ enabled, }); }} @@ -108,7 +108,7 @@ export const DatasourceInputStreamConfig: React.FunctionComponent<{ varDef={varDef} value={value} onChange={(newValue: any) => { - updateDatasourceInputStream({ + updatePackageConfigInputStream({ vars: { ...datasourceInputStream.vars, [varName]: { @@ -152,7 +152,7 @@ export const DatasourceInputStreamConfig: React.FunctionComponent<{ varDef={varDef} value={value} onChange={(newValue: any) => { - updateDatasourceInputStream({ + updatePackageConfigInputStream({ vars: { ...datasourceInputStream.vars, [varName]: { diff --git a/x-pack/plugins/ingest_manager/public/applications/ingest_manager/sections/agent_config/create_datasource_page/index.tsx b/x-pack/plugins/ingest_manager/public/applications/ingest_manager/sections/agent_config/create_datasource_page/index.tsx index 18c4f2f82ac01..536a0782ffb5f 100644 --- a/x-pack/plugins/ingest_manager/public/applications/ingest_manager/sections/agent_config/create_datasource_page/index.tsx +++ b/x-pack/plugins/ingest_manager/public/applications/ingest_manager/sections/agent_config/create_datasource_page/index.tsx @@ -20,7 +20,7 @@ import { EuiStepProps } from '@elastic/eui/src/components/steps/step'; import { AgentConfig, PackageInfo, - NewDatasource, + NewPackageConfig, CreateDatasourceRouteState, } from '../../../types'; import { @@ -91,7 +91,7 @@ export const CreateDatasourcePage: React.FunctionComponent = () => { const [agentCount, setAgentCount] = useState(0); // New datasource state - const [datasource, setDatasource] = useState({ + const [datasource, setDatasource] = useState({ name: '', description: '', config_id: '', @@ -147,7 +147,7 @@ export const CreateDatasourcePage: React.FunctionComponent = () => { const hasErrors = validationResults ? validationHasErrors(validationResults) : false; // Update datasource method - const updateDatasource = (updatedFields: Partial) => { + const updateDatasource = (updatedFields: Partial) => { const newDatasource = { ...datasource, ...updatedFields, @@ -167,7 +167,7 @@ export const CreateDatasourcePage: React.FunctionComponent = () => { } }; - const updateDatasourceValidation = (newDatasource?: NewDatasource) => { + const updateDatasourceValidation = (newDatasource?: NewPackageConfig) => { if (packageInfo) { const newValidationResult = validateDatasource(newDatasource || datasource, packageInfo); setValidationResults(newValidationResult); diff --git a/x-pack/plugins/ingest_manager/public/applications/ingest_manager/sections/agent_config/create_datasource_page/services/validate_datasource.test.ts b/x-pack/plugins/ingest_manager/public/applications/ingest_manager/sections/agent_config/create_datasource_page/services/validate_datasource.test.ts index 64facf01d474a..cdf49290ea18e 100644 --- a/x-pack/plugins/ingest_manager/public/applications/ingest_manager/sections/agent_config/create_datasource_page/services/validate_datasource.test.ts +++ b/x-pack/plugins/ingest_manager/public/applications/ingest_manager/sections/agent_config/create_datasource_page/services/validate_datasource.test.ts @@ -6,7 +6,7 @@ import { PackageInfo, InstallationStatus, - NewDatasource, + NewPackageConfig, RegistryConfigTemplate, } from '../../../../types'; import { validateDatasource, validationHasErrors } from './validate_datasource'; @@ -141,7 +141,7 @@ describe('Ingest Manager - validateDatasource()', () => { ], } as unknown) as PackageInfo; - const validDatasource: NewDatasource = { + const validDatasource: NewPackageConfig = { name: 'datasource1-1', config_id: 'test-config', enabled: true, @@ -225,7 +225,7 @@ describe('Ingest Manager - validateDatasource()', () => { ], }; - const invalidDatasource: NewDatasource = { + const invalidDatasource: NewPackageConfig = { ...validDatasource, name: '', inputs: [ diff --git a/x-pack/plugins/ingest_manager/public/applications/ingest_manager/sections/agent_config/create_datasource_page/services/validate_datasource.ts b/x-pack/plugins/ingest_manager/public/applications/ingest_manager/sections/agent_config/create_datasource_page/services/validate_datasource.ts index 30dca4a5fbf81..0525e23275484 100644 --- a/x-pack/plugins/ingest_manager/public/applications/ingest_manager/sections/agent_config/create_datasource_page/services/validate_datasource.ts +++ b/x-pack/plugins/ingest_manager/public/applications/ingest_manager/sections/agent_config/create_datasource_page/services/validate_datasource.ts @@ -7,10 +7,10 @@ import { i18n } from '@kbn/i18n'; import { safeLoad } from 'js-yaml'; import { getFlattenedObject } from '../../../../services'; import { - NewDatasource, - DatasourceInput, - DatasourceInputStream, - DatasourceConfigRecordEntry, + NewPackageConfig, + PackageConfigInput, + PackageConfigInputStream, + PackageConfigConfigRecordEntry, PackageInfo, RegistryInput, RegistryStream, @@ -26,13 +26,13 @@ export interface DatasourceConfigValidationResults { } export type DatasourceInputValidationResults = DatasourceConfigValidationResults & { - streams?: Record; + streams?: Record; }; export interface DatasourceValidationResults { name: Errors; description: Errors; - inputs: Record | null; + inputs: Record | null; } /* @@ -40,7 +40,7 @@ export interface DatasourceValidationResults { * Note: this method assumes that `datasource` is correctly structured for the given package */ export const validateDatasource = ( - datasource: NewDatasource, + datasource: NewPackageConfig, packageInfo: PackageInfo ): DatasourceValidationResults => { const validationResults: DatasourceValidationResults = { @@ -162,7 +162,7 @@ export const validateDatasource = ( }; const validateDatasourceConfig = ( - configEntry: DatasourceConfigRecordEntry, + configEntry: PackageConfigConfigRecordEntry, varDef: RegistryVarsEntry ): string[] | null => { const errors = []; diff --git a/x-pack/plugins/ingest_manager/public/applications/ingest_manager/sections/agent_config/create_datasource_page/step_configure_datasource.tsx b/x-pack/plugins/ingest_manager/public/applications/ingest_manager/sections/agent_config/create_datasource_page/step_configure_datasource.tsx index c319dbc08b2c6..4d7bb47e899bb 100644 --- a/x-pack/plugins/ingest_manager/public/applications/ingest_manager/sections/agent_config/create_datasource_page/step_configure_datasource.tsx +++ b/x-pack/plugins/ingest_manager/public/applications/ingest_manager/sections/agent_config/create_datasource_page/step_configure_datasource.tsx @@ -7,7 +7,7 @@ import React from 'react'; import { FormattedMessage } from '@kbn/i18n/react'; import { EuiPanel, EuiFlexGroup, EuiFlexItem, EuiSpacer, EuiCallOut } from '@elastic/eui'; import { i18n } from '@kbn/i18n'; -import { PackageInfo, RegistryStream, NewDatasource, DatasourceInput } from '../../../types'; +import { PackageInfo, RegistryStream, NewPackageConfig, PackageConfigInput } from '../../../types'; import { Loading } from '../../../components'; import { DatasourceValidationResults, validationHasErrors } from './services'; import { DatasourceInputPanel, CustomConfigureDatasource } from './components'; @@ -38,9 +38,9 @@ const findStreamsForInputType = ( export const StepConfigureDatasource: React.FunctionComponent<{ from?: CreateDatasourceFrom; packageInfo: PackageInfo; - datasource: NewDatasource; + datasource: NewPackageConfig; datasourceId?: string; - updateDatasource: (fields: Partial) => void; + updateDatasource: (fields: Partial) => void; validationResults: DatasourceValidationResults; submitAttempted: boolean; }> = ({ @@ -73,7 +73,7 @@ export const StepConfigureDatasource: React.FunctionComponent<{ packageInput={packageInput} packageInputStreams={packageInputStreams} datasourceInput={datasourceInput} - updateDatasourceInput={(updatedInput: Partial) => { + updateDatasourceInput={(updatedInput: Partial) => { const indexOfUpdatedInput = datasource.inputs.findIndex( (input) => input.type === packageInput.type ); diff --git a/x-pack/plugins/ingest_manager/public/applications/ingest_manager/sections/agent_config/create_datasource_page/step_define_datasource.tsx b/x-pack/plugins/ingest_manager/public/applications/ingest_manager/sections/agent_config/create_datasource_page/step_define_datasource.tsx index 2651615b458f7..958a4a8c6eb39 100644 --- a/x-pack/plugins/ingest_manager/public/applications/ingest_manager/sections/agent_config/create_datasource_page/step_define_datasource.tsx +++ b/x-pack/plugins/ingest_manager/public/applications/ingest_manager/sections/agent_config/create_datasource_page/step_define_datasource.tsx @@ -15,7 +15,7 @@ import { EuiText, EuiComboBox, } from '@elastic/eui'; -import { AgentConfig, PackageInfo, Datasource, NewDatasource } from '../../../types'; +import { AgentConfig, PackageInfo, PackageConfig, NewPackageConfig } from '../../../types'; import { packageToConfigDatasourceInputs } from '../../../services'; import { Loading } from '../../../components'; import { DatasourceValidationResults } from './services'; @@ -23,8 +23,8 @@ import { DatasourceValidationResults } from './services'; export const StepDefineDatasource: React.FunctionComponent<{ agentConfig: AgentConfig; packageInfo: PackageInfo; - datasource: NewDatasource; - updateDatasource: (fields: Partial) => void; + datasource: NewPackageConfig; + updateDatasource: (fields: Partial) => void; validationResults: DatasourceValidationResults; }> = ({ agentConfig, packageInfo, datasource, updateDatasource, validationResults }) => { // Form show/hide states @@ -40,7 +40,7 @@ export const StepDefineDatasource: React.FunctionComponent<{ if (currentPkgKey !== pkgKey) { // Existing datasources on the agent config using the package name, retrieve highest number appended to datasource name const dsPackageNamePattern = new RegExp(`${packageInfo.name}-(\\d+)`); - const dsWithMatchingNames = (agentConfig.datasources as Datasource[]) + const dsWithMatchingNames = (agentConfig.datasources as PackageConfig[]) .filter((ds) => Boolean(ds.name.match(dsPackageNamePattern))) .map((ds) => parseInt(ds.name.match(dsPackageNamePattern)![1], 10)) .sort(); diff --git a/x-pack/plugins/ingest_manager/public/applications/ingest_manager/sections/agent_config/details_page/components/datasources/datasources_table.tsx b/x-pack/plugins/ingest_manager/public/applications/ingest_manager/sections/agent_config/details_page/components/datasources/datasources_table.tsx index caf0c149c0199..f179269019eef 100644 --- a/x-pack/plugins/ingest_manager/public/applications/ingest_manager/sections/agent_config/details_page/components/datasources/datasources_table.tsx +++ b/x-pack/plugins/ingest_manager/public/applications/ingest_manager/sections/agent_config/details_page/components/datasources/datasources_table.tsx @@ -16,13 +16,13 @@ import { EuiFlexGroup, EuiFlexItem, } from '@elastic/eui'; -import { AgentConfig, Datasource } from '../../../../../types'; +import { AgentConfig, PackageConfig } from '../../../../../types'; import { PackageIcon, ContextMenuActions } from '../../../../../components'; import { DatasourceDeleteProvider, DangerEuiContextMenuItem } from '../../../components'; import { useCapabilities, useLink } from '../../../../../hooks'; import { useConfigRefresh } from '../../hooks'; -interface InMemoryDatasource extends Datasource { +interface InMemoryDatasource extends PackageConfig { streams: { total: number; enabled: number }; inputTypes: string[]; packageName?: string; @@ -31,7 +31,7 @@ interface InMemoryDatasource extends Datasource { } interface Props { - datasources: Datasource[]; + datasources: PackageConfig[]; config: AgentConfig; // Pass through props to InMemoryTable loading?: EuiInMemoryTableProps['loading']; diff --git a/x-pack/plugins/ingest_manager/public/applications/ingest_manager/sections/agent_config/details_page/components/datasources/index.tsx b/x-pack/plugins/ingest_manager/public/applications/ingest_manager/sections/agent_config/details_page/components/datasources/index.tsx index 346ccde45f3f0..666e8acf172b6 100644 --- a/x-pack/plugins/ingest_manager/public/applications/ingest_manager/sections/agent_config/details_page/components/datasources/index.tsx +++ b/x-pack/plugins/ingest_manager/public/applications/ingest_manager/sections/agent_config/details_page/components/datasources/index.tsx @@ -5,7 +5,7 @@ */ import React, { memo } from 'react'; -import { AgentConfig, Datasource } from '../../../../../../../../common/types/models'; +import { AgentConfig, PackageConfig } from '../../../../../types'; import { NoDatasources } from './no_datasources'; import { DatasourcesTable } from './datasources_table'; @@ -15,6 +15,6 @@ export const ConfigDatasourcesView = memo<{ config: AgentConfig }>(({ config }) } return ( - + ); }); diff --git a/x-pack/plugins/ingest_manager/public/applications/ingest_manager/sections/agent_config/edit_datasource_page/index.tsx b/x-pack/plugins/ingest_manager/public/applications/ingest_manager/sections/agent_config/edit_datasource_page/index.tsx index af39cb87f18c9..7bed7792e590d 100644 --- a/x-pack/plugins/ingest_manager/public/applications/ingest_manager/sections/agent_config/edit_datasource_page/index.tsx +++ b/x-pack/plugins/ingest_manager/public/applications/ingest_manager/sections/agent_config/edit_datasource_page/index.tsx @@ -16,7 +16,7 @@ import { EuiFlexItem, EuiSpacer, } from '@elastic/eui'; -import { AgentConfig, PackageInfo, NewDatasource } from '../../../types'; +import { AgentConfig, PackageInfo, NewPackageConfig } from '../../../types'; import { useLink, useBreadcrumbs, @@ -69,7 +69,7 @@ export const EditDatasourcePage: React.FunctionComponent = () => { const [loadingError, setLoadingError] = useState(); const [agentConfig, setAgentConfig] = useState(); const [packageInfo, setPackageInfo] = useState(); - const [datasource, setDatasource] = useState({ + const [datasource, setDatasource] = useState({ name: '', description: '', config_id: '', @@ -156,7 +156,7 @@ export const EditDatasourcePage: React.FunctionComponent = () => { const hasErrors = validationResults ? validationHasErrors(validationResults) : false; // Update datasource method - const updateDatasource = (updatedFields: Partial) => { + const updateDatasource = (updatedFields: Partial) => { const newDatasource = { ...datasource, ...updatedFields, @@ -174,7 +174,7 @@ export const EditDatasourcePage: React.FunctionComponent = () => { } }; - const updateDatasourceValidation = (newDatasource?: NewDatasource) => { + const updateDatasourceValidation = (newDatasource?: NewPackageConfig) => { if (packageInfo) { const newValidationResult = validateDatasource(newDatasource || datasource, packageInfo); setValidationResults(newValidationResult); diff --git a/x-pack/plugins/ingest_manager/public/applications/ingest_manager/sections/fleet/components/agent_config_datasource_badges.tsx b/x-pack/plugins/ingest_manager/public/applications/ingest_manager/sections/fleet/components/agent_config_datasource_badges.tsx index 30bc9dc701427..9feb1d65bb56c 100644 --- a/x-pack/plugins/ingest_manager/public/applications/ingest_manager/sections/fleet/components/agent_config_datasource_badges.tsx +++ b/x-pack/plugins/ingest_manager/public/applications/ingest_manager/sections/fleet/components/agent_config_datasource_badges.tsx @@ -6,7 +6,7 @@ import React from 'react'; import { FormattedMessage } from '@kbn/i18n/react'; import { EuiSpacer, EuiText, EuiFlexGroup, EuiFlexItem, EuiBadge } from '@elastic/eui'; -import { Datasource } from '../../../types'; +import { PackageConfig } from '../../../types'; import { useGetOneAgentConfig } from '../../../hooks'; import { PackageIcon } from '../../../components/package_icon'; @@ -34,7 +34,7 @@ export const AgentConfigDatasourceBadges: React.FunctionComponent = ({ ag /> - {(agentConfig.datasources as Datasource[]).map((datasource, idx) => { + {(agentConfig.datasources as PackageConfig[]).map((datasource, idx) => { if (!datasource.package) { return null; } diff --git a/x-pack/plugins/ingest_manager/public/applications/ingest_manager/types/index.ts b/x-pack/plugins/ingest_manager/public/applications/ingest_manager/types/index.ts index 90315f38fd476..30e1d6b870bae 100644 --- a/x-pack/plugins/ingest_manager/public/applications/ingest_manager/types/index.ts +++ b/x-pack/plugins/ingest_manager/public/applications/ingest_manager/types/index.ts @@ -13,11 +13,11 @@ export { NewAgentConfig, AgentEvent, EnrollmentAPIKey, - Datasource, - NewDatasource, - DatasourceInput, - DatasourceInputStream, - DatasourceConfigRecordEntry, + PackageConfig, + NewPackageConfig, + PackageConfigInput, + PackageConfigInputStream, + PackageConfigConfigRecordEntry, Output, DataStream, // API schema - misc setup, status diff --git a/x-pack/plugins/ingest_manager/public/applications/ingest_manager/types/intra_app_route_state.ts b/x-pack/plugins/ingest_manager/public/applications/ingest_manager/types/intra_app_route_state.ts index b2948686ff6e5..a736698fea150 100644 --- a/x-pack/plugins/ingest_manager/public/applications/ingest_manager/types/intra_app_route_state.ts +++ b/x-pack/plugins/ingest_manager/public/applications/ingest_manager/types/intra_app_route_state.ts @@ -5,7 +5,7 @@ */ import { ApplicationStart } from 'kibana/public'; -import { Datasource } from '../../../../common/types/models'; +import { PackageConfig } from './'; /** * Supported routing state for the create datasource page routes @@ -14,7 +14,7 @@ export interface CreateDatasourceRouteState { /** On a successful save of the datasource, use navigate to the given app */ onSaveNavigateTo?: | Parameters - | ((newDatasource: Datasource) => Parameters); + | ((newDatasource: PackageConfig) => Parameters); /** On cancel, navigate to the given app */ onCancelNavigateTo?: Parameters; /** Url to be used on cancel links */ diff --git a/x-pack/plugins/ingest_manager/public/index.ts b/x-pack/plugins/ingest_manager/public/index.ts index ac56349b30c13..4ecef9cdb4710 100644 --- a/x-pack/plugins/ingest_manager/public/index.ts +++ b/x-pack/plugins/ingest_manager/public/index.ts @@ -18,5 +18,5 @@ export { registerDatasource, } from './applications/ingest_manager/sections/agent_config/create_datasource_page/components/custom_configure_datasource'; -export { NewDatasource } from './applications/ingest_manager/types'; +export { NewPackageConfig } from './applications/ingest_manager/types'; export * from './applications/ingest_manager/types/intra_app_route_state'; diff --git a/x-pack/plugins/ingest_manager/server/plugin.ts b/x-pack/plugins/ingest_manager/server/plugin.ts index 9943726be5be4..c72cdb572aefe 100644 --- a/x-pack/plugins/ingest_manager/server/plugin.ts +++ b/x-pack/plugins/ingest_manager/server/plugin.ts @@ -45,7 +45,7 @@ import { registerSettingsRoutes, registerAppRoutes, } from './routes'; -import { IngestManagerConfigType, NewDatasource } from '../common'; +import { IngestManagerConfigType, NewPackageConfig } from '../common'; import { appContextService, licenseService, @@ -103,7 +103,7 @@ const allSavedObjectTypes = [ */ export type ExternalCallback = [ 'datasourceCreate', - (newDatasource: NewDatasource) => Promise + (newDatasource: NewPackageConfig) => Promise ]; export type ExternalCallbacksStorage = Map>; diff --git a/x-pack/plugins/ingest_manager/server/routes/agent_config/handlers.ts b/x-pack/plugins/ingest_manager/server/routes/agent_config/handlers.ts index d01b361bd6ca4..9e1628a5c1117 100644 --- a/x-pack/plugins/ingest_manager/server/routes/agent_config/handlers.ts +++ b/x-pack/plugins/ingest_manager/server/routes/agent_config/handlers.ts @@ -20,7 +20,7 @@ import { GetFullAgentConfigRequestSchema, AgentConfig, DefaultPackages, - NewDatasource, + NewPackageConfig, } from '../../types'; import { GetAgentConfigsResponse, @@ -107,21 +107,22 @@ export const createAgentConfigHandler: RequestHandler< const withSysMonitoring = request.query.sys_monitoring ?? false; try { // eslint-disable-next-line prefer-const - let [agentConfig, newSysDatasource] = await Promise.all( - [ - agentConfigService.create(soClient, request.body, { - user, - }), - // If needed, retrieve System package information and build a new Datasource for the system package - // NOTE: we ignore failures in attempting to create datasource, since config might have been created - // successfully - withSysMonitoring - ? datasourceService - .buildDatasourceFromPackage(soClient, DefaultPackages.system) - .catch(() => undefined) - : undefined, - ] - ); + let [agentConfig, newSysDatasource] = await Promise.all< + AgentConfig, + NewPackageConfig | undefined + >([ + agentConfigService.create(soClient, request.body, { + user, + }), + // If needed, retrieve System package information and build a new Datasource for the system package + // NOTE: we ignore failures in attempting to create datasource, since config might have been created + // successfully + withSysMonitoring + ? datasourceService + .buildDatasourceFromPackage(soClient, DefaultPackages.system) + .catch(() => undefined) + : undefined, + ]); // Create the system monitoring datasource and add it to config. if (withSysMonitoring && newSysDatasource !== undefined && agentConfig !== undefined) { diff --git a/x-pack/plugins/ingest_manager/server/routes/datasource/handlers.ts b/x-pack/plugins/ingest_manager/server/routes/datasource/handlers.ts index 4f83d24a846ea..28a8b43f9f548 100644 --- a/x-pack/plugins/ingest_manager/server/routes/datasource/handlers.ts +++ b/x-pack/plugins/ingest_manager/server/routes/datasource/handlers.ts @@ -14,7 +14,7 @@ import { CreateDatasourceRequestSchema, UpdateDatasourceRequestSchema, DeleteDatasourcesRequestSchema, - NewDatasource, + NewPackageConfig, } from '../../types'; import { CreateDatasourceResponse, DeleteDatasourcesResponse } from '../../../common'; @@ -83,7 +83,7 @@ export const createDatasourceHandler: RequestHandler< // If we have external callbacks, then process those now before creating the actual datasource const externalCallbacks = appContextService.getExternalCallbacks('datasourceCreate'); if (externalCallbacks && externalCallbacks.size > 0) { - let updatedNewData: NewDatasource = newData; + let updatedNewData: NewPackageConfig = newData; for (const callback of externalCallbacks) { try { @@ -98,7 +98,7 @@ export const createDatasourceHandler: RequestHandler< } } - // The type `NewDatasource` and the `DatasourceBaseSchema` are incompatible. + // The type `NewPackageConfig` and the `DatasourceBaseSchema` are incompatible. // `NewDatasrouce` defines `namespace` as optional string, which means that `undefined` is a // valid value, however, the schema defines it as string with a minimum length of 1. // Here, we need to cast the value back to the schema type and ignore the TS error. diff --git a/x-pack/plugins/ingest_manager/server/services/agent_config.ts b/x-pack/plugins/ingest_manager/server/services/agent_config.ts index 9c27e9b7a3a7a..bda8d87262be1 100644 --- a/x-pack/plugins/ingest_manager/server/services/agent_config.ts +++ b/x-pack/plugins/ingest_manager/server/services/agent_config.ts @@ -12,7 +12,7 @@ import { AGENT_SAVED_OBJECT_TYPE, } from '../constants'; import { - Datasource, + PackageConfig, NewAgentConfig, AgentConfig, AgentConfigSOAttributes, @@ -202,8 +202,8 @@ class AgentConfigService { // Copy all datasources if (baseAgentConfig.datasources.length) { - const newDatasources = (baseAgentConfig.datasources as Datasource[]).map( - (datasource: Datasource) => { + const newDatasources = (baseAgentConfig.datasources as PackageConfig[]).map( + (datasource: PackageConfig) => { const { id: datasourceId, ...newDatasource } = datasource; return newDatasource; } @@ -373,7 +373,7 @@ class AgentConfigService { {} as FullAgentConfig['outputs'] ), }, - inputs: storedDatasourcesToAgentInputs(config.datasources as Datasource[]), + inputs: storedDatasourcesToAgentInputs(config.datasources as PackageConfig[]), revision: config.revision, ...(config.monitoring_enabled && config.monitoring_enabled.length > 0 ? { diff --git a/x-pack/plugins/ingest_manager/server/services/datasource.ts b/x-pack/plugins/ingest_manager/server/services/datasource.ts index b73d3d3d19803..571160060bad6 100644 --- a/x-pack/plugins/ingest_manager/server/services/datasource.ts +++ b/x-pack/plugins/ingest_manager/server/services/datasource.ts @@ -8,16 +8,16 @@ import { AuthenticatedUser } from '../../../security/server'; import { DeleteDatasourcesResponse, packageToConfigDatasource, - DatasourceInput, - DatasourceInputStream, + PackageConfigInput, + PackageConfigInputStream, PackageInfo, } from '../../common'; import { PACKAGE_CONFIG_SAVED_OBJECT_TYPE } from '../constants'; import { - NewDatasource, - Datasource, + NewPackageConfig, + PackageConfig, ListWithKuery, - DatasourceSOAttributes, + PackageConfigSOAttributes, RegistryPackage, } from '../types'; import { agentConfigService } from './agent_config'; @@ -36,11 +36,11 @@ function getDataset(st: string) { class DatasourceService { public async create( soClient: SavedObjectsClientContract, - datasource: NewDatasource, + datasource: NewPackageConfig, options?: { id?: string; user?: AuthenticatedUser } - ): Promise { + ): Promise { const isoDate = new Date().toISOString(); - const newSo = await soClient.create( + const newSo = await soClient.create( SAVED_OBJECT_TYPE, { ...datasource, @@ -66,12 +66,12 @@ class DatasourceService { public async bulkCreate( soClient: SavedObjectsClientContract, - datasources: NewDatasource[], + datasources: NewPackageConfig[], configId: string, options?: { user?: AuthenticatedUser } - ): Promise { + ): Promise { const isoDate = new Date().toISOString(); - const { saved_objects: newSos } = await soClient.bulkCreate>( + const { saved_objects: newSos } = await soClient.bulkCreate>( datasources.map((datasource) => ({ type: SAVED_OBJECT_TYPE, attributes: { @@ -102,8 +102,11 @@ class DatasourceService { })); } - public async get(soClient: SavedObjectsClientContract, id: string): Promise { - const datasourceSO = await soClient.get(SAVED_OBJECT_TYPE, id); + public async get( + soClient: SavedObjectsClientContract, + id: string + ): Promise { + const datasourceSO = await soClient.get(SAVED_OBJECT_TYPE, id); if (!datasourceSO) { return null; } @@ -121,8 +124,8 @@ class DatasourceService { public async getByIDs( soClient: SavedObjectsClientContract, ids: string[] - ): Promise { - const datasourceSO = await soClient.bulkGet( + ): Promise { + const datasourceSO = await soClient.bulkGet( ids.map((id) => ({ id, type: SAVED_OBJECT_TYPE, @@ -141,10 +144,10 @@ class DatasourceService { public async list( soClient: SavedObjectsClientContract, options: ListWithKuery - ): Promise<{ items: Datasource[]; total: number; page: number; perPage: number }> { + ): Promise<{ items: PackageConfig[]; total: number; page: number; perPage: number }> { const { page = 1, perPage = 20, kuery } = options; - const datasources = await soClient.find({ + const datasources = await soClient.find({ type: SAVED_OBJECT_TYPE, page, perPage, @@ -158,7 +161,7 @@ class DatasourceService { }); return { - items: datasources.saved_objects.map((datasourceSO) => ({ + items: datasources.saved_objects.map((datasourceSO) => ({ id: datasourceSO.id, ...datasourceSO.attributes, })), @@ -171,16 +174,16 @@ class DatasourceService { public async update( soClient: SavedObjectsClientContract, id: string, - datasource: NewDatasource, + datasource: NewPackageConfig, options?: { user?: AuthenticatedUser } - ): Promise { + ): Promise { const oldDatasource = await this.get(soClient, id); if (!oldDatasource) { throw new Error('Datasource not found'); } - await soClient.update(SAVED_OBJECT_TYPE, id, { + await soClient.update(SAVED_OBJECT_TYPE, id, { ...datasource, revision: oldDatasource.revision + 1, updated_at: new Date().toISOString(), @@ -190,7 +193,7 @@ class DatasourceService { // Bump revision of associated agent config await agentConfigService.bumpRevision(soClient, datasource.config_id, { user: options?.user }); - return (await this.get(soClient, id)) as Datasource; + return (await this.get(soClient, id)) as PackageConfig; } public async delete( @@ -235,7 +238,7 @@ class DatasourceService { public async buildDatasourceFromPackage( soClient: SavedObjectsClientContract, pkgName: string - ): Promise { + ): Promise { const pkgInstall = await getInstallation({ savedObjectsClient: soClient, pkgName }); if (pkgInstall) { const [pkgInfo, defaultOutputId] = await Promise.all([ @@ -257,8 +260,8 @@ class DatasourceService { public async assignPackageStream( pkgInfo: PackageInfo, - inputs: DatasourceInput[] - ): Promise { + inputs: PackageConfigInput[] + ): Promise { const registryPkgInfo = await Registry.fetchInfo(pkgInfo.name, pkgInfo.version); const inputsPromises = inputs.map((input) => _assignPackageStreamToInput(registryPkgInfo, pkgInfo, input) @@ -271,7 +274,7 @@ class DatasourceService { async function _assignPackageStreamToInput( registryPkgInfo: RegistryPackage, pkgInfo: PackageInfo, - input: DatasourceInput + input: PackageConfigInput ) { const streamsPromises = input.streams.map((stream) => _assignPackageStreamToStream(registryPkgInfo, pkgInfo, input, stream) @@ -284,8 +287,8 @@ async function _assignPackageStreamToInput( async function _assignPackageStreamToStream( registryPkgInfo: RegistryPackage, pkgInfo: PackageInfo, - input: DatasourceInput, - stream: DatasourceInputStream + input: PackageConfigInput, + stream: PackageConfigInputStream ) { if (!stream.enabled) { return { ...stream, agent_stream: undefined }; diff --git a/x-pack/plugins/ingest_manager/server/services/epm/agent/agent.ts b/x-pack/plugins/ingest_manager/server/services/epm/agent/agent.ts index 0bcb2464f8d74..d697ad0576396 100644 --- a/x-pack/plugins/ingest_manager/server/services/epm/agent/agent.ts +++ b/x-pack/plugins/ingest_manager/server/services/epm/agent/agent.ts @@ -6,9 +6,9 @@ import Handlebars from 'handlebars'; import { safeLoad, safeDump } from 'js-yaml'; -import { DatasourceConfigRecord } from '../../../../common'; +import { PackageConfigConfigRecord } from '../../../../common'; -export function createStream(variables: DatasourceConfigRecord, streamTemplate: string) { +export function createStream(variables: PackageConfigConfigRecord, streamTemplate: string) { const { vars, yamlValues } = buildTemplateVariables(variables, streamTemplate); const template = Handlebars.compile(streamTemplate, { noEscape: true }); @@ -52,7 +52,7 @@ function replaceVariablesInYaml(yamlVariables: { [k: string]: any }, yaml: any) return yaml; } -function buildTemplateVariables(variables: DatasourceConfigRecord, streamTemplate: string) { +function buildTemplateVariables(variables: PackageConfigConfigRecord, streamTemplate: string) { const yamlValues: { [k: string]: any } = {}; const vars = Object.entries(variables).reduce((acc, [key, recordEntry]) => { // support variables with . like key.patterns diff --git a/x-pack/plugins/ingest_manager/server/services/setup.ts b/x-pack/plugins/ingest_manager/server/services/setup.ts index 7a81a1db84b60..f1589e28e85bb 100644 --- a/x-pack/plugins/ingest_manager/server/services/setup.ts +++ b/x-pack/plugins/ingest_manager/server/services/setup.ts @@ -14,7 +14,7 @@ import { ensureInstalledDefaultPackages } from './epm/packages/install'; import { ensureDefaultIndices } from './epm/kibana/index_pattern/install'; import { packageToConfigDatasource, - Datasource, + PackageConfig, AgentConfig, Installation, Output, @@ -87,7 +87,7 @@ export async function setupIngestManager( continue; } - const isInstalled = configWithDatasource.datasources.some((d: Datasource | string) => { + const isInstalled = configWithDatasource.datasources.some((d: PackageConfig | string) => { return typeof d !== 'string' && d.package?.name === installedPackage.name; }); diff --git a/x-pack/plugins/ingest_manager/server/types/index.tsx b/x-pack/plugins/ingest_manager/server/types/index.tsx index eedb5d86abda3..179474d31bc18 100644 --- a/x-pack/plugins/ingest_manager/server/types/index.tsx +++ b/x-pack/plugins/ingest_manager/server/types/index.tsx @@ -17,11 +17,11 @@ export { AgentEventSOAttributes, AgentAction, AgentActionSOAttributes, - Datasource, - DatasourceInput, - DatasourceInputStream, - NewDatasource, - DatasourceSOAttributes, + PackageConfig, + PackageConfigInput, + PackageConfigInputStream, + NewPackageConfig, + PackageConfigSOAttributes, FullAgentConfigInput, FullAgentConfig, AgentConfig, diff --git a/x-pack/plugins/security_solution/common/endpoint/types.ts b/x-pack/plugins/security_solution/common/endpoint/types.ts index 72839a8370495..ca5cc449a7ad7 100644 --- a/x-pack/plugins/security_solution/common/endpoint/types.ts +++ b/x-pack/plugins/security_solution/common/endpoint/types.ts @@ -4,7 +4,7 @@ * you may not use this file except in compliance with the Elastic License. */ -import { Datasource, NewDatasource } from '../../../ingest_manager/common'; +import { PackageConfig, NewPackageConfig } from '../../../ingest_manager/common'; /** * Object that allows you to maintain stateful information in the location object across navigation events @@ -670,14 +670,14 @@ export enum ProtectionModes { } /** - * Endpoint Policy data, which extends Ingest's `Datasource` type + * Endpoint Policy data, which extends Ingest's `PackageConfig` type */ -export type PolicyData = Datasource & NewPolicyData; +export type PolicyData = PackageConfig & NewPolicyData; /** * New policy data. Used when updating the policy record via ingest APIs */ -export type NewPolicyData = NewDatasource & { +export type NewPolicyData = NewPackageConfig & { inputs: [ { type: 'endpoint'; diff --git a/x-pack/plugins/security_solution/public/management/pages/policy/store/policy_list/index.test.ts b/x-pack/plugins/security_solution/public/management/pages/policy/store/policy_list/index.test.ts index f454061055e96..e472343b5d38c 100644 --- a/x-pack/plugins/security_solution/public/management/pages/policy/store/policy_list/index.test.ts +++ b/x-pack/plugins/security_solution/public/management/pages/policy/store/policy_list/index.test.ts @@ -8,7 +8,7 @@ import { PolicyListState } from '../../types'; import { Store, applyMiddleware, createStore } from 'redux'; import { coreMock } from '../../../../../../../../../src/core/public/mocks'; -import { DATASOURCE_SAVED_OBJECT_TYPE } from '../../../../../../../ingest_manager/common'; +import { PACKAGE_CONFIG_SAVED_OBJECT_TYPE } from '../../../../../../../ingest_manager/common'; import { policyListReducer } from './reducer'; import { policyListMiddlewareFactory } from './middleware'; @@ -167,7 +167,7 @@ describe('policy list store concerns', () => { await waitForAction('serverReturnedPolicyListData'); expect(fakeCoreStart.http.get).toHaveBeenCalledWith(INGEST_API_DATASOURCES, { query: { - kuery: `${DATASOURCE_SAVED_OBJECT_TYPE}.package.name: endpoint`, + kuery: `${PACKAGE_CONFIG_SAVED_OBJECT_TYPE}.package.name: endpoint`, page: 1, perPage: 10, }, @@ -190,7 +190,7 @@ describe('policy list store concerns', () => { await waitForAction('serverReturnedPolicyListData'); expect(fakeCoreStart.http.get).toHaveBeenCalledWith(INGEST_API_DATASOURCES, { query: { - kuery: `${DATASOURCE_SAVED_OBJECT_TYPE}.package.name: endpoint`, + kuery: `${PACKAGE_CONFIG_SAVED_OBJECT_TYPE}.package.name: endpoint`, page: 1, perPage: 50, }, @@ -213,7 +213,7 @@ describe('policy list store concerns', () => { await waitForAction('serverReturnedPolicyListData'); expect(fakeCoreStart.http.get).toHaveBeenCalledWith(INGEST_API_DATASOURCES, { query: { - kuery: `${DATASOURCE_SAVED_OBJECT_TYPE}.package.name: endpoint`, + kuery: `${PACKAGE_CONFIG_SAVED_OBJECT_TYPE}.package.name: endpoint`, page: 1, perPage: 10, }, @@ -224,7 +224,7 @@ describe('policy list store concerns', () => { await waitForAction('serverReturnedPolicyListData'); expect(fakeCoreStart.http.get).toHaveBeenCalledWith(INGEST_API_DATASOURCES, { query: { - kuery: `${DATASOURCE_SAVED_OBJECT_TYPE}.package.name: endpoint`, + kuery: `${PACKAGE_CONFIG_SAVED_OBJECT_TYPE}.package.name: endpoint`, page: 1, perPage: 10, }, @@ -235,7 +235,7 @@ describe('policy list store concerns', () => { await waitForAction('serverReturnedPolicyListData'); expect(fakeCoreStart.http.get).toHaveBeenCalledWith(INGEST_API_DATASOURCES, { query: { - kuery: `${DATASOURCE_SAVED_OBJECT_TYPE}.package.name: endpoint`, + kuery: `${PACKAGE_CONFIG_SAVED_OBJECT_TYPE}.package.name: endpoint`, page: 11, perPage: 10, }, @@ -264,7 +264,7 @@ describe('policy list store concerns', () => { dispatchUserChangedUrl('?page_size=10&page_index=11'); expect(fakeCoreStart.http.get).toHaveBeenCalledWith(INGEST_API_DATASOURCES, { query: { - kuery: `${DATASOURCE_SAVED_OBJECT_TYPE}.package.name: endpoint`, + kuery: `${PACKAGE_CONFIG_SAVED_OBJECT_TYPE}.package.name: endpoint`, page: 12, perPage: 10, }, diff --git a/x-pack/plugins/security_solution/public/management/pages/policy/store/policy_list/services/ingest.test.ts b/x-pack/plugins/security_solution/public/management/pages/policy/store/policy_list/services/ingest.test.ts index 818ca49e1e81a..67be9992012d3 100644 --- a/x-pack/plugins/security_solution/public/management/pages/policy/store/policy_list/services/ingest.test.ts +++ b/x-pack/plugins/security_solution/public/management/pages/policy/store/policy_list/services/ingest.test.ts @@ -11,7 +11,7 @@ import { sendGetEndpointSpecificDatasources, } from './ingest'; import { httpServiceMock } from '../../../../../../../../../../src/core/public/mocks'; -import { DATASOURCE_SAVED_OBJECT_TYPE } from '../../../../../../../../ingest_manager/common'; +import { PACKAGE_CONFIG_SAVED_OBJECT_TYPE } from '../../../../../../../../ingest_manager/common'; import { apiPathMockResponseProviders } from '../test_mock_utils'; describe('ingest service', () => { @@ -26,7 +26,7 @@ describe('ingest service', () => { await sendGetEndpointSpecificDatasources(http); expect(http.get).toHaveBeenCalledWith('/api/ingest_manager/datasources', { query: { - kuery: `${DATASOURCE_SAVED_OBJECT_TYPE}.package.name: endpoint`, + kuery: `${PACKAGE_CONFIG_SAVED_OBJECT_TYPE}.package.name: endpoint`, }, }); }); @@ -36,7 +36,7 @@ describe('ingest service', () => { }); expect(http.get).toHaveBeenCalledWith('/api/ingest_manager/datasources', { query: { - kuery: `someValueHere and ${DATASOURCE_SAVED_OBJECT_TYPE}.package.name: endpoint`, + kuery: `someValueHere and ${PACKAGE_CONFIG_SAVED_OBJECT_TYPE}.package.name: endpoint`, perPage: 10, page: 1, }, diff --git a/x-pack/plugins/security_solution/public/management/pages/policy/store/policy_list/services/ingest.ts b/x-pack/plugins/security_solution/public/management/pages/policy/store/policy_list/services/ingest.ts index cbdd67261739f..18ed3cbec96af 100644 --- a/x-pack/plugins/security_solution/public/management/pages/policy/store/policy_list/services/ingest.ts +++ b/x-pack/plugins/security_solution/public/management/pages/policy/store/policy_list/services/ingest.ts @@ -10,7 +10,7 @@ import { GetAgentStatusResponse, DeleteDatasourcesResponse, DeleteDatasourcesRequest, - DATASOURCE_SAVED_OBJECT_TYPE, + PACKAGE_CONFIG_SAVED_OBJECT_TYPE, GetPackagesResponse, } from '../../../../../../../../ingest_manager/common'; import { GetPolicyListResponse, GetPolicyResponse, UpdatePolicyResponse } from '../../../types'; @@ -39,7 +39,7 @@ export const sendGetEndpointSpecificDatasources = ( ...options.query, kuery: `${ options?.query?.kuery ? `${options.query.kuery} and ` : '' - }${DATASOURCE_SAVED_OBJECT_TYPE}.package.name: endpoint`, + }${PACKAGE_CONFIG_SAVED_OBJECT_TYPE}.package.name: endpoint`, }, }); }; diff --git a/x-pack/plugins/security_solution/server/endpoint/ingest_integration.ts b/x-pack/plugins/security_solution/server/endpoint/ingest_integration.ts index 6ff0949311587..b2c22c7593729 100644 --- a/x-pack/plugins/security_solution/server/endpoint/ingest_integration.ts +++ b/x-pack/plugins/security_solution/server/endpoint/ingest_integration.ts @@ -6,15 +6,15 @@ import { factory as policyConfigFactory } from '../../common/endpoint/models/policy_config'; import { NewPolicyData } from '../../common/endpoint/types'; -import { NewDatasource } from '../../../ingest_manager/common/types/models'; +import { NewPackageConfig } from '../../../ingest_manager/common/types/models'; /** * Callback to handle creation of Datasources in Ingest Manager * @param newDatasource */ export const handleDatasourceCreate = async ( - newDatasource: NewDatasource -): Promise => { + newDatasource: NewPackageConfig +): Promise => { // We only care about Endpoint datasources if (newDatasource.package?.name !== 'endpoint') { return newDatasource; From 77cebc2d89c8697efe2b501f6509f9e8aab3030a Mon Sep 17 00:00:00 2001 From: Jen Huang Date: Fri, 26 Jun 2020 14:01:03 -0700 Subject: [PATCH 04/16] Rename `Datasource` schemas and rest spec typings to `PackageConfig` (does not include actual schema changes yet) --- .../common/types/rest_spec/index.ts | 2 +- .../{datasource.ts => package_config.ts} | 20 +++++----- .../hooks/use_request/datasource.ts | 36 ++++++++--------- .../ingest_manager/types/index.ts | 8 ++-- .../datasource/datasource_handlers.test.ts | 8 ++-- .../server/routes/datasource/handlers.ts | 40 +++++++++---------- .../server/routes/datasource/index.ts | 20 +++++----- .../server/services/datasource.ts | 6 +-- .../server/types/models/agent_config.ts | 4 +- .../server/types/models/index.ts | 2 +- .../{datasource.ts => package_config.ts} | 10 ++--- .../server/types/rest_spec/index.ts | 2 +- .../{datasource.ts => package_config.ts} | 18 ++++----- 13 files changed, 88 insertions(+), 88 deletions(-) rename x-pack/plugins/ingest_manager/common/types/rest_spec/{datasource.ts => package_config.ts} (59%) rename x-pack/plugins/ingest_manager/server/types/models/{datasource.ts => package_config.ts} (90%) rename x-pack/plugins/ingest_manager/server/types/rest_spec/{datasource.ts => package_config.ts} (56%) diff --git a/x-pack/plugins/ingest_manager/common/types/rest_spec/index.ts b/x-pack/plugins/ingest_manager/common/types/rest_spec/index.ts index 294e10aabe4ef..c40940fdbb623 100644 --- a/x-pack/plugins/ingest_manager/common/types/rest_spec/index.ts +++ b/x-pack/plugins/ingest_manager/common/types/rest_spec/index.ts @@ -4,7 +4,7 @@ * you may not use this file except in compliance with the Elastic License. */ export * from './common'; -export * from './datasource'; +export * from './package_config'; export * from './data_stream'; export * from './agent'; export * from './agent_config'; diff --git a/x-pack/plugins/ingest_manager/common/types/rest_spec/datasource.ts b/x-pack/plugins/ingest_manager/common/types/rest_spec/package_config.ts similarity index 59% rename from x-pack/plugins/ingest_manager/common/types/rest_spec/datasource.ts rename to x-pack/plugins/ingest_manager/common/types/rest_spec/package_config.ts index 8d7d9cb38e74e..e8ccbae17ea36 100644 --- a/x-pack/plugins/ingest_manager/common/types/rest_spec/datasource.ts +++ b/x-pack/plugins/ingest_manager/common/types/rest_spec/package_config.ts @@ -5,7 +5,7 @@ */ import { PackageConfig, NewPackageConfig } from '../models'; -export interface GetDatasourcesRequest { +export interface GetPackageConfigsRequest { query: { page: number; perPage: number; @@ -13,7 +13,7 @@ export interface GetDatasourcesRequest { }; } -export interface GetDatasourcesResponse { +export interface GetPackageConfigsResponse { items: PackageConfig[]; total: number; page: number; @@ -21,39 +21,39 @@ export interface GetDatasourcesResponse { success: boolean; } -export interface GetOneDatasourceRequest { +export interface GetOnePackageConfigRequest { params: { datasourceId: string; }; } -export interface GetOneDatasourceResponse { +export interface GetOnePackageConfigResponse { item: PackageConfig; success: boolean; } -export interface CreateDatasourceRequest { +export interface CreatePackageConfigRequest { body: NewPackageConfig; } -export interface CreateDatasourceResponse { +export interface CreatePackageConfigResponse { item: PackageConfig; success: boolean; } -export type UpdateDatasourceRequest = GetOneDatasourceRequest & { +export type UpdatePackageConfigRequest = GetOnePackageConfigRequest & { body: NewPackageConfig; }; -export type UpdateDatasourceResponse = CreateDatasourceResponse; +export type UpdatePackageConfigResponse = CreatePackageConfigResponse; -export interface DeleteDatasourcesRequest { +export interface DeletePackageConfigsRequest { body: { datasourceIds: string[]; }; } -export type DeleteDatasourcesResponse = Array<{ +export type DeletePackageConfigsResponse = Array<{ id: string; success: boolean; }>; diff --git a/x-pack/plugins/ingest_manager/public/applications/ingest_manager/hooks/use_request/datasource.ts b/x-pack/plugins/ingest_manager/public/applications/ingest_manager/hooks/use_request/datasource.ts index e2fc190e158f9..b5c2f560f7f25 100644 --- a/x-pack/plugins/ingest_manager/public/applications/ingest_manager/hooks/use_request/datasource.ts +++ b/x-pack/plugins/ingest_manager/public/applications/ingest_manager/hooks/use_request/datasource.ts @@ -6,21 +6,21 @@ import { sendRequest, useRequest } from './use_request'; import { datasourceRouteService } from '../../services'; import { - CreateDatasourceRequest, - CreateDatasourceResponse, - UpdateDatasourceRequest, - UpdateDatasourceResponse, + CreatePackageConfigRequest, + CreatePackageConfigResponse, + UpdatePackageConfigRequest, + UpdatePackageConfigResponse, } from '../../types'; import { - DeleteDatasourcesRequest, - DeleteDatasourcesResponse, - GetDatasourcesRequest, - GetDatasourcesResponse, - GetOneDatasourceResponse, + DeletePackageConfigsRequest, + DeletePackageConfigsResponse, + GetPackageConfigsRequest, + GetPackageConfigsResponse, + GetOnePackageConfigResponse, } from '../../../../../common/types/rest_spec'; -export const sendCreateDatasource = (body: CreateDatasourceRequest['body']) => { - return sendRequest({ +export const sendCreateDatasource = (body: CreatePackageConfigRequest['body']) => { + return sendRequest({ path: datasourceRouteService.getCreatePath(), method: 'post', body: JSON.stringify(body), @@ -29,25 +29,25 @@ export const sendCreateDatasource = (body: CreateDatasourceRequest['body']) => { export const sendUpdateDatasource = ( datasourceId: string, - body: UpdateDatasourceRequest['body'] + body: UpdatePackageConfigRequest['body'] ) => { - return sendRequest({ + return sendRequest({ path: datasourceRouteService.getUpdatePath(datasourceId), method: 'put', body: JSON.stringify(body), }); }; -export const sendDeleteDatasource = (body: DeleteDatasourcesRequest['body']) => { - return sendRequest({ +export const sendDeleteDatasource = (body: DeletePackageConfigsRequest['body']) => { + return sendRequest({ path: datasourceRouteService.getDeletePath(), method: 'post', body: JSON.stringify(body), }); }; -export function useGetDatasources(query: GetDatasourcesRequest['query']) { - return useRequest({ +export function useGetDatasources(query: GetPackageConfigsRequest['query']) { + return useRequest({ method: 'get', path: datasourceRouteService.getListPath(), query, @@ -55,7 +55,7 @@ export function useGetDatasources(query: GetDatasourcesRequest['query']) { } export const sendGetOneDatasource = (datasourceId: string) => { - return sendRequest({ + return sendRequest({ path: datasourceRouteService.getInfoPath(datasourceId), method: 'get', }); diff --git a/x-pack/plugins/ingest_manager/public/applications/ingest_manager/types/index.ts b/x-pack/plugins/ingest_manager/public/applications/ingest_manager/types/index.ts index 30e1d6b870bae..5b79513df926e 100644 --- a/x-pack/plugins/ingest_manager/public/applications/ingest_manager/types/index.ts +++ b/x-pack/plugins/ingest_manager/public/applications/ingest_manager/types/index.ts @@ -36,10 +36,10 @@ export { DeleteAgentConfigRequest, DeleteAgentConfigResponse, // API schemas - Datasource - CreateDatasourceRequest, - CreateDatasourceResponse, - UpdateDatasourceRequest, - UpdateDatasourceResponse, + CreatePackageConfigRequest, + CreatePackageConfigResponse, + UpdatePackageConfigRequest, + UpdatePackageConfigResponse, // API schemas - Data Streams GetDataStreamsResponse, // API schemas - Agents diff --git a/x-pack/plugins/ingest_manager/server/routes/datasource/datasource_handlers.test.ts b/x-pack/plugins/ingest_manager/server/routes/datasource/datasource_handlers.test.ts index 07cbeb8b2cec5..379fdbf581c5e 100644 --- a/x-pack/plugins/ingest_manager/server/routes/datasource/datasource_handlers.test.ts +++ b/x-pack/plugins/ingest_manager/server/routes/datasource/datasource_handlers.test.ts @@ -12,7 +12,7 @@ import { xpackMocks } from '../../../../../mocks'; import { appContextService } from '../../services'; import { createAppContextStartContractMock } from '../../mocks'; import { DatasourceServiceInterface, ExternalCallback } from '../..'; -import { CreateDatasourceRequestSchema } from '../../types/rest_spec'; +import { CreatePackageConfigRequestSchema } from '../../types/rest_spec'; import { datasourceService } from '../../services'; const datasourceServiceMock = datasourceService as jest.Mocked; @@ -77,12 +77,12 @@ describe('When calling datasource', () => { describe('create api handler', () => { const getCreateKibanaRequest = ( - newData?: typeof CreateDatasourceRequestSchema.body - ): KibanaRequest => { + newData?: typeof CreatePackageConfigRequestSchema.body + ): KibanaRequest => { return httpServerMock.createKibanaRequest< undefined, undefined, - typeof CreateDatasourceRequestSchema.body + typeof CreatePackageConfigRequestSchema.body >({ path: routeConfig.path, method: 'post', diff --git a/x-pack/plugins/ingest_manager/server/routes/datasource/handlers.ts b/x-pack/plugins/ingest_manager/server/routes/datasource/handlers.ts index 28a8b43f9f548..c4fb4ac08081d 100644 --- a/x-pack/plugins/ingest_manager/server/routes/datasource/handlers.ts +++ b/x-pack/plugins/ingest_manager/server/routes/datasource/handlers.ts @@ -9,18 +9,18 @@ import { RequestHandler } from 'src/core/server'; import { appContextService, datasourceService } from '../../services'; import { ensureInstalledPackage, getPackageInfo } from '../../services/epm/packages'; import { - GetDatasourcesRequestSchema, - GetOneDatasourceRequestSchema, - CreateDatasourceRequestSchema, - UpdateDatasourceRequestSchema, - DeleteDatasourcesRequestSchema, + GetPackageConfigsRequestSchema, + GetOnePackageConfigRequestSchema, + CreatePackageConfigRequestSchema, + UpdatePackageConfigRequestSchema, + DeletePackageConfigsRequestSchema, NewPackageConfig, } from '../../types'; -import { CreateDatasourceResponse, DeleteDatasourcesResponse } from '../../../common'; +import { CreatePackageConfigResponse, DeletePackageConfigsResponse } from '../../../common'; export const getDatasourcesHandler: RequestHandler< undefined, - TypeOf + TypeOf > = async (context, request, response) => { const soClient = context.core.savedObjects.client; try { @@ -43,7 +43,7 @@ export const getDatasourcesHandler: RequestHandler< }; export const getOneDatasourceHandler: RequestHandler> = async (context, request, response) => { const soClient = context.core.savedObjects.client; try { @@ -72,7 +72,7 @@ export const getOneDatasourceHandler: RequestHandler + TypeOf > = async (context, request, response) => { const soClient = context.core.savedObjects.client; const callCluster = context.core.elasticsearch.legacy.client.callAsCurrentUser; @@ -88,7 +88,7 @@ export const createDatasourceHandler: RequestHandler< for (const callback of externalCallbacks) { try { // ensure that the returned value by the callback passes schema validation - updatedNewData = CreateDatasourceRequestSchema.body.validate( + updatedNewData = CreatePackageConfigRequestSchema.body.validate( await callback(updatedNewData) ); } catch (error) { @@ -98,12 +98,12 @@ export const createDatasourceHandler: RequestHandler< } } - // The type `NewPackageConfig` and the `DatasourceBaseSchema` are incompatible. - // `NewDatasrouce` defines `namespace` as optional string, which means that `undefined` is a + // The type `NewPackageConfig` and the `PackageConfigBaseSchema` are incompatible. + // `NewDatasource` defines `namespace` as optional string, which means that `undefined` is a // valid value, however, the schema defines it as string with a minimum length of 1. // Here, we need to cast the value back to the schema type and ignore the TS error. // @ts-ignore - newData = updatedNewData as typeof CreateDatasourceRequestSchema.body; + newData = updatedNewData as typeof CreatePackageConfigRequestSchema.body; } // Make sure the datasource package is installed @@ -121,12 +121,12 @@ export const createDatasourceHandler: RequestHandler< newData.inputs = (await datasourceService.assignPackageStream( pkgInfo, newData.inputs - )) as TypeOf['inputs']; + )) as TypeOf['inputs']; } // Create datasource const datasource = await datasourceService.create(soClient, newData, { user }); - const body: CreateDatasourceResponse = { item: datasource, success: true }; + const body: CreatePackageConfigResponse = { item: datasource, success: true }; return response.ok({ body, }); @@ -140,9 +140,9 @@ export const createDatasourceHandler: RequestHandler< }; export const updateDatasourceHandler: RequestHandler< - TypeOf, + TypeOf, unknown, - TypeOf + TypeOf > = async (context, request, response) => { const soClient = context.core.savedObjects.client; const user = (await appContextService.getSecurity()?.authc.getCurrentUser(request)) || undefined; @@ -163,7 +163,7 @@ export const updateDatasourceHandler: RequestHandler< pkgVersion: pkg.version, }); newData.inputs = (await datasourceService.assignPackageStream(pkgInfo, inputs)) as TypeOf< - typeof CreateDatasourceRequestSchema.body + typeof CreatePackageConfigRequestSchema.body >['inputs']; } @@ -187,12 +187,12 @@ export const updateDatasourceHandler: RequestHandler< export const deleteDatasourceHandler: RequestHandler< unknown, unknown, - TypeOf + TypeOf > = async (context, request, response) => { const soClient = context.core.savedObjects.client; const user = (await appContextService.getSecurity()?.authc.getCurrentUser(request)) || undefined; try { - const body: DeleteDatasourcesResponse = await datasourceService.delete( + const body: DeletePackageConfigsResponse = await datasourceService.delete( soClient, request.body.datasourceIds, { user } diff --git a/x-pack/plugins/ingest_manager/server/routes/datasource/index.ts b/x-pack/plugins/ingest_manager/server/routes/datasource/index.ts index 7217f28053cf3..1c5bbea72dd19 100644 --- a/x-pack/plugins/ingest_manager/server/routes/datasource/index.ts +++ b/x-pack/plugins/ingest_manager/server/routes/datasource/index.ts @@ -6,11 +6,11 @@ import { IRouter } from 'src/core/server'; import { PLUGIN_ID, DATASOURCE_API_ROUTES } from '../../constants'; import { - GetDatasourcesRequestSchema, - GetOneDatasourceRequestSchema, - CreateDatasourceRequestSchema, - UpdateDatasourceRequestSchema, - DeleteDatasourcesRequestSchema, + GetPackageConfigsRequestSchema, + GetOnePackageConfigRequestSchema, + CreatePackageConfigRequestSchema, + UpdatePackageConfigRequestSchema, + DeletePackageConfigsRequestSchema, } from '../../types'; import { getDatasourcesHandler, @@ -25,7 +25,7 @@ export const registerRoutes = (router: IRouter) => { router.get( { path: DATASOURCE_API_ROUTES.LIST_PATTERN, - validate: GetDatasourcesRequestSchema, + validate: GetPackageConfigsRequestSchema, options: { tags: [`access:${PLUGIN_ID}-read`] }, }, getDatasourcesHandler @@ -35,7 +35,7 @@ export const registerRoutes = (router: IRouter) => { router.get( { path: DATASOURCE_API_ROUTES.INFO_PATTERN, - validate: GetOneDatasourceRequestSchema, + validate: GetOnePackageConfigRequestSchema, options: { tags: [`access:${PLUGIN_ID}-read`] }, }, getOneDatasourceHandler @@ -45,7 +45,7 @@ export const registerRoutes = (router: IRouter) => { router.post( { path: DATASOURCE_API_ROUTES.CREATE_PATTERN, - validate: CreateDatasourceRequestSchema, + validate: CreatePackageConfigRequestSchema, options: { tags: [`access:${PLUGIN_ID}-all`] }, }, createDatasourceHandler @@ -55,7 +55,7 @@ export const registerRoutes = (router: IRouter) => { router.put( { path: DATASOURCE_API_ROUTES.UPDATE_PATTERN, - validate: UpdateDatasourceRequestSchema, + validate: UpdatePackageConfigRequestSchema, options: { tags: [`access:${PLUGIN_ID}-all`] }, }, updateDatasourceHandler @@ -65,7 +65,7 @@ export const registerRoutes = (router: IRouter) => { router.post( { path: DATASOURCE_API_ROUTES.DELETE_PATTERN, - validate: DeleteDatasourcesRequestSchema, + validate: DeletePackageConfigsRequestSchema, options: { tags: [`access:${PLUGIN_ID}`] }, }, deleteDatasourceHandler diff --git a/x-pack/plugins/ingest_manager/server/services/datasource.ts b/x-pack/plugins/ingest_manager/server/services/datasource.ts index 571160060bad6..3fd89233d3494 100644 --- a/x-pack/plugins/ingest_manager/server/services/datasource.ts +++ b/x-pack/plugins/ingest_manager/server/services/datasource.ts @@ -6,7 +6,7 @@ import { SavedObjectsClientContract } from 'src/core/server'; import { AuthenticatedUser } from '../../../security/server'; import { - DeleteDatasourcesResponse, + DeletePackageConfigsResponse, packageToConfigDatasource, PackageConfigInput, PackageConfigInputStream, @@ -200,8 +200,8 @@ class DatasourceService { soClient: SavedObjectsClientContract, ids: string[], options?: { user?: AuthenticatedUser; skipUnassignFromAgentConfigs?: boolean } - ): Promise { - const result: DeleteDatasourcesResponse = []; + ): Promise { + const result: DeletePackageConfigsResponse = []; for (const id of ids) { try { diff --git a/x-pack/plugins/ingest_manager/server/types/models/agent_config.ts b/x-pack/plugins/ingest_manager/server/types/models/agent_config.ts index ee91813a48e2f..0de8021e653e4 100644 --- a/x-pack/plugins/ingest_manager/server/types/models/agent_config.ts +++ b/x-pack/plugins/ingest_manager/server/types/models/agent_config.ts @@ -4,7 +4,7 @@ * you may not use this file except in compliance with the Elastic License. */ import { schema } from '@kbn/config-schema'; -import { DatasourceSchema } from './datasource'; +import { PackageConfigSchema } from './package_config'; import { AgentConfigStatus } from '../../../common'; const AgentConfigBaseSchema = { @@ -27,7 +27,7 @@ export const AgentConfigSchema = schema.object({ schema.literal(AgentConfigStatus.Active), schema.literal(AgentConfigStatus.Inactive), ]), - datasources: schema.oneOf([schema.arrayOf(schema.string()), schema.arrayOf(DatasourceSchema)]), + datasources: schema.oneOf([schema.arrayOf(schema.string()), schema.arrayOf(PackageConfigSchema)]), updated_at: schema.string(), updated_by: schema.string(), }); diff --git a/x-pack/plugins/ingest_manager/server/types/models/index.ts b/x-pack/plugins/ingest_manager/server/types/models/index.ts index 7da36c8a18ad2..268e87eb529be 100644 --- a/x-pack/plugins/ingest_manager/server/types/models/index.ts +++ b/x-pack/plugins/ingest_manager/server/types/models/index.ts @@ -5,6 +5,6 @@ */ export * from './agent_config'; export * from './agent'; -export * from './datasource'; +export * from './package_config'; export * from './output'; export * from './enrollment_api_key'; diff --git a/x-pack/plugins/ingest_manager/server/types/models/datasource.ts b/x-pack/plugins/ingest_manager/server/types/models/package_config.ts similarity index 90% rename from x-pack/plugins/ingest_manager/server/types/models/datasource.ts rename to x-pack/plugins/ingest_manager/server/types/models/package_config.ts index 114986c4a486e..45a8cd5566e66 100644 --- a/x-pack/plugins/ingest_manager/server/types/models/datasource.ts +++ b/x-pack/plugins/ingest_manager/server/types/models/package_config.ts @@ -13,7 +13,7 @@ const ConfigRecordSchema = schema.recordOf( }) ); -const DatasourceBaseSchema = { +const PackageConfigBaseSchema = { name: schema.string(), description: schema.maybe(schema.string()), namespace: schema.string({ minLength: 1 }), @@ -64,11 +64,11 @@ const DatasourceBaseSchema = { ), }; -export const NewDatasourceSchema = schema.object({ - ...DatasourceBaseSchema, +export const NewPackageConfigSchema = schema.object({ + ...PackageConfigBaseSchema, }); -export const DatasourceSchema = schema.object({ - ...DatasourceBaseSchema, +export const PackageConfigSchema = schema.object({ + ...PackageConfigBaseSchema, id: schema.string(), }); diff --git a/x-pack/plugins/ingest_manager/server/types/rest_spec/index.ts b/x-pack/plugins/ingest_manager/server/types/rest_spec/index.ts index 7dc3d4f8f1961..f3ee868f43f00 100644 --- a/x-pack/plugins/ingest_manager/server/types/rest_spec/index.ts +++ b/x-pack/plugins/ingest_manager/server/types/rest_spec/index.ts @@ -6,7 +6,7 @@ export * from './common'; export * from './agent_config'; export * from './agent'; -export * from './datasource'; +export * from './package_config'; export * from './epm'; export * from './enrollment_api_key'; export * from './install_script'; diff --git a/x-pack/plugins/ingest_manager/server/types/rest_spec/datasource.ts b/x-pack/plugins/ingest_manager/server/types/rest_spec/package_config.ts similarity index 56% rename from x-pack/plugins/ingest_manager/server/types/rest_spec/datasource.ts rename to x-pack/plugins/ingest_manager/server/types/rest_spec/package_config.ts index fce2c94b282bd..ca8a97e0321d4 100644 --- a/x-pack/plugins/ingest_manager/server/types/rest_spec/datasource.ts +++ b/x-pack/plugins/ingest_manager/server/types/rest_spec/package_config.ts @@ -4,29 +4,29 @@ * you may not use this file except in compliance with the Elastic License. */ import { schema } from '@kbn/config-schema'; -import { NewDatasourceSchema } from '../models'; +import { NewPackageConfigSchema } from '../models'; import { ListWithKuerySchema } from './index'; -export const GetDatasourcesRequestSchema = { +export const GetPackageConfigsRequestSchema = { query: ListWithKuerySchema, }; -export const GetOneDatasourceRequestSchema = { +export const GetOnePackageConfigRequestSchema = { params: schema.object({ datasourceId: schema.string(), }), }; -export const CreateDatasourceRequestSchema = { - body: NewDatasourceSchema, +export const CreatePackageConfigRequestSchema = { + body: NewPackageConfigSchema, }; -export const UpdateDatasourceRequestSchema = { - ...GetOneDatasourceRequestSchema, - body: NewDatasourceSchema, +export const UpdatePackageConfigRequestSchema = { + ...GetOnePackageConfigRequestSchema, + body: NewPackageConfigSchema, }; -export const DeleteDatasourcesRequestSchema = { +export const DeletePackageConfigsRequestSchema = { body: schema.object({ datasourceIds: schema.arrayOf(schema.string()), }), From 6e7320ed359685f112211b3bbeb4f4e23b021cc9 Mon Sep 17 00:00:00 2001 From: Jen Huang Date: Fri, 26 Jun 2020 14:16:50 -0700 Subject: [PATCH 05/16] Change `datasources` on agent config typings and schemas to `package_configs` and update all references --- .../common/types/models/agent_config.ts | 2 +- .../step_define_datasource.tsx | 2 +- .../components/datasources/index.tsx | 7 ++++-- .../agent_config/details_page/index.tsx | 7 ++++-- .../sections/agent_config/list_page/index.tsx | 3 ++- .../agent_config_datasource_badges.tsx | 6 ++--- .../server/services/agent_config.ts | 22 +++++++++---------- .../ingest_manager/server/services/setup.ts | 6 ++--- .../server/types/models/agent_config.ts | 5 ++++- .../policy/store/policy_list/middleware.ts | 8 +++---- .../store/policy_list/services/ingest.ts | 12 +++++----- .../public/management/pages/policy/types.ts | 12 +++++----- 12 files changed, 51 insertions(+), 41 deletions(-) diff --git a/x-pack/plugins/ingest_manager/common/types/models/agent_config.ts b/x-pack/plugins/ingest_manager/common/types/models/agent_config.ts index 721120c832d15..17b00f116b603 100644 --- a/x-pack/plugins/ingest_manager/common/types/models/agent_config.ts +++ b/x-pack/plugins/ingest_manager/common/types/models/agent_config.ts @@ -22,7 +22,7 @@ export interface NewAgentConfig { export interface AgentConfig extends NewAgentConfig { id: string; status: AgentConfigStatus; - datasources: string[] | PackageConfig[]; + package_configs: string[] | PackageConfig[]; updated_at: string; updated_by: string; revision: number; diff --git a/x-pack/plugins/ingest_manager/public/applications/ingest_manager/sections/agent_config/create_datasource_page/step_define_datasource.tsx b/x-pack/plugins/ingest_manager/public/applications/ingest_manager/sections/agent_config/create_datasource_page/step_define_datasource.tsx index 958a4a8c6eb39..9038177b4d8d8 100644 --- a/x-pack/plugins/ingest_manager/public/applications/ingest_manager/sections/agent_config/create_datasource_page/step_define_datasource.tsx +++ b/x-pack/plugins/ingest_manager/public/applications/ingest_manager/sections/agent_config/create_datasource_page/step_define_datasource.tsx @@ -40,7 +40,7 @@ export const StepDefineDatasource: React.FunctionComponent<{ if (currentPkgKey !== pkgKey) { // Existing datasources on the agent config using the package name, retrieve highest number appended to datasource name const dsPackageNamePattern = new RegExp(`${packageInfo.name}-(\\d+)`); - const dsWithMatchingNames = (agentConfig.datasources as PackageConfig[]) + const dsWithMatchingNames = (agentConfig.package_configs as PackageConfig[]) .filter((ds) => Boolean(ds.name.match(dsPackageNamePattern))) .map((ds) => parseInt(ds.name.match(dsPackageNamePattern)![1], 10)) .sort(); diff --git a/x-pack/plugins/ingest_manager/public/applications/ingest_manager/sections/agent_config/details_page/components/datasources/index.tsx b/x-pack/plugins/ingest_manager/public/applications/ingest_manager/sections/agent_config/details_page/components/datasources/index.tsx index 666e8acf172b6..e5fde9b605db4 100644 --- a/x-pack/plugins/ingest_manager/public/applications/ingest_manager/sections/agent_config/details_page/components/datasources/index.tsx +++ b/x-pack/plugins/ingest_manager/public/applications/ingest_manager/sections/agent_config/details_page/components/datasources/index.tsx @@ -10,11 +10,14 @@ import { NoDatasources } from './no_datasources'; import { DatasourcesTable } from './datasources_table'; export const ConfigDatasourcesView = memo<{ config: AgentConfig }>(({ config }) => { - if (config.datasources.length === 0) { + if (config.package_configs.length === 0) { return ; } return ( - + ); }); diff --git a/x-pack/plugins/ingest_manager/public/applications/ingest_manager/sections/agent_config/details_page/index.tsx b/x-pack/plugins/ingest_manager/public/applications/ingest_manager/sections/agent_config/details_page/index.tsx index eaa161d57bbe4..c5862de49b659 100644 --- a/x-pack/plugins/ingest_manager/public/applications/ingest_manager/sections/agent_config/details_page/index.tsx +++ b/x-pack/plugins/ingest_manager/public/applications/ingest_manager/sections/agent_config/details_page/index.tsx @@ -120,13 +120,16 @@ export const AgentConfigDetailsPage: React.FunctionComponent = () => { }, { isDivider: true }, { - label: i18n.translate('xpack.ingestManager.configDetails.summary.datasources', { + label: i18n.translate('xpack.ingestManager.configDetails.summary.package_configs', { defaultMessage: 'Data sources', }), content: ( ), diff --git a/x-pack/plugins/ingest_manager/public/applications/ingest_manager/sections/agent_config/list_page/index.tsx b/x-pack/plugins/ingest_manager/public/applications/ingest_manager/sections/agent_config/list_page/index.tsx index 8b1ff0988d443..85c86079e332b 100644 --- a/x-pack/plugins/ingest_manager/public/applications/ingest_manager/sections/agent_config/list_page/index.tsx +++ b/x-pack/plugins/ingest_manager/public/applications/ingest_manager/sections/agent_config/list_page/index.tsx @@ -181,7 +181,8 @@ export const AgentConfigListPage: React.FunctionComponent<{}> = () => { defaultMessage: 'Data sources', }), dataType: 'number', - render: (datasources: AgentConfig['datasources']) => (datasources ? datasources.length : 0), + render: (datasources: AgentConfig['package_configs']) => + datasources ? datasources.length : 0, }, { name: i18n.translate('xpack.ingestManager.agentConfigList.actionsColumnTitle', { diff --git a/x-pack/plugins/ingest_manager/public/applications/ingest_manager/sections/fleet/components/agent_config_datasource_badges.tsx b/x-pack/plugins/ingest_manager/public/applications/ingest_manager/sections/fleet/components/agent_config_datasource_badges.tsx index 9feb1d65bb56c..96ca23a387624 100644 --- a/x-pack/plugins/ingest_manager/public/applications/ingest_manager/sections/fleet/components/agent_config_datasource_badges.tsx +++ b/x-pack/plugins/ingest_manager/public/applications/ingest_manager/sections/fleet/components/agent_config_datasource_badges.tsx @@ -28,13 +28,13 @@ export const AgentConfigDatasourceBadges: React.FunctionComponent = ({ ag id="xpack.ingestManager.agentReassignConfig.configDescription" defaultMessage="The selected agent configuration will collect data for {count, plural, one {{countValue} data source} other {{countValue} data sources}}:" values={{ - count: agentConfig.datasources.length, - countValue: {agentConfig.datasources.length}, + count: agentConfig.package_configs.length, + countValue: {agentConfig.package_configs.length}, }} /> - {(agentConfig.datasources as PackageConfig[]).map((datasource, idx) => { + {(agentConfig.package_configs as PackageConfig[]).map((datasource, idx) => { if (!datasource.package) { return null; } diff --git a/x-pack/plugins/ingest_manager/server/services/agent_config.ts b/x-pack/plugins/ingest_manager/server/services/agent_config.ts index bda8d87262be1..71ece09a31173 100644 --- a/x-pack/plugins/ingest_manager/server/services/agent_config.ts +++ b/x-pack/plugins/ingest_manager/server/services/agent_config.ts @@ -129,10 +129,10 @@ class AgentConfigService { const agentConfig = { id: agentConfigSO.id, ...agentConfigSO.attributes }; if (withDatasources) { - agentConfig.datasources = + agentConfig.package_configs = (await datasourceService.getByIDs( soClient, - (agentConfigSO.attributes.datasources as string[]) || [] + (agentConfigSO.attributes.package_configs as string[]) || [] )) || []; } @@ -201,8 +201,8 @@ class AgentConfigService { ); // Copy all datasources - if (baseAgentConfig.datasources.length) { - const newDatasources = (baseAgentConfig.datasources as PackageConfig[]).map( + if (baseAgentConfig.package_configs.length) { + const newDatasources = (baseAgentConfig.package_configs as PackageConfig[]).map( (datasource: PackageConfig) => { const { id: datasourceId, ...newDatasource } = datasource; return newDatasource; @@ -244,8 +244,8 @@ class AgentConfigService { soClient, id, { - datasources: uniq( - [...((oldAgentConfig.datasources || []) as string[])].concat(datasourceIds) + package_configs: uniq( + [...((oldAgentConfig.package_configs || []) as string[])].concat(datasourceIds) ), }, options?.user @@ -269,8 +269,8 @@ class AgentConfigService { id, { ...oldAgentConfig, - datasources: uniq( - [...((oldAgentConfig.datasources || []) as string[])].filter( + package_configs: uniq( + [...((oldAgentConfig.package_configs || []) as string[])].filter( (dsId) => !datasourceIds.includes(dsId) ) ), @@ -318,8 +318,8 @@ class AgentConfigService { throw new Error('Cannot delete agent config that is assigned to agent(s)'); } - if (config.datasources && config.datasources.length) { - await datasourceService.delete(soClient, config.datasources as string[], { + if (config.package_configs && config.package_configs.length) { + await datasourceService.delete(soClient, config.package_configs as string[], { skipUnassignFromAgentConfigs: true, }); } @@ -373,7 +373,7 @@ class AgentConfigService { {} as FullAgentConfig['outputs'] ), }, - inputs: storedDatasourcesToAgentInputs(config.datasources as PackageConfig[]), + inputs: storedDatasourcesToAgentInputs(config.package_configs as PackageConfig[]), revision: config.revision, ...(config.monitoring_enabled && config.monitoring_enabled.length > 0 ? { diff --git a/x-pack/plugins/ingest_manager/server/services/setup.ts b/x-pack/plugins/ingest_manager/server/services/setup.ts index f1589e28e85bb..a787520e7002f 100644 --- a/x-pack/plugins/ingest_manager/server/services/setup.ts +++ b/x-pack/plugins/ingest_manager/server/services/setup.ts @@ -74,8 +74,8 @@ export async function setupIngestManager( throw new Error('Config not found'); } if ( - configWithDatasource.datasources.length && - typeof configWithDatasource.datasources[0] === 'string' + configWithDatasource.package_configs.length && + typeof configWithDatasource.package_configs[0] === 'string' ) { throw new Error('Config not found'); } @@ -87,7 +87,7 @@ export async function setupIngestManager( continue; } - const isInstalled = configWithDatasource.datasources.some((d: PackageConfig | string) => { + const isInstalled = configWithDatasource.package_configs.some((d: PackageConfig | string) => { return typeof d !== 'string' && d.package?.name === installedPackage.name; }); diff --git a/x-pack/plugins/ingest_manager/server/types/models/agent_config.ts b/x-pack/plugins/ingest_manager/server/types/models/agent_config.ts index 0de8021e653e4..a9e14301cd7c3 100644 --- a/x-pack/plugins/ingest_manager/server/types/models/agent_config.ts +++ b/x-pack/plugins/ingest_manager/server/types/models/agent_config.ts @@ -27,7 +27,10 @@ export const AgentConfigSchema = schema.object({ schema.literal(AgentConfigStatus.Active), schema.literal(AgentConfigStatus.Inactive), ]), - datasources: schema.oneOf([schema.arrayOf(schema.string()), schema.arrayOf(PackageConfigSchema)]), + package_configs: schema.oneOf([ + schema.arrayOf(schema.string()), + schema.arrayOf(PackageConfigSchema), + ]), updated_at: schema.string(), updated_by: schema.string(), }); diff --git a/x-pack/plugins/security_solution/public/management/pages/policy/store/policy_list/middleware.ts b/x-pack/plugins/security_solution/public/management/pages/policy/store/policy_list/middleware.ts index 7d8620a5831d0..0797d14c78139 100644 --- a/x-pack/plugins/security_solution/public/management/pages/policy/store/policy_list/middleware.ts +++ b/x-pack/plugins/security_solution/public/management/pages/policy/store/policy_list/middleware.ts @@ -15,8 +15,8 @@ import { endpointPackageInfo, isOnPolicyListPage, urlSearchParams } from './sele import { ImmutableMiddlewareFactory } from '../../../../../common/store'; import { initialPolicyListState } from './reducer'; import { - DeleteDatasourcesResponse, - DeleteDatasourcesRequest, + DeletePackageConfigsResponse, + DeletePackageConfigsRequest, GetAgentStatusResponse, } from '../../../../../../../ingest_manager/common'; @@ -81,8 +81,8 @@ export const policyListMiddlewareFactory: ImmutableMiddlewareFactory = {} + options: HttpFetchOptions & Partial = {} ): Promise => { return http.get(INGEST_API_DATASOURCES, { ...options, @@ -66,10 +66,10 @@ export const sendGetDatasource = ( */ export const sendDeleteDatasource = ( http: HttpStart, - body: DeleteDatasourcesRequest, + body: DeletePackageConfigsRequest, options?: HttpFetchOptions ) => { - return http.post(INGEST_API_DELETE_DATASOURCE, { + return http.post(INGEST_API_DELETE_DATASOURCE, { ...options, body: JSON.stringify(body.body), }); diff --git a/x-pack/plugins/security_solution/public/management/pages/policy/types.ts b/x-pack/plugins/security_solution/public/management/pages/policy/types.ts index a3a0983331ac3..7c27acdb51568 100644 --- a/x-pack/plugins/security_solution/public/management/pages/policy/types.ts +++ b/x-pack/plugins/security_solution/public/management/pages/policy/types.ts @@ -14,10 +14,10 @@ import { import { ServerApiError } from '../../../common/types'; import { GetAgentStatusResponse, - GetDatasourcesResponse, - GetOneDatasourceResponse, + GetPackageConfigsResponse, + GetOnePackageConfigResponse, GetPackagesResponse, - UpdateDatasourceResponse, + UpdatePackageConfigResponse, } from '../../../../../ingest_manager/common'; /** @@ -169,14 +169,14 @@ export type KeysByValueCriteria = { /** Returns an array of the policy OSes that have a malware protection field */ export type MalwareProtectionOSes = KeysByValueCriteria; -export interface GetPolicyListResponse extends GetDatasourcesResponse { +export interface GetPolicyListResponse extends GetPackageConfigsResponse { items: PolicyData[]; } -export interface GetPolicyResponse extends GetOneDatasourceResponse { +export interface GetPolicyResponse extends GetOnePackageConfigResponse { item: PolicyData; } -export interface UpdatePolicyResponse extends UpdateDatasourceResponse { +export interface UpdatePolicyResponse extends UpdatePackageConfigResponse { item: PolicyData; } From 330af136b0f925b80f7254c771ff091ef9147835 Mon Sep 17 00:00:00 2001 From: Jen Huang Date: Fri, 26 Jun 2020 15:04:18 -0700 Subject: [PATCH 06/16] Add back `enabled` field on package config and input levels. They are needed for current & future UI features. Also: - Match types and schemas with saved object mappings (`agent_stream` to `compiled_stream`, removal of `processors`) - Set `namespace` to be a required property on agent config and package config types, add validation support for it on UI --- .../services/datasources_to_agent_inputs.test.ts | 2 +- .../common/services/datasources_to_agent_inputs.ts | 5 +---- .../common/services/package_to_config.test.ts | 11 ++++++++--- .../common/services/package_to_config.ts | 2 +- .../common/types/models/agent_config.ts | 14 +++++++++----- .../common/types/models/package_config.ts | 14 ++++++-------- .../agent_config/create_datasource_page/index.tsx | 1 + .../services/validate_datasource.test.ts | 12 ++++++++++++ .../services/validate_datasource.ts | 10 ++++++++++ .../step_define_datasource.tsx | 4 +++- .../agent_config/edit_datasource_page/index.tsx | 5 +++-- .../server/routes/agent_config/handlers.ts | 1 + .../server/routes/datasource/handlers.ts | 7 +------ .../ingest_manager/server/saved_objects/index.ts | 2 ++ .../server/services/datasource.test.ts | 4 ++-- .../ingest_manager/server/services/datasource.ts | 4 ++-- .../ingest_manager/server/services/setup.ts | 1 - .../server/types/models/package_config.ts | 2 -- 18 files changed, 63 insertions(+), 38 deletions(-) diff --git a/x-pack/plugins/ingest_manager/common/services/datasources_to_agent_inputs.test.ts b/x-pack/plugins/ingest_manager/common/services/datasources_to_agent_inputs.test.ts index 11b0378eda571..2cf7b25ec0cd5 100644 --- a/x-pack/plugins/ingest_manager/common/services/datasources_to_agent_inputs.test.ts +++ b/x-pack/plugins/ingest_manager/common/services/datasources_to_agent_inputs.test.ts @@ -44,7 +44,7 @@ describe('Ingest Manager - storedDatasourcesToAgentInputs', () => { fooVar: { value: 'foo-value' }, fooVar2: { value: [1, 2] }, }, - agent_stream: { + compiled_stream: { fooKey: 'fooValue1', fooKey2: ['fooValue2'], }, diff --git a/x-pack/plugins/ingest_manager/common/services/datasources_to_agent_inputs.ts b/x-pack/plugins/ingest_manager/common/services/datasources_to_agent_inputs.ts index 12e2994a9f306..7cdb300758085 100644 --- a/x-pack/plugins/ingest_manager/common/services/datasources_to_agent_inputs.ts +++ b/x-pack/plugins/ingest_manager/common/services/datasources_to_agent_inputs.ts @@ -38,15 +38,12 @@ export const storedDatasourcesToAgentInputs = ( const fullStream: FullAgentConfigInputStream = { id: stream.id, dataset: stream.dataset, - ...stream.agent_stream, + ...stream.compiled_stream, ...Object.entries(stream.config || {}).reduce((acc, [key, { value }]) => { acc[key] = value; return acc; }, {} as { [k: string]: any }), }; - if (stream.processors) { - fullStream.processors = stream.processors; - } return fullStream; }), }; diff --git a/x-pack/plugins/ingest_manager/common/services/package_to_config.test.ts b/x-pack/plugins/ingest_manager/common/services/package_to_config.test.ts index 7739fdc3a3b61..dd15c5f46488b 100644 --- a/x-pack/plugins/ingest_manager/common/services/package_to_config.test.ts +++ b/x-pack/plugins/ingest_manager/common/services/package_to_config.test.ts @@ -317,6 +317,7 @@ describe('Ingest Manager - packageToConfig', () => { it('returns datasource with default name', () => { expect(packageToConfigDatasource(mockPackage, '1', '2')).toEqual({ config_id: '1', + namespace: '', enabled: true, inputs: [], name: 'mock-package-1', @@ -329,8 +330,9 @@ describe('Ingest Manager - packageToConfig', () => { }); }); it('returns datasource with custom name', () => { - expect(packageToConfigDatasource(mockPackage, '1', '2', 'ds-1')).toEqual({ + expect(packageToConfigDatasource(mockPackage, '1', '2', 'default', 'ds-1')).toEqual({ config_id: '1', + namespace: 'default', enabled: true, inputs: [], name: 'ds-1', @@ -348,8 +350,8 @@ describe('Ingest Manager - packageToConfig', () => { mockPackage, '1', '2', - 'ds-1', 'mock-namespace', + 'ds-1', 'Test description' ) ).toEqual({ @@ -373,8 +375,11 @@ describe('Ingest Manager - packageToConfig', () => { config_templates: [{ inputs: [{ type: 'foo' }] }], } as unknown) as PackageInfo; - expect(packageToConfigDatasource(mockPackageWithDatasources, '1', '2', 'ds-1')).toEqual({ + expect( + packageToConfigDatasource(mockPackageWithDatasources, '1', '2', 'default', 'ds-1') + ).toEqual({ config_id: '1', + namespace: 'default', enabled: true, inputs: [{ type: 'foo', enabled: true, streams: [] }], name: 'ds-1', diff --git a/x-pack/plugins/ingest_manager/common/services/package_to_config.ts b/x-pack/plugins/ingest_manager/common/services/package_to_config.ts index f5661d7677f5e..46af03b95078a 100644 --- a/x-pack/plugins/ingest_manager/common/services/package_to_config.ts +++ b/x-pack/plugins/ingest_manager/common/services/package_to_config.ts @@ -120,8 +120,8 @@ export const packageToConfigDatasource = ( packageInfo: PackageInfo, configId: string, outputId: string, + namespace: string = '', datasourceName?: string, - namespace?: string, description?: string ): NewPackageConfig => { return { diff --git a/x-pack/plugins/ingest_manager/common/types/models/agent_config.ts b/x-pack/plugins/ingest_manager/common/types/models/agent_config.ts index 17b00f116b603..a6040742e45fc 100644 --- a/x-pack/plugins/ingest_manager/common/types/models/agent_config.ts +++ b/x-pack/plugins/ingest_manager/common/types/models/agent_config.ts @@ -3,7 +3,7 @@ * or more contributor license agreements. Licensed under the Elastic License; * you may not use this file except in compliance with the Elastic License. */ -import { PackageConfig, PackageConfigPackage, PackageConfigInputStream } from './package_config'; +import { PackageConfig, PackageConfigPackage } from './package_config'; import { Output } from './output'; export enum AgentConfigStatus { @@ -13,7 +13,7 @@ export enum AgentConfigStatus { export interface NewAgentConfig { name: string; - namespace?: string; + namespace: string; description?: string; is_default?: boolean; monitoring_enabled?: Array<'logs' | 'metrics'>; @@ -30,10 +30,14 @@ export interface AgentConfig extends NewAgentConfig { export type AgentConfigSOAttributes = Omit; -export type FullAgentConfigInputStream = Pick & { - dataset: { name: string }; +export interface FullAgentConfigInputStream { + id: string; + dataset: { + name: string; + type: string; + }; [key: string]: any; -}; +} export interface FullAgentConfigInput { id: string; diff --git a/x-pack/plugins/ingest_manager/common/types/models/package_config.ts b/x-pack/plugins/ingest_manager/common/types/models/package_config.ts index f6300d35def05..e9595bab0174e 100644 --- a/x-pack/plugins/ingest_manager/common/types/models/package_config.ts +++ b/x-pack/plugins/ingest_manager/common/types/models/package_config.ts @@ -24,21 +24,19 @@ export interface NewPackageConfigInputStream { name: string; type: string; }; - processors?: string[]; - config?: PackageConfigConfigRecord; vars?: PackageConfigConfigRecord; + config?: PackageConfigConfigRecord; } export interface PackageConfigInputStream extends NewPackageConfigInputStream { - agent_stream?: any; + compiled_stream?: any; } export interface NewPackageConfigInput { type: string; enabled: boolean; - processors?: string[]; - config?: PackageConfigConfigRecord; vars?: PackageConfigConfigRecord; + config?: PackageConfigConfigRecord; streams: NewPackageConfigInputStream[]; } @@ -49,11 +47,11 @@ export interface PackageConfigInput extends Omit { const [datasource, setDatasource] = useState({ name: '', description: '', + namespace: '', config_id: '', enabled: true, output_id: '', // TODO: Blank for now as we only support default output diff --git a/x-pack/plugins/ingest_manager/public/applications/ingest_manager/sections/agent_config/create_datasource_page/services/validate_datasource.test.ts b/x-pack/plugins/ingest_manager/public/applications/ingest_manager/sections/agent_config/create_datasource_page/services/validate_datasource.test.ts index cdf49290ea18e..2a94ddf82ecc6 100644 --- a/x-pack/plugins/ingest_manager/public/applications/ingest_manager/sections/agent_config/create_datasource_page/services/validate_datasource.test.ts +++ b/x-pack/plugins/ingest_manager/public/applications/ingest_manager/sections/agent_config/create_datasource_page/services/validate_datasource.test.ts @@ -143,6 +143,7 @@ describe('Ingest Manager - validateDatasource()', () => { const validDatasource: NewPackageConfig = { name: 'datasource1-1', + namespace: 'default', config_id: 'test-config', enabled: true, output_id: 'test-output', @@ -315,6 +316,7 @@ describe('Ingest Manager - validateDatasource()', () => { const noErrorsValidationResults = { name: null, description: null, + namespace: null, inputs: { foo: { vars: { @@ -356,6 +358,7 @@ describe('Ingest Manager - validateDatasource()', () => { expect(validateDatasource(invalidDatasource, mockPackage)).toEqual({ name: ['Name is required'], description: null, + namespace: null, inputs: { foo: { vars: { @@ -412,6 +415,7 @@ describe('Ingest Manager - validateDatasource()', () => { ).toEqual({ name: ['Name is required'], description: null, + namespace: null, inputs: { foo: { vars: { @@ -458,6 +462,7 @@ describe('Ingest Manager - validateDatasource()', () => { ).toEqual({ name: null, description: null, + namespace: null, inputs: null, }); expect( @@ -468,6 +473,7 @@ describe('Ingest Manager - validateDatasource()', () => { ).toEqual({ name: null, description: null, + namespace: null, inputs: null, }); }); @@ -481,6 +487,7 @@ describe('Ingest Manager - validateDatasource()', () => { ).toEqual({ name: null, description: null, + namespace: null, inputs: null, }); expect( @@ -491,6 +498,7 @@ describe('Ingest Manager - validateDatasource()', () => { ).toEqual({ name: null, description: null, + namespace: null, inputs: null, }); }); @@ -542,6 +550,7 @@ describe('Ingest Manager - validationHasErrors()', () => { validationHasErrors({ name: ['name error'], description: null, + namespace: null, inputs: { input1: { vars: { foo: null, bar: null }, @@ -554,6 +563,7 @@ describe('Ingest Manager - validationHasErrors()', () => { validationHasErrors({ name: null, description: null, + namespace: null, inputs: { input1: { vars: { foo: ['foo error'], bar: null }, @@ -566,6 +576,7 @@ describe('Ingest Manager - validationHasErrors()', () => { validationHasErrors({ name: null, description: null, + namespace: null, inputs: { input1: { vars: { foo: null, bar: null }, @@ -581,6 +592,7 @@ describe('Ingest Manager - validationHasErrors()', () => { validationHasErrors({ name: null, description: null, + namespace: null, inputs: { input1: { vars: { foo: null, bar: null }, diff --git a/x-pack/plugins/ingest_manager/public/applications/ingest_manager/sections/agent_config/create_datasource_page/services/validate_datasource.ts b/x-pack/plugins/ingest_manager/public/applications/ingest_manager/sections/agent_config/create_datasource_page/services/validate_datasource.ts index 0525e23275484..b9bc621e3bbec 100644 --- a/x-pack/plugins/ingest_manager/public/applications/ingest_manager/sections/agent_config/create_datasource_page/services/validate_datasource.ts +++ b/x-pack/plugins/ingest_manager/public/applications/ingest_manager/sections/agent_config/create_datasource_page/services/validate_datasource.ts @@ -32,6 +32,7 @@ export type DatasourceInputValidationResults = DatasourceConfigValidationResults export interface DatasourceValidationResults { name: Errors; description: Errors; + namespace: Errors; inputs: Record | null; } @@ -46,6 +47,7 @@ export const validateDatasource = ( const validationResults: DatasourceValidationResults = { name: null, description: null, + namespace: null, inputs: {}, }; @@ -57,6 +59,14 @@ export const validateDatasource = ( ]; } + if (!datasource.namespace.trim()) { + validationResults.namespace = [ + i18n.translate('xpack.ingestManager.datasourceValidation.namespaceRequiredErrorMessage', { + defaultMessage: 'Namespace is required', + }), + ]; + } + if ( !packageInfo.config_templates || packageInfo.config_templates.length === 0 || diff --git a/x-pack/plugins/ingest_manager/public/applications/ingest_manager/sections/agent_config/create_datasource_page/step_define_datasource.tsx b/x-pack/plugins/ingest_manager/public/applications/ingest_manager/sections/agent_config/create_datasource_page/step_define_datasource.tsx index 9038177b4d8d8..ef94977485922 100644 --- a/x-pack/plugins/ingest_manager/public/applications/ingest_manager/sections/agent_config/create_datasource_page/step_define_datasource.tsx +++ b/x-pack/plugins/ingest_manager/public/applications/ingest_manager/sections/agent_config/create_datasource_page/step_define_datasource.tsx @@ -135,12 +135,14 @@ export const StepDefineDatasource: React.FunctionComponent<{ /> {/* Todo: Populate list of existing namespaces */} - {isShowingAdvancedDefine ? ( + {isShowingAdvancedDefine || !!validationResults.namespace ? ( { const [datasource, setDatasource] = useState({ name: '', description: '', + namespace: '', config_id: '', enabled: true, output_id: '', @@ -102,7 +103,7 @@ export const EditDatasourcePage: React.FunctionComponent = () => { updated_at, ...restOfDatasource } = datasourceData.item; - // Remove `agent_stream` from all stream info, we assign this after saving + // Remove `compiled_stream` from all stream info, we assign this after saving const newDatasource = { ...restOfDatasource, inputs: inputs.map((input) => { @@ -110,7 +111,7 @@ export const EditDatasourcePage: React.FunctionComponent = () => { return { ...restOfInput, streams: streams.map((stream) => { - const { agent_stream, ...restOfStream } = stream; + const { compiled_stream, ...restOfStream } = stream; return restOfStream; }), }; diff --git a/x-pack/plugins/ingest_manager/server/routes/agent_config/handlers.ts b/x-pack/plugins/ingest_manager/server/routes/agent_config/handlers.ts index 9e1628a5c1117..bab12a930d788 100644 --- a/x-pack/plugins/ingest_manager/server/routes/agent_config/handlers.ts +++ b/x-pack/plugins/ingest_manager/server/routes/agent_config/handlers.ts @@ -127,6 +127,7 @@ export const createAgentConfigHandler: RequestHandler< // Create the system monitoring datasource and add it to config. if (withSysMonitoring && newSysDatasource !== undefined && agentConfig !== undefined) { newSysDatasource.config_id = agentConfig.id; + newSysDatasource.namespace = agentConfig.namespace; const sysDatasource = await datasourceService.create(soClient, newSysDatasource, { user }); if (sysDatasource) { diff --git a/x-pack/plugins/ingest_manager/server/routes/datasource/handlers.ts b/x-pack/plugins/ingest_manager/server/routes/datasource/handlers.ts index c4fb4ac08081d..54507460ddb57 100644 --- a/x-pack/plugins/ingest_manager/server/routes/datasource/handlers.ts +++ b/x-pack/plugins/ingest_manager/server/routes/datasource/handlers.ts @@ -98,12 +98,7 @@ export const createDatasourceHandler: RequestHandler< } } - // The type `NewPackageConfig` and the `PackageConfigBaseSchema` are incompatible. - // `NewDatasource` defines `namespace` as optional string, which means that `undefined` is a - // valid value, however, the schema defines it as string with a minimum length of 1. - // Here, we need to cast the value back to the schema type and ignore the TS error. - // @ts-ignore - newData = updatedNewData as typeof CreatePackageConfigRequestSchema.body; + newData = updatedNewData; } // Make sure the datasource package is installed diff --git a/x-pack/plugins/ingest_manager/server/saved_objects/index.ts b/x-pack/plugins/ingest_manager/server/saved_objects/index.ts index 6aa747259b7ad..f568d2a7d96c5 100644 --- a/x-pack/plugins/ingest_manager/server/saved_objects/index.ts +++ b/x-pack/plugins/ingest_manager/server/saved_objects/index.ts @@ -185,6 +185,7 @@ const savedObjectTypes: { [key: string]: SavedObjectsType } = { name: { type: 'keyword' }, description: { type: 'text' }, namespace: { type: 'keyword' }, + enabled: { type: 'boolean' }, config_id: { type: 'keyword' }, output_id: { type: 'keyword' }, package: { @@ -198,6 +199,7 @@ const savedObjectTypes: { [key: string]: SavedObjectsType } = { type: 'nested', properties: { type: { type: 'keyword' }, + enabled: { type: 'boolean' }, vars: { type: 'flattened' }, config: { type: 'flattened' }, streams: { diff --git a/x-pack/plugins/ingest_manager/server/services/datasource.test.ts b/x-pack/plugins/ingest_manager/server/services/datasource.test.ts index 8d98e41c8ae69..afd067e466164 100644 --- a/x-pack/plugins/ingest_manager/server/services/datasource.test.ts +++ b/x-pack/plugins/ingest_manager/server/services/datasource.test.ts @@ -89,7 +89,7 @@ describe('Datasource service', () => { value: ['/var/log/set.log'], }, }, - agent_stream: { + compiled_stream: { metricset: ['dataset1'], paths: ['/var/log/set.log'], type: 'log', @@ -150,7 +150,7 @@ describe('Datasource service', () => { id: 'dataset01', dataset: { name: 'package.dataset1', type: 'logs' }, enabled: true, - agent_stream: { + compiled_stream: { metricset: ['dataset1'], paths: ['/var/log/set.log'], type: 'log', diff --git a/x-pack/plugins/ingest_manager/server/services/datasource.ts b/x-pack/plugins/ingest_manager/server/services/datasource.ts index 3fd89233d3494..a4aca775916c9 100644 --- a/x-pack/plugins/ingest_manager/server/services/datasource.ts +++ b/x-pack/plugins/ingest_manager/server/services/datasource.ts @@ -291,7 +291,7 @@ async function _assignPackageStreamToStream( stream: PackageConfigInputStream ) { if (!stream.enabled) { - return { ...stream, agent_stream: undefined }; + return { ...stream, compiled_stream: undefined }; } const datasetPath = getDataset(stream.dataset.name); const packageDatasets = pkgInfo.datasets; @@ -335,7 +335,7 @@ async function _assignPackageStreamToStream( pkgStream.buffer.toString() ); - stream.agent_stream = yaml; + stream.compiled_stream = yaml; return { ...stream }; } diff --git a/x-pack/plugins/ingest_manager/server/services/setup.ts b/x-pack/plugins/ingest_manager/server/services/setup.ts index a787520e7002f..7a911591c8b8e 100644 --- a/x-pack/plugins/ingest_manager/server/services/setup.ts +++ b/x-pack/plugins/ingest_manager/server/services/setup.ts @@ -175,7 +175,6 @@ async function addPackageToConfig( packageInfo, config.id, defaultOutput.id, - undefined, config.namespace ); newDatasource.inputs = await datasourceService.assignPackageStream( diff --git a/x-pack/plugins/ingest_manager/server/types/models/package_config.ts b/x-pack/plugins/ingest_manager/server/types/models/package_config.ts index 45a8cd5566e66..4b9718dfbe165 100644 --- a/x-pack/plugins/ingest_manager/server/types/models/package_config.ts +++ b/x-pack/plugins/ingest_manager/server/types/models/package_config.ts @@ -31,7 +31,6 @@ const PackageConfigBaseSchema = { schema.object({ type: schema.string(), enabled: schema.boolean(), - processors: schema.maybe(schema.arrayOf(schema.string())), vars: schema.maybe(ConfigRecordSchema), config: schema.maybe( schema.recordOf( @@ -47,7 +46,6 @@ const PackageConfigBaseSchema = { id: schema.string(), enabled: schema.boolean(), dataset: schema.object({ name: schema.string(), type: schema.string() }), - processors: schema.maybe(schema.arrayOf(schema.string())), vars: schema.maybe(ConfigRecordSchema), config: schema.maybe( schema.recordOf( From 58e5e8675128275594aaaf682abc453575ecb97a Mon Sep 17 00:00:00 2001 From: Jen Huang Date: Mon, 29 Jun 2020 10:46:21 -0700 Subject: [PATCH 07/16] Rename server-side datasource references in file names, variable names, and routes --- x-pack/plugins/ingest_manager/README.md | 2 +- .../common/constants/agent_config.ts | 2 +- .../ingest_manager/common/constants/routes.ts | 14 ++-- .../ingest_manager/common/services/index.ts | 4 +- ...> package_configs_to_agent_inputs.test.ts} | 32 ++++---- ....ts => package_configs_to_agent_inputs.ts} | 22 ++--- .../common/services/package_to_config.test.ts | 52 ++++++------ .../common/services/package_to_config.ts | 30 ++++--- .../ingest_manager/common/services/routes.ts | 18 ++-- .../ingest_manager/common/types/models/epm.ts | 2 +- .../common/types/rest_spec/package_config.ts | 4 +- .../hooks/use_request/datasource.ts | 16 ++-- .../components/datasource_delete_provider.tsx | 2 +- .../step_define_datasource.tsx | 4 +- .../sections/epm/screens/detail/content.tsx | 2 +- .../epm/screens/detail/side_nav_links.tsx | 7 +- .../ingest_manager/services/index.ts | 6 +- .../ingest_manager/server/constants/index.ts | 2 +- x-pack/plugins/ingest_manager/server/index.ts | 2 +- .../server/integration_tests/router.test.ts | 22 ++--- x-pack/plugins/ingest_manager/server/mocks.ts | 8 +- .../plugins/ingest_manager/server/plugin.ts | 16 ++-- .../server/routes/agent_config/handlers.ts | 30 +++---- .../ingest_manager/server/routes/index.ts | 2 +- .../handlers.test.ts} | 38 ++++----- .../handlers.ts | 65 ++++++++------- .../{datasource => package_config}/index.ts | 32 ++++---- .../server/services/agent_config.ts | 43 +++++----- .../server/services/epm/packages/remove.ts | 6 +- .../ingest_manager/server/services/index.ts | 2 +- ...asource.test.ts => package_config.test.ts} | 8 +- .../{datasource.ts => package_config.ts} | 82 ++++++++++--------- .../ingest_manager/server/services/setup.ts | 30 +++---- .../server/types/rest_spec/package_config.ts | 4 +- .../policy/store/policy_list/middleware.ts | 4 +- .../endpoint/endpoint_app_context_services.ts | 4 +- .../server/endpoint/ingest_integration.ts | 24 +++--- .../server/endpoint/mocks.ts | 4 +- 38 files changed, 329 insertions(+), 318 deletions(-) rename x-pack/plugins/ingest_manager/common/services/{datasources_to_agent_inputs.test.ts => package_configs_to_agent_inputs.test.ts} (82%) rename x-pack/plugins/ingest_manager/common/services/{datasources_to_agent_inputs.ts => package_configs_to_agent_inputs.ts} (73%) rename x-pack/plugins/ingest_manager/server/routes/{datasource/datasource_handlers.test.ts => package_config/handlers.test.ts} (87%) rename x-pack/plugins/ingest_manager/server/routes/{datasource => package_config}/handlers.ts (71%) rename x-pack/plugins/ingest_manager/server/routes/{datasource => package_config}/index.ts (67%) rename x-pack/plugins/ingest_manager/server/services/{datasource.test.ts => package_config.test.ts} (94%) rename x-pack/plugins/ingest_manager/server/services/{datasource.ts => package_config.ts} (80%) diff --git a/x-pack/plugins/ingest_manager/README.md b/x-pack/plugins/ingest_manager/README.md index 50c42544b8bdc..eebafc76a5e00 100644 --- a/x-pack/plugins/ingest_manager/README.md +++ b/x-pack/plugins/ingest_manager/README.md @@ -3,7 +3,7 @@ ## Plugin - The plugin is disabled by default. See the TypeScript type for the [the available plugin configuration options](https://github.com/elastic/kibana/blob/master/x-pack/plugins/ingest_manager/common/types/index.ts#L9-L27) -- Setting `xpack.ingestManager.enabled=true` enables the plugin including the EPM and Fleet features. It also adds the `DATASOURCE_API_ROUTES` and `AGENT_CONFIG_API_ROUTES` values in [`common/constants/routes.ts`](./common/constants/routes.ts) +- Setting `xpack.ingestManager.enabled=true` enables the plugin including the EPM and Fleet features. It also adds the `PACKAGE_CONFIG_API_ROUTES` and `AGENT_CONFIG_API_ROUTES` values in [`common/constants/routes.ts`](./common/constants/routes.ts) - Adding `--xpack.ingestManager.epm.enabled=false` will disable the EPM API & UI - Adding `--xpack.ingestManager.fleet.enabled=false` will disable the Fleet API & UI - [code for adding the routes](https://github.com/elastic/kibana/blob/1f27d349533b1c2865c10c45b2cf705d7416fb36/x-pack/plugins/ingest_manager/server/plugin.ts#L115-L133) diff --git a/x-pack/plugins/ingest_manager/common/constants/agent_config.ts b/x-pack/plugins/ingest_manager/common/constants/agent_config.ts index 9bc1293799d3c..30ca92f5f32f3 100644 --- a/x-pack/plugins/ingest_manager/common/constants/agent_config.ts +++ b/x-pack/plugins/ingest_manager/common/constants/agent_config.ts @@ -12,7 +12,7 @@ export const DEFAULT_AGENT_CONFIG = { namespace: 'default', description: 'Default agent configuration created by Kibana', status: AgentConfigStatus.Active, - datasources: [], + package_configs: [], is_default: true, monitoring_enabled: ['logs', 'metrics'] as Array<'logs' | 'metrics'>, }; diff --git a/x-pack/plugins/ingest_manager/common/constants/routes.ts b/x-pack/plugins/ingest_manager/common/constants/routes.ts index 1fe29aa54f6f9..c9112db6b4e0c 100644 --- a/x-pack/plugins/ingest_manager/common/constants/routes.ts +++ b/x-pack/plugins/ingest_manager/common/constants/routes.ts @@ -7,7 +7,7 @@ export const API_ROOT = `/api/ingest_manager`; export const EPM_API_ROOT = `${API_ROOT}/epm`; export const DATA_STREAM_API_ROOT = `${API_ROOT}/data_streams`; -export const DATASOURCE_API_ROOT = `${API_ROOT}/datasources`; +export const PACKAGE_CONFIG_API_ROOT = `${API_ROOT}/package_configs`; export const AGENT_CONFIG_API_ROOT = `${API_ROOT}/agent_configs`; export const FLEET_API_ROOT = `${API_ROOT}/fleet`; @@ -30,12 +30,12 @@ export const DATA_STREAM_API_ROUTES = { }; // Datasource API routes -export const DATASOURCE_API_ROUTES = { - LIST_PATTERN: `${DATASOURCE_API_ROOT}`, - INFO_PATTERN: `${DATASOURCE_API_ROOT}/{datasourceId}`, - CREATE_PATTERN: `${DATASOURCE_API_ROOT}`, - UPDATE_PATTERN: `${DATASOURCE_API_ROOT}/{datasourceId}`, - DELETE_PATTERN: `${DATASOURCE_API_ROOT}/delete`, +export const PACKAGE_CONFIG_API_ROUTES = { + LIST_PATTERN: `${PACKAGE_CONFIG_API_ROOT}`, + INFO_PATTERN: `${PACKAGE_CONFIG_API_ROOT}/{packageConfigId}`, + CREATE_PATTERN: `${PACKAGE_CONFIG_API_ROOT}`, + UPDATE_PATTERN: `${PACKAGE_CONFIG_API_ROOT}/{packageConfigId}`, + DELETE_PATTERN: `${PACKAGE_CONFIG_API_ROOT}/delete`, }; // Agent config API routes diff --git a/x-pack/plugins/ingest_manager/common/services/index.ts b/x-pack/plugins/ingest_manager/common/services/index.ts index e53d97972fa2f..a0db7c20747e2 100644 --- a/x-pack/plugins/ingest_manager/common/services/index.ts +++ b/x-pack/plugins/ingest_manager/common/services/index.ts @@ -6,8 +6,8 @@ import * as AgentStatusKueryHelper from './agent_status'; export * from './routes'; -export { packageToConfigDatasourceInputs, packageToConfigDatasource } from './package_to_config'; -export { storedDatasourcesToAgentInputs } from './datasources_to_agent_inputs'; +export { packageToPackageConfigInputs, packageToPackageConfig } from './package_to_config'; +export { storedPackageConfigsToAgentInputs } from './package_configs_to_agent_inputs'; export { configToYaml } from './config_to_yaml'; export { AgentStatusKueryHelper }; export { decodeCloudId } from './decode_cloud_id'; diff --git a/x-pack/plugins/ingest_manager/common/services/datasources_to_agent_inputs.test.ts b/x-pack/plugins/ingest_manager/common/services/package_configs_to_agent_inputs.test.ts similarity index 82% rename from x-pack/plugins/ingest_manager/common/services/datasources_to_agent_inputs.test.ts rename to x-pack/plugins/ingest_manager/common/services/package_configs_to_agent_inputs.test.ts index 2cf7b25ec0cd5..a4d87f54b0915 100644 --- a/x-pack/plugins/ingest_manager/common/services/datasources_to_agent_inputs.test.ts +++ b/x-pack/plugins/ingest_manager/common/services/package_configs_to_agent_inputs.test.ts @@ -4,12 +4,12 @@ * you may not use this file except in compliance with the Elastic License. */ import { PackageConfig, PackageConfigInput } from '../types'; -import { storedDatasourcesToAgentInputs } from './datasources_to_agent_inputs'; +import { storedPackageConfigsToAgentInputs } from './package_configs_to_agent_inputs'; -describe('Ingest Manager - storedDatasourcesToAgentInputs', () => { - const mockDatasource: PackageConfig = { +describe('Ingest Manager - storedPackageConfigsToAgentInputs', () => { + const mockPackageConfig: PackageConfig = { id: 'some-uuid', - name: 'mock-datasource', + name: 'mock-package-config', description: '', created_at: '', created_by: '', @@ -74,13 +74,13 @@ describe('Ingest Manager - storedDatasourcesToAgentInputs', () => { ], }; - it('returns no inputs for datasource with no inputs, or only disabled inputs', () => { - expect(storedDatasourcesToAgentInputs([mockDatasource])).toEqual([]); + it('returns no inputs for package config with no inputs, or only disabled inputs', () => { + expect(storedPackageConfigsToAgentInputs([mockPackageConfig])).toEqual([]); expect( - storedDatasourcesToAgentInputs([ + storedPackageConfigsToAgentInputs([ { - ...mockDatasource, + ...mockPackageConfig, package: { name: 'mock-package', title: 'Mock package', @@ -91,9 +91,9 @@ describe('Ingest Manager - storedDatasourcesToAgentInputs', () => { ).toEqual([]); expect( - storedDatasourcesToAgentInputs([ + storedPackageConfigsToAgentInputs([ { - ...mockDatasource, + ...mockPackageConfig, inputs: [{ ...mockInput, enabled: false }], }, ]) @@ -102,9 +102,9 @@ describe('Ingest Manager - storedDatasourcesToAgentInputs', () => { it('returns agent inputs', () => { expect( - storedDatasourcesToAgentInputs([ + storedPackageConfigsToAgentInputs([ { - ...mockDatasource, + ...mockPackageConfig, package: { name: 'mock-package', title: 'Mock package', @@ -116,7 +116,7 @@ describe('Ingest Manager - storedDatasourcesToAgentInputs', () => { ).toEqual([ { id: 'some-uuid', - name: 'mock-datasource', + name: 'mock-package-config', type: 'test-logs', dataset: { namespace: 'default' }, use_output: 'default', @@ -144,9 +144,9 @@ describe('Ingest Manager - storedDatasourcesToAgentInputs', () => { it('returns agent inputs without disabled streams', () => { expect( - storedDatasourcesToAgentInputs([ + storedPackageConfigsToAgentInputs([ { - ...mockDatasource, + ...mockPackageConfig, inputs: [ { ...mockInput, @@ -158,7 +158,7 @@ describe('Ingest Manager - storedDatasourcesToAgentInputs', () => { ).toEqual([ { id: 'some-uuid', - name: 'mock-datasource', + name: 'mock-package-config', type: 'test-logs', dataset: { namespace: 'default' }, use_output: 'default', diff --git a/x-pack/plugins/ingest_manager/common/services/datasources_to_agent_inputs.ts b/x-pack/plugins/ingest_manager/common/services/package_configs_to_agent_inputs.ts similarity index 73% rename from x-pack/plugins/ingest_manager/common/services/datasources_to_agent_inputs.ts rename to x-pack/plugins/ingest_manager/common/services/package_configs_to_agent_inputs.ts index 7cdb300758085..64ba6b8a52b57 100644 --- a/x-pack/plugins/ingest_manager/common/services/datasources_to_agent_inputs.ts +++ b/x-pack/plugins/ingest_manager/common/services/package_configs_to_agent_inputs.ts @@ -6,26 +6,26 @@ import { PackageConfig, FullAgentConfigInput, FullAgentConfigInputStream } from '../types'; import { DEFAULT_OUTPUT } from '../constants'; -export const storedDatasourcesToAgentInputs = ( - datasources: PackageConfig[] +export const storedPackageConfigsToAgentInputs = ( + packageConfigs: PackageConfig[] ): FullAgentConfigInput[] => { const fullInputs: FullAgentConfigInput[] = []; - datasources.forEach((datasource) => { - if (!datasource.enabled || !datasource.inputs || !datasource.inputs.length) { + packageConfigs.forEach((packageConfig) => { + if (!packageConfig.enabled || !packageConfig.inputs || !packageConfig.inputs.length) { return; } - datasource.inputs.forEach((input) => { + packageConfig.inputs.forEach((input) => { if (!input.enabled) { return; } const fullInput: FullAgentConfigInput = { - id: datasource.id || datasource.name, - name: datasource.name, + id: packageConfig.id || packageConfig.name, + name: packageConfig.name, type: input.type, dataset: { - namespace: datasource.namespace || 'default', + namespace: packageConfig.namespace || 'default', }, use_output: DEFAULT_OUTPUT.name, ...Object.entries(input.config || {}).reduce((acc, [key, { value }]) => { @@ -48,11 +48,11 @@ export const storedDatasourcesToAgentInputs = ( }), }; - if (datasource.package) { + if (packageConfig.package) { fullInput.meta = { package: { - name: datasource.package.name, - version: datasource.package.version, + name: packageConfig.package.name, + version: packageConfig.package.version, }, }; } diff --git a/x-pack/plugins/ingest_manager/common/services/package_to_config.test.ts b/x-pack/plugins/ingest_manager/common/services/package_to_config.test.ts index dd15c5f46488b..e0cd32df1535e 100644 --- a/x-pack/plugins/ingest_manager/common/services/package_to_config.test.ts +++ b/x-pack/plugins/ingest_manager/common/services/package_to_config.test.ts @@ -4,7 +4,7 @@ * you may not use this file except in compliance with the Elastic License. */ import { PackageInfo, InstallationStatus } from '../types'; -import { packageToConfigDatasource, packageToConfigDatasourceInputs } from './package_to_config'; +import { packageToPackageConfig, packageToPackageConfigInputs } from './package_to_config'; describe('Ingest Manager - packageToConfig', () => { const mockPackage: PackageInfo = { @@ -31,15 +31,15 @@ describe('Ingest Manager - packageToConfig', () => { status: InstallationStatus.notInstalled, }; - describe('packageToConfigDatasourceInputs', () => { - it('returns empty array for packages with no datasources', () => { - expect(packageToConfigDatasourceInputs(mockPackage)).toEqual([]); - expect(packageToConfigDatasourceInputs({ ...mockPackage, config_templates: [] })).toEqual([]); + describe('packageToPackageConfigInputs', () => { + it('returns empty array for packages with no config templates', () => { + expect(packageToPackageConfigInputs(mockPackage)).toEqual([]); + expect(packageToPackageConfigInputs({ ...mockPackage, config_templates: [] })).toEqual([]); }); - it('returns empty array for packages a datasource but no inputs', () => { + it('returns empty array for packages with a config template but no inputs', () => { expect( - packageToConfigDatasourceInputs(({ + packageToPackageConfigInputs(({ ...mockPackage, config_templates: [{ inputs: [] }], } as unknown) as PackageInfo) @@ -48,13 +48,13 @@ describe('Ingest Manager - packageToConfig', () => { it('returns inputs with no streams for packages with no streams', () => { expect( - packageToConfigDatasourceInputs(({ + packageToPackageConfigInputs(({ ...mockPackage, config_templates: [{ inputs: [{ type: 'foo' }] }], } as unknown) as PackageInfo) ).toEqual([{ type: 'foo', enabled: true, streams: [] }]); expect( - packageToConfigDatasourceInputs(({ + packageToPackageConfigInputs(({ ...mockPackage, config_templates: [{ inputs: [{ type: 'foo' }, { type: 'bar' }] }], } as unknown) as PackageInfo) @@ -66,7 +66,7 @@ describe('Ingest Manager - packageToConfig', () => { it('returns inputs with streams for packages with streams', () => { expect( - packageToConfigDatasourceInputs(({ + packageToPackageConfigInputs(({ ...mockPackage, datasets: [ { type: 'logs', name: 'foo', streams: [{ input: 'foo' }] }, @@ -98,7 +98,7 @@ describe('Ingest Manager - packageToConfig', () => { it('returns inputs with streams configurations for packages with stream vars', () => { expect( - packageToConfigDatasourceInputs(({ + packageToPackageConfigInputs(({ ...mockPackage, datasets: [ { @@ -169,7 +169,7 @@ describe('Ingest Manager - packageToConfig', () => { it('returns inputs with streams configurations for packages with stream and input vars', () => { expect( - packageToConfigDatasourceInputs(({ + packageToPackageConfigInputs(({ ...mockPackage, datasets: [ { @@ -313,9 +313,9 @@ describe('Ingest Manager - packageToConfig', () => { }); }); - describe('packageToConfigDatasource', () => { - it('returns datasource with default name', () => { - expect(packageToConfigDatasource(mockPackage, '1', '2')).toEqual({ + describe('packageToPackageConfig', () => { + it('returns package config with default name', () => { + expect(packageToPackageConfig(mockPackage, '1', '2')).toEqual({ config_id: '1', namespace: '', enabled: true, @@ -329,13 +329,13 @@ describe('Ingest Manager - packageToConfig', () => { }, }); }); - it('returns datasource with custom name', () => { - expect(packageToConfigDatasource(mockPackage, '1', '2', 'default', 'ds-1')).toEqual({ + it('returns package config with custom name', () => { + expect(packageToPackageConfig(mockPackage, '1', '2', 'default', 'pkgConfig-1')).toEqual({ config_id: '1', namespace: 'default', enabled: true, inputs: [], - name: 'ds-1', + name: 'pkgConfig-1', output_id: '2', package: { name: 'mock-package', @@ -344,21 +344,21 @@ describe('Ingest Manager - packageToConfig', () => { }, }); }); - it('returns datasource with namespace and description', () => { + it('returns package config with namespace and description', () => { expect( - packageToConfigDatasource( + packageToPackageConfig( mockPackage, '1', '2', 'mock-namespace', - 'ds-1', + 'pkgConfig-1', 'Test description' ) ).toEqual({ config_id: '1', enabled: true, inputs: [], - name: 'ds-1', + name: 'pkgConfig-1', namespace: 'mock-namespace', description: 'Test description', output_id: '2', @@ -369,20 +369,20 @@ describe('Ingest Manager - packageToConfig', () => { }, }); }); - it('returns datasource with inputs', () => { - const mockPackageWithDatasources = ({ + it('returns package config with inputs', () => { + const mockPackageWithConfigTemplates = ({ ...mockPackage, config_templates: [{ inputs: [{ type: 'foo' }] }], } as unknown) as PackageInfo; expect( - packageToConfigDatasource(mockPackageWithDatasources, '1', '2', 'default', 'ds-1') + packageToPackageConfig(mockPackageWithConfigTemplates, '1', '2', 'default', 'pkgConfig-1') ).toEqual({ config_id: '1', namespace: 'default', enabled: true, inputs: [{ type: 'foo', enabled: true, streams: [] }], - name: 'ds-1', + name: 'pkgConfig-1', output_id: '2', package: { name: 'mock-package', diff --git a/x-pack/plugins/ingest_manager/common/services/package_to_config.ts b/x-pack/plugins/ingest_manager/common/services/package_to_config.ts index 46af03b95078a..5957267c7304c 100644 --- a/x-pack/plugins/ingest_manager/common/services/package_to_config.ts +++ b/x-pack/plugins/ingest_manager/common/services/package_to_config.ts @@ -40,23 +40,21 @@ const getStreamsForInputType = ( }; /* - * This service creates a datasource inputs definition from defaults provided in package info + * This service creates a package config inputs definition from defaults provided in package info */ -export const packageToConfigDatasourceInputs = ( - packageInfo: PackageInfo -): PackageConfig['inputs'] => { +export const packageToPackageConfigInputs = (packageInfo: PackageInfo): PackageConfig['inputs'] => { const inputs: PackageConfig['inputs'] = []; - // Assume package will only ever ship one datasource for now - const packageDatasource: RegistryConfigTemplate | null = + // Assume package will only ever ship one package config template for now + const packageConfigTemplate: RegistryConfigTemplate | null = packageInfo.config_templates && packageInfo.config_templates[0] ? packageInfo.config_templates[0] : null; - // Create datasource input property - if (packageDatasource?.inputs?.length) { - // Map each package datasource input to agent config datasource input - packageDatasource.inputs.forEach((packageInput) => { + // Create package config input property + if (packageConfigTemplate?.inputs?.length) { + // Map each package package config input to agent config package config input + packageConfigTemplate.inputs.forEach((packageInput) => { // Reduces registry var def into config object entry const varsReducer = ( configObject: PackageConfigConfigRecord, @@ -72,7 +70,7 @@ export const packageToConfigDatasourceInputs = ( return configObject; }; - // Map each package input stream into datasource input stream + // Map each package input stream into package config input stream const streams: PackageConfigInputStream[] = getStreamsForInputType( packageInput.type, packageInfo @@ -114,18 +112,18 @@ export const packageToConfigDatasourceInputs = ( * @param packageInfo * @param configId * @param outputId - * @param datasourceName + * @param packageConfigName */ -export const packageToConfigDatasource = ( +export const packageToPackageConfig = ( packageInfo: PackageInfo, configId: string, outputId: string, namespace: string = '', - datasourceName?: string, + packageConfigName?: string, description?: string ): NewPackageConfig => { return { - name: datasourceName || `${packageInfo.name}-1`, + name: packageConfigName || `${packageInfo.name}-1`, namespace, description, package: { @@ -136,6 +134,6 @@ export const packageToConfigDatasource = ( enabled: true, config_id: configId, output_id: outputId, - inputs: packageToConfigDatasourceInputs(packageInfo), + inputs: packageToPackageConfigInputs(packageInfo), }; }; diff --git a/x-pack/plugins/ingest_manager/common/services/routes.ts b/x-pack/plugins/ingest_manager/common/services/routes.ts index 8136abe1a42d4..463a18887174c 100644 --- a/x-pack/plugins/ingest_manager/common/services/routes.ts +++ b/x-pack/plugins/ingest_manager/common/services/routes.ts @@ -6,7 +6,7 @@ import { EPM_API_ROOT, EPM_API_ROUTES, - DATASOURCE_API_ROUTES, + PACKAGE_CONFIG_API_ROUTES, AGENT_CONFIG_API_ROUTES, DATA_STREAM_API_ROUTES, FLEET_SETUP_API_ROUTES, @@ -44,25 +44,25 @@ export const epmRouteService = { }, }; -export const datasourceRouteService = { +export const packageConfigRouteService = { getListPath: () => { - return DATASOURCE_API_ROUTES.LIST_PATTERN; + return PACKAGE_CONFIG_API_ROUTES.LIST_PATTERN; }, - getInfoPath: (datasourceId: string) => { - return DATASOURCE_API_ROUTES.INFO_PATTERN.replace('{datasourceId}', datasourceId); + getInfoPath: (packageConfigId: string) => { + return PACKAGE_CONFIG_API_ROUTES.INFO_PATTERN.replace('{packageConfigId}', packageConfigId); }, getCreatePath: () => { - return DATASOURCE_API_ROUTES.CREATE_PATTERN; + return PACKAGE_CONFIG_API_ROUTES.CREATE_PATTERN; }, - getUpdatePath: (datasourceId: string) => { - return DATASOURCE_API_ROUTES.UPDATE_PATTERN.replace('{datasourceId}', datasourceId); + getUpdatePath: (packageConfigId: string) => { + return PACKAGE_CONFIG_API_ROUTES.UPDATE_PATTERN.replace('{packageConfigId}', packageConfigId); }, getDeletePath: () => { - return DATASOURCE_API_ROUTES.DELETE_PATTERN; + return PACKAGE_CONFIG_API_ROUTES.DELETE_PATTERN; }, }; diff --git a/x-pack/plugins/ingest_manager/common/types/models/epm.ts b/x-pack/plugins/ingest_manager/common/types/models/epm.ts index f45924c30faad..a2748dc4e424f 100644 --- a/x-pack/plugins/ingest_manager/common/types/models/epm.ts +++ b/x-pack/plugins/ingest_manager/common/types/models/epm.ts @@ -19,7 +19,7 @@ export enum InstallStatus { uninstalling = 'uninstalling', } -export type DetailViewPanelName = 'overview' | 'data-sources' | 'settings'; +export type DetailViewPanelName = 'overview' | 'usages' | 'settings'; export type ServiceName = 'kibana' | 'elasticsearch'; export type AssetType = KibanaAssetType | ElasticsearchAssetType | AgentAssetType; diff --git a/x-pack/plugins/ingest_manager/common/types/rest_spec/package_config.ts b/x-pack/plugins/ingest_manager/common/types/rest_spec/package_config.ts index e8ccbae17ea36..4b8abbde47d5b 100644 --- a/x-pack/plugins/ingest_manager/common/types/rest_spec/package_config.ts +++ b/x-pack/plugins/ingest_manager/common/types/rest_spec/package_config.ts @@ -23,7 +23,7 @@ export interface GetPackageConfigsResponse { export interface GetOnePackageConfigRequest { params: { - datasourceId: string; + packageConfigId: string; }; } @@ -49,7 +49,7 @@ export type UpdatePackageConfigResponse = CreatePackageConfigResponse; export interface DeletePackageConfigsRequest { body: { - datasourceIds: string[]; + packageConfigIds: string[]; }; } diff --git a/x-pack/plugins/ingest_manager/public/applications/ingest_manager/hooks/use_request/datasource.ts b/x-pack/plugins/ingest_manager/public/applications/ingest_manager/hooks/use_request/datasource.ts index b5c2f560f7f25..89246c8236b6b 100644 --- a/x-pack/plugins/ingest_manager/public/applications/ingest_manager/hooks/use_request/datasource.ts +++ b/x-pack/plugins/ingest_manager/public/applications/ingest_manager/hooks/use_request/datasource.ts @@ -4,7 +4,7 @@ * you may not use this file except in compliance with the Elastic License. */ import { sendRequest, useRequest } from './use_request'; -import { datasourceRouteService } from '../../services'; +import { packageConfigRouteService } from '../../services'; import { CreatePackageConfigRequest, CreatePackageConfigResponse, @@ -21,18 +21,18 @@ import { export const sendCreateDatasource = (body: CreatePackageConfigRequest['body']) => { return sendRequest({ - path: datasourceRouteService.getCreatePath(), + path: packageConfigRouteService.getCreatePath(), method: 'post', body: JSON.stringify(body), }); }; export const sendUpdateDatasource = ( - datasourceId: string, + packageConfigId: string, body: UpdatePackageConfigRequest['body'] ) => { return sendRequest({ - path: datasourceRouteService.getUpdatePath(datasourceId), + path: packageConfigRouteService.getUpdatePath(packageConfigId), method: 'put', body: JSON.stringify(body), }); @@ -40,7 +40,7 @@ export const sendUpdateDatasource = ( export const sendDeleteDatasource = (body: DeletePackageConfigsRequest['body']) => { return sendRequest({ - path: datasourceRouteService.getDeletePath(), + path: packageConfigRouteService.getDeletePath(), method: 'post', body: JSON.stringify(body), }); @@ -49,14 +49,14 @@ export const sendDeleteDatasource = (body: DeletePackageConfigsRequest['body']) export function useGetDatasources(query: GetPackageConfigsRequest['query']) { return useRequest({ method: 'get', - path: datasourceRouteService.getListPath(), + path: packageConfigRouteService.getListPath(), query, }); } -export const sendGetOneDatasource = (datasourceId: string) => { +export const sendGetOneDatasource = (packageConfigId: string) => { return sendRequest({ - path: datasourceRouteService.getInfoPath(datasourceId), + path: packageConfigRouteService.getInfoPath(packageConfigId), method: 'get', }); }; diff --git a/x-pack/plugins/ingest_manager/public/applications/ingest_manager/sections/agent_config/components/datasource_delete_provider.tsx b/x-pack/plugins/ingest_manager/public/applications/ingest_manager/sections/agent_config/components/datasource_delete_provider.tsx index 86186f7f0a6dd..0c0ebc6403679 100644 --- a/x-pack/plugins/ingest_manager/public/applications/ingest_manager/sections/agent_config/components/datasource_delete_provider.tsx +++ b/x-pack/plugins/ingest_manager/public/applications/ingest_manager/sections/agent_config/components/datasource_delete_provider.tsx @@ -88,7 +88,7 @@ export const DatasourceDeleteProvider: React.FunctionComponent = ({ setIsLoading(true); try { - const { data } = await sendDeleteDatasource({ datasourceIds: datasources }); + const { data } = await sendDeleteDatasource({ packageConfigIds: datasources }); const successfulResults = data?.filter((result) => result.success) || []; const failedResults = data?.filter((result) => !result.success) || []; diff --git a/x-pack/plugins/ingest_manager/public/applications/ingest_manager/sections/agent_config/create_datasource_page/step_define_datasource.tsx b/x-pack/plugins/ingest_manager/public/applications/ingest_manager/sections/agent_config/create_datasource_page/step_define_datasource.tsx index ef94977485922..2dbc8749d00bc 100644 --- a/x-pack/plugins/ingest_manager/public/applications/ingest_manager/sections/agent_config/create_datasource_page/step_define_datasource.tsx +++ b/x-pack/plugins/ingest_manager/public/applications/ingest_manager/sections/agent_config/create_datasource_page/step_define_datasource.tsx @@ -16,7 +16,7 @@ import { EuiComboBox, } from '@elastic/eui'; import { AgentConfig, PackageInfo, PackageConfig, NewPackageConfig } from '../../../types'; -import { packageToConfigDatasourceInputs } from '../../../services'; +import { packageToPackageConfigInputs } from '../../../services'; import { Loading } from '../../../components'; import { DatasourceValidationResults } from './services'; @@ -54,7 +54,7 @@ export const StepDefineDatasource: React.FunctionComponent<{ title: packageInfo.title, version: packageInfo.version, }, - inputs: packageToConfigDatasourceInputs(packageInfo), + inputs: packageToPackageConfigInputs(packageInfo), }); } diff --git a/x-pack/plugins/ingest_manager/public/applications/ingest_manager/sections/epm/screens/detail/content.tsx b/x-pack/plugins/ingest_manager/public/applications/ingest_manager/sections/epm/screens/detail/content.tsx index 96aebb08e0c63..94bbba00c5aea 100644 --- a/x-pack/plugins/ingest_manager/public/applications/ingest_manager/sections/epm/screens/detail/content.tsx +++ b/x-pack/plugins/ingest_manager/public/applications/ingest_manager/sections/epm/screens/detail/content.tsx @@ -63,7 +63,7 @@ export function ContentPanel(props: ContentPanelProps) { latestVersion={latestVersion} /> ); - case 'data-sources': + case 'usages': return ; case 'overview': default: diff --git a/x-pack/plugins/ingest_manager/public/applications/ingest_manager/sections/epm/screens/detail/side_nav_links.tsx b/x-pack/plugins/ingest_manager/public/applications/ingest_manager/sections/epm/screens/detail/side_nav_links.tsx index 1aa491498c466..8e242fd076966 100644 --- a/x-pack/plugins/ingest_manager/public/applications/ingest_manager/sections/epm/screens/detail/side_nav_links.tsx +++ b/x-pack/plugins/ingest_manager/public/applications/ingest_manager/sections/epm/screens/detail/side_nav_links.tsx @@ -19,7 +19,7 @@ const PanelDisplayNames: Record = { overview: i18n.translate('xpack.ingestManager.epm.packageDetailsNav.overviewLinkText', { defaultMessage: 'Overview', }), - 'data-sources': i18n.translate('xpack.ingestManager.epm.packageDetailsNav.datasourcesLinkText', { + usages: i18n.translate('xpack.ingestManager.epm.packageDetailsNav.datasourcesLinkText', { defaultMessage: 'Data sources', }), settings: i18n.translate('xpack.ingestManager.epm.packageDetailsNav.settingsLinkText', { @@ -45,10 +45,7 @@ export function SideNavLinks({ name, version, active }: NavLinkProps) { `; // Don't display Data Sources tab as we haven't implemented this yet // FIXME: Restore when we implement data sources page - if ( - panel === 'data-sources' && - (true || packageInstallStatus.status !== InstallStatus.installed) - ) + if (panel === 'usages' && (true || packageInstallStatus.status !== InstallStatus.installed)) return null; return ( diff --git a/x-pack/plugins/ingest_manager/public/applications/ingest_manager/services/index.ts b/x-pack/plugins/ingest_manager/public/applications/ingest_manager/services/index.ts index ece7aef2c247f..5dc9026aebdee 100644 --- a/x-pack/plugins/ingest_manager/public/applications/ingest_manager/services/index.ts +++ b/x-pack/plugins/ingest_manager/public/applications/ingest_manager/services/index.ts @@ -8,7 +8,7 @@ export { getFlattenedObject } from '../../../../../../../src/core/public'; export { agentConfigRouteService, - datasourceRouteService, + packageConfigRouteService, dataStreamRouteService, fleetSetupRouteService, agentRouteService, @@ -18,8 +18,8 @@ export { outputRoutesService, settingsRoutesService, appRoutesService, - packageToConfigDatasourceInputs, - storedDatasourcesToAgentInputs, + packageToPackageConfigInputs, + storedPackageConfigsToAgentInputs, configToYaml, AgentStatusKueryHelper, } from '../../../../common'; diff --git a/x-pack/plugins/ingest_manager/server/constants/index.ts b/x-pack/plugins/ingest_manager/server/constants/index.ts index 2efbdef56f488..650211ce9c1b2 100644 --- a/x-pack/plugins/ingest_manager/server/constants/index.ts +++ b/x-pack/plugins/ingest_manager/server/constants/index.ts @@ -16,7 +16,7 @@ export { PLUGIN_ID, EPM_API_ROUTES, DATA_STREAM_API_ROUTES, - DATASOURCE_API_ROUTES, + PACKAGE_CONFIG_API_ROUTES, AGENT_API_ROUTES, AGENT_CONFIG_API_ROUTES, FLEET_SETUP_API_ROUTES, diff --git a/x-pack/plugins/ingest_manager/server/index.ts b/x-pack/plugins/ingest_manager/server/index.ts index 1e9011c9dfe4f..5d6a1ad321b6d 100644 --- a/x-pack/plugins/ingest_manager/server/index.ts +++ b/x-pack/plugins/ingest_manager/server/index.ts @@ -43,7 +43,7 @@ export const config = { export type IngestManagerConfigType = TypeOf; -export { DatasourceServiceInterface } from './services/datasource'; +export { PackageConfigServiceInterface } from './services/package_config'; export const plugin = (initializerContext: PluginInitializerContext) => { return new IngestManagerPlugin(initializerContext); diff --git a/x-pack/plugins/ingest_manager/server/integration_tests/router.test.ts b/x-pack/plugins/ingest_manager/server/integration_tests/router.test.ts index bfd8428222643..9d671c629ef91 100644 --- a/x-pack/plugins/ingest_manager/server/integration_tests/router.test.ts +++ b/x-pack/plugins/ingest_manager/server/integration_tests/router.test.ts @@ -46,8 +46,8 @@ describe('ingestManager', () => { await kbnTestServer.request.get(root, '/api/ingest_manager/agent_configs').expect(404); }); - it('does not have datasources api', async () => { - await kbnTestServer.request.get(root, '/api/ingest_manager/datasources').expect(404); + it('does not have package configs api', async () => { + await kbnTestServer.request.get(root, '/api/ingest_manager/package_configs').expect(404); }); it('does not have EPM api', async () => { @@ -79,8 +79,8 @@ describe('ingestManager', () => { await kbnTestServer.request.get(root, '/api/ingest_manager/agent_configs').expect(200); }); - it('has datasources api', async () => { - await kbnTestServer.request.get(root, '/api/ingest_manager/datasources').expect(200); + it('has package configs api', async () => { + await kbnTestServer.request.get(root, '/api/ingest_manager/package_configs').expect(200); }); it('does not have EPM api', async () => { @@ -92,7 +92,7 @@ describe('ingestManager', () => { }); }); - // For now, only the manager routes (/agent_configs & /datasources) are added + // For now, only the manager routes (/agent_configs & /package_configs) are added // EPM and ingest will be conditionally added when we enable these lines // https://github.com/jfsiii/kibana/blob/f73b54ebb7e0f6fc00efd8a6800a01eb2d9fb772/x-pack/plugins/ingest_manager/server/plugin.ts#L84 // adding tests to confirm the Fleet & EPM routes are never added @@ -118,8 +118,8 @@ describe('ingestManager', () => { await kbnTestServer.request.get(root, '/api/ingest_manager/agent_configs').expect(200); }); - it('has datasources api', async () => { - await kbnTestServer.request.get(root, '/api/ingest_manager/datasources').expect(200); + it('has package configs api', async () => { + await kbnTestServer.request.get(root, '/api/ingest_manager/package_configs').expect(200); }); it('does have EPM api', async () => { @@ -152,8 +152,8 @@ describe('ingestManager', () => { await kbnTestServer.request.get(root, '/api/ingest_manager/agent_configs').expect(200); }); - it('has datasources api', async () => { - await kbnTestServer.request.get(root, '/api/ingest_manager/datasources').expect(200); + it('has package configs api', async () => { + await kbnTestServer.request.get(root, '/api/ingest_manager/package_configs').expect(200); }); it('does not have EPM api', async () => { @@ -187,8 +187,8 @@ describe('ingestManager', () => { await kbnTestServer.request.get(root, '/api/ingest_manager/agent_configs').expect(200); }); - it('has datasources api', async () => { - await kbnTestServer.request.get(root, '/api/ingest_manager/datasources').expect(200); + it('has package configs api', async () => { + await kbnTestServer.request.get(root, '/api/ingest_manager/package_configs').expect(200); }); it('does have EPM api', async () => { diff --git a/x-pack/plugins/ingest_manager/server/mocks.ts b/x-pack/plugins/ingest_manager/server/mocks.ts index 3bdef14dc85a0..f305d9dd0c1a7 100644 --- a/x-pack/plugins/ingest_manager/server/mocks.ts +++ b/x-pack/plugins/ingest_manager/server/mocks.ts @@ -8,7 +8,7 @@ import { loggingSystemMock, savedObjectsServiceMock } from 'src/core/server/mock import { IngestManagerAppContext } from './plugin'; import { encryptedSavedObjectsMock } from '../../encrypted_saved_objects/server/mocks'; import { securityMock } from '../../security/server/mocks'; -import { DatasourceServiceInterface } from './services/datasource'; +import { PackageConfigServiceInterface } from './services/package_config'; export const createAppContextStartContractMock = (): IngestManagerAppContext => { return { @@ -21,10 +21,10 @@ export const createAppContextStartContractMock = (): IngestManagerAppContext => }; }; -export const createDatasourceServiceMock = () => { +export const createPackageConfigServiceMock = () => { return { assignPackageStream: jest.fn(), - buildDatasourceFromPackage: jest.fn(), + buildPackageConfigFromPackage: jest.fn(), bulkCreate: jest.fn(), create: jest.fn(), delete: jest.fn(), @@ -32,5 +32,5 @@ export const createDatasourceServiceMock = () => { getByIDs: jest.fn(), list: jest.fn(), update: jest.fn(), - } as jest.Mocked; + } as jest.Mocked; }; diff --git a/x-pack/plugins/ingest_manager/server/plugin.ts b/x-pack/plugins/ingest_manager/server/plugin.ts index c72cdb572aefe..91201dbf9848b 100644 --- a/x-pack/plugins/ingest_manager/server/plugin.ts +++ b/x-pack/plugins/ingest_manager/server/plugin.ts @@ -34,7 +34,7 @@ import { import { registerSavedObjects, registerEncryptedSavedObjects } from './saved_objects'; import { registerEPMRoutes, - registerDatasourceRoutes, + registerPackageConfigRoutes, registerDataStreamRoutes, registerAgentConfigRoutes, registerSetupRoutes, @@ -52,7 +52,7 @@ import { ESIndexPatternSavedObjectService, ESIndexPatternService, AgentService, - datasourceService, + packageConfigService, } from './services'; import { getAgentStatusById, @@ -102,8 +102,8 @@ const allSavedObjectTypes = [ * Callbacks supported by the Ingest plugin */ export type ExternalCallback = [ - 'datasourceCreate', - (newDatasource: NewPackageConfig) => Promise + 'packageConfigCreate', + (newPackageConfig: NewPackageConfig) => Promise ]; export type ExternalCallbacksStorage = Map>; @@ -115,9 +115,9 @@ export interface IngestManagerStartContract { esIndexPatternService: ESIndexPatternService; agentService: AgentService; /** - * Services for Ingest's Datasources + * Services for Ingest's package configs */ - datasourceService: typeof datasourceService; + packageConfigService: typeof packageConfigService; /** * Register callbacks for inclusion in ingest API processing * @param args @@ -205,7 +205,7 @@ export class IngestManagerPlugin if (this.security) { registerSetupRoutes(router, config); registerAgentConfigRoutes(router); - registerDatasourceRoutes(router); + registerPackageConfigRoutes(router); registerOutputRoutes(router); registerSettingsRoutes(router); registerDataStreamRoutes(router); @@ -265,7 +265,7 @@ export class IngestManagerPlugin getAgentStatusById, authenticateAgentWithAccessToken, }, - datasourceService, + packageConfigService, registerExternalCallback: (...args: ExternalCallback) => { return appContextService.addExternalCallback(...args); }, diff --git a/x-pack/plugins/ingest_manager/server/routes/agent_config/handlers.ts b/x-pack/plugins/ingest_manager/server/routes/agent_config/handlers.ts index bab12a930d788..7b12a076ff041 100644 --- a/x-pack/plugins/ingest_manager/server/routes/agent_config/handlers.ts +++ b/x-pack/plugins/ingest_manager/server/routes/agent_config/handlers.ts @@ -7,7 +7,7 @@ import { TypeOf } from '@kbn/config-schema'; import { RequestHandler, ResponseHeaders } from 'src/core/server'; import bluebird from 'bluebird'; import { configToYaml } from '../../../common/services'; -import { appContextService, agentConfigService, datasourceService } from '../../services'; +import { appContextService, agentConfigService, packageConfigService } from '../../services'; import { listAgents } from '../../services/agents'; import { AGENT_SAVED_OBJECT_TYPE } from '../../constants'; import { @@ -107,32 +107,34 @@ export const createAgentConfigHandler: RequestHandler< const withSysMonitoring = request.query.sys_monitoring ?? false; try { // eslint-disable-next-line prefer-const - let [agentConfig, newSysDatasource] = await Promise.all< + let [agentConfig, newSysPackageConfig] = await Promise.all< AgentConfig, NewPackageConfig | undefined >([ agentConfigService.create(soClient, request.body, { user, }), - // If needed, retrieve System package information and build a new Datasource for the system package - // NOTE: we ignore failures in attempting to create datasource, since config might have been created + // If needed, retrieve System package information and build a new package config for the system package + // NOTE: we ignore failures in attempting to create package config, since config might have been created // successfully withSysMonitoring - ? datasourceService - .buildDatasourceFromPackage(soClient, DefaultPackages.system) + ? packageConfigService + .buildPackageConfigFromPackage(soClient, DefaultPackages.system) .catch(() => undefined) : undefined, ]); - // Create the system monitoring datasource and add it to config. - if (withSysMonitoring && newSysDatasource !== undefined && agentConfig !== undefined) { - newSysDatasource.config_id = agentConfig.id; - newSysDatasource.namespace = agentConfig.namespace; - const sysDatasource = await datasourceService.create(soClient, newSysDatasource, { user }); + // Create the system monitoring package config and add it to agent config. + if (withSysMonitoring && newSysPackageConfig !== undefined && agentConfig !== undefined) { + newSysPackageConfig.config_id = agentConfig.id; + newSysPackageConfig.namespace = agentConfig.namespace; + const sysPackageConfig = await packageConfigService.create(soClient, newSysPackageConfig, { + user, + }); - if (sysDatasource) { - agentConfig = await agentConfigService.assignDatasources(soClient, agentConfig.id, [ - sysDatasource.id, + if (sysPackageConfig) { + agentConfig = await agentConfigService.assignPackageConfigs(soClient, agentConfig.id, [ + sysPackageConfig.id, ]); } } diff --git a/x-pack/plugins/ingest_manager/server/routes/index.ts b/x-pack/plugins/ingest_manager/server/routes/index.ts index 0978c2aa57bf6..f6b4439d8bef1 100644 --- a/x-pack/plugins/ingest_manager/server/routes/index.ts +++ b/x-pack/plugins/ingest_manager/server/routes/index.ts @@ -4,7 +4,7 @@ * you may not use this file except in compliance with the Elastic License. */ export { registerRoutes as registerAgentConfigRoutes } from './agent_config'; -export { registerRoutes as registerDatasourceRoutes } from './datasource'; +export { registerRoutes as registerPackageConfigRoutes } from './package_config'; export { registerRoutes as registerDataStreamRoutes } from './data_streams'; export { registerRoutes as registerEPMRoutes } from './epm'; export { registerRoutes as registerSetupRoutes } from './setup'; diff --git a/x-pack/plugins/ingest_manager/server/routes/datasource/datasource_handlers.test.ts b/x-pack/plugins/ingest_manager/server/routes/package_config/handlers.test.ts similarity index 87% rename from x-pack/plugins/ingest_manager/server/routes/datasource/datasource_handlers.test.ts rename to x-pack/plugins/ingest_manager/server/routes/package_config/handlers.test.ts index 379fdbf581c5e..6d712ce063290 100644 --- a/x-pack/plugins/ingest_manager/server/routes/datasource/datasource_handlers.test.ts +++ b/x-pack/plugins/ingest_manager/server/routes/package_config/handlers.test.ts @@ -7,23 +7,23 @@ import { httpServerMock, httpServiceMock } from 'src/core/server/mocks'; import { IRouter, KibanaRequest, Logger, RequestHandler, RouteConfig } from 'kibana/server'; import { registerRoutes } from './index'; -import { DATASOURCE_API_ROUTES } from '../../../common/constants'; +import { PACKAGE_CONFIG_API_ROUTES } from '../../../common/constants'; import { xpackMocks } from '../../../../../mocks'; import { appContextService } from '../../services'; import { createAppContextStartContractMock } from '../../mocks'; -import { DatasourceServiceInterface, ExternalCallback } from '../..'; +import { PackageConfigServiceInterface, ExternalCallback } from '../..'; import { CreatePackageConfigRequestSchema } from '../../types/rest_spec'; -import { datasourceService } from '../../services'; +import { packageConfigService } from '../../services'; -const datasourceServiceMock = datasourceService as jest.Mocked; +const packageConfigServiceMock = packageConfigService as jest.Mocked; -jest.mock('../../services/datasource', (): { - datasourceService: jest.Mocked; +jest.mock('../../services/package_config', (): { + packageConfigService: jest.Mocked; } => { return { - datasourceService: { + packageConfigService: { assignPackageStream: jest.fn((packageInfo, dataInputs) => Promise.resolve(dataInputs)), - buildDatasourceFromPackage: jest.fn(), + buildPackageConfigFromPackage: jest.fn(), bulkCreate: jest.fn(), create: jest.fn((soClient, newData) => Promise.resolve({ @@ -52,7 +52,7 @@ jest.mock('../../services/epm/packages', () => { }; }); -describe('When calling datasource', () => { +describe('When calling package config', () => { let routerMock: jest.Mocked; let routeHandler: RequestHandler; let routeConfig: RouteConfig; @@ -102,7 +102,7 @@ describe('When calling datasource', () => { // Set the routeConfig and routeHandler to the Create API beforeAll(() => { [routeConfig, routeHandler] = routerMock.post.mock.calls.find(([{ path }]) => - path.startsWith(DATASOURCE_API_ROUTES.CREATE_PATTERN) + path.startsWith(PACKAGE_CONFIG_API_ROUTES.CREATE_PATTERN) )!; }); @@ -151,8 +151,8 @@ describe('When calling datasource', () => { }); beforeEach(() => { - appContextService.addExternalCallback('datasourceCreate', callbackOne); - appContextService.addExternalCallback('datasourceCreate', callbackTwo); + appContextService.addExternalCallback('packageConfigCreate', callbackOne); + appContextService.addExternalCallback('packageConfigCreate', callbackTwo); }); afterEach(() => (callbackCallingOrder.length = 0)); @@ -164,7 +164,7 @@ describe('When calling datasource', () => { expect(callbackCallingOrder).toEqual(['one', 'two']); }); - it('should feed datasource returned by last callback', async () => { + it('should feed package config returned by last callback', async () => { const request = getCreateKibanaRequest(); await routeHandler(context, request, response); expect(response.ok).toHaveBeenCalled(); @@ -213,7 +213,7 @@ describe('When calling datasource', () => { const request = getCreateKibanaRequest(); await routeHandler(context, request, response); expect(response.ok).toHaveBeenCalled(); - expect(datasourceServiceMock.create.mock.calls[0][1]).toEqual({ + expect(packageConfigServiceMock.create.mock.calls[0][1]).toEqual({ config_id: 'a5ca00c0-b30c-11ea-9732-1bb05811278c', description: '', enabled: true, @@ -268,8 +268,8 @@ describe('When calling datasource', () => { }); beforeEach(() => { - appContextService.addExternalCallback('datasourceCreate', callbackThree); - appContextService.addExternalCallback('datasourceCreate', callbackFour); + appContextService.addExternalCallback('packageConfigCreate', callbackThree); + appContextService.addExternalCallback('packageConfigCreate', callbackFour); }); it('should skip over callback exceptions and still execute other callbacks', async () => { @@ -285,16 +285,16 @@ describe('When calling datasource', () => { await routeHandler(context, request, response); expect(response.ok).toHaveBeenCalled(); expect(errorLogger.mock.calls).toEqual([ - ['An external registered [datasourceCreate] callback failed when executed'], + ['An external registered [packageConfigCreate] callback failed when executed'], [new Error('callbackThree threw error on purpose')], ]); }); - it('should create datasource with last successful returned datasource', async () => { + it('should create package config with last successful returned package config', async () => { const request = getCreateKibanaRequest(); await routeHandler(context, request, response); expect(response.ok).toHaveBeenCalled(); - expect(datasourceServiceMock.create.mock.calls[0][1]).toEqual({ + expect(packageConfigServiceMock.create.mock.calls[0][1]).toEqual({ config_id: 'a5ca00c0-b30c-11ea-9732-1bb05811278c', description: '', enabled: true, diff --git a/x-pack/plugins/ingest_manager/server/routes/datasource/handlers.ts b/x-pack/plugins/ingest_manager/server/routes/package_config/handlers.ts similarity index 71% rename from x-pack/plugins/ingest_manager/server/routes/datasource/handlers.ts rename to x-pack/plugins/ingest_manager/server/routes/package_config/handlers.ts index 54507460ddb57..e212c861ce770 100644 --- a/x-pack/plugins/ingest_manager/server/routes/datasource/handlers.ts +++ b/x-pack/plugins/ingest_manager/server/routes/package_config/handlers.ts @@ -6,7 +6,7 @@ import { TypeOf } from '@kbn/config-schema'; import Boom from 'boom'; import { RequestHandler } from 'src/core/server'; -import { appContextService, datasourceService } from '../../services'; +import { appContextService, packageConfigService } from '../../services'; import { ensureInstalledPackage, getPackageInfo } from '../../services/epm/packages'; import { GetPackageConfigsRequestSchema, @@ -18,13 +18,16 @@ import { } from '../../types'; import { CreatePackageConfigResponse, DeletePackageConfigsResponse } from '../../../common'; -export const getDatasourcesHandler: RequestHandler< +export const getPackageConfigsHandler: RequestHandler< undefined, TypeOf > = async (context, request, response) => { const soClient = context.core.savedObjects.client; try { - const { items, total, page, perPage } = await datasourceService.list(soClient, request.query); + const { items, total, page, perPage } = await packageConfigService.list( + soClient, + request.query + ); return response.ok({ body: { items, @@ -42,23 +45,23 @@ export const getDatasourcesHandler: RequestHandler< } }; -export const getOneDatasourceHandler: RequestHandler> = async (context, request, response) => { const soClient = context.core.savedObjects.client; try { - const datasource = await datasourceService.get(soClient, request.params.datasourceId); - if (datasource) { + const packageConfig = await packageConfigService.get(soClient, request.params.packageConfigId); + if (packageConfig) { return response.ok({ body: { - item: datasource, + item: packageConfig, success: true, }, }); } else { return response.customError({ statusCode: 404, - body: { message: 'Datasource not found' }, + body: { message: 'Package config not found' }, }); } } catch (e) { @@ -69,7 +72,7 @@ export const getOneDatasourceHandler: RequestHandler @@ -80,8 +83,8 @@ export const createDatasourceHandler: RequestHandler< const logger = appContextService.getLogger(); let newData = { ...request.body }; try { - // If we have external callbacks, then process those now before creating the actual datasource - const externalCallbacks = appContextService.getExternalCallbacks('datasourceCreate'); + // If we have external callbacks, then process those now before creating the actual package config + const externalCallbacks = appContextService.getExternalCallbacks('packageConfigCreate'); if (externalCallbacks && externalCallbacks.size > 0) { let updatedNewData: NewPackageConfig = newData; @@ -93,7 +96,9 @@ export const createDatasourceHandler: RequestHandler< ); } catch (error) { // Log the error, but keep going and process the other callbacks - logger.error('An external registered [datasourceCreate] callback failed when executed'); + logger.error( + 'An external registered [packageConfigCreate] callback failed when executed' + ); logger.error(error); } } @@ -101,7 +106,7 @@ export const createDatasourceHandler: RequestHandler< newData = updatedNewData; } - // Make sure the datasource package is installed + // Make sure the associated package is installed if (newData.package?.name) { await ensureInstalledPackage({ savedObjectsClient: soClient, @@ -113,15 +118,15 @@ export const createDatasourceHandler: RequestHandler< pkgName: newData.package.name, pkgVersion: newData.package.version, }); - newData.inputs = (await datasourceService.assignPackageStream( + newData.inputs = (await packageConfigService.assignPackageStream( pkgInfo, newData.inputs )) as TypeOf['inputs']; } - // Create datasource - const datasource = await datasourceService.create(soClient, newData, { user }); - const body: CreatePackageConfigResponse = { item: datasource, success: true }; + // Create package config + const packageConfig = await packageConfigService.create(soClient, newData, { user }); + const body: CreatePackageConfigResponse = { item: packageConfig, success: true }; return response.ok({ body, }); @@ -134,7 +139,7 @@ export const createDatasourceHandler: RequestHandler< } }; -export const updateDatasourceHandler: RequestHandler< +export const updatePackageConfigHandler: RequestHandler< TypeOf, unknown, TypeOf @@ -142,34 +147,34 @@ export const updateDatasourceHandler: RequestHandler< const soClient = context.core.savedObjects.client; const user = (await appContextService.getSecurity()?.authc.getCurrentUser(request)) || undefined; try { - const datasource = await datasourceService.get(soClient, request.params.datasourceId); + const packageConfig = await packageConfigService.get(soClient, request.params.packageConfigId); - if (!datasource) { - throw Boom.notFound('Datasource not found'); + if (!packageConfig) { + throw Boom.notFound('Package config not found'); } const newData = { ...request.body }; - const pkg = newData.package || datasource.package; - const inputs = newData.inputs || datasource.inputs; + const pkg = newData.package || packageConfig.package; + const inputs = newData.inputs || packageConfig.inputs; if (pkg && (newData.inputs || newData.package)) { const pkgInfo = await getPackageInfo({ savedObjectsClient: soClient, pkgName: pkg.name, pkgVersion: pkg.version, }); - newData.inputs = (await datasourceService.assignPackageStream(pkgInfo, inputs)) as TypeOf< + newData.inputs = (await packageConfigService.assignPackageStream(pkgInfo, inputs)) as TypeOf< typeof CreatePackageConfigRequestSchema.body >['inputs']; } - const updatedDatasource = await datasourceService.update( + const updatedPackageConfig = await packageConfigService.update( soClient, - request.params.datasourceId, + request.params.packageConfigId, newData, { user } ); return response.ok({ - body: { item: updatedDatasource, success: true }, + body: { item: updatedPackageConfig, success: true }, }); } catch (e) { return response.customError({ @@ -179,7 +184,7 @@ export const updateDatasourceHandler: RequestHandler< } }; -export const deleteDatasourceHandler: RequestHandler< +export const deletePackageConfigHandler: RequestHandler< unknown, unknown, TypeOf @@ -187,9 +192,9 @@ export const deleteDatasourceHandler: RequestHandler< const soClient = context.core.savedObjects.client; const user = (await appContextService.getSecurity()?.authc.getCurrentUser(request)) || undefined; try { - const body: DeletePackageConfigsResponse = await datasourceService.delete( + const body: DeletePackageConfigsResponse = await packageConfigService.delete( soClient, - request.body.datasourceIds, + request.body.packageConfigIds, { user } ); return response.ok({ diff --git a/x-pack/plugins/ingest_manager/server/routes/datasource/index.ts b/x-pack/plugins/ingest_manager/server/routes/package_config/index.ts similarity index 67% rename from x-pack/plugins/ingest_manager/server/routes/datasource/index.ts rename to x-pack/plugins/ingest_manager/server/routes/package_config/index.ts index 1c5bbea72dd19..1da045e052997 100644 --- a/x-pack/plugins/ingest_manager/server/routes/datasource/index.ts +++ b/x-pack/plugins/ingest_manager/server/routes/package_config/index.ts @@ -4,7 +4,7 @@ * you may not use this file except in compliance with the Elastic License. */ import { IRouter } from 'src/core/server'; -import { PLUGIN_ID, DATASOURCE_API_ROUTES } from '../../constants'; +import { PLUGIN_ID, PACKAGE_CONFIG_API_ROUTES } from '../../constants'; import { GetPackageConfigsRequestSchema, GetOnePackageConfigRequestSchema, @@ -13,61 +13,61 @@ import { DeletePackageConfigsRequestSchema, } from '../../types'; import { - getDatasourcesHandler, - getOneDatasourceHandler, - createDatasourceHandler, - updateDatasourceHandler, - deleteDatasourceHandler, + getPackageConfigsHandler, + getOnePackageConfigHandler, + createPackageConfigHandler, + updatePackageConfigHandler, + deletePackageConfigHandler, } from './handlers'; export const registerRoutes = (router: IRouter) => { // List router.get( { - path: DATASOURCE_API_ROUTES.LIST_PATTERN, + path: PACKAGE_CONFIG_API_ROUTES.LIST_PATTERN, validate: GetPackageConfigsRequestSchema, options: { tags: [`access:${PLUGIN_ID}-read`] }, }, - getDatasourcesHandler + getPackageConfigsHandler ); // Get one router.get( { - path: DATASOURCE_API_ROUTES.INFO_PATTERN, + path: PACKAGE_CONFIG_API_ROUTES.INFO_PATTERN, validate: GetOnePackageConfigRequestSchema, options: { tags: [`access:${PLUGIN_ID}-read`] }, }, - getOneDatasourceHandler + getOnePackageConfigHandler ); // Create router.post( { - path: DATASOURCE_API_ROUTES.CREATE_PATTERN, + path: PACKAGE_CONFIG_API_ROUTES.CREATE_PATTERN, validate: CreatePackageConfigRequestSchema, options: { tags: [`access:${PLUGIN_ID}-all`] }, }, - createDatasourceHandler + createPackageConfigHandler ); // Update router.put( { - path: DATASOURCE_API_ROUTES.UPDATE_PATTERN, + path: PACKAGE_CONFIG_API_ROUTES.UPDATE_PATTERN, validate: UpdatePackageConfigRequestSchema, options: { tags: [`access:${PLUGIN_ID}-all`] }, }, - updateDatasourceHandler + updatePackageConfigHandler ); // Delete router.post( { - path: DATASOURCE_API_ROUTES.DELETE_PATTERN, + path: PACKAGE_CONFIG_API_ROUTES.DELETE_PATTERN, validate: DeletePackageConfigsRequestSchema, options: { tags: [`access:${PLUGIN_ID}`] }, }, - deleteDatasourceHandler + deletePackageConfigHandler ); }; diff --git a/x-pack/plugins/ingest_manager/server/services/agent_config.ts b/x-pack/plugins/ingest_manager/server/services/agent_config.ts index 71ece09a31173..ada35d1825069 100644 --- a/x-pack/plugins/ingest_manager/server/services/agent_config.ts +++ b/x-pack/plugins/ingest_manager/server/services/agent_config.ts @@ -20,9 +20,9 @@ import { AgentConfigStatus, ListWithKuery, } from '../types'; -import { DeleteAgentConfigResponse, storedDatasourcesToAgentInputs } from '../../common'; +import { DeleteAgentConfigResponse, storedPackageConfigsToAgentInputs } from '../../common'; import { listAgents } from './agents'; -import { datasourceService } from './datasource'; +import { packageConfigService } from './package_config'; import { outputService } from './output'; import { agentConfigUpdateEventHandler } from './agent_config_update'; @@ -115,7 +115,7 @@ class AgentConfigService { public async get( soClient: SavedObjectsClientContract, id: string, - withDatasources: boolean = true + withPackageConfigs: boolean = true ): Promise { const agentConfigSO = await soClient.get(SAVED_OBJECT_TYPE, id); if (!agentConfigSO) { @@ -128,9 +128,9 @@ class AgentConfigService { const agentConfig = { id: agentConfigSO.id, ...agentConfigSO.attributes }; - if (withDatasources) { + if (withPackageConfigs) { agentConfig.package_configs = - (await datasourceService.getByIDs( + (await packageConfigService.getByIDs( soClient, (agentConfigSO.attributes.package_configs as string[]) || [] )) || []; @@ -200,15 +200,20 @@ class AgentConfigService { options ); - // Copy all datasources + // Copy all package configs if (baseAgentConfig.package_configs.length) { - const newDatasources = (baseAgentConfig.package_configs as PackageConfig[]).map( - (datasource: PackageConfig) => { - const { id: datasourceId, ...newDatasource } = datasource; - return newDatasource; + const newPackageConfigs = (baseAgentConfig.package_configs as PackageConfig[]).map( + (packageConfig: PackageConfig) => { + const { id: packageConfigId, ...newPackageConfig } = packageConfig; + return newPackageConfig; } ); - await datasourceService.bulkCreate(soClient, newDatasources, newAgentConfig.id, options); + await packageConfigService.bulkCreate( + soClient, + newPackageConfigs, + newAgentConfig.id, + options + ); } // Get updated config @@ -228,10 +233,10 @@ class AgentConfigService { return this._update(soClient, id, {}, options?.user); } - public async assignDatasources( + public async assignPackageConfigs( soClient: SavedObjectsClientContract, id: string, - datasourceIds: string[], + packageConfigIds: string[], options?: { user?: AuthenticatedUser } ): Promise { const oldAgentConfig = await this.get(soClient, id, false); @@ -245,17 +250,17 @@ class AgentConfigService { id, { package_configs: uniq( - [...((oldAgentConfig.package_configs || []) as string[])].concat(datasourceIds) + [...((oldAgentConfig.package_configs || []) as string[])].concat(packageConfigIds) ), }, options?.user ); } - public async unassignDatasources( + public async unassignPackageConfigs( soClient: SavedObjectsClientContract, id: string, - datasourceIds: string[], + packageConfigIds: string[], options?: { user?: AuthenticatedUser } ): Promise { const oldAgentConfig = await this.get(soClient, id, false); @@ -271,7 +276,7 @@ class AgentConfigService { ...oldAgentConfig, package_configs: uniq( [...((oldAgentConfig.package_configs || []) as string[])].filter( - (dsId) => !datasourceIds.includes(dsId) + (pkgConfigId) => !packageConfigIds.includes(pkgConfigId) ) ), }, @@ -319,7 +324,7 @@ class AgentConfigService { } if (config.package_configs && config.package_configs.length) { - await datasourceService.delete(soClient, config.package_configs as string[], { + await packageConfigService.delete(soClient, config.package_configs as string[], { skipUnassignFromAgentConfigs: true, }); } @@ -373,7 +378,7 @@ class AgentConfigService { {} as FullAgentConfig['outputs'] ), }, - inputs: storedDatasourcesToAgentInputs(config.package_configs as PackageConfig[]), + inputs: storedPackageConfigsToAgentInputs(config.package_configs as PackageConfig[]), revision: config.revision, ...(config.monitoring_enabled && config.monitoring_enabled.length > 0 ? { diff --git a/x-pack/plugins/ingest_manager/server/services/epm/packages/remove.ts b/x-pack/plugins/ingest_manager/server/services/epm/packages/remove.ts index a5650f6cfa871..94af672d8e29f 100644 --- a/x-pack/plugins/ingest_manager/server/services/epm/packages/remove.ts +++ b/x-pack/plugins/ingest_manager/server/services/epm/packages/remove.ts @@ -11,7 +11,7 @@ import { AssetReference, AssetType, ElasticsearchAssetType } from '../../../type import { CallESAsCurrentUser } from '../../../types'; import { getInstallation, savedObjectTypes } from './index'; import { installIndexPatterns } from '../kibana/index_pattern/install'; -import { datasourceService } from '../..'; +import { packageConfigService } from '../..'; export async function removeInstallation(options: { savedObjectsClient: SavedObjectsClientContract; @@ -27,7 +27,7 @@ export async function removeInstallation(options: { throw Boom.badRequest(`${pkgName} is installed by default and cannot be removed`); const installedObjects = installation.installed || []; - const { total } = await datasourceService.list(savedObjectsClient, { + const { total } = await packageConfigService.list(savedObjectsClient, { kuery: `${PACKAGE_CONFIG_SAVED_OBJECT_TYPE}.package.name:${pkgName}`, page: 0, perPage: 0, @@ -35,7 +35,7 @@ export async function removeInstallation(options: { if (total > 0) throw Boom.badRequest( - `unable to remove package with existing datasource(s) in use by agent(s)` + `unable to remove package with existing package config(s) in use by agent(s)` ); // Delete the manager saved object with references to the asset objects diff --git a/x-pack/plugins/ingest_manager/server/services/index.ts b/x-pack/plugins/ingest_manager/server/services/index.ts index 49896959f3c3a..74adab09d12eb 100644 --- a/x-pack/plugins/ingest_manager/server/services/index.ts +++ b/x-pack/plugins/ingest_manager/server/services/index.ts @@ -59,8 +59,8 @@ export interface AgentService { } // Saved object services -export { datasourceService } from './datasource'; export { agentConfigService } from './agent_config'; +export { packageConfigService } from './package_config'; export { outputService } from './output'; export { settingsService }; diff --git a/x-pack/plugins/ingest_manager/server/services/datasource.test.ts b/x-pack/plugins/ingest_manager/server/services/package_config.test.ts similarity index 94% rename from x-pack/plugins/ingest_manager/server/services/datasource.test.ts rename to x-pack/plugins/ingest_manager/server/services/package_config.test.ts index afd067e466164..f8dd1c65e3e72 100644 --- a/x-pack/plugins/ingest_manager/server/services/datasource.test.ts +++ b/x-pack/plugins/ingest_manager/server/services/package_config.test.ts @@ -4,7 +4,7 @@ * you may not use this file except in compliance with the Elastic License. */ -import { datasourceService } from './datasource'; +import { packageConfigService } from './package_config'; import { PackageInfo } from '../types'; async function mockedGetAssetsData(_a: any, _b: any, dataset: string) { @@ -37,10 +37,10 @@ jest.mock('./epm/registry', () => { }; }); -describe('Datasource service', () => { +describe('Package config service', () => { describe('assignPackageStream', () => { it('should work with config variables from the stream', async () => { - const inputs = await datasourceService.assignPackageStream( + const inputs = await packageConfigService.assignPackageStream( ({ datasets: [ { @@ -101,7 +101,7 @@ describe('Datasource service', () => { }); it('should work with config variables at the input level', async () => { - const inputs = await datasourceService.assignPackageStream( + const inputs = await packageConfigService.assignPackageStream( ({ datasets: [ { diff --git a/x-pack/plugins/ingest_manager/server/services/datasource.ts b/x-pack/plugins/ingest_manager/server/services/package_config.ts similarity index 80% rename from x-pack/plugins/ingest_manager/server/services/datasource.ts rename to x-pack/plugins/ingest_manager/server/services/package_config.ts index a4aca775916c9..c886f4868ad30 100644 --- a/x-pack/plugins/ingest_manager/server/services/datasource.ts +++ b/x-pack/plugins/ingest_manager/server/services/package_config.ts @@ -7,7 +7,7 @@ import { SavedObjectsClientContract } from 'src/core/server'; import { AuthenticatedUser } from '../../../security/server'; import { DeletePackageConfigsResponse, - packageToConfigDatasource, + packageToPackageConfig, PackageConfigInput, PackageConfigInputStream, PackageInfo, @@ -33,17 +33,17 @@ function getDataset(st: string) { return st.split('.')[1]; } -class DatasourceService { +class PackageConfigService { public async create( soClient: SavedObjectsClientContract, - datasource: NewPackageConfig, + packageConfig: NewPackageConfig, options?: { id?: string; user?: AuthenticatedUser } ): Promise { const isoDate = new Date().toISOString(); const newSo = await soClient.create( SAVED_OBJECT_TYPE, { - ...datasource, + ...packageConfig, revision: 1, created_at: isoDate, created_by: options?.user?.username ?? 'system', @@ -54,7 +54,7 @@ class DatasourceService { ); // Assign it to the given agent config - await agentConfigService.assignDatasources(soClient, datasource.config_id, [newSo.id], { + await agentConfigService.assignPackageConfigs(soClient, packageConfig.config_id, [newSo.id], { user: options?.user, }); @@ -66,16 +66,16 @@ class DatasourceService { public async bulkCreate( soClient: SavedObjectsClientContract, - datasources: NewPackageConfig[], + packageConfigs: NewPackageConfig[], configId: string, options?: { user?: AuthenticatedUser } ): Promise { const isoDate = new Date().toISOString(); const { saved_objects: newSos } = await soClient.bulkCreate>( - datasources.map((datasource) => ({ + packageConfigs.map((packageConfig) => ({ type: SAVED_OBJECT_TYPE, attributes: { - ...datasource, + ...packageConfig, config_id: configId, revision: 1, created_at: isoDate, @@ -87,7 +87,7 @@ class DatasourceService { ); // Assign it to the given agent config - await agentConfigService.assignDatasources( + await agentConfigService.assignPackageConfigs( soClient, configId, newSos.map((newSo) => newSo.id), @@ -106,18 +106,18 @@ class DatasourceService { soClient: SavedObjectsClientContract, id: string ): Promise { - const datasourceSO = await soClient.get(SAVED_OBJECT_TYPE, id); - if (!datasourceSO) { + const packageConfigSO = await soClient.get(SAVED_OBJECT_TYPE, id); + if (!packageConfigSO) { return null; } - if (datasourceSO.error) { - throw new Error(datasourceSO.error.message); + if (packageConfigSO.error) { + throw new Error(packageConfigSO.error.message); } return { - id: datasourceSO.id, - ...datasourceSO.attributes, + id: packageConfigSO.id, + ...packageConfigSO.attributes, }; } @@ -125,17 +125,17 @@ class DatasourceService { soClient: SavedObjectsClientContract, ids: string[] ): Promise { - const datasourceSO = await soClient.bulkGet( + const packageConfigSO = await soClient.bulkGet( ids.map((id) => ({ id, type: SAVED_OBJECT_TYPE, })) ); - if (!datasourceSO) { + if (!packageConfigSO) { return null; } - return datasourceSO.saved_objects.map((so) => ({ + return packageConfigSO.saved_objects.map((so) => ({ id: so.id, ...so.attributes, })); @@ -147,7 +147,7 @@ class DatasourceService { ): Promise<{ items: PackageConfig[]; total: number; page: number; perPage: number }> { const { page = 1, perPage = 20, kuery } = options; - const datasources = await soClient.find({ + const packageConfigs = await soClient.find({ type: SAVED_OBJECT_TYPE, page, perPage, @@ -161,11 +161,11 @@ class DatasourceService { }); return { - items: datasources.saved_objects.map((datasourceSO) => ({ - id: datasourceSO.id, - ...datasourceSO.attributes, + items: packageConfigs.saved_objects.map((packageConfigSO) => ({ + id: packageConfigSO.id, + ...packageConfigSO.attributes, })), - total: datasources.total, + total: packageConfigs.total, page, perPage, }; @@ -174,24 +174,26 @@ class DatasourceService { public async update( soClient: SavedObjectsClientContract, id: string, - datasource: NewPackageConfig, + packageConfig: NewPackageConfig, options?: { user?: AuthenticatedUser } ): Promise { - const oldDatasource = await this.get(soClient, id); + const oldPackageConfig = await this.get(soClient, id); - if (!oldDatasource) { - throw new Error('Datasource not found'); + if (!oldPackageConfig) { + throw new Error('Package config not found'); } await soClient.update(SAVED_OBJECT_TYPE, id, { - ...datasource, - revision: oldDatasource.revision + 1, + ...packageConfig, + revision: oldPackageConfig.revision + 1, updated_at: new Date().toISOString(), updated_by: options?.user?.username ?? 'system', }); // Bump revision of associated agent config - await agentConfigService.bumpRevision(soClient, datasource.config_id, { user: options?.user }); + await agentConfigService.bumpRevision(soClient, packageConfig.config_id, { + user: options?.user, + }); return (await this.get(soClient, id)) as PackageConfig; } @@ -205,15 +207,15 @@ class DatasourceService { for (const id of ids) { try { - const oldDatasource = await this.get(soClient, id); - if (!oldDatasource) { - throw new Error('Datasource not found'); + const oldPackageConfig = await this.get(soClient, id); + if (!oldPackageConfig) { + throw new Error('Package config not found'); } if (!options?.skipUnassignFromAgentConfigs) { - await agentConfigService.unassignDatasources( + await agentConfigService.unassignPackageConfigs( soClient, - oldDatasource.config_id, - [oldDatasource.id], + oldPackageConfig.config_id, + [oldPackageConfig.id], { user: options?.user, } @@ -235,7 +237,7 @@ class DatasourceService { return result; } - public async buildDatasourceFromPackage( + public async buildPackageConfigFromPackage( soClient: SavedObjectsClientContract, pkgName: string ): Promise { @@ -253,7 +255,7 @@ class DatasourceService { if (!defaultOutputId) { throw new Error('Default output is not set'); } - return packageToConfigDatasource(pkgInfo, '', defaultOutputId); + return packageToPackageConfig(pkgInfo, '', defaultOutputId); } } } @@ -340,5 +342,5 @@ async function _assignPackageStreamToStream( return { ...stream }; } -export type DatasourceServiceInterface = DatasourceService; -export const datasourceService = new DatasourceService(); +export type PackageConfigServiceInterface = PackageConfigService; +export const packageConfigService = new PackageConfigService(); diff --git a/x-pack/plugins/ingest_manager/server/services/setup.ts b/x-pack/plugins/ingest_manager/server/services/setup.ts index 7a911591c8b8e..61a31e29c6937 100644 --- a/x-pack/plugins/ingest_manager/server/services/setup.ts +++ b/x-pack/plugins/ingest_manager/server/services/setup.ts @@ -13,7 +13,7 @@ import { outputService } from './output'; import { ensureInstalledDefaultPackages } from './epm/packages/install'; import { ensureDefaultIndices } from './epm/kibana/index_pattern/install'; import { - packageToConfigDatasource, + packageToPackageConfig, PackageConfig, AgentConfig, Installation, @@ -22,7 +22,7 @@ import { decodeCloudId, } from '../../common'; import { getPackageInfo } from './epm/packages'; -import { datasourceService } from './datasource'; +import { packageConfigService } from './package_config'; import { generateEnrollmentAPIKey } from './api_keys'; import { settingsService } from '.'; import { appContextService } from './app_context'; @@ -69,13 +69,13 @@ export async function setupIngestManager( ]); // ensure default packages are added to the default conifg - const configWithDatasource = await agentConfigService.get(soClient, config.id, true); - if (!configWithDatasource) { + const configWithPackageConfigs = await agentConfigService.get(soClient, config.id, true); + if (!configWithPackageConfigs) { throw new Error('Config not found'); } if ( - configWithDatasource.package_configs.length && - typeof configWithDatasource.package_configs[0] === 'string' + configWithPackageConfigs.package_configs.length && + typeof configWithPackageConfigs.package_configs[0] === 'string' ) { throw new Error('Config not found'); } @@ -87,12 +87,14 @@ export async function setupIngestManager( continue; } - const isInstalled = configWithDatasource.package_configs.some((d: PackageConfig | string) => { - return typeof d !== 'string' && d.package?.name === installedPackage.name; - }); + const isInstalled = configWithPackageConfigs.package_configs.some( + (d: PackageConfig | string) => { + return typeof d !== 'string' && d.package?.name === installedPackage.name; + } + ); if (!isInstalled) { - await addPackageToConfig(soClient, installedPackage, configWithDatasource, defaultOutput); + await addPackageToConfig(soClient, installedPackage, configWithPackageConfigs, defaultOutput); } } } @@ -171,16 +173,16 @@ async function addPackageToConfig( pkgVersion: packageToInstall.version, }); - const newDatasource = packageToConfigDatasource( + const newPackageConfig = packageToPackageConfig( packageInfo, config.id, defaultOutput.id, config.namespace ); - newDatasource.inputs = await datasourceService.assignPackageStream( + newPackageConfig.inputs = await packageConfigService.assignPackageStream( packageInfo, - newDatasource.inputs + newPackageConfig.inputs ); - await datasourceService.create(soClient, newDatasource); + await packageConfigService.create(soClient, newPackageConfig); } diff --git a/x-pack/plugins/ingest_manager/server/types/rest_spec/package_config.ts b/x-pack/plugins/ingest_manager/server/types/rest_spec/package_config.ts index ca8a97e0321d4..7b7ae1957c15e 100644 --- a/x-pack/plugins/ingest_manager/server/types/rest_spec/package_config.ts +++ b/x-pack/plugins/ingest_manager/server/types/rest_spec/package_config.ts @@ -13,7 +13,7 @@ export const GetPackageConfigsRequestSchema = { export const GetOnePackageConfigRequestSchema = { params: schema.object({ - datasourceId: schema.string(), + packageConfigId: schema.string(), }), }; @@ -28,6 +28,6 @@ export const UpdatePackageConfigRequestSchema = { export const DeletePackageConfigsRequestSchema = { body: schema.object({ - datasourceIds: schema.arrayOf(schema.string()), + packageConfigIds: schema.arrayOf(schema.string()), }), }; diff --git a/x-pack/plugins/security_solution/public/management/pages/policy/store/policy_list/middleware.ts b/x-pack/plugins/security_solution/public/management/pages/policy/store/policy_list/middleware.ts index 0797d14c78139..39d0511ea2bea 100644 --- a/x-pack/plugins/security_solution/public/management/pages/policy/store/policy_list/middleware.ts +++ b/x-pack/plugins/security_solution/public/management/pages/policy/store/policy_list/middleware.ts @@ -81,10 +81,10 @@ export const policyListMiddlewareFactory: ImmutableMiddlewareFactory => { - // We only care about Endpoint datasources - if (newDatasource.package?.name !== 'endpoint') { - return newDatasource; + // We only care about Endpoint package configs + if (newPackageConfig.package?.name !== 'endpoint') { + return newPackageConfig; } // We cast the type here so that any changes to the Endpoint specific data // follow the types/schema expected - let updatedDatasource = newDatasource as NewPolicyData; + let updatedPackageConfig = newPackageConfig as NewPolicyData; // Until we get the Default Policy Configuration in the Endpoint package, // we will add it here manually at creation time. // @ts-ignore - if (newDatasource.inputs.length === 0) { - updatedDatasource = { - ...newDatasource, + if (newPackageConfig.inputs.length === 0) { + updatedPackageConfig = { + ...newPackageConfig, inputs: [ { type: 'endpoint', @@ -45,5 +45,5 @@ export const handleDatasourceCreate = async ( }; } - return updatedDatasource; + return updatedPackageConfig; }; diff --git a/x-pack/plugins/security_solution/server/endpoint/mocks.ts b/x-pack/plugins/security_solution/server/endpoint/mocks.ts index 84f3d1a5631bf..ffd919db87fc9 100644 --- a/x-pack/plugins/security_solution/server/endpoint/mocks.ts +++ b/x-pack/plugins/security_solution/server/endpoint/mocks.ts @@ -12,7 +12,7 @@ import { ExternalCallback, } from '../../../ingest_manager/server'; import { EndpointAppContextServiceStartContract } from './endpoint_app_context_services'; -import { createDatasourceServiceMock } from '../../../ingest_manager/server/mocks'; +import { createPackageConfigServiceMock } from '../../../ingest_manager/server/mocks'; /** * Crates a mocked input contract for the `EndpointAppContextService#start()` method @@ -57,7 +57,7 @@ export const createMockIngestManagerStartContract = ( }, agentService: createMockAgentService(), registerExternalCallback: jest.fn((...args: ExternalCallback) => {}), - datasourceService: createDatasourceServiceMock(), + packageConfigService: createPackageConfigServiceMock(), }; }; From 4b31a663ff13f5f1075c027982983c7f27097ecc Mon Sep 17 00:00:00 2001 From: Jen Huang Date: Mon, 29 Jun 2020 10:49:07 -0700 Subject: [PATCH 08/16] Update spec file and schema file --- .../ingest_manager/common/constants/routes.ts | 2 +- .../common/openapi/spec_oas3.json | 60 +++++++++---------- .../dev_docs/schema/saved_objects.mml | 8 +-- 3 files changed, 34 insertions(+), 36 deletions(-) diff --git a/x-pack/plugins/ingest_manager/common/constants/routes.ts b/x-pack/plugins/ingest_manager/common/constants/routes.ts index c9112db6b4e0c..dad3cdce1a497 100644 --- a/x-pack/plugins/ingest_manager/common/constants/routes.ts +++ b/x-pack/plugins/ingest_manager/common/constants/routes.ts @@ -29,7 +29,7 @@ export const DATA_STREAM_API_ROUTES = { LIST_PATTERN: `${DATA_STREAM_API_ROOT}`, }; -// Datasource API routes +// Package config API routes export const PACKAGE_CONFIG_API_ROUTES = { LIST_PATTERN: `${PACKAGE_CONFIG_API_ROOT}`, INFO_PATTERN: `${PACKAGE_CONFIG_API_ROOT}/{packageConfigId}`, diff --git a/x-pack/plugins/ingest_manager/common/openapi/spec_oas3.json b/x-pack/plugins/ingest_manager/common/openapi/spec_oas3.json index d17b4115e64ab..98da898eb097a 100644 --- a/x-pack/plugins/ingest_manager/common/openapi/spec_oas3.json +++ b/x-pack/plugins/ingest_manager/common/openapi/spec_oas3.json @@ -60,7 +60,7 @@ "namespace": "default", "description": "Default agent configuration created by Kibana", "status": "active", - "datasources": ["8a5679b0-8fbf-11ea-b2ce-01c4a6127154"], + "packageConfigs": ["8a5679b0-8fbf-11ea-b2ce-01c4a6127154"], "is_default": true, "monitoring_enabled": ["logs", "metrics"], "revision": 2, @@ -175,7 +175,7 @@ "namespace": "default", "description": "Default agent configuration created by Kibana", "status": "active", - "datasources": [ + "packageConfigs": [ { "id": "8a5679b0-8fbf-11ea-b2ce-01c4a6127154", "name": "system-1", @@ -750,7 +750,7 @@ "namespace": "UPDATED namespace", "updated_on": "Fri Feb 28 2020 16:22:31 GMT-0500 (Eastern Standard Time)", "updated_by": "elastic", - "datasources": [] + "packageConfigs": [] }, "success": true } @@ -922,9 +922,9 @@ }, "parameters": [] }, - "/datasources": { + "/packageConfigs": { "get": { - "summary": "Datasources - List", + "summary": "PackageConfigs - List", "tags": [], "responses": { "200": { @@ -937,7 +937,7 @@ "items": { "type": "array", "items": { - "$ref": "#/components/schemas/Datasource" + "$ref": "#/components/schemas/PackageConfig" } }, "total": { @@ -1166,14 +1166,14 @@ } } }, - "operationId": "get-datasources", + "operationId": "get-packageConfigs", "security": [], "parameters": [] }, "parameters": [], "post": { - "summary": "Datasources - Create", - "operationId": "post-datasources", + "summary": "PackageConfigs - Create", + "operationId": "post-packageConfigs", "responses": { "200": { "description": "OK" @@ -1183,7 +1183,7 @@ "content": { "application/json": { "schema": { - "$ref": "#/components/schemas/NewDatasource" + "$ref": "#/components/schemas/NewPackageConfig" }, "examples": { "example-1": { @@ -1237,9 +1237,9 @@ ] } }, - "/datasources/{datasourceId}": { + "/packageConfigs/{packageConfigId}": { "get": { - "summary": "Datasources - Info", + "summary": "PackageConfigs - Info", "tags": [], "responses": { "200": { @@ -1250,7 +1250,7 @@ "type": "object", "properties": { "item": { - "$ref": "#/components/schemas/Datasource" + "$ref": "#/components/schemas/PackageConfig" }, "success": { "type": "boolean" @@ -1262,21 +1262,21 @@ } } }, - "operationId": "get-datasources-datasourceId" + "operationId": "get-packageConfigs-packageConfigId" }, "parameters": [ { "schema": { "type": "string" }, - "name": "datasourceId", + "name": "packageConfigId", "in": "path", "required": true } ], "put": { - "summary": "Datasources - Update", - "operationId": "put-datasources-datasourceId", + "summary": "PackageConfigs - Update", + "operationId": "put-packageConfigs-packageConfigId", "responses": { "200": { "description": "OK", @@ -1286,7 +1286,7 @@ "type": "object", "properties": { "item": { - "$ref": "#/components/schemas/Datasource" + "$ref": "#/components/schemas/PackageConfig" }, "sucess": { "type": "boolean" @@ -1724,9 +1724,7 @@ "license": "basic", "description": "This is the Elastic Endpoint package.", "type": "solution", - "categories": [ - "security" - ], + "categories": ["security"], "release": "beta", "requirement": { "kibana": { @@ -1826,7 +1824,7 @@ "path": "telemetry" } ], - "datasources": [ + "packageConfigs": [ { "name": "endpoint", "title": "Endpoint data source", @@ -2782,7 +2780,7 @@ }, "actions": [ { - "data": "{\"config\":{\"id\":\"ae556400-5e39-11ea-8b49-f9747e466f7b\",\"outputs\":{\"default\":{\"type\":\"elasticsearch\",\"hosts\":[\"http://localhost:9200\"],\"api_key\":\"\",\"api_token\":\"6ckkp3ABz7e_XRqr3LM8:gQuDfUNSRgmY0iziYqP9Hw\"}},\"datasources\":[]}}", + "data": "{\"config\":{\"id\":\"ae556400-5e39-11ea-8b49-f9747e466f7b\",\"outputs\":{\"default\":{\"type\":\"elasticsearch\",\"hosts\":[\"http://localhost:9200\"],\"api_key\":\"\",\"api_token\":\"6ckkp3ABz7e_XRqr3LM8:gQuDfUNSRgmY0iziYqP9Hw\"}},\"packageConfigs\":[]}}", "created_at": "2020-03-04T20:02:56.149Z", "id": "6a95c00a-d76d-4931-97c3-0bf935272d7d", "type": "CONFIG_CHANGE" @@ -2967,7 +2965,7 @@ "api_key": "Z-XkgHIBvwtjzIKtSCTh:AejRqdKpQx6z-6dqSI1LHg" } }, - "datasources": [ + "packageConfigs": [ { "id": "33d6bd70-a5e0-11ea-a587-5f886c8a849f", "name": "system-1", @@ -3690,7 +3688,7 @@ "type": "string", "enum": ["active", "inactive"] }, - "datasources": { + "packageConfigs": { "oneOf": [ { "items": { @@ -3699,7 +3697,7 @@ }, { "items": { - "$ref": "#/components/schemas/Datasource" + "$ref": "#/components/schemas/PackageConfig" } } ], @@ -3723,8 +3721,8 @@ } ] }, - "Datasource": { - "title": "Datasource", + "PackageConfig": { + "title": "PackageConfig", "allOf": [ { "type": "object", @@ -3743,7 +3741,7 @@ "required": ["id", "revision"] }, { - "$ref": "#/components/schemas/NewDatasource" + "$ref": "#/components/schemas/NewPackageConfig" } ], "x-examples": { @@ -3765,8 +3763,8 @@ } } }, - "NewDatasource": { - "title": "NewDatasource", + "NewPackageConfig": { + "title": "NewPackageConfig", "type": "object", "x-examples": { "example-1": { diff --git a/x-pack/plugins/ingest_manager/dev_docs/schema/saved_objects.mml b/x-pack/plugins/ingest_manager/dev_docs/schema/saved_objects.mml index 373bd10ad6628..d157bf32fa66b 100644 --- a/x-pack/plugins/ingest_manager/dev_docs/schema/saved_objects.mml +++ b/x-pack/plugins/ingest_manager/dev_docs/schema/saved_objects.mml @@ -1,11 +1,11 @@ classDiagram - agent_configs "1" -- "*" datasources + agent_configs "1" -- "*" package_configs agent_configs "1" -- "*" enrollment_api_keys agent_configs "1" -- "*" agents : is used agent_configs "*" -- "*" outputs agents "1" -- "*" agent_events agents "1" -- "*" agent_events - package "1" -- "*" datasources + package "1" -- "*" package_configs class package { installed @@ -37,14 +37,14 @@ classDiagram } class agent_configs { - datasources // datasource ids + package_configs // package_config ids name namespace description status } - class datasources { + class package_configs { name namespace config_id From 849f2286115307beee85908806d4ed72db472608 Mon Sep 17 00:00:00 2001 From: Jen Huang Date: Mon, 29 Jun 2020 10:50:52 -0700 Subject: [PATCH 09/16] Update doc wording --- .../common/openapi/spec_oas3.json | 4 ++-- .../ingest_manager/dev_docs/definitions.md | 21 ++++++++----------- 2 files changed, 11 insertions(+), 14 deletions(-) diff --git a/x-pack/plugins/ingest_manager/common/openapi/spec_oas3.json b/x-pack/plugins/ingest_manager/common/openapi/spec_oas3.json index 98da898eb097a..9617173bd0c7b 100644 --- a/x-pack/plugins/ingest_manager/common/openapi/spec_oas3.json +++ b/x-pack/plugins/ingest_manager/common/openapi/spec_oas3.json @@ -1827,7 +1827,7 @@ "packageConfigs": [ { "name": "endpoint", - "title": "Endpoint data source", + "title": "Endpoint package config", "description": "Interact with the endpoint.", "inputs": null, "multiple": false @@ -2119,7 +2119,7 @@ } }, { - "description": "The log package should be used to create data sources for all type of logs for which an package doesn't exist yet.\n", + "description": "The log package should be used to create package configs for all type of logs for which an package doesn't exist yet.\n", "download": "/epr/log/log-0.9.0.tar.gz", "icons": [ { diff --git a/x-pack/plugins/ingest_manager/dev_docs/definitions.md b/x-pack/plugins/ingest_manager/dev_docs/definitions.md index 0d9e285ab80d3..a33d95f3afa38 100644 --- a/x-pack/plugins/ingest_manager/dev_docs/definitions.md +++ b/x-pack/plugins/ingest_manager/dev_docs/definitions.md @@ -5,15 +5,14 @@ Overall documentation of Ingest Management is now maintained in the `elastic/sta This section is to define terms used across ingest management. -## Data Source +## Package Config -A data source is a definition on how to collect data from a service, for example `nginx`. A data source contains +A package config is a definition on how to collect data from a service, for example `nginx`. A package config contains definitions for one or multiple inputs and each input can contain one or multiple streams. -With the example of the nginx Data Source, it contains to inputs: `logs` and `nginx/metrics`. Logs and metrics are collected +With the example of the nginx Package Config, it contains to inputs: `logs` and `nginx/metrics`. Logs and metrics are collected differently. The `logs` input contains two streams, `access` and `error`, the `nginx/metrics` input contains the stubstatus stream. - ## Data Stream Data Streams are a [new concept](https://github.com/elastic/elasticsearch/issues/53100) in Elasticsearch which simplify @@ -23,7 +22,6 @@ ingesting data and the setup of Elasticsearch. A single, unified agent that users can deploy to hosts or containers. It controls which data is collected from the host or containers and where the data is sent. It will run Beats, Endpoint or other monitoring programs as needed. It can operate standalone or pull a configuration policy from Fleet. - ## Elastic Package Registry The Elastic Package Registry (EPR) is a service which runs under [https://epr.elastic.co]. It serves the packages through its API. @@ -42,15 +40,15 @@ the index strategy is sent to Data Streams. ## Input -An input is the configuration unit in an Agent Config that defines the options on how to collect data from -an endpoint. This could be username / password which are need to authenticate with a service or a host url +An input is the configuration unit in an Agent Config that defines the options on how to collect data from +an endpoint. This could be username / password which are need to authenticate with a service or a host url as an example. -An input is part of a Data Source and contains streams. +An input is part of a Package Config and contains streams. ## Integration -An integration is a package with the type integration. An integration package has at least 1 data source +An integration is a package with the type integration. An integration package has at least 1 package config and usually collects data from / about a service. ## Namespace @@ -59,13 +57,12 @@ A user-specified string that will be used to part of the index name in Elasticse ## Package -A package contains all the assets for the Elastic Stack. A more detailed definition of a +A package contains all the assets for the Elastic Stack. A more detailed definition of a package can be found under https://github.com/elastic/package-registry. -Besides the assets, a package contains the data source definitions with its inputs and streams. +Besides the assets, a package contains the package config definitions with its inputs and streams. ## Stream A stream is a configuration unit in the Elastic Agent config. A stream is part of an input and defines how the data fetched by this input should be processed and which Data Stream to send it to. - From 7972d2bbaeec6b602037fc7b598823d074babcf3 Mon Sep 17 00:00:00 2001 From: Jen Huang Date: Mon, 29 Jun 2020 12:50:31 -0700 Subject: [PATCH 10/16] Rename all instances of datasource in file paths and variable names on client sides, and for Endpoint too --- .../ingest_manager/constants/page_paths.ts | 20 +- .../ingest_manager/hooks/use_breadcrumbs.tsx | 18 +- .../ingest_manager/hooks/use_request/index.ts | 2 +- .../{datasource.ts => package_config.ts} | 10 +- .../agent_config/components/config_form.tsx | 4 +- .../sections/agent_config/components/index.ts | 2 +- ...tsx => package_config_delete_provider.tsx} | 80 ++++---- .../custom_configure_datasource.tsx | 62 ------- .../components/index.ts | 9 - .../create_datasource_page/constants.ts | 11 -- .../components/custom_package_config.tsx | 61 ++++++ .../components/index.ts | 9 + .../components/layout.tsx | 28 +-- .../package_config_input_config.tsx} | 44 +++-- .../package_config_input_panel.tsx} | 60 +++--- .../package_config_input_stream.tsx} | 34 ++-- .../package_config_input_var_field.tsx} | 4 +- .../index.tsx | 138 ++++++++------ .../services/index.ts | 10 +- .../services/is_advanced_var.test.ts | 0 .../services/is_advanced_var.ts | 0 .../services/validate_package_config.ts} | 65 +++---- .../validate_package_config.ts.test.ts} | 62 ++++--- .../step_configure_package.tsx} | 56 +++--- .../step_define_package_config.tsx} | 68 ++++--- .../step_select_config.tsx | 10 +- .../step_select_package.tsx | 8 +- .../types.ts | 4 +- .../details_page/components/index.ts | 4 +- .../index.tsx | 12 +- .../no_package_configs.tsx} | 19 +- .../package_configs_table.tsx} | 173 +++++++++--------- .../agent_config/details_page/index.tsx | 16 +- .../index.tsx | 140 +++++++------- .../sections/agent_config/index.tsx | 12 +- .../list_page/components/create_config.tsx | 2 +- .../sections/agent_config/list_page/index.tsx | 10 +- .../ingest_manager/sections/epm/index.tsx | 6 +- .../sections/epm/screens/detail/content.tsx | 4 +- .../sections/epm/screens/detail/header.tsx | 4 +- ...es_panel.tsx => package_configs_panel.tsx} | 15 +- .../epm/screens/detail/settings_panel.tsx | 12 +- .../epm/screens/detail/side_nav_links.tsx | 8 +- ...es.tsx => agent_config_package_badges.tsx} | 14 +- .../config_selection.tsx | 4 +- .../agent_reassign_config_flyout/index.tsx | 4 +- .../components/configuration_section.tsx | 12 +- .../ingest_manager/types/index.ts | 2 +- .../types/intra_app_route_state.ts | 10 +- x-pack/plugins/ingest_manager/public/index.ts | 8 +- .../plugins/ingest_manager/public/plugin.ts | 6 +- .../common/endpoint/generate_data.ts | 4 +- .../mock/endpoint/dependencies_start_mock.ts | 7 +- .../pages/endpoint_hosts/store/middleware.ts | 4 +- .../pages/endpoint_hosts/view/index.tsx | 6 +- .../policy/store/policy_details/middleware.ts | 8 +- .../policy/store/policy_list/index.test.ts | 14 +- .../policy/store/policy_list/middleware.ts | 8 +- .../policy_list/mock_policy_result_list.ts | 2 +- .../store/policy_list/services/ingest.test.ts | 24 +-- .../store/policy_list/services/ingest.ts | 44 ++--- .../store/policy_list/test_mock_utils.ts | 6 +- ...ource.tsx => configure_package_config.tsx} | 26 +-- .../pages/policy/view/policy_details.test.tsx | 20 +- .../pages/policy/view/policy_list.tsx | 8 +- .../security_solution/public/plugin.tsx | 7 +- .../translations/translations/ja-JP.json | 166 ++++++++--------- .../translations/translations/zh-CN.json | 166 ++++++++--------- .../ingest_manager_create_datasource_page.ts | 14 +- .../page_objects/policy_page.ts | 2 +- .../services/endpoint_policy.ts | 87 ++++----- 71 files changed, 1021 insertions(+), 978 deletions(-) rename x-pack/plugins/ingest_manager/public/applications/ingest_manager/hooks/use_request/{datasource.ts => package_config.ts} (81%) rename x-pack/plugins/ingest_manager/public/applications/ingest_manager/sections/agent_config/components/{datasource_delete_provider.tsx => package_config_delete_provider.tsx} (66%) delete mode 100644 x-pack/plugins/ingest_manager/public/applications/ingest_manager/sections/agent_config/create_datasource_page/components/custom_configure_datasource.tsx delete mode 100644 x-pack/plugins/ingest_manager/public/applications/ingest_manager/sections/agent_config/create_datasource_page/components/index.ts delete mode 100644 x-pack/plugins/ingest_manager/public/applications/ingest_manager/sections/agent_config/create_datasource_page/constants.ts create mode 100644 x-pack/plugins/ingest_manager/public/applications/ingest_manager/sections/agent_config/create_package_config_page/components/custom_package_config.tsx create mode 100644 x-pack/plugins/ingest_manager/public/applications/ingest_manager/sections/agent_config/create_package_config_page/components/index.ts rename x-pack/plugins/ingest_manager/public/applications/ingest_manager/sections/agent_config/{create_datasource_page => create_package_config_page}/components/layout.tsx (83%) rename x-pack/plugins/ingest_manager/public/applications/ingest_manager/sections/agent_config/{create_datasource_page/components/datasource_input_config.tsx => create_package_config_page/components/package_config_input_config.tsx} (78%) rename x-pack/plugins/ingest_manager/public/applications/ingest_manager/sections/agent_config/{create_datasource_page/components/datasource_input_panel.tsx => create_package_config_page/components/package_config_input_panel.tsx} (76%) rename x-pack/plugins/ingest_manager/public/applications/ingest_manager/sections/agent_config/{create_datasource_page/components/datasource_input_stream_config.tsx => create_package_config_page/components/package_config_input_stream.tsx} (83%) rename x-pack/plugins/ingest_manager/public/applications/ingest_manager/sections/agent_config/{create_datasource_page/components/datasource_input_var_field.tsx => create_package_config_page/components/package_config_input_var_field.tsx} (93%) rename x-pack/plugins/ingest_manager/public/applications/ingest_manager/sections/agent_config/{create_datasource_page => create_package_config_page}/index.tsx (72%) rename x-pack/plugins/ingest_manager/public/applications/ingest_manager/sections/agent_config/{create_datasource_page => create_package_config_page}/services/index.ts (65%) rename x-pack/plugins/ingest_manager/public/applications/ingest_manager/sections/agent_config/{create_datasource_page => create_package_config_page}/services/is_advanced_var.test.ts (100%) rename x-pack/plugins/ingest_manager/public/applications/ingest_manager/sections/agent_config/{create_datasource_page => create_package_config_page}/services/is_advanced_var.ts (100%) rename x-pack/plugins/ingest_manager/public/applications/ingest_manager/sections/agent_config/{create_datasource_page/services/validate_datasource.ts => create_package_config_page/services/validate_package_config.ts} (73%) rename x-pack/plugins/ingest_manager/public/applications/ingest_manager/sections/agent_config/{create_datasource_page/services/validate_datasource.test.ts => create_package_config_page/services/validate_package_config.ts.test.ts} (90%) rename x-pack/plugins/ingest_manager/public/applications/ingest_manager/sections/agent_config/{create_datasource_page/step_configure_datasource.tsx => create_package_config_page/step_configure_package.tsx} (69%) rename x-pack/plugins/ingest_manager/public/applications/ingest_manager/sections/agent_config/{create_datasource_page/step_define_datasource.tsx => create_package_config_page/step_define_package_config.tsx} (68%) rename x-pack/plugins/ingest_manager/public/applications/ingest_manager/sections/agent_config/{create_datasource_page => create_package_config_page}/step_select_config.tsx (91%) rename x-pack/plugins/ingest_manager/public/applications/ingest_manager/sections/agent_config/{create_datasource_page => create_package_config_page}/step_select_package.tsx (92%) rename x-pack/plugins/ingest_manager/public/applications/ingest_manager/sections/agent_config/{create_datasource_page => create_package_config_page}/types.ts (59%) rename x-pack/plugins/ingest_manager/public/applications/ingest_manager/sections/agent_config/details_page/components/{datasources => package_configs}/index.tsx (55%) rename x-pack/plugins/ingest_manager/public/applications/ingest_manager/sections/agent_config/details_page/components/{datasources/no_datasources.tsx => package_configs/no_package_configs.tsx} (61%) rename x-pack/plugins/ingest_manager/public/applications/ingest_manager/sections/agent_config/details_page/components/{datasources/datasources_table.tsx => package_configs/package_configs_table.tsx} (56%) rename x-pack/plugins/ingest_manager/public/applications/ingest_manager/sections/agent_config/{edit_datasource_page => edit_package_config_page}/index.tsx (66%) rename x-pack/plugins/ingest_manager/public/applications/ingest_manager/sections/epm/screens/detail/{data_sources_panel.tsx => package_configs_panel.tsx} (75%) rename x-pack/plugins/ingest_manager/public/applications/ingest_manager/sections/fleet/components/{agent_config_datasource_badges.tsx => agent_config_package_badges.tsx} (76%) rename x-pack/plugins/security_solution/public/management/pages/policy/view/ingest_manager_integration/{configure_datasource.tsx => configure_package_config.tsx} (78%) diff --git a/x-pack/plugins/ingest_manager/public/applications/ingest_manager/constants/page_paths.ts b/x-pack/plugins/ingest_manager/public/applications/ingest_manager/constants/page_paths.ts index 5ef7f45faec48..9881d5e40d8ab 100644 --- a/x-pack/plugins/ingest_manager/public/applications/ingest_manager/constants/page_paths.ts +++ b/x-pack/plugins/ingest_manager/public/applications/ingest_manager/constants/page_paths.ts @@ -18,9 +18,9 @@ export type StaticPage = export type DynamicPage = | 'integration_details' | 'configuration_details' - | 'add_datasource_from_configuration' - | 'add_datasource_from_integration' - | 'edit_datasource' + | 'add_integration_from_configuration' + | 'add_integration_to_configuration' + | 'edit_integration' | 'fleet_agent_list' | 'fleet_agent_details'; @@ -44,9 +44,9 @@ export const PAGE_ROUTING_PATHS = { configurations_list: '/configs', configuration_details: '/configs/:configId/:tabId?', configuration_details_settings: '/configs/:configId/settings', - add_datasource_from_configuration: '/configs/:configId/add-datasource', - add_datasource_from_integration: '/integrations/:pkgkey/add-datasource', - edit_datasource: '/configs/:configId/edit-datasource/:datasourceId', + add_integration_from_configuration: '/configs/:configId/add-integration', + add_integration_to_configuration: '/integrations/:pkgkey/add-integration', + edit_integration: '/configs/:configId/edit-integration/:packageConfigId', fleet: '/fleet', fleet_agent_list: '/fleet/agents', fleet_agent_details: '/fleet/agents/:agentId/:tabId?', @@ -71,10 +71,10 @@ export const pagePathGetters: { configurations: () => '/configs', configurations_list: () => '/configs', configuration_details: ({ configId, tabId }) => `/configs/${configId}${tabId ? `/${tabId}` : ''}`, - add_datasource_from_configuration: ({ configId }) => `/configs/${configId}/add-datasource`, - add_datasource_from_integration: ({ pkgkey }) => `/integrations/${pkgkey}/add-datasource`, - edit_datasource: ({ configId, datasourceId }) => - `/configs/${configId}/edit-datasource/${datasourceId}`, + add_integration_from_configuration: ({ configId }) => `/configs/${configId}/add-integration`, + add_integration_to_configuration: ({ pkgkey }) => `/integrations/${pkgkey}/add-integration`, + edit_integration: ({ configId, packageConfigId }) => + `/configs/${configId}/edit-integration/${packageConfigId}`, fleet: () => '/fleet', fleet_agent_list: ({ kuery }) => `/fleet/agents${kuery ? `?kuery=${kuery}` : ''}`, fleet_agent_details: ({ agentId, tabId }) => diff --git a/x-pack/plugins/ingest_manager/public/applications/ingest_manager/hooks/use_breadcrumbs.tsx b/x-pack/plugins/ingest_manager/public/applications/ingest_manager/hooks/use_breadcrumbs.tsx index 0c858cd2b305d..2b92987963ef6 100644 --- a/x-pack/plugins/ingest_manager/public/applications/ingest_manager/hooks/use_breadcrumbs.tsx +++ b/x-pack/plugins/ingest_manager/public/applications/ingest_manager/hooks/use_breadcrumbs.tsx @@ -98,7 +98,7 @@ const breadcrumbGetters: { }, { text: configName }, ], - add_datasource_from_configuration: ({ configName, configId }) => [ + add_integration_from_configuration: ({ configName, configId }) => [ BASE_BREADCRUMB, { href: pagePathGetters.configurations(), @@ -111,12 +111,12 @@ const breadcrumbGetters: { text: configName, }, { - text: i18n.translate('xpack.ingestManager.breadcrumbs.addDatasourcePageTitle', { - defaultMessage: 'Add data source', + text: i18n.translate('xpack.ingestManager.breadcrumbs.addPackageConfigPageTitle', { + defaultMessage: 'Add integration', }), }, ], - add_datasource_from_integration: ({ pkgTitle, pkgkey }) => [ + add_integration_to_configuration: ({ pkgTitle, pkgkey }) => [ BASE_BREADCRUMB, { href: pagePathGetters.integrations(), @@ -129,12 +129,12 @@ const breadcrumbGetters: { text: pkgTitle, }, { - text: i18n.translate('xpack.ingestManager.breadcrumbs.addDatasourcePageTitle', { - defaultMessage: 'Add data source', + text: i18n.translate('xpack.ingestManager.breadcrumbs.addPackageConfigPageTitle', { + defaultMessage: 'Add integration', }), }, ], - edit_datasource: ({ configName, configId }) => [ + edit_integration: ({ configName, configId }) => [ BASE_BREADCRUMB, { href: pagePathGetters.configurations(), @@ -147,8 +147,8 @@ const breadcrumbGetters: { text: configName, }, { - text: i18n.translate('xpack.ingestManager.breadcrumbs.editDatasourcePageTitle', { - defaultMessage: 'Edit data source', + text: i18n.translate('xpack.ingestManager.breadcrumbs.editPackageConfigPageTitle', { + defaultMessage: 'Edit integration', }), }, ], diff --git a/x-pack/plugins/ingest_manager/public/applications/ingest_manager/hooks/use_request/index.ts b/x-pack/plugins/ingest_manager/public/applications/ingest_manager/hooks/use_request/index.ts index 8aec20d15c888..0d703925f2cf3 100644 --- a/x-pack/plugins/ingest_manager/public/applications/ingest_manager/hooks/use_request/index.ts +++ b/x-pack/plugins/ingest_manager/public/applications/ingest_manager/hooks/use_request/index.ts @@ -5,7 +5,7 @@ */ export { setHttpClient, sendRequest, useRequest } from './use_request'; export * from './agent_config'; -export * from './datasource'; +export * from './package_config'; export * from './data_stream'; export * from './agents'; export * from './enrollment_api_keys'; diff --git a/x-pack/plugins/ingest_manager/public/applications/ingest_manager/hooks/use_request/datasource.ts b/x-pack/plugins/ingest_manager/public/applications/ingest_manager/hooks/use_request/package_config.ts similarity index 81% rename from x-pack/plugins/ingest_manager/public/applications/ingest_manager/hooks/use_request/datasource.ts rename to x-pack/plugins/ingest_manager/public/applications/ingest_manager/hooks/use_request/package_config.ts index 89246c8236b6b..aba950123ead3 100644 --- a/x-pack/plugins/ingest_manager/public/applications/ingest_manager/hooks/use_request/datasource.ts +++ b/x-pack/plugins/ingest_manager/public/applications/ingest_manager/hooks/use_request/package_config.ts @@ -19,7 +19,7 @@ import { GetOnePackageConfigResponse, } from '../../../../../common/types/rest_spec'; -export const sendCreateDatasource = (body: CreatePackageConfigRequest['body']) => { +export const sendCreatePackageConfig = (body: CreatePackageConfigRequest['body']) => { return sendRequest({ path: packageConfigRouteService.getCreatePath(), method: 'post', @@ -27,7 +27,7 @@ export const sendCreateDatasource = (body: CreatePackageConfigRequest['body']) = }); }; -export const sendUpdateDatasource = ( +export const sendUpdatePackageConfig = ( packageConfigId: string, body: UpdatePackageConfigRequest['body'] ) => { @@ -38,7 +38,7 @@ export const sendUpdateDatasource = ( }); }; -export const sendDeleteDatasource = (body: DeletePackageConfigsRequest['body']) => { +export const sendDeletePackageConfig = (body: DeletePackageConfigsRequest['body']) => { return sendRequest({ path: packageConfigRouteService.getDeletePath(), method: 'post', @@ -46,7 +46,7 @@ export const sendDeleteDatasource = (body: DeletePackageConfigsRequest['body']) }); }; -export function useGetDatasources(query: GetPackageConfigsRequest['query']) { +export function useGetPackageConfigs(query: GetPackageConfigsRequest['query']) { return useRequest({ method: 'get', path: packageConfigRouteService.getListPath(), @@ -54,7 +54,7 @@ export function useGetDatasources(query: GetPackageConfigsRequest['query']) { }); } -export const sendGetOneDatasource = (packageConfigId: string) => { +export const sendGetOnePackageConfig = (packageConfigId: string) => { return sendRequest({ path: packageConfigRouteService.getInfoPath(packageConfigId), method: 'get', diff --git a/x-pack/plugins/ingest_manager/public/applications/ingest_manager/sections/agent_config/components/config_form.tsx b/x-pack/plugins/ingest_manager/public/applications/ingest_manager/sections/agent_config/components/config_form.tsx index 73ddd567c515b..ad04e78bdcd11 100644 --- a/x-pack/plugins/ingest_manager/public/applications/ingest_manager/sections/agent_config/components/config_form.tsx +++ b/x-pack/plugins/ingest_manager/public/applications/ingest_manager/sections/agent_config/components/config_form.tsx @@ -174,7 +174,7 @@ export const AgentConfigForm: React.FunctionComponent = ({ description={ } > @@ -336,7 +336,7 @@ export const AgentConfigForm: React.FunctionComponent = ({ 'xpack.ingestManager.agentConfigForm.systemMonitoringTooltipText', { defaultMessage: - 'Enable this option to bootstrap your configuration with a data source that collects system metrics and information.', + 'Enable this option to bootstrap your configuration with an integration that collects system metrics and information.', } )} position="right" diff --git a/x-pack/plugins/ingest_manager/public/applications/ingest_manager/sections/agent_config/components/index.ts b/x-pack/plugins/ingest_manager/public/applications/ingest_manager/sections/agent_config/components/index.ts index f3ec15e0f477d..3794a1f1afd26 100644 --- a/x-pack/plugins/ingest_manager/public/applications/ingest_manager/sections/agent_config/components/index.ts +++ b/x-pack/plugins/ingest_manager/public/applications/ingest_manager/sections/agent_config/components/index.ts @@ -5,7 +5,7 @@ */ export { AgentConfigForm, agentConfigFormValidation } from './config_form'; export { AgentConfigDeleteProvider } from './config_delete_provider'; -export { DatasourceDeleteProvider } from './datasource_delete_provider'; +export { PackageConfigDeleteProvider } from './package_config_delete_provider'; export { LinkedAgentCount } from './linked_agent_count'; export { ConfirmDeployConfigModal } from './confirm_deploy_modal'; export { DangerEuiContextMenuItem } from './danger_eui_context_menu_item'; diff --git a/x-pack/plugins/ingest_manager/public/applications/ingest_manager/sections/agent_config/components/datasource_delete_provider.tsx b/x-pack/plugins/ingest_manager/public/applications/ingest_manager/sections/agent_config/components/package_config_delete_provider.tsx similarity index 66% rename from x-pack/plugins/ingest_manager/public/applications/ingest_manager/sections/agent_config/components/datasource_delete_provider.tsx rename to x-pack/plugins/ingest_manager/public/applications/ingest_manager/sections/agent_config/components/package_config_delete_provider.tsx index 0c0ebc6403679..3421b70715c35 100644 --- a/x-pack/plugins/ingest_manager/public/applications/ingest_manager/sections/agent_config/components/datasource_delete_provider.tsx +++ b/x-pack/plugins/ingest_manager/public/applications/ingest_manager/sections/agent_config/components/package_config_delete_provider.tsx @@ -8,23 +8,23 @@ import React, { Fragment, useMemo, useRef, useState } from 'react'; import { EuiCallOut, EuiConfirmModal, EuiOverlayMask, EuiSpacer } from '@elastic/eui'; import { i18n } from '@kbn/i18n'; import { FormattedMessage } from '@kbn/i18n/react'; -import { useCore, sendRequest, sendDeleteDatasource, useConfig } from '../../../hooks'; +import { useCore, sendRequest, sendDeletePackageConfig, useConfig } from '../../../hooks'; import { AGENT_API_ROUTES, AGENT_SAVED_OBJECT_TYPE } from '../../../constants'; import { AgentConfig } from '../../../types'; interface Props { agentConfig: AgentConfig; - children: (deleteDatasourcePrompt: DeleteAgentConfigDatasourcePrompt) => React.ReactElement; + children: (deletePackageConfigsPrompt: DeletePackageConfigsPrompt) => React.ReactElement; } -export type DeleteAgentConfigDatasourcePrompt = ( - datasourcesToDelete: string[], +export type DeletePackageConfigsPrompt = ( + packageConfigsToDelete: string[], onSuccess?: OnSuccessCallback ) => void; -type OnSuccessCallback = (datasourcesDeleted: string[]) => void; +type OnSuccessCallback = (packageConfigsDeleted: string[]) => void; -export const DatasourceDeleteProvider: React.FunctionComponent = ({ +export const PackageConfigDeleteProvider: React.FunctionComponent = ({ agentConfig, children, }) => { @@ -32,7 +32,7 @@ export const DatasourceDeleteProvider: React.FunctionComponent = ({ const { fleet: { enabled: isFleetEnabled }, } = useConfig(); - const [datasources, setDatasources] = useState([]); + const [packageConfigs, setPackageConfigs] = useState([]); const [isModalOpen, setIsModalOpen] = useState(false); const [isLoadingAgentsCount, setIsLoadingAgentsCount] = useState(false); const [agentsCount, setAgentsCount] = useState(0); @@ -60,13 +60,13 @@ export const DatasourceDeleteProvider: React.FunctionComponent = ({ [agentConfig.id, isFleetEnabled, isLoadingAgentsCount] ); - const deleteDatasourcesPrompt = useMemo( - (): DeleteAgentConfigDatasourcePrompt => (datasourcesToDelete, onSuccess = () => undefined) => { - if (!Array.isArray(datasourcesToDelete) || datasourcesToDelete.length === 0) { - throw new Error('No datasources specified for deletion'); + const deletePackageConfigsPrompt = useMemo( + (): DeletePackageConfigsPrompt => (packageConfigsToDelete, onSuccess = () => undefined) => { + if (!Array.isArray(packageConfigsToDelete) || packageConfigsToDelete.length === 0) { + throw new Error('No package configs specified for deletion'); } setIsModalOpen(true); - setDatasources(datasourcesToDelete); + setPackageConfigs(packageConfigsToDelete); fetchAgentsCount(); onSuccessCallback.current = onSuccess; }, @@ -75,7 +75,7 @@ export const DatasourceDeleteProvider: React.FunctionComponent = ({ const closeModal = useMemo( () => () => { - setDatasources([]); + setPackageConfigs([]); setIsLoading(false); setIsLoadingAgentsCount(false); setIsModalOpen(false); @@ -83,12 +83,12 @@ export const DatasourceDeleteProvider: React.FunctionComponent = ({ [] ); - const deleteDatasources = useMemo( + const deletePackageConfigs = useMemo( () => async () => { setIsLoading(true); try { - const { data } = await sendDeleteDatasource({ packageConfigIds: datasources }); + const { data } = await sendDeletePackageConfig({ packageConfigIds: packageConfigs }); const successfulResults = data?.filter((result) => result.success) || []; const failedResults = data?.filter((result) => !result.success) || []; @@ -96,16 +96,16 @@ export const DatasourceDeleteProvider: React.FunctionComponent = ({ const hasMultipleSuccesses = successfulResults.length > 1; const successMessage = hasMultipleSuccesses ? i18n.translate( - 'xpack.ingestManager.deleteDatasource.successMultipleNotificationTitle', + 'xpack.ingestManager.deletePackageConfig.successMultipleNotificationTitle', { - defaultMessage: 'Deleted {count} data sources', + defaultMessage: 'Deleted {count} integrations', values: { count: successfulResults.length }, } ) : i18n.translate( - 'xpack.ingestManager.deleteDatasource.successSingleNotificationTitle', + 'xpack.ingestManager.deletePackageConfig.successSingleNotificationTitle', { - defaultMessage: "Deleted data source '{id}'", + defaultMessage: "Deleted integration '{id}'", values: { id: successfulResults[0].id }, } ); @@ -116,16 +116,16 @@ export const DatasourceDeleteProvider: React.FunctionComponent = ({ const hasMultipleFailures = failedResults.length > 1; const failureMessage = hasMultipleFailures ? i18n.translate( - 'xpack.ingestManager.deleteDatasource.failureMultipleNotificationTitle', + 'xpack.ingestManager.deletePackageConfig.failureMultipleNotificationTitle', { - defaultMessage: 'Error deleting {count} data sources', + defaultMessage: 'Error deleting {count} integrations', values: { count: failedResults.length }, } ) : i18n.translate( - 'xpack.ingestManager.deleteDatasource.failureSingleNotificationTitle', + 'xpack.ingestManager.deletePackageConfig.failureSingleNotificationTitle', { - defaultMessage: "Error deleting data source '{id}'", + defaultMessage: "Error deleting integration '{id}'", values: { id: failedResults[0].id }, } ); @@ -137,14 +137,14 @@ export const DatasourceDeleteProvider: React.FunctionComponent = ({ } } catch (e) { notifications.toasts.addDanger( - i18n.translate('xpack.ingestManager.deleteDatasource.fatalErrorNotificationTitle', { - defaultMessage: 'Error deleting data source', + i18n.translate('xpack.ingestManager.deletePackageConfig.fatalErrorNotificationTitle', { + defaultMessage: 'Error deleting integration', }) ); } closeModal(); }, - [closeModal, datasources, notifications.toasts] + [closeModal, packageConfigs, notifications.toasts] ); const renderModal = () => { @@ -157,31 +157,31 @@ export const DatasourceDeleteProvider: React.FunctionComponent = ({ } onCancel={closeModal} - onConfirm={deleteDatasources} + onConfirm={deletePackageConfigs} cancelButtonText={ } confirmButtonText={ isLoading || isLoadingAgentsCount ? ( ) : ( ) @@ -191,7 +191,7 @@ export const DatasourceDeleteProvider: React.FunctionComponent = ({ > {isLoadingAgentsCount ? ( ) : agentsCount ? ( @@ -200,14 +200,14 @@ export const DatasourceDeleteProvider: React.FunctionComponent = ({ color="danger" title={ } > {agentConfig.name}, @@ -219,7 +219,7 @@ export const DatasourceDeleteProvider: React.FunctionComponent = ({ ) : null} {!isLoadingAgentsCount && ( )} @@ -230,7 +230,7 @@ export const DatasourceDeleteProvider: React.FunctionComponent = ({ return ( - {children(deleteDatasourcesPrompt)} + {children(deletePackageConfigsPrompt)} {renderModal()} ); diff --git a/x-pack/plugins/ingest_manager/public/applications/ingest_manager/sections/agent_config/create_datasource_page/components/custom_configure_datasource.tsx b/x-pack/plugins/ingest_manager/public/applications/ingest_manager/sections/agent_config/create_datasource_page/components/custom_configure_datasource.tsx deleted file mode 100644 index 4cdc0d20fac39..0000000000000 --- a/x-pack/plugins/ingest_manager/public/applications/ingest_manager/sections/agent_config/create_datasource_page/components/custom_configure_datasource.tsx +++ /dev/null @@ -1,62 +0,0 @@ -/* - * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one - * or more contributor license agreements. Licensed under the Elastic License; - * you may not use this file except in compliance with the Elastic License. - */ -import React from 'react'; -import { FormattedMessage } from '@kbn/i18n/react'; -import { EuiEmptyPrompt, EuiText } from '@elastic/eui'; -import { NewPackageConfig } from '../../../../types'; -import { CreateDatasourceFrom } from '../types'; - -export interface CustomConfigureDatasourceProps { - packageName: string; - from: CreateDatasourceFrom; - datasource: NewPackageConfig; - datasourceId?: string; -} - -/** - * Custom content type that external plugins can provide to Ingest's - * Datasource configuration. - */ -export type CustomConfigureDatasourceContent = React.FC; - -type AllowedDatasourceKey = 'endpoint'; -const ConfigureDatasourceMapping: { - [key: string]: CustomConfigureDatasourceContent; -} = {}; - -/** - * Plugins can call this function from the start lifecycle to - * register a custom component in the Ingest Datasource configuration. - */ -export function registerDatasource( - key: AllowedDatasourceKey, - value: CustomConfigureDatasourceContent -) { - ConfigureDatasourceMapping[key] = value; -} - -const EmptyConfigureDatasource: CustomConfigureDatasourceContent = () => ( - -

- -

- - } - /> -); - -export const CustomConfigureDatasource = (props: CustomConfigureDatasourceProps) => { - const ConfigureDatasourceContent = - ConfigureDatasourceMapping[props.packageName] || EmptyConfigureDatasource; - return ; -}; diff --git a/x-pack/plugins/ingest_manager/public/applications/ingest_manager/sections/agent_config/create_datasource_page/components/index.ts b/x-pack/plugins/ingest_manager/public/applications/ingest_manager/sections/agent_config/create_datasource_page/components/index.ts deleted file mode 100644 index 42848cc0f5e41..0000000000000 --- a/x-pack/plugins/ingest_manager/public/applications/ingest_manager/sections/agent_config/create_datasource_page/components/index.ts +++ /dev/null @@ -1,9 +0,0 @@ -/* - * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one - * or more contributor license agreements. Licensed under the Elastic License; - * you may not use this file except in compliance with the Elastic License. - */ -export { CreateDatasourcePageLayout } from './layout'; -export { DatasourceInputPanel } from './datasource_input_panel'; -export { DatasourceInputVarField } from './datasource_input_var_field'; -export { CustomConfigureDatasource } from './custom_configure_datasource'; diff --git a/x-pack/plugins/ingest_manager/public/applications/ingest_manager/sections/agent_config/create_datasource_page/constants.ts b/x-pack/plugins/ingest_manager/public/applications/ingest_manager/sections/agent_config/create_datasource_page/constants.ts deleted file mode 100644 index 49223a8eb4531..0000000000000 --- a/x-pack/plugins/ingest_manager/public/applications/ingest_manager/sections/agent_config/create_datasource_page/constants.ts +++ /dev/null @@ -1,11 +0,0 @@ -/* - * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one - * or more contributor license agreements. Licensed under the Elastic License; - * you may not use this file except in compliance with the Elastic License. - */ -export const WeightedCreateDatasourceSteps = [ - 'selectConfig', - 'selectPackage', - 'configure', - 'review', -]; diff --git a/x-pack/plugins/ingest_manager/public/applications/ingest_manager/sections/agent_config/create_package_config_page/components/custom_package_config.tsx b/x-pack/plugins/ingest_manager/public/applications/ingest_manager/sections/agent_config/create_package_config_page/components/custom_package_config.tsx new file mode 100644 index 0000000000000..98ab507c1453d --- /dev/null +++ b/x-pack/plugins/ingest_manager/public/applications/ingest_manager/sections/agent_config/create_package_config_page/components/custom_package_config.tsx @@ -0,0 +1,61 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License; + * you may not use this file except in compliance with the Elastic License. + */ +import React from 'react'; +import { FormattedMessage } from '@kbn/i18n/react'; +import { EuiEmptyPrompt, EuiText } from '@elastic/eui'; +import { NewPackageConfig } from '../../../../types'; +import { CreatePackageConfigFrom } from '../types'; + +export interface CustomConfigurePackageConfigProps { + packageName: string; + from: CreatePackageConfigFrom; + packageConfig: NewPackageConfig; + packageConfigId?: string; +} + +/** + * Custom content type that external plugins can provide to Ingest's + * package config UI. + */ +export type CustomConfigurePackageConfigContent = React.FC; + +type AllowedPackageKey = 'endpoint'; +const PackageConfigMapping: { + [key: string]: CustomConfigurePackageConfigContent; +} = {}; + +/** + * Plugins can call this function from the start lifecycle to + * register a custom component in the Ingest package config. + */ +export function registerPackageConfigComponent( + key: AllowedPackageKey, + value: CustomConfigurePackageConfigContent +) { + PackageConfigMapping[key] = value; +} + +const EmptyPackageConfig: CustomConfigurePackageConfigContent = () => ( + +

+ +

+ + } + /> +); + +export const CustomPackageConfig = (props: CustomConfigurePackageConfigProps) => { + const CustomPackageConfigContent = PackageConfigMapping[props.packageName] || EmptyPackageConfig; + return ; +}; diff --git a/x-pack/plugins/ingest_manager/public/applications/ingest_manager/sections/agent_config/create_package_config_page/components/index.ts b/x-pack/plugins/ingest_manager/public/applications/ingest_manager/sections/agent_config/create_package_config_page/components/index.ts new file mode 100644 index 0000000000000..e8d2ef329b25e --- /dev/null +++ b/x-pack/plugins/ingest_manager/public/applications/ingest_manager/sections/agent_config/create_package_config_page/components/index.ts @@ -0,0 +1,9 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License; + * you may not use this file except in compliance with the Elastic License. + */ +export { CreatePackageConfigPageLayout } from './layout'; +export { PackageConfigInputPanel } from './package_config_input_panel'; +export { PackageConfigInputVarField } from './package_config_input_var_field'; +export { CustomPackageConfig } from './custom_package_config'; diff --git a/x-pack/plugins/ingest_manager/public/applications/ingest_manager/sections/agent_config/create_datasource_page/components/layout.tsx b/x-pack/plugins/ingest_manager/public/applications/ingest_manager/sections/agent_config/create_package_config_page/components/layout.tsx similarity index 83% rename from x-pack/plugins/ingest_manager/public/applications/ingest_manager/sections/agent_config/create_datasource_page/components/layout.tsx rename to x-pack/plugins/ingest_manager/public/applications/ingest_manager/sections/agent_config/create_package_config_page/components/layout.tsx index 6f23c0ce60850..e0f40f1b15375 100644 --- a/x-pack/plugins/ingest_manager/public/applications/ingest_manager/sections/agent_config/create_datasource_page/components/layout.tsx +++ b/x-pack/plugins/ingest_manager/public/applications/ingest_manager/sections/agent_config/create_package_config_page/components/layout.tsx @@ -18,10 +18,10 @@ import { import { WithHeaderLayout } from '../../../../layouts'; import { AgentConfig, PackageInfo } from '../../../../types'; import { PackageIcon } from '../../../../components/package_icon'; -import { CreateDatasourceFrom } from '../types'; +import { CreatePackageConfigFrom } from '../types'; -export const CreateDatasourcePageLayout: React.FunctionComponent<{ - from: CreateDatasourceFrom; +export const CreatePackageConfigPageLayout: React.FunctionComponent<{ + from: CreatePackageConfigFrom; cancelUrl: string; onCancel?: React.ReactEventHandler; agentConfig?: AgentConfig; @@ -49,7 +49,7 @@ export const CreateDatasourcePageLayout: React.FunctionComponent<{ data-test-subj={`${dataTestSubj}_cancelBackLink`} > @@ -59,13 +59,13 @@ export const CreateDatasourcePageLayout: React.FunctionComponent<{

{from === 'edit' ? ( ) : ( )}

@@ -76,17 +76,17 @@ export const CreateDatasourcePageLayout: React.FunctionComponent<{ {from === 'edit' ? ( ) : from === 'config' ? ( ) : ( )} @@ -102,7 +102,7 @@ export const CreateDatasourcePageLayout: React.FunctionComponent<{ @@ -115,7 +115,7 @@ export const CreateDatasourcePageLayout: React.FunctionComponent<{ diff --git a/x-pack/plugins/ingest_manager/public/applications/ingest_manager/sections/agent_config/create_datasource_page/components/datasource_input_config.tsx b/x-pack/plugins/ingest_manager/public/applications/ingest_manager/sections/agent_config/create_package_config_page/components/package_config_input_config.tsx similarity index 78% rename from x-pack/plugins/ingest_manager/public/applications/ingest_manager/sections/agent_config/create_datasource_page/components/datasource_input_config.tsx rename to x-pack/plugins/ingest_manager/public/applications/ingest_manager/sections/agent_config/create_package_config_page/components/package_config_input_config.tsx index 3e74a394f8a7d..85c0f2134d8dc 100644 --- a/x-pack/plugins/ingest_manager/public/applications/ingest_manager/sections/agent_config/create_datasource_page/components/datasource_input_config.tsx +++ b/x-pack/plugins/ingest_manager/public/applications/ingest_manager/sections/agent_config/create_package_config_page/components/package_config_input_config.tsx @@ -16,19 +16,23 @@ import { EuiIconTip, } from '@elastic/eui'; import { PackageConfigInput, RegistryVarsEntry } from '../../../../types'; -import { isAdvancedVar, DatasourceConfigValidationResults, validationHasErrors } from '../services'; -import { DatasourceInputVarField } from './datasource_input_var_field'; +import { + isAdvancedVar, + PackageConfigConfigValidationResults, + validationHasErrors, +} from '../services'; +import { PackageConfigInputVarField } from './package_config_input_var_field'; -export const DatasourceInputConfig: React.FunctionComponent<{ +export const PackageConfigInputConfig: React.FunctionComponent<{ packageInputVars?: RegistryVarsEntry[]; - datasourceInput: PackageConfigInput; - updateDatasourceInput: (updatedInput: Partial) => void; - inputVarsValidationResults: DatasourceConfigValidationResults; + packageConfigInput: PackageConfigInput; + updatePackageConfigInput: (updatedInput: Partial) => void; + inputVarsValidationResults: PackageConfigConfigValidationResults; forceShowErrors?: boolean; }> = ({ packageInputVars, - datasourceInput, - updateDatasourceInput, + packageConfigInput, + updatePackageConfigInput, inputVarsValidationResults, forceShowErrors, }) => { @@ -60,7 +64,7 @@ export const DatasourceInputConfig: React.FunctionComponent<{

@@ -71,7 +75,7 @@ export const DatasourceInputConfig: React.FunctionComponent<{ } @@ -87,7 +91,7 @@ export const DatasourceInputConfig: React.FunctionComponent<{

@@ -97,16 +101,16 @@ export const DatasourceInputConfig: React.FunctionComponent<{ {requiredVars.map((varDef) => { const { name: varName, type: varType } = varDef; - const value = datasourceInput.vars![varName].value; + const value = packageConfigInput.vars![varName].value; return ( - { - updateDatasourceInput({ + updatePackageConfigInput({ vars: { - ...datasourceInput.vars, + ...packageConfigInput.vars, [varName]: { type: varType, value: newValue, @@ -132,7 +136,7 @@ export const DatasourceInputConfig: React.FunctionComponent<{ flush="left" > @@ -141,16 +145,16 @@ export const DatasourceInputConfig: React.FunctionComponent<{ {isShowingAdvanced ? advancedVars.map((varDef) => { const { name: varName, type: varType } = varDef; - const value = datasourceInput.vars![varName].value; + const value = packageConfigInput.vars![varName].value; return ( - { - updateDatasourceInput({ + updatePackageConfigInput({ vars: { - ...datasourceInput.vars, + ...packageConfigInput.vars, [varName]: { type: varType, value: newValue, diff --git a/x-pack/plugins/ingest_manager/public/applications/ingest_manager/sections/agent_config/create_datasource_page/components/datasource_input_panel.tsx b/x-pack/plugins/ingest_manager/public/applications/ingest_manager/sections/agent_config/create_package_config_page/components/package_config_input_panel.tsx similarity index 76% rename from x-pack/plugins/ingest_manager/public/applications/ingest_manager/sections/agent_config/create_datasource_page/components/datasource_input_panel.tsx rename to x-pack/plugins/ingest_manager/public/applications/ingest_manager/sections/agent_config/create_package_config_page/components/package_config_input_panel.tsx index 4dc2b6ed73404..f9c9dcd469b25 100644 --- a/x-pack/plugins/ingest_manager/public/applications/ingest_manager/sections/agent_config/create_datasource_page/components/datasource_input_panel.tsx +++ b/x-pack/plugins/ingest_manager/public/applications/ingest_manager/sections/agent_config/create_package_config_page/components/package_config_input_panel.tsx @@ -25,9 +25,9 @@ import { RegistryInput, RegistryStream, } from '../../../../types'; -import { DatasourceInputValidationResults, validationHasErrors } from '../services'; -import { DatasourceInputConfig } from './datasource_input_config'; -import { DatasourceInputStreamConfig } from './datasource_input_stream_config'; +import { PackageConfigInputValidationResults, validationHasErrors } from '../services'; +import { PackageConfigInputConfig } from './package_config_input_config'; +import { PackageConfigInputStreamConfig } from './package_config_input_stream'; const FlushHorizontalRule = styled(EuiHorizontalRule)` margin-left: -${(props) => props.theme.eui.paddingSizes.m}; @@ -35,18 +35,18 @@ const FlushHorizontalRule = styled(EuiHorizontalRule)` width: auto; `; -export const DatasourceInputPanel: React.FunctionComponent<{ +export const PackageConfigInputPanel: React.FunctionComponent<{ packageInput: RegistryInput; packageInputStreams: Array; - datasourceInput: PackageConfigInput; - updateDatasourceInput: (updatedInput: Partial) => void; - inputValidationResults: DatasourceInputValidationResults; + packageConfigInput: PackageConfigInput; + updatePackageConfigInput: (updatedInput: Partial) => void; + inputValidationResults: PackageConfigInputValidationResults; forceShowErrors?: boolean; }> = ({ packageInput, packageInputStreams, - datasourceInput, - updateDatasourceInput, + packageConfigInput, + updatePackageConfigInput, inputValidationResults, forceShowErrors, }) => { @@ -78,7 +78,7 @@ export const DatasourceInputPanel: React.FunctionComponent<{ } @@ -90,12 +90,12 @@ export const DatasourceInputPanel: React.FunctionComponent<{ ) : null} } - checked={datasourceInput.enabled} + checked={packageConfigInput.enabled} onChange={(e) => { const enabled = e.target.checked; - updateDatasourceInput({ + updatePackageConfigInput({ enabled, - streams: datasourceInput.streams.map((stream) => ({ + streams: packageConfigInput.streams.map((stream) => ({ ...stream, enabled, })), @@ -108,13 +108,13 @@ export const DatasourceInputPanel: React.FunctionComponent<{ - {datasourceInput.streams.filter((stream) => stream.enabled).length} + {packageConfigInput.streams.filter((stream) => stream.enabled).length} ), @@ -131,7 +131,7 @@ export const DatasourceInputPanel: React.FunctionComponent<{ aria-label={ isShowingStreams ? i18n.translate( - 'xpack.ingestManager.createDatasource.stepConfigure.hideStreamsAriaLabel', + 'xpack.ingestManager.createPackageConfig.stepConfigure.hideStreamsAriaLabel', { defaultMessage: 'Hide {type} streams', values: { @@ -140,7 +140,7 @@ export const DatasourceInputPanel: React.FunctionComponent<{ } ) : i18n.translate( - 'xpack.ingestManager.createDatasource.stepConfigure.showStreamsAriaLabel', + 'xpack.ingestManager.createPackageConfig.stepConfigure.showStreamsAriaLabel', { defaultMessage: 'Show {type} streams', values: { @@ -161,10 +161,10 @@ export const DatasourceInputPanel: React.FunctionComponent<{ {/* Input level configuration */} {isShowingStreams && packageInput.vars && packageInput.vars.length ? ( - @@ -176,21 +176,21 @@ export const DatasourceInputPanel: React.FunctionComponent<{ {isShowingStreams ? ( {packageInputStreams.map((packageInputStream) => { - const datasourceInputStream = datasourceInput.streams.find( + const packageConfigInputStream = packageConfigInput.streams.find( (stream) => stream.dataset.name === packageInputStream.dataset.name ); - return datasourceInputStream ? ( + return packageConfigInputStream ? ( - ) => { - const indexOfUpdatedStream = datasourceInput.streams.findIndex( + const indexOfUpdatedStream = packageConfigInput.streams.findIndex( (stream) => stream.dataset.name === packageInputStream.dataset.name ); - const newStreams = [...datasourceInput.streams]; + const newStreams = [...packageConfigInput.streams]; newStreams[indexOfUpdatedStream] = { ...newStreams[indexOfUpdatedStream], ...updatedStream, @@ -201,19 +201,19 @@ export const DatasourceInputPanel: React.FunctionComponent<{ }; // Update input enabled state if needed - if (!datasourceInput.enabled && updatedStream.enabled) { + if (!packageConfigInput.enabled && updatedStream.enabled) { updatedInput.enabled = true; } else if ( - datasourceInput.enabled && + packageConfigInput.enabled && !newStreams.find((stream) => stream.enabled) ) { updatedInput.enabled = false; } - updateDatasourceInput(updatedInput); + updatePackageConfigInput(updatedInput); }} inputStreamValidationResults={ - inputValidationResults.streams![datasourceInputStream.id] + inputValidationResults.streams![packageConfigInputStream.id] } forceShowErrors={forceShowErrors} /> diff --git a/x-pack/plugins/ingest_manager/public/applications/ingest_manager/sections/agent_config/create_datasource_page/components/datasource_input_stream_config.tsx b/x-pack/plugins/ingest_manager/public/applications/ingest_manager/sections/agent_config/create_package_config_page/components/package_config_input_stream.tsx similarity index 83% rename from x-pack/plugins/ingest_manager/public/applications/ingest_manager/sections/agent_config/create_datasource_page/components/datasource_input_stream_config.tsx rename to x-pack/plugins/ingest_manager/public/applications/ingest_manager/sections/agent_config/create_package_config_page/components/package_config_input_stream.tsx index 436f652143285..52a4748fe14c7 100644 --- a/x-pack/plugins/ingest_manager/public/applications/ingest_manager/sections/agent_config/create_datasource_page/components/datasource_input_stream_config.tsx +++ b/x-pack/plugins/ingest_manager/public/applications/ingest_manager/sections/agent_config/create_package_config_page/components/package_config_input_stream.tsx @@ -17,18 +17,22 @@ import { EuiIconTip, } from '@elastic/eui'; import { PackageConfigInputStream, RegistryStream, RegistryVarsEntry } from '../../../../types'; -import { isAdvancedVar, DatasourceConfigValidationResults, validationHasErrors } from '../services'; -import { DatasourceInputVarField } from './datasource_input_var_field'; +import { + isAdvancedVar, + PackageConfigConfigValidationResults, + validationHasErrors, +} from '../services'; +import { PackageConfigInputVarField } from './package_config_input_var_field'; -export const DatasourceInputStreamConfig: React.FunctionComponent<{ +export const PackageConfigInputStreamConfig: React.FunctionComponent<{ packageInputStream: RegistryStream; - datasourceInputStream: PackageConfigInputStream; + packageConfigInputStream: PackageConfigInputStream; updatePackageConfigInputStream: (updatedStream: Partial) => void; - inputStreamValidationResults: DatasourceConfigValidationResults; + inputStreamValidationResults: PackageConfigConfigValidationResults; forceShowErrors?: boolean; }> = ({ packageInputStream, - datasourceInputStream, + packageConfigInputStream, updatePackageConfigInputStream, inputStreamValidationResults, forceShowErrors, @@ -68,7 +72,7 @@ export const DatasourceInputStreamConfig: React.FunctionComponent<{ } @@ -80,7 +84,7 @@ export const DatasourceInputStreamConfig: React.FunctionComponent<{ ) : null} } - checked={datasourceInputStream.enabled} + checked={packageConfigInputStream.enabled} onChange={(e) => { const enabled = e.target.checked; updatePackageConfigInputStream({ @@ -101,16 +105,16 @@ export const DatasourceInputStreamConfig: React.FunctionComponent<{ {requiredVars.map((varDef) => { const { name: varName, type: varType } = varDef; - const value = datasourceInputStream.vars![varName].value; + const value = packageConfigInputStream.vars![varName].value; return ( - { updatePackageConfigInputStream({ vars: { - ...datasourceInputStream.vars, + ...packageConfigInputStream.vars, [varName]: { type: varType, value: newValue, @@ -136,7 +140,7 @@ export const DatasourceInputStreamConfig: React.FunctionComponent<{ flush="left" > @@ -145,16 +149,16 @@ export const DatasourceInputStreamConfig: React.FunctionComponent<{ {isShowingAdvanced ? advancedVars.map((varDef) => { const { name: varName, type: varType } = varDef; - const value = datasourceInputStream.vars![varName].value; + const value = packageConfigInputStream.vars![varName].value; return ( - { updatePackageConfigInputStream({ vars: { - ...datasourceInputStream.vars, + ...packageConfigInputStream.vars, [varName]: { type: varType, value: newValue, diff --git a/x-pack/plugins/ingest_manager/public/applications/ingest_manager/sections/agent_config/create_datasource_page/components/datasource_input_var_field.tsx b/x-pack/plugins/ingest_manager/public/applications/ingest_manager/sections/agent_config/create_package_config_page/components/package_config_input_var_field.tsx similarity index 93% rename from x-pack/plugins/ingest_manager/public/applications/ingest_manager/sections/agent_config/create_datasource_page/components/datasource_input_var_field.tsx rename to x-pack/plugins/ingest_manager/public/applications/ingest_manager/sections/agent_config/create_package_config_page/components/package_config_input_var_field.tsx index f5f21f685f180..8868e00ecc1f1 100644 --- a/x-pack/plugins/ingest_manager/public/applications/ingest_manager/sections/agent_config/create_datasource_page/components/datasource_input_var_field.tsx +++ b/x-pack/plugins/ingest_manager/public/applications/ingest_manager/sections/agent_config/create_package_config_page/components/package_config_input_var_field.tsx @@ -12,7 +12,7 @@ import { RegistryVarsEntry } from '../../../../types'; import 'brace/mode/yaml'; import 'brace/theme/textmate'; -export const DatasourceInputVarField: React.FunctionComponent<{ +export const PackageConfigInputVarField: React.FunctionComponent<{ varDef: RegistryVarsEntry; value: any; onChange: (newValue: any) => void; @@ -78,7 +78,7 @@ export const DatasourceInputVarField: React.FunctionComponent<{ !required ? ( diff --git a/x-pack/plugins/ingest_manager/public/applications/ingest_manager/sections/agent_config/create_datasource_page/index.tsx b/x-pack/plugins/ingest_manager/public/applications/ingest_manager/sections/agent_config/create_package_config_page/index.tsx similarity index 72% rename from x-pack/plugins/ingest_manager/public/applications/ingest_manager/sections/agent_config/create_datasource_page/index.tsx rename to x-pack/plugins/ingest_manager/public/applications/ingest_manager/sections/agent_config/create_package_config_page/index.tsx index 1f7bb9d1016c6..a81fb232ceaa0 100644 --- a/x-pack/plugins/ingest_manager/public/applications/ingest_manager/sections/agent_config/create_datasource_page/index.tsx +++ b/x-pack/plugins/ingest_manager/public/applications/ingest_manager/sections/agent_config/create_package_config_page/index.tsx @@ -21,27 +21,31 @@ import { AgentConfig, PackageInfo, NewPackageConfig, - CreateDatasourceRouteState, + CreatePackageConfigRouteState, } from '../../../types'; import { useLink, useBreadcrumbs, - sendCreateDatasource, + sendCreatePackageConfig, useCore, useConfig, sendGetAgentStatus, } from '../../../hooks'; import { ConfirmDeployConfigModal } from '../components'; -import { CreateDatasourcePageLayout } from './components'; -import { CreateDatasourceFrom, DatasourceFormState } from './types'; -import { DatasourceValidationResults, validateDatasource, validationHasErrors } from './services'; +import { CreatePackageConfigPageLayout } from './components'; +import { CreatePackageConfigFrom, PackageConfigFormState } from './types'; +import { + PackageConfigValidationResults, + validatePackageConfig, + validationHasErrors, +} from './services'; import { StepSelectPackage } from './step_select_package'; import { StepSelectConfig } from './step_select_config'; -import { StepConfigureDatasource } from './step_configure_datasource'; -import { StepDefineDatasource } from './step_define_datasource'; +import { StepConfigurePackage } from './step_configure_package'; +import { StepDefinePackageConfig } from './step_define_package_config'; import { useIntraAppState } from '../../../hooks/use_intra_app_state'; -export const CreateDatasourcePage: React.FunctionComponent = () => { +export const CreatePackageConfigPage: React.FunctionComponent = () => { const { notifications, chrome: { getIsNavDrawerLocked$ }, @@ -56,8 +60,8 @@ export const CreateDatasourcePage: React.FunctionComponent = () => { } = useRouteMatch(); const { getHref, getPath } = useLink(); const history = useHistory(); - const routeState = useIntraAppState(); - const from: CreateDatasourceFrom = configId ? 'config' : 'package'; + const routeState = useIntraAppState(); + const from: CreatePackageConfigFrom = configId ? 'config' : 'package'; const [isNavDrawerLocked, setIsNavDrawerLocked] = useState(false); useEffect(() => { @@ -90,8 +94,8 @@ export const CreateDatasourcePage: React.FunctionComponent = () => { }, [agentConfigId, isFleetEnabled]); const [agentCount, setAgentCount] = useState(0); - // New datasource state - const [datasource, setDatasource] = useState({ + // New package config state + const [packageConfig, setPackageConfig] = useState({ name: '', description: '', namespace: '', @@ -101,11 +105,11 @@ export const CreateDatasourcePage: React.FunctionComponent = () => { inputs: [], }); - // Datasource validation state - const [validationResults, setValidationResults] = useState(); + // Package config validation state + const [validationResults, setValidationResults] = useState(); // Form state - const [formState, setFormState] = useState('INVALID'); + const [formState, setFormState] = useState('INVALID'); // Update package info method const updatePackageInfo = useCallback( @@ -147,33 +151,36 @@ export const CreateDatasourcePage: React.FunctionComponent = () => { const hasErrors = validationResults ? validationHasErrors(validationResults) : false; - // Update datasource method - const updateDatasource = (updatedFields: Partial) => { - const newDatasource = { - ...datasource, + // Update package config method + const updatePackageConfig = (updatedFields: Partial) => { + const newPackageConfig = { + ...packageConfig, ...updatedFields, }; - setDatasource(newDatasource); + setPackageConfig(newPackageConfig); // eslint-disable-next-line no-console - console.debug('Datasource updated', newDatasource); - const newValidationResults = updateDatasourceValidation(newDatasource); - const hasPackage = newDatasource.package; + console.debug('Package config updated', newPackageConfig); + const newValidationResults = updatePackageConfigValidation(newPackageConfig); + const hasPackage = newPackageConfig.package; const hasValidationErrors = newValidationResults ? validationHasErrors(newValidationResults) : false; - const hasAgentConfig = newDatasource.config_id && newDatasource.config_id !== ''; + const hasAgentConfig = newPackageConfig.config_id && newPackageConfig.config_id !== ''; if (hasPackage && hasAgentConfig && !hasValidationErrors) { setFormState('VALID'); } }; - const updateDatasourceValidation = (newDatasource?: NewPackageConfig) => { + const updatePackageConfigValidation = (newPackageConfig?: NewPackageConfig) => { if (packageInfo) { - const newValidationResult = validateDatasource(newDatasource || datasource, packageInfo); + const newValidationResult = validatePackageConfig( + newPackageConfig || packageConfig, + packageInfo + ); setValidationResults(newValidationResult); // eslint-disable-next-line no-console - console.debug('Datasource validation results', newValidationResult); + console.debug('Package config validation results', newValidationResult); return newValidationResult; } @@ -199,10 +206,10 @@ export const CreateDatasourcePage: React.FunctionComponent = () => { [routeState, navigateToApp] ); - // Save datasource - const saveDatasource = async () => { + // Save package config + const savePackageConfig = async () => { setFormState('LOADING'); - const result = await sendCreateDatasource(datasource); + const result = await sendCreatePackageConfig(packageConfig); setFormState('SUBMITTED'); return result; }; @@ -216,7 +223,7 @@ export const CreateDatasourcePage: React.FunctionComponent = () => { setFormState('CONFIRM'); return; } - const { error, data } = await saveDatasource(); + const { error, data } = await savePackageConfig(); if (!error) { if (routeState && routeState.onSaveNavigateTo) { navigateToApp( @@ -229,22 +236,22 @@ export const CreateDatasourcePage: React.FunctionComponent = () => { } notifications.toasts.addSuccess({ - title: i18n.translate('xpack.ingestManager.createDatasource.addedNotificationTitle', { - defaultMessage: `Successfully added '{datasourceName}'`, + title: i18n.translate('xpack.ingestManager.createPackageConfig.addedNotificationTitle', { + defaultMessage: `Successfully added '{packageConfigName}'`, values: { - datasourceName: datasource.name, + packageConfigName: packageConfig.name, }, }), text: agentCount && agentConfig - ? i18n.translate('xpack.ingestManager.createDatasource.addedNotificationMessage', { + ? i18n.translate('xpack.ingestManager.createPackageConfig.addedNotificationMessage', { defaultMessage: `Fleet will deploy updates to all agents that use the '{agentConfigName}' configuration`, values: { agentConfigName: agentConfig.name, }, }) : undefined, - 'data-test-subj': 'datasourceCreateSuccessToast', + 'data-test-subj': 'packageConfigCreateSuccessToast', }); } else { notifications.toasts.addError(error, { @@ -289,45 +296,54 @@ export const CreateDatasourcePage: React.FunctionComponent = () => { const steps: EuiStepProps[] = [ from === 'package' ? { - title: i18n.translate('xpack.ingestManager.createDatasource.stepSelectAgentConfigTitle', { - defaultMessage: 'Select an agent configuration', - }), + title: i18n.translate( + 'xpack.ingestManager.createPackageConfig.stepSelectAgentConfigTitle', + { + defaultMessage: 'Select an agent configuration', + } + ), children: stepSelectConfig, } : { - title: i18n.translate('xpack.ingestManager.createDatasource.stepSelectPackageTitle', { + title: i18n.translate('xpack.ingestManager.createPackageConfig.stepSelectPackageTitle', { defaultMessage: 'Select an integration', }), children: stepSelectPackage, }, { - title: i18n.translate('xpack.ingestManager.createDatasource.stepDefineDatasourceTitle', { - defaultMessage: 'Define your data source', - }), + title: i18n.translate( + 'xpack.ingestManager.createPackageConfig.stepDefinePackageConfigTitle', + { + defaultMessage: 'Define your integration', + } + ), status: !packageInfo || !agentConfig ? 'disabled' : undefined, children: agentConfig && packageInfo ? ( - ) : null, }, { - title: i18n.translate('xpack.ingestManager.createDatasource.stepConfgiureDatasourceTitle', { - defaultMessage: 'Select the data you want to collect', - }), + title: i18n.translate( + 'xpack.ingestManager.createPackageConfig.stepConfigurePackageConfigTitle', + { + defaultMessage: 'Select the data you want to collect', + } + ), status: !packageInfo || !agentConfig ? 'disabled' : undefined, 'data-test-subj': 'dataCollectionSetupStep', children: agentConfig && packageInfo ? ( - @@ -336,7 +352,7 @@ export const CreateDatasourcePage: React.FunctionComponent = () => { ]; return ( - + {formState === 'CONFIRM' && agentConfig && ( { color="ghost" href={cancelUrl} onClick={cancelClickHandler} - data-test-subj="createDatasourceCancelButton" + data-test-subj="createPackageConfigCancelButton" > @@ -390,17 +406,17 @@ export const CreateDatasourcePage: React.FunctionComponent = () => { iconType="save" color="primary" fill - data-test-subj="createDatasourceSaveButton" + data-test-subj="createPackageConfigSaveButton" > - + ); }; @@ -408,7 +424,7 @@ const ConfigurationBreadcrumb: React.FunctionComponent<{ configName: string; configId: string; }> = ({ configName, configId }) => { - useBreadcrumbs('add_datasource_from_configuration', { configName, configId }); + useBreadcrumbs('add_integration_from_configuration', { configName, configId }); return null; }; @@ -416,6 +432,6 @@ const IntegrationBreadcrumb: React.FunctionComponent<{ pkgTitle: string; pkgkey: string; }> = ({ pkgTitle, pkgkey }) => { - useBreadcrumbs('add_datasource_from_integration', { pkgTitle, pkgkey }); + useBreadcrumbs('add_integration_to_configuration', { pkgTitle, pkgkey }); return null; }; diff --git a/x-pack/plugins/ingest_manager/public/applications/ingest_manager/sections/agent_config/create_datasource_page/services/index.ts b/x-pack/plugins/ingest_manager/public/applications/ingest_manager/sections/agent_config/create_package_config_page/services/index.ts similarity index 65% rename from x-pack/plugins/ingest_manager/public/applications/ingest_manager/sections/agent_config/create_datasource_page/services/index.ts rename to x-pack/plugins/ingest_manager/public/applications/ingest_manager/sections/agent_config/create_package_config_page/services/index.ts index d99f0712db3c3..6cfb1c74bd661 100644 --- a/x-pack/plugins/ingest_manager/public/applications/ingest_manager/sections/agent_config/create_datasource_page/services/index.ts +++ b/x-pack/plugins/ingest_manager/public/applications/ingest_manager/sections/agent_config/create_package_config_page/services/index.ts @@ -5,9 +5,9 @@ */ export { isAdvancedVar } from './is_advanced_var'; export { - DatasourceValidationResults, - DatasourceConfigValidationResults, - DatasourceInputValidationResults, - validateDatasource, + PackageConfigValidationResults, + PackageConfigConfigValidationResults, + PackageConfigInputValidationResults, + validatePackageConfig, validationHasErrors, -} from './validate_datasource'; +} from './validate_package_config'; diff --git a/x-pack/plugins/ingest_manager/public/applications/ingest_manager/sections/agent_config/create_datasource_page/services/is_advanced_var.test.ts b/x-pack/plugins/ingest_manager/public/applications/ingest_manager/sections/agent_config/create_package_config_page/services/is_advanced_var.test.ts similarity index 100% rename from x-pack/plugins/ingest_manager/public/applications/ingest_manager/sections/agent_config/create_datasource_page/services/is_advanced_var.test.ts rename to x-pack/plugins/ingest_manager/public/applications/ingest_manager/sections/agent_config/create_package_config_page/services/is_advanced_var.test.ts diff --git a/x-pack/plugins/ingest_manager/public/applications/ingest_manager/sections/agent_config/create_datasource_page/services/is_advanced_var.ts b/x-pack/plugins/ingest_manager/public/applications/ingest_manager/sections/agent_config/create_package_config_page/services/is_advanced_var.ts similarity index 100% rename from x-pack/plugins/ingest_manager/public/applications/ingest_manager/sections/agent_config/create_datasource_page/services/is_advanced_var.ts rename to x-pack/plugins/ingest_manager/public/applications/ingest_manager/sections/agent_config/create_package_config_page/services/is_advanced_var.ts diff --git a/x-pack/plugins/ingest_manager/public/applications/ingest_manager/sections/agent_config/create_datasource_page/services/validate_datasource.ts b/x-pack/plugins/ingest_manager/public/applications/ingest_manager/sections/agent_config/create_package_config_page/services/validate_package_config.ts similarity index 73% rename from x-pack/plugins/ingest_manager/public/applications/ingest_manager/sections/agent_config/create_datasource_page/services/validate_datasource.ts rename to x-pack/plugins/ingest_manager/public/applications/ingest_manager/sections/agent_config/create_package_config_page/services/validate_package_config.ts index b9bc621e3bbec..cd301747c3f53 100644 --- a/x-pack/plugins/ingest_manager/public/applications/ingest_manager/sections/agent_config/create_datasource_page/services/validate_datasource.ts +++ b/x-pack/plugins/ingest_manager/public/applications/ingest_manager/sections/agent_config/create_package_config_page/services/validate_package_config.ts @@ -21,47 +21,47 @@ type Errors = string[] | null; type ValidationEntry = Record; -export interface DatasourceConfigValidationResults { +export interface PackageConfigConfigValidationResults { vars?: ValidationEntry; } -export type DatasourceInputValidationResults = DatasourceConfigValidationResults & { - streams?: Record; +export type PackageConfigInputValidationResults = PackageConfigConfigValidationResults & { + streams?: Record; }; -export interface DatasourceValidationResults { +export interface PackageConfigValidationResults { name: Errors; description: Errors; namespace: Errors; - inputs: Record | null; + inputs: Record | null; } /* - * Returns validation information for a given datasource configuration and package info - * Note: this method assumes that `datasource` is correctly structured for the given package + * Returns validation information for a given package config and package info + * Note: this method assumes that `packageConfig` is correctly structured for the given package */ -export const validateDatasource = ( - datasource: NewPackageConfig, +export const validatePackageConfig = ( + packageConfig: NewPackageConfig, packageInfo: PackageInfo -): DatasourceValidationResults => { - const validationResults: DatasourceValidationResults = { +): PackageConfigValidationResults => { + const validationResults: PackageConfigValidationResults = { name: null, description: null, namespace: null, inputs: {}, }; - if (!datasource.name.trim()) { + if (!packageConfig.name.trim()) { validationResults.name = [ - i18n.translate('xpack.ingestManager.datasourceValidation.nameRequiredErrorMessage', { + i18n.translate('xpack.ingestManager.packageConfigValidation.nameRequiredErrorMessage', { defaultMessage: 'Name is required', }), ]; } - if (!datasource.namespace.trim()) { + if (!packageConfig.namespace.trim()) { validationResults.namespace = [ - i18n.translate('xpack.ingestManager.datasourceValidation.namespaceRequiredErrorMessage', { + i18n.translate('xpack.ingestManager.packageConfigValidation.namespaceRequiredErrorMessage', { defaultMessage: 'Namespace is required', }), ]; @@ -93,13 +93,13 @@ export const validateDatasource = ( return datasets; }, {} as Record); - // Validate each datasource input with either its own config fields or streams - datasource.inputs.forEach((input) => { + // Validate each package config input with either its own config fields or streams + packageConfig.inputs.forEach((input) => { if (!input.vars && !input.streams) { return; } - const inputValidationResults: DatasourceInputValidationResults = { + const inputValidationResults: PackageConfigInputValidationResults = { vars: undefined, streams: {}, }; @@ -117,7 +117,7 @@ export const validateDatasource = ( if (inputConfigs.length) { inputValidationResults.vars = inputConfigs.reduce((results, [name, configEntry]) => { results[name] = input.enabled - ? validateDatasourceConfig(configEntry, inputVarsByName[name]) + ? validatePackageConfigConfig(configEntry, inputVarsByName[name]) : null; return results; }, {} as ValidationEntry); @@ -128,7 +128,7 @@ export const validateDatasource = ( // Validate each input stream with config fields if (input.streams.length) { input.streams.forEach((stream) => { - const streamValidationResults: DatasourceConfigValidationResults = {}; + const streamValidationResults: PackageConfigConfigValidationResults = {}; // Validate stream-level config fields if (stream.vars) { @@ -146,7 +146,7 @@ export const validateDatasource = ( (results, [name, configEntry]) => { results[name] = input.enabled && stream.enabled - ? validateDatasourceConfig(configEntry, streamVarsByName[name]) + ? validatePackageConfigConfig(configEntry, streamVarsByName[name]) : null; return results; }, @@ -171,7 +171,7 @@ export const validateDatasource = ( return validationResults; }; -const validateDatasourceConfig = ( +const validatePackageConfigConfig = ( configEntry: PackageConfigConfigRecordEntry, varDef: RegistryVarsEntry ): string[] | null => { @@ -186,7 +186,7 @@ const validateDatasourceConfig = ( if (varDef.required) { if (parsedValue === undefined || (typeof parsedValue === 'string' && !parsedValue)) { errors.push( - i18n.translate('xpack.ingestManager.datasourceValidation.requiredErrorMessage', { + i18n.translate('xpack.ingestManager.packageConfigValidation.requiredErrorMessage', { defaultMessage: '{fieldName} is required', values: { fieldName: varDef.title || varDef.name, @@ -201,9 +201,12 @@ const validateDatasourceConfig = ( parsedValue = safeLoad(value); } catch (e) { errors.push( - i18n.translate('xpack.ingestManager.datasourceValidation.invalidYamlFormatErrorMessage', { - defaultMessage: 'Invalid YAML format', - }) + i18n.translate( + 'xpack.ingestManager.packageConfigValidation.invalidYamlFormatErrorMessage', + { + defaultMessage: 'Invalid YAML format', + } + ) ); } } @@ -211,7 +214,7 @@ const validateDatasourceConfig = ( if (varDef.multi) { if (parsedValue && !Array.isArray(parsedValue)) { errors.push( - i18n.translate('xpack.ingestManager.datasourceValidation.invalidArrayErrorMessage', { + i18n.translate('xpack.ingestManager.packageConfigValidation.invalidArrayErrorMessage', { defaultMessage: 'Invalid format', }) ); @@ -221,7 +224,7 @@ const validateDatasourceConfig = ( (!parsedValue || (Array.isArray(parsedValue) && parsedValue.length === 0)) ) { errors.push( - i18n.translate('xpack.ingestManager.datasourceValidation.requiredErrorMessage', { + i18n.translate('xpack.ingestManager.packageConfigValidation.requiredErrorMessage', { defaultMessage: '{fieldName} is required', values: { fieldName: varDef.title || varDef.name, @@ -236,9 +239,9 @@ const validateDatasourceConfig = ( export const validationHasErrors = ( validationResults: - | DatasourceValidationResults - | DatasourceInputValidationResults - | DatasourceConfigValidationResults + | PackageConfigValidationResults + | PackageConfigInputValidationResults + | PackageConfigConfigValidationResults ) => { const flattenedValidation = getFlattenedObject(validationResults); diff --git a/x-pack/plugins/ingest_manager/public/applications/ingest_manager/sections/agent_config/create_datasource_page/services/validate_datasource.test.ts b/x-pack/plugins/ingest_manager/public/applications/ingest_manager/sections/agent_config/create_package_config_page/services/validate_package_config.ts.test.ts similarity index 90% rename from x-pack/plugins/ingest_manager/public/applications/ingest_manager/sections/agent_config/create_datasource_page/services/validate_datasource.test.ts rename to x-pack/plugins/ingest_manager/public/applications/ingest_manager/sections/agent_config/create_package_config_page/services/validate_package_config.ts.test.ts index 2a94ddf82ecc6..41d46f03dca23 100644 --- a/x-pack/plugins/ingest_manager/public/applications/ingest_manager/sections/agent_config/create_datasource_page/services/validate_datasource.test.ts +++ b/x-pack/plugins/ingest_manager/public/applications/ingest_manager/sections/agent_config/create_package_config_page/services/validate_package_config.ts.test.ts @@ -9,9 +9,9 @@ import { NewPackageConfig, RegistryConfigTemplate, } from '../../../../types'; -import { validateDatasource, validationHasErrors } from './validate_datasource'; +import { validatePackageConfig, validationHasErrors } from './validate_package_config'; -describe('Ingest Manager - validateDatasource()', () => { +describe('Ingest Manager - validatePackageConfig()', () => { const mockPackage = ({ name: 'mock-package', title: 'Mock package', @@ -92,9 +92,9 @@ describe('Ingest Manager - validateDatasource()', () => { ], config_templates: [ { - name: 'datasource1', - title: 'Datasource 1', - description: 'test datasource', + name: 'pkgConfig1', + title: 'Package config 1', + description: 'test package config', inputs: [ { type: 'foo', @@ -141,8 +141,8 @@ describe('Ingest Manager - validateDatasource()', () => { ], } as unknown) as PackageInfo; - const validDatasource: NewPackageConfig = { - name: 'datasource1-1', + const validPackageConfig: NewPackageConfig = { + name: 'pkgConfig1-1', namespace: 'default', config_id: 'test-config', enabled: true, @@ -226,8 +226,8 @@ describe('Ingest Manager - validateDatasource()', () => { ], }; - const invalidDatasource: NewPackageConfig = { - ...validDatasource, + const invalidPackageConfig: NewPackageConfig = { + ...validPackageConfig, name: '', inputs: [ { @@ -350,12 +350,14 @@ describe('Ingest Manager - validateDatasource()', () => { }, }; - it('returns no errors for valid datasource configuration', () => { - expect(validateDatasource(validDatasource, mockPackage)).toEqual(noErrorsValidationResults); + it('returns no errors for valid package config', () => { + expect(validatePackageConfig(validPackageConfig, mockPackage)).toEqual( + noErrorsValidationResults + ); }); - it('returns errors for invalid datasource configuration', () => { - expect(validateDatasource(invalidDatasource, mockPackage)).toEqual({ + it('returns errors for invalid package config', () => { + expect(validatePackageConfig(invalidPackageConfig, mockPackage)).toEqual({ name: ['Name is required'], description: null, namespace: null, @@ -395,14 +397,17 @@ describe('Ingest Manager - validateDatasource()', () => { }); it('returns no errors for disabled inputs', () => { - const disabledInputs = invalidDatasource.inputs.map((input) => ({ ...input, enabled: false })); - expect(validateDatasource({ ...validDatasource, inputs: disabledInputs }, mockPackage)).toEqual( - noErrorsValidationResults - ); + const disabledInputs = invalidPackageConfig.inputs.map((input) => ({ + ...input, + enabled: false, + })); + expect( + validatePackageConfig({ ...validPackageConfig, inputs: disabledInputs }, mockPackage) + ).toEqual(noErrorsValidationResults); }); - it('returns only datasource and input-level errors for disabled streams', () => { - const inputsWithDisabledStreams = invalidDatasource.inputs.map((input) => + it('returns only package config and input-level errors for disabled streams', () => { + const inputsWithDisabledStreams = invalidPackageConfig.inputs.map((input) => input.streams ? { ...input, @@ -411,7 +416,10 @@ describe('Ingest Manager - validateDatasource()', () => { : input ); expect( - validateDatasource({ ...invalidDatasource, inputs: inputsWithDisabledStreams }, mockPackage) + validatePackageConfig( + { ...invalidPackageConfig, inputs: inputsWithDisabledStreams }, + mockPackage + ) ).toEqual({ name: ['Name is required'], description: null, @@ -453,9 +461,9 @@ describe('Ingest Manager - validateDatasource()', () => { }); }); - it('returns no errors for packages with no datasources', () => { + it('returns no errors for packages with no package configs', () => { expect( - validateDatasource(validDatasource, { + validatePackageConfig(validPackageConfig, { ...mockPackage, config_templates: undefined, }) @@ -466,7 +474,7 @@ describe('Ingest Manager - validateDatasource()', () => { inputs: null, }); expect( - validateDatasource(validDatasource, { + validatePackageConfig(validPackageConfig, { ...mockPackage, config_templates: [], }) @@ -480,7 +488,7 @@ describe('Ingest Manager - validateDatasource()', () => { it('returns no errors for packages with no inputs', () => { expect( - validateDatasource(validDatasource, { + validatePackageConfig(validPackageConfig, { ...mockPackage, config_templates: [{} as RegistryConfigTemplate], }) @@ -491,7 +499,7 @@ describe('Ingest Manager - validateDatasource()', () => { inputs: null, }); expect( - validateDatasource(validDatasource, { + validatePackageConfig(validPackageConfig, { ...mockPackage, config_templates: [({ inputs: [] } as unknown) as RegistryConfigTemplate], }) @@ -545,7 +553,7 @@ describe('Ingest Manager - validationHasErrors()', () => { ).toBe(false); }); - it('returns true for datasource validation results with errors', () => { + it('returns true for package config validation results with errors', () => { expect( validationHasErrors({ name: ['name error'], @@ -587,7 +595,7 @@ describe('Ingest Manager - validationHasErrors()', () => { ).toBe(true); }); - it('returns false for datasource validation results with no errors', () => { + it('returns false for package config validation results with no errors', () => { expect( validationHasErrors({ name: null, diff --git a/x-pack/plugins/ingest_manager/public/applications/ingest_manager/sections/agent_config/create_datasource_page/step_configure_datasource.tsx b/x-pack/plugins/ingest_manager/public/applications/ingest_manager/sections/agent_config/create_package_config_page/step_configure_package.tsx similarity index 69% rename from x-pack/plugins/ingest_manager/public/applications/ingest_manager/sections/agent_config/create_datasource_page/step_configure_datasource.tsx rename to x-pack/plugins/ingest_manager/public/applications/ingest_manager/sections/agent_config/create_package_config_page/step_configure_package.tsx index 4d7bb47e899bb..eecd204a5e307 100644 --- a/x-pack/plugins/ingest_manager/public/applications/ingest_manager/sections/agent_config/create_datasource_page/step_configure_datasource.tsx +++ b/x-pack/plugins/ingest_manager/public/applications/ingest_manager/sections/agent_config/create_package_config_page/step_configure_package.tsx @@ -9,9 +9,9 @@ import { EuiPanel, EuiFlexGroup, EuiFlexItem, EuiSpacer, EuiCallOut } from '@ela import { i18n } from '@kbn/i18n'; import { PackageInfo, RegistryStream, NewPackageConfig, PackageConfigInput } from '../../../types'; import { Loading } from '../../../components'; -import { DatasourceValidationResults, validationHasErrors } from './services'; -import { DatasourceInputPanel, CustomConfigureDatasource } from './components'; -import { CreateDatasourceFrom } from './types'; +import { PackageConfigValidationResults, validationHasErrors } from './services'; +import { PackageConfigInputPanel, CustomPackageConfig } from './components'; +import { CreatePackageConfigFrom } from './types'; const findStreamsForInputType = ( inputType: string, @@ -35,27 +35,27 @@ const findStreamsForInputType = ( return streams; }; -export const StepConfigureDatasource: React.FunctionComponent<{ - from?: CreateDatasourceFrom; +export const StepConfigurePackage: React.FunctionComponent<{ + from?: CreatePackageConfigFrom; packageInfo: PackageInfo; - datasource: NewPackageConfig; - datasourceId?: string; - updateDatasource: (fields: Partial) => void; - validationResults: DatasourceValidationResults; + packageConfig: NewPackageConfig; + packageConfigId?: string; + updatePackageConfig: (fields: Partial) => void; + validationResults: PackageConfigValidationResults; submitAttempted: boolean; }> = ({ from = 'config', packageInfo, - datasource, - datasourceId, - updateDatasource, + packageConfig, + packageConfigId, + updatePackageConfig, validationResults, submitAttempted, }) => { const hasErrors = validationResults ? validationHasErrors(validationResults) : false; // Configure inputs (and their streams) - // Assume packages only export one datasource for now + // Assume packages only export one config template for now const renderConfigureInputs = () => packageInfo.config_templates && packageInfo.config_templates[0] && @@ -63,30 +63,30 @@ export const StepConfigureDatasource: React.FunctionComponent<{ packageInfo.config_templates[0].inputs.length ? ( {packageInfo.config_templates[0].inputs.map((packageInput) => { - const datasourceInput = datasource.inputs.find( + const packageConfigInput = packageConfig.inputs.find( (input) => input.type === packageInput.type ); const packageInputStreams = findStreamsForInputType(packageInput.type, packageInfo); - return datasourceInput ? ( + return packageConfigInput ? ( - ) => { - const indexOfUpdatedInput = datasource.inputs.findIndex( + packageConfigInput={packageConfigInput} + updatePackageConfigInput={(updatedInput: Partial) => { + const indexOfUpdatedInput = packageConfig.inputs.findIndex( (input) => input.type === packageInput.type ); - const newInputs = [...datasource.inputs]; + const newInputs = [...packageConfig.inputs]; newInputs[indexOfUpdatedInput] = { ...newInputs[indexOfUpdatedInput], ...updatedInput, }; - updateDatasource({ + updatePackageConfig({ inputs: newInputs, }); }} - inputValidationResults={validationResults!.inputs![datasourceInput.type]} + inputValidationResults={validationResults!.inputs![packageConfigInput.type]} forceShowErrors={submitAttempted} /> @@ -95,11 +95,11 @@ export const StepConfigureDatasource: React.FunctionComponent<{ ) : ( - ); @@ -112,16 +112,16 @@ export const StepConfigureDatasource: React.FunctionComponent<{

diff --git a/x-pack/plugins/ingest_manager/public/applications/ingest_manager/sections/agent_config/create_datasource_page/step_define_datasource.tsx b/x-pack/plugins/ingest_manager/public/applications/ingest_manager/sections/agent_config/create_package_config_page/step_define_package_config.tsx similarity index 68% rename from x-pack/plugins/ingest_manager/public/applications/ingest_manager/sections/agent_config/create_datasource_page/step_define_datasource.tsx rename to x-pack/plugins/ingest_manager/public/applications/ingest_manager/sections/agent_config/create_package_config_page/step_define_package_config.tsx index 2dbc8749d00bc..574813629e0b7 100644 --- a/x-pack/plugins/ingest_manager/public/applications/ingest_manager/sections/agent_config/create_datasource_page/step_define_datasource.tsx +++ b/x-pack/plugins/ingest_manager/public/applications/ingest_manager/sections/agent_config/create_package_config_page/step_define_package_config.tsx @@ -18,34 +18,34 @@ import { import { AgentConfig, PackageInfo, PackageConfig, NewPackageConfig } from '../../../types'; import { packageToPackageConfigInputs } from '../../../services'; import { Loading } from '../../../components'; -import { DatasourceValidationResults } from './services'; +import { PackageConfigValidationResults } from './services'; -export const StepDefineDatasource: React.FunctionComponent<{ +export const StepDefinePackageConfig: React.FunctionComponent<{ agentConfig: AgentConfig; packageInfo: PackageInfo; - datasource: NewPackageConfig; - updateDatasource: (fields: Partial) => void; - validationResults: DatasourceValidationResults; -}> = ({ agentConfig, packageInfo, datasource, updateDatasource, validationResults }) => { + packageConfig: NewPackageConfig; + updatePackageConfig: (fields: Partial) => void; + validationResults: PackageConfigValidationResults; +}> = ({ agentConfig, packageInfo, packageConfig, updatePackageConfig, validationResults }) => { // Form show/hide states const [isShowingAdvancedDefine, setIsShowingAdvancedDefine] = useState(false); - // Update datasource's package and config info + // Update package config's package and config info useEffect(() => { - const dsPackage = datasource.package; - const currentPkgKey = dsPackage ? `${dsPackage.name}-${dsPackage.version}` : ''; + const pkg = packageConfig.package; + const currentPkgKey = pkg ? `${pkg.name}-${pkg.version}` : ''; const pkgKey = `${packageInfo.name}-${packageInfo.version}`; - // If package has changed, create shell datasource with input&stream values based on package info + // If package has changed, create shell package config with input&stream values based on package info if (currentPkgKey !== pkgKey) { - // Existing datasources on the agent config using the package name, retrieve highest number appended to datasource name + // Existing package configs on the agent config using the package name, retrieve highest number appended to package config name const dsPackageNamePattern = new RegExp(`${packageInfo.name}-(\\d+)`); const dsWithMatchingNames = (agentConfig.package_configs as PackageConfig[]) .filter((ds) => Boolean(ds.name.match(dsPackageNamePattern))) .map((ds) => parseInt(ds.name.match(dsPackageNamePattern)![1], 10)) .sort(); - updateDatasource({ + updatePackageConfig({ name: `${packageInfo.name}-${ dsWithMatchingNames.length ? dsWithMatchingNames[dsWithMatchingNames.length - 1] + 1 : 1 }`, @@ -58,14 +58,20 @@ export const StepDefineDatasource: React.FunctionComponent<{ }); } - // If agent config has changed, update datasource's config ID and namespace - if (datasource.config_id !== agentConfig.id) { - updateDatasource({ + // If agent config has changed, update package config's config ID and namespace + if (packageConfig.config_id !== agentConfig.id) { + updatePackageConfig({ config_id: agentConfig.id, namespace: agentConfig.namespace, }); } - }, [datasource.package, datasource.config_id, agentConfig, packageInfo, updateDatasource]); + }, [ + packageConfig.package, + packageConfig.config_id, + agentConfig, + packageInfo, + updatePackageConfig, + ]); return validationResults ? ( <> @@ -76,19 +82,19 @@ export const StepDefineDatasource: React.FunctionComponent<{ error={validationResults.name} label={ } > - updateDatasource({ + updatePackageConfig({ name: e.target.value, }) } - data-test-subj="datasourceNameInput" + data-test-subj="packageConfigNameInput" />
@@ -96,14 +102,14 @@ export const StepDefineDatasource: React.FunctionComponent<{ } labelAppend={ @@ -112,9 +118,9 @@ export const StepDefineDatasource: React.FunctionComponent<{ error={validationResults.description} > - updateDatasource({ + updatePackageConfig({ description: e.target.value, }) } @@ -130,7 +136,7 @@ export const StepDefineDatasource: React.FunctionComponent<{ onClick={() => setIsShowingAdvancedDefine(!isShowingAdvancedDefine)} > @@ -145,7 +151,7 @@ export const StepDefineDatasource: React.FunctionComponent<{ error={validationResults.namespace} label={ } @@ -153,14 +159,16 @@ export const StepDefineDatasource: React.FunctionComponent<{ { - updateDatasource({ + updatePackageConfig({ namespace: newNamespace, }); }} onChange={(newNamespaces: Array<{ label: string }>) => { - updateDatasource({ + updatePackageConfig({ namespace: newNamespaces.length ? newNamespaces[0].label : '', }); }} diff --git a/x-pack/plugins/ingest_manager/public/applications/ingest_manager/sections/agent_config/create_datasource_page/step_select_config.tsx b/x-pack/plugins/ingest_manager/public/applications/ingest_manager/sections/agent_config/create_package_config_page/step_select_config.tsx similarity index 91% rename from x-pack/plugins/ingest_manager/public/applications/ingest_manager/sections/agent_config/create_datasource_page/step_select_config.tsx rename to x-pack/plugins/ingest_manager/public/applications/ingest_manager/sections/agent_config/create_package_config_page/step_select_config.tsx index 5f556a46e518d..70668c2856f98 100644 --- a/x-pack/plugins/ingest_manager/public/applications/ingest_manager/sections/agent_config/create_datasource_page/step_select_config.tsx +++ b/x-pack/plugins/ingest_manager/public/applications/ingest_manager/sections/agent_config/create_package_config_page/step_select_config.tsx @@ -76,7 +76,7 @@ export const StepSelectConfig: React.FunctionComponent<{ } @@ -91,7 +91,7 @@ export const StepSelectConfig: React.FunctionComponent<{ } @@ -127,7 +127,7 @@ export const StepSelectConfig: React.FunctionComponent<{ } diff --git a/x-pack/plugins/ingest_manager/public/applications/ingest_manager/sections/agent_config/create_datasource_page/step_select_package.tsx b/x-pack/plugins/ingest_manager/public/applications/ingest_manager/sections/agent_config/create_package_config_page/step_select_package.tsx similarity index 92% rename from x-pack/plugins/ingest_manager/public/applications/ingest_manager/sections/agent_config/create_datasource_page/step_select_package.tsx rename to x-pack/plugins/ingest_manager/public/applications/ingest_manager/sections/agent_config/create_package_config_page/step_select_package.tsx index 12f5bf9eec1d0..e4f4c976688b1 100644 --- a/x-pack/plugins/ingest_manager/public/applications/ingest_manager/sections/agent_config/create_datasource_page/step_select_package.tsx +++ b/x-pack/plugins/ingest_manager/public/applications/ingest_manager/sections/agent_config/create_package_config_page/step_select_package.tsx @@ -70,7 +70,7 @@ export const StepSelectPackage: React.FunctionComponent<{ } @@ -85,7 +85,7 @@ export const StepSelectPackage: React.FunctionComponent<{ } @@ -124,7 +124,7 @@ export const StepSelectPackage: React.FunctionComponent<{ }} searchProps={{ placeholder: i18n.translate( - 'xpack.ingestManager.createDatasource.stepSelectPackage.filterPackagesInputPlaceholder', + 'xpack.ingestManager.createPackageConfig.stepSelectPackage.filterPackagesInputPlaceholder', { defaultMessage: 'Search for integrations', } @@ -155,7 +155,7 @@ export const StepSelectPackage: React.FunctionComponent<{ } diff --git a/x-pack/plugins/ingest_manager/public/applications/ingest_manager/sections/agent_config/create_datasource_page/types.ts b/x-pack/plugins/ingest_manager/public/applications/ingest_manager/sections/agent_config/create_package_config_page/types.ts similarity index 59% rename from x-pack/plugins/ingest_manager/public/applications/ingest_manager/sections/agent_config/create_datasource_page/types.ts rename to x-pack/plugins/ingest_manager/public/applications/ingest_manager/sections/agent_config/create_package_config_page/types.ts index 10b30a5696d83..5386ff17fe96b 100644 --- a/x-pack/plugins/ingest_manager/public/applications/ingest_manager/sections/agent_config/create_datasource_page/types.ts +++ b/x-pack/plugins/ingest_manager/public/applications/ingest_manager/sections/agent_config/create_package_config_page/types.ts @@ -4,5 +4,5 @@ * you may not use this file except in compliance with the Elastic License. */ -export type CreateDatasourceFrom = 'package' | 'config' | 'edit'; -export type DatasourceFormState = 'VALID' | 'INVALID' | 'CONFIRM' | 'LOADING' | 'SUBMITTED'; +export type CreatePackageConfigFrom = 'package' | 'config' | 'edit'; +export type PackageConfigFormState = 'VALID' | 'INVALID' | 'CONFIRM' | 'LOADING' | 'SUBMITTED'; diff --git a/x-pack/plugins/ingest_manager/public/applications/ingest_manager/sections/agent_config/details_page/components/index.ts b/x-pack/plugins/ingest_manager/public/applications/ingest_manager/sections/agent_config/details_page/components/index.ts index ee2eb9f9dbba6..e53206c68c443 100644 --- a/x-pack/plugins/ingest_manager/public/applications/ingest_manager/sections/agent_config/details_page/components/index.ts +++ b/x-pack/plugins/ingest_manager/public/applications/ingest_manager/sections/agent_config/details_page/components/index.ts @@ -3,6 +3,6 @@ * or more contributor license agreements. Licensed under the Elastic License; * you may not use this file except in compliance with the Elastic License. */ -export { DatasourcesTable } from './datasources/datasources_table'; -export { ConfigDatasourcesView } from './datasources'; +export { PackageConfigsTable } from './package_configs/package_configs_table'; +export { ConfigPackageConfigsView } from './package_configs'; export { ConfigSettingsView } from './settings'; diff --git a/x-pack/plugins/ingest_manager/public/applications/ingest_manager/sections/agent_config/details_page/components/datasources/index.tsx b/x-pack/plugins/ingest_manager/public/applications/ingest_manager/sections/agent_config/details_page/components/package_configs/index.tsx similarity index 55% rename from x-pack/plugins/ingest_manager/public/applications/ingest_manager/sections/agent_config/details_page/components/datasources/index.tsx rename to x-pack/plugins/ingest_manager/public/applications/ingest_manager/sections/agent_config/details_page/components/package_configs/index.tsx index e5fde9b605db4..3aef297e8d22e 100644 --- a/x-pack/plugins/ingest_manager/public/applications/ingest_manager/sections/agent_config/details_page/components/datasources/index.tsx +++ b/x-pack/plugins/ingest_manager/public/applications/ingest_manager/sections/agent_config/details_page/components/package_configs/index.tsx @@ -6,18 +6,18 @@ import React, { memo } from 'react'; import { AgentConfig, PackageConfig } from '../../../../../types'; -import { NoDatasources } from './no_datasources'; -import { DatasourcesTable } from './datasources_table'; +import { NoPackageConfigs } from './no_package_configs'; +import { PackageConfigsTable } from './package_configs_table'; -export const ConfigDatasourcesView = memo<{ config: AgentConfig }>(({ config }) => { +export const ConfigPackageConfigsView = memo<{ config: AgentConfig }>(({ config }) => { if (config.package_configs.length === 0) { - return ; + return ; } return ( - ); }); diff --git a/x-pack/plugins/ingest_manager/public/applications/ingest_manager/sections/agent_config/details_page/components/datasources/no_datasources.tsx b/x-pack/plugins/ingest_manager/public/applications/ingest_manager/sections/agent_config/details_page/components/package_configs/no_package_configs.tsx similarity index 61% rename from x-pack/plugins/ingest_manager/public/applications/ingest_manager/sections/agent_config/details_page/components/datasources/no_datasources.tsx rename to x-pack/plugins/ingest_manager/public/applications/ingest_manager/sections/agent_config/details_page/components/package_configs/no_package_configs.tsx index f2c204d955a0b..ad75c70783698 100644 --- a/x-pack/plugins/ingest_manager/public/applications/ingest_manager/sections/agent_config/details_page/components/datasources/no_datasources.tsx +++ b/x-pack/plugins/ingest_manager/public/applications/ingest_manager/sections/agent_config/details_page/components/package_configs/no_package_configs.tsx @@ -3,13 +3,12 @@ * or more contributor license agreements. Licensed under the Elastic License; * you may not use this file except in compliance with the Elastic License. */ - +import React, { memo } from 'react'; import { FormattedMessage } from '@kbn/i18n/react'; import { EuiButton, EuiEmptyPrompt } from '@elastic/eui'; -import React, { memo } from 'react'; import { useCapabilities, useLink } from '../../../../../hooks'; -export const NoDatasources = memo<{ configId: string }>(({ configId }) => { +export const NoPackageConfigs = memo<{ configId: string }>(({ configId }) => { const { getHref } = useLink(); const hasWriteCapabilities = useCapabilities().write; @@ -19,26 +18,26 @@ export const NoDatasources = memo<{ configId: string }>(({ configId }) => { title={

} body={ } actions={ } diff --git a/x-pack/plugins/ingest_manager/public/applications/ingest_manager/sections/agent_config/details_page/components/datasources/datasources_table.tsx b/x-pack/plugins/ingest_manager/public/applications/ingest_manager/sections/agent_config/details_page/components/package_configs/package_configs_table.tsx similarity index 56% rename from x-pack/plugins/ingest_manager/public/applications/ingest_manager/sections/agent_config/details_page/components/datasources/datasources_table.tsx rename to x-pack/plugins/ingest_manager/public/applications/ingest_manager/sections/agent_config/details_page/components/package_configs/package_configs_table.tsx index f179269019eef..19243084f6821 100644 --- a/x-pack/plugins/ingest_manager/public/applications/ingest_manager/sections/agent_config/details_page/components/datasources/datasources_table.tsx +++ b/x-pack/plugins/ingest_manager/public/applications/ingest_manager/sections/agent_config/details_page/components/package_configs/package_configs_table.tsx @@ -18,11 +18,11 @@ import { } from '@elastic/eui'; import { AgentConfig, PackageConfig } from '../../../../../types'; import { PackageIcon, ContextMenuActions } from '../../../../../components'; -import { DatasourceDeleteProvider, DangerEuiContextMenuItem } from '../../../components'; +import { PackageConfigDeleteProvider, DangerEuiContextMenuItem } from '../../../components'; import { useCapabilities, useLink } from '../../../../../hooks'; import { useConfigRefresh } from '../../hooks'; -interface InMemoryDatasource extends PackageConfig { +interface InMemoryPackageConfig extends PackageConfig { streams: { total: number; enabled: number }; inputTypes: string[]; packageName?: string; @@ -31,11 +31,11 @@ interface InMemoryDatasource extends PackageConfig { } interface Props { - datasources: PackageConfig[]; + packageConfigs: PackageConfig[]; config: AgentConfig; // Pass through props to InMemoryTable - loading?: EuiInMemoryTableProps['loading']; - message?: EuiInMemoryTableProps['message']; + loading?: EuiInMemoryTableProps['loading']; + message?: EuiInMemoryTableProps['message']; } interface FilterOption { @@ -46,8 +46,8 @@ interface FilterOption { const stringSortAscending = (a: string, b: string): number => a.localeCompare(b); const toFilterOption = (value: string): FilterOption => ({ name: value, value }); -export const DatasourcesTable: React.FunctionComponent = ({ - datasources: originalDatasources, +export const PackageConfigsTable: React.FunctionComponent = ({ + packageConfigs: originalPackageConfigs, config, ...rest }) => { @@ -55,75 +55,80 @@ export const DatasourcesTable: React.FunctionComponent = ({ const hasWriteCapabilities = useCapabilities().write; const refreshConfig = useConfigRefresh(); - // With the datasources provided on input, generate the list of datasources + // With the package configs provided on input, generate the list of package configs // used in the InMemoryTable (flattens some values for search) as well as // the list of options that will be used in the filters dropdowns - const [datasources, namespaces, inputTypes] = useMemo((): [ - InMemoryDatasource[], + const [packageConfigs, namespaces, inputTypes] = useMemo((): [ + InMemoryPackageConfig[], FilterOption[], FilterOption[] ] => { const namespacesValues: string[] = []; const inputTypesValues: string[] = []; - const mappedDatasources = originalDatasources.map((datasource) => { - if (datasource.namespace && !namespacesValues.includes(datasource.namespace)) { - namespacesValues.push(datasource.namespace); - } + const mappedPackageConfigs = originalPackageConfigs.map( + (packageConfig) => { + if (packageConfig.namespace && !namespacesValues.includes(packageConfig.namespace)) { + namespacesValues.push(packageConfig.namespace); + } - const dsInputTypes: string[] = []; - const streams = datasource.inputs.reduce( - (streamSummary, input) => { - if (!inputTypesValues.includes(input.type)) { - inputTypesValues.push(input.type); - } - if (!dsInputTypes.includes(input.type)) { - dsInputTypes.push(input.type); - } + const dsInputTypes: string[] = []; + const streams = packageConfig.inputs.reduce( + (streamSummary, input) => { + if (!inputTypesValues.includes(input.type)) { + inputTypesValues.push(input.type); + } + if (!dsInputTypes.includes(input.type)) { + dsInputTypes.push(input.type); + } - streamSummary.total += input.streams.length; - streamSummary.enabled += input.enabled - ? input.streams.filter((stream) => stream.enabled).length - : 0; + streamSummary.total += input.streams.length; + streamSummary.enabled += input.enabled + ? input.streams.filter((stream) => stream.enabled).length + : 0; - return streamSummary; - }, - { total: 0, enabled: 0 } - ); + return streamSummary; + }, + { total: 0, enabled: 0 } + ); - dsInputTypes.sort(stringSortAscending); + dsInputTypes.sort(stringSortAscending); - return { - ...datasource, - streams, - inputTypes: dsInputTypes, - packageName: datasource.package?.name ?? '', - packageTitle: datasource.package?.title ?? '', - packageVersion: datasource.package?.version ?? '', - }; - }); + return { + ...packageConfig, + streams, + inputTypes: dsInputTypes, + packageName: packageConfig.package?.name ?? '', + packageTitle: packageConfig.package?.title ?? '', + packageVersion: packageConfig.package?.version ?? '', + }; + } + ); namespacesValues.sort(stringSortAscending); inputTypesValues.sort(stringSortAscending); return [ - mappedDatasources, + mappedPackageConfigs, namespacesValues.map(toFilterOption), inputTypesValues.map(toFilterOption), ]; - }, [originalDatasources]); + }, [originalPackageConfigs]); const columns = useMemo( - (): EuiInMemoryTableProps['columns'] => [ + (): EuiInMemoryTableProps['columns'] => [ { field: 'name', - name: i18n.translate('xpack.ingestManager.configDetails.datasourcesTable.nameColumnTitle', { - defaultMessage: 'Data source', - }), + name: i18n.translate( + 'xpack.ingestManager.configDetails.packageConfigsTable.nameColumnTitle', + { + defaultMessage: 'Name', + } + ), }, { field: 'description', name: i18n.translate( - 'xpack.ingestManager.configDetails.datasourcesTable.descriptionColumnTitle', + 'xpack.ingestManager.configDetails.packageConfigsTable.descriptionColumnTitle', { defaultMessage: 'Description', } @@ -133,19 +138,19 @@ export const DatasourcesTable: React.FunctionComponent = ({ { field: 'packageTitle', name: i18n.translate( - 'xpack.ingestManager.configDetails.datasourcesTable.packageNameColumnTitle', + 'xpack.ingestManager.configDetails.packageConfigsTable.packageNameColumnTitle', { defaultMessage: 'Integration', } ), - render(packageTitle: string, datasource: InMemoryDatasource) { + render(packageTitle: string, packageConfig: InMemoryPackageConfig) { return ( - {datasource.package && ( + {packageConfig.package && ( @@ -159,24 +164,24 @@ export const DatasourcesTable: React.FunctionComponent = ({ { field: 'namespace', name: i18n.translate( - 'xpack.ingestManager.configDetails.datasourcesTable.namespaceColumnTitle', + 'xpack.ingestManager.configDetails.packageConfigsTable.namespaceColumnTitle', { defaultMessage: 'Namespace', } ), - render: (namespace: InMemoryDatasource['namespace']) => { + render: (namespace: InMemoryPackageConfig['namespace']) => { return namespace ? {namespace} : ''; }, }, { field: 'streams', name: i18n.translate( - 'xpack.ingestManager.configDetails.datasourcesTable.streamsCountColumnTitle', + 'xpack.ingestManager.configDetails.packageConfigsTable.streamsCountColumnTitle', { defaultMessage: 'Streams', } ), - render: (streams: InMemoryDatasource['streams']) => { + render: (streams: InMemoryPackageConfig['streams']) => { return ( <> {streams.enabled} @@ -187,67 +192,67 @@ export const DatasourcesTable: React.FunctionComponent = ({ }, { name: i18n.translate( - 'xpack.ingestManager.configDetails.datasourcesTable.actionsColumnTitle', + 'xpack.ingestManager.configDetails.packageConfigsTable.actionsColumnTitle', { defaultMessage: 'Actions', } ), actions: [ { - render: (datasource: InMemoryDatasource) => ( + render: (packageConfig: InMemoryPackageConfig) => ( {}} - // key="datasourceView" + // key="packageConfigView" // > // // , , - // FIXME: implement Copy datasource action - // {}} key="datasourceCopy"> + // FIXME: implement Copy package config action + // {}} key="packageConfigCopy"> // // , - - {(deleteDatasourcePrompt) => { + + {(deletePackageConfigsPrompt) => { return ( { - deleteDatasourcePrompt([datasource.id], refreshConfig); + deletePackageConfigsPrompt([packageConfig.id], refreshConfig); }} > ); }} - , + , ]} /> ), @@ -259,9 +264,9 @@ export const DatasourcesTable: React.FunctionComponent = ({ ); return ( - + itemId="id" - items={datasources} + items={packageConfigs} columns={columns} sorting={{ sort: { @@ -273,14 +278,14 @@ export const DatasourcesTable: React.FunctionComponent = ({ search={{ toolsRight: [ , ], diff --git a/x-pack/plugins/ingest_manager/public/applications/ingest_manager/sections/agent_config/details_page/index.tsx b/x-pack/plugins/ingest_manager/public/applications/ingest_manager/sections/agent_config/details_page/index.tsx index c5862de49b659..4ae16eb91e582 100644 --- a/x-pack/plugins/ingest_manager/public/applications/ingest_manager/sections/agent_config/details_page/index.tsx +++ b/x-pack/plugins/ingest_manager/public/applications/ingest_manager/sections/agent_config/details_page/index.tsx @@ -28,7 +28,7 @@ import { Loading } from '../../../components'; import { WithHeaderLayout } from '../../../layouts'; import { ConfigRefreshContext, useGetAgentStatus, AgentStatusRefreshContext } from './hooks'; import { LinkedAgentCount, AgentConfigActionMenu } from '../components'; -import { ConfigDatasourcesView, ConfigSettingsView } from './components'; +import { ConfigPackageConfigsView, ConfigSettingsView } from './components'; import { useIntraAppState } from '../../../hooks/use_intra_app_state'; const Divider = styled.div` @@ -121,7 +121,7 @@ export const AgentConfigDetailsPage: React.FunctionComponent = () => { { isDivider: true }, { label: i18n.translate('xpack.ingestManager.configDetails.summary.package_configs', { - defaultMessage: 'Data sources', + defaultMessage: 'Integrations', }), content: ( { const headerTabs = useMemo(() => { return [ { - id: 'datasources', - name: i18n.translate('xpack.ingestManager.configDetails.subTabs.datasourcesTabText', { - defaultMessage: 'Data sources', + id: 'integrations', + name: i18n.translate('xpack.ingestManager.configDetails.subTabs.packageConfigsTabText', { + defaultMessage: 'Integrations', }), - href: getHref('configuration_details', { configId, tabId: 'datasources' }), - isSelected: tabId === '' || tabId === 'datasources', + href: getHref('configuration_details', { configId, tabId: 'integrations' }), + isSelected: tabId === '' || tabId === 'integrations', }, { id: 'settings', @@ -295,7 +295,7 @@ const AgentConfigDetailsContent: React.FunctionComponent<{ agentConfig: AgentCon { - return ; + return ; }} /> diff --git a/x-pack/plugins/ingest_manager/public/applications/ingest_manager/sections/agent_config/edit_datasource_page/index.tsx b/x-pack/plugins/ingest_manager/public/applications/ingest_manager/sections/agent_config/edit_package_config_page/index.tsx similarity index 66% rename from x-pack/plugins/ingest_manager/public/applications/ingest_manager/sections/agent_config/edit_datasource_page/index.tsx rename to x-pack/plugins/ingest_manager/public/applications/ingest_manager/sections/agent_config/edit_package_config_page/index.tsx index 5eaa1f59b47b8..7fbcdbb9738cb 100644 --- a/x-pack/plugins/ingest_manager/public/applications/ingest_manager/sections/agent_config/edit_datasource_page/index.tsx +++ b/x-pack/plugins/ingest_manager/public/applications/ingest_manager/sections/agent_config/edit_package_config_page/index.tsx @@ -22,25 +22,28 @@ import { useBreadcrumbs, useCore, useConfig, - sendUpdateDatasource, + sendUpdatePackageConfig, sendGetAgentStatus, sendGetOneAgentConfig, - sendGetOneDatasource, + sendGetOnePackageConfig, sendGetPackageInfoByKey, } from '../../../hooks'; import { Loading, Error } from '../../../components'; import { ConfirmDeployConfigModal } from '../components'; -import { CreateDatasourcePageLayout } from '../create_datasource_page/components'; +import { CreatePackageConfigPageLayout } from '../create_package_config_page/components'; import { - DatasourceValidationResults, - validateDatasource, + PackageConfigValidationResults, + validatePackageConfig, validationHasErrors, -} from '../create_datasource_page/services'; -import { DatasourceFormState, CreateDatasourceFrom } from '../create_datasource_page/types'; -import { StepConfigureDatasource } from '../create_datasource_page/step_configure_datasource'; -import { StepDefineDatasource } from '../create_datasource_page/step_define_datasource'; +} from '../create_package_config_page/services'; +import { + PackageConfigFormState, + CreatePackageConfigFrom, +} from '../create_package_config_page/types'; +import { StepConfigurePackage } from '../create_package_config_page/step_configure_package'; +import { StepDefinePackageConfig } from '../create_package_config_page/step_define_package_config'; -export const EditDatasourcePage: React.FunctionComponent = () => { +export const EditPackageConfigPage: React.FunctionComponent = () => { const { notifications, chrome: { getIsNavDrawerLocked$ }, @@ -50,7 +53,7 @@ export const EditDatasourcePage: React.FunctionComponent = () => { fleet: { enabled: isFleetEnabled }, } = useConfig(); const { - params: { configId, datasourceId }, + params: { configId, packageConfigId }, } = useRouteMatch(); const history = useHistory(); const { getHref, getPath } = useLink(); @@ -64,12 +67,12 @@ export const EditDatasourcePage: React.FunctionComponent = () => { return () => subscription.unsubscribe(); }); - // Agent config, package info, and datasource states + // Agent config, package info, and package config states const [isLoadingData, setIsLoadingData] = useState(true); const [loadingError, setLoadingError] = useState(); const [agentConfig, setAgentConfig] = useState(); const [packageInfo, setPackageInfo] = useState(); - const [datasource, setDatasource] = useState({ + const [packageConfig, setPackageConfig] = useState({ name: '', description: '', namespace: '', @@ -79,20 +82,20 @@ export const EditDatasourcePage: React.FunctionComponent = () => { inputs: [], }); - // Retrieve agent config, package, and datasource info + // Retrieve agent config, package, and package config info useEffect(() => { const getData = async () => { setIsLoadingData(true); setLoadingError(undefined); try { - const [{ data: agentConfigData }, { data: datasourceData }] = await Promise.all([ + const [{ data: agentConfigData }, { data: packageConfigData }] = await Promise.all([ sendGetOneAgentConfig(configId), - sendGetOneDatasource(datasourceId), + sendGetOnePackageConfig(packageConfigId), ]); if (agentConfigData?.item) { setAgentConfig(agentConfigData.item); } - if (datasourceData?.item) { + if (packageConfigData?.item) { const { id, revision, @@ -101,11 +104,11 @@ export const EditDatasourcePage: React.FunctionComponent = () => { created_at, updated_by, updated_at, - ...restOfDatasource - } = datasourceData.item; + ...restOfPackageConfig + } = packageConfigData.item; // Remove `compiled_stream` from all stream info, we assign this after saving - const newDatasource = { - ...restOfDatasource, + const newPackageConfig = { + ...restOfPackageConfig, inputs: inputs.map((input) => { const { streams, ...restOfInput } = input; return { @@ -117,14 +120,14 @@ export const EditDatasourcePage: React.FunctionComponent = () => { }; }), }; - setDatasource(newDatasource); - if (datasourceData.item.package) { + setPackageConfig(newPackageConfig); + if (packageConfigData.item.package) { const { data: packageData } = await sendGetPackageInfoByKey( - `${datasourceData.item.package.name}-${datasourceData.item.package.version}` + `${packageConfigData.item.package.name}-${packageConfigData.item.package.version}` ); if (packageData?.response) { setPackageInfo(packageData.response); - setValidationResults(validateDatasource(newDatasource, packageData.response)); + setValidationResults(validatePackageConfig(newPackageConfig, packageData.response)); setFormState('VALID'); } } @@ -135,7 +138,7 @@ export const EditDatasourcePage: React.FunctionComponent = () => { setIsLoadingData(false); }; getData(); - }, [configId, datasourceId]); + }, [configId, packageConfigId]); // Retrieve agent count const [agentCount, setAgentCount] = useState(0); @@ -152,21 +155,21 @@ export const EditDatasourcePage: React.FunctionComponent = () => { } }, [configId, isFleetEnabled]); - // Datasource validation state - const [validationResults, setValidationResults] = useState(); + // Package config validation state + const [validationResults, setValidationResults] = useState(); const hasErrors = validationResults ? validationHasErrors(validationResults) : false; - // Update datasource method - const updateDatasource = (updatedFields: Partial) => { - const newDatasource = { - ...datasource, + // Update package config method + const updatePackageConfig = (updatedFields: Partial) => { + const newPackageConfig = { + ...packageConfig, ...updatedFields, }; - setDatasource(newDatasource); + setPackageConfig(newPackageConfig); // eslint-disable-next-line no-console - console.debug('Datasource updated', newDatasource); - const newValidationResults = updateDatasourceValidation(newDatasource); + console.debug('Package config updated', newPackageConfig); + const newValidationResults = updatePackageConfigValidation(newPackageConfig); const hasValidationErrors = newValidationResults ? validationHasErrors(newValidationResults) : false; @@ -175,12 +178,15 @@ export const EditDatasourcePage: React.FunctionComponent = () => { } }; - const updateDatasourceValidation = (newDatasource?: NewPackageConfig) => { + const updatePackageConfigValidation = (newPackageConfig?: NewPackageConfig) => { if (packageInfo) { - const newValidationResult = validateDatasource(newDatasource || datasource, packageInfo); + const newValidationResult = validatePackageConfig( + newPackageConfig || packageConfig, + packageInfo + ); setValidationResults(newValidationResult); // eslint-disable-next-line no-console - console.debug('Datasource validation results', newValidationResult); + console.debug('Package config validation results', newValidationResult); return newValidationResult; } @@ -189,11 +195,11 @@ export const EditDatasourcePage: React.FunctionComponent = () => { // Cancel url const cancelUrl = getHref('configuration_details', { configId }); - // Save datasource - const [formState, setFormState] = useState('INVALID'); - const saveDatasource = async () => { + // Save package config + const [formState, setFormState] = useState('INVALID'); + const savePackageConfig = async () => { setFormState('LOADING'); - const result = await sendUpdateDatasource(datasourceId, datasource); + const result = await sendUpdatePackageConfig(packageConfigId, packageConfig); setFormState('SUBMITTED'); return result; }; @@ -207,19 +213,19 @@ export const EditDatasourcePage: React.FunctionComponent = () => { setFormState('CONFIRM'); return; } - const { error } = await saveDatasource(); + const { error } = await savePackageConfig(); if (!error) { history.push(getPath('configuration_details', { configId })); notifications.toasts.addSuccess({ - title: i18n.translate('xpack.ingestManager.editDatasource.updatedNotificationTitle', { - defaultMessage: `Successfully updated '{datasourceName}'`, + title: i18n.translate('xpack.ingestManager.editPackageConfig.updatedNotificationTitle', { + defaultMessage: `Successfully updated '{packageConfigName}'`, values: { - datasourceName: datasource.name, + packageConfigName: packageConfig.name, }, }), text: agentCount && agentConfig - ? i18n.translate('xpack.ingestManager.editDatasource.updatedNotificationMessage', { + ? i18n.translate('xpack.ingestManager.editPackageConfig.updatedNotificationMessage', { defaultMessage: `Fleet will deploy updates to all agents that use the '{agentConfigName}' configuration`, values: { agentConfigName: agentConfig.name, @@ -236,28 +242,28 @@ export const EditDatasourcePage: React.FunctionComponent = () => { }; const layoutProps = { - from: 'edit' as CreateDatasourceFrom, + from: 'edit' as CreatePackageConfigFrom, cancelUrl, agentConfig, packageInfo, }; return ( - + {isLoadingData ? ( ) : loadingError || !agentConfig || !packageInfo ? ( } error={ loadingError || - i18n.translate('xpack.ingestManager.editDatasource.errorLoadingDataMessage', { - defaultMessage: 'There was an error loading this data source information', + i18n.translate('xpack.ingestManager.editPackageConfig.errorLoadingDataMessage', { + defaultMessage: 'There was an error loading this intergration information', }) } /> @@ -276,35 +282,35 @@ export const EditDatasourcePage: React.FunctionComponent = () => { steps={[ { title: i18n.translate( - 'xpack.ingestManager.editDatasource.stepDefineDatasourceTitle', + 'xpack.ingestManager.editPackageConfig.stepDefinePackageConfigTitle', { - defaultMessage: 'Define your data source', + defaultMessage: 'Define your integration', } ), children: ( - ), }, { title: i18n.translate( - 'xpack.ingestManager.editDatasource.stepConfgiureDatasourceTitle', + 'xpack.ingestManager.editPackageConfig.stepConfigurePackageConfigTitle', { defaultMessage: 'Select the data you want to collect', } ), children: ( - @@ -327,7 +333,7 @@ export const EditDatasourcePage: React.FunctionComponent = () => { @@ -342,8 +348,8 @@ export const EditDatasourcePage: React.FunctionComponent = () => { fill > @@ -351,7 +357,7 @@ export const EditDatasourcePage: React.FunctionComponent = () => { )} - + ); }; @@ -359,6 +365,6 @@ const Breadcrumb: React.FunctionComponent<{ configName: string; configId: string configName, configId, }) => { - useBreadcrumbs('edit_datasource', { configName, configId }); + useBreadcrumbs('edit_integration', { configName, configId }); return null; }; diff --git a/x-pack/plugins/ingest_manager/public/applications/ingest_manager/sections/agent_config/index.tsx b/x-pack/plugins/ingest_manager/public/applications/ingest_manager/sections/agent_config/index.tsx index 74fa67078f741..727ef23347251 100644 --- a/x-pack/plugins/ingest_manager/public/applications/ingest_manager/sections/agent_config/index.tsx +++ b/x-pack/plugins/ingest_manager/public/applications/ingest_manager/sections/agent_config/index.tsx @@ -9,8 +9,8 @@ import { PAGE_ROUTING_PATHS } from '../../constants'; import { useBreadcrumbs } from '../../hooks'; import { AgentConfigListPage } from './list_page'; import { AgentConfigDetailsPage } from './details_page'; -import { CreateDatasourcePage } from './create_datasource_page'; -import { EditDatasourcePage } from './edit_datasource_page'; +import { CreatePackageConfigPage } from './create_package_config_page'; +import { EditPackageConfigPage } from './edit_package_config_page'; export const AgentConfigApp: React.FunctionComponent = () => { useBreadcrumbs('configurations'); @@ -18,11 +18,11 @@ export const AgentConfigApp: React.FunctionComponent = () => { return ( - - + + - - + + diff --git a/x-pack/plugins/ingest_manager/public/applications/ingest_manager/sections/agent_config/list_page/components/create_config.tsx b/x-pack/plugins/ingest_manager/public/applications/ingest_manager/sections/agent_config/list_page/components/create_config.tsx index f746fadc4b0a3..d1abd88adba86 100644 --- a/x-pack/plugins/ingest_manager/public/applications/ingest_manager/sections/agent_config/list_page/components/create_config.tsx +++ b/x-pack/plugins/ingest_manager/public/applications/ingest_manager/sections/agent_config/list_page/components/create_config.tsx @@ -64,7 +64,7 @@ export const CreateAgentConfigFlyout: React.FunctionComponent = ({ onClos diff --git a/x-pack/plugins/ingest_manager/public/applications/ingest_manager/sections/agent_config/list_page/index.tsx b/x-pack/plugins/ingest_manager/public/applications/ingest_manager/sections/agent_config/list_page/index.tsx index 85c86079e332b..0a9daf0038aab 100644 --- a/x-pack/plugins/ingest_manager/public/applications/ingest_manager/sections/agent_config/list_page/index.tsx +++ b/x-pack/plugins/ingest_manager/public/applications/ingest_manager/sections/agent_config/list_page/index.tsx @@ -176,13 +176,13 @@ export const AgentConfigListPage: React.FunctionComponent<{}> = () => { ), }, { - field: 'datasources', - name: i18n.translate('xpack.ingestManager.agentConfigList.datasourcesCountColumnTitle', { - defaultMessage: 'Data sources', + field: 'package_configs', + name: i18n.translate('xpack.ingestManager.agentConfigList.packageConfigsCountColumnTitle', { + defaultMessage: 'Integrations', }), dataType: 'number', - render: (datasources: AgentConfig['package_configs']) => - datasources ? datasources.length : 0, + render: (packageConfigs: AgentConfig['package_configs']) => + packageConfigs ? packageConfigs.length : 0, }, { name: i18n.translate('xpack.ingestManager.agentConfigList.actionsColumnTitle', { diff --git a/x-pack/plugins/ingest_manager/public/applications/ingest_manager/sections/epm/index.tsx b/x-pack/plugins/ingest_manager/public/applications/ingest_manager/sections/epm/index.tsx index ca1a8df534044..cb0664143bb34 100644 --- a/x-pack/plugins/ingest_manager/public/applications/ingest_manager/sections/epm/index.tsx +++ b/x-pack/plugins/ingest_manager/public/applications/ingest_manager/sections/epm/index.tsx @@ -8,7 +8,7 @@ import React from 'react'; import { HashRouter as Router, Switch, Route } from 'react-router-dom'; import { PAGE_ROUTING_PATHS } from '../../constants'; import { useConfig, useBreadcrumbs } from '../../hooks'; -import { CreateDatasourcePage } from '../agent_config/create_datasource_page'; +import { CreatePackageConfigPage } from '../agent_config/create_package_config_page'; import { EPMHomePage } from './screens/home'; import { Detail } from './screens/detail'; @@ -19,8 +19,8 @@ export const EPMApp: React.FunctionComponent = () => { return epm.enabled ? ( - - + + diff --git a/x-pack/plugins/ingest_manager/public/applications/ingest_manager/sections/epm/screens/detail/content.tsx b/x-pack/plugins/ingest_manager/public/applications/ingest_manager/sections/epm/screens/detail/content.tsx index 94bbba00c5aea..ff32d78a80fc0 100644 --- a/x-pack/plugins/ingest_manager/public/applications/ingest_manager/sections/epm/screens/detail/content.tsx +++ b/x-pack/plugins/ingest_manager/public/applications/ingest_manager/sections/epm/screens/detail/content.tsx @@ -14,7 +14,7 @@ import { Requirements } from '../../components/requirements'; import { CenterColumn, LeftColumn, RightColumn } from './layout'; import { OverviewPanel } from './overview_panel'; import { SideNavLinks } from './side_nav_links'; -import { DataSourcesPanel } from './data_sources_panel'; +import { PackageConfigsPanel } from './package_configs_panel'; import { SettingsPanel } from './settings_panel'; type ContentProps = PackageInfo & Pick & { hasIconPanel: boolean }; @@ -64,7 +64,7 @@ export function ContentPanel(props: ContentPanelProps) { /> ); case 'usages': - return ; + return ; case 'overview': default: return ; diff --git a/x-pack/plugins/ingest_manager/public/applications/ingest_manager/sections/epm/screens/detail/header.tsx b/x-pack/plugins/ingest_manager/public/applications/ingest_manager/sections/epm/screens/detail/header.tsx index db046d18ccebc..875a8f5c5c127 100644 --- a/x-pack/plugins/ingest_manager/public/applications/ingest_manager/sections/epm/screens/detail/header.tsx +++ b/x-pack/plugins/ingest_manager/public/applications/ingest_manager/sections/epm/screens/detail/header.tsx @@ -70,10 +70,10 @@ export function Header(props: HeaderProps) { { +export const PackageConfigsPanel = ({ name, version }: PackageConfigsPanelProps) => { const { getPath } = useLink(); const getPackageInstallStatus = useGetPackageInstallStatus(); const packageInstallStatus = getPackageInstallStatus(name); @@ -23,11 +22,5 @@ export const DataSourcesPanel = ({ name, version }: DataSourcesPanelProps) => { // this happens if they arrive with a direct url or they uninstall while on this tab if (packageInstallStatus.status !== InstallStatus.installed) return ; - return ( - - - Data Sources - - - ); + return null; }; diff --git a/x-pack/plugins/ingest_manager/public/applications/ingest_manager/sections/epm/screens/detail/settings_panel.tsx b/x-pack/plugins/ingest_manager/public/applications/ingest_manager/sections/epm/screens/detail/settings_panel.tsx index 52d2cd0bcc314..125289ce3ee8d 100644 --- a/x-pack/plugins/ingest_manager/public/applications/ingest_manager/sections/epm/screens/detail/settings_panel.tsx +++ b/x-pack/plugins/ingest_manager/public/applications/ingest_manager/sections/epm/screens/detail/settings_panel.tsx @@ -10,7 +10,7 @@ import { EuiTitle, EuiFlexGroup, EuiFlexItem, EuiText } from '@elastic/eui'; import { EuiSpacer } from '@elastic/eui'; import styled from 'styled-components'; import { InstallStatus, PackageInfo } from '../../../../types'; -import { useGetDatasources } from '../../../../hooks'; +import { useGetPackageConfigs } from '../../../../hooks'; import { PACKAGE_CONFIG_SAVED_OBJECT_TYPE } from '../../../../constants'; import { useGetPackageInstallStatus } from '../../hooks'; import { InstallationButton } from './installation_button'; @@ -46,13 +46,13 @@ export const SettingsPanel = ( ) => { const { name, title, removable, latestVersion, version } = props; const getPackageInstallStatus = useGetPackageInstallStatus(); - const { data: datasourcesData } = useGetDatasources({ + const { data: packageConfigsData } = useGetPackageConfigs({ perPage: 0, page: 1, kuery: `${PACKAGE_CONFIG_SAVED_OBJECT_TYPE}.package.name:${props.name}`, }); const { status: installationStatus, version: installedVersion } = getPackageInstallStatus(name); - const packageHasDatasources = !!datasourcesData?.total; + const packageHasUsages = !!packageConfigsData?.total; const updateAvailable = installedVersion && installedVersion < latestVersion ? true : false; const isViewingOldPackage = version < latestVersion; // hide install/remove options if the user has version of the package is installed @@ -185,16 +185,16 @@ export const SettingsPanel = (

- {packageHasDatasources && removable === true && ( + {packageHasUsages && removable === true && (

= { overview: i18n.translate('xpack.ingestManager.epm.packageDetailsNav.overviewLinkText', { defaultMessage: 'Overview', }), - usages: i18n.translate('xpack.ingestManager.epm.packageDetailsNav.datasourcesLinkText', { - defaultMessage: 'Data sources', + usages: i18n.translate('xpack.ingestManager.epm.packageDetailsNav.packageConfigsLinkText', { + defaultMessage: 'Usages', }), settings: i18n.translate('xpack.ingestManager.epm.packageDetailsNav.settingsLinkText', { defaultMessage: 'Settings', @@ -43,8 +43,8 @@ export function SideNavLinks({ name, version, active }: NavLinkProps) { ? p.theme.eui.euiFontWeightSemiBold : p.theme.eui.euiFontWeightRegular}; `; - // Don't display Data Sources tab as we haven't implemented this yet - // FIXME: Restore when we implement data sources page + // Don't display usages tab as we haven't implemented this yet + // FIXME: Restore when we implement usages page if (panel === 'usages' && (true || packageInstallStatus.status !== InstallStatus.installed)) return null; diff --git a/x-pack/plugins/ingest_manager/public/applications/ingest_manager/sections/fleet/components/agent_config_datasource_badges.tsx b/x-pack/plugins/ingest_manager/public/applications/ingest_manager/sections/fleet/components/agent_config_package_badges.tsx similarity index 76% rename from x-pack/plugins/ingest_manager/public/applications/ingest_manager/sections/fleet/components/agent_config_datasource_badges.tsx rename to x-pack/plugins/ingest_manager/public/applications/ingest_manager/sections/fleet/components/agent_config_package_badges.tsx index 96ca23a387624..fcdb5ff02e7a4 100644 --- a/x-pack/plugins/ingest_manager/public/applications/ingest_manager/sections/fleet/components/agent_config_datasource_badges.tsx +++ b/x-pack/plugins/ingest_manager/public/applications/ingest_manager/sections/fleet/components/agent_config_package_badges.tsx @@ -14,7 +14,7 @@ interface Props { agentConfigId: string; } -export const AgentConfigDatasourceBadges: React.FunctionComponent = ({ agentConfigId }) => { +export const AgentConfigPackageBadges: React.FunctionComponent = ({ agentConfigId }) => { const agentConfigRequest = useGetOneAgentConfig(agentConfigId); const agentConfig = agentConfigRequest.data ? agentConfigRequest.data.item : null; @@ -26,7 +26,7 @@ export const AgentConfigDatasourceBadges: React.FunctionComponent = ({ ag {agentConfig.package_configs.length}, @@ -34,8 +34,8 @@ export const AgentConfigDatasourceBadges: React.FunctionComponent = ({ ag /> - {(agentConfig.package_configs as PackageConfig[]).map((datasource, idx) => { - if (!datasource.package) { + {(agentConfig.package_configs as PackageConfig[]).map((packageConfig, idx) => { + if (!packageConfig.package) { return null; } return ( @@ -43,13 +43,13 @@ export const AgentConfigDatasourceBadges: React.FunctionComponent = ({ ag - {datasource.package.title} + {packageConfig.package.title} ); diff --git a/x-pack/plugins/ingest_manager/public/applications/ingest_manager/sections/fleet/components/agent_enrollment_flyout/config_selection.tsx b/x-pack/plugins/ingest_manager/public/applications/ingest_manager/sections/fleet/components/agent_enrollment_flyout/config_selection.tsx index 6e7427c6ab55e..8cd337586d1bc 100644 --- a/x-pack/plugins/ingest_manager/public/applications/ingest_manager/sections/fleet/components/agent_enrollment_flyout/config_selection.tsx +++ b/x-pack/plugins/ingest_manager/public/applications/ingest_manager/sections/fleet/components/agent_enrollment_flyout/config_selection.tsx @@ -10,7 +10,7 @@ import { FormattedMessage } from '@kbn/i18n/react'; import { EuiSelect, EuiSpacer, EuiText, EuiButtonEmpty } from '@elastic/eui'; import { AgentConfig } from '../../../../types'; import { useGetEnrollmentAPIKeys } from '../../../../hooks'; -import { AgentConfigDatasourceBadges } from '../agent_config_datasource_badges'; +import { AgentConfigPackageBadges } from '../agent_config_package_badges'; interface Props { agentConfigs: AgentConfig[]; @@ -83,7 +83,7 @@ export const EnrollmentStepAgentConfig: React.FC = ({ agentConfigs, onKey /> {selectedState.agentConfigId && ( - + )} void; @@ -113,7 +113,7 @@ export const AgentReassignConfigFlyout: React.FunctionComponent = ({ onCl {selectedAgentConfigId && ( - + )} diff --git a/x-pack/plugins/ingest_manager/public/applications/ingest_manager/sections/overview/components/configuration_section.tsx b/x-pack/plugins/ingest_manager/public/applications/ingest_manager/sections/overview/components/configuration_section.tsx index 68364f9acbbf9..4879dde134378 100644 --- a/x-pack/plugins/ingest_manager/public/applications/ingest_manager/sections/overview/components/configuration_section.tsx +++ b/x-pack/plugins/ingest_manager/public/applications/ingest_manager/sections/overview/components/configuration_section.tsx @@ -15,7 +15,7 @@ import { } from '@elastic/eui'; import { OverviewPanel } from './overview_panel'; import { OverviewStats } from './overview_stats'; -import { useLink, useGetDatasources } from '../../../hooks'; +import { useLink, useGetPackageConfigs } from '../../../hooks'; import { AgentConfig } from '../../../types'; import { Loading } from '../../fleet/components'; @@ -23,7 +23,7 @@ export const OverviewConfigurationSection: React.FC<{ agentConfigs: AgentConfig[ agentConfigs, }) => { const { getHref } = useLink(); - const datasourcesRequest = useGetDatasources({ + const packageConfigsRequest = useGetPackageConfigs({ page: 1, perPage: 10000, }); @@ -48,7 +48,7 @@ export const OverviewConfigurationSection: React.FC<{ agentConfigs: AgentConfig[ - {datasourcesRequest.isLoading ? ( + {packageConfigsRequest.isLoading ? ( ) : ( <> @@ -63,12 +63,12 @@ export const OverviewConfigurationSection: React.FC<{ agentConfigs: AgentConfig[ - + )} diff --git a/x-pack/plugins/ingest_manager/public/applications/ingest_manager/types/index.ts b/x-pack/plugins/ingest_manager/public/applications/ingest_manager/types/index.ts index 5b79513df926e..43ec2f6d1a74d 100644 --- a/x-pack/plugins/ingest_manager/public/applications/ingest_manager/types/index.ts +++ b/x-pack/plugins/ingest_manager/public/applications/ingest_manager/types/index.ts @@ -35,7 +35,7 @@ export { CopyAgentConfigResponse, DeleteAgentConfigRequest, DeleteAgentConfigResponse, - // API schemas - Datasource + // API schemas - Package config CreatePackageConfigRequest, CreatePackageConfigResponse, UpdatePackageConfigRequest, diff --git a/x-pack/plugins/ingest_manager/public/applications/ingest_manager/types/intra_app_route_state.ts b/x-pack/plugins/ingest_manager/public/applications/ingest_manager/types/intra_app_route_state.ts index a736698fea150..49200625b0859 100644 --- a/x-pack/plugins/ingest_manager/public/applications/ingest_manager/types/intra_app_route_state.ts +++ b/x-pack/plugins/ingest_manager/public/applications/ingest_manager/types/intra_app_route_state.ts @@ -8,13 +8,13 @@ import { ApplicationStart } from 'kibana/public'; import { PackageConfig } from './'; /** - * Supported routing state for the create datasource page routes + * Supported routing state for the create package config page routes */ -export interface CreateDatasourceRouteState { - /** On a successful save of the datasource, use navigate to the given app */ +export interface CreatePackageConfigRouteState { + /** On a successful save of the package config, use navigate to the given app */ onSaveNavigateTo?: | Parameters - | ((newDatasource: PackageConfig) => Parameters); + | ((newPackageConfig: PackageConfig) => Parameters); /** On cancel, navigate to the given app */ onCancelNavigateTo?: Parameters; /** Url to be used on cancel links */ @@ -33,5 +33,5 @@ export interface AgentConfigDetailsDeployAgentAction { * All possible Route states. */ export type AnyIntraAppRouteState = - | CreateDatasourceRouteState + | CreatePackageConfigRouteState | AgentConfigDetailsDeployAgentAction; diff --git a/x-pack/plugins/ingest_manager/public/index.ts b/x-pack/plugins/ingest_manager/public/index.ts index 4ecef9cdb4710..866d17145b075 100644 --- a/x-pack/plugins/ingest_manager/public/index.ts +++ b/x-pack/plugins/ingest_manager/public/index.ts @@ -13,10 +13,10 @@ export const plugin = (initializerContext: PluginInitializerContext) => { }; export { - CustomConfigureDatasourceContent, - CustomConfigureDatasourceProps, - registerDatasource, -} from './applications/ingest_manager/sections/agent_config/create_datasource_page/components/custom_configure_datasource'; + CustomConfigurePackageConfigContent, + CustomConfigurePackageConfigProps, + registerPackageConfigComponent, +} from './applications/ingest_manager/sections/agent_config/create_package_config_page/components/custom_package_config'; export { NewPackageConfig } from './applications/ingest_manager/types'; export * from './applications/ingest_manager/types/intra_app_route_state'; diff --git a/x-pack/plugins/ingest_manager/public/plugin.ts b/x-pack/plugins/ingest_manager/public/plugin.ts index 4a10a26151e78..69dd5e42a0bc5 100644 --- a/x-pack/plugins/ingest_manager/public/plugin.ts +++ b/x-pack/plugins/ingest_manager/public/plugin.ts @@ -18,7 +18,7 @@ import { PLUGIN_ID, CheckPermissionsResponse, PostIngestSetupResponse } from '.. import { IngestManagerConfigType } from '../common/types'; import { setupRouteService, appRoutesService } from '../common'; -import { registerDatasource } from './applications/ingest_manager/sections/agent_config/create_datasource_page/components/custom_configure_datasource'; +import { registerPackageConfigComponent } from './applications/ingest_manager/sections/agent_config/create_package_config_page/components/custom_package_config'; export { IngestManagerConfigType } from '../common/types'; @@ -31,7 +31,7 @@ export interface IngestManagerSetup {} * Describes public IngestManager plugin contract returned at the `start` stage. */ export interface IngestManagerStart { - registerDatasource: typeof registerDatasource; + registerPackageConfigComponent: typeof registerPackageConfigComponent; success: Promise; } @@ -102,7 +102,7 @@ export class IngestManagerPlugin return { success: successPromise, - registerDatasource, + registerPackageConfigComponent, }; } diff --git a/x-pack/plugins/security_solution/common/endpoint/generate_data.ts b/x-pack/plugins/security_solution/common/endpoint/generate_data.ts index 563e2e4ccc9f2..0cc6377c8dba6 100644 --- a/x-pack/plugins/security_solution/common/endpoint/generate_data.ts +++ b/x-pack/plugins/security_solution/common/endpoint/generate_data.ts @@ -965,9 +965,9 @@ export class EndpointDocGenerator { } /** - * Generates an Ingest `datasource` that includes the Endpoint Policy data + * Generates an Ingest `package config` that includes the Endpoint Policy data */ - public generatePolicyDatasource(): PolicyData { + public generatePolicyPackageConfig(): PolicyData { const created = new Date(Date.now() - 8.64e7).toISOString(); // 24h ago return { id: this.seededUUIDv4(), diff --git a/x-pack/plugins/security_solution/public/common/mock/endpoint/dependencies_start_mock.ts b/x-pack/plugins/security_solution/public/common/mock/endpoint/dependencies_start_mock.ts index f2e8d045eccf9..9276d503176c6 100644 --- a/x-pack/plugins/security_solution/public/common/mock/endpoint/dependencies_start_mock.ts +++ b/x-pack/plugins/security_solution/public/common/mock/endpoint/dependencies_start_mock.ts @@ -4,7 +4,10 @@ * you may not use this file except in compliance with the Elastic License. */ -import { IngestManagerStart, registerDatasource } from '../../../../../ingest_manager/public'; +import { + IngestManagerStart, + registerPackageConfigComponent, +} from '../../../../../ingest_manager/public'; import { dataPluginMock, Start as DataPublicStartMock, @@ -56,6 +59,6 @@ export const depsStartMock: () => DepsStartMock = () => { return { data: dataMock, - ingestManager: { success: Promise.resolve(true), registerDatasource }, + ingestManager: { success: Promise.resolve(true), registerPackageConfigComponent }, }; }; diff --git a/x-pack/plugins/security_solution/public/management/pages/endpoint_hosts/store/middleware.ts b/x-pack/plugins/security_solution/public/management/pages/endpoint_hosts/store/middleware.ts index ce164318fdadc..12fa3dc47beac 100644 --- a/x-pack/plugins/security_solution/public/management/pages/endpoint_hosts/store/middleware.ts +++ b/x-pack/plugins/security_solution/public/management/pages/endpoint_hosts/store/middleware.ts @@ -16,7 +16,7 @@ import { } from './selectors'; import { HostState } from '../types'; import { - sendGetEndpointSpecificDatasources, + sendGetEndpointSpecificPackageConfigs, sendGetEndpointSecurityPackage, } from '../../policy/store/policy_list/services/ingest'; @@ -69,7 +69,7 @@ export const hostMiddlewareFactory: ImmutableMiddlewareFactory = (cor if (hostResponse && hostResponse.hosts.length === 0) { const http = coreStart.http; try { - const policyDataResponse: GetPolicyListResponse = await sendGetEndpointSpecificDatasources( + const policyDataResponse: GetPolicyListResponse = await sendGetEndpointSpecificPackageConfigs( http, { query: { diff --git a/x-pack/plugins/security_solution/public/management/pages/endpoint_hosts/view/index.tsx b/x-pack/plugins/security_solution/public/management/pages/endpoint_hosts/view/index.tsx index 3601b8db5ee59..d49335ca8de2c 100644 --- a/x-pack/plugins/security_solution/public/management/pages/endpoint_hosts/view/index.tsx +++ b/x-pack/plugins/security_solution/public/management/pages/endpoint_hosts/view/index.tsx @@ -37,7 +37,7 @@ import { PolicyEmptyState, EndpointsEmptyState } from '../../../components/manag import { FormattedDate } from '../../../../common/components/formatted_date'; import { useNavigateToAppEventHandler } from '../../../../common/hooks/endpoint/use_navigate_to_app_event_handler'; import { - CreateDatasourceRouteState, + CreatePackageConfigRouteState, AgentConfigDetailsDeployAgentAction, } from '../../../../../../ingest_manager/public'; import { SecurityPageName } from '../../../../app/types'; @@ -118,11 +118,11 @@ export const HostList = () => { [history, queryParams] ); - const handleCreatePolicyClick = useNavigateToAppEventHandler( + const handleCreatePolicyClick = useNavigateToAppEventHandler( 'ingestManager', { path: `#/integrations${ - endpointPackageVersion ? `/endpoint-${endpointPackageVersion}/add-datasource` : '' + endpointPackageVersion ? `/endpoint-${endpointPackageVersion}/add-integration` : '' }`, state: { onCancelNavigateTo: [ diff --git a/x-pack/plugins/security_solution/public/management/pages/policy/store/policy_details/middleware.ts b/x-pack/plugins/security_solution/public/management/pages/policy/store/policy_details/middleware.ts index 899f85ecdea30..cfa1a478619b7 100644 --- a/x-pack/plugins/security_solution/public/management/pages/policy/store/policy_details/middleware.ts +++ b/x-pack/plugins/security_solution/public/management/pages/policy/store/policy_details/middleware.ts @@ -12,9 +12,9 @@ import { policyDetailsForUpdate, } from './selectors'; import { - sendGetDatasource, + sendGetPackageConfig, sendGetFleetAgentStatusForConfig, - sendPutDatasource, + sendPutPackageConfig, } from '../policy_list/services/ingest'; import { NewPolicyData, PolicyData } from '../../../../../../common/endpoint/types'; import { ImmutableMiddlewareFactory } from '../../../../../common/store'; @@ -33,7 +33,7 @@ export const policyDetailsMiddlewareFactory: ImmutableMiddlewareFactory { }, }); await waitForAction('serverReturnedPolicyListData'); - expect(fakeCoreStart.http.get).toHaveBeenCalledWith(INGEST_API_DATASOURCES, { + expect(fakeCoreStart.http.get).toHaveBeenCalledWith(INGEST_API_PACKAGE_CONFIGS, { query: { kuery: `${PACKAGE_CONFIG_SAVED_OBJECT_TYPE}.package.name: endpoint`, page: 1, @@ -188,7 +188,7 @@ describe('policy list store concerns', () => { it('uses pagination params from url', async () => { dispatchUserChangedUrl('?page_size=50&page_index=0'); await waitForAction('serverReturnedPolicyListData'); - expect(fakeCoreStart.http.get).toHaveBeenCalledWith(INGEST_API_DATASOURCES, { + expect(fakeCoreStart.http.get).toHaveBeenCalledWith(INGEST_API_PACKAGE_CONFIGS, { query: { kuery: `${PACKAGE_CONFIG_SAVED_OBJECT_TYPE}.package.name: endpoint`, page: 1, @@ -211,7 +211,7 @@ describe('policy list store concerns', () => { it('accepts only positive numbers for page_index and page_size', async () => { dispatchUserChangedUrl('?page_size=-50&page_index=-99'); await waitForAction('serverReturnedPolicyListData'); - expect(fakeCoreStart.http.get).toHaveBeenCalledWith(INGEST_API_DATASOURCES, { + expect(fakeCoreStart.http.get).toHaveBeenCalledWith(INGEST_API_PACKAGE_CONFIGS, { query: { kuery: `${PACKAGE_CONFIG_SAVED_OBJECT_TYPE}.package.name: endpoint`, page: 1, @@ -222,7 +222,7 @@ describe('policy list store concerns', () => { it('it ignores non-numeric values for page_index and page_size', async () => { dispatchUserChangedUrl('?page_size=fifty&page_index=ten'); await waitForAction('serverReturnedPolicyListData'); - expect(fakeCoreStart.http.get).toHaveBeenCalledWith(INGEST_API_DATASOURCES, { + expect(fakeCoreStart.http.get).toHaveBeenCalledWith(INGEST_API_PACKAGE_CONFIGS, { query: { kuery: `${PACKAGE_CONFIG_SAVED_OBJECT_TYPE}.package.name: endpoint`, page: 1, @@ -233,7 +233,7 @@ describe('policy list store concerns', () => { it('accepts only known values for `page_size`', async () => { dispatchUserChangedUrl('?page_size=300&page_index=10'); await waitForAction('serverReturnedPolicyListData'); - expect(fakeCoreStart.http.get).toHaveBeenCalledWith(INGEST_API_DATASOURCES, { + expect(fakeCoreStart.http.get).toHaveBeenCalledWith(INGEST_API_PACKAGE_CONFIGS, { query: { kuery: `${PACKAGE_CONFIG_SAVED_OBJECT_TYPE}.package.name: endpoint`, page: 11, @@ -262,7 +262,7 @@ describe('policy list store concerns', () => { expect(endpointPackageVersion(store.getState())).toEqual('0.5.0'); fakeCoreStart.http.get.mockClear(); dispatchUserChangedUrl('?page_size=10&page_index=11'); - expect(fakeCoreStart.http.get).toHaveBeenCalledWith(INGEST_API_DATASOURCES, { + expect(fakeCoreStart.http.get).toHaveBeenCalledWith(INGEST_API_PACKAGE_CONFIGS, { query: { kuery: `${PACKAGE_CONFIG_SAVED_OBJECT_TYPE}.package.name: endpoint`, page: 12, diff --git a/x-pack/plugins/security_solution/public/management/pages/policy/store/policy_list/middleware.ts b/x-pack/plugins/security_solution/public/management/pages/policy/store/policy_list/middleware.ts index 39d0511ea2bea..b4e1da4e43da3 100644 --- a/x-pack/plugins/security_solution/public/management/pages/policy/store/policy_list/middleware.ts +++ b/x-pack/plugins/security_solution/public/management/pages/policy/store/policy_list/middleware.ts @@ -6,8 +6,8 @@ import { GetPolicyListResponse, PolicyListState } from '../../types'; import { - sendGetEndpointSpecificDatasources, - sendDeleteDatasource, + sendGetEndpointSpecificPackageConfigs, + sendDeletePackageConfig, sendGetFleetAgentStatusForConfig, sendGetEndpointSecurityPackage, } from './services/ingest'; @@ -56,7 +56,7 @@ export const policyListMiddlewareFactory: ImmutableMiddlewareFactory { http = httpServiceMock.createStartContract(); }); - describe('sendGetEndpointSpecificDatasources()', () => { + describe('sendGetEndpointSpecificPackageConfigs()', () => { it('auto adds kuery to api request', async () => { - await sendGetEndpointSpecificDatasources(http); - expect(http.get).toHaveBeenCalledWith('/api/ingest_manager/datasources', { + await sendGetEndpointSpecificPackageConfigs(http); + expect(http.get).toHaveBeenCalledWith('/api/ingest_manager/package_configs', { query: { kuery: `${PACKAGE_CONFIG_SAVED_OBJECT_TYPE}.package.name: endpoint`, }, }); }); it('supports additional KQL to be defined on input for query params', async () => { - await sendGetEndpointSpecificDatasources(http, { + await sendGetEndpointSpecificPackageConfigs(http, { query: { kuery: 'someValueHere', page: 1, perPage: 10 }, }); - expect(http.get).toHaveBeenCalledWith('/api/ingest_manager/datasources', { + expect(http.get).toHaveBeenCalledWith('/api/ingest_manager/package_configs', { query: { kuery: `someValueHere and ${PACKAGE_CONFIG_SAVED_OBJECT_TYPE}.package.name: endpoint`, perPage: 10, @@ -44,14 +44,14 @@ describe('ingest service', () => { }); }); - describe('sendGetDatasource()', () => { + describe('sendGetPackageConfig()', () => { it('builds correct API path', async () => { - await sendGetDatasource(http, '123'); - expect(http.get).toHaveBeenCalledWith('/api/ingest_manager/datasources/123', undefined); + await sendGetPackageConfig(http, '123'); + expect(http.get).toHaveBeenCalledWith('/api/ingest_manager/package_configs/123', undefined); }); it('supports http options', async () => { - await sendGetDatasource(http, '123', { query: { page: 1 } }); - expect(http.get).toHaveBeenCalledWith('/api/ingest_manager/datasources/123', { + await sendGetPackageConfig(http, '123', { query: { page: 1 } }); + expect(http.get).toHaveBeenCalledWith('/api/ingest_manager/package_configs/123', { query: { page: 1, }, diff --git a/x-pack/plugins/security_solution/public/management/pages/policy/store/policy_list/services/ingest.ts b/x-pack/plugins/security_solution/public/management/pages/policy/store/policy_list/services/ingest.ts index d49dbb8dc28b0..48b6bedf50fd8 100644 --- a/x-pack/plugins/security_solution/public/management/pages/policy/store/policy_list/services/ingest.ts +++ b/x-pack/plugins/security_solution/public/management/pages/policy/store/policy_list/services/ingest.ts @@ -17,23 +17,23 @@ import { GetPolicyListResponse, GetPolicyResponse, UpdatePolicyResponse } from ' import { NewPolicyData } from '../../../../../../../common/endpoint/types'; const INGEST_API_ROOT = `/api/ingest_manager`; -export const INGEST_API_DATASOURCES = `${INGEST_API_ROOT}/datasources`; +export const INGEST_API_PACKAGE_CONFIGS = `${INGEST_API_ROOT}/package_configs`; const INGEST_API_FLEET = `${INGEST_API_ROOT}/fleet`; const INGEST_API_FLEET_AGENT_STATUS = `${INGEST_API_FLEET}/agent-status`; export const INGEST_API_EPM_PACKAGES = `${INGEST_API_ROOT}/epm/packages`; -const INGEST_API_DELETE_DATASOURCE = `${INGEST_API_DATASOURCES}/delete`; +const INGEST_API_DELETE_PACKAGE_CONFIG = `${INGEST_API_PACKAGE_CONFIGS}/delete`; /** - * Retrieves a list of endpoint specific datasources (those created with a `package.name` of + * Retrieves a list of endpoint specific package configs (those created with a `package.name` of * `endpoint`) from Ingest * @param http * @param options */ -export const sendGetEndpointSpecificDatasources = ( +export const sendGetEndpointSpecificPackageConfigs = ( http: HttpStart, options: HttpFetchOptions & Partial = {} ): Promise => { - return http.get(INGEST_API_DATASOURCES, { + return http.get(INGEST_API_PACKAGE_CONFIGS, { ...options, query: { ...options.query, @@ -45,53 +45,53 @@ export const sendGetEndpointSpecificDatasources = ( }; /** - * Retrieves a single datasource based on ID from ingest + * Retrieves a single package config based on ID from ingest * @param http - * @param datasourceId + * @param packageConfigId * @param options */ -export const sendGetDatasource = ( +export const sendGetPackageConfig = ( http: HttpStart, - datasourceId: string, + packageConfigId: string, options?: HttpFetchOptions ) => { - return http.get(`${INGEST_API_DATASOURCES}/${datasourceId}`, options); + return http.get(`${INGEST_API_PACKAGE_CONFIGS}/${packageConfigId}`, options); }; /** - * Retrieves a single datasource based on ID from ingest + * Retrieves a single package config based on ID from ingest * @param http - * @param datasourceId + * @param body * @param options */ -export const sendDeleteDatasource = ( +export const sendDeletePackageConfig = ( http: HttpStart, body: DeletePackageConfigsRequest, options?: HttpFetchOptions ) => { - return http.post(INGEST_API_DELETE_DATASOURCE, { + return http.post(INGEST_API_DELETE_PACKAGE_CONFIG, { ...options, body: JSON.stringify(body.body), }); }; /** - * Updates a datasources + * Updates a package config * * @param http - * @param datasourceId - * @param datasource + * @param packageConfigId + * @param packageConfig * @param options */ -export const sendPutDatasource = ( +export const sendPutPackageConfig = ( http: HttpStart, - datasourceId: string, - datasource: NewPolicyData, + packageConfigId: string, + packageConfig: NewPolicyData, options: Exclude = {} ): Promise => { - return http.put(`${INGEST_API_DATASOURCES}/${datasourceId}`, { + return http.put(`${INGEST_API_PACKAGE_CONFIGS}/${packageConfigId}`, { ...options, - body: JSON.stringify(datasource), + body: JSON.stringify(packageConfig), }); }; diff --git a/x-pack/plugins/security_solution/public/management/pages/policy/store/policy_list/test_mock_utils.ts b/x-pack/plugins/security_solution/public/management/pages/policy/store/policy_list/test_mock_utils.ts index 46f84d296bd4e..963b7922a7bff 100644 --- a/x-pack/plugins/security_solution/public/management/pages/policy/store/policy_list/test_mock_utils.ts +++ b/x-pack/plugins/security_solution/public/management/pages/policy/store/policy_list/test_mock_utils.ts @@ -5,7 +5,7 @@ */ import { HttpStart } from 'kibana/public'; -import { INGEST_API_DATASOURCES, INGEST_API_EPM_PACKAGES } from './services/ingest'; +import { INGEST_API_PACKAGE_CONFIGS, INGEST_API_EPM_PACKAGES } from './services/ingest'; import { EndpointDocGenerator } from '../../../../../../common/endpoint/generate_data'; import { GetPolicyListResponse } from '../../types'; import { @@ -99,12 +99,12 @@ export const apiPathMockResponseProviders = { */ export const setPolicyListApiMockImplementation = ( mockedHttpService: jest.Mocked, - responseItems: GetPolicyListResponse['items'] = [generator.generatePolicyDatasource()] + responseItems: GetPolicyListResponse['items'] = [generator.generatePolicyPackageConfig()] ): void => { mockedHttpService.get.mockImplementation((...args) => { const [path] = args; if (typeof path === 'string') { - if (path === INGEST_API_DATASOURCES) { + if (path === INGEST_API_PACKAGE_CONFIGS) { return Promise.resolve({ items: responseItems, total: 10, diff --git a/x-pack/plugins/security_solution/public/management/pages/policy/view/ingest_manager_integration/configure_datasource.tsx b/x-pack/plugins/security_solution/public/management/pages/policy/view/ingest_manager_integration/configure_package_config.tsx similarity index 78% rename from x-pack/plugins/security_solution/public/management/pages/policy/view/ingest_manager_integration/configure_datasource.tsx rename to x-pack/plugins/security_solution/public/management/pages/policy/view/ingest_manager_integration/configure_package_config.tsx index df1591bf78778..1e2307c884695 100644 --- a/x-pack/plugins/security_solution/public/management/pages/policy/view/ingest_manager_integration/configure_datasource.tsx +++ b/x-pack/plugins/security_solution/public/management/pages/policy/view/ingest_manager_integration/configure_package_config.tsx @@ -10,20 +10,20 @@ import { EuiCallOut, EuiText, EuiTitle, EuiSpacer } from '@elastic/eui'; import { i18n } from '@kbn/i18n'; import { LinkToApp } from '../../../../../common/components/endpoint/link_to_app'; import { - CustomConfigureDatasourceContent, - CustomConfigureDatasourceProps, + CustomConfigurePackageConfigContent, + CustomConfigurePackageConfigProps, } from '../../../../../../../ingest_manager/public'; import { getPolicyDetailPath } from '../../../../common/routing'; /** - * Exports Endpoint-specific datasource configuration instructions - * for use in the Ingest app create / edit datasource config + * Exports Endpoint-specific package config instructions + * for use in the Ingest app create / edit package config */ -export const ConfigureEndpointDatasource = memo( - ({ from, datasourceId }: CustomConfigureDatasourceProps) => { +export const ConfigureEndpointPackageConfig = memo( + ({ from, packageConfigId }: CustomConfigurePackageConfigProps) => { let policyUrl = ''; - if (from === 'edit' && datasourceId) { - policyUrl = getPolicyDetailPath(datasourceId); + if (from === 'edit' && packageConfigId) { + policyUrl = getPolicyDetailPath(packageConfigId); } return ( @@ -38,7 +38,7 @@ export const ConfigureEndpointDatasource = memo @@ -65,14 +65,14 @@ export const ConfigureEndpointDatasource = memo ) : ( )} @@ -84,4 +84,4 @@ export const ConfigureEndpointDatasource = memo { let middlewareSpy: AppContextTestRender['middlewareSpy']; let http: typeof coreStart.http; let render: (ui: Parameters[0]) => ReturnType; - let policyDatasource: ReturnType; + let policyPackageConfig: ReturnType; let policyView: ReturnType; beforeEach(() => { @@ -75,17 +75,17 @@ describe('Policy Details', () => { let asyncActions: Promise = Promise.resolve(); beforeEach(() => { - policyDatasource = generator.generatePolicyDatasource(); - policyDatasource.id = '1'; + policyPackageConfig = generator.generatePolicyPackageConfig(); + policyPackageConfig.id = '1'; http.get.mockImplementation((...args) => { const [path] = args; if (typeof path === 'string') { // GET datasouce - if (path === '/api/ingest_manager/datasources/1') { + if (path === '/api/ingest_manager/package_configs/1') { asyncActions = asyncActions.then(async (): Promise => sleep()); return Promise.resolve({ - item: policyDatasource, + item: policyPackageConfig, success: true, }); } @@ -130,7 +130,7 @@ describe('Policy Details', () => { const pageTitle = pageHeaderLeft.find('[data-test-subj="pageViewHeaderLeftTitle"]'); expect(pageTitle).toHaveLength(1); - expect(pageTitle.text()).toEqual(policyDatasource.name); + expect(pageTitle.text()).toEqual(policyPackageConfig.name); }); it('should navigate to list if back to link is clicked', async () => { policyView.update(); @@ -200,9 +200,9 @@ describe('Policy Details', () => { asyncActions = asyncActions.then(async () => sleep()); const [path] = args; if (typeof path === 'string') { - if (path === '/api/ingest_manager/datasources/1') { + if (path === '/api/ingest_manager/package_configs/1') { return Promise.resolve({ - item: policyDatasource, + item: policyPackageConfig, success: true, }); } @@ -245,7 +245,7 @@ describe('Policy Details', () => { // API should be called await asyncActions; - expect(http.put.mock.calls[0][0]).toEqual(`/api/ingest_manager/datasources/1`); + expect(http.put.mock.calls[0][0]).toEqual(`/api/ingest_manager/package_configs/1`); policyView.update(); // Toast notification should be shown @@ -257,7 +257,7 @@ describe('Policy Details', () => { }); }); it('should show an error notification toast if update fails', async () => { - policyDatasource.id = 'invalid'; + policyPackageConfig.id = 'invalid'; modalConfirmButton.simulate('click'); await asyncActions; diff --git a/x-pack/plugins/security_solution/public/management/pages/policy/view/policy_list.tsx b/x-pack/plugins/security_solution/public/management/pages/policy/view/policy_list.tsx index 8a760334c53af..800061a6a1533 100644 --- a/x-pack/plugins/security_solution/public/management/pages/policy/view/policy_list.tsx +++ b/x-pack/plugins/security_solution/public/management/pages/policy/view/policy_list.tsx @@ -45,7 +45,7 @@ import { SecurityPageName } from '../../../../app/types'; import { useFormatUrl } from '../../../../common/components/link_to'; import { getPolicyDetailPath, getPoliciesPath } from '../../../common/routing'; import { useNavigateToAppEventHandler } from '../../../../common/hooks/endpoint/use_navigate_to_app_event_handler'; -import { CreateDatasourceRouteState } from '../../../../../../ingest_manager/public'; +import { CreatePackageConfigRouteState } from '../../../../../../ingest_manager/public'; interface TableChangeCallbackArguments { page: { index: number; size: number }; @@ -141,16 +141,16 @@ export const PolicyList = React.memo(() => { endpointPackageVersion, } = usePolicyListSelector(selector); - const handleCreatePolicyClick = useNavigateToAppEventHandler( + const handleCreatePolicyClick = useNavigateToAppEventHandler( 'ingestManager', { // We redirect to Ingest's Integaration page if we can't get the package version, and - // to the Integration Endpoint Package Add Datasource if we have package information. + // to the Integration Endpoint Package Add Integration if we have package information. // Also, // We pass along soem state information so that the Ingest page can change the behaviour // of the cancel and submit buttons and redirect the user back to endpoint policy path: `#/integrations${ - endpointPackageVersion ? `/endpoint-${endpointPackageVersion}/add-datasource` : '' + endpointPackageVersion ? `/endpoint-${endpointPackageVersion}/add-integration` : '' }`, state: { onCancelNavigateTo: ['securitySolution:management', { path: getPoliciesPath() }], diff --git a/x-pack/plugins/security_solution/public/plugin.tsx b/x-pack/plugins/security_solution/public/plugin.tsx index d7e29a466cbf2..c1114dbf096c1 100644 --- a/x-pack/plugins/security_solution/public/plugin.tsx +++ b/x-pack/plugins/security_solution/public/plugin.tsx @@ -45,7 +45,7 @@ import { APP_ENDPOINT_ALERTS_PATH, APP_PATH, } from '../common/constants'; -import { ConfigureEndpointDatasource } from './management/pages/policy/view/ingest_manager_integration/configure_datasource'; +import { ConfigureEndpointPackageConfig } from './management/pages/policy/view/ingest_manager_integration/configure_package_config'; import { State, createStore, createInitialState } from './common/store'; import { SecurityPageName } from './app/types'; @@ -348,7 +348,10 @@ export class Plugin implements IPlugin; - /** The Ingest datasource created and added to agent configuration. + /** The Ingest Package Config created and added to agent configuration. * This is where Endpoint Policy is stored. */ - datasource: Immutable; + packageConfig: Immutable; /** * Information about the endpoint package */ packageInfo: Immutable; - /** will clean up (delete) the objects created (agent config + datasource) */ + /** will clean up (delete) the objects created (agent config + Package Config) */ cleanup: () => Promise; } @@ -127,7 +126,7 @@ export function EndpointPolicyTestResourcesProvider({ getService }: FtrProviderC }, /** - * Creates an Ingest Agent Configuration and adds to it the Endpoint Datasource that + * Creates an Ingest Agent Configuration and adds to it the Endpoint Package Config that * stores the Policy configuration data */ async createPolicy(): Promise { @@ -152,10 +151,10 @@ export function EndpointPolicyTestResourcesProvider({ getService }: FtrProviderC // Retrieve the Endpoint package information const endpointPackageInfo = await retrieveEndpointPackageInfo(); - // create datasource and associated it to agent config - let datasource: CreateDatasourceResponse['item']; + // create Package Config and associated it to agent config + let packageConfig: CreatePackageConfigResponse['item']; try { - const newDatasourceData: CreateDatasourceRequest['body'] = { + const newPackageConfigData: CreatePackageConfigRequest['body'] = { name: 'Protect East Coast', description: 'Protect the worlds data - but in the East Coast', config_id: agentConfig!.id, @@ -180,33 +179,35 @@ export function EndpointPolicyTestResourcesProvider({ getService }: FtrProviderC version: endpointPackageInfo?.version ?? '', }, }; - const { body: createResponse }: { body: CreateDatasourceResponse } = await supertest - .post(INGEST_API_DATASOURCES) + const { + body: createResponse, + }: { body: CreatePackageConfigResponse } = await supertest + .post(INGEST_API_PACKAGE_CONFIGS) .set('kbn-xsrf', 'xxx') - .send(newDatasourceData) + .send(newPackageConfigData) .expect(200); - datasource = createResponse.item; + packageConfig = createResponse.item; } catch (error) { - return logSupertestApiErrorAndThrow(`Unable to create Datasource via Ingest!`, error); + return logSupertestApiErrorAndThrow(`Unable to create Package Config via Ingest!`, error); } return { agentConfig, - datasource, + packageConfig, packageInfo: endpointPackageInfo!, async cleanup() { - // Delete Datasource + // Delete Package Config try { - const deleteDatasourceData: DeleteDatasourcesRequest['body'] = { - datasourceIds: [datasource.id], + const deletePackageConfigData: DeletePackageConfigsRequest['body'] = { + packageConfigIds: [packageConfig.id], }; await supertest - .post(INGEST_API_DATASOURCES_DELETE) + .post(INGEST_API_PACKAGE_CONFIGS_DELETE) .set('kbn-xsrf', 'xxx') - .send(deleteDatasourceData) + .send(deletePackageConfigData) .expect(200); } catch (error) { - logSupertestApiErrorAndThrow('Unable to delete Datasource via Ingest!', error); + logSupertestApiErrorAndThrow('Unable to delete Package Config via Ingest!', error); } // Delete Agent config @@ -227,45 +228,47 @@ export function EndpointPolicyTestResourcesProvider({ getService }: FtrProviderC }, /** - * Deletes a policy (Datasource) by using the policy name + * Deletes a policy (Package Config) by using the policy name * @param name */ async deletePolicyByName(name: string) { - let datasourceList: GetDatasourcesResponse['items']; + let packageConfigList: GetPackageConfigsResponse['items']; try { - const { body: datasourcesResponse }: { body: GetDatasourcesResponse } = await supertest - .get(INGEST_API_DATASOURCES) + const { + body: packageConfigsResponse, + }: { body: GetPackageConfigsResponse } = await supertest + .get(INGEST_API_PACKAGE_CONFIGS) .set('kbn-xsrf', 'xxx') - .query({ kuery: `${DATASOURCE_SAVED_OBJECT_TYPE}.name: ${name}` }) + .query({ kuery: `${PACKAGE_CONFIG_SAVED_OBJECT_TYPE}.name: ${name}` }) .send() .expect(200); - datasourceList = datasourcesResponse.items; + packageConfigList = packageConfigsResponse.items; } catch (error) { return logSupertestApiErrorAndThrow( - `Unable to get list of datasources with name=${name}`, + `Unable to get list of Package Configs with name=${name}`, error ); } - if (datasourceList.length === 0) { + if (packageConfigList.length === 0) { throw new Error(`Policy named '${name}' was not found!`); } - if (datasourceList.length > 1) { - throw new Error(`Found ${datasourceList.length} Policies - was expecting only one!`); + if (packageConfigList.length > 1) { + throw new Error(`Found ${packageConfigList.length} Policies - was expecting only one!`); } try { - const deleteDatasourceData: DeleteDatasourcesRequest['body'] = { - datasourceIds: [datasourceList[0].id], + const deletePackageConfigData: DeletePackageConfigsRequest['body'] = { + packageConfigIds: [packageConfigList[0].id], }; await supertest - .post(INGEST_API_DATASOURCES_DELETE) + .post(INGEST_API_PACKAGE_CONFIGS_DELETE) .set('kbn-xsrf', 'xxx') - .send(deleteDatasourceData) + .send(deletePackageConfigData) .expect(200); } catch (error) { - logSupertestApiErrorAndThrow('Unable to delete Datasource via Ingest!', error); + logSupertestApiErrorAndThrow('Unable to delete Package Config via Ingest!', error); } }, }; From a985661397d4321422e08168eaf838e0b3ca44df Mon Sep 17 00:00:00 2001 From: Jen Huang Date: Mon, 29 Jun 2020 13:13:53 -0700 Subject: [PATCH 11/16] Minor copy adjustments, fix i18n check --- .../create_package_config_page/step_define_package_config.tsx | 2 +- .../sections/overview/components/configuration_section.tsx | 2 +- x-pack/plugins/translations/translations/ja-JP.json | 1 - x-pack/plugins/translations/translations/zh-CN.json | 1 - 4 files changed, 2 insertions(+), 4 deletions(-) diff --git a/x-pack/plugins/ingest_manager/public/applications/ingest_manager/sections/agent_config/create_package_config_page/step_define_package_config.tsx b/x-pack/plugins/ingest_manager/public/applications/ingest_manager/sections/agent_config/create_package_config_page/step_define_package_config.tsx index 574813629e0b7..b2ffe62104eb1 100644 --- a/x-pack/plugins/ingest_manager/public/applications/ingest_manager/sections/agent_config/create_package_config_page/step_define_package_config.tsx +++ b/x-pack/plugins/ingest_manager/public/applications/ingest_manager/sections/agent_config/create_package_config_page/step_define_package_config.tsx @@ -83,7 +83,7 @@ export const StepDefinePackageConfig: React.FunctionComponent<{ label={ } > diff --git a/x-pack/plugins/ingest_manager/public/applications/ingest_manager/sections/overview/components/configuration_section.tsx b/x-pack/plugins/ingest_manager/public/applications/ingest_manager/sections/overview/components/configuration_section.tsx index 4879dde134378..ed4b3fc8e6a5d 100644 --- a/x-pack/plugins/ingest_manager/public/applications/ingest_manager/sections/overview/components/configuration_section.tsx +++ b/x-pack/plugins/ingest_manager/public/applications/ingest_manager/sections/overview/components/configuration_section.tsx @@ -64,7 +64,7 @@ export const OverviewConfigurationSection: React.FC<{ agentConfigs: AgentConfig[ diff --git a/x-pack/plugins/translations/translations/ja-JP.json b/x-pack/plugins/translations/translations/ja-JP.json index 530eaa968d61c..624c236f7361d 100644 --- a/x-pack/plugins/translations/translations/ja-JP.json +++ b/x-pack/plugins/translations/translations/ja-JP.json @@ -8169,7 +8169,6 @@ "xpack.ingestManager.configDetails.packageConfigsTable.streamsCountColumnTitle": "ストリーム", "xpack.ingestManager.configDetails.subTabs.packageConfigsTabText": "データソース", "xpack.ingestManager.configDetails.subTabs.settingsTabText": "設定", - "xpack.ingestManager.configDetails.summary.packageConfigs": "データソース", "xpack.ingestManager.configDetails.summary.lastUpdated": "最終更新日:", "xpack.ingestManager.configDetails.summary.revision": "リビジョン", "xpack.ingestManager.configDetails.summary.usedBy": "使用者", diff --git a/x-pack/plugins/translations/translations/zh-CN.json b/x-pack/plugins/translations/translations/zh-CN.json index 6ec373aaca444..b9e52cd847d76 100644 --- a/x-pack/plugins/translations/translations/zh-CN.json +++ b/x-pack/plugins/translations/translations/zh-CN.json @@ -8174,7 +8174,6 @@ "xpack.ingestManager.configDetails.packageConfigsTable.streamsCountColumnTitle": "流计数", "xpack.ingestManager.configDetails.subTabs.packageConfigsTabText": "数据源", "xpack.ingestManager.configDetails.subTabs.settingsTabText": "设置", - "xpack.ingestManager.configDetails.summary.packageConfigs": "数据源", "xpack.ingestManager.configDetails.summary.lastUpdated": "最后更新时间", "xpack.ingestManager.configDetails.summary.revision": "修订", "xpack.ingestManager.configDetails.summary.usedBy": "使用者", From 640c63bd5ceb6b2143b8deb777acc5cf228aed7d Mon Sep 17 00:00:00 2001 From: Jen Huang Date: Mon, 29 Jun 2020 13:28:40 -0700 Subject: [PATCH 12/16] Replace datasource references in tests and fixtures; remove unused `ingest/policies` es archiver data --- .../apis/ingest_manager/agent_config.ts | 2 +- .../es_archives/fleet/agents/data.json | 2 +- .../es_archives/fleet/agents/mappings.json | 6 +- .../es_archives/ingest/policies/data.json | 59 - .../es_archives/ingest/policies/mappings.json | 1545 ----------------- .../custom_rule_with_timeline/mappings.json | 6 +- .../apps/endpoint/policy_details.ts | 22 +- .../apps/endpoint/policy_list.ts | 28 +- .../page_objects/index.ts | 4 +- ...est_manager_create_package_config_page.ts} | 19 +- .../page_objects/policy_page.ts | 4 +- 11 files changed, 48 insertions(+), 1649 deletions(-) delete mode 100644 x-pack/test/functional/es_archives/ingest/policies/data.json delete mode 100644 x-pack/test/functional/es_archives/ingest/policies/mappings.json rename x-pack/test/security_solution_endpoint/page_objects/{ingest_manager_create_datasource_page.ts => ingest_manager_create_package_config_page.ts} (81%) diff --git a/x-pack/test/api_integration/apis/ingest_manager/agent_config.ts b/x-pack/test/api_integration/apis/ingest_manager/agent_config.ts index caa29561a1256..8bf3efbdaf501 100644 --- a/x-pack/test/api_integration/apis/ingest_manager/agent_config.ts +++ b/x-pack/test/api_integration/apis/ingest_manager/agent_config.ts @@ -69,7 +69,7 @@ export default function ({ getService }: FtrProviderContext) { monitoring_enabled: ['logs', 'metrics'], revision: 1, updated_by: 'elastic', - datasources: [], + package_configs: [], }); }); diff --git a/x-pack/test/functional/es_archives/fleet/agents/data.json b/x-pack/test/functional/es_archives/fleet/agents/data.json index 047f26a3f443c..9cbfb31771917 100644 --- a/x-pack/test/functional/es_archives/fleet/agents/data.json +++ b/x-pack/test/functional/es_archives/fleet/agents/data.json @@ -212,7 +212,7 @@ "namespace": "default", "description": "Config 1", "status": "active", - "datasources": [], + "package_configs": [], "is_default": true, "monitoring_enabled": [ "logs", diff --git a/x-pack/test/functional/es_archives/fleet/agents/mappings.json b/x-pack/test/functional/es_archives/fleet/agents/mappings.json index 15e5a5524107b..7bdcb35dae00a 100644 --- a/x-pack/test/functional/es_archives/fleet/agents/mappings.json +++ b/x-pack/test/functional/es_archives/fleet/agents/mappings.json @@ -28,7 +28,7 @@ "application_usage_transactional": "965839e75f809fefe04f92dc4d99722a", "action_task_params": "a9d49f184ee89641044be0ca2950fa3a", "fleet-agent-events": "3231653fafe4ef3196fe3b32ab774bf2", - "ingest-datasources": "2346514df03316001d56ed4c8d46fa94", + "ingest-package-configs": "2346514df03316001d56ed4c8d46fa94", "apm-indices": "9bb9b2bf1fa636ed8619cbab5ce6a1dd", "inventory-view": "5299b67717e96502c77babf1c16fd4d3", "upgrade-assistant-reindex-operation": "296a89039fc4260292be36b1b005d8f2", @@ -1799,7 +1799,7 @@ }, "ingest-agent-configs": { "properties": { - "datasources": { + "package_configs": { "type": "keyword" }, "description": { @@ -1834,7 +1834,7 @@ } } }, - "ingest-datasources": { + "ingest-package-configs": { "properties": { "config_id": { "type": "keyword" diff --git a/x-pack/test/functional/es_archives/ingest/policies/data.json b/x-pack/test/functional/es_archives/ingest/policies/data.json deleted file mode 100644 index 78cf18d501a3e..0000000000000 --- a/x-pack/test/functional/es_archives/ingest/policies/data.json +++ /dev/null @@ -1,59 +0,0 @@ -{ - "type": "doc", - "value": { - "index": ".kibana", - "id": "policies:1", - "source": { - "policies": { - "name": "Policy 1", - "description": "Amazing policy", - "status": "active", - "updated_on": "2019-09-20T17:35:09+0000", - "updated_by": "nchaulet" - }, - "type": "policies", - "references": [], - "updated_at": "2019-09-20T17:30:22.950Z" - } - } -} - -{ - "type": "doc", - "value": { - "index": ".kibana", - "id": "policies:2", - "source": { - "policies": { - "name": "Policy", - "description": "Amazing policy", - "status": "active", - "updated_on": "2019-09-20T17:35:09+0000", - "updated_by": "nchaulet" - }, - "type": "policies", - "references": [], - "updated_at": "2019-09-20T17:30:22.950Z" - } - } -} - -{ - "type": "doc", - "value": { - "index": ".kibana", - "id": "policies:3", - "source": { - "policies": { - "name": "Policy 3", - "description": "Amazing policy", - "status": "active", - "updated_on": "2019-09-20T17:35:09+0000", - "updated_by": "nchaulet" - }, - "type": "policies", - "references": [], - "updated_at": "2019-09-20T17:30:22.950Z" - } - } -} diff --git a/x-pack/test/functional/es_archives/ingest/policies/mappings.json b/x-pack/test/functional/es_archives/ingest/policies/mappings.json deleted file mode 100644 index 878d6aa58c225..0000000000000 --- a/x-pack/test/functional/es_archives/ingest/policies/mappings.json +++ /dev/null @@ -1,1545 +0,0 @@ -{ - "type": "index", - "value": { - "aliases": { - ".kibana": {} - }, - "index": ".kibana_1", - "mappings": { - "dynamic": "strict", - "_meta": { - "migrationMappingPropertyHashes": { - "ml-telemetry": "257fd1d4b4fdbb9cb4b8a3b27da201e9", - "server": "ec97f1c5da1a19609a60874e5af1100c", - "visualization": "52d7a13ad68a150c4525b292d23e12cc", - "references": "7997cf5a56cc02bdc9c93361bde732b0", - "graph-workspace": "cd7ba1330e6682e9cc00b78850874be1", - "siem-ui-timeline-note": "8874706eedc49059d4cf0f5094559084", - "policies": "1a096b98c98c2efebfdba77cefcfe54a", - "type": "2f4316de49999235636386fe51dc06c1", - "lens": "21c3ea0763beb1ecb0162529706b88c5", - "space": "c5ca8acafa0beaa4d08d014a97b6bc6b", - "infrastructure-ui-source": "ddc0ecb18383f6b26101a2fadb2dab0c", - "sample-data-telemetry": "7d3cfeb915303c9641c59681967ffeb4", - "search": "181661168bbadd1eff5902361e2a0d5c", - "updated_at": "00da57df13e94e9d98437d13ace4bfe0", - "canvas-workpad": "b0a1706d356228dbdcb4a17e6b9eb231", - "map": "23d7aa4a720d4938ccde3983f87bd58d", - "dashboard": "d00f614b29a80360e1190193fd333bab", - "apm-services-telemetry": "07ee1939fa4302c62ddc052ec03fed90", - "metrics-explorer-view": "53c5365793677328df0ccb6138bf3cdd", - "epm": "abf5b64aa599932bd181efc86dce14a7", - "siem-ui-timeline": "6485ab095be8d15246667b98a1a34295", - "agent_events": "8060c5567d33f6697164e1fd5c81b8ed", - "file-upload-telemetry": "0ed4d3e1983d1217a30982630897092e", - "query": "11aaeb7f5f7fa5bb43f25e18ce26e7d9", - "kql-telemetry": "d12a98a6f19a2d273696597547e064ee", - "ui-metric": "0d409297dc5ebe1e3a1da691c6ee32e3", - "url": "c7f66a0df8b1b52f17c28c4adb111105", - "apm-indices": "c69b68f3fe2bf27b4788d4191c1d6011", - "agents": "1c8e942384219bd899f381fd40e407d7", - "migrationVersion": "4a1746014a75ade3a714e1db5763276f", - "inventory-view": "84b320fd67209906333ffce261128462", - "enrollment_api_keys": "90e66b79e8e948e9c15434fdb3ae576e", - "upgrade-assistant-reindex-operation": "a53a20fe086b72c9a86da3cc12dad8a6", - "index-pattern": "66eccb05066c5a89924f48a9e9736499", - "canvas-element": "7390014e1091044523666d97247392fc", - "datasources": "2fed9e9883b9622cd59a73ee5550ef4f", - "maps-telemetry": "a4229f8b16a6820c6d724b7e0c1f729d", - "namespace": "2f4316de49999235636386fe51dc06c1", - "telemetry": "358ffaa88ba34a97d55af0933a117de4", - "siem-ui-timeline-pinned-event": "20638091112f0e14f0e443d512301c29", - "timelion-sheet": "9a2a2748877c7a7b582fef201ab1d4cf", - "config": "87aca8fdb053154f11383fce3dbf3edf", - "upgrade-assistant-telemetry": "56702cec857e0a9dacfb696655b4ff7b", - "lens-ui-telemetry": "509bfa5978586998e05f9e303c07a327" - } - }, - "properties": { - "agent_events": { - "properties": { - "agent_id": { - "type": "keyword" - }, - "data": { - "type": "text" - }, - "message": { - "type": "text" - }, - "payload": { - "type": "text" - }, - "subtype": { - "type": "keyword" - }, - "timestamp": { - "type": "date" - }, - "type": { - "type": "keyword" - } - } - }, - "agents": { - "properties": { - "access_api_key_id": { - "type": "keyword" - }, - "actions": { - "type": "nested", - "properties": { - "created_at": { - "type": "date" - }, - "data": { - "type": "text" - }, - "id": { - "type": "keyword" - }, - "sent_at": { - "type": "date" - }, - "type": { - "type": "keyword" - } - } - }, - "active": { - "type": "boolean" - }, - "enrolled_at": { - "type": "date" - }, - "last_checkin": { - "type": "date" - }, - "last_updated": { - "type": "date" - }, - "local_metadata": { - "type": "text" - }, - "config_id": { - "type": "keyword" - }, - "shared_id": { - "type": "keyword" - }, - "type": { - "type": "keyword" - }, - "updated_at": { - "type": "date" - }, - "user_provided_metadata": { - "type": "text" - }, - "version": { - "type": "keyword" - } - } - }, - "apm-indices": { - "properties": { - "apm_oss": { - "properties": { - "apmAgentConfigurationIndex": { - "type": "keyword" - }, - "errorIndices": { - "type": "keyword" - }, - "metricsIndices": { - "type": "keyword" - }, - "onboardingIndices": { - "type": "keyword" - }, - "sourcemapIndices": { - "type": "keyword" - }, - "spanIndices": { - "type": "keyword" - }, - "transactionIndices": { - "type": "keyword" - } - } - } - } - }, - "apm-services-telemetry": { - "properties": { - "has_any_services": { - "type": "boolean" - }, - "services_per_agent": { - "properties": { - "dotnet": { - "type": "long", - "null_value": 0 - }, - "go": { - "type": "long", - "null_value": 0 - }, - "java": { - "type": "long", - "null_value": 0 - }, - "js-base": { - "type": "long", - "null_value": 0 - }, - "nodejs": { - "type": "long", - "null_value": 0 - }, - "python": { - "type": "long", - "null_value": 0 - }, - "ruby": { - "type": "long", - "null_value": 0 - }, - "rum-js": { - "type": "long", - "null_value": 0 - } - } - } - } - }, - "canvas-element": { - "dynamic": "false", - "properties": { - "@created": { - "type": "date" - }, - "@timestamp": { - "type": "date" - }, - "content": { - "type": "text" - }, - "help": { - "type": "text" - }, - "image": { - "type": "text" - }, - "name": { - "type": "text", - "fields": { - "keyword": { - "type": "keyword" - } - } - } - } - }, - "canvas-workpad": { - "dynamic": "false", - "properties": { - "@created": { - "type": "date" - }, - "@timestamp": { - "type": "date" - }, - "name": { - "type": "text", - "fields": { - "keyword": { - "type": "keyword" - } - } - } - } - }, - "config": { - "dynamic": "true", - "properties": { - "buildNum": { - "type": "keyword" - } - } - }, - "dashboard": { - "properties": { - "description": { - "type": "text" - }, - "hits": { - "type": "integer" - }, - "kibanaSavedObjectMeta": { - "properties": { - "searchSourceJSON": { - "type": "text" - } - } - }, - "optionsJSON": { - "type": "text" - }, - "panelsJSON": { - "type": "text" - }, - "refreshInterval": { - "properties": { - "display": { - "type": "keyword" - }, - "pause": { - "type": "boolean" - }, - "section": { - "type": "integer" - }, - "value": { - "type": "integer" - } - } - }, - "timeFrom": { - "type": "keyword" - }, - "timeRestore": { - "type": "boolean" - }, - "timeTo": { - "type": "keyword" - }, - "title": { - "type": "text" - }, - "version": { - "type": "integer" - } - } - }, - "datasources": { - "properties": { - "id": { - "type": "keyword" - }, - "name": { - "type": "keyword" - }, - "package": { - "properties": { - "assets": { - "properties": { - "id": { - "type": "keyword" - }, - "type": { - "type": "keyword" - } - } - }, - "description": { - "type": "keyword" - }, - "name": { - "type": "keyword" - }, - "title": { - "type": "keyword" - }, - "version": { - "type": "keyword" - } - } - }, - "read_alias": { - "type": "keyword" - }, - "streams": { - "properties": { - "config": { - "type": "flattened" - }, - "id": { - "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" - } - } - }, - "output_id": { - "type": "keyword" - }, - "processors": { - "type": "keyword" - } - } - } - } - }, - "enrollment_api_keys": { - "properties": { - "active": { - "type": "boolean" - }, - "api_key": { - "type": "binary" - }, - "api_key_id": { - "type": "keyword" - }, - "created_at": { - "type": "date" - }, - "enrollment_rules": { - "type": "nested", - "properties": { - "created_at": { - "type": "date" - }, - "id": { - "type": "keyword" - }, - "ip_ranges": { - "type": "keyword" - }, - "types": { - "type": "keyword" - }, - "updated_at": { - "type": "date" - }, - "window_duration": { - "type": "nested", - "properties": { - "from": { - "type": "date" - }, - "to": { - "type": "date" - } - } - } - } - }, - "expire_at": { - "type": "date" - }, - "name": { - "type": "keyword" - }, - "config_id": { - "type": "keyword" - }, - "type": { - "type": "keyword" - }, - "updated_at": { - "type": "date" - } - } - }, - "epm": { - "properties": { - "installed": { - "type": "nested", - "properties": { - "id": { - "type": "keyword" - }, - "type": { - "type": "keyword" - } - } - } - } - }, - "file-upload-telemetry": { - "properties": { - "filesUploadedTotalCount": { - "type": "long" - } - } - }, - "graph-workspace": { - "properties": { - "description": { - "type": "text" - }, - "kibanaSavedObjectMeta": { - "properties": { - "searchSourceJSON": { - "type": "text" - } - } - }, - "numLinks": { - "type": "integer" - }, - "numVertices": { - "type": "integer" - }, - "title": { - "type": "text" - }, - "version": { - "type": "integer" - }, - "wsState": { - "type": "text" - } - } - }, - "index-pattern": { - "properties": { - "fieldFormatMap": { - "type": "text" - }, - "fields": { - "type": "text" - }, - "intervalName": { - "type": "keyword" - }, - "notExpandable": { - "type": "boolean" - }, - "sourceFilters": { - "type": "text" - }, - "timeFieldName": { - "type": "keyword" - }, - "title": { - "type": "text" - }, - "type": { - "type": "keyword" - }, - "typeMeta": { - "type": "keyword" - } - } - }, - "infrastructure-ui-source": { - "properties": { - "description": { - "type": "text" - }, - "fields": { - "properties": { - "container": { - "type": "keyword" - }, - "host": { - "type": "keyword" - }, - "pod": { - "type": "keyword" - }, - "tiebreaker": { - "type": "keyword" - }, - "timestamp": { - "type": "keyword" - } - } - }, - "logAlias": { - "type": "keyword" - }, - "logColumns": { - "type": "nested", - "properties": { - "fieldColumn": { - "properties": { - "field": { - "type": "keyword" - }, - "id": { - "type": "keyword" - } - } - }, - "messageColumn": { - "properties": { - "id": { - "type": "keyword" - } - } - }, - "timestampColumn": { - "properties": { - "id": { - "type": "keyword" - } - } - } - } - }, - "metricAlias": { - "type": "keyword" - }, - "name": { - "type": "text" - } - } - }, - "inventory-view": { - "properties": { - "autoBounds": { - "type": "boolean" - }, - "autoReload": { - "type": "boolean" - }, - "boundsOverride": { - "properties": { - "max": { - "type": "integer" - }, - "min": { - "type": "integer" - } - } - }, - "customOptions": { - "type": "nested", - "properties": { - "field": { - "type": "keyword" - }, - "text": { - "type": "keyword" - } - } - }, - "filterQuery": { - "properties": { - "expression": { - "type": "keyword" - }, - "kind": { - "type": "keyword" - } - } - }, - "groupBy": { - "type": "nested", - "properties": { - "field": { - "type": "keyword" - }, - "label": { - "type": "keyword" - } - } - }, - "metric": { - "properties": { - "type": { - "type": "keyword" - } - } - }, - "name": { - "type": "keyword" - }, - "nodeType": { - "type": "keyword" - }, - "time": { - "type": "integer" - }, - "view": { - "type": "keyword" - } - } - }, - "kql-telemetry": { - "properties": { - "optInCount": { - "type": "long" - }, - "optOutCount": { - "type": "long" - } - } - }, - "lens": { - "properties": { - "expression": { - "type": "keyword", - "index": false - }, - "state": { - "type": "flattened" - }, - "title": { - "type": "text" - }, - "visualizationType": { - "type": "keyword" - } - } - }, - "lens-ui-telemetry": { - "properties": { - "count": { - "type": "integer" - }, - "date": { - "type": "date" - }, - "name": { - "type": "keyword" - }, - "type": { - "type": "keyword" - } - } - }, - "map": { - "properties": { - "bounds": { - "type": "geo_shape" - }, - "description": { - "type": "text" - }, - "layerListJSON": { - "type": "text" - }, - "mapStateJSON": { - "type": "text" - }, - "title": { - "type": "text" - }, - "uiStateJSON": { - "type": "text" - }, - "version": { - "type": "integer" - } - } - }, - "maps-telemetry": { - "properties": { - "attributesPerMap": { - "properties": { - "dataSourcesCount": { - "properties": { - "avg": { - "type": "long" - }, - "max": { - "type": "long" - }, - "min": { - "type": "long" - } - } - }, - "emsVectorLayersCount": { - "type": "object", - "dynamic": "true" - }, - "layerTypesCount": { - "type": "object", - "dynamic": "true" - }, - "layersCount": { - "properties": { - "avg": { - "type": "long" - }, - "max": { - "type": "long" - }, - "min": { - "type": "long" - } - } - } - } - }, - "mapsTotalCount": { - "type": "long" - }, - "timeCaptured": { - "type": "date" - } - } - }, - "metrics-explorer-view": { - "properties": { - "chartOptions": { - "properties": { - "stack": { - "type": "boolean" - }, - "type": { - "type": "keyword" - }, - "yAxisMode": { - "type": "keyword" - } - } - }, - "currentTimerange": { - "properties": { - "from": { - "type": "keyword" - }, - "interval": { - "type": "keyword" - }, - "to": { - "type": "keyword" - } - } - }, - "name": { - "type": "keyword" - }, - "options": { - "properties": { - "aggregation": { - "type": "keyword" - }, - "filterQuery": { - "type": "keyword" - }, - "groupBy": { - "type": "keyword" - }, - "limit": { - "type": "integer" - }, - "metrics": { - "type": "nested", - "properties": { - "aggregation": { - "type": "keyword" - }, - "color": { - "type": "keyword" - }, - "field": { - "type": "keyword" - }, - "label": { - "type": "keyword" - } - } - } - } - } - } - }, - "migrationVersion": { - "dynamic": "true", - "properties": { - "space": { - "type": "text", - "fields": { - "keyword": { - "type": "keyword", - "ignore_above": 256 - } - } - } - } - }, - "ml-telemetry": { - "properties": { - "file_data_visualizer": { - "properties": { - "index_creation_count": { - "type": "long" - } - } - } - } - }, - "namespace": { - "type": "keyword" - }, - "policies": { - "properties": { - "datasources": { - "type": "keyword" - }, - "description": { - "type": "text" - }, - "id": { - "type": "keyword" - }, - "label": { - "type": "keyword" - }, - "name": { - "type": "text" - }, - "status": { - "type": "keyword" - }, - "updated_by": { - "type": "keyword" - }, - "updated_on": { - "type": "keyword" - } - } - }, - "query": { - "properties": { - "description": { - "type": "text" - }, - "filters": { - "type": "object", - "enabled": false - }, - "query": { - "properties": { - "language": { - "type": "keyword" - }, - "query": { - "type": "keyword", - "index": false - } - } - }, - "timefilter": { - "type": "object", - "enabled": false - }, - "title": { - "type": "text" - } - } - }, - "references": { - "type": "nested", - "properties": { - "id": { - "type": "keyword" - }, - "name": { - "type": "keyword" - }, - "type": { - "type": "keyword" - } - } - }, - "sample-data-telemetry": { - "properties": { - "installCount": { - "type": "long" - }, - "unInstallCount": { - "type": "long" - } - } - }, - "search": { - "properties": { - "columns": { - "type": "keyword" - }, - "description": { - "type": "text" - }, - "hits": { - "type": "integer" - }, - "kibanaSavedObjectMeta": { - "properties": { - "searchSourceJSON": { - "type": "text" - } - } - }, - "sort": { - "type": "keyword" - }, - "title": { - "type": "text" - }, - "version": { - "type": "integer" - } - } - }, - "server": { - "properties": { - "uuid": { - "type": "keyword" - } - } - }, - "siem-ui-timeline": { - "properties": { - "columns": { - "properties": { - "aggregatable": { - "type": "boolean" - }, - "category": { - "type": "keyword" - }, - "columnHeaderType": { - "type": "keyword" - }, - "description": { - "type": "text" - }, - "example": { - "type": "text" - }, - "id": { - "type": "keyword" - }, - "indexes": { - "type": "keyword" - }, - "name": { - "type": "text" - }, - "placeholder": { - "type": "text" - }, - "searchable": { - "type": "boolean" - }, - "type": { - "type": "keyword" - } - } - }, - "created": { - "type": "date" - }, - "createdBy": { - "type": "text" - }, - "dataProviders": { - "properties": { - "and": { - "properties": { - "enabled": { - "type": "boolean" - }, - "excluded": { - "type": "boolean" - }, - "id": { - "type": "keyword" - }, - "kqlQuery": { - "type": "text" - }, - "name": { - "type": "text" - }, - "queryMatch": { - "properties": { - "displayField": { - "type": "text" - }, - "displayValue": { - "type": "text" - }, - "field": { - "type": "text" - }, - "operator": { - "type": "text" - }, - "value": { - "type": "text" - } - } - } - } - }, - "enabled": { - "type": "boolean" - }, - "excluded": { - "type": "boolean" - }, - "id": { - "type": "keyword" - }, - "kqlQuery": { - "type": "text" - }, - "name": { - "type": "text" - }, - "queryMatch": { - "properties": { - "displayField": { - "type": "text" - }, - "displayValue": { - "type": "text" - }, - "field": { - "type": "text" - }, - "operator": { - "type": "text" - }, - "value": { - "type": "text" - } - } - } - } - }, - "dateRange": { - "properties": { - "end": { - "type": "date" - }, - "start": { - "type": "date" - } - } - }, - "description": { - "type": "text" - }, - "favorite": { - "properties": { - "favoriteDate": { - "type": "date" - }, - "fullName": { - "type": "text" - }, - "keySearch": { - "type": "text" - }, - "userName": { - "type": "text" - } - } - }, - "filters": { - "properties": { - "exists": { - "type": "text" - }, - "match_all": { - "type": "text" - }, - "meta": { - "properties": { - "alias": { - "type": "text" - }, - "controlledBy": { - "type": "text" - }, - "disabled": { - "type": "boolean" - }, - "field": { - "type": "text" - }, - "formattedValue": { - "type": "text" - }, - "index": { - "type": "keyword" - }, - "key": { - "type": "keyword" - }, - "negate": { - "type": "boolean" - }, - "params": { - "type": "text" - }, - "type": { - "type": "keyword" - }, - "value": { - "type": "text" - } - } - }, - "missing": { - "type": "text" - }, - "query": { - "type": "text" - }, - "range": { - "type": "text" - }, - "script": { - "type": "text" - } - } - }, - "kqlMode": { - "type": "keyword" - }, - "kqlQuery": { - "properties": { - "filterQuery": { - "properties": { - "kuery": { - "properties": { - "expression": { - "type": "text" - }, - "kind": { - "type": "keyword" - } - } - }, - "serializedQuery": { - "type": "text" - } - } - } - } - }, - "savedQueryId": { - "type": "keyword" - }, - "sort": { - "properties": { - "columnId": { - "type": "keyword" - }, - "sortDirection": { - "type": "keyword" - } - } - }, - "title": { - "type": "text" - }, - "updated": { - "type": "date" - }, - "updatedBy": { - "type": "text" - } - } - }, - "siem-ui-timeline-note": { - "properties": { - "created": { - "type": "date" - }, - "createdBy": { - "type": "text" - }, - "eventId": { - "type": "keyword" - }, - "note": { - "type": "text" - }, - "timelineId": { - "type": "keyword" - }, - "updated": { - "type": "date" - }, - "updatedBy": { - "type": "text" - } - } - }, - "siem-ui-timeline-pinned-event": { - "properties": { - "created": { - "type": "date" - }, - "createdBy": { - "type": "text" - }, - "eventId": { - "type": "keyword" - }, - "timelineId": { - "type": "keyword" - }, - "updated": { - "type": "date" - }, - "updatedBy": { - "type": "text" - } - } - }, - "space": { - "properties": { - "_reserved": { - "type": "boolean" - }, - "color": { - "type": "keyword" - }, - "description": { - "type": "text" - }, - "disabledFeatures": { - "type": "keyword" - }, - "imageUrl": { - "type": "text", - "index": false - }, - "initials": { - "type": "keyword" - }, - "name": { - "type": "text", - "fields": { - "keyword": { - "type": "keyword", - "ignore_above": 2048 - } - } - } - } - }, - "telemetry": { - "properties": { - "enabled": { - "type": "boolean" - }, - "lastReported": { - "type": "date" - }, - "lastVersionChecked": { - "type": "keyword", - "ignore_above": 256 - }, - "sendUsageFrom": { - "type": "keyword", - "ignore_above": 256 - }, - "userHasSeenNotice": { - "type": "boolean" - } - } - }, - "timelion-sheet": { - "properties": { - "description": { - "type": "text" - }, - "hits": { - "type": "integer" - }, - "kibanaSavedObjectMeta": { - "properties": { - "searchSourceJSON": { - "type": "text" - } - } - }, - "timelion_chart_height": { - "type": "integer" - }, - "timelion_columns": { - "type": "integer" - }, - "timelion_interval": { - "type": "keyword" - }, - "timelion_other_interval": { - "type": "keyword" - }, - "timelion_rows": { - "type": "integer" - }, - "timelion_sheet": { - "type": "text" - }, - "title": { - "type": "text" - }, - "version": { - "type": "integer" - } - } - }, - "type": { - "type": "keyword" - }, - "ui-metric": { - "properties": { - "count": { - "type": "integer" - } - } - }, - "updated_at": { - "type": "date" - }, - "upgrade-assistant-reindex-operation": { - "dynamic": "true", - "properties": { - "indexName": { - "type": "keyword" - }, - "status": { - "type": "integer" - } - } - }, - "upgrade-assistant-telemetry": { - "properties": { - "features": { - "properties": { - "deprecation_logging": { - "properties": { - "enabled": { - "type": "boolean", - "null_value": true - } - } - } - } - }, - "ui_open": { - "properties": { - "cluster": { - "type": "long", - "null_value": 0 - }, - "indices": { - "type": "long", - "null_value": 0 - }, - "overview": { - "type": "long", - "null_value": 0 - } - } - }, - "ui_reindex": { - "properties": { - "close": { - "type": "long", - "null_value": 0 - }, - "open": { - "type": "long", - "null_value": 0 - }, - "start": { - "type": "long", - "null_value": 0 - }, - "stop": { - "type": "long", - "null_value": 0 - } - } - } - } - }, - "url": { - "properties": { - "accessCount": { - "type": "long" - }, - "accessDate": { - "type": "date" - }, - "createDate": { - "type": "date" - }, - "url": { - "type": "text", - "fields": { - "keyword": { - "type": "keyword", - "ignore_above": 2048 - } - } - } - } - }, - "visualization": { - "properties": { - "description": { - "type": "text" - }, - "kibanaSavedObjectMeta": { - "properties": { - "searchSourceJSON": { - "type": "text" - } - } - }, - "savedSearchRefName": { - "type": "keyword" - }, - "title": { - "type": "text" - }, - "uiStateJSON": { - "type": "text" - }, - "version": { - "type": "integer" - }, - "visState": { - "type": "text" - } - } - } - } - }, - "settings": { - "index": { - "number_of_replicas": "0", - "number_of_shards": "1" - } - } - } -} diff --git a/x-pack/test/security_solution_cypress/es_archives/custom_rule_with_timeline/mappings.json b/x-pack/test/security_solution_cypress/es_archives/custom_rule_with_timeline/mappings.json index d01e6344bcfaf..693878a88f899 100644 --- a/x-pack/test/security_solution_cypress/es_archives/custom_rule_with_timeline/mappings.json +++ b/x-pack/test/security_solution_cypress/es_archives/custom_rule_with_timeline/mappings.json @@ -34,7 +34,7 @@ "index-pattern": "66eccb05066c5a89924f48a9e9736499", "infrastructure-ui-source": "ddc0ecb18383f6b26101a2fadb2dab0c", "ingest-agent-configs": "d9a5cbdce8e937f674a7b376c47a34a1", - "ingest-datasources": "c0fe6347b0eebcbf421841669e3acd31", + "ingest-package-configs": "c0fe6347b0eebcbf421841669e3acd31", "ingest-outputs": "0e57221778a7153c8292edf154099036", "ingest_manager_settings": "c5b0749b4ab03c582efd4c14cb8f132c", "inventory-view": "88fc7e12fd1b45b6f0787323ce4f18d2", @@ -2103,7 +2103,7 @@ } } }, - "ingest-datasources": { + "ingest-package-configs": { "properties": { "config_id": { "type": "keyword" @@ -2606,7 +2606,7 @@ }, "type": "text" }, - "ingest-datasources": { + "ingest-package-configs": { "fields": { "keyword": { "ignore_above": 256, diff --git a/x-pack/test/security_solution_endpoint/apps/endpoint/policy_details.ts b/x-pack/test/security_solution_endpoint/apps/endpoint/policy_details.ts index f0e47c6886601..c5f75ece13d19 100644 --- a/x-pack/test/security_solution_endpoint/apps/endpoint/policy_details.ts +++ b/x-pack/test/security_solution_endpoint/apps/endpoint/policy_details.ts @@ -14,7 +14,7 @@ export default function ({ getPageObjects, getService }: FtrProviderContext) { 'endpoint', 'policy', 'endpointPageUtils', - 'ingestManagerCreateDatasource', + 'ingestManagerCreatePackageConfig', ]); const testSubjects = getService('testSubjects'); const policyTestResources = getService('policyTestResources'); @@ -27,7 +27,7 @@ export default function ({ getPageObjects, getService }: FtrProviderContext) { await pageObjects.policy.navigateToPolicyDetails('invalid-id'); await testSubjects.existOrFail('policyDetailsIdNotFoundMessage'); expect(await testSubjects.getVisibleText('policyDetailsIdNotFoundMessage')).to.equal( - 'Saved object [ingest-datasources/invalid-id] not found' + 'Saved object [ingest-package-configs/invalid-id] not found' ); }); }); @@ -37,7 +37,7 @@ export default function ({ getPageObjects, getService }: FtrProviderContext) { before(async () => { policyInfo = await policyTestResources.createPolicy(); - await pageObjects.policy.navigateToPolicyDetails(policyInfo.datasource.id); + await pageObjects.policy.navigateToPolicyDetails(policyInfo.package_config.id); }); after(async () => { @@ -48,7 +48,7 @@ export default function ({ getPageObjects, getService }: FtrProviderContext) { it('should display policy view', async () => { expect(await testSubjects.getVisibleText('pageViewHeaderLeftTitle')).to.equal( - policyInfo.datasource.name + policyInfo.package_config.name ); }); }); @@ -58,7 +58,7 @@ export default function ({ getPageObjects, getService }: FtrProviderContext) { beforeEach(async () => { policyInfo = await policyTestResources.createPolicy(); - await pageObjects.policy.navigateToPolicyDetails(policyInfo.datasource.id); + await pageObjects.policy.navigateToPolicyDetails(policyInfo.package_config.id); }); afterEach(async () => { @@ -73,7 +73,7 @@ export default function ({ getPageObjects, getService }: FtrProviderContext) { await testSubjects.existOrFail('policyDetailsSuccessMessage'); expect(await testSubjects.getVisibleText('policyDetailsSuccessMessage')).to.equal( - `Policy ${policyInfo.datasource.name} has been updated.` + `Policy ${policyInfo.package_config.name} has been updated.` ); }); it('should persist update on the screen', async () => { @@ -82,7 +82,7 @@ export default function ({ getPageObjects, getService }: FtrProviderContext) { await testSubjects.existOrFail('policyDetailsSuccessMessage'); await pageObjects.policy.navigateToPolicyList(); - await pageObjects.policy.navigateToPolicyDetails(policyInfo.datasource.id); + await pageObjects.policy.navigateToPolicyDetails(policyInfo.package_config.id); expect(await (await testSubjects.find('policyWindowsEvent_process')).isSelected()).to.equal( false @@ -107,7 +107,7 @@ export default function ({ getPageObjects, getService }: FtrProviderContext) { expect(agentFullConfig).to.eql({ inputs: [ { - id: policyInfo.datasource.id, + id: policyInfo.package_config.id, dataset: { namespace: 'default' }, name: 'Protect East Coast', meta: { @@ -194,14 +194,14 @@ export default function ({ getPageObjects, getService }: FtrProviderContext) { }); }); - describe('when on Ingest Configurations Edit Datasource page', async () => { + describe('when on Ingest Configurations Edit Package Config page', async () => { let policyInfo: PolicyTestResourceInfo; beforeEach(async () => { // Create a policy and navigate to Ingest app policyInfo = await policyTestResources.createPolicy(); - await pageObjects.ingestManagerCreateDatasource.navigateToAgentConfigEditDatasource( + await pageObjects.ingestManagerCreatePackageConfig.navigateToAgentConfigEditPackageConfig( policyInfo.agentConfig.id, - policyInfo.datasource.id + policyInfo.package_config.id ); }); afterEach(async () => { diff --git a/x-pack/test/security_solution_endpoint/apps/endpoint/policy_list.ts b/x-pack/test/security_solution_endpoint/apps/endpoint/policy_list.ts index 941a100416740..90f0901bbb448 100644 --- a/x-pack/test/security_solution_endpoint/apps/endpoint/policy_list.ts +++ b/x-pack/test/security_solution_endpoint/apps/endpoint/policy_list.ts @@ -13,7 +13,7 @@ export default function ({ getPageObjects, getService }: FtrProviderContext) { 'endpoint', 'policy', 'endpointPageUtils', - 'ingestManagerCreateDatasource', + 'ingestManagerCreatePackageConfig', ]); const testSubjects = getService('testSubjects'); const policyTestResources = getService('policyTestResources'); @@ -78,7 +78,7 @@ export default function ({ getPageObjects, getService }: FtrProviderContext) { 'Protect East Coastrev. 1', 'elastic', 'elastic', - `${policyInfo.datasource.package?.title} v${policyInfo.datasource.package?.version}`, + `${policyInfo.package_config.package?.title} v${policyInfo.package_config.package?.version}`, '', ]); [policyRow[2], policyRow[4]].forEach((relativeDate) => { @@ -111,42 +111,42 @@ export default function ({ getPageObjects, getService }: FtrProviderContext) { await (await pageObjects.policy.findHeaderCreateNewButton()).click(); }); - it('should redirect to ingest management integrations add datasource', async () => { - await pageObjects.ingestManagerCreateDatasource.ensureOnCreatePageOrFail(); + it('should redirect to ingest management integrations add package config', async () => { + await pageObjects.ingestManagerCreatePackageConfig.ensureOnCreatePageOrFail(); }); it('should redirect user back to Policy List if Cancel button is clicked', async () => { - await (await pageObjects.ingestManagerCreateDatasource.findCancelButton()).click(); + await (await pageObjects.ingestManagerCreatePackageConfig.findCancelButton()).click(); await pageObjects.policy.ensureIsOnPolicyPage(); }); it('should redirect user back to Policy List if Back link is clicked', async () => { - await (await pageObjects.ingestManagerCreateDatasource.findBackLink()).click(); + await (await pageObjects.ingestManagerCreatePackageConfig.findBackLink()).click(); await pageObjects.policy.ensureIsOnPolicyPage(); }); it('should display custom endpoint configuration message', async () => { - await pageObjects.ingestManagerCreateDatasource.selectAgentConfig(); - const endpointConfig = await pageObjects.policy.findDatasourceEndpointCustomConfiguration(); + await pageObjects.ingestManagerCreatePackageConfig.selectAgentConfig(); + const endpointConfig = await pageObjects.policy.findPackageConfigEndpointCustomConfiguration(); expect(endpointConfig).not.to.be(undefined); }); it('should redirect user back to Policy List after a successful save', async () => { const newPolicyName = `endpoint policy ${Date.now()}`; - await pageObjects.ingestManagerCreateDatasource.selectAgentConfig(); - await pageObjects.ingestManagerCreateDatasource.setDatasourceName(newPolicyName); - await (await pageObjects.ingestManagerCreateDatasource.findDSaveButton()).click(); - await pageObjects.ingestManagerCreateDatasource.waitForSaveSuccessNotification(); + await pageObjects.ingestManagerCreatePackageConfig.selectAgentConfig(); + await pageObjects.ingestManagerCreatePackageConfig.setPackageConfigName(newPolicyName); + await (await pageObjects.ingestManagerCreatePackageConfig.findDSaveButton()).click(); + await pageObjects.ingestManagerCreatePackageConfig.waitForSaveSuccessNotification(); await pageObjects.policy.ensureIsOnPolicyPage(); await policyTestResources.deletePolicyByName(newPolicyName); }); }); describe('and user clicks on page header create button', () => { - it('should direct users to the ingest management integrations add datasource', async () => { + it('should direct users to the ingest management integrations add package config', async () => { await pageObjects.policy.navigateToPolicyList(); await (await pageObjects.policy.findOnboardingStartButton()).click(); - await pageObjects.ingestManagerCreateDatasource.ensureOnCreatePageOrFail(); + await pageObjects.ingestManagerCreatePackageConfig.ensureOnCreatePageOrFail(); }); }); }); diff --git a/x-pack/test/security_solution_endpoint/page_objects/index.ts b/x-pack/test/security_solution_endpoint/page_objects/index.ts index 96e2a47e7803e..e82e105992d8b 100644 --- a/x-pack/test/security_solution_endpoint/page_objects/index.ts +++ b/x-pack/test/security_solution_endpoint/page_objects/index.ts @@ -9,7 +9,7 @@ import { EndpointPageProvider } from './endpoint_page'; import { EndpointAlertsPageProvider } from './endpoint_alerts_page'; import { EndpointPolicyPageProvider } from './policy_page'; import { EndpointPageUtils } from './page_utils'; -import { IngestManagerCreateDatasource } from './ingest_manager_create_datasource_page'; +import { IngestManagerCreatePackageConfig } from './ingest_manager_create_package_config_page'; export const pageObjects = { ...xpackFunctionalPageObjects, @@ -17,5 +17,5 @@ export const pageObjects = { policy: EndpointPolicyPageProvider, endpointPageUtils: EndpointPageUtils, endpointAlerts: EndpointAlertsPageProvider, - ingestManagerCreateDatasource: IngestManagerCreateDatasource, + ingestManagerCreatePackageConfig: IngestManagerCreatePackageConfig, }; diff --git a/x-pack/test/security_solution_endpoint/page_objects/ingest_manager_create_datasource_page.ts b/x-pack/test/security_solution_endpoint/page_objects/ingest_manager_create_package_config_page.ts similarity index 81% rename from x-pack/test/security_solution_endpoint/page_objects/ingest_manager_create_datasource_page.ts rename to x-pack/test/security_solution_endpoint/page_objects/ingest_manager_create_package_config_page.ts index 2ede7356bfdcd..dd3fc637a3d6c 100644 --- a/x-pack/test/security_solution_endpoint/page_objects/ingest_manager_create_datasource_page.ts +++ b/x-pack/test/security_solution_endpoint/page_objects/ingest_manager_create_package_config_page.ts @@ -6,14 +6,17 @@ import { FtrProviderContext } from '../ftr_provider_context'; -export function IngestManagerCreateDatasource({ getService, getPageObjects }: FtrProviderContext) { +export function IngestManagerCreatePackageConfig({ + getService, + getPageObjects, +}: FtrProviderContext) { const testSubjects = getService('testSubjects'); const find = getService('find'); const pageObjects = getPageObjects(['common']); return { /** - * Validates that the page shown is the Datasource Create Page + * Validates that the page shown is the Package Config Create Page */ async ensureOnCreatePageOrFail() { await testSubjects.existOrFail('createPackageConfig_header'); @@ -60,10 +63,10 @@ export function IngestManagerCreateDatasource({ getService, getPageObjects }: Ft }, /** - * Set the name of the datasource on the input field + * Set the name of the package config on the input field * @param name */ - async setDatasourceName(name: string) { + async setPackageConfigName(name: string) { // Because of the bottom sticky bar, we need to scroll section 2 into view // so that `setValue()` enters the data on the input field. await testSubjects.scrollIntoView('dataCollectionSetupStep'); @@ -78,18 +81,18 @@ export function IngestManagerCreateDatasource({ getService, getPageObjects }: Ft }, /** - * Validates that the page shown is the Datasource Edit Page + * Validates that the page shown is the Package Config Edit Page */ async ensureOnEditPageOrFail() { await testSubjects.existOrFail('editPackageConfig_header'); }, /** - * Navigates to the Ingest Agent configuration Edit Datasource page + * Navigates to the Ingest Agent configuration Edit Package Config page */ - async navigateToAgentConfigEditDatasource(agentConfigId: string, datasourceId: string) { + async navigateToAgentConfigEditPackageConfig(agentConfigId: string, packageConfigId: string) { await pageObjects.common.navigateToApp('ingestManager', { - hash: `/configs/${agentConfigId}/edit-datasource/${datasourceId}`, + hash: `/configs/${agentConfigId}/edit-integration/${packageConfigId}`, }); await this.ensureOnEditPageOrFail(); }, diff --git a/x-pack/test/security_solution_endpoint/page_objects/policy_page.ts b/x-pack/test/security_solution_endpoint/page_objects/policy_page.ts index d941371f0e744..b20e7c7c05e64 100644 --- a/x-pack/test/security_solution_endpoint/page_objects/policy_page.ts +++ b/x-pack/test/security_solution_endpoint/page_objects/policy_page.ts @@ -98,11 +98,11 @@ export function EndpointPolicyPageProvider({ getService, getPageObjects }: FtrPr }, /** - * Used when looking a the Ingest create/edit datasource pages. Finds the endpoint + * Used when looking a the Ingest create/edit package config pages. Finds the endpoint * custom configuaration component * @param onEditPage */ - async findDatasourceEndpointCustomConfiguration(onEditPage: boolean = false) { + async findPackageConfigEndpointCustomConfiguration(onEditPage: boolean = false) { return await testSubjects.find(`endpointPackageConfig_${onEditPage ? 'edit' : 'create'}`); }, From 91d13f2e7ae18341dd8f302fb723261583559ba3 Mon Sep 17 00:00:00 2001 From: Jen Huang Date: Mon, 29 Jun 2020 15:24:31 -0700 Subject: [PATCH 13/16] Fix tests --- .../functional/es_archives/fleet/agents/data.json | 2 +- .../apps/endpoint/policy_details.ts | 14 +++++++------- .../apps/endpoint/policy_list.ts | 2 +- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/x-pack/test/functional/es_archives/fleet/agents/data.json b/x-pack/test/functional/es_archives/fleet/agents/data.json index 9cbfb31771917..c317aad8ba05b 100644 --- a/x-pack/test/functional/es_archives/fleet/agents/data.json +++ b/x-pack/test/functional/es_archives/fleet/agents/data.json @@ -219,7 +219,7 @@ "metrics" ], "revision": 2, - "updated_on": "2020-05-07T19:34:42.533Z", + "updated_at": "2020-05-07T19:34:42.533Z", "updated_by": "system", "id": "config1" } diff --git a/x-pack/test/security_solution_endpoint/apps/endpoint/policy_details.ts b/x-pack/test/security_solution_endpoint/apps/endpoint/policy_details.ts index c5f75ece13d19..45ea82c59bf97 100644 --- a/x-pack/test/security_solution_endpoint/apps/endpoint/policy_details.ts +++ b/x-pack/test/security_solution_endpoint/apps/endpoint/policy_details.ts @@ -37,7 +37,7 @@ export default function ({ getPageObjects, getService }: FtrProviderContext) { before(async () => { policyInfo = await policyTestResources.createPolicy(); - await pageObjects.policy.navigateToPolicyDetails(policyInfo.package_config.id); + await pageObjects.policy.navigateToPolicyDetails(policyInfo.packageConfig.id); }); after(async () => { @@ -48,7 +48,7 @@ export default function ({ getPageObjects, getService }: FtrProviderContext) { it('should display policy view', async () => { expect(await testSubjects.getVisibleText('pageViewHeaderLeftTitle')).to.equal( - policyInfo.package_config.name + policyInfo.packageConfig.name ); }); }); @@ -58,7 +58,7 @@ export default function ({ getPageObjects, getService }: FtrProviderContext) { beforeEach(async () => { policyInfo = await policyTestResources.createPolicy(); - await pageObjects.policy.navigateToPolicyDetails(policyInfo.package_config.id); + await pageObjects.policy.navigateToPolicyDetails(policyInfo.packageConfig.id); }); afterEach(async () => { @@ -73,7 +73,7 @@ export default function ({ getPageObjects, getService }: FtrProviderContext) { await testSubjects.existOrFail('policyDetailsSuccessMessage'); expect(await testSubjects.getVisibleText('policyDetailsSuccessMessage')).to.equal( - `Policy ${policyInfo.package_config.name} has been updated.` + `Policy ${policyInfo.packageConfig.name} has been updated.` ); }); it('should persist update on the screen', async () => { @@ -82,7 +82,7 @@ export default function ({ getPageObjects, getService }: FtrProviderContext) { await testSubjects.existOrFail('policyDetailsSuccessMessage'); await pageObjects.policy.navigateToPolicyList(); - await pageObjects.policy.navigateToPolicyDetails(policyInfo.package_config.id); + await pageObjects.policy.navigateToPolicyDetails(policyInfo.packageConfig.id); expect(await (await testSubjects.find('policyWindowsEvent_process')).isSelected()).to.equal( false @@ -107,7 +107,7 @@ export default function ({ getPageObjects, getService }: FtrProviderContext) { expect(agentFullConfig).to.eql({ inputs: [ { - id: policyInfo.package_config.id, + id: policyInfo.packageConfig.id, dataset: { namespace: 'default' }, name: 'Protect East Coast', meta: { @@ -201,7 +201,7 @@ export default function ({ getPageObjects, getService }: FtrProviderContext) { policyInfo = await policyTestResources.createPolicy(); await pageObjects.ingestManagerCreatePackageConfig.navigateToAgentConfigEditPackageConfig( policyInfo.agentConfig.id, - policyInfo.package_config.id + policyInfo.packageConfig.id ); }); afterEach(async () => { diff --git a/x-pack/test/security_solution_endpoint/apps/endpoint/policy_list.ts b/x-pack/test/security_solution_endpoint/apps/endpoint/policy_list.ts index 90f0901bbb448..57321ab4cd911 100644 --- a/x-pack/test/security_solution_endpoint/apps/endpoint/policy_list.ts +++ b/x-pack/test/security_solution_endpoint/apps/endpoint/policy_list.ts @@ -78,7 +78,7 @@ export default function ({ getPageObjects, getService }: FtrProviderContext) { 'Protect East Coastrev. 1', 'elastic', 'elastic', - `${policyInfo.package_config.package?.title} v${policyInfo.package_config.package?.version}`, + `${policyInfo.packageConfig.package?.title} v${policyInfo.packageConfig.package?.version}`, '', ]); [policyRow[2], policyRow[4]].forEach((relativeDate) => { From b459636980b8d60b4224b6a1908aa80b0867ffa9 Mon Sep 17 00:00:00 2001 From: Jen Huang Date: Mon, 29 Jun 2020 17:11:15 -0700 Subject: [PATCH 14/16] Fix test field name --- x-pack/test/functional/es_archives/fleet/agents/data.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/x-pack/test/functional/es_archives/fleet/agents/data.json b/x-pack/test/functional/es_archives/fleet/agents/data.json index c317aad8ba05b..9cbfb31771917 100644 --- a/x-pack/test/functional/es_archives/fleet/agents/data.json +++ b/x-pack/test/functional/es_archives/fleet/agents/data.json @@ -219,7 +219,7 @@ "metrics" ], "revision": 2, - "updated_at": "2020-05-07T19:34:42.533Z", + "updated_on": "2020-05-07T19:34:42.533Z", "updated_by": "system", "id": "config1" } From 81940942dff7be1f1dcbab41e12d12d3fe3dbe04 Mon Sep 17 00:00:00 2001 From: Jen Huang Date: Mon, 29 Jun 2020 18:52:31 -0700 Subject: [PATCH 15/16] Fix test fixtures fields again --- x-pack/test/functional/es_archives/fleet/agents/data.json | 2 +- x-pack/test/functional/es_archives/fleet/agents/mappings.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/x-pack/test/functional/es_archives/fleet/agents/data.json b/x-pack/test/functional/es_archives/fleet/agents/data.json index 9cbfb31771917..c317aad8ba05b 100644 --- a/x-pack/test/functional/es_archives/fleet/agents/data.json +++ b/x-pack/test/functional/es_archives/fleet/agents/data.json @@ -219,7 +219,7 @@ "metrics" ], "revision": 2, - "updated_on": "2020-05-07T19:34:42.533Z", + "updated_at": "2020-05-07T19:34:42.533Z", "updated_by": "system", "id": "config1" } diff --git a/x-pack/test/functional/es_archives/fleet/agents/mappings.json b/x-pack/test/functional/es_archives/fleet/agents/mappings.json index 7bdcb35dae00a..0b84514de23f2 100644 --- a/x-pack/test/functional/es_archives/fleet/agents/mappings.json +++ b/x-pack/test/functional/es_archives/fleet/agents/mappings.json @@ -1829,7 +1829,7 @@ "updated_by": { "type": "keyword" }, - "updated_on": { + "updated_at": { "type": "keyword" } } From 7761eb977975b2d3993eecf9adf5f404c3df7b8d Mon Sep 17 00:00:00 2001 From: Jen Huang Date: Wed, 1 Jul 2020 12:26:58 -0700 Subject: [PATCH 16/16] Fix i18n --- x-pack/plugins/translations/translations/ja-JP.json | 2 +- x-pack/plugins/translations/translations/zh-CN.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/x-pack/plugins/translations/translations/ja-JP.json b/x-pack/plugins/translations/translations/ja-JP.json index 948980f7d3882..074e93e10fd12 100644 --- a/x-pack/plugins/translations/translations/ja-JP.json +++ b/x-pack/plugins/translations/translations/ja-JP.json @@ -8315,7 +8315,7 @@ "xpack.ingestManager.enrollmentTokensList.secretTitle": "シークレット", "xpack.ingestManager.epm.browseAllButtonText": "すべての統合を参照", "xpack.ingestManager.epm.illustrationAltText": "Elastic統合の例", - "xpack.ingestManager.epm.packageDetailsNav.datasourcesLinkText": "データソース", + "xpack.ingestManager.epm.packageDetailsNav.packageConfigsLinkText": "データソース", "xpack.ingestManager.epm.packageDetailsNav.overviewLinkText": "概要", "xpack.ingestManager.epm.packageDetailsNav.settingsLinkText": "設定", "xpack.ingestManager.epm.pageSubtitle": "一般的なアプリやサービスの統合を参照する", diff --git a/x-pack/plugins/translations/translations/zh-CN.json b/x-pack/plugins/translations/translations/zh-CN.json index dc01fe8f8d29c..9d0bd95526670 100644 --- a/x-pack/plugins/translations/translations/zh-CN.json +++ b/x-pack/plugins/translations/translations/zh-CN.json @@ -8319,7 +8319,7 @@ "xpack.ingestManager.enrollmentTokensList.secretTitle": "密钥", "xpack.ingestManager.epm.browseAllButtonText": "浏览所有集成", "xpack.ingestManager.epm.illustrationAltText": "Elastic 集成的图示", - "xpack.ingestManager.epm.packageDetailsNav.datasourcesLinkText": "数据源", + "xpack.ingestManager.epm.packageDetailsNav.packageConfigsLinkText": "数据源", "xpack.ingestManager.epm.packageDetailsNav.overviewLinkText": "概览", "xpack.ingestManager.epm.packageDetailsNav.settingsLinkText": "设置", "xpack.ingestManager.epm.pageSubtitle": "浏览集成以了解热门应用和服务。",