From d314a67b70d3f3712380f375e88f3b081fb530dc Mon Sep 17 00:00:00 2001 From: Nicolas Chaulet Date: Wed, 21 Sep 2022 15:21:55 -0400 Subject: [PATCH] [Fleet] Add experimental data stream features support to simplified package policy API --- .../simplified_package_policy_helper.test.ts | 31 +++++++++++++++++++ .../simplified_package_policy_helper.ts | 10 +++++- .../server/routes/package_policy/handlers.ts | 7 +++-- .../server/types/models/package_policy.ts | 21 +++++++------ 4 files changed, 56 insertions(+), 13 deletions(-) diff --git a/x-pack/plugins/fleet/common/services/simplified_package_policy_helper.test.ts b/x-pack/plugins/fleet/common/services/simplified_package_policy_helper.test.ts index eec59a647c39d..7d5a7966f91c3 100644 --- a/x-pack/plugins/fleet/common/services/simplified_package_policy_helper.test.ts +++ b/x-pack/plugins/fleet/common/services/simplified_package_policy_helper.test.ts @@ -115,5 +115,36 @@ describe('toPackagePolicy', () => { 'nginx-nginx/metrics': ['nginx.stubstatus'], }); }); + + it('should to pass experimental_data_stream_features', () => { + const res = simplifiedPackagePolicytoNewPackagePolicy( + { + name: 'nginx-1', + namespace: 'default', + policy_id: 'policy123', + description: 'Test description', + }, + nginxPackageInfo as unknown as PackageInfo, + { + experimental_data_stream_features: [ + { + data_stream: 'logs-nginx.access', + features: { + synthetic_source: true, + }, + }, + ], + } + ); + + expect(res.package?.experimental_data_stream_features).toEqual([ + { + data_stream: 'logs-nginx.access', + features: { + synthetic_source: true, + }, + }, + ]); + }); }); }); diff --git a/x-pack/plugins/fleet/common/services/simplified_package_policy_helper.ts b/x-pack/plugins/fleet/common/services/simplified_package_policy_helper.ts index c0d05d1eeab2a..a17796e4b8561 100644 --- a/x-pack/plugins/fleet/common/services/simplified_package_policy_helper.ts +++ b/x-pack/plugins/fleet/common/services/simplified_package_policy_helper.ts @@ -11,6 +11,7 @@ import type { PackagePolicyConfigRecord, NewPackagePolicy, PackageInfo, + ExperimentalDataStreamFeature, } from '../types'; import { PackagePolicyValidationError } from '../errors'; @@ -66,7 +67,10 @@ type InputMap = Map