From 9cd4160e1be8cc333d0dcc39fd42280f08806aac Mon Sep 17 00:00:00 2001
From: Neda Moeini <neda.moeini@geant.org>
Date: Thu, 17 Apr 2025 16:29:55 +0200
Subject: [PATCH] Add configuration file to the project

---
 mapping_provider/config.py | 43 ++++++++++++++++++++++++++++++++++++++
 1 file changed, 43 insertions(+)
 create mode 100644 mapping_provider/config.py

diff --git a/mapping_provider/config.py b/mapping_provider/config.py
new file mode 100644
index 0000000..978b201
--- /dev/null
+++ b/mapping_provider/config.py
@@ -0,0 +1,43 @@
+"""Configuration file for the Mapping Provider."""
+
+import json
+
+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):
+    """loads, validates and returns configuration parameters.
+
+    :param f: file-like object that produces the config file
+    :return:
+    """
+    config = json.loads(f.read())
+    jsonschema.validate(config, CONFIG_SCHEMA)
+    return config
-- 
GitLab