Skip to content
Merged
Show file tree
Hide file tree
Changes from 10 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
79 changes: 67 additions & 12 deletions docs/source/schemas/schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -348,7 +348,7 @@
},
"match": {
"$ref": "#/definitions/DatasourcesConfig-Datasource-MARS-Match",
"description": "filters requests based on presence of specific key=value pair in user request"
"description": "filters requests based on request keys and values. Non-date keys accept scalar or list values. Date supports comparative rules (e.g. >30d, <40d) or MARS date rules (single/list/range). MARS rules do not support by-step."
},
"patch": {
"$ref": "#/definitions/DatasourcesConfig-Datasource-MARS-Patch",
Expand Down Expand Up @@ -455,7 +455,7 @@
},
"match": {
"$ref": "#/definitions/DatasourcesConfig-Datasource-MARS-Match",
"description": "filters requests based on presence of specific key=value pair in user request"
"description": "filters requests based on request keys and values. Non-date keys accept scalar or list values. Date supports comparative rules (e.g. >30d, <40d) or MARS date rules (single/list/range). MARS rules do not support by-step."
},
"patch": {
"$ref": "#/definitions/DatasourcesConfig-Datasource-MARS-Patch",
Expand All @@ -474,26 +474,81 @@
},
"DatasourcesConfig-Datasource-MARS-Match": {
"type": "object",
"description": "Datasource match rules keyed by request parameter. For non-date keys, scalar and list forms are supported. For date, use either comparative rules (all rules must pass) or MARS date rules (no mixing with comparative rules).",
"properties": {
"date": {
"$ref": "#/definitions/DatasourcesConfig-Datasource-MARS-Match-DateValue",
"description": "Date matching rules. Comparative style (all rules must pass): >30d, <40d. MARS style (no mixing with comparative rules): single/list/range rules without by-step, e.g. -1/-5/-10 or -1/to/-20. User-supplied date ranges may include /by/N.",
"examples": [
">30d",
[
">30d",
"<40d"
],
"-1/to/-20",
[
"-1/-5/-10",
"-20/to/-30"
],
[
"2024-02-21/to/2025-03-01",
"-1/-5/-10"
]
]
},
"key1": {
"$ref": "#/definitions/DatasourcesConfig-Datasource-MARS-Match-Value",
"description": "Example non-date match key. Request values must be a subset of the allowed values."
},
"key2": {
"$ref": "#/definitions/DatasourcesConfig-Datasource-MARS-Match-Value"
}
},
"preferredOrder": [
"date",
"key1",
"key2"
],
"additionalProperties": {
"$ref": "#/definitions/DatasourcesConfig-Datasource-MARS-Match-Value"
}
},
"DatasourcesConfig-Datasource-MARS-Match-Value": {
"oneOf": [
{
"type": "string"
},
{
"type": "number"
},
{
"type": "array",
"items": {
"type": "string"
"oneOf": [
{
"type": "string"
},
{
"type": "number"
}
]
},
"default": "[]",
"description": "value matches any in list"
"default": []
}
]
},
"DatasourcesConfig-Datasource-MARS-Match-DateValue": {
"oneOf": [
{
"type": "string"
},
"key2": {
{
"type": "array",
"items": {
"type": "string"
},
"default": "[]"
"default": []
}
},
"preferredOrder": [
"key1",
"key2"
]
},
"DatasourcesConfig-Datasource-MARS-Patch": {
Expand Down Expand Up @@ -1239,7 +1294,7 @@
"default": 6379
},
"db": {
"type": "interger",
"type": "integer",
"description": "id of the database to use",
"default": 0
}
Expand Down
4 changes: 2 additions & 2 deletions polytope_server/common/datasource/datasource.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
from ..config import polytope_config
from ..request import PolytopeRequest, Verb
from ..user import User
from .date_check import DateError, date_check
from .date_check import DateError, validate_date_match

#######################################################

Expand Down Expand Up @@ -112,7 +112,7 @@ def match(ds_config, coerced_ur: Dict[str, Any], user: User) -> str:
# Process date rules
if rule_key == "date":
try:
date_check(coerced_ur_copy["date"], allowed_values)
validate_date_match(coerced_ur_copy["date"], allowed_values)
except DateError as e:
return f"Skipping datasource {DataSource.repr(ds_config)}: {e}."
except Exception as e:
Expand Down
Loading
Loading