From faa7c75db843591568eac59433533cd823396abf Mon Sep 17 00:00:00 2001 From: Julia Bardi Date: Tue, 3 Dec 2024 14:56:56 +0100 Subject: [PATCH 1/4] fix schema validation --- .../fleet/server/types/models/agent_policy.ts | 2 +- .../fleet/server/types/rest_spec/agent.ts | 35 ++++++++++--------- 2 files changed, 20 insertions(+), 17 deletions(-) diff --git a/x-pack/plugins/fleet/server/types/models/agent_policy.ts b/x-pack/plugins/fleet/server/types/models/agent_policy.ts index 4f131d00bdf38..cc7dabe253ec1 100644 --- a/x-pack/plugins/fleet/server/types/models/agent_policy.ts +++ b/x-pack/plugins/fleet/server/types/models/agent_policy.ts @@ -135,7 +135,7 @@ export const AgentPolicyBaseSchema = { monitoring_pprof_enabled: schema.maybe(schema.boolean()), monitoring_http: schema.maybe( schema.object({ - enabled: schema.boolean(), + enabled: schema.maybe(schema.boolean()), host: schema.maybe(schema.string({ defaultValue: 'localhost' })), port: schema.maybe(schema.number({ min: 0, max: 65353, defaultValue: 6791 })), buffer: schema.maybe(schema.object({ enabled: schema.boolean({ defaultValue: false }) })), diff --git a/x-pack/plugins/fleet/server/types/rest_spec/agent.ts b/x-pack/plugins/fleet/server/types/rest_spec/agent.ts index a5fb3e9e034ed..9df9b73b3f49b 100644 --- a/x-pack/plugins/fleet/server/types/rest_spec/agent.ts +++ b/x-pack/plugins/fleet/server/types/rest_spec/agent.ts @@ -138,22 +138,25 @@ export const AgentResponseSchema = schema.object({ upgraded_at: schema.maybe(schema.oneOf([schema.literal(null), schema.string()])), upgrade_started_at: schema.maybe(schema.oneOf([schema.literal(null), schema.string()])), upgrade_details: schema.maybe( - schema.object({ - target_version: schema.string(), - action_id: schema.string(), - state: AgentUpgradeStateTypeSchema, - metadata: schema.maybe( - schema.object({ - scheduled_at: schema.maybe(schema.string()), - download_percent: schema.maybe(schema.number()), - download_rate: schema.maybe(schema.number()), - failed_state: schema.maybe(AgentUpgradeStateTypeSchema), - error_msg: schema.maybe(schema.string()), - retry_error_msg: schema.maybe(schema.string()), - retry_until: schema.maybe(schema.string()), - }) - ), - }) + schema.oneOf([ + schema.literal(null), + schema.object({ + target_version: schema.string(), + action_id: schema.string(), + state: AgentUpgradeStateTypeSchema, + metadata: schema.maybe( + schema.object({ + scheduled_at: schema.maybe(schema.string()), + download_percent: schema.maybe(schema.number()), + download_rate: schema.maybe(schema.number()), + failed_state: schema.maybe(AgentUpgradeStateTypeSchema), + error_msg: schema.maybe(schema.string()), + retry_error_msg: schema.maybe(schema.string()), + retry_until: schema.maybe(schema.string()), + }) + ), + }), + ]) ), access_api_key_id: schema.maybe(schema.string()), default_api_key: schema.maybe(schema.string()), From 1fc3c38698e9874814814d9819da7bb6b66c8de6 Mon Sep 17 00:00:00 2001 From: kibanamachine <42973632+kibanamachine@users.noreply.github.com> Date: Tue, 3 Dec 2024 14:18:34 +0000 Subject: [PATCH 2/4] [CI] Auto-commit changed files from 'node scripts/capture_oas_snapshot --include-path /api/status --include-path /api/alerting/rule/ --include-path /api/alerting/rules --include-path /api/actions --include-path /api/security/role --include-path /api/spaces --include-path /api/fleet --update' --- oas_docs/bundle.json | 27 +++------------------------ oas_docs/bundle.serverless.json | 27 +++------------------------ 2 files changed, 6 insertions(+), 48 deletions(-) diff --git a/oas_docs/bundle.json b/oas_docs/bundle.json index b96aaa3a3ce00..0244960e1f55f 100644 --- a/oas_docs/bundle.json +++ b/oas_docs/bundle.json @@ -6547,9 +6547,6 @@ "type": "number" } }, - "required": [ - "enabled" - ], "type": "object" }, "monitoring_output_id": { @@ -7316,9 +7313,6 @@ "type": "number" } }, - "required": [ - "enabled" - ], "type": "object" }, "monitoring_output_id": { @@ -7577,9 +7571,6 @@ "type": "number" } }, - "required": [ - "enabled" - ], "type": "object" }, "monitoring_output_id": { @@ -8376,9 +8367,6 @@ "type": "number" } }, - "required": [ - "enabled" - ], "type": "object" }, "monitoring_output_id": { @@ -9436,9 +9424,6 @@ "type": "number" } }, - "required": [ - "enabled" - ], "type": "object" }, "monitoring_output_id": { @@ -10204,9 +10189,6 @@ "type": "number" } }, - "required": [ - "enabled" - ], "type": "object" }, "monitoring_output_id": { @@ -10465,9 +10447,6 @@ "type": "number" } }, - "required": [ - "enabled" - ], "type": "object" }, "monitoring_output_id": { @@ -11265,9 +11244,6 @@ "type": "number" } }, - "required": [ - "enabled" - ], "type": "object" }, "monitoring_output_id": { @@ -13278,6 +13254,7 @@ }, "upgrade_details": { "additionalProperties": false, + "nullable": true, "properties": { "action_id": { "type": "string" @@ -15470,6 +15447,7 @@ }, "upgrade_details": { "additionalProperties": false, + "nullable": true, "properties": { "action_id": { "type": "string" @@ -15958,6 +15936,7 @@ }, "upgrade_details": { "additionalProperties": false, + "nullable": true, "properties": { "action_id": { "type": "string" diff --git a/oas_docs/bundle.serverless.json b/oas_docs/bundle.serverless.json index 9115670ecb313..acfe609ea0c2f 100644 --- a/oas_docs/bundle.serverless.json +++ b/oas_docs/bundle.serverless.json @@ -6547,9 +6547,6 @@ "type": "number" } }, - "required": [ - "enabled" - ], "type": "object" }, "monitoring_output_id": { @@ -7316,9 +7313,6 @@ "type": "number" } }, - "required": [ - "enabled" - ], "type": "object" }, "monitoring_output_id": { @@ -7577,9 +7571,6 @@ "type": "number" } }, - "required": [ - "enabled" - ], "type": "object" }, "monitoring_output_id": { @@ -8376,9 +8367,6 @@ "type": "number" } }, - "required": [ - "enabled" - ], "type": "object" }, "monitoring_output_id": { @@ -9436,9 +9424,6 @@ "type": "number" } }, - "required": [ - "enabled" - ], "type": "object" }, "monitoring_output_id": { @@ -10204,9 +10189,6 @@ "type": "number" } }, - "required": [ - "enabled" - ], "type": "object" }, "monitoring_output_id": { @@ -10465,9 +10447,6 @@ "type": "number" } }, - "required": [ - "enabled" - ], "type": "object" }, "monitoring_output_id": { @@ -11265,9 +11244,6 @@ "type": "number" } }, - "required": [ - "enabled" - ], "type": "object" }, "monitoring_output_id": { @@ -13278,6 +13254,7 @@ }, "upgrade_details": { "additionalProperties": false, + "nullable": true, "properties": { "action_id": { "type": "string" @@ -15470,6 +15447,7 @@ }, "upgrade_details": { "additionalProperties": false, + "nullable": true, "properties": { "action_id": { "type": "string" @@ -15958,6 +15936,7 @@ }, "upgrade_details": { "additionalProperties": false, + "nullable": true, "properties": { "action_id": { "type": "string" From fc2eae34ae840422ab9c260837fbab2472193156 Mon Sep 17 00:00:00 2001 From: kibanamachine <42973632+kibanamachine@users.noreply.github.com> Date: Tue, 3 Dec 2024 14:36:17 +0000 Subject: [PATCH 3/4] [CI] Auto-commit changed files from 'make api-docs' --- oas_docs/output/kibana.serverless.yaml | 19 +++---------------- oas_docs/output/kibana.yaml | 19 +++---------------- 2 files changed, 6 insertions(+), 32 deletions(-) diff --git a/oas_docs/output/kibana.serverless.yaml b/oas_docs/output/kibana.serverless.yaml index b605ab09de62f..142c0742614fb 100644 --- a/oas_docs/output/kibana.serverless.yaml +++ b/oas_docs/output/kibana.serverless.yaml @@ -9628,8 +9628,6 @@ paths: maximum: 65353 minimum: 0 type: number - required: - - enabled monitoring_output_id: nullable: true type: string @@ -10160,8 +10158,6 @@ paths: maximum: 65353 minimum: 0 type: number - required: - - enabled monitoring_output_id: nullable: true type: string @@ -10342,8 +10338,6 @@ paths: maximum: 65353 minimum: 0 type: number - required: - - enabled monitoring_output_id: nullable: true type: string @@ -10896,8 +10890,6 @@ paths: maximum: 65353 minimum: 0 type: number - required: - - enabled monitoring_output_id: nullable: true type: string @@ -11430,8 +11422,6 @@ paths: maximum: 65353 minimum: 0 type: number - required: - - enabled monitoring_output_id: nullable: true type: string @@ -11961,8 +11951,6 @@ paths: maximum: 65353 minimum: 0 type: number - required: - - enabled monitoring_output_id: nullable: true type: string @@ -12143,8 +12131,6 @@ paths: maximum: 65353 minimum: 0 type: number - required: - - enabled monitoring_output_id: nullable: true type: string @@ -12697,8 +12683,6 @@ paths: maximum: 65353 minimum: 0 type: number - required: - - enabled monitoring_output_id: nullable: true type: string @@ -14248,6 +14232,7 @@ paths: type: array upgrade_details: additionalProperties: false + nullable: true type: object properties: action_id: @@ -14715,6 +14700,7 @@ paths: type: array upgrade_details: additionalProperties: false + nullable: true type: object properties: action_id: @@ -15059,6 +15045,7 @@ paths: type: array upgrade_details: additionalProperties: false + nullable: true type: object properties: action_id: diff --git a/oas_docs/output/kibana.yaml b/oas_docs/output/kibana.yaml index b1f2186262365..0abbcc4b4a102 100644 --- a/oas_docs/output/kibana.yaml +++ b/oas_docs/output/kibana.yaml @@ -12489,8 +12489,6 @@ paths: maximum: 65353 minimum: 0 type: number - required: - - enabled monitoring_output_id: nullable: true type: string @@ -13020,8 +13018,6 @@ paths: maximum: 65353 minimum: 0 type: number - required: - - enabled monitoring_output_id: nullable: true type: string @@ -13202,8 +13198,6 @@ paths: maximum: 65353 minimum: 0 type: number - required: - - enabled monitoring_output_id: nullable: true type: string @@ -13755,8 +13749,6 @@ paths: maximum: 65353 minimum: 0 type: number - required: - - enabled monitoring_output_id: nullable: true type: string @@ -14288,8 +14280,6 @@ paths: maximum: 65353 minimum: 0 type: number - required: - - enabled monitoring_output_id: nullable: true type: string @@ -14818,8 +14808,6 @@ paths: maximum: 65353 minimum: 0 type: number - required: - - enabled monitoring_output_id: nullable: true type: string @@ -15000,8 +14988,6 @@ paths: maximum: 65353 minimum: 0 type: number - required: - - enabled monitoring_output_id: nullable: true type: string @@ -15553,8 +15539,6 @@ paths: maximum: 65353 minimum: 0 type: number - required: - - enabled monitoring_output_id: nullable: true type: string @@ -17096,6 +17080,7 @@ paths: type: array upgrade_details: additionalProperties: false + nullable: true type: object properties: action_id: @@ -17560,6 +17545,7 @@ paths: type: array upgrade_details: additionalProperties: false + nullable: true type: object properties: action_id: @@ -17903,6 +17889,7 @@ paths: type: array upgrade_details: additionalProperties: false + nullable: true type: object properties: action_id: From a989467f628d88771c8dd5f8541a77747c30a0f8 Mon Sep 17 00:00:00 2001 From: Julia Bardi Date: Tue, 3 Dec 2024 16:38:48 +0100 Subject: [PATCH 4/4] fix checks --- x-pack/plugins/fleet/common/types/models/agent_policy.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/x-pack/plugins/fleet/common/types/models/agent_policy.ts b/x-pack/plugins/fleet/common/types/models/agent_policy.ts index fb19953a1f731..0d180a0f4935a 100644 --- a/x-pack/plugins/fleet/common/types/models/agent_policy.ts +++ b/x-pack/plugins/fleet/common/types/models/agent_policy.ts @@ -46,7 +46,7 @@ export interface NewAgentPolicy { global_data_tags?: GlobalDataTag[]; monitoring_pprof_enabled?: boolean; monitoring_http?: { - enabled: boolean; + enabled?: boolean; host?: string; port?: number; buffer?: {