From 7f3154f5151314ff6b3c3c21d8d6698bce6c38bd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julian-Samuel=20Geb=C3=BChr?= Date: Mon, 9 Jan 2023 12:01:39 +0100 Subject: [PATCH] Make update of block possible --- cli.py | 6 ++++-- models.py | 2 +- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/cli.py b/cli.py index 4291e3b..504da76 100644 --- a/cli.py +++ b/cli.py @@ -21,14 +21,14 @@ def load_local_blocklist(filename: str) -> [Instance]: return instances -def blocklist_json_to_instances(blocklist_json): +def blocklist_json_to_instances(blocklist_json: str): instances = [] for i in blocklist_json: instances.append(Instance(i)) return instances -def load_remote_blocklist(server, token): +def load_remote_blocklist(server: str, token: str): headers = { f'Authorization': f'Bearer {token}', } @@ -68,5 +68,7 @@ def cli(): diffs = Instance.list_diffs(local_blocklist, remote_blocklist) Instance.apply_blocks_from_diff(diffs, args.server, args.token) + if __name__ == "__main__": + logging.basicConfig(level=logging.DEBUG) cli() diff --git a/models.py b/models.py index b97b5ff..dcc8aea 100644 --- a/models.py +++ b/models.py @@ -69,7 +69,7 @@ class Instance: if block_id is None: response = requests.post(f'https://{server}/api/v1/admin/domain_blocks', data=data, headers=headers) else: - response = requests.post(f'https://{server}/api/v1/admin/domain_blocks/{block_id}', data=data, headers=headers) + response = requests.put(f'https://{server}/api/v1/admin/domain_blocks/{block_id}', data=data, headers=headers) if response.status_code != 200: raise ConnectionError(f"Could not apply block ({response.status_code}: {response.reason})")