-
Neda Moeini authoredNeda Moeini authored
config.py 1.20 KiB
"""Configuration file for the Mapping Provider."""
import json
from typing import Any, TextIO
import jsonschema
CONFIG_SCHEMA = {
"$schema": "http://json-schema.org/draft-07/schema#",
"type": "object",
"properties": {
"aai": {
"type": "object",
"properties": {
"discovery_endpoint_url": {"type": "string"},
"client_id": {"type": "string"},
"secret": {"type": "string"},
},
"required": ["client_id", "secret", "discovery_endpoint_url"],
"additionalProperties": False,
},
"orchestrator": {
"type": "object",
"properties": {
"url": {"type": "string"},
},
"required": ["url"],
"additionalProperties": False,
},
},
"required": ["aai", "orchestrator"],
"additionalProperties": False,
}
def load(f: TextIO) -> dict[str, Any]:
"""loads, validates and returns configuration parameters.
:param f: file-like object that produces the config file
:return:
"""
config: dict[str, Any] = json.loads(f.read())
jsonschema.validate(config, CONFIG_SCHEMA)
return config