Skip to content

Commit 6a22885

Browse files
committed
filling out required policy fields
and a stub for rule definition
1 parent 4a58b1b commit 6a22885

2 files changed

Lines changed: 59 additions & 5 deletions

File tree

schema/policy.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,12 @@ def policy_schema(common_definitions):
1313
"""
1414
# load schema template and insert definitions
1515
schema = common.load_json("./templates/policy/policy.json")
16-
schema["definitions"] = {
16+
schema["definitions"].update({
17+
"string": common_definitions["string"],
18+
"timestamp": common_definitions["timestamp"],
19+
"uuid": common_definitions["uuid"],
1720
"version": common_definitions["version"]
18-
}
21+
})
1922

2023
# verify and return
2124
return common.check_schema(schema)

schema/templates/policy/policy.json

Lines changed: 54 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,15 @@
33
"$schema": "http://json-schema.org/draft-06/schema#",
44
"title": "The MDS Policy Schema",
55
"type": "object",
6-
"definitions": {},
6+
"definitions": {
7+
"rule": {
8+
"$id": "#/definitions/rule",
9+
"type": "object",
10+
"additionalProperties": false,
11+
"required": [],
12+
"properties": {}
13+
}
14+
},
715
"required": [
816
"data",
917
"updated",
@@ -27,8 +35,51 @@
2735
"type": "object",
2836
"title": "The policy item schema",
2937
"additionalItems": false,
30-
"required": [],
31-
"properties": {}
38+
"required": [
39+
"name",
40+
"policy_id",
41+
"description",
42+
"start_date",
43+
"published_date",
44+
"rules"
45+
],
46+
"properties": {
47+
"name": {
48+
"$id": "#/properties/data/properties/policy/items/properties/name",
49+
"$ref": "#/definitions/string",
50+
"description": "Name of policy"
51+
},
52+
"policy_id": {
53+
"$id": "#/properties/data/properties/policy/items/properties/policy_id",
54+
"$ref": "#/definitions/uuid",
55+
"description": "Unique ID of policy"
56+
},
57+
"description": {
58+
"$id": "#/properties/data/properties/policy/items/properties/description",
59+
"$ref": "#/definitions/string",
60+
"description": "Description of policy"
61+
},
62+
"start_date":{
63+
"$id": "#/properties/data/properties/policy/items/properties/start_date",
64+
"$ref": "#/definitions/timestamp",
65+
"description": "Beginning date/time of policy enforcement"
66+
},
67+
"published_date": {
68+
"$id": "#/properties/data/properties/policy/items/properties/published_date",
69+
"$ref": "#/definitions/timestamp",
70+
"description": "Timestamp that the policy was published"
71+
},
72+
"rules": {
73+
"$id": "#/properties/data/properties/policy/items/properties/rules",
74+
"type": "array",
75+
"description": "List of applicable Rule objects",
76+
"items": {
77+
"$id": "#/properties/data/properties/policy/items/properties/rules/items",
78+
"$ref": "#/definitions/rule",
79+
"description": "An individual rule in the policy"
80+
}
81+
}
82+
}
3283
}
3384
}
3485
},

0 commit comments

Comments
 (0)