From bd6533f30b58fc831670d400f25a61321379902c Mon Sep 17 00:00:00 2001 From: Jen Huang Date: Wed, 9 Oct 2024 13:08:18 -0700 Subject: [PATCH] [UII] Add types to return content packages correctly (#195505) ## Summary Related to #192484. This PR adding [new content package types and schemas](https://github.com/elastic/package-spec/pull/777) so that content packages can be returned correctly from EPR to unblock development of those packages. The only current content package is `kubernetes_otel`. You will need to bump up the max allowed spec version and search with beta (prerelease) packages enabled to find it: ``` xpack.fleet.internal.registry.spec.max: '3.4' ``` Tests will come with the rest of work for #192484 --------- Co-authored-by: kibanamachine <42973632+kibanamachine@users.noreply.github.com> --- oas_docs/bundle.json | 144 +++++++++++++++++- oas_docs/bundle.serverless.json | 144 +++++++++++++++++- .../output/kibana.serverless.staging.yaml | 90 +++++++++++ oas_docs/output/kibana.serverless.yaml | 90 +++++++++++ oas_docs/output/kibana.staging.yaml | 90 +++++++++++ oas_docs/output/kibana.yaml | 90 +++++++++++ .../fleet/common/types/models/package_spec.ts | 9 +- .../fleet/server/types/rest_spec/epm.ts | 13 +- 8 files changed, 655 insertions(+), 15 deletions(-) diff --git a/oas_docs/bundle.json b/oas_docs/bundle.json index 6cc3990de1b51..e52362ff13a6a 100644 --- a/oas_docs/bundle.json +++ b/oas_docs/bundle.json @@ -19328,6 +19328,27 @@ "description": { "type": "string" }, + "discovery": { + "additionalProperties": true, + "properties": { + "fields": { + "items": { + "additionalProperties": true, + "properties": { + "name": { + "type": "string" + } + }, + "required": [ + "name" + ], + "type": "object" + }, + "type": "array" + } + }, + "type": "object" + }, "download": { "type": "string" }, @@ -19716,7 +19737,8 @@ "type": { "enum": [ "integration", - "input" + "input", + "content" ], "type": "string" }, @@ -19793,6 +19815,27 @@ "description": { "type": "string" }, + "discovery": { + "additionalProperties": true, + "properties": { + "fields": { + "items": { + "additionalProperties": true, + "properties": { + "name": { + "type": "string" + } + }, + "required": [ + "name" + ], + "type": "object" + }, + "type": "array" + } + }, + "type": "object" + }, "download": { "type": "string" }, @@ -20181,7 +20224,8 @@ "type": { "enum": [ "integration", - "input" + "input", + "content" ], "type": "string" }, @@ -21769,6 +21813,27 @@ "description": { "type": "string" }, + "discovery": { + "additionalProperties": true, + "properties": { + "fields": { + "items": { + "additionalProperties": true, + "properties": { + "name": { + "type": "string" + } + }, + "required": [ + "name" + ], + "type": "object" + }, + "type": "array" + } + }, + "type": "object" + }, "download": { "type": "string" }, @@ -22197,7 +22262,8 @@ "type": { "enum": [ "integration", - "input" + "input", + "content" ], "type": "string" }, @@ -22329,6 +22395,27 @@ "description": { "type": "string" }, + "discovery": { + "additionalProperties": true, + "properties": { + "fields": { + "items": { + "additionalProperties": true, + "properties": { + "name": { + "type": "string" + } + }, + "required": [ + "name" + ], + "type": "object" + }, + "type": "array" + } + }, + "type": "object" + }, "download": { "type": "string" }, @@ -22757,7 +22844,8 @@ "type": { "enum": [ "integration", - "input" + "input", + "content" ], "type": "string" }, @@ -23279,6 +23367,27 @@ "description": { "type": "string" }, + "discovery": { + "additionalProperties": true, + "properties": { + "fields": { + "items": { + "additionalProperties": true, + "properties": { + "name": { + "type": "string" + } + }, + "required": [ + "name" + ], + "type": "object" + }, + "type": "array" + } + }, + "type": "object" + }, "download": { "type": "string" }, @@ -23707,7 +23816,8 @@ "type": { "enum": [ "integration", - "input" + "input", + "content" ], "type": "string" }, @@ -23827,6 +23937,27 @@ "description": { "type": "string" }, + "discovery": { + "additionalProperties": true, + "properties": { + "fields": { + "items": { + "additionalProperties": true, + "properties": { + "name": { + "type": "string" + } + }, + "required": [ + "name" + ], + "type": "object" + }, + "type": "array" + } + }, + "type": "object" + }, "download": { "type": "string" }, @@ -24255,7 +24386,8 @@ "type": { "enum": [ "integration", - "input" + "input", + "content" ], "type": "string" }, diff --git a/oas_docs/bundle.serverless.json b/oas_docs/bundle.serverless.json index 6fcc247e1fb22..531ab412ce1bf 100644 --- a/oas_docs/bundle.serverless.json +++ b/oas_docs/bundle.serverless.json @@ -19328,6 +19328,27 @@ "description": { "type": "string" }, + "discovery": { + "additionalProperties": true, + "properties": { + "fields": { + "items": { + "additionalProperties": true, + "properties": { + "name": { + "type": "string" + } + }, + "required": [ + "name" + ], + "type": "object" + }, + "type": "array" + } + }, + "type": "object" + }, "download": { "type": "string" }, @@ -19716,7 +19737,8 @@ "type": { "enum": [ "integration", - "input" + "input", + "content" ], "type": "string" }, @@ -19793,6 +19815,27 @@ "description": { "type": "string" }, + "discovery": { + "additionalProperties": true, + "properties": { + "fields": { + "items": { + "additionalProperties": true, + "properties": { + "name": { + "type": "string" + } + }, + "required": [ + "name" + ], + "type": "object" + }, + "type": "array" + } + }, + "type": "object" + }, "download": { "type": "string" }, @@ -20181,7 +20224,8 @@ "type": { "enum": [ "integration", - "input" + "input", + "content" ], "type": "string" }, @@ -21769,6 +21813,27 @@ "description": { "type": "string" }, + "discovery": { + "additionalProperties": true, + "properties": { + "fields": { + "items": { + "additionalProperties": true, + "properties": { + "name": { + "type": "string" + } + }, + "required": [ + "name" + ], + "type": "object" + }, + "type": "array" + } + }, + "type": "object" + }, "download": { "type": "string" }, @@ -22197,7 +22262,8 @@ "type": { "enum": [ "integration", - "input" + "input", + "content" ], "type": "string" }, @@ -22329,6 +22395,27 @@ "description": { "type": "string" }, + "discovery": { + "additionalProperties": true, + "properties": { + "fields": { + "items": { + "additionalProperties": true, + "properties": { + "name": { + "type": "string" + } + }, + "required": [ + "name" + ], + "type": "object" + }, + "type": "array" + } + }, + "type": "object" + }, "download": { "type": "string" }, @@ -22757,7 +22844,8 @@ "type": { "enum": [ "integration", - "input" + "input", + "content" ], "type": "string" }, @@ -23279,6 +23367,27 @@ "description": { "type": "string" }, + "discovery": { + "additionalProperties": true, + "properties": { + "fields": { + "items": { + "additionalProperties": true, + "properties": { + "name": { + "type": "string" + } + }, + "required": [ + "name" + ], + "type": "object" + }, + "type": "array" + } + }, + "type": "object" + }, "download": { "type": "string" }, @@ -23707,7 +23816,8 @@ "type": { "enum": [ "integration", - "input" + "input", + "content" ], "type": "string" }, @@ -23827,6 +23937,27 @@ "description": { "type": "string" }, + "discovery": { + "additionalProperties": true, + "properties": { + "fields": { + "items": { + "additionalProperties": true, + "properties": { + "name": { + "type": "string" + } + }, + "required": [ + "name" + ], + "type": "object" + }, + "type": "array" + } + }, + "type": "object" + }, "download": { "type": "string" }, @@ -24255,7 +24386,8 @@ "type": { "enum": [ "integration", - "input" + "input", + "content" ], "type": "string" }, diff --git a/oas_docs/output/kibana.serverless.staging.yaml b/oas_docs/output/kibana.serverless.staging.yaml index bd2f5c597ecc4..69b783c6ccc44 100644 --- a/oas_docs/output/kibana.serverless.staging.yaml +++ b/oas_docs/output/kibana.serverless.staging.yaml @@ -18990,6 +18990,20 @@ paths: type: array description: type: string + discovery: + additionalProperties: true + type: object + properties: + fields: + items: + additionalProperties: true + type: object + properties: + name: + type: string + required: + - name + type: array download: type: string format_version: @@ -19270,6 +19284,7 @@ paths: enum: - integration - input + - content type: string vars: items: @@ -19322,6 +19337,20 @@ paths: type: array description: type: string + discovery: + additionalProperties: true + type: object + properties: + fields: + items: + additionalProperties: true + type: object + properties: + name: + type: string + required: + - name + type: array download: type: string format_version: @@ -19602,6 +19631,7 @@ paths: enum: - integration - input + - content type: string vars: items: @@ -20574,6 +20604,20 @@ paths: type: array description: type: string + discovery: + additionalProperties: true + type: object + properties: + fields: + items: + additionalProperties: true + type: object + properties: + name: + type: string + required: + - name + type: array download: type: string elasticsearch: @@ -20881,6 +20925,7 @@ paths: enum: - integration - input + - content type: string vars: items: @@ -20970,6 +21015,20 @@ paths: type: array description: type: string + discovery: + additionalProperties: true + type: object + properties: + fields: + items: + additionalProperties: true + type: object + properties: + name: + type: string + required: + - name + type: array download: type: string elasticsearch: @@ -21277,6 +21336,7 @@ paths: enum: - integration - input + - content type: string vars: items: @@ -21629,6 +21689,20 @@ paths: type: array description: type: string + discovery: + additionalProperties: true + type: object + properties: + fields: + items: + additionalProperties: true + type: object + properties: + name: + type: string + required: + - name + type: array download: type: string elasticsearch: @@ -21936,6 +22010,7 @@ paths: enum: - integration - input + - content type: string vars: items: @@ -22017,6 +22092,20 @@ paths: type: array description: type: string + discovery: + additionalProperties: true + type: object + properties: + fields: + items: + additionalProperties: true + type: object + properties: + name: + type: string + required: + - name + type: array download: type: string elasticsearch: @@ -22324,6 +22413,7 @@ paths: enum: - integration - input + - content type: string vars: items: diff --git a/oas_docs/output/kibana.serverless.yaml b/oas_docs/output/kibana.serverless.yaml index bd2f5c597ecc4..69b783c6ccc44 100644 --- a/oas_docs/output/kibana.serverless.yaml +++ b/oas_docs/output/kibana.serverless.yaml @@ -18990,6 +18990,20 @@ paths: type: array description: type: string + discovery: + additionalProperties: true + type: object + properties: + fields: + items: + additionalProperties: true + type: object + properties: + name: + type: string + required: + - name + type: array download: type: string format_version: @@ -19270,6 +19284,7 @@ paths: enum: - integration - input + - content type: string vars: items: @@ -19322,6 +19337,20 @@ paths: type: array description: type: string + discovery: + additionalProperties: true + type: object + properties: + fields: + items: + additionalProperties: true + type: object + properties: + name: + type: string + required: + - name + type: array download: type: string format_version: @@ -19602,6 +19631,7 @@ paths: enum: - integration - input + - content type: string vars: items: @@ -20574,6 +20604,20 @@ paths: type: array description: type: string + discovery: + additionalProperties: true + type: object + properties: + fields: + items: + additionalProperties: true + type: object + properties: + name: + type: string + required: + - name + type: array download: type: string elasticsearch: @@ -20881,6 +20925,7 @@ paths: enum: - integration - input + - content type: string vars: items: @@ -20970,6 +21015,20 @@ paths: type: array description: type: string + discovery: + additionalProperties: true + type: object + properties: + fields: + items: + additionalProperties: true + type: object + properties: + name: + type: string + required: + - name + type: array download: type: string elasticsearch: @@ -21277,6 +21336,7 @@ paths: enum: - integration - input + - content type: string vars: items: @@ -21629,6 +21689,20 @@ paths: type: array description: type: string + discovery: + additionalProperties: true + type: object + properties: + fields: + items: + additionalProperties: true + type: object + properties: + name: + type: string + required: + - name + type: array download: type: string elasticsearch: @@ -21936,6 +22010,7 @@ paths: enum: - integration - input + - content type: string vars: items: @@ -22017,6 +22092,20 @@ paths: type: array description: type: string + discovery: + additionalProperties: true + type: object + properties: + fields: + items: + additionalProperties: true + type: object + properties: + name: + type: string + required: + - name + type: array download: type: string elasticsearch: @@ -22324,6 +22413,7 @@ paths: enum: - integration - input + - content type: string vars: items: diff --git a/oas_docs/output/kibana.staging.yaml b/oas_docs/output/kibana.staging.yaml index 544315cd12646..bc0828a44b619 100644 --- a/oas_docs/output/kibana.staging.yaml +++ b/oas_docs/output/kibana.staging.yaml @@ -22419,6 +22419,20 @@ paths: type: array description: type: string + discovery: + additionalProperties: true + type: object + properties: + fields: + items: + additionalProperties: true + type: object + properties: + name: + type: string + required: + - name + type: array download: type: string format_version: @@ -22699,6 +22713,7 @@ paths: enum: - integration - input + - content type: string vars: items: @@ -22751,6 +22766,20 @@ paths: type: array description: type: string + discovery: + additionalProperties: true + type: object + properties: + fields: + items: + additionalProperties: true + type: object + properties: + name: + type: string + required: + - name + type: array download: type: string format_version: @@ -23031,6 +23060,7 @@ paths: enum: - integration - input + - content type: string vars: items: @@ -24003,6 +24033,20 @@ paths: type: array description: type: string + discovery: + additionalProperties: true + type: object + properties: + fields: + items: + additionalProperties: true + type: object + properties: + name: + type: string + required: + - name + type: array download: type: string elasticsearch: @@ -24310,6 +24354,7 @@ paths: enum: - integration - input + - content type: string vars: items: @@ -24399,6 +24444,20 @@ paths: type: array description: type: string + discovery: + additionalProperties: true + type: object + properties: + fields: + items: + additionalProperties: true + type: object + properties: + name: + type: string + required: + - name + type: array download: type: string elasticsearch: @@ -24706,6 +24765,7 @@ paths: enum: - integration - input + - content type: string vars: items: @@ -25058,6 +25118,20 @@ paths: type: array description: type: string + discovery: + additionalProperties: true + type: object + properties: + fields: + items: + additionalProperties: true + type: object + properties: + name: + type: string + required: + - name + type: array download: type: string elasticsearch: @@ -25365,6 +25439,7 @@ paths: enum: - integration - input + - content type: string vars: items: @@ -25446,6 +25521,20 @@ paths: type: array description: type: string + discovery: + additionalProperties: true + type: object + properties: + fields: + items: + additionalProperties: true + type: object + properties: + name: + type: string + required: + - name + type: array download: type: string elasticsearch: @@ -25753,6 +25842,7 @@ paths: enum: - integration - input + - content type: string vars: items: diff --git a/oas_docs/output/kibana.yaml b/oas_docs/output/kibana.yaml index 544315cd12646..bc0828a44b619 100644 --- a/oas_docs/output/kibana.yaml +++ b/oas_docs/output/kibana.yaml @@ -22419,6 +22419,20 @@ paths: type: array description: type: string + discovery: + additionalProperties: true + type: object + properties: + fields: + items: + additionalProperties: true + type: object + properties: + name: + type: string + required: + - name + type: array download: type: string format_version: @@ -22699,6 +22713,7 @@ paths: enum: - integration - input + - content type: string vars: items: @@ -22751,6 +22766,20 @@ paths: type: array description: type: string + discovery: + additionalProperties: true + type: object + properties: + fields: + items: + additionalProperties: true + type: object + properties: + name: + type: string + required: + - name + type: array download: type: string format_version: @@ -23031,6 +23060,7 @@ paths: enum: - integration - input + - content type: string vars: items: @@ -24003,6 +24033,20 @@ paths: type: array description: type: string + discovery: + additionalProperties: true + type: object + properties: + fields: + items: + additionalProperties: true + type: object + properties: + name: + type: string + required: + - name + type: array download: type: string elasticsearch: @@ -24310,6 +24354,7 @@ paths: enum: - integration - input + - content type: string vars: items: @@ -24399,6 +24444,20 @@ paths: type: array description: type: string + discovery: + additionalProperties: true + type: object + properties: + fields: + items: + additionalProperties: true + type: object + properties: + name: + type: string + required: + - name + type: array download: type: string elasticsearch: @@ -24706,6 +24765,7 @@ paths: enum: - integration - input + - content type: string vars: items: @@ -25058,6 +25118,20 @@ paths: type: array description: type: string + discovery: + additionalProperties: true + type: object + properties: + fields: + items: + additionalProperties: true + type: object + properties: + name: + type: string + required: + - name + type: array download: type: string elasticsearch: @@ -25365,6 +25439,7 @@ paths: enum: - integration - input + - content type: string vars: items: @@ -25446,6 +25521,20 @@ paths: type: array description: type: string + discovery: + additionalProperties: true + type: object + properties: + fields: + items: + additionalProperties: true + type: object + properties: + name: + type: string + required: + - name + type: array download: type: string elasticsearch: @@ -25753,6 +25842,7 @@ paths: enum: - integration - input + - content type: string vars: items: diff --git a/x-pack/plugins/fleet/common/types/models/package_spec.ts b/x-pack/plugins/fleet/common/types/models/package_spec.ts index 24a592490137c..18c10e4617417 100644 --- a/x-pack/plugins/fleet/common/types/models/package_spec.ts +++ b/x-pack/plugins/fleet/common/types/models/package_spec.ts @@ -18,7 +18,7 @@ export interface PackageSpecManifest { source?: { license: string; }; - type?: 'integration' | 'input'; + type?: PackageSpecPackageType; release?: 'experimental' | 'beta' | 'ga'; categories?: Array; conditions?: PackageSpecConditions; @@ -35,6 +35,11 @@ export interface PackageSpecManifest { privileges?: { root?: boolean }; }; asset_tags?: PackageSpecTags[]; + discovery?: { + fields?: Array<{ + name: string; + }>; + }; } export interface PackageSpecTags { text: string; @@ -42,7 +47,7 @@ export interface PackageSpecTags { asset_ids?: string[]; } -export type PackageSpecPackageType = 'integration' | 'input'; +export type PackageSpecPackageType = 'integration' | 'input' | 'content'; export type PackageSpecCategory = | 'advanced_analytics_ueba' diff --git a/x-pack/plugins/fleet/server/types/rest_spec/epm.ts b/x-pack/plugins/fleet/server/types/rest_spec/epm.ts index 2dc9606a5432d..f08ccd9ff1248 100644 --- a/x-pack/plugins/fleet/server/types/rest_spec/epm.ts +++ b/x-pack/plugins/fleet/server/types/rest_spec/epm.ts @@ -163,7 +163,13 @@ export const PackageInfoSchema = schema release: schema.maybe( schema.oneOf([schema.literal('ga'), schema.literal('beta'), schema.literal('experimental')]) ), - type: schema.maybe(schema.oneOf([schema.literal('integration'), schema.literal('input')])), + type: schema.maybe( + schema.oneOf([ + schema.literal('integration'), + schema.literal('input'), + schema.literal('content'), + ]) + ), path: schema.maybe(schema.string()), download: schema.maybe(schema.string()), internal: schema.maybe(schema.boolean()), @@ -192,6 +198,11 @@ export const PackageInfoSchema = schema format_version: schema.maybe(schema.string()), vars: schema.maybe(schema.arrayOf(schema.recordOf(schema.string(), schema.any()))), latestVersion: schema.maybe(schema.string()), + discovery: schema.maybe( + schema.object({ + fields: schema.maybe(schema.arrayOf(schema.object({ name: schema.string() }))), + }) + ), }) // sometimes package list response contains extra properties, e.g. installed_kibana .extendsDeep({