Make update of block possible
This commit is contained in:
parent
1197228650
commit
7f3154f515
6
cli.py
6
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()
|
||||
|
@ -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})")
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user