diff --git a/x-pack/plugins/fleet/common/openapi/bundled.json b/x-pack/plugins/fleet/common/openapi/bundled.json index 77f0bcae3ed0a..44d40cdabeb60 100644 --- a/x-pack/plugins/fleet/common/openapi/bundled.json +++ b/x-pack/plugins/fleet/common/openapi/bundled.json @@ -6997,10 +6997,10 @@ "nullable": true }, "unenroll_timeout": { - "type": "number" + "type": "integer" }, "inactivity_timeout": { - "type": "number" + "type": "integer" }, "package_policies": { "description": "This field is present only when retrieving a single agent policy, or when retrieving a list of agent policies with the ?full=true parameter", @@ -7100,10 +7100,10 @@ "nullable": true }, "unenroll_timeout": { - "type": "number" + "type": "integer" }, "inactivity_timeout": { - "type": "number" + "type": "integer" }, "agent_features": { "type": "array", @@ -7172,10 +7172,10 @@ "nullable": true }, "unenroll_timeout": { - "type": "number" + "type": "integer" }, "inactivity_timeout": { - "type": "number" + "type": "integer" }, "agent_features": { "type": "array", diff --git a/x-pack/plugins/fleet/common/openapi/bundled.yaml b/x-pack/plugins/fleet/common/openapi/bundled.yaml index bb80c1d16723f..8cbc587b657a8 100644 --- a/x-pack/plugins/fleet/common/openapi/bundled.yaml +++ b/x-pack/plugins/fleet/common/openapi/bundled.yaml @@ -4472,9 +4472,9 @@ components: type: string nullable: true unenroll_timeout: - type: number + type: integer inactivity_timeout: - type: number + type: integer package_policies: description: >- This field is present only when retrieving a single agent policy, or @@ -4553,9 +4553,9 @@ components: type: string nullable: true unenroll_timeout: - type: number + type: integer inactivity_timeout: - type: number + type: integer agent_features: type: array items: @@ -4603,9 +4603,9 @@ components: type: string nullable: true unenroll_timeout: - type: number + type: integer inactivity_timeout: - type: number + type: integer agent_features: type: array items: diff --git a/x-pack/plugins/fleet/common/openapi/components/schemas/agent_policy.yaml b/x-pack/plugins/fleet/common/openapi/components/schemas/agent_policy.yaml index ac29a287b91c8..7def81c1318b1 100644 --- a/x-pack/plugins/fleet/common/openapi/components/schemas/agent_policy.yaml +++ b/x-pack/plugins/fleet/common/openapi/components/schemas/agent_policy.yaml @@ -29,9 +29,9 @@ properties: type: string nullable: true unenroll_timeout: - type: number + type: integer inactivity_timeout: - type: number + type: integer package_policies: description: This field is present only when retrieving a single agent policy, or when retrieving a list of agent policies with the ?full=true parameter type: array diff --git a/x-pack/plugins/fleet/common/openapi/components/schemas/agent_policy_create_request.yaml b/x-pack/plugins/fleet/common/openapi/components/schemas/agent_policy_create_request.yaml index 68009b3cc7a8c..e1d94c69a0d24 100644 --- a/x-pack/plugins/fleet/common/openapi/components/schemas/agent_policy_create_request.yaml +++ b/x-pack/plugins/fleet/common/openapi/components/schemas/agent_policy_create_request.yaml @@ -29,9 +29,9 @@ properties: type: string nullable: true unenroll_timeout: - type: number + type: integer inactivity_timeout: - type: number + type: integer agent_features: type: array items: diff --git a/x-pack/plugins/fleet/common/openapi/components/schemas/agent_policy_update_request.yaml b/x-pack/plugins/fleet/common/openapi/components/schemas/agent_policy_update_request.yaml index 81eb81790e8f7..0500c94871192 100644 --- a/x-pack/plugins/fleet/common/openapi/components/schemas/agent_policy_update_request.yaml +++ b/x-pack/plugins/fleet/common/openapi/components/schemas/agent_policy_update_request.yaml @@ -27,9 +27,9 @@ properties: type: string nullable: true unenroll_timeout: - type: number + type: integer inactivity_timeout: - type: number + type: integer agent_features: type: array items: 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 0fb27475c0779..255138f6e566a 100644 --- a/x-pack/plugins/fleet/server/types/models/agent_policy.ts +++ b/x-pack/plugins/fleet/server/types/models/agent_policy.ts @@ -19,6 +19,12 @@ function validateNonEmptyString(val: string) { const TWO_WEEKS_SECONDS = 1209600; +function isInteger(n: number) { + if (!Number.isInteger(n)) { + return `${n} is not a valid integer`; + } +} + export const AgentPolicyBaseSchema = { id: schema.maybe(schema.string()), name: schema.string({ minLength: 1, validate: validateNonEmptyString }), @@ -28,8 +34,12 @@ export const AgentPolicyBaseSchema = { has_fleet_server: schema.maybe(schema.boolean()), is_default: schema.maybe(schema.boolean()), is_default_fleet_server: schema.maybe(schema.boolean()), - unenroll_timeout: schema.maybe(schema.number({ min: 0 })), - inactivity_timeout: schema.number({ min: 0, defaultValue: TWO_WEEKS_SECONDS }), + unenroll_timeout: schema.maybe(schema.number({ min: 0, validate: isInteger })), + inactivity_timeout: schema.number({ + min: 0, + defaultValue: TWO_WEEKS_SECONDS, + validate: isInteger, + }), monitoring_enabled: schema.maybe( schema.arrayOf( schema.oneOf([schema.literal(dataTypes.Logs), schema.literal(dataTypes.Metrics)])