From 5b7347ce718654e6f32489aba593d74109c0d997 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julian-Samuel=20Geb=C3=BChr?= Date: Wed, 11 Jan 2023 19:19:14 +0100 Subject: [PATCH] Add delete method --- models.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/models.py b/models.py index 69ea012..3c8ad4d 100644 --- a/models.py +++ b/models.py @@ -72,6 +72,14 @@ class Instance: 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})") + def delete(self, server: str, token: str): + headers = { + f'Authorization': f'Bearer {token}', + } + response = requests.delete(f'https://{server}/api/v1/admin/domain_blocks/{self.id}', headers=headers) + if response.status_code != 200: + raise ConnectionError(f"Could not apply block ({response.status_code}: {response.reason})") + @staticmethod def list_diffs(local_blocklist, remote_blocklist):