Skip to content

Commit 3c56a5f

Browse files
committed
adding more common definitions to fill out rule
1 parent d20955d commit 3c56a5f

4 files changed

Lines changed: 107 additions & 5 deletions

File tree

schema/policy.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,17 @@ def policy_schema():
1414
# load schema template and insert definitions
1515
schema = common.load_json("./templates/policy/policy.json")
1616
definitions = common.load_definitions(
17+
"day",
18+
"days",
19+
"iso_time",
20+
"propulsion_type",
21+
"propulsion_types",
1722
"string",
1823
"timestamp",
1924
"uuid",
25+
"vehicle_event",
26+
"vehicle_type",
27+
"vehicle_types",
2028
"version"
2129
)
2230
schema["definitions"].update(definitions)

schema/provider.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ def endpoint_schema(endpoint, extra_definitions={}):
6262
vehicle = common.vehicle_definition()
6363
items["required"] = vehicle["required"] + items["required"]
6464
items["properties"] = { **vehicle["properties"], **items["properties"] }
65-
definitions.update(common.load_definitions("propulsion_types", "vehicle_type"))
65+
definitions.update(common.load_definitions("propulsion_type", "propulsion_types", "vehicle_type"))
6666

6767
# merge endpoint schema into the endpoint template
6868
data_schema = schema["properties"]["data"]

schema/templates/common.json

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,36 @@
1414
"preferred_drop_off"
1515
]
1616
},
17+
"day": {
18+
"$id": "#/definitions/day",
19+
"type": "string",
20+
"description": "A day of the week",
21+
"enum": [
22+
"sun",
23+
"mon",
24+
"tue",
25+
"wed",
26+
"thu",
27+
"fri",
28+
"sat"
29+
]
30+
},
31+
"days": {
32+
"$id": "#/definitions/days",
33+
"type": "array",
34+
"description": "Array of days of the week",
35+
"items": {
36+
"$id": "#/definitions/days/items",
37+
"$ref": "#/definitions/day"
38+
},
39+
"uniqueItems": true
40+
},
41+
"iso_time": {
42+
"$id": "#/definitions/iso_time",
43+
"type": "string",
44+
"description": "Time-of-day expressed as ISO 8601 hh:mm:ss",
45+
"pattern": "([0-2][0-3]|[0-1][0-9]):[0-5][0-9]:[0-5][0-9]"
46+
},
1747
"links": {
1848
"$id": "#/definitions/links",
1949
"type": "object",

schema/templates/policy/policy.json

Lines changed: 68 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@
4646
"rules": {
4747
"$id": "#/definitions/rule",
4848
"type": "array",
49-
"description": "List of applicable Rule objects",
49+
"description": "Array of applicable Rule objects",
5050
"items": {
5151
"$id": "#/definitions/policy/properties/rules/items",
5252
"$ref": "#/definitions/rule"
@@ -109,7 +109,7 @@
109109
"rule_units": {
110110
"$id": "#/definitions/rule/properties/rule_units",
111111
"type": "string",
112-
"description": "Meaured units of policy",
112+
"description": "Measured units of policy",
113113
"enum": [
114114
"seconds",
115115
"minutes",
@@ -120,6 +120,70 @@
120120
"devices",
121121
"amount"
122122
]
123+
},
124+
"vehicle_types": {
125+
"$id": "#/definitions/rule/properties/vehicle_types",
126+
"$ref": "#/definitions/vehicle_types",
127+
"description": "Applicable vehicle types, default \"all\""
128+
},
129+
"propulsion_types": {
130+
"$id": "#/definitions/rule/properties/propulsion_types",
131+
"$ref": "#/definitions/propulsion_types",
132+
"description": "Applicable vehicle propulsion types, default \"all\""
133+
},
134+
"minimum": {
135+
"$id": "#/definitions/rule/properties/minimum",
136+
"type": "integer",
137+
"description": "Minimum value, if applicable (default 0)"
138+
},
139+
"maximum": {
140+
"$id": "#/definitions/rule/properties/maximum",
141+
"type": "integer",
142+
"description": "Maximum value, if applicable (default unlimited)"
143+
},
144+
"rate_amount": {
145+
"$id": "#/definitions/rule/properties/rate_amount",
146+
"type": "integer",
147+
"description": "The amount of a rate applied when this rule applies, if applicable (default zero). A positive integer rate amount represents a fee, while a negative integer represents a subsidy. Rate amounts are given in the currency defined in the Policy."
148+
},
149+
"rate_recurrence": {
150+
"$id": "#/definitions/rule/properties/rate_recurrence",
151+
"type": "string",
152+
"description": "Specify when a rate is applied – either once, or periodically according to a time unit specified using rule_units",
153+
"enum": [
154+
"once",
155+
"each_time_unit",
156+
"per_complete_time_unit"
157+
]
158+
},
159+
"start_time": {
160+
"$id": "#/definitions/rule/properties/start_time",
161+
"$ref": "#/definitions/iso_time",
162+
"description": "Beginning time-of-day when the rule is in effect (default 00:00:00)"
163+
},
164+
"end_time": {
165+
"$id": "#/definitions/rule/properties/end_time",
166+
"$ref": "#/definitions/iso_time",
167+
"description": "Ending time-of-day when the rule is in effect (default 23:59:59)"
168+
},
169+
"days": {
170+
"$id": "#/definitions/rule/properties/days",
171+
"$ref": "#/definitions/days",
172+
"description": "Days when the rule is in effect (default all)"
173+
},
174+
"messages": {
175+
"$id": "#/definitions/rule/properties/messages",
176+
"type": "object",
177+
"description": "Message to rider user, if desired, in various languages, keyed by BCP 47 language tag",
178+
"propertyNames": {
179+
"pattern": "([A-Za-z]{2,3})([-][A-Za-z]{3}){0,3}([-]([A-Za-z]{4}))?([-]([A-Za-z]{2}|[0-9]{3}))?"
180+
}
181+
},
182+
"value_url": {
183+
"$id": "#/definitions/rule/properties/value_url",
184+
"type": "string",
185+
"description": "URL to an API endpoint that can provide dynamic information for the measured value",
186+
"format": "uri"
123187
}
124188
}
125189
}
@@ -158,12 +222,12 @@
158222
"updated": {
159223
"$id": "#/properties/updated",
160224
"$ref": "#/definitions/timestamp",
161-
"description": "The timestamp when the Policy document was last updated"
225+
"description": "The timestamp when the Policy was last updated"
162226
},
163227
"version": {
164228
"$id": "#/properties/version",
165229
"$ref": "#/definitions/version",
166-
"description": "The MDS version this Policy document corresponds with"
230+
"description": "The version of MDS that the Policy represents"
167231
}
168232
},
169233
"additionalProperties": false

0 commit comments

Comments
 (0)