[Fleet] Fix OpenAPI for agent policy (#152108)

This commit is contained in:
Nicolas Chaulet 2023-02-24 10:40:29 -05:00 committed by GitHub
parent eb9cc11a7c
commit e1f73db5bf
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 525 additions and 280 deletions

View file

@ -2689,7 +2689,7 @@
"content": { "content": {
"application/json": { "application/json": {
"schema": { "schema": {
"$ref": "#/components/schemas/new_agent_policy" "$ref": "#/components/schemas/agent_policy_create_request"
} }
} }
} }
@ -2774,7 +2774,7 @@
"content": { "content": {
"application/json": { "application/json": {
"schema": { "schema": {
"$ref": "#/components/schemas/new_agent_policy" "$ref": "#/components/schemas/agent_policy_update_request"
} }
} }
} }
@ -5956,60 +5956,6 @@
} }
} }
}, },
"new_agent_policy": {
"title": "New agent policy",
"type": "object",
"properties": {
"id": {
"type": "string"
},
"name": {
"type": "string"
},
"namespace": {
"type": "string"
},
"description": {
"type": "string"
},
"monitoring_enabled": {
"type": "array",
"items": {
"type": "string",
"enum": [
"metrics",
"logs"
]
}
},
"data_output_id": {
"type": "string",
"nullable": true
},
"monitoring_output_id": {
"type": "string",
"nullable": true
},
"fleet_server_host_id": {
"type": "string",
"nullable": true
},
"download_source_id": {
"type": "string",
"nullable": true
},
"unenroll_timeout": {
"type": "number"
},
"inactivity_timeout": {
"type": "number"
}
},
"required": [
"name",
"namespace"
]
},
"new_package_policy": { "new_package_policy": {
"title": "New package policy", "title": "New package policy",
"type": "object", "type": "object",
@ -6120,83 +6066,238 @@
] ]
}, },
"agent_policy": { "agent_policy": {
"allOf": [ "title": "Agent Policy",
{ "type": "object",
"$ref": "#/components/schemas/new_agent_policy" "properties": {
"id": {
"type": "string"
}, },
{ "name": {
"type": "object", "type": "string"
"properties": { },
"id": { "namespace": {
"type": "string" "type": "string"
}, },
"status": { "description": {
"type": "string", "type": "string"
"enum": [ },
"active", "monitoring_enabled": {
"inactive" "type": "array",
] "items": {
}, "type": "string",
"package_policies": { "enum": [
"description": "This field is present only when retrieving a single agent policy, or when retrieving a list of agent policy with the ?full=true parameter", "metrics",
"type": "array", "logs"
"items": { ]
"$ref": "#/components/schemas/package_policy" }
},
"data_output_id": {
"type": "string",
"nullable": true
},
"monitoring_output_id": {
"type": "string",
"nullable": true
},
"fleet_server_host_id": {
"type": "string",
"nullable": true
},
"download_source_id": {
"type": "string",
"nullable": true
},
"unenroll_timeout": {
"type": "number"
},
"inactivity_timeout": {
"type": "number"
},
"package_policies": {
"description": "This field is present only when retrieving a single agent policy, or when retrieving a list of agent policy with the ?full=true parameter",
"type": "array",
"items": {
"$ref": "#/components/schemas/package_policy"
}
},
"updated_on": {
"type": "string",
"format": "date-time"
},
"updated_by": {
"type": "string"
},
"revision": {
"type": "number"
},
"agents": {
"type": "number"
},
"agent_features": {
"type": "array",
"items": {
"type": "object",
"properties": {
"name": {
"type": "string"
},
"enabled": {
"type": "boolean"
} }
}, },
"updated_on": { "required": [
"type": "string", "name",
"format": "date-time" "enabled"
}, ]
"updated_by": { }
"type": "string"
},
"data_output_id": {
"type": "string",
"nullable": true
},
"monitoring_output_id": {
"type": "string",
"nullable": true
},
"fleet_server_host_id": {
"type": "string",
"nullable": true
},
"download_source_id": {
"type": "string",
"nullable": true
},
"revision": {
"type": "number"
},
"agents": {
"type": "number"
},
"agent_features": {
"type": "array",
"items": {
"type": "object",
"properties": {
"name": {
"type": "string"
},
"enabled": {
"type": "boolean"
}
},
"required": [
"name",
"enabled"
]
}
}
},
"required": [
"id",
"status"
]
} }
},
"required": [
"id",
"status",
"name",
"namespace"
]
},
"agent_policy_create_request": {
"title": "Create agent policy request",
"type": "object",
"properties": {
"id": {
"type": "string"
},
"name": {
"type": "string"
},
"namespace": {
"type": "string"
},
"description": {
"type": "string"
},
"monitoring_enabled": {
"type": "array",
"items": {
"type": "string",
"enum": [
"metrics",
"logs"
]
}
},
"data_output_id": {
"type": "string",
"nullable": true
},
"monitoring_output_id": {
"type": "string",
"nullable": true
},
"fleet_server_host_id": {
"type": "string",
"nullable": true
},
"download_source_id": {
"type": "string",
"nullable": true
},
"unenroll_timeout": {
"type": "number"
},
"inactivity_timeout": {
"type": "number"
},
"agent_features": {
"type": "array",
"items": {
"type": "object",
"properties": {
"name": {
"type": "string"
},
"enabled": {
"type": "boolean"
}
},
"required": [
"name",
"enabled"
]
}
}
},
"required": [
"name",
"namespace"
]
},
"agent_policy_update_request": {
"title": "Update agent policy request",
"type": "object",
"properties": {
"name": {
"type": "string"
},
"namespace": {
"type": "string"
},
"description": {
"type": "string"
},
"monitoring_enabled": {
"type": "array",
"items": {
"type": "string",
"enum": [
"metrics",
"logs"
]
}
},
"data_output_id": {
"type": "string",
"nullable": true
},
"monitoring_output_id": {
"type": "string",
"nullable": true
},
"fleet_server_host_id": {
"type": "string",
"nullable": true
},
"download_source_id": {
"type": "string",
"nullable": true
},
"unenroll_timeout": {
"type": "number"
},
"inactivity_timeout": {
"type": "number"
},
"agent_features": {
"type": "array",
"items": {
"type": "object",
"properties": {
"name": {
"type": "string"
},
"enabled": {
"type": "boolean"
}
},
"required": [
"name",
"enabled"
]
}
}
},
"required": [
"name",
"namespace"
] ]
}, },
"full_agent_policy_output": { "full_agent_policy_output": {

View file

@ -1675,7 +1675,7 @@ paths:
content: content:
application/json: application/json:
schema: schema:
$ref: '#/components/schemas/new_agent_policy' $ref: '#/components/schemas/agent_policy_create_request'
security: [] security: []
parameters: parameters:
- $ref: '#/components/parameters/kbn_xsrf' - $ref: '#/components/parameters/kbn_xsrf'
@ -1728,7 +1728,7 @@ paths:
content: content:
application/json: application/json:
schema: schema:
$ref: '#/components/schemas/new_agent_policy' $ref: '#/components/schemas/agent_policy_update_request'
parameters: parameters:
- $ref: '#/components/parameters/kbn_xsrf' - $ref: '#/components/parameters/kbn_xsrf'
/agent_policies/{agentPolicyId}/copy: /agent_policies/{agentPolicyId}/copy:
@ -3797,44 +3797,6 @@ components:
type: array type: array
items: items:
type: string type: string
new_agent_policy:
title: New agent policy
type: object
properties:
id:
type: string
name:
type: string
namespace:
type: string
description:
type: string
monitoring_enabled:
type: array
items:
type: string
enum:
- metrics
- logs
data_output_id:
type: string
nullable: true
monitoring_output_id:
type: string
nullable: true
fleet_server_host_id:
type: string
nullable: true
download_source_id:
type: string
nullable: true
unenroll_timeout:
type: number
inactivity_timeout:
type: number
required:
- name
- namespace
new_package_policy: new_package_policy:
title: New package policy title: New package policy
type: object type: object
@ -3908,61 +3870,171 @@ components:
- revision - revision
- $ref: '#/components/schemas/new_package_policy' - $ref: '#/components/schemas/new_package_policy'
agent_policy: agent_policy:
allOf: title: Agent Policy
- $ref: '#/components/schemas/new_agent_policy' type: object
- type: object properties:
properties: id:
id: type: string
type: string name:
status: type: string
type: string namespace:
enum: type: string
- active description:
- inactive type: string
package_policies: monitoring_enabled:
description: >- type: array
This field is present only when retrieving a single agent items:
policy, or when retrieving a list of agent policy with the type: string
?full=true parameter enum:
type: array - metrics
items: - logs
$ref: '#/components/schemas/package_policy' data_output_id:
updated_on: type: string
type: string nullable: true
format: date-time monitoring_output_id:
updated_by: type: string
type: string nullable: true
data_output_id: fleet_server_host_id:
type: string type: string
nullable: true nullable: true
monitoring_output_id: download_source_id:
type: string type: string
nullable: true nullable: true
fleet_server_host_id: unenroll_timeout:
type: string type: number
nullable: true inactivity_timeout:
download_source_id: type: number
type: string package_policies:
nullable: true description: >-
revision: This field is present only when retrieving a single agent policy, or
type: number when retrieving a list of agent policy with the ?full=true parameter
agents: type: array
type: number items:
agent_features: $ref: '#/components/schemas/package_policy'
type: array updated_on:
items: type: string
type: object format: date-time
properties: updated_by:
name: type: string
type: string revision:
enabled: type: number
type: boolean agents:
required: type: number
- name agent_features:
- enabled type: array
required: items:
- id type: object
- status properties:
name:
type: string
enabled:
type: boolean
required:
- name
- enabled
required:
- id
- status
- name
- namespace
agent_policy_create_request:
title: Create agent policy request
type: object
properties:
id:
type: string
name:
type: string
namespace:
type: string
description:
type: string
monitoring_enabled:
type: array
items:
type: string
enum:
- metrics
- logs
data_output_id:
type: string
nullable: true
monitoring_output_id:
type: string
nullable: true
fleet_server_host_id:
type: string
nullable: true
download_source_id:
type: string
nullable: true
unenroll_timeout:
type: number
inactivity_timeout:
type: number
agent_features:
type: array
items:
type: object
properties:
name:
type: string
enabled:
type: boolean
required:
- name
- enabled
required:
- name
- namespace
agent_policy_update_request:
title: Update agent policy request
type: object
properties:
name:
type: string
namespace:
type: string
description:
type: string
monitoring_enabled:
type: array
items:
type: string
enum:
- metrics
- logs
data_output_id:
type: string
nullable: true
monitoring_output_id:
type: string
nullable: true
fleet_server_host_id:
type: string
nullable: true
download_source_id:
type: string
nullable: true
unenroll_timeout:
type: number
inactivity_timeout:
type: number
agent_features:
type: array
items:
type: object
properties:
name:
type: string
enabled:
type: boolean
required:
- name
- enabled
required:
- name
- namespace
full_agent_policy_output: full_agent_policy_output:
title: Full agent policy title: Full agent policy
type: object type: object

View file

@ -1,52 +1,65 @@
allOf: title: Agent Policy
- $ref: ./new_agent_policy.yaml type: object
- type: object properties:
properties: id:
id: type: string
type: string name:
status: type: string
type: string namespace:
enum: type: string
- active description:
- inactive type: string
package_policies: monitoring_enabled:
description: This field is present only when retrieving a single agent policy, or when retrieving a list of agent policy with the ?full=true parameter type: array
type: array items:
items: type: string
$ref: ./package_policy.yaml enum:
updated_on: - metrics
type: string - logs
format: date-time data_output_id:
updated_by: type: string
type: string nullable: true
data_output_id: monitoring_output_id:
type: string type: string
nullable: true nullable: true
monitoring_output_id: fleet_server_host_id:
type: string type: string
nullable: true nullable: true
fleet_server_host_id: download_source_id:
type: string type: string
nullable: true nullable: true
download_source_id: unenroll_timeout:
type: string type: number
nullable: true inactivity_timeout:
revision: type: number
type: number package_policies:
agents: description: This field is present only when retrieving a single agent policy, or when retrieving a list of agent policy with the ?full=true parameter
type: number type: array
agent_features: items:
type: array $ref: ./package_policy.yaml
items: updated_on:
type: object type: string
properties: format: date-time
name: updated_by:
type: string type: string
enabled: revision:
type: boolean type: number
required: agents:
- name type: number
- enabled agent_features:
required: type: array
- id items:
- status type: object
properties:
name:
type: string
enabled:
type: boolean
required:
- name
- enabled
required:
- id
- status
- name
- namespace

View file

@ -1,4 +1,4 @@
title: New agent policy title: Create agent policy request
type: object type: object
properties: properties:
id: id:
@ -32,6 +32,18 @@ properties:
type: number type: number
inactivity_timeout: inactivity_timeout:
type: number type: number
agent_features:
type: array
items:
type: object
properties:
name:
type: string
enabled:
type: boolean
required:
- name
- enabled
required: required:
- name - name
- namespace - namespace

View file

@ -0,0 +1,47 @@
title: Update agent policy request
type: object
properties:
name:
type: string
namespace:
type: string
description:
type: string
monitoring_enabled:
type: array
items:
type: string
enum:
- metrics
- logs
data_output_id:
type: string
nullable: true
monitoring_output_id:
type: string
nullable: true
fleet_server_host_id:
type: string
nullable: true
download_source_id:
type: string
nullable: true
unenroll_timeout:
type: number
inactivity_timeout:
type: number
agent_features:
type: array
items:
type: object
properties:
name:
type: string
enabled:
type: boolean
required:
- name
- enabled
required:
- name
- namespace

View file

@ -40,7 +40,7 @@ get:
type: boolean type: boolean
in: query in: query
name: noAgentCount name: noAgentCount
description: When set to true, do not count how many agents are in the agent policy, this can improve performance if you are searching over a large number of agent policies. The "agents" property will always be 0 if set to true. description: When set to true, do not count how many agents are in the agent policy, this can improve performance if you are searching over a large number of agent policies. The "agents" property will always be 0 if set to true.
description: '' description: ''
post: post:
@ -63,7 +63,7 @@ post:
content: content:
application/json: application/json:
schema: schema:
$ref: ../components/schemas/new_agent_policy.yaml $ref: ../components/schemas/agent_policy_create_request.yaml
security: [] security: []
parameters: parameters:
- $ref: ../components/headers/kbn_xsrf.yaml - $ref: ../components/headers/kbn_xsrf.yaml

View file

@ -46,6 +46,6 @@ put:
content: content:
application/json: application/json:
schema: schema:
$ref: ../components/schemas/new_agent_policy.yaml $ref: ../components/schemas/agent_policy_update_request.yaml
parameters: parameters:
- $ref: ../components/headers/kbn_xsrf.yaml - $ref: ../components/headers/kbn_xsrf.yaml