diff options
| author | Victor Näslund <victor@sunet.se> | 2022-11-19 19:06:38 +0100 |
|---|---|---|
| committer | Victor Näslund <victor@sunet.se> | 2022-11-19 19:06:38 +0100 |
| commit | ed22012bf1dfce0d9ab925d39e9eafd0f941f960 (patch) | |
| tree | 4e62a679db31f3f45f67499a46723d00cc9f01ef /src/soc_collector/soc_collector_cli.py | |
| parent | 220653827c2df98cdbc8e94423e549edb4231d2f (diff) | |
Updated schema with tags and better logic for the 'result' tag, lets force descriptionvictor_updates
Diffstat (limited to 'src/soc_collector/soc_collector_cli.py')
| -rw-r--r-- | src/soc_collector/soc_collector_cli.py | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/src/soc_collector/soc_collector_cli.py b/src/soc_collector/soc_collector_cli.py index 4929655..85afce1 100644 --- a/src/soc_collector/soc_collector_cli.py +++ b/src/soc_collector/soc_collector_cli.py @@ -8,7 +8,7 @@ from sys import exit as app_exit import json import requests -from .schema import object_id_from_data +from .schema import object_id_from_data, valid_schema ROOT_CA_FILE = __file__.replace("soc_collector_cli.py", "data/collector_root_ca.crt") @@ -136,6 +136,9 @@ def replace_action(data: str, api_key: str, base_url: str = "https://collector-d print("ERROR: Valid '_id' key not in data") app_exit(1) + if not valid_schema(json_data): + app_exit(1) + req = requests.put( f"{base_url}/sc/v0", json=json_data, headers={"API-KEY": api_key}, timeout=5, verify=ROOT_CA_FILE ) @@ -166,6 +169,9 @@ def insert_action(data: str, api_key: str, base_url: str = "https://collector-de print("ERROR: '_id' key in data") app_exit(1) + if not valid_schema(json_data): + app_exit(1) + req = requests.post( f"{base_url}/sc/v0", json=json_data, headers={"API-KEY": api_key}, timeout=5, verify=ROOT_CA_FILE ) |
