From 9fd8a86f3da47fd5ba8eda19aca91c2a9b76a4ae Mon Sep 17 00:00:00 2001 From: Jen Huang Date: Wed, 1 Jul 2020 19:19:45 -0700 Subject: [PATCH] [Ingest Manager] Rename data sources to package configs (#70259) (#70537) * 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 * Pluralize `ingest-package-configs` for consistency * Rename `Datasource`-related types to `PackageConfig`, update all references (does not include actual type definition changes yet) * Rename `Datasource` schemas and rest spec typings to `PackageConfig` (does not include actual schema changes yet) * Change `datasources` on agent config typings and schemas to `package_configs` and update all references * 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 * Rename server-side datasource references in file names, variable names, and routes * Update spec file and schema file * Update doc wording * Rename all instances of datasource in file paths and variable names on client sides, and for Endpoint too * Minor copy adjustments, fix i18n check * Replace datasource references in tests and fixtures; remove unused `ingest/policies` es archiver data * Fix tests * Fix test field name * Fix test fixtures fields again * Fix i18n # Conflicts: # x-pack/plugins/translations/translations/ja-JP.json # x-pack/plugins/translations/translations/zh-CN.json --- x-pack/plugins/ingest_manager/README.md | 2 +- .../common/constants/agent_config.ts | 2 +- .../ingest_manager/common/constants/index.ts | 2 +- .../{datasource.ts => package_config.ts} | 2 +- .../ingest_manager/common/constants/routes.ts | 16 +- .../common/openapi/spec_oas3.json | 64 +- .../ingest_manager/common/services/index.ts | 4 +- ...> package_configs_to_agent_inputs.test.ts} | 38 +- ....ts => package_configs_to_agent_inputs.ts} | 29 +- .../common/services/package_to_config.test.ts | 57 +- .../common/services/package_to_config.ts | 60 +- .../ingest_manager/common/services/routes.ts | 18 +- .../common/types/models/agent_config.ts | 18 +- .../common/types/models/datasource.ts | 70 - .../ingest_manager/common/types/models/epm.ts | 2 +- .../common/types/models/index.ts | 2 +- .../common/types/models/package_config.ts | 68 + .../common/types/rest_spec/datasource.ts | 59 - .../common/types/rest_spec/index.ts | 2 +- .../common/types/rest_spec/package_config.ts | 59 + .../ingest_manager/dev_docs/definitions.md | 21 +- .../dev_docs/schema/saved_objects.mml | 8 +- .../ingest_manager/constants/index.ts | 2 +- .../ingest_manager/constants/page_paths.ts | 20 +- .../ingest_manager/hooks/use_breadcrumbs.tsx | 18 +- .../hooks/use_request/datasource.ts | 62 - .../ingest_manager/hooks/use_request/index.ts | 2 +- .../hooks/use_request/package_config.ts | 62 + .../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} | 46 +- .../package_config_input_panel.tsx} | 70 +- .../package_config_input_stream.tsx} | 46 +- .../package_config_input_var_field.tsx} | 4 +- .../index.tsx | 141 +- .../services/index.ts | 10 +- .../services/is_advanced_var.test.ts | 0 .../services/is_advanced_var.ts | 0 .../services/validate_package_config.ts} | 81 +- .../validate_package_config.ts.test.ts} | 76 +- .../step_configure_package.tsx} | 58 +- .../step_define_package_config.tsx} | 80 +- .../step_select_config.tsx | 10 +- .../step_select_package.tsx | 8 +- .../types.ts | 4 +- .../components/datasources/index.tsx | 20 - .../details_page/components/index.ts | 4 +- .../components/package_configs/index.tsx | 23 + .../no_package_configs.tsx} | 19 +- .../package_configs_table.tsx} | 175 +- .../agent_config/details_page/index.tsx | 23 +- .../index.tsx | 147 +- .../sections/agent_config/index.tsx | 12 +- .../list_page/components/create_config.tsx | 2 +- .../sections/agent_config/list_page/index.tsx | 9 +- .../ingest_manager/sections/epm/index.tsx | 6 +- .../sections/epm/screens/detail/content.tsx | 6 +- .../sections/epm/screens/detail/header.tsx | 4 +- ...es_panel.tsx => package_configs_panel.tsx} | 15 +- .../epm/screens/detail/settings_panel.tsx | 16 +- .../epm/screens/detail/side_nav_links.tsx | 13 +- ...es.tsx => agent_config_package_badges.tsx} | 20 +- .../config_selection.tsx | 4 +- .../agent_reassign_config_flyout/index.tsx | 4 +- .../components/configuration_section.tsx | 12 +- .../ingest_manager/services/index.ts | 6 +- .../ingest_manager/types/index.ts | 20 +- .../types/intra_app_route_state.ts | 12 +- x-pack/plugins/ingest_manager/public/index.ts | 10 +- .../plugins/ingest_manager/public/plugin.ts | 6 +- .../ingest_manager/server/constants/index.ts | 4 +- 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 | 22 +- .../server/routes/agent_config/handlers.ts | 52 +- .../server/routes/datasource/index.ts | 73 - .../ingest_manager/server/routes/index.ts | 2 +- .../handlers.test.ts} | 46 +- .../handlers.ts | 106 +- .../server/routes/package_config/index.ts | 73 + .../server/saved_objects/index.ts | 37 +- .../migrations/agent_config_v790.ts | 24 - .../migrations/datasources_v790.ts | 43 - .../server/services/agent_config.ts | 59 +- .../server/services/epm/agent/agent.ts | 6 +- .../server/services/epm/packages/remove.ts | 10 +- .../ingest_manager/server/services/index.ts | 2 +- ...asource.test.ts => package_config.test.ts} | 12 +- .../{datasource.ts => package_config.ts} | 141 +- .../ingest_manager/server/services/setup.ts | 39 +- .../ingest_manager/server/types/index.tsx | 10 +- .../server/types/models/agent_config.ts | 7 +- .../server/types/models/index.ts | 2 +- .../{datasource.ts => package_config.ts} | 12 +- .../server/types/rest_spec/datasource.ts | 33 - .../server/types/rest_spec/index.ts | 2 +- .../server/types/rest_spec/package_config.ts | 33 + .../common/endpoint/generate_data.ts | 4 +- .../common/endpoint/types.ts | 8 +- .../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 | 28 +- .../policy/store/policy_list/middleware.ts | 16 +- .../policy_list/mock_policy_result_list.ts | 2 +- .../store/policy_list/services/ingest.test.ts | 30 +- .../store/policy_list/services/ingest.ts | 58 +- .../store/policy_list/test_mock_utils.ts | 6 +- .../public/management/pages/policy/types.ts | 12 +- ...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 +- .../endpoint/endpoint_app_context_services.ts | 4 +- .../server/endpoint/ingest_integration.ts | 28 +- .../server/endpoint/mocks.ts | 4 +- .../translations/translations/ja-JP.json | 168 +- .../translations/translations/zh-CN.json | 168 +- .../apis/ingest_manager/agent_config.ts | 2 +- .../es_archives/fleet/agents/data.json | 4 +- .../es_archives/fleet/agents/mappings.json | 8 +- .../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} | 33 +- .../page_objects/policy_page.ts | 6 +- .../services/endpoint_policy.ts | 87 +- 139 files changed, 1994 insertions(+), 3571 deletions(-) rename x-pack/plugins/ingest_manager/common/constants/{datasource.ts => package_config.ts} (76%) rename x-pack/plugins/ingest_manager/common/services/{datasources_to_agent_inputs.test.ts => package_configs_to_agent_inputs.test.ts} (79%) rename x-pack/plugins/ingest_manager/common/services/{datasources_to_agent_inputs.ts => package_configs_to_agent_inputs.ts} (65%) 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 delete mode 100644 x-pack/plugins/ingest_manager/common/types/rest_spec/datasource.ts create mode 100644 x-pack/plugins/ingest_manager/common/types/rest_spec/package_config.ts delete mode 100644 x-pack/plugins/ingest_manager/public/applications/ingest_manager/hooks/use_request/datasource.ts create mode 100644 x-pack/plugins/ingest_manager/public/applications/ingest_manager/hooks/use_request/package_config.ts 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} (77%) 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} (73%) 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} (78%) 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 (71%) 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} (69%) 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} (88%) 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} (67%) 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} (60%) 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%) delete mode 100644 x-pack/plugins/ingest_manager/public/applications/ingest_manager/sections/agent_config/details_page/components/datasources/index.tsx create mode 100644 x-pack/plugins/ingest_manager/public/applications/ingest_manager/sections/agent_config/details_page/components/package_configs/index.tsx 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} (55%) rename x-pack/plugins/ingest_manager/public/applications/ingest_manager/sections/agent_config/{edit_datasource_page => edit_package_config_page}/index.tsx (64%) 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} (68%) delete mode 100644 x-pack/plugins/ingest_manager/server/routes/datasource/index.ts rename x-pack/plugins/ingest_manager/server/routes/{datasource/datasource_handlers.test.ts => package_config/handlers.test.ts} (85%) rename x-pack/plugins/ingest_manager/server/routes/{datasource => package_config}/handlers.ts (56%) create mode 100644 x-pack/plugins/ingest_manager/server/routes/package_config/index.ts 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 rename x-pack/plugins/ingest_manager/server/services/{datasource.test.ts => package_config.test.ts} (92%) rename x-pack/plugins/ingest_manager/server/services/{datasource.ts => package_config.ts} (67%) rename x-pack/plugins/ingest_manager/server/types/models/{datasource.ts => package_config.ts} (84%) delete mode 100644 x-pack/plugins/ingest_manager/server/types/rest_spec/datasource.ts create mode 100644 x-pack/plugins/ingest_manager/server/types/rest_spec/package_config.ts rename x-pack/plugins/security_solution/public/management/pages/policy/view/ingest_manager_integration/{configure_datasource.tsx => configure_package_config.tsx} (79%) 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} (66%) 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/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..e7d5ef67f7253 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-configs'; diff --git a/x-pack/plugins/ingest_manager/common/constants/routes.ts b/x-pack/plugins/ingest_manager/common/constants/routes.ts index 1fe29aa54f6f9..dad3cdce1a497 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`; @@ -29,13 +29,13 @@ export const DATA_STREAM_API_ROUTES = { LIST_PATTERN: `${DATA_STREAM_API_ROOT}`, }; -// 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`, +// Package config API routes +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/openapi/spec_oas3.json b/x-pack/plugins/ingest_manager/common/openapi/spec_oas3.json index d17b4115e64ab..9617173bd0c7b 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,10 +1824,10 @@ "path": "telemetry" } ], - "datasources": [ + "packageConfigs": [ { "name": "endpoint", - "title": "Endpoint data source", + "title": "Endpoint package config", "description": "Interact with the endpoint.", "inputs": null, "multiple": false @@ -2121,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": [ { @@ -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/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 79% 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 538951ff10399..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 @@ -3,13 +3,13 @@ * 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 { storedDatasourcesToAgentInputs } from './datasources_to_agent_inputs'; +import { PackageConfig, PackageConfigInput } from '../types'; +import { storedPackageConfigsToAgentInputs } from './package_configs_to_agent_inputs'; -describe('Ingest Manager - storedDatasourcesToAgentInputs', () => { - const mockDatasource: Datasource = { +describe('Ingest Manager - storedPackageConfigsToAgentInputs', () => { + const mockPackageConfig: PackageConfig = { id: 'some-uuid', - name: 'mock-datasource', + name: 'mock-package-config', description: '', created_at: '', created_by: '', @@ -23,7 +23,7 @@ describe('Ingest Manager - storedDatasourcesToAgentInputs', () => { revision: 1, }; - const mockInput: DatasourceInput = { + const mockInput: PackageConfigInput = { type: 'test-logs', enabled: true, vars: { @@ -44,7 +44,7 @@ describe('Ingest Manager - storedDatasourcesToAgentInputs', () => { fooVar: { value: 'foo-value' }, fooVar2: { value: [1, 2] }, }, - agent_stream: { + compiled_stream: { fooKey: 'fooValue1', fooKey2: ['fooValue2'], }, @@ -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 65% 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 c6c5d784396db..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 @@ -3,29 +3,29 @@ * 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[] +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 }]) => { @@ -38,24 +38,21 @@ 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; }), }; - 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 7739fdc3a3b61..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,10 +313,11 @@ 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, inputs: [], name: 'mock-package-1', @@ -328,12 +329,13 @@ describe('Ingest Manager - packageToConfig', () => { }, }); }); - it('returns datasource with custom name', () => { - expect(packageToConfigDatasource(mockPackage, '1', '2', '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', @@ -342,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', - 'ds-1', 'mock-namespace', + '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', @@ -367,17 +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', 'ds-1')).toEqual({ + expect( + 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 1817077e97f9c..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 @@ -8,12 +8,12 @@ import { RegistryConfigTemplate, RegistryVarsEntry, RegistryStream, - Datasource, - DatasourceConfigRecord, - DatasourceConfigRecordEntry, - DatasourceInput, - DatasourceInputStream, - NewDatasource, + PackageConfig, + PackageConfigConfigRecord, + PackageConfigConfigRecordEntry, + PackageConfigInput, + PackageConfigInputStream, + NewPackageConfig, } from '../types'; const getStreamsForInputType = ( @@ -40,27 +40,27 @@ 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): Datasource['inputs'] => { - const inputs: Datasource['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: DatasourceConfigRecord, + configObject: PackageConfigConfigRecord, registryVar: RegistryVarsEntry - ): DatasourceConfigRecord => { - const configEntry: DatasourceConfigRecordEntry = { + ): PackageConfigConfigRecord => { + const configEntry: PackageConfigConfigRecordEntry = { value: !registryVar.default && registryVar.multi ? [] : registryVar.default, }; if (registryVar.type) { @@ -70,12 +70,12 @@ export const packageToConfigDatasourceInputs = (packageInfo: PackageInfo): Datas return configObject; }; - // Map each package input stream into datasource input stream - const streams: DatasourceInputStream[] = getStreamsForInputType( + // Map each package input stream into package config input stream + 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 +89,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,23 +107,23 @@ 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 * @param outputId - * @param datasourceName + * @param packageConfigName */ -export const packageToConfigDatasource = ( +export const packageToPackageConfig = ( packageInfo: PackageInfo, configId: string, outputId: string, - datasourceName?: string, - namespace?: string, + namespace: string = '', + packageConfigName?: string, description?: string -): NewDatasource => { +): NewPackageConfig => { return { - name: datasourceName || `${packageInfo.name}-1`, + name: packageConfigName || `${packageInfo.name}-1`, namespace, description, package: { @@ -134,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/agent_config.ts b/x-pack/plugins/ingest_manager/common/types/models/agent_config.ts index 0d7dc13af7a30..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 { Datasource, DatasourcePackage, DatasourceInputStream } from './datasource'; +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'>; @@ -22,7 +22,7 @@ export interface NewAgentConfig { export interface AgentConfig extends NewAgentConfig { id: string; status: AgentConfigStatus; - datasources: string[] | Datasource[]; + package_configs: string[] | PackageConfig[]; updated_at: string; updated_by: string; revision: number; @@ -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; @@ -42,7 +46,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 b001b994187e1..5b68cd2beeed4 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/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..e9595bab0174e --- /dev/null +++ b/x-pack/plugins/ingest_manager/common/types/models/package_config.ts @@ -0,0 +1,68 @@ +/* + * 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; + }; + vars?: PackageConfigConfigRecord; + config?: PackageConfigConfigRecord; +} + +export interface PackageConfigInputStream extends NewPackageConfigInputStream { + compiled_stream?: any; +} + +export interface NewPackageConfigInput { + type: string; + enabled: boolean; + vars?: PackageConfigConfigRecord; + config?: PackageConfigConfigRecord; + streams: NewPackageConfigInputStream[]; +} + +export interface PackageConfigInput extends Omit { + streams: PackageConfigInputStream[]; +} + +export interface NewPackageConfig { + name: string; + description?: string; + namespace: string; + enabled: boolean; + config_id: string; + output_id: string; + package?: PackageConfigPackage; + 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 deleted file mode 100644 index 61f1f15d49259..0000000000000 --- a/x-pack/plugins/ingest_manager/common/types/rest_spec/datasource.ts +++ /dev/null @@ -1,59 +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 { Datasource, NewDatasource } from '../models'; - -export interface GetDatasourcesRequest { - query: { - page: number; - perPage: number; - kuery?: string; - }; -} - -export interface GetDatasourcesResponse { - items: Datasource[]; - total: number; - page: number; - perPage: number; - success: boolean; -} - -export interface GetOneDatasourceRequest { - params: { - datasourceId: string; - }; -} - -export interface GetOneDatasourceResponse { - item: Datasource; - success: boolean; -} - -export interface CreateDatasourceRequest { - body: NewDatasource; -} - -export interface CreateDatasourceResponse { - item: Datasource; - success: boolean; -} - -export type UpdateDatasourceRequest = GetOneDatasourceRequest & { - body: NewDatasource; -}; - -export type UpdateDatasourceResponse = CreateDatasourceResponse; - -export interface DeleteDatasourcesRequest { - body: { - datasourceIds: string[]; - }; -} - -export type DeleteDatasourcesResponse = Array<{ - id: string; - success: boolean; -}>; 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/package_config.ts b/x-pack/plugins/ingest_manager/common/types/rest_spec/package_config.ts new file mode 100644 index 0000000000000..4b8abbde47d5b --- /dev/null +++ b/x-pack/plugins/ingest_manager/common/types/rest_spec/package_config.ts @@ -0,0 +1,59 @@ +/* + * 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 { PackageConfig, NewPackageConfig } from '../models'; + +export interface GetPackageConfigsRequest { + query: { + page: number; + perPage: number; + kuery?: string; + }; +} + +export interface GetPackageConfigsResponse { + items: PackageConfig[]; + total: number; + page: number; + perPage: number; + success: boolean; +} + +export interface GetOnePackageConfigRequest { + params: { + packageConfigId: string; + }; +} + +export interface GetOnePackageConfigResponse { + item: PackageConfig; + success: boolean; +} + +export interface CreatePackageConfigRequest { + body: NewPackageConfig; +} + +export interface CreatePackageConfigResponse { + item: PackageConfig; + success: boolean; +} + +export type UpdatePackageConfigRequest = GetOnePackageConfigRequest & { + body: NewPackageConfig; +}; + +export type UpdatePackageConfigResponse = CreatePackageConfigResponse; + +export interface DeletePackageConfigsRequest { + body: { + packageConfigIds: string[]; + }; +} + +export type DeletePackageConfigsResponse = Array<{ + id: string; + success: boolean; +}>; 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. - 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 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/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/datasource.ts b/x-pack/plugins/ingest_manager/public/applications/ingest_manager/hooks/use_request/datasource.ts deleted file mode 100644 index e2fc190e158f9..0000000000000 --- a/x-pack/plugins/ingest_manager/public/applications/ingest_manager/hooks/use_request/datasource.ts +++ /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 { sendRequest, useRequest } from './use_request'; -import { datasourceRouteService } from '../../services'; -import { - CreateDatasourceRequest, - CreateDatasourceResponse, - UpdateDatasourceRequest, - UpdateDatasourceResponse, -} from '../../types'; -import { - DeleteDatasourcesRequest, - DeleteDatasourcesResponse, - GetDatasourcesRequest, - GetDatasourcesResponse, - GetOneDatasourceResponse, -} from '../../../../../common/types/rest_spec'; - -export const sendCreateDatasource = (body: CreateDatasourceRequest['body']) => { - return sendRequest({ - path: datasourceRouteService.getCreatePath(), - method: 'post', - body: JSON.stringify(body), - }); -}; - -export const sendUpdateDatasource = ( - datasourceId: string, - body: UpdateDatasourceRequest['body'] -) => { - return sendRequest({ - path: datasourceRouteService.getUpdatePath(datasourceId), - method: 'put', - body: JSON.stringify(body), - }); -}; - -export const sendDeleteDatasource = (body: DeleteDatasourcesRequest['body']) => { - return sendRequest({ - path: datasourceRouteService.getDeletePath(), - method: 'post', - body: JSON.stringify(body), - }); -}; - -export function useGetDatasources(query: GetDatasourcesRequest['query']) { - return useRequest({ - method: 'get', - path: datasourceRouteService.getListPath(), - query, - }); -} - -export const sendGetOneDatasource = (datasourceId: string) => { - return sendRequest({ - path: datasourceRouteService.getInfoPath(datasourceId), - method: 'get', - }); -}; 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/package_config.ts b/x-pack/plugins/ingest_manager/public/applications/ingest_manager/hooks/use_request/package_config.ts new file mode 100644 index 0000000000000..aba950123ead3 --- /dev/null +++ b/x-pack/plugins/ingest_manager/public/applications/ingest_manager/hooks/use_request/package_config.ts @@ -0,0 +1,62 @@ +/* + * 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 { sendRequest, useRequest } from './use_request'; +import { packageConfigRouteService } from '../../services'; +import { + CreatePackageConfigRequest, + CreatePackageConfigResponse, + UpdatePackageConfigRequest, + UpdatePackageConfigResponse, +} from '../../types'; +import { + DeletePackageConfigsRequest, + DeletePackageConfigsResponse, + GetPackageConfigsRequest, + GetPackageConfigsResponse, + GetOnePackageConfigResponse, +} from '../../../../../common/types/rest_spec'; + +export const sendCreatePackageConfig = (body: CreatePackageConfigRequest['body']) => { + return sendRequest({ + path: packageConfigRouteService.getCreatePath(), + method: 'post', + body: JSON.stringify(body), + }); +}; + +export const sendUpdatePackageConfig = ( + packageConfigId: string, + body: UpdatePackageConfigRequest['body'] +) => { + return sendRequest({ + path: packageConfigRouteService.getUpdatePath(packageConfigId), + method: 'put', + body: JSON.stringify(body), + }); +}; + +export const sendDeletePackageConfig = (body: DeletePackageConfigsRequest['body']) => { + return sendRequest({ + path: packageConfigRouteService.getDeletePath(), + method: 'post', + body: JSON.stringify(body), + }); +}; + +export function useGetPackageConfigs(query: GetPackageConfigsRequest['query']) { + return useRequest({ + method: 'get', + path: packageConfigRouteService.getListPath(), + query, + }); +} + +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 86186f7f0a6dd..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({ datasourceIds: 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 4263feb7cd8c7..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 { NewDatasource } from '../../../../types'; -import { CreateDatasourceFrom } from '../types'; - -export interface CustomConfigureDatasourceProps { - packageName: string; - from: CreateDatasourceFrom; - datasource: NewDatasource; - 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 77% 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 6eed7e74d6bc6..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 @@ -15,20 +15,24 @@ import { EuiTitle, EuiIconTip, } from '@elastic/eui'; -import { DatasourceInput, RegistryVarsEntry } from '../../../../types'; -import { isAdvancedVar, DatasourceConfigValidationResults, validationHasErrors } from '../services'; -import { DatasourceInputVarField } from './datasource_input_var_field'; +import { PackageConfigInput, RegistryVarsEntry } from '../../../../types'; +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: DatasourceInput; - 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 73% 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 6f6fa5aaa7f3e..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 @@ -20,14 +20,14 @@ import { EuiIconTip, } from '@elastic/eui'; import { - DatasourceInput, - DatasourceInputStream, + PackageConfigInput, + PackageConfigInputStream, 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: DatasourceInput; - 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,42 +176,44 @@ 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( + packageConfigInputStream={packageConfigInputStream} + updatePackageConfigInputStream={( + updatedStream: Partial + ) => { + 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, }; - const updatedInput: Partial = { + const updatedInput: Partial = { streams: newStreams, }; // 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 78% 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 f697ef736ef70..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 @@ -16,20 +16,24 @@ import { EuiTextColor, EuiIconTip, } from '@elastic/eui'; -import { DatasourceInputStream, RegistryStream, RegistryVarsEntry } from '../../../../types'; -import { isAdvancedVar, DatasourceConfigValidationResults, validationHasErrors } from '../services'; -import { DatasourceInputVarField } from './datasource_input_var_field'; +import { PackageConfigInputStream, RegistryStream, RegistryVarsEntry } from '../../../../types'; +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: DatasourceInputStream; - updateDatasourceInputStream: (updatedStream: Partial) => void; - inputStreamValidationResults: DatasourceConfigValidationResults; + packageConfigInputStream: PackageConfigInputStream; + updatePackageConfigInputStream: (updatedStream: Partial) => void; + inputStreamValidationResults: PackageConfigConfigValidationResults; forceShowErrors?: boolean; }> = ({ packageInputStream, - datasourceInputStream, - updateDatasourceInputStream, + packageConfigInputStream, + updatePackageConfigInputStream, inputStreamValidationResults, forceShowErrors, }) => { @@ -68,7 +72,7 @@ export const DatasourceInputStreamConfig: React.FunctionComponent<{ } @@ -80,10 +84,10 @@ export const DatasourceInputStreamConfig: React.FunctionComponent<{ ) : null} } - checked={datasourceInputStream.enabled} + checked={packageConfigInputStream.enabled} onChange={(e) => { const enabled = e.target.checked; - updateDatasourceInputStream({ + updatePackageConfigInputStream({ enabled, }); }} @@ -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 ( - { - updateDatasourceInputStream({ + 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 ( - { - updateDatasourceInputStream({ + 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 71% 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 18c4f2f82ac01..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 @@ -20,28 +20,32 @@ import { EuiStepProps } from '@elastic/eui/src/components/steps/step'; import { AgentConfig, PackageInfo, - NewDatasource, - CreateDatasourceRouteState, + NewPackageConfig, + 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,21 +94,22 @@ 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: '', config_id: '', enabled: true, output_id: '', // TODO: Blank for now as we only support default output 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( @@ -146,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?: NewDatasource) => { + 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; } @@ -198,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; }; @@ -215,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( @@ -228,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, { @@ -288,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 ? ( - @@ -335,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" > @@ -389,17 +406,17 @@ export const CreateDatasourcePage: React.FunctionComponent = () => { iconType="save" color="primary" fill - data-test-subj="createDatasourceSaveButton" + data-test-subj="createPackageConfigSaveButton" > - + ); }; @@ -407,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; }; @@ -415,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 69% 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 30dca4a5fbf81..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 @@ -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, @@ -21,42 +21,52 @@ 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; - inputs: Record | null; + namespace: Errors; + 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: NewDatasource, +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 (!packageConfig.namespace.trim()) { + validationResults.namespace = [ + i18n.translate('xpack.ingestManager.packageConfigValidation.namespaceRequiredErrorMessage', { + defaultMessage: 'Namespace is required', + }), + ]; + } + if ( !packageInfo.config_templates || packageInfo.config_templates.length === 0 || @@ -83,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: {}, }; @@ -107,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); @@ -118,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) { @@ -136,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; }, @@ -161,8 +171,8 @@ export const validateDatasource = ( return validationResults; }; -const validateDatasourceConfig = ( - configEntry: DatasourceConfigRecordEntry, +const validatePackageConfigConfig = ( + configEntry: PackageConfigConfigRecordEntry, varDef: RegistryVarsEntry ): string[] | null => { const errors = []; @@ -176,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, @@ -191,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', + } + ) ); } } @@ -201,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', }) ); @@ -211,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, @@ -226,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 88% 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 64facf01d474a..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 @@ -6,12 +6,12 @@ import { PackageInfo, InstallationStatus, - NewDatasource, + 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,9 @@ describe('Ingest Manager - validateDatasource()', () => { ], } as unknown) as PackageInfo; - const validDatasource: NewDatasource = { - name: 'datasource1-1', + const validPackageConfig: NewPackageConfig = { + name: 'pkgConfig1-1', + namespace: 'default', config_id: 'test-config', enabled: true, output_id: 'test-output', @@ -225,8 +226,8 @@ describe('Ingest Manager - validateDatasource()', () => { ], }; - const invalidDatasource: NewDatasource = { - ...validDatasource, + const invalidPackageConfig: NewPackageConfig = { + ...validPackageConfig, name: '', inputs: [ { @@ -315,6 +316,7 @@ describe('Ingest Manager - validateDatasource()', () => { const noErrorsValidationResults = { name: null, description: null, + namespace: null, inputs: { foo: { vars: { @@ -348,14 +350,17 @@ 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, inputs: { foo: { vars: { @@ -392,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, @@ -408,10 +416,14 @@ describe('Ingest Manager - validateDatasource()', () => { : input ); expect( - validateDatasource({ ...invalidDatasource, inputs: inputsWithDisabledStreams }, mockPackage) + validatePackageConfig( + { ...invalidPackageConfig, inputs: inputsWithDisabledStreams }, + mockPackage + ) ).toEqual({ name: ['Name is required'], description: null, + namespace: null, inputs: { foo: { vars: { @@ -449,48 +461,52 @@ 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, }) ).toEqual({ name: null, description: null, + namespace: null, inputs: null, }); expect( - validateDatasource(validDatasource, { + validatePackageConfig(validPackageConfig, { ...mockPackage, config_templates: [], }) ).toEqual({ name: null, description: null, + namespace: null, inputs: null, }); }); it('returns no errors for packages with no inputs', () => { expect( - validateDatasource(validDatasource, { + validatePackageConfig(validPackageConfig, { ...mockPackage, config_templates: [{} as RegistryConfigTemplate], }) ).toEqual({ name: null, description: null, + namespace: null, inputs: null, }); expect( - validateDatasource(validDatasource, { + validatePackageConfig(validPackageConfig, { ...mockPackage, config_templates: [({ inputs: [] } as unknown) as RegistryConfigTemplate], }) ).toEqual({ name: null, description: null, + namespace: null, inputs: null, }); }); @@ -537,11 +553,12 @@ 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'], description: null, + namespace: null, inputs: { input1: { vars: { foo: null, bar: null }, @@ -554,6 +571,7 @@ describe('Ingest Manager - validationHasErrors()', () => { validationHasErrors({ name: null, description: null, + namespace: null, inputs: { input1: { vars: { foo: ['foo error'], bar: null }, @@ -566,6 +584,7 @@ describe('Ingest Manager - validationHasErrors()', () => { validationHasErrors({ name: null, description: null, + namespace: null, inputs: { input1: { vars: { foo: null, bar: null }, @@ -576,11 +595,12 @@ 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, 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/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 67% 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 c319dbc08b2c6..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 @@ -7,11 +7,11 @@ 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'; -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: NewDatasource; - 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 60% 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 2651615b458f7..b2ffe62104eb1 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 @@ -15,37 +15,37 @@ import { EuiText, EuiComboBox, } from '@elastic/eui'; -import { AgentConfig, PackageInfo, Datasource, NewDatasource } from '../../../types'; -import { packageToConfigDatasourceInputs } from '../../../services'; +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: NewDatasource; - 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.datasources as Datasource[]) + 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 }`, @@ -54,18 +54,24 @@ export const StepDefineDatasource: React.FunctionComponent<{ title: packageInfo.title, version: packageInfo.version, }, - inputs: packageToConfigDatasourceInputs(packageInfo), + inputs: packageToPackageConfigInputs(packageInfo), }); } - // 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,20 +136,22 @@ export const StepDefineDatasource: React.FunctionComponent<{ onClick={() => setIsShowingAdvancedDefine(!isShowingAdvancedDefine)} > {/* Todo: Populate list of existing namespaces */} - {isShowingAdvancedDefine ? ( + {isShowingAdvancedDefine || !!validationResults.namespace ? ( } @@ -151,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/datasources/index.tsx b/x-pack/plugins/ingest_manager/public/applications/ingest_manager/sections/agent_config/details_page/components/datasources/index.tsx deleted file mode 100644 index 346ccde45f3f0..0000000000000 --- a/x-pack/plugins/ingest_manager/public/applications/ingest_manager/sections/agent_config/details_page/components/datasources/index.tsx +++ /dev/null @@ -1,20 +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, { memo } from 'react'; -import { AgentConfig, Datasource } from '../../../../../../../../common/types/models'; -import { NoDatasources } from './no_datasources'; -import { DatasourcesTable } from './datasources_table'; - -export const ConfigDatasourcesView = memo<{ config: AgentConfig }>(({ config }) => { - if (config.datasources.length === 0) { - return ; - } - - return ( - - ); -}); 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/package_configs/index.tsx b/x-pack/plugins/ingest_manager/public/applications/ingest_manager/sections/agent_config/details_page/components/package_configs/index.tsx new file mode 100644 index 0000000000000..3aef297e8d22e --- /dev/null +++ b/x-pack/plugins/ingest_manager/public/applications/ingest_manager/sections/agent_config/details_page/components/package_configs/index.tsx @@ -0,0 +1,23 @@ +/* + * 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, { memo } from 'react'; +import { AgentConfig, PackageConfig } from '../../../../../types'; +import { NoPackageConfigs } from './no_package_configs'; +import { PackageConfigsTable } from './package_configs_table'; + +export const ConfigPackageConfigsView = memo<{ config: AgentConfig }>(({ config }) => { + 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/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 55% 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 caf0c149c0199..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 @@ -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 { PackageConfigDeleteProvider, DangerEuiContextMenuItem } from '../../../components'; import { useCapabilities, useLink } from '../../../../../hooks'; import { useConfigRefresh } from '../../hooks'; -interface InMemoryDatasource extends Datasource { +interface InMemoryPackageConfig extends PackageConfig { streams: { total: number; enabled: number }; inputTypes: string[]; packageName?: string; @@ -31,11 +31,11 @@ interface InMemoryDatasource extends Datasource { } interface Props { - datasources: Datasource[]; + 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 eaa161d57bbe4..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` @@ -120,13 +120,16 @@ export const AgentConfigDetailsPage: React.FunctionComponent = () => { }, { isDivider: true }, { - label: i18n.translate('xpack.ingestManager.configDetails.summary.datasources', { - defaultMessage: 'Data sources', + label: i18n.translate('xpack.ingestManager.configDetails.summary.package_configs', { + defaultMessage: 'Integrations', }), content: ( ), @@ -204,12 +207,12 @@ export const AgentConfigDetailsPage: React.FunctionComponent = () => { 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', @@ -292,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 64% 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 af39cb87f18c9..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 @@ -16,31 +16,34 @@ import { EuiFlexItem, EuiSpacer, } from '@elastic/eui'; -import { AgentConfig, PackageInfo, NewDatasource } from '../../../types'; +import { AgentConfig, PackageInfo, NewPackageConfig } from '../../../types'; import { useLink, 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,34 +67,35 @@ 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: '', config_id: '', enabled: true, output_id: '', 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, @@ -100,30 +104,30 @@ export const EditDatasourcePage: React.FunctionComponent = () => { created_at, updated_by, updated_at, - ...restOfDatasource - } = datasourceData.item; - // Remove `agent_stream` from all stream info, we assign this after saving - const newDatasource = { - ...restOfDatasource, + ...restOfPackageConfig + } = packageConfigData.item; + // Remove `compiled_stream` from all stream info, we assign this after saving + const newPackageConfig = { + ...restOfPackageConfig, inputs: inputs.map((input) => { const { streams, ...restOfInput } = input; return { ...restOfInput, streams: streams.map((stream) => { - const { agent_stream, ...restOfStream } = stream; + const { compiled_stream, ...restOfStream } = stream; return restOfStream; }), }; }), }; - 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'); } } @@ -134,7 +138,7 @@ export const EditDatasourcePage: React.FunctionComponent = () => { setIsLoadingData(false); }; getData(); - }, [configId, datasourceId]); + }, [configId, packageConfigId]); // Retrieve agent count const [agentCount, setAgentCount] = useState(0); @@ -151,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; @@ -174,12 +178,15 @@ export const EditDatasourcePage: React.FunctionComponent = () => { } }; - const updateDatasourceValidation = (newDatasource?: NewDatasource) => { + 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; } @@ -188,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; }; @@ -206,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, @@ -235,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', }) } /> @@ -275,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: ( - @@ -326,7 +333,7 @@ export const EditDatasourcePage: React.FunctionComponent = () => { @@ -341,8 +348,8 @@ export const EditDatasourcePage: React.FunctionComponent = () => { fill > @@ -350,7 +357,7 @@ export const EditDatasourcePage: React.FunctionComponent = () => { )} - + ); }; @@ -358,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 8b1ff0988d443..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,12 +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['datasources']) => (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 96aebb08e0c63..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 }; @@ -63,8 +63,8 @@ export function ContentPanel(props: ContentPanelProps) { latestVersion={latestVersion} /> ); - case 'data-sources': - return ; + case 'usages': + 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 986b946131e33..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,8 +10,8 @@ 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 { DATASOURCE_SAVED_OBJECT_TYPE } from '../../../../constants'; +import { useGetPackageConfigs } from '../../../../hooks'; +import { PACKAGE_CONFIG_SAVED_OBJECT_TYPE } from '../../../../constants'; import { useGetPackageInstallStatus } from '../../hooks'; import { InstallationButton } from './installation_button'; import { UpdateIcon } from '../../components/icons'; @@ -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: `${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; + 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', }), - 'data-sources': 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,12 +43,9 @@ 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 - if ( - panel === 'data-sources' && - (true || packageInstallStatus.status !== InstallStatus.installed) - ) + // 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; return ( 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 68% 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 30bc9dc701427..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 @@ -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'; @@ -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,16 +26,16 @@ export const AgentConfigDatasourceBadges: React.FunctionComponent = ({ ag {agentConfig.datasources.length}, + count: agentConfig.package_configs.length, + countValue: {agentConfig.package_configs.length}, }} /> - {(agentConfig.datasources as Datasource[]).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..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 @@ -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/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/public/applications/ingest_manager/types/index.ts b/x-pack/plugins/ingest_manager/public/applications/ingest_manager/types/index.ts index 90315f38fd476..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 @@ -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 @@ -35,11 +35,11 @@ export { CopyAgentConfigResponse, DeleteAgentConfigRequest, DeleteAgentConfigResponse, - // API schemas - Datasource - CreateDatasourceRequest, - CreateDatasourceResponse, - UpdateDatasourceRequest, - UpdateDatasourceResponse, + // API schemas - Package config + CreatePackageConfigRequest, + CreatePackageConfigResponse, + UpdatePackageConfigRequest, + UpdatePackageConfigResponse, // API schemas - Data Streams GetDataStreamsResponse, // API schemas - Agents 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 c5833adcded5f..4fd770501ae3f 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,16 +5,16 @@ */ import { ApplicationStart } from 'kibana/public'; -import { Datasource } from '../../../../common/types/models'; +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: Datasource) => Parameters); + | ((newPackageConfig: PackageConfig) => Parameters); /** On cancel, navigate to the given app */ onCancelNavigateTo?: Parameters; /** Url to be used on cancel links */ @@ -41,6 +41,6 @@ export interface AgentDetailsReassignConfigAction { * All possible Route states. */ export type AnyIntraAppRouteState = - | CreateDatasourceRouteState + | CreatePackageConfigRouteState | AgentConfigDetailsDeployAgentAction | AgentDetailsReassignConfigAction; diff --git a/x-pack/plugins/ingest_manager/public/index.ts b/x-pack/plugins/ingest_manager/public/index.ts index ac56349b30c13..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 { 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/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/ingest_manager/server/constants/index.ts b/x-pack/plugins/ingest_manager/server/constants/index.ts index ebcce6320ec4b..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, @@ -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/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 4c4fdb2ba1e06..98999e66c57f7 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, @@ -34,7 +34,7 @@ import { import { registerSavedObjects, registerEncryptedSavedObjects } from './saved_objects'; import { registerEPMRoutes, - registerDatasourceRoutes, + registerPackageConfigRoutes, registerDataStreamRoutes, registerAgentConfigRoutes, registerSetupRoutes, @@ -45,14 +45,14 @@ import { registerSettingsRoutes, registerAppRoutes, } from './routes'; -import { IngestManagerConfigType, NewDatasource } from '../common'; +import { IngestManagerConfigType, NewPackageConfig } from '../common'; import { appContextService, licenseService, ESIndexPatternSavedObjectService, ESIndexPatternService, AgentService, - datasourceService, + packageConfigService, } from './services'; import { getAgentStatusById, @@ -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, @@ -102,8 +102,8 @@ const allSavedObjectTypes = [ * Callbacks supported by the Ingest plugin */ export type ExternalCallback = [ - 'datasourceCreate', - (newDatasource: NewDatasource) => 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 d01b361bd6ca4..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 { @@ -20,7 +20,7 @@ import { GetFullAgentConfigRequestSchema, AgentConfig, DefaultPackages, - NewDatasource, + NewPackageConfig, } from '../../types'; import { GetAgentConfigsResponse, @@ -107,30 +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( - [ - 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, newSysPackageConfig] = await Promise.all< + AgentConfig, + NewPackageConfig | undefined + >([ + agentConfigService.create(soClient, request.body, { + user, + }), + // 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 + ? 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; - 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/datasource/index.ts b/x-pack/plugins/ingest_manager/server/routes/datasource/index.ts deleted file mode 100644 index 7217f28053cf3..0000000000000 --- a/x-pack/plugins/ingest_manager/server/routes/datasource/index.ts +++ /dev/null @@ -1,73 +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 { IRouter } from 'src/core/server'; -import { PLUGIN_ID, DATASOURCE_API_ROUTES } from '../../constants'; -import { - GetDatasourcesRequestSchema, - GetOneDatasourceRequestSchema, - CreateDatasourceRequestSchema, - UpdateDatasourceRequestSchema, - DeleteDatasourcesRequestSchema, -} from '../../types'; -import { - getDatasourcesHandler, - getOneDatasourceHandler, - createDatasourceHandler, - updateDatasourceHandler, - deleteDatasourceHandler, -} from './handlers'; - -export const registerRoutes = (router: IRouter) => { - // List - router.get( - { - path: DATASOURCE_API_ROUTES.LIST_PATTERN, - validate: GetDatasourcesRequestSchema, - options: { tags: [`access:${PLUGIN_ID}-read`] }, - }, - getDatasourcesHandler - ); - - // Get one - router.get( - { - path: DATASOURCE_API_ROUTES.INFO_PATTERN, - validate: GetOneDatasourceRequestSchema, - options: { tags: [`access:${PLUGIN_ID}-read`] }, - }, - getOneDatasourceHandler - ); - - // Create - router.post( - { - path: DATASOURCE_API_ROUTES.CREATE_PATTERN, - validate: CreateDatasourceRequestSchema, - options: { tags: [`access:${PLUGIN_ID}-all`] }, - }, - createDatasourceHandler - ); - - // Update - router.put( - { - path: DATASOURCE_API_ROUTES.UPDATE_PATTERN, - validate: UpdateDatasourceRequestSchema, - options: { tags: [`access:${PLUGIN_ID}-all`] }, - }, - updateDatasourceHandler - ); - - // Delete - router.post( - { - path: DATASOURCE_API_ROUTES.DELETE_PATTERN, - validate: DeleteDatasourcesRequestSchema, - options: { tags: [`access:${PLUGIN_ID}`] }, - }, - deleteDatasourceHandler - ); -}; 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 85% 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 07cbeb8b2cec5..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 { CreateDatasourceRequestSchema } from '../../types/rest_spec'; -import { datasourceService } from '../../services'; +import { PackageConfigServiceInterface, ExternalCallback } from '../..'; +import { CreatePackageConfigRequestSchema } from '../../types/rest_spec'; +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; @@ -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', @@ -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 56% 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 4f83d24a846ea..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,25 +6,28 @@ 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 { - GetDatasourcesRequestSchema, - GetOneDatasourceRequestSchema, - CreateDatasourceRequestSchema, - UpdateDatasourceRequestSchema, - DeleteDatasourcesRequestSchema, - NewDatasource, + GetPackageConfigsRequestSchema, + GetOnePackageConfigRequestSchema, + CreatePackageConfigRequestSchema, + UpdatePackageConfigRequestSchema, + DeletePackageConfigsRequestSchema, + NewPackageConfig, } from '../../types'; -import { CreateDatasourceResponse, DeleteDatasourcesResponse } from '../../../common'; +import { CreatePackageConfigResponse, DeletePackageConfigsResponse } from '../../../common'; -export const getDatasourcesHandler: RequestHandler< +export const getPackageConfigsHandler: RequestHandler< undefined, - TypeOf + 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,10 +72,10 @@ export const getOneDatasourceHandler: RequestHandler + TypeOf > = async (context, request, response) => { const soClient = context.core.savedObjects.client; const callCluster = context.core.elasticsearch.legacy.client.callAsCurrentUser; @@ -80,33 +83,30 @@ 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: NewDatasource = newData; + let updatedNewData: NewPackageConfig = newData; 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) { // 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); } } - // The type `NewDatasource` 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. - // @ts-ignore - newData = updatedNewData as typeof CreateDatasourceRequestSchema.body; + newData = updatedNewData; } - // Make sure the datasource package is installed + // Make sure the associated package is installed if (newData.package?.name) { await ensureInstalledPackage({ savedObjectsClient: soClient, @@ -118,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']; + )) as TypeOf['inputs']; } - // Create datasource - const datasource = await datasourceService.create(soClient, newData, { user }); - const body: CreateDatasourceResponse = { 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, }); @@ -139,42 +139,42 @@ export const createDatasourceHandler: RequestHandler< } }; -export const updateDatasourceHandler: RequestHandler< - TypeOf, +export const updatePackageConfigHandler: RequestHandler< + TypeOf, unknown, - TypeOf + TypeOf > = async (context, request, response) => { 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< - typeof CreateDatasourceRequestSchema.body + 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({ @@ -184,17 +184,17 @@ export const updateDatasourceHandler: RequestHandler< } }; -export const deleteDatasourceHandler: RequestHandler< +export const deletePackageConfigHandler: 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 packageConfigService.delete( soClient, - request.body.datasourceIds, + request.body.packageConfigIds, { user } ); return response.ok({ diff --git a/x-pack/plugins/ingest_manager/server/routes/package_config/index.ts b/x-pack/plugins/ingest_manager/server/routes/package_config/index.ts new file mode 100644 index 0000000000000..1da045e052997 --- /dev/null +++ b/x-pack/plugins/ingest_manager/server/routes/package_config/index.ts @@ -0,0 +1,73 @@ +/* + * 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 { IRouter } from 'src/core/server'; +import { PLUGIN_ID, PACKAGE_CONFIG_API_ROUTES } from '../../constants'; +import { + GetPackageConfigsRequestSchema, + GetOnePackageConfigRequestSchema, + CreatePackageConfigRequestSchema, + UpdatePackageConfigRequestSchema, + DeletePackageConfigsRequestSchema, +} from '../../types'; +import { + getPackageConfigsHandler, + getOnePackageConfigHandler, + createPackageConfigHandler, + updatePackageConfigHandler, + deletePackageConfigHandler, +} from './handlers'; + +export const registerRoutes = (router: IRouter) => { + // List + router.get( + { + path: PACKAGE_CONFIG_API_ROUTES.LIST_PATTERN, + validate: GetPackageConfigsRequestSchema, + options: { tags: [`access:${PLUGIN_ID}-read`] }, + }, + getPackageConfigsHandler + ); + + // Get one + router.get( + { + path: PACKAGE_CONFIG_API_ROUTES.INFO_PATTERN, + validate: GetOnePackageConfigRequestSchema, + options: { tags: [`access:${PLUGIN_ID}-read`] }, + }, + getOnePackageConfigHandler + ); + + // Create + router.post( + { + path: PACKAGE_CONFIG_API_ROUTES.CREATE_PATTERN, + validate: CreatePackageConfigRequestSchema, + options: { tags: [`access:${PLUGIN_ID}-all`] }, + }, + createPackageConfigHandler + ); + + // Update + router.put( + { + path: PACKAGE_CONFIG_API_ROUTES.UPDATE_PATTERN, + validate: UpdatePackageConfigRequestSchema, + options: { tags: [`access:${PLUGIN_ID}-all`] }, + }, + updatePackageConfigHandler + ); + + // Delete + router.post( + { + path: PACKAGE_CONFIG_API_ROUTES.DELETE_PATTERN, + validate: DeletePackageConfigsRequestSchema, + options: { tags: [`access:${PLUGIN_ID}`] }, + }, + deletePackageConfigHandler + ); +}; 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 1d412937e244f..98de9ac217af9 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, @@ -122,20 +121,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' }, updated_at: { type: 'date' }, updated_by: { type: 'keyword' }, revision: { type: 'integer' }, monitoring_enabled: { type: 'keyword', index: false }, }, }, - migrations: { - '7.9.0': migrateAgentConfigToV790, - }, }, [ENROLLMENT_API_KEYS_SAVED_OBJECT_TYPE]: { name: ENROLLMENT_API_KEYS_SAVED_OBJECT_TYPE, @@ -178,8 +174,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,8 +186,9 @@ const savedObjectTypes: { [key: string]: SavedObjectsType } = { name: { type: 'keyword' }, description: { type: 'text' }, namespace: { type: 'keyword' }, - config_id: { type: 'keyword' }, enabled: { type: 'boolean' }, + config_id: { type: 'keyword' }, + output_id: { type: 'keyword' }, package: { properties: { name: { type: 'keyword' }, @@ -199,16 +196,14 @@ const savedObjectTypes: { [key: string]: SavedObjectsType } = { version: { type: 'keyword' }, }, }, - output_id: { type: 'keyword' }, inputs: { type: 'nested', enabled: false, properties: { type: { type: 'keyword' }, enabled: { type: 'boolean' }, - processors: { type: 'keyword' }, - config: { type: 'flattened' }, vars: { type: 'flattened' }, + config: { type: 'flattened' }, streams: { type: 'nested', properties: { @@ -220,10 +215,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' }, }, }, }, @@ -235,9 +229,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/agent_config.ts b/x-pack/plugins/ingest_manager/server/services/agent_config.ts index 9c27e9b7a3a7a..ada35d1825069 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, @@ -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,11 +128,11 @@ class AgentConfigService { const agentConfig = { id: agentConfigSO.id, ...agentConfigSO.attributes }; - if (withDatasources) { - agentConfig.datasources = - (await datasourceService.getByIDs( + if (withPackageConfigs) { + agentConfig.package_configs = + (await packageConfigService.getByIDs( soClient, - (agentConfigSO.attributes.datasources as string[]) || [] + (agentConfigSO.attributes.package_configs as string[]) || [] )) || []; } @@ -200,15 +200,20 @@ class AgentConfigService { options ); - // Copy all datasources - if (baseAgentConfig.datasources.length) { - const newDatasources = (baseAgentConfig.datasources as Datasource[]).map( - (datasource: Datasource) => { - const { id: datasourceId, ...newDatasource } = datasource; - return newDatasource; + // Copy all package configs + if (baseAgentConfig.package_configs.length) { + 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); @@ -244,18 +249,18 @@ class AgentConfigService { soClient, id, { - datasources: uniq( - [...((oldAgentConfig.datasources || []) as string[])].concat(datasourceIds) + package_configs: uniq( + [...((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); @@ -269,9 +274,9 @@ class AgentConfigService { id, { ...oldAgentConfig, - datasources: uniq( - [...((oldAgentConfig.datasources || []) as string[])].filter( - (dsId) => !datasourceIds.includes(dsId) + package_configs: uniq( + [...((oldAgentConfig.package_configs || []) as string[])].filter( + (pkgConfigId) => !packageConfigIds.includes(pkgConfigId) ) ), }, @@ -318,8 +323,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 packageConfigService.delete(soClient, config.package_configs as string[], { skipUnassignFromAgentConfigs: true, }); } @@ -373,7 +378,7 @@ class AgentConfigService { {} as FullAgentConfig['outputs'] ), }, - inputs: storedDatasourcesToAgentInputs(config.datasources as Datasource[]), + 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/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/epm/packages/remove.ts b/x-pack/plugins/ingest_manager/server/services/epm/packages/remove.ts index 9b506a2d055a7..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 @@ -6,12 +6,12 @@ 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'; import { installIndexPatterns } from '../kibana/index_pattern/install'; -import { datasourceService } from '../..'; +import { packageConfigService } from '../..'; export async function removeInstallation(options: { savedObjectsClient: SavedObjectsClientContract; @@ -27,15 +27,15 @@ 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, { - kuery: `${DATASOURCE_SAVED_OBJECT_TYPE}.package.name:${pkgName}`, + const { total } = await packageConfigService.list(savedObjectsClient, { + kuery: `${PACKAGE_CONFIG_SAVED_OBJECT_TYPE}.package.name:${pkgName}`, page: 0, perPage: 0, }); 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 502f28a97bb2d..9e198debbb904 100644 --- a/x-pack/plugins/ingest_manager/server/services/index.ts +++ b/x-pack/plugins/ingest_manager/server/services/index.ts @@ -60,8 +60,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 92% 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 8d98e41c8ae69..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: [ { @@ -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', @@ -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: [ { @@ -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/package_config.ts similarity index 67% rename from x-pack/plugins/ingest_manager/server/services/datasource.ts rename to x-pack/plugins/ingest_manager/server/services/package_config.ts index fecec0c463459..c886f4868ad30 100644 --- a/x-pack/plugins/ingest_manager/server/services/datasource.ts +++ b/x-pack/plugins/ingest_manager/server/services/package_config.ts @@ -6,18 +6,18 @@ import { SavedObjectsClientContract } from 'src/core/server'; import { AuthenticatedUser } from '../../../security/server'; import { - DeleteDatasourcesResponse, - packageToConfigDatasource, - DatasourceInput, - DatasourceInputStream, + DeletePackageConfigsResponse, + packageToPackageConfig, + PackageConfigInput, + PackageConfigInputStream, PackageInfo, } from '../../common'; -import { DATASOURCE_SAVED_OBJECT_TYPE } from '../constants'; +import { PACKAGE_CONFIG_SAVED_OBJECT_TYPE } from '../constants'; import { - NewDatasource, - Datasource, + NewPackageConfig, + PackageConfig, ListWithKuery, - DatasourceSOAttributes, + PackageConfigSOAttributes, RegistryPackage, } from '../types'; import { agentConfigService } from './agent_config'; @@ -27,23 +27,23 @@ 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]; } -class DatasourceService { +class PackageConfigService { public async create( soClient: SavedObjectsClientContract, - datasource: NewDatasource, + packageConfig: 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, + ...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: NewDatasource[], + packageConfigs: NewPackageConfig[], configId: string, options?: { user?: AuthenticatedUser } - ): Promise { + ): Promise { const isoDate = new Date().toISOString(); - const { saved_objects: newSos } = await soClient.bulkCreate>( - datasources.map((datasource) => ({ + const { saved_objects: newSos } = await soClient.bulkCreate>( + 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), @@ -102,37 +102,40 @@ class DatasourceService { })); } - public async get(soClient: SavedObjectsClientContract, id: string): Promise { - const datasourceSO = await soClient.get(SAVED_OBJECT_TYPE, id); - if (!datasourceSO) { + public async get( + soClient: SavedObjectsClientContract, + id: string + ): Promise { + 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, }; } public async getByIDs( soClient: SavedObjectsClientContract, ids: string[] - ): Promise { - const datasourceSO = await soClient.bulkGet( + ): Promise { + 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, })); @@ -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 packageConfigs = await soClient.find({ type: SAVED_OBJECT_TYPE, page, perPage, @@ -158,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, }; @@ -171,46 +174,48 @@ class DatasourceService { public async update( soClient: SavedObjectsClientContract, id: string, - datasource: NewDatasource, + packageConfig: NewPackageConfig, options?: { user?: AuthenticatedUser } - ): Promise { - const oldDatasource = await this.get(soClient, id); + ): Promise { + 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, + await soClient.update(SAVED_OBJECT_TYPE, id, { + ...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 Datasource; + return (await this.get(soClient, id)) as PackageConfig; } public async delete( soClient: SavedObjectsClientContract, ids: string[], options?: { user?: AuthenticatedUser; skipUnassignFromAgentConfigs?: boolean } - ): Promise { - const result: DeleteDatasourcesResponse = []; + ): Promise { + const result: DeletePackageConfigsResponse = []; 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, } @@ -232,10 +237,10 @@ class DatasourceService { return result; } - public async buildDatasourceFromPackage( + public async buildPackageConfigFromPackage( soClient: SavedObjectsClientContract, pkgName: string - ): Promise { + ): Promise { const pkgInstall = await getInstallation({ savedObjectsClient: soClient, pkgName }); if (pkgInstall) { const [pkgInfo, defaultOutputId] = await Promise.all([ @@ -250,15 +255,15 @@ class DatasourceService { if (!defaultOutputId) { throw new Error('Default output is not set'); } - return packageToConfigDatasource(pkgInfo, '', defaultOutputId); + return packageToPackageConfig(pkgInfo, '', defaultOutputId); } } } 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 +276,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,11 +289,11 @@ 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 }; + return { ...stream, compiled_stream: undefined }; } const datasetPath = getDataset(stream.dataset.name); const packageDatasets = pkgInfo.datasets; @@ -332,10 +337,10 @@ async function _assignPackageStreamToStream( pkgStream.buffer.toString() ); - stream.agent_stream = yaml; + stream.compiled_stream = yaml; 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 9cf1e5b368385..61e1d0ad94db8 100644 --- a/x-pack/plugins/ingest_manager/server/services/setup.ts +++ b/x-pack/plugins/ingest_manager/server/services/setup.ts @@ -13,8 +13,8 @@ import { outputService } from './output'; import { ensureInstalledDefaultPackages } from './epm/packages/install'; import { ensureDefaultIndices } from './epm/kibana/index_pattern/install'; import { - packageToConfigDatasource, - Datasource, + packageToPackageConfig, + PackageConfig, AgentConfig, Installation, Output, @@ -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'; @@ -86,13 +86,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.datasources.length && - typeof configWithDatasource.datasources[0] === 'string' + configWithPackageConfigs.package_configs.length && + typeof configWithPackageConfigs.package_configs[0] === 'string' ) { throw new Error('Config not found'); } @@ -104,11 +104,19 @@ export async function setupIngestManager( continue; } - const isInstalled = configWithDatasource.datasources.some((d: Datasource | 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 + ); } } @@ -194,17 +202,16 @@ async function addPackageToConfig( pkgVersion: packageToInstall.version, }); - const newDatasource = packageToConfigDatasource( + const newPackageConfig = packageToPackageConfig( packageInfo, config.id, defaultOutput.id, - undefined, 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/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/ingest_manager/server/types/models/agent_config.ts b/x-pack/plugins/ingest_manager/server/types/models/agent_config.ts index ee91813a48e2f..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 @@ -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,10 @@ export const AgentConfigSchema = schema.object({ schema.literal(AgentConfigStatus.Active), schema.literal(AgentConfigStatus.Inactive), ]), - datasources: schema.oneOf([schema.arrayOf(schema.string()), schema.arrayOf(DatasourceSchema)]), + 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/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 84% 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..4b9718dfbe165 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 }), @@ -31,7 +31,6 @@ const DatasourceBaseSchema = { 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 DatasourceBaseSchema = { 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( @@ -64,11 +62,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/datasource.ts b/x-pack/plugins/ingest_manager/server/types/rest_spec/datasource.ts deleted file mode 100644 index fce2c94b282bd..0000000000000 --- a/x-pack/plugins/ingest_manager/server/types/rest_spec/datasource.ts +++ /dev/null @@ -1,33 +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 { schema } from '@kbn/config-schema'; -import { NewDatasourceSchema } from '../models'; -import { ListWithKuerySchema } from './index'; - -export const GetDatasourcesRequestSchema = { - query: ListWithKuerySchema, -}; - -export const GetOneDatasourceRequestSchema = { - params: schema.object({ - datasourceId: schema.string(), - }), -}; - -export const CreateDatasourceRequestSchema = { - body: NewDatasourceSchema, -}; - -export const UpdateDatasourceRequestSchema = { - ...GetOneDatasourceRequestSchema, - body: NewDatasourceSchema, -}; - -export const DeleteDatasourcesRequestSchema = { - body: schema.object({ - datasourceIds: schema.arrayOf(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/package_config.ts b/x-pack/plugins/ingest_manager/server/types/rest_spec/package_config.ts new file mode 100644 index 0000000000000..7b7ae1957c15e --- /dev/null +++ b/x-pack/plugins/ingest_manager/server/types/rest_spec/package_config.ts @@ -0,0 +1,33 @@ +/* + * 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 { schema } from '@kbn/config-schema'; +import { NewPackageConfigSchema } from '../models'; +import { ListWithKuerySchema } from './index'; + +export const GetPackageConfigsRequestSchema = { + query: ListWithKuerySchema, +}; + +export const GetOnePackageConfigRequestSchema = { + params: schema.object({ + packageConfigId: schema.string(), + }), +}; + +export const CreatePackageConfigRequestSchema = { + body: NewPackageConfigSchema, +}; + +export const UpdatePackageConfigRequestSchema = { + ...GetOnePackageConfigRequestSchema, + body: NewPackageConfigSchema, +}; + +export const DeletePackageConfigsRequestSchema = { + body: schema.object({ + packageConfigIds: schema.arrayOf(schema.string()), + }), +}; 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/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/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: `${DATASOURCE_SAVED_OBJECT_TYPE}.package.name: endpoint`, + kuery: `${PACKAGE_CONFIG_SAVED_OBJECT_TYPE}.package.name: endpoint`, page: 1, perPage: 10, }, @@ -188,9 +188,9 @@ 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: `${DATASOURCE_SAVED_OBJECT_TYPE}.package.name: endpoint`, + kuery: `${PACKAGE_CONFIG_SAVED_OBJECT_TYPE}.package.name: endpoint`, page: 1, perPage: 50, }, @@ -211,9 +211,9 @@ 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: `${DATASOURCE_SAVED_OBJECT_TYPE}.package.name: endpoint`, + kuery: `${PACKAGE_CONFIG_SAVED_OBJECT_TYPE}.package.name: endpoint`, page: 1, perPage: 10, }, @@ -222,9 +222,9 @@ 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: `${DATASOURCE_SAVED_OBJECT_TYPE}.package.name: endpoint`, + kuery: `${PACKAGE_CONFIG_SAVED_OBJECT_TYPE}.package.name: endpoint`, page: 1, perPage: 10, }, @@ -233,9 +233,9 @@ 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: `${DATASOURCE_SAVED_OBJECT_TYPE}.package.name: endpoint`, + kuery: `${PACKAGE_CONFIG_SAVED_OBJECT_TYPE}.package.name: endpoint`, page: 11, perPage: 10, }, @@ -262,9 +262,9 @@ 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: `${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/middleware.ts b/x-pack/plugins/security_solution/public/management/pages/policy/store/policy_list/middleware.ts index 7d8620a5831d0..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'; @@ -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'; @@ -56,7 +56,7 @@ export const policyListMiddlewareFactory: ImmutableMiddlewareFactory { @@ -21,22 +21,22 @@ describe('ingest service', () => { 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: `${DATASOURCE_SAVED_OBJECT_TYPE}.package.name: endpoint`, + 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 ${DATASOURCE_SAVED_OBJECT_TYPE}.package.name: endpoint`, + kuery: `someValueHere and ${PACKAGE_CONFIG_SAVED_OBJECT_TYPE}.package.name: endpoint`, perPage: 10, page: 1, }, @@ -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 cbdd67261739f..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 @@ -6,92 +6,92 @@ import { HttpFetchOptions, HttpStart } from 'kibana/public'; import { - GetDatasourcesRequest, + GetPackageConfigsRequest, GetAgentStatusResponse, - DeleteDatasourcesResponse, - DeleteDatasourcesRequest, - DATASOURCE_SAVED_OBJECT_TYPE, + DeletePackageConfigsResponse, + DeletePackageConfigsRequest, + PACKAGE_CONFIG_SAVED_OBJECT_TYPE, GetPackagesResponse, } from '../../../../../../../../ingest_manager/common'; import { GetPolicyListResponse, GetPolicyResponse, UpdatePolicyResponse } from '../../../types'; 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 = {} + options: HttpFetchOptions & Partial = {} ): Promise => { - return http.get(INGEST_API_DATASOURCES, { + return http.get(INGEST_API_PACKAGE_CONFIGS, { ...options, query: { ...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`, }, }); }; /** - * 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: DeleteDatasourcesRequest, + 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/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; } 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 79% 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 9b2b4b19ce55c..ebcfd3f1bb209 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,21 +10,21 @@ 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'; import { MANAGEMENT_APP_ID } from '../../../../common/constants'; /** - * 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 ( @@ -39,7 +39,7 @@ export const ConfigureEndpointDatasource = memo @@ -66,14 +66,14 @@ export const ConfigureEndpointDatasource = memo ) : ( )} @@ -85,4 +85,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(() => { @@ -77,17 +77,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, }); } @@ -132,7 +132,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(); @@ -202,9 +202,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, }); } @@ -247,7 +247,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 @@ -259,7 +259,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 5690f1381eaf3..08c6ec89ff051 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'; import { MANAGEMENT_APP_ID } from '../../../common/constants'; interface TableChangeCallbackArguments { @@ -142,16 +142,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: [MANAGEMENT_APP_ID, { path: getPoliciesPath() }], diff --git a/x-pack/plugins/security_solution/public/plugin.tsx b/x-pack/plugins/security_solution/public/plugin.tsx index 283ef8bad896b..65121327b40b9 100644 --- a/x-pack/plugins/security_solution/public/plugin.tsx +++ b/x-pack/plugins/security_solution/public/plugin.tsx @@ -43,7 +43,7 @@ import { APP_CASES_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'; @@ -317,7 +317,10 @@ export class Plugin implements IPlugin => { - // We only care about Endpoint datasources - if (newDatasource.package?.name !== 'endpoint') { - return newDatasource; +export const handlePackageConfigCreate = async ( + newPackageConfig: NewPackageConfig +): Promise => { + // 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(), }; }; diff --git a/x-pack/plugins/translations/translations/ja-JP.json b/x-pack/plugins/translations/translations/ja-JP.json index e98d7c231b763..8a732766ce761 100644 --- a/x-pack/plugins/translations/translations/ja-JP.json +++ b/x-pack/plugins/translations/translations/ja-JP.json @@ -8034,7 +8034,7 @@ "xpack.ingestManager.agentConfigList.addButton": "エージェント構成を作成", "xpack.ingestManager.agentConfigList.agentsColumnTitle": "エージェント", "xpack.ingestManager.agentConfigList.clearFiltersLinkText": "フィルターを消去", - "xpack.ingestManager.agentConfigList.datasourcesCountColumnTitle": "データソース", + "xpack.ingestManager.agentConfigList.packageConfigsCountColumnTitle": "データソース", "xpack.ingestManager.agentConfigList.descriptionColumnTitle": "説明", "xpack.ingestManager.agentConfigList.loadingAgentConfigsMessage": "エージェント構成を読み込み中...", "xpack.ingestManager.agentConfigList.nameColumnTitle": "名前", @@ -8159,28 +8159,27 @@ "xpack.ingestManager.appNavigation.sendFeedbackButton": "フィードバックを送信", "xpack.ingestManager.appNavigation.settingsButton": "設定", "xpack.ingestManager.appTitle": "Ingest Manager", - "xpack.ingestManager.configDetails.addDatasourceButtonText": "データソースを作成", + "xpack.ingestManager.configDetails.addPackageConfigButtonText": "データソースを作成", "xpack.ingestManager.configDetails.configDetailsTitle": "構成「{id}」", "xpack.ingestManager.configDetails.configNotFoundErrorTitle": "構成「{id}」が見つかりません", - "xpack.ingestManager.configDetails.datasourcesTable.actionsColumnTitle": "アクション", - "xpack.ingestManager.configDetails.datasourcesTable.deleteActionTitle": "データソースを削除", - "xpack.ingestManager.configDetails.datasourcesTable.descriptionColumnTitle": "説明", - "xpack.ingestManager.configDetails.datasourcesTable.editActionTitle": "データソースを編集", - "xpack.ingestManager.configDetails.datasourcesTable.nameColumnTitle": "データソース", - "xpack.ingestManager.configDetails.datasourcesTable.namespaceColumnTitle": "名前空間", - "xpack.ingestManager.configDetails.datasourcesTable.packageNameColumnTitle": "統合", - "xpack.ingestManager.configDetails.datasourcesTable.streamsCountColumnTitle": "ストリーム", - "xpack.ingestManager.configDetails.subTabs.datasourcesTabText": "データソース", + "xpack.ingestManager.configDetails.packageConfigsTable.actionsColumnTitle": "アクション", + "xpack.ingestManager.configDetails.packageConfigsTable.deleteActionTitle": "データソースを削除", + "xpack.ingestManager.configDetails.packageConfigsTable.descriptionColumnTitle": "説明", + "xpack.ingestManager.configDetails.packageConfigsTable.editActionTitle": "データソースを編集", + "xpack.ingestManager.configDetails.packageConfigsTable.nameColumnTitle": "データソース", + "xpack.ingestManager.configDetails.packageConfigsTable.namespaceColumnTitle": "名前空間", + "xpack.ingestManager.configDetails.packageConfigsTable.packageNameColumnTitle": "統合", + "xpack.ingestManager.configDetails.packageConfigsTable.streamsCountColumnTitle": "ストリーム", + "xpack.ingestManager.configDetails.subTabs.packageConfigsTabText": "データソース", "xpack.ingestManager.configDetails.subTabs.settingsTabText": "設定", - "xpack.ingestManager.configDetails.summary.datasources": "データソース", "xpack.ingestManager.configDetails.summary.lastUpdated": "最終更新日:", "xpack.ingestManager.configDetails.summary.revision": "リビジョン", "xpack.ingestManager.configDetails.summary.usedBy": "使用者", "xpack.ingestManager.configDetails.unexceptedErrorTitle": "構成を読み込む間にエラーが発生しました", "xpack.ingestManager.configDetails.viewAgentListTitle": "すべてのエージェント構成を表示", - "xpack.ingestManager.configDetailsDatasources.createFirstButtonText": "データソースを作成", - "xpack.ingestManager.configDetailsDatasources.createFirstMessage": "この構成にはデータソースはまだありません。", - "xpack.ingestManager.configDetailsDatasources.createFirstTitle": "初めてのデーソースを作成する", + "xpack.ingestManager.configDetailsPackageConfigs.createFirstButtonText": "データソースを作成", + "xpack.ingestManager.configDetailsPackageConfigs.createFirstMessage": "この構成にはデータソースはまだありません。", + "xpack.ingestManager.configDetailsPackageConfigs.createFirstTitle": "初めてのデーソースを作成する", "xpack.ingestManager.configForm.deleteConfigActionText": "構成を削除", "xpack.ingestManager.configForm.deleteConfigGroupDescription": "既存のデータは削除されません。", "xpack.ingestManager.configForm.deleteConfigGroupTitle": "構成を削除", @@ -8193,50 +8192,50 @@ "xpack.ingestManager.createAgentConfig.flyoutTitleDescription": "エージェント構成は、エージェントのグループ全体にわたる設定を管理する目的で使用されます。エージェント構成にデータソースを追加すると、エージェントで収集するデータを指定できます。エージェント構成の編集時には、フリートを使用して、指定したエージェントのグループに更新をデプロイできます。", "xpack.ingestManager.createAgentConfig.submitButtonLabel": "エージェント構成を作成", "xpack.ingestManager.createAgentConfig.successNotificationTitle": "エージェント構成「{name}」を作成しました", - "xpack.ingestManager.createDatasource.addedNotificationMessage": "フリートは'{agentConfigName}'構成で使用されているすべてのエージェントに更新をデプロイします。", - "xpack.ingestManager.createDatasource.addedNotificationTitle": "正常に'{datasourceName}'を追加しました", - "xpack.ingestManager.createDatasource.agentConfigurationNameLabel": "構成", - "xpack.ingestManager.createDatasource.cancelButton": "キャンセル", - "xpack.ingestManager.createDatasource.cancelLinkText": "キャンセル", - "xpack.ingestManager.createDatasource.packageNameLabel": "統合", - "xpack.ingestManager.createDatasource.pageDescriptionfromConfig": "次の手順に従い、統合をこのエージェント構成に追加します。", - "xpack.ingestManager.createDatasource.pageDescriptionfromPackage": "次の手順に従い、この統合をエージェント構成に追加します。", - "xpack.ingestManager.createDatasource.pageTitle": "データソースを追加", - "xpack.ingestManager.createDatasource.saveButton": "データソースを保存", - "xpack.ingestManager.createDatasource.stepConfgiureDatasourceTitle": "収集するデータを選択", - "xpack.ingestManager.createDatasource.stepConfigure.advancedOptionsToggleLinkText": "高度なオプション", - "xpack.ingestManager.createDatasource.stepConfigure.datasourceDescriptionInputLabel": "説明", - "xpack.ingestManager.createDatasource.stepConfigure.datasourceNameInputLabel": "データソース名", - "xpack.ingestManager.createDatasource.stepConfigure.datasourceNamespaceInputLabel": "名前空間", - "xpack.ingestManager.createDatasource.stepConfigure.hideStreamsAriaLabel": "{type} ストリームを隠す", - "xpack.ingestManager.createDatasource.stepConfigure.inputConfigErrorsTooltip": "構成エラーを修正してください", - "xpack.ingestManager.createDatasource.stepConfigure.inputLevelErrorsTooltip": "構成エラーを修正してください", - "xpack.ingestManager.createDatasource.stepConfigure.inputSettingsDescription": "次の設定はすべてのストリームに適用されます。", - "xpack.ingestManager.createDatasource.stepConfigure.inputSettingsTitle": "設定", - "xpack.ingestManager.createDatasource.stepConfigure.inputVarFieldOptionalLabel": "オプション", - "xpack.ingestManager.createDatasource.stepConfigure.noConfigOptionsMessage": "構成するものがありません", - "xpack.ingestManager.createDatasource.stepConfigure.showStreamsAriaLabel": "{type} ストリームを表示", - "xpack.ingestManager.createDatasource.stepConfigure.streamLevelErrorsTooltip": "構成エラーを修正してください", - "xpack.ingestManager.createDatasource.stepConfigure.streamsEnabledCountText": "{count} / {total, plural, one {# ストリーム} other {# ストリーム}}が有効です", - "xpack.ingestManager.createDatasource.stepConfigure.toggleAdvancedOptionsButtonText": "高度なオプション", - "xpack.ingestManager.createDatasource.stepConfigure.validationErrorText": "続行する前に、上記のエラーを修正してください", - "xpack.ingestManager.createDatasource.stepConfigure.validationErrorTitle": "データソース構成にエラーがあります", - "xpack.ingestManager.createDatasource.stepDefineDatasourceTitle": "データソースを定義", - "xpack.ingestManager.createDatasource.stepSelectAgentConfigTitle": "エージェント構成を選択する", - "xpack.ingestManager.createDatasource.StepSelectConfig.agentConfigAgentsCountText": "{count, plural, one {# エージェント} other {# エージェント}}", - "xpack.ingestManager.createDatasource.StepSelectConfig.errorLoadingAgentConfigsTitle": "エージェント構成の読み込みエラー", - "xpack.ingestManager.createDatasource.StepSelectConfig.errorLoadingPackageTitle": "パッケージ情報の読み込みエラー", - "xpack.ingestManager.createDatasource.StepSelectConfig.errorLoadingSelectedAgentConfigTitle": "選択したエージェント構成の読み込みエラー", - "xpack.ingestManager.createDatasource.StepSelectConfig.filterAgentConfigsInputPlaceholder": "エージェント構成の検索", - "xpack.ingestManager.createDatasource.stepSelectPackage.errorLoadingConfigTitle": "エージェント構成情報の読み込みエラー", - "xpack.ingestManager.createDatasource.stepSelectPackage.errorLoadingPackagesTitle": "統合の読み込みエラー", - "xpack.ingestManager.createDatasource.stepSelectPackage.errorLoadingSelectedPackageTitle": "選択した統合の読み込みエラー", - "xpack.ingestManager.createDatasource.stepSelectPackage.filterPackagesInputPlaceholder": "統合を検索", - "xpack.ingestManager.createDatasource.stepSelectPackageTitle": "統合を選択", - "xpack.ingestManager.datasourceValidation.invalidArrayErrorMessage": "無効なフォーマット", - "xpack.ingestManager.datasourceValidation.invalidYamlFormatErrorMessage": "YAML形式が無効です", - "xpack.ingestManager.datasourceValidation.nameRequiredErrorMessage": "名前が必要です", - "xpack.ingestManager.datasourceValidation.requiredErrorMessage": "{fieldName}が必要です", + "xpack.ingestManager.createPackageConfig.addedNotificationMessage": "フリートは'{agentConfigName}'構成で使用されているすべてのエージェントに更新をデプロイします。", + "xpack.ingestManager.createPackageConfig.addedNotificationTitle": "正常に'{packageConfigName}'を追加しました", + "xpack.ingestManager.createPackageConfig.agentConfigurationNameLabel": "構成", + "xpack.ingestManager.createPackageConfig.cancelButton": "キャンセル", + "xpack.ingestManager.createPackageConfig.cancelLinkText": "キャンセル", + "xpack.ingestManager.createPackageConfig.packageNameLabel": "統合", + "xpack.ingestManager.createPackageConfig.pageDescriptionfromConfig": "次の手順に従い、統合をこのエージェント構成に追加します。", + "xpack.ingestManager.createPackageConfig.pageDescriptionfromPackage": "次の手順に従い、この統合をエージェント構成に追加します。", + "xpack.ingestManager.createPackageConfig.pageTitle": "データソースを追加", + "xpack.ingestManager.createPackageConfig.saveButton": "データソースを保存", + "xpack.ingestManager.createPackageConfig.stepConfigurePackageConfigTitle": "収集するデータを選択", + "xpack.ingestManager.createPackageConfig.stepConfigure.advancedOptionsToggleLinkText": "高度なオプション", + "xpack.ingestManager.createPackageConfig.stepConfigure.packageConfigDescriptionInputLabel": "説明", + "xpack.ingestManager.createPackageConfig.stepConfigure.packageConfigNameInputLabel": "データソース名", + "xpack.ingestManager.createPackageConfig.stepConfigure.packageConfigNamespaceInputLabel": "名前空間", + "xpack.ingestManager.createPackageConfig.stepConfigure.hideStreamsAriaLabel": "{type} ストリームを隠す", + "xpack.ingestManager.createPackageConfig.stepConfigure.inputConfigErrorsTooltip": "構成エラーを修正してください", + "xpack.ingestManager.createPackageConfig.stepConfigure.inputLevelErrorsTooltip": "構成エラーを修正してください", + "xpack.ingestManager.createPackageConfig.stepConfigure.inputSettingsDescription": "次の設定はすべてのストリームに適用されます。", + "xpack.ingestManager.createPackageConfig.stepConfigure.inputSettingsTitle": "設定", + "xpack.ingestManager.createPackageConfig.stepConfigure.inputVarFieldOptionalLabel": "オプション", + "xpack.ingestManager.createPackageConfig.stepConfigure.noConfigOptionsMessage": "構成するものがありません", + "xpack.ingestManager.createPackageConfig.stepConfigure.showStreamsAriaLabel": "{type} ストリームを表示", + "xpack.ingestManager.createPackageConfig.stepConfigure.streamLevelErrorsTooltip": "構成エラーを修正してください", + "xpack.ingestManager.createPackageConfig.stepConfigure.streamsEnabledCountText": "{count} / {total, plural, one {# ストリーム} other {# ストリーム}}が有効です", + "xpack.ingestManager.createPackageConfig.stepConfigure.toggleAdvancedOptionsButtonText": "高度なオプション", + "xpack.ingestManager.createPackageConfig.stepConfigure.validationErrorText": "続行する前に、上記のエラーを修正してください", + "xpack.ingestManager.createPackageConfig.stepConfigure.validationErrorTitle": "データソース構成にエラーがあります", + "xpack.ingestManager.createPackageConfig.stepDefinePackageConfigTitle": "データソースを定義", + "xpack.ingestManager.createPackageConfig.stepSelectAgentConfigTitle": "エージェント構成を選択する", + "xpack.ingestManager.createPackageConfig.StepSelectConfig.agentConfigAgentsCountText": "{count, plural, one {# エージェント} other {# エージェント}}", + "xpack.ingestManager.createPackageConfig.StepSelectConfig.errorLoadingAgentConfigsTitle": "エージェント構成の読み込みエラー", + "xpack.ingestManager.createPackageConfig.StepSelectConfig.errorLoadingPackageTitle": "パッケージ情報の読み込みエラー", + "xpack.ingestManager.createPackageConfig.StepSelectConfig.errorLoadingSelectedAgentConfigTitle": "選択したエージェント構成の読み込みエラー", + "xpack.ingestManager.createPackageConfig.StepSelectConfig.filterAgentConfigsInputPlaceholder": "エージェント構成の検索", + "xpack.ingestManager.createPackageConfig.stepSelectPackage.errorLoadingConfigTitle": "エージェント構成情報の読み込みエラー", + "xpack.ingestManager.createPackageConfig.stepSelectPackage.errorLoadingPackagesTitle": "統合の読み込みエラー", + "xpack.ingestManager.createPackageConfig.stepSelectPackage.errorLoadingSelectedPackageTitle": "選択した統合の読み込みエラー", + "xpack.ingestManager.createPackageConfig.stepSelectPackage.filterPackagesInputPlaceholder": "統合を検索", + "xpack.ingestManager.createPackageConfig.stepSelectPackageTitle": "統合を選択", + "xpack.ingestManager.packageConfigValidation.invalidArrayErrorMessage": "無効なフォーマット", + "xpack.ingestManager.packageConfigValidation.invalidYamlFormatErrorMessage": "YAML形式が無効です", + "xpack.ingestManager.packageConfigValidation.nameRequiredErrorMessage": "名前が必要です", + "xpack.ingestManager.packageConfigValidation.requiredErrorMessage": "{fieldName}が必要です", "xpack.ingestManager.dataStreamList.actionsColumnTitle": "アクション", "xpack.ingestManager.dataStreamList.datasetColumnTitle": "データセット", "xpack.ingestManager.dataStreamList.integrationColumnTitle": "統合", @@ -8266,19 +8265,19 @@ "xpack.ingestManager.deleteAgentConfig.failureSingleNotificationTitle": "エージェント構成「{id}」の削除エラー", "xpack.ingestManager.deleteAgentConfig.fatalErrorNotificationTitle": "エージェント構成の削除エラー", "xpack.ingestManager.deleteAgentConfig.successSingleNotificationTitle": "エージェント構成「{id}」を削除しました", - "xpack.ingestManager.deleteDatasource.confirmModal.affectedAgentsMessage": "{agentConfigName} が一部のエージェントで既に使用されていることをフリートが検出しました。", - "xpack.ingestManager.deleteDatasource.confirmModal.affectedAgentsTitle": "このアクションは {agentsCount} {agentsCount, plural, one {# エージェント} other {# エージェント}}に影響します", - "xpack.ingestManager.deleteDatasource.confirmModal.cancelButtonLabel": "キャンセル", - "xpack.ingestManager.deleteDatasource.confirmModal.confirmButtonLabel": "{agentConfigsCount, plural, one {データソース} other {データソース}} を削除", - "xpack.ingestManager.deleteDatasource.confirmModal.deleteMultipleTitle": "{count, plural, one {データソース} other {# データソース}} を削除しますか?", - "xpack.ingestManager.deleteDatasource.confirmModal.generalMessage": "このアクションは元に戻せません。続行していいですか?", - "xpack.ingestManager.deleteDatasource.confirmModal.loadingAgentsCountMessage": "影響があるエージェントを確認中...", - "xpack.ingestManager.deleteDatasource.confirmModal.loadingButtonLabel": "読み込み中...", - "xpack.ingestManager.deleteDatasource.failureMultipleNotificationTitle": "{count} 件のデータソースの削除エラー", - "xpack.ingestManager.deleteDatasource.failureSingleNotificationTitle": "データソース「{id}」の削除エラー", - "xpack.ingestManager.deleteDatasource.fatalErrorNotificationTitle": "データソースの削除エラー", - "xpack.ingestManager.deleteDatasource.successMultipleNotificationTitle": "{count} 件のデータソースを削除しました", - "xpack.ingestManager.deleteDatasource.successSingleNotificationTitle": "データソース「{id}」を削除しました", + "xpack.ingestManager.deletePackageConfig.confirmModal.affectedAgentsMessage": "{agentConfigName} が一部のエージェントで既に使用されていることをフリートが検出しました。", + "xpack.ingestManager.deletePackageConfig.confirmModal.affectedAgentsTitle": "このアクションは {agentsCount} {agentsCount, plural, one {# エージェント} other {# エージェント}}に影響します", + "xpack.ingestManager.deletePackageConfig.confirmModal.cancelButtonLabel": "キャンセル", + "xpack.ingestManager.deletePackageConfig.confirmModal.confirmButtonLabel": "{agentConfigsCount, plural, one {データソース} other {データソース}} を削除", + "xpack.ingestManager.deletePackageConfig.confirmModal.deleteMultipleTitle": "{count, plural, one {データソース} other {# データソース}} を削除しますか?", + "xpack.ingestManager.deletePackageConfig.confirmModal.generalMessage": "このアクションは元に戻せません。続行していいですか?", + "xpack.ingestManager.deletePackageConfig.confirmModal.loadingAgentsCountMessage": "影響があるエージェントを確認中...", + "xpack.ingestManager.deletePackageConfig.confirmModal.loadingButtonLabel": "読み込み中...", + "xpack.ingestManager.deletePackageConfig.failureMultipleNotificationTitle": "{count} 件のデータソースの削除エラー", + "xpack.ingestManager.deletePackageConfig.failureSingleNotificationTitle": "データソース「{id}」の削除エラー", + "xpack.ingestManager.deletePackageConfig.fatalErrorNotificationTitle": "データソースの削除エラー", + "xpack.ingestManager.deletePackageConfig.successMultipleNotificationTitle": "{count} 件のデータソースを削除しました", + "xpack.ingestManager.deletePackageConfig.successSingleNotificationTitle": "データソース「{id}」を削除しました", "xpack.ingestManager.disabledSecurityDescription": "Elastic Fleet を使用するには、Kibana と Elasticsearch でセキュリティを有効にする必要があります。", "xpack.ingestManager.disabledSecurityTitle": "セキュリティが有効ではありません", "xpack.ingestManager.editAgentConfig.cancelButtonText": "キャンセル", @@ -8287,16 +8286,16 @@ "xpack.ingestManager.editAgentConfig.savingButtonText": "保存中…", "xpack.ingestManager.editAgentConfig.successNotificationTitle": "正常に'{name}'設定を更新しました", "xpack.ingestManager.editAgentConfig.unsavedChangesText": "保存されていない変更があります", - "xpack.ingestManager.editDatasource.cancelButton": "キャンセル", - "xpack.ingestManager.editDatasource.errorLoadingDataMessage": "このデータソース情報の読み込みエラーが発生しました", - "xpack.ingestManager.editDatasource.errorLoadingDataTitle": "データの読み込み中にエラーが発生", - "xpack.ingestManager.editDatasource.pageDescription": "次の手順に従い、このデータソースを編集します。", - "xpack.ingestManager.editDatasource.pageTitle": "データソースを編集", - "xpack.ingestManager.editDatasource.saveButton": "データソースを保存", - "xpack.ingestManager.editDatasource.stepConfgiureDatasourceTitle": "収集するデータを選択", - "xpack.ingestManager.editDatasource.stepDefineDatasourceTitle": "データソースを定義", - "xpack.ingestManager.editDatasource.updatedNotificationMessage": "フリートは'{agentConfigName}'構成で使用されているすべてのエージェントに更新をデプロイします。", - "xpack.ingestManager.editDatasource.updatedNotificationTitle": "正常に'{datasourceName}'を更新しました", + "xpack.ingestManager.editPackageConfig.cancelButton": "キャンセル", + "xpack.ingestManager.editPackageConfig.errorLoadingDataMessage": "このデータソース情報の読み込みエラーが発生しました", + "xpack.ingestManager.editPackageConfig.errorLoadingDataTitle": "データの読み込み中にエラーが発生", + "xpack.ingestManager.editPackageConfig.pageDescription": "次の手順に従い、このデータソースを編集します。", + "xpack.ingestManager.editPackageConfig.pageTitle": "データソースを編集", + "xpack.ingestManager.editPackageConfig.saveButton": "データソースを保存", + "xpack.ingestManager.editPackageConfig.stepConfigurePackageConfigTitle": "収集するデータを選択", + "xpack.ingestManager.editPackageConfig.stepDefinePackageConfigTitle": "データソースを定義", + "xpack.ingestManager.editPackageConfig.updatedNotificationMessage": "フリートは'{agentConfigName}'構成で使用されているすべてのエージェントに更新をデプロイします。", + "xpack.ingestManager.editPackageConfig.updatedNotificationTitle": "正常に'{packageConfigName}'を更新しました", "xpack.ingestManager.enrollemntAPIKeyList.emptyMessage": "登録トークンが見つかりません。", "xpack.ingestManager.enrollemntAPIKeyList.loadingTokensMessage": "登録トークンを読み込んでいます...", "xpack.ingestManager.enrollmentInstructions.copyButton": "コマンドをコピー", @@ -8319,6 +8318,9 @@ "xpack.ingestManager.enrollmentTokensList.secretTitle": "シークレット", "xpack.ingestManager.epm.browseAllButtonText": "すべての統合を参照", "xpack.ingestManager.epm.illustrationAltText": "Elastic統合の例", + "xpack.ingestManager.epm.packageDetailsNav.packageConfigsLinkText": "データソース", + "xpack.ingestManager.epm.packageDetailsNav.overviewLinkText": "概要", + "xpack.ingestManager.epm.packageDetailsNav.settingsLinkText": "設定", "xpack.ingestManager.epm.pageSubtitle": "一般的なアプリやサービスの統合を参照する", "xpack.ingestManager.epm.pageTitle": "Elastic統合", "xpack.ingestManager.epmList.allFilterLinkText": "すべて", @@ -8391,7 +8393,7 @@ "xpack.ingestManager.overviewAgentOfflineTitle": "オフライン", "xpack.ingestManager.overviewAgentTotalTitle": "合計エージェント数", "xpack.ingestManager.overviewConfigTotalTitle": "合計構成数", - "xpack.ingestManager.overviewDatasourceTitle": "データソース", + "xpack.ingestManager.overviewPackageConfigTitle": "データソース", "xpack.ingestManager.overviewDatastreamNamespacesTitle": "名前空間", "xpack.ingestManager.overviewDatastreamSizeTitle": "合計サイズ", "xpack.ingestManager.overviewDatastreamTotalTitle": "データストリーム", diff --git a/x-pack/plugins/translations/translations/zh-CN.json b/x-pack/plugins/translations/translations/zh-CN.json index dfba168416190..daa8ffa598546 100644 --- a/x-pack/plugins/translations/translations/zh-CN.json +++ b/x-pack/plugins/translations/translations/zh-CN.json @@ -8039,7 +8039,7 @@ "xpack.ingestManager.agentConfigList.addButton": "创建代理配置", "xpack.ingestManager.agentConfigList.agentsColumnTitle": "代理", "xpack.ingestManager.agentConfigList.clearFiltersLinkText": "清除筛选", - "xpack.ingestManager.agentConfigList.datasourcesCountColumnTitle": "数据源", + "xpack.ingestManager.agentConfigList.packageConfigsCountColumnTitle": "数据源", "xpack.ingestManager.agentConfigList.descriptionColumnTitle": "描述", "xpack.ingestManager.agentConfigList.loadingAgentConfigsMessage": "正在加载代理配置……", "xpack.ingestManager.agentConfigList.nameColumnTitle": "名称", @@ -8164,28 +8164,27 @@ "xpack.ingestManager.appNavigation.sendFeedbackButton": "发送反馈", "xpack.ingestManager.appNavigation.settingsButton": "设置", "xpack.ingestManager.appTitle": "Ingest Manager", - "xpack.ingestManager.configDetails.addDatasourceButtonText": "创建数据源", + "xpack.ingestManager.configDetails.addPackageConfigButtonText": "创建数据源", "xpack.ingestManager.configDetails.configDetailsTitle": "配置“{id}”", "xpack.ingestManager.configDetails.configNotFoundErrorTitle": "未找到配置“{id}”", - "xpack.ingestManager.configDetails.datasourcesTable.actionsColumnTitle": "操作", - "xpack.ingestManager.configDetails.datasourcesTable.deleteActionTitle": "删除数据源", - "xpack.ingestManager.configDetails.datasourcesTable.descriptionColumnTitle": "描述", - "xpack.ingestManager.configDetails.datasourcesTable.editActionTitle": "编辑数据源", - "xpack.ingestManager.configDetails.datasourcesTable.nameColumnTitle": "数据源", - "xpack.ingestManager.configDetails.datasourcesTable.namespaceColumnTitle": "命名空间", - "xpack.ingestManager.configDetails.datasourcesTable.packageNameColumnTitle": "集成", - "xpack.ingestManager.configDetails.datasourcesTable.streamsCountColumnTitle": "流计数", - "xpack.ingestManager.configDetails.subTabs.datasourcesTabText": "数据源", + "xpack.ingestManager.configDetails.packageConfigsTable.actionsColumnTitle": "操作", + "xpack.ingestManager.configDetails.packageConfigsTable.deleteActionTitle": "删除数据源", + "xpack.ingestManager.configDetails.packageConfigsTable.descriptionColumnTitle": "描述", + "xpack.ingestManager.configDetails.packageConfigsTable.editActionTitle": "编辑数据源", + "xpack.ingestManager.configDetails.packageConfigsTable.nameColumnTitle": "数据源", + "xpack.ingestManager.configDetails.packageConfigsTable.namespaceColumnTitle": "命名空间", + "xpack.ingestManager.configDetails.packageConfigsTable.packageNameColumnTitle": "集成", + "xpack.ingestManager.configDetails.packageConfigsTable.streamsCountColumnTitle": "流计数", + "xpack.ingestManager.configDetails.subTabs.packageConfigsTabText": "数据源", "xpack.ingestManager.configDetails.subTabs.settingsTabText": "设置", - "xpack.ingestManager.configDetails.summary.datasources": "数据源", "xpack.ingestManager.configDetails.summary.lastUpdated": "最后更新时间", "xpack.ingestManager.configDetails.summary.revision": "修订", "xpack.ingestManager.configDetails.summary.usedBy": "使用者", "xpack.ingestManager.configDetails.unexceptedErrorTitle": "加载配置时发生错误", "xpack.ingestManager.configDetails.viewAgentListTitle": "查看所有代理配置", - "xpack.ingestManager.configDetailsDatasources.createFirstButtonText": "创建数据源", - "xpack.ingestManager.configDetailsDatasources.createFirstMessage": "此配置尚未有任何数据源。", - "xpack.ingestManager.configDetailsDatasources.createFirstTitle": "创建您的首个数据源", + "xpack.ingestManager.configDetailsPackageConfigs.createFirstButtonText": "创建数据源", + "xpack.ingestManager.configDetailsPackageConfigs.createFirstMessage": "此配置尚未有任何数据源。", + "xpack.ingestManager.configDetailsPackageConfigs.createFirstTitle": "创建您的首个数据源", "xpack.ingestManager.configForm.deleteConfigActionText": "删除配置", "xpack.ingestManager.configForm.deleteConfigGroupDescription": "将不会删除现有数据。", "xpack.ingestManager.configForm.deleteConfigGroupTitle": "删除配置", @@ -8198,50 +8197,50 @@ "xpack.ingestManager.createAgentConfig.flyoutTitleDescription": "代理配置用于管理整个代理组的设置。您可以将数据源添加到代理配置以指定代理收集的数据。编辑代理配置时,可以使用 Fleet 将更新部署到指定的代理组。", "xpack.ingestManager.createAgentConfig.submitButtonLabel": "创建代理配置", "xpack.ingestManager.createAgentConfig.successNotificationTitle": "代理配置“{name}”已创建", - "xpack.ingestManager.createDatasource.addedNotificationMessage": "Fleet 会将更新部署到所有使用配置“{agentConfigName}”的代理", - "xpack.ingestManager.createDatasource.addedNotificationTitle": "已成功添加“{datasourceName}”", - "xpack.ingestManager.createDatasource.agentConfigurationNameLabel": "配置", - "xpack.ingestManager.createDatasource.cancelButton": "取消", - "xpack.ingestManager.createDatasource.cancelLinkText": "取消", - "xpack.ingestManager.createDatasource.packageNameLabel": "集成", - "xpack.ingestManager.createDatasource.pageDescriptionfromConfig": "按照下面的说明将集成添加此代理配置。", - "xpack.ingestManager.createDatasource.pageDescriptionfromPackage": "按照下面的说明将此集成添加代理配置。", - "xpack.ingestManager.createDatasource.pageTitle": "添加数据源", - "xpack.ingestManager.createDatasource.saveButton": "保存数据源", - "xpack.ingestManager.createDatasource.stepConfgiureDatasourceTitle": "选择要收集的数据", - "xpack.ingestManager.createDatasource.stepConfigure.advancedOptionsToggleLinkText": "高级选项", - "xpack.ingestManager.createDatasource.stepConfigure.datasourceDescriptionInputLabel": "描述", - "xpack.ingestManager.createDatasource.stepConfigure.datasourceNameInputLabel": "数据源名称", - "xpack.ingestManager.createDatasource.stepConfigure.datasourceNamespaceInputLabel": "命名空间", - "xpack.ingestManager.createDatasource.stepConfigure.hideStreamsAriaLabel": "隐藏 {type} 流", - "xpack.ingestManager.createDatasource.stepConfigure.inputConfigErrorsTooltip": "解决配置错误", - "xpack.ingestManager.createDatasource.stepConfigure.inputLevelErrorsTooltip": "解决配置错误", - "xpack.ingestManager.createDatasource.stepConfigure.inputSettingsDescription": "以下设置适用于所有流。", - "xpack.ingestManager.createDatasource.stepConfigure.inputSettingsTitle": "设置", - "xpack.ingestManager.createDatasource.stepConfigure.inputVarFieldOptionalLabel": "可选", - "xpack.ingestManager.createDatasource.stepConfigure.noConfigOptionsMessage": "没有可配置的内容", - "xpack.ingestManager.createDatasource.stepConfigure.showStreamsAriaLabel": "显示 {type} 流", - "xpack.ingestManager.createDatasource.stepConfigure.streamLevelErrorsTooltip": "解决配置错误", - "xpack.ingestManager.createDatasource.stepConfigure.streamsEnabledCountText": "{count} / {total, plural, one {# 个流} other {# 个流}}已启用", - "xpack.ingestManager.createDatasource.stepConfigure.toggleAdvancedOptionsButtonText": "高级选项", - "xpack.ingestManager.createDatasource.stepConfigure.validationErrorText": "在继续之前请解决上述错误", - "xpack.ingestManager.createDatasource.stepConfigure.validationErrorTitle": "您的数据源配置有错误", - "xpack.ingestManager.createDatasource.stepDefineDatasourceTitle": "定义您的数据源", - "xpack.ingestManager.createDatasource.stepSelectAgentConfigTitle": "选择代理配置", - "xpack.ingestManager.createDatasource.StepSelectConfig.agentConfigAgentsCountText": "{count, plural, one {# 个代理} other {# 个代理}}", - "xpack.ingestManager.createDatasource.StepSelectConfig.errorLoadingAgentConfigsTitle": "加载代理配置时出错", - "xpack.ingestManager.createDatasource.StepSelectConfig.errorLoadingPackageTitle": "加载软件包信息时出错", - "xpack.ingestManager.createDatasource.StepSelectConfig.errorLoadingSelectedAgentConfigTitle": "加载选定代理配置时出错", - "xpack.ingestManager.createDatasource.StepSelectConfig.filterAgentConfigsInputPlaceholder": "搜索代理配置", - "xpack.ingestManager.createDatasource.stepSelectPackage.errorLoadingConfigTitle": "加载代理配置信息时出错", - "xpack.ingestManager.createDatasource.stepSelectPackage.errorLoadingPackagesTitle": "加载集成时出错", - "xpack.ingestManager.createDatasource.stepSelectPackage.errorLoadingSelectedPackageTitle": "加载选定集成时出错", - "xpack.ingestManager.createDatasource.stepSelectPackage.filterPackagesInputPlaceholder": "搜索集成", - "xpack.ingestManager.createDatasource.stepSelectPackageTitle": "选择集成", - "xpack.ingestManager.datasourceValidation.invalidArrayErrorMessage": "格式无效", - "xpack.ingestManager.datasourceValidation.invalidYamlFormatErrorMessage": "YAML 格式无效", - "xpack.ingestManager.datasourceValidation.nameRequiredErrorMessage": "“名称”必填", - "xpack.ingestManager.datasourceValidation.requiredErrorMessage": "“{fieldName}”必填", + "xpack.ingestManager.createPackageConfig.addedNotificationMessage": "Fleet 会将更新部署到所有使用配置“{agentConfigName}”的代理", + "xpack.ingestManager.createPackageConfig.addedNotificationTitle": "已成功添加“{packageConfigName}”", + "xpack.ingestManager.createPackageConfig.agentConfigurationNameLabel": "配置", + "xpack.ingestManager.createPackageConfig.cancelButton": "取消", + "xpack.ingestManager.createPackageConfig.cancelLinkText": "取消", + "xpack.ingestManager.createPackageConfig.packageNameLabel": "集成", + "xpack.ingestManager.createPackageConfig.pageDescriptionfromConfig": "按照下面的说明将集成添加此代理配置。", + "xpack.ingestManager.createPackageConfig.pageDescriptionfromPackage": "按照下面的说明将此集成添加代理配置。", + "xpack.ingestManager.createPackageConfig.pageTitle": "添加数据源", + "xpack.ingestManager.createPackageConfig.saveButton": "保存数据源", + "xpack.ingestManager.createPackageConfig.stepConfigurePackageConfigTitle": "选择要收集的数据", + "xpack.ingestManager.createPackageConfig.stepConfigure.advancedOptionsToggleLinkText": "高级选项", + "xpack.ingestManager.createPackageConfig.stepConfigure.packageConfigDescriptionInputLabel": "描述", + "xpack.ingestManager.createPackageConfig.stepConfigure.packageConfigNameInputLabel": "数据源名称", + "xpack.ingestManager.createPackageConfig.stepConfigure.packageConfigNamespaceInputLabel": "命名空间", + "xpack.ingestManager.createPackageConfig.stepConfigure.hideStreamsAriaLabel": "隐藏 {type} 流", + "xpack.ingestManager.createPackageConfig.stepConfigure.inputConfigErrorsTooltip": "解决配置错误", + "xpack.ingestManager.createPackageConfig.stepConfigure.inputLevelErrorsTooltip": "解决配置错误", + "xpack.ingestManager.createPackageConfig.stepConfigure.inputSettingsDescription": "以下设置适用于所有流。", + "xpack.ingestManager.createPackageConfig.stepConfigure.inputSettingsTitle": "设置", + "xpack.ingestManager.createPackageConfig.stepConfigure.inputVarFieldOptionalLabel": "可选", + "xpack.ingestManager.createPackageConfig.stepConfigure.noConfigOptionsMessage": "没有可配置的内容", + "xpack.ingestManager.createPackageConfig.stepConfigure.showStreamsAriaLabel": "显示 {type} 流", + "xpack.ingestManager.createPackageConfig.stepConfigure.streamLevelErrorsTooltip": "解决配置错误", + "xpack.ingestManager.createPackageConfig.stepConfigure.streamsEnabledCountText": "{count} / {total, plural, one {# 个流} other {# 个流}}已启用", + "xpack.ingestManager.createPackageConfig.stepConfigure.toggleAdvancedOptionsButtonText": "高级选项", + "xpack.ingestManager.createPackageConfig.stepConfigure.validationErrorText": "在继续之前请解决上述错误", + "xpack.ingestManager.createPackageConfig.stepConfigure.validationErrorTitle": "您的数据源配置有错误", + "xpack.ingestManager.createPackageConfig.stepDefinePackageConfigTitle": "定义您的数据源", + "xpack.ingestManager.createPackageConfig.stepSelectAgentConfigTitle": "选择代理配置", + "xpack.ingestManager.createPackageConfig.StepSelectConfig.agentConfigAgentsCountText": "{count, plural, one {# 个代理} other {# 个代理}}", + "xpack.ingestManager.createPackageConfig.StepSelectConfig.errorLoadingAgentConfigsTitle": "加载代理配置时出错", + "xpack.ingestManager.createPackageConfig.StepSelectConfig.errorLoadingPackageTitle": "加载软件包信息时出错", + "xpack.ingestManager.createPackageConfig.StepSelectConfig.errorLoadingSelectedAgentConfigTitle": "加载选定代理配置时出错", + "xpack.ingestManager.createPackageConfig.StepSelectConfig.filterAgentConfigsInputPlaceholder": "搜索代理配置", + "xpack.ingestManager.createPackageConfig.stepSelectPackage.errorLoadingConfigTitle": "加载代理配置信息时出错", + "xpack.ingestManager.createPackageConfig.stepSelectPackage.errorLoadingPackagesTitle": "加载集成时出错", + "xpack.ingestManager.createPackageConfig.stepSelectPackage.errorLoadingSelectedPackageTitle": "加载选定集成时出错", + "xpack.ingestManager.createPackageConfig.stepSelectPackage.filterPackagesInputPlaceholder": "搜索集成", + "xpack.ingestManager.createPackageConfig.stepSelectPackageTitle": "选择集成", + "xpack.ingestManager.packageConfigValidation.invalidArrayErrorMessage": "格式无效", + "xpack.ingestManager.packageConfigValidation.invalidYamlFormatErrorMessage": "YAML 格式无效", + "xpack.ingestManager.packageConfigValidation.nameRequiredErrorMessage": "“名称”必填", + "xpack.ingestManager.packageConfigValidation.requiredErrorMessage": "“{fieldName}”必填", "xpack.ingestManager.dataStreamList.actionsColumnTitle": "操作", "xpack.ingestManager.dataStreamList.datasetColumnTitle": "数据集", "xpack.ingestManager.dataStreamList.integrationColumnTitle": "集成", @@ -8271,19 +8270,19 @@ "xpack.ingestManager.deleteAgentConfig.failureSingleNotificationTitle": "删除代理配置“{id}”时出错", "xpack.ingestManager.deleteAgentConfig.fatalErrorNotificationTitle": "删除代理配置时出错", "xpack.ingestManager.deleteAgentConfig.successSingleNotificationTitle": "已删除代理配置“{id}”", - "xpack.ingestManager.deleteDatasource.confirmModal.affectedAgentsMessage": "Fleet 已检测到 {agentConfigName} 已由您的部分代理使用。", - "xpack.ingestManager.deleteDatasource.confirmModal.affectedAgentsTitle": "此操作将影响 {agentsCount} 个 {agentsCount, plural, one {代理} other {代理}}。", - "xpack.ingestManager.deleteDatasource.confirmModal.cancelButtonLabel": "取消", - "xpack.ingestManager.deleteDatasource.confirmModal.confirmButtonLabel": "删除{agentConfigsCount, plural, one {数据源} other {数据源}}", - "xpack.ingestManager.deleteDatasource.confirmModal.deleteMultipleTitle": "删除{count, plural, one {数据源} other {# 个数据源}}?", - "xpack.ingestManager.deleteDatasource.confirmModal.generalMessage": "此操作无法撤消。是否确定要继续?", - "xpack.ingestManager.deleteDatasource.confirmModal.loadingAgentsCountMessage": "正在检查受影响的代理……", - "xpack.ingestManager.deleteDatasource.confirmModal.loadingButtonLabel": "正在加载……", - "xpack.ingestManager.deleteDatasource.failureMultipleNotificationTitle": "删除 {count} 个数据源时出错", - "xpack.ingestManager.deleteDatasource.failureSingleNotificationTitle": "删除数据源“{id}”时出错", - "xpack.ingestManager.deleteDatasource.fatalErrorNotificationTitle": "删除数据源时出错", - "xpack.ingestManager.deleteDatasource.successMultipleNotificationTitle": "已删除 {count} 个数据源", - "xpack.ingestManager.deleteDatasource.successSingleNotificationTitle": "已删除数据源“{id}”", + "xpack.ingestManager.deletePackageConfig.confirmModal.affectedAgentsMessage": "Fleet 已检测到 {agentConfigName} 已由您的部分代理使用。", + "xpack.ingestManager.deletePackageConfig.confirmModal.affectedAgentsTitle": "此操作将影响 {agentsCount} 个 {agentsCount, plural, one {代理} other {代理}}。", + "xpack.ingestManager.deletePackageConfig.confirmModal.cancelButtonLabel": "取消", + "xpack.ingestManager.deletePackageConfig.confirmModal.confirmButtonLabel": "删除{agentConfigsCount, plural, one {数据源} other {数据源}}", + "xpack.ingestManager.deletePackageConfig.confirmModal.deleteMultipleTitle": "删除{count, plural, one {数据源} other {# 个数据源}}?", + "xpack.ingestManager.deletePackageConfig.confirmModal.generalMessage": "此操作无法撤消。是否确定要继续?", + "xpack.ingestManager.deletePackageConfig.confirmModal.loadingAgentsCountMessage": "正在检查受影响的代理……", + "xpack.ingestManager.deletePackageConfig.confirmModal.loadingButtonLabel": "正在加载……", + "xpack.ingestManager.deletePackageConfig.failureMultipleNotificationTitle": "删除 {count} 个数据源时出错", + "xpack.ingestManager.deletePackageConfig.failureSingleNotificationTitle": "删除数据源“{id}”时出错", + "xpack.ingestManager.deletePackageConfig.fatalErrorNotificationTitle": "删除数据源时出错", + "xpack.ingestManager.deletePackageConfig.successMultipleNotificationTitle": "已删除 {count} 个数据源", + "xpack.ingestManager.deletePackageConfig.successSingleNotificationTitle": "已删除数据源“{id}”", "xpack.ingestManager.disabledSecurityDescription": "必须在 Kibana 和 Elasticsearch 启用安全性,才能使用 Elastic Fleet。", "xpack.ingestManager.disabledSecurityTitle": "安全性未启用", "xpack.ingestManager.editAgentConfig.cancelButtonText": "取消", @@ -8292,16 +8291,16 @@ "xpack.ingestManager.editAgentConfig.savingButtonText": "正在保存……", "xpack.ingestManager.editAgentConfig.successNotificationTitle": "已成功更新“{name}”设置", "xpack.ingestManager.editAgentConfig.unsavedChangesText": "您有未保存更改", - "xpack.ingestManager.editDatasource.cancelButton": "取消", - "xpack.ingestManager.editDatasource.errorLoadingDataMessage": "加载此数据源信息时出错", - "xpack.ingestManager.editDatasource.errorLoadingDataTitle": "加载数据时出错", - "xpack.ingestManager.editDatasource.pageDescription": "按照下面的说明编辑此数据源。", - "xpack.ingestManager.editDatasource.pageTitle": "编辑数据源", - "xpack.ingestManager.editDatasource.saveButton": "保存数据源", - "xpack.ingestManager.editDatasource.stepConfgiureDatasourceTitle": "选择要收集的数据", - "xpack.ingestManager.editDatasource.stepDefineDatasourceTitle": "定义您的数据源", - "xpack.ingestManager.editDatasource.updatedNotificationMessage": "Fleet 会将更新部署到所有使用配置“{agentConfigName}”的代理", - "xpack.ingestManager.editDatasource.updatedNotificationTitle": "已成功更新“{datasourceName}”", + "xpack.ingestManager.editPackageConfig.cancelButton": "取消", + "xpack.ingestManager.editPackageConfig.errorLoadingDataMessage": "加载此数据源信息时出错", + "xpack.ingestManager.editPackageConfig.errorLoadingDataTitle": "加载数据时出错", + "xpack.ingestManager.editPackageConfig.pageDescription": "按照下面的说明编辑此数据源。", + "xpack.ingestManager.editPackageConfig.pageTitle": "编辑数据源", + "xpack.ingestManager.editPackageConfig.saveButton": "保存数据源", + "xpack.ingestManager.editPackageConfig.stepConfigurePackageConfigTitle": "选择要收集的数据", + "xpack.ingestManager.editPackageConfig.stepDefinePackageConfigTitle": "定义您的数据源", + "xpack.ingestManager.editPackageConfig.updatedNotificationMessage": "Fleet 会将更新部署到所有使用配置“{agentConfigName}”的代理", + "xpack.ingestManager.editPackageConfig.updatedNotificationTitle": "已成功更新“{packageConfigName}”", "xpack.ingestManager.enrollemntAPIKeyList.emptyMessage": "未找到任何注册令牌。", "xpack.ingestManager.enrollemntAPIKeyList.loadingTokensMessage": "正在加载注册令牌......", "xpack.ingestManager.enrollmentInstructions.copyButton": "复制命令", @@ -8324,6 +8323,9 @@ "xpack.ingestManager.enrollmentTokensList.secretTitle": "密钥", "xpack.ingestManager.epm.browseAllButtonText": "浏览所有集成", "xpack.ingestManager.epm.illustrationAltText": "Elastic 集成的图示", + "xpack.ingestManager.epm.packageDetailsNav.packageConfigsLinkText": "数据源", + "xpack.ingestManager.epm.packageDetailsNav.overviewLinkText": "概览", + "xpack.ingestManager.epm.packageDetailsNav.settingsLinkText": "设置", "xpack.ingestManager.epm.pageSubtitle": "浏览集成以了解热门应用和服务。", "xpack.ingestManager.epm.pageTitle": "Elastic 集成", "xpack.ingestManager.epmList.allFilterLinkText": "全部", @@ -8396,7 +8398,7 @@ "xpack.ingestManager.overviewAgentOfflineTitle": "脱机", "xpack.ingestManager.overviewAgentTotalTitle": "代理总数", "xpack.ingestManager.overviewConfigTotalTitle": "配置总数", - "xpack.ingestManager.overviewDatasourceTitle": "数据源", + "xpack.ingestManager.overviewPackageConfigTitle": "数据源", "xpack.ingestManager.overviewDatastreamNamespacesTitle": "命名空间", "xpack.ingestManager.overviewDatastreamSizeTitle": "总大小", "xpack.ingestManager.overviewDatastreamTotalTitle": "数据流", 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..c317aad8ba05b 100644 --- a/x-pack/test/functional/es_archives/fleet/agents/data.json +++ b/x-pack/test/functional/es_archives/fleet/agents/data.json @@ -212,14 +212,14 @@ "namespace": "default", "description": "Config 1", "status": "active", - "datasources": [], + "package_configs": [], "is_default": true, "monitoring_enabled": [ "logs", "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 15e5a5524107b..0b84514de23f2 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": { @@ -1829,12 +1829,12 @@ "updated_by": { "type": "keyword" }, - "updated_on": { + "updated_at": { "type": "keyword" } } }, - "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..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 @@ -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.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.datasource.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.datasource.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.datasource.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.datasource.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.datasource.id, + id: policyInfo.packageConfig.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.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 941a100416740..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 @@ -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.packageConfig.package?.title} v${policyInfo.packageConfig.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 2d27082ff5949..68e1ad00619c7 100644 --- a/x-pack/test/security_solution_endpoint/page_objects/index.ts +++ b/x-pack/test/security_solution_endpoint/page_objects/index.ts @@ -8,12 +8,12 @@ import { pageObjects as xpackFunctionalPageObjects } from '../../functional/page import { EndpointPageProvider } from './endpoint_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, endpoint: EndpointPageProvider, policy: EndpointPolicyPageProvider, endpointPageUtils: EndpointPageUtils, - 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 66% 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 e104b8701276c..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,38 +6,41 @@ 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('createDataSource_header'); + await testSubjects.existOrFail('createPackageConfig_header'); }, /** * Finds and returns the Cancel button on the sticky bottom bar */ async findCancelButton() { - return await testSubjects.find('createDatasourceCancelButton'); + return await testSubjects.find('createPackageConfigCancelButton'); }, /** * Finds and returns the Cancel back link at the top of the create page */ async findBackLink() { - return await testSubjects.find('createDataSource_cancelBackLink'); + return await testSubjects.find('createPackageConfig_cancelBackLink'); }, /** * Finds and returns the save button on the sticky bottom bar */ async findDSaveButton() { - return await testSubjects.find('createDatasourceSaveButton'); + return await testSubjects.find('createPackageConfigSaveButton'); }, /** @@ -60,36 +63,36 @@ 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'); - await testSubjects.setValue('datasourceNameInput', name); + await testSubjects.setValue('packageConfigNameInput', name); }, /** * Waits for the save Notification toast to be visible */ async waitForSaveSuccessNotification() { - await testSubjects.existOrFail('datasourceCreateSuccessToast'); + await testSubjects.existOrFail('packageConfigCreateSuccessToast'); }, /** - * 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('editDataSource_header'); + 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 d07c4e70f2687..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,12 +98,12 @@ 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) { - return await testSubjects.find(`endpointDatasourceConfig_${onEditPage ? 'edit' : 'create'}`); + async findPackageConfigEndpointCustomConfiguration(onEditPage: boolean = false) { + return await testSubjects.find(`endpointPackageConfig_${onEditPage ? 'edit' : 'create'}`); }, /** diff --git a/x-pack/test/security_solution_endpoint/services/endpoint_policy.ts b/x-pack/test/security_solution_endpoint/services/endpoint_policy.ts index fbed7dcc663ec..df7d117e91dcb 100644 --- a/x-pack/test/security_solution_endpoint/services/endpoint_policy.ts +++ b/x-pack/test/security_solution_endpoint/services/endpoint_policy.ts @@ -3,17 +3,16 @@ * or more contributor license agreements. Licensed under the Elastic License; * you may not use this file except in compliance with the Elastic License. */ - import { FtrProviderContext } from '../ftr_provider_context'; import { CreateAgentConfigRequest, CreateAgentConfigResponse, - CreateDatasourceRequest, - CreateDatasourceResponse, - DATASOURCE_SAVED_OBJECT_TYPE, + CreatePackageConfigRequest, + CreatePackageConfigResponse, + PACKAGE_CONFIG_SAVED_OBJECT_TYPE, DeleteAgentConfigRequest, - DeleteDatasourcesRequest, - GetDatasourcesResponse, + DeletePackageConfigsRequest, + GetPackageConfigsResponse, GetFullAgentConfigResponse, GetPackagesResponse, } from '../../../plugins/ingest_manager/common'; @@ -23,8 +22,8 @@ import { Immutable } from '../../../plugins/security_solution/common/endpoint/ty const INGEST_API_ROOT = '/api/ingest_manager'; const INGEST_API_AGENT_CONFIGS = `${INGEST_API_ROOT}/agent_configs`; const INGEST_API_AGENT_CONFIGS_DELETE = `${INGEST_API_AGENT_CONFIGS}/delete`; -const INGEST_API_DATASOURCES = `${INGEST_API_ROOT}/datasources`; -const INGEST_API_DATASOURCES_DELETE = `${INGEST_API_DATASOURCES}/delete`; +const INGEST_API_PACKAGE_CONFIGS = `${INGEST_API_ROOT}/package_configs`; +const INGEST_API_PACKAGE_CONFIGS_DELETE = `${INGEST_API_PACKAGE_CONFIGS}/delete`; const INGEST_API_EPM_PACKAGES = `${INGEST_API_ROOT}/epm/packages`; const SECURITY_PACKAGES_ROUTE = `${INGEST_API_EPM_PACKAGES}?category=security`; @@ -35,15 +34,15 @@ const SECURITY_PACKAGES_ROUTE = `${INGEST_API_EPM_PACKAGES}?category=security`; export interface PolicyTestResourceInfo { /** The Ingest agent configuration created */ agentConfig: Immutable; - /** 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); } }, };