Skip to content

Commit

Permalink
[Fleet] OpenAPI - add missing routes and clean up names, types, etc (#…
Browse files Browse the repository at this point in the history
…106464) (#106540)

### Add specs for several missing routes
See additions in `openapi/entrypoint.yaml`

- `/agents/{agentId}/reassign`
- `/agents/bulk_reassign`
- `/agents/bulk_unenroll`
- `/package_policies/delete`

### Add enum of string values for delete package response
See 5c04dfc

### Fixed inaccurate operation spec
spec for `delete-agent-policy` operation currently shows it accepting an array of ids`agentPolicyIds: string[]`  and returning an array of results, but it actually accepts a single `agentPolicyId: string` id an returns a single object

### Internal changes
#### Better / more consistent operation names
e.g.

```diff
-  operationId: post-agent-policy
+  operationId: create-agent-policy
```
and 
```diff
-  operationId: put-agent-policy-agentPolicyId
+  operationId: update-agent-policy
```

#### Better schema titles
e.g.
```diff
- title: UpdatePackagePolicy
+ title: Update package policy
```

Co-authored-by: John Schulz <[email protected]>
  • Loading branch information
kibanamachine and John Schulz authored Jul 22, 2021
1 parent 78b3b3b commit d28b7a4
Show file tree
Hide file tree
Showing 41 changed files with 1,016 additions and 312 deletions.
558 changes: 441 additions & 117 deletions x-pack/plugins/fleet/common/openapi/bundled.json

Large diffs are not rendered by default.

382 changes: 286 additions & 96 deletions x-pack/plugins/fleet/common/openapi/bundled.yaml

Large diffs are not rendered by default.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
title: AgentMetadata
title: Agent metadata
type: object
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,12 @@ allOf:
- inactive
packagePolicies:
oneOf:
- items:
- type: array
items:
type: string
- items:
- type: array
items:
$ref: ./package_policy.yaml
type: array
updated_on:
type: string
format: date-time
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
type: string
title: AgentStatus
title: Agent status
enum:
- offline
- error
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
type: string
title: AgentType
title: Agent type
enum:
- PERMANENT
- EPHEMERAL
Expand Down
Original file line number Diff line number Diff line change
@@ -1,37 +1,16 @@
title: BulkUpgradeAgents
oneOf:
- type: object
properties:
version:
type: string
agents:
type: array
title: Bulk upgrade agents
type: object
properties:
version:
type: string
source_uri:
type: string
agents:
oneOf:
- type: array
items:
type: string
required:
- version
- agents
- type: object
properties:
version:
type: string
source_uri:
type: string
agents:
type: array
items:
type: string
required:
- version
- agents
- type: object
properties:
version:
type: string
source_uri:
type: string
agents:
type: string
required:
- version
- agents
- type: string
required:
- agents
- version
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
title: Elasticsearch asset type
type: string
enum:
- component_template
- ingest_pipeline
- index_template
- ilm_policy
- transform
- data_stream_ilm_policy
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
title: EnrollmentApiKey
title: Enrollment API key
type: object
properties:
id:
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
title: Kibana saved object asset type
type: string
enum:
- dashboard
- visualization
- search
- index-pattern
- map
- lens
- ml-module
- security-rule
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
title: NewAgentPolicy
title: New agent policy
type: object
properties:
name:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
title: NewPackagePolicy
title: New package policy
type: object
description: ''
properties:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
title: PackageInfo
title: Package information
type: object
properties:
name:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
title: PackagePolicy
title: Package policy
allOf:
- type: object
properties:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
title: SearchResult
title: Search result
type: object
properties:
description:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
title: UpdatePackagePolicy
title: Update package policy
allOf:
- type: object
properties:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
title: UpgradeAgent
title: Upgrade agent
oneOf:
- type: object
properties:
Expand Down
8 changes: 8 additions & 0 deletions x-pack/plugins/fleet/common/openapi/entrypoint.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,16 @@ paths:
$ref: paths/agents@bulk_upgrade.yaml
'/agents/{agentId}':
$ref: 'paths/agents@{agent_id}.yaml'
'/agents/{agentId}/reassign':
$ref: 'paths/agents@{agent_id}@reassign.yaml'
'/agents/{agentId}/unenroll':
$ref: 'paths/agents@{agent_id}@unenroll.yaml'
'/agents/{agentId}/upgrade':
$ref: 'paths/agents@{agent_id}@upgrade.yaml'
'/agents/bulk_reassign':
$ref: 'paths/agents@bulk_reassign.yaml'
'/agents/bulk_unenroll':
$ref: 'paths/agents@bulk_unenroll.yaml'
/agent_policies:
$ref: paths/agent_policies.yaml
'/agent_policies/{agentPolicyId}':
Expand All @@ -52,6 +58,8 @@ paths:
$ref: 'paths/enrollment_api_keys@{key_id}.yaml'
/package_policies:
$ref: paths/package_policies.yaml
/package_policies/delete:
$ref: paths/[email protected]
'/package_policies/{packagePolicyId}':
$ref: 'paths/package_policies@{package_policy_id}.yaml'
components:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ post:
properties:
item:
$ref: ../components/schemas/agent_policy.yaml
operationId: post-agent-policy
operationId: create-agent-policy
requestBody:
content:
application/json:
Expand Down
30 changes: 14 additions & 16 deletions x-pack/plugins/fleet/common/openapi/paths/[email protected]
Original file line number Diff line number Diff line change
@@ -1,33 +1,31 @@
post:
summary: Agent policy - Delete
operationId: post-agent-policy-delete
operationId: delete-agent-policy
responses:
'200':
description: OK
content:
application/json:
schema:
type: array
items:
type: object
properties:
id:
type: string
success:
type: boolean
required:
- id
- success
type: object
properties:
id:
type: string
success:
type: boolean
required:
- id
- success
requestBody:
content:
application/json:
schema:
type: object
properties:
agentPolicyIds:
type: array
items:
type: string
agentPolicyId:
type: string
required:
- agentPolicyId
parameters:
- $ref: ../components/headers/kbn_xsrf.yaml
parameters: []
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ put:
$ref: ../components/schemas/agent_policy.yaml
required:
- item
operationId: put-agent-policy-agentPolicyId
operationId: update-agent-policy
requestBody:
content:
application/json:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ get:
- other
- total
- updating
operationId: get-fleet-agent-status
operationId: get-agent-status
parameters:
- schema:
type: string
Expand Down
2 changes: 1 addition & 1 deletion x-pack/plugins/fleet/common/openapi/paths/agents.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,6 @@ get:
- total
- page
- perPage
operationId: get-fleet-agents
operationId: get-agents
security:
- basicAuth: []
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
post:
summary: Agents - Bulk reassign
tags: []
responses:
'200':
description: OK
content:
application/json:
schema:
type: object
additionalProperties:
type: object
properties:
success:
type: boolean
error:
type: string
required:
- success
operationId: bulk-reassign-agents
parameters:
- $ref: ../components/headers/kbn_xsrf.yaml
requestBody:
content:
application/json:
schema:
type: object
properties:
policy_id:
type: string
agents:
oneOf:
- type: string
- type: array
items:
type: string
required:
- policy_id
- agents
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
post:
summary: Agents - Bulk unenroll
tags: []
responses:
'200':
description: OK
content:
application/json:
schema:
type: object
additionalProperties:
type: object
properties:
success:
type: boolean
error:
type: string
required:
- success
operationId: bulk-unenroll-agents
parameters:
- $ref: ../components/headers/kbn_xsrf.yaml
requestBody:
content:
application/json:
schema:
type: object
properties:
revoke:
type: boolean
force:
type: boolean
agents:
oneOf:
- type: string
- type: array
items:
type: string
required:
- agents
13 changes: 11 additions & 2 deletions x-pack/plugins/fleet/common/openapi/paths/agents@bulk_upgrade.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,23 @@ post:
content:
application/json:
schema:
$ref: ../components/schemas/bulk_upgrade_agents.yaml
type: object
additionalProperties:
type: object
properties:
success:
type: boolean
error:
type: string
required:
- success
'400':
description: BAD REQUEST
content:
application/json:
schema:
$ref: ../components/schemas/upgrade_agent.yaml
operationId: post-fleet-agents-bulk-upgrade
operationId: bulk-upgrade-agents
parameters:
- $ref: ../components/headers/kbn_xsrf.yaml
requestBody:
Expand Down
4 changes: 2 additions & 2 deletions x-pack/plugins/fleet/common/openapi/paths/[email protected]
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,12 @@ get:
application/json:
schema:
$ref: ../components/schemas/fleet_status_response.yaml
operationId: get-agents-setup
operationId: get-agents-setup-status
security:
- basicAuth: []
post:
summary: Agents setup - Create
operationId: post-agents-setup
operationId: setup-agents
responses:
'200':
description: OK
Expand Down
Loading

0 comments on commit d28b7a4

Please sign in to comment.