Skip to content

Commit

Permalink
[Fleet] Simplified package policy create API, enriching default values (
Browse files Browse the repository at this point in the history
#119739) (#120576)

* simplified api, enriching default values

* removed comment

* reverted changes in common models

* fixed handlers test

* separated create schema

* fixed test

* removed throwing error

* getting package info from registry only

* fix type

* fix test and new tests

* simplified update api

* updated open api spec

* fixed compiled_input

* added policy_template enrich

Co-authored-by: Kibana Machine <[email protected]>

Co-authored-by: Julia Bardi <[email protected]>
  • Loading branch information
kibanamachine and juliaElastic authored Dec 7, 2021
1 parent 8f57ac7 commit ef882c2
Show file tree
Hide file tree
Showing 11 changed files with 743 additions and 83 deletions.
85 changes: 74 additions & 11 deletions x-pack/plugins/fleet/common/openapi/bundled.json
Original file line number Diff line number Diff line change
Expand Up @@ -2673,8 +2673,7 @@
},
"required": [
"name",
"version",
"title"
"version"
]
},
"namespace": {
Expand Down Expand Up @@ -2713,8 +2712,7 @@
},
"required": [
"type",
"enabled",
"streams"
"enabled"
]
}
},
Expand All @@ -2729,9 +2727,7 @@
}
},
"required": [
"output_id",
"inputs",
"policy_id",
"name"
]
},
Expand Down Expand Up @@ -2858,19 +2854,86 @@
},
"update_package_policy": {
"title": "Update package policy",
"allOf": [
{
"type": "object",
"description": "",
"properties": {
"version": {
"type": "string"
},
"enabled": {
"type": "boolean"
},
"package": {
"type": "object",
"properties": {
"name": {
"type": "string"
},
"version": {
"type": "string"
},
"title": {
"type": "string"
}
},
"required": [
"name",
"title",
"version"
]
},
"namespace": {
"type": "string"
},
"output_id": {
"type": "string"
},
"inputs": {
"type": "array",
"items": {
"type": "object",
"properties": {
"type": {
"type": "string"
},
"enabled": {
"type": "boolean"
},
"processors": {
"type": "array",
"items": {
"type": "string"
}
},
"streams": {
"type": "array",
"items": {}
},
"config": {
"type": "object"
},
"vars": {
"type": "object"
}
},
"required": [
"type",
"enabled",
"streams"
]
}
},
{
"$ref": "#/components/schemas/new_package_policy"
"policy_id": {
"type": "string"
},
"name": {
"type": "string"
},
"description": {
"type": "string"
}
]
},
"required": null
},
"output": {
"title": "Output",
Expand Down
59 changes: 52 additions & 7 deletions x-pack/plugins/fleet/common/openapi/bundled.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1683,7 +1683,6 @@ components:
required:
- name
- version
- title
namespace:
type: string
output_id:
Expand Down Expand Up @@ -1711,17 +1710,14 @@ components:
required:
- type
- enabled
- streams
policy_id:
type: string
name:
type: string
description:
type: string
required:
- output_id
- inputs
- policy_id
- name
package_policy:
title: Package policy
Expand Down Expand Up @@ -1801,12 +1797,61 @@ components:
items: {}
update_package_policy:
title: Update package policy
allOf:
- type: object
type: object
description: ''
properties:
version:
type: string
enabled:
type: boolean
package:
type: object
properties:
name:
type: string
version:
type: string
- $ref: '#/components/schemas/new_package_policy'
title:
type: string
required:
- name
- title
- version
namespace:
type: string
output_id:
type: string
inputs:
type: array
items:
type: object
properties:
type:
type: string
enabled:
type: boolean
processors:
type: array
items:
type: string
streams:
type: array
items: {}
config:
type: object
vars:
type: object
required:
- type
- enabled
- streams
policy_id:
type: string
name:
type: string
description:
type: string
required: null
output:
title: Output
type: object
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ properties:
required:
- name
- version
- title
namespace:
type: string
output_id:
Expand Down Expand Up @@ -44,15 +43,12 @@ properties:
required:
- type
- enabled
- streams
policy_id:
type: string
name:
type: string
description:
type: string
required:
- output_id
- inputs
- policy_id
- name
Original file line number Diff line number Diff line change
@@ -1,7 +1,56 @@
title: Update package policy
allOf:
- type: object
type: object
description: ''
properties:
version:
type: string
enabled:
type: boolean
package:
type: object
properties:
name:
type: string
version:
type: string
- $ref: ./new_package_policy.yaml
title:
type: string
required:
- name
- title
- version
namespace:
type: string
output_id:
type: string
inputs:
type: array
items:
type: object
properties:
type:
type: string
enabled:
type: boolean
processors:
type: array
items:
type: string
streams:
type: array
items: {}
config:
type: object
vars:
type: object
required:
- type
- enabled
- streams
policy_id:
type: string
name:
type: string
description:
type: string
required:
2 changes: 2 additions & 0 deletions x-pack/plugins/fleet/server/mocks/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@ export const createPackagePolicyServiceMock = (): jest.Mocked<PackagePolicyServi
return {
_compilePackagePolicyInputs: jest.fn(),
buildPackagePolicyFromPackage: jest.fn(),
buildPackagePolicyFromPackageWithVersion: jest.fn(),
bulkCreate: jest.fn(),
create: jest.fn(),
delete: jest.fn(),
Expand All @@ -112,6 +113,7 @@ export const createPackagePolicyServiceMock = (): jest.Mocked<PackagePolicyServi
upgrade: jest.fn(),
getUpgradeDryRunDiff: jest.fn(),
getUpgradePackagePolicyInfo: jest.fn(),
enrichPolicyWithDefaultsFromPackage: jest.fn(),
};
};

Expand Down
Loading

0 comments on commit ef882c2

Please sign in to comment.