summaryrefslogtreecommitdiff
path: root/src/schema.py
diff options
context:
space:
mode:
Diffstat (limited to 'src/schema.py')
-rw-r--r--src/schema.py34
1 files changed, 29 insertions, 5 deletions
diff --git a/src/schema.py b/src/schema.py
index f92a2ea..9bdf130 100644
--- a/src/schema.py
+++ b/src/schema.py
@@ -1,5 +1,6 @@
import json
import sys
+import traceback
import jsonschema
@@ -94,18 +95,41 @@ schema = {
# fmt:on
+def get_index_keys():
+ keys = list()
+ for key in schema["properties"]:
+ keys.append(key)
+ return keys
+
+
+def as_index_list():
+ index_list = list()
+ for key in schema["properties"]:
+ name = f"{key}-json-index"
+ index = {
+ "index": {
+ "fields": [
+ key,
+ ]
+ },
+ "name": name,
+ "type": "json"
+ }
+ index_list.append(index)
+
+ return index_list
+
+
def validate_collector_data(json_blob):
try:
jsonschema.validate(json_blob, schema)
except jsonschema.exceptions.ValidationError as e:
- print(f"Validation failed with error: {e}")
- return False
-
- return True
+ return f"Validation failed with error: {e.message}"
+ return ""
if __name__ == "__main__":
with open(sys.argv[1]) as fd:
json_data = json.loads(fd.read())
- validate_collector_data(json_data)
+ print(validate_collector_data(json_data))