Add documentation
This commit is contained in:
parent
7c54a1286a
commit
45f52b940e
@ -57,6 +57,7 @@ class Instance:
|
|||||||
pass
|
pass
|
||||||
|
|
||||||
def apply(self, server, token, block_id=None):
|
def apply(self, server, token, block_id=None):
|
||||||
|
"""Applies instance block on the remote server"""
|
||||||
headers = {
|
headers = {
|
||||||
f'Authorization': f'Bearer {token}',
|
f'Authorization': f'Bearer {token}',
|
||||||
}
|
}
|
||||||
@ -77,6 +78,7 @@ class Instance:
|
|||||||
raise ConnectionError(f"Could not apply block ({response.status_code}: {response.reason})")
|
raise ConnectionError(f"Could not apply block ({response.status_code}: {response.reason})")
|
||||||
|
|
||||||
def delete(self, server: str, token: str):
|
def delete(self, server: str, token: str):
|
||||||
|
"""Deletes the instance from the blocklist on the remote server"""
|
||||||
headers = {
|
headers = {
|
||||||
f'Authorization': f'Bearer {token}',
|
f'Authorization': f'Bearer {token}',
|
||||||
}
|
}
|
||||||
@ -86,6 +88,7 @@ class Instance:
|
|||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def list_diffs(local_blocklist, remote_blocklist):
|
def list_diffs(local_blocklist, remote_blocklist):
|
||||||
|
"""Compares the local and remote blocklist and returns a list of differences"""
|
||||||
diffs = []
|
diffs = []
|
||||||
for local_instance in local_blocklist:
|
for local_instance in local_blocklist:
|
||||||
instance_found = False
|
instance_found = False
|
||||||
@ -109,6 +112,7 @@ class Instance:
|
|||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def apply_blocks_from_diff(diffs, server, token, no_delete: bool):
|
def apply_blocks_from_diff(diffs, server, token, no_delete: bool):
|
||||||
|
"""Uses a diff (list of difference in local an remote instance) to apply instance blocks"""
|
||||||
for diff in diffs:
|
for diff in diffs:
|
||||||
if diff["local"] is None:
|
if diff["local"] is None:
|
||||||
if not no_delete:
|
if not no_delete:
|
||||||
@ -126,6 +130,7 @@ class Instance:
|
|||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def show_diffs(local_blocklist, remote_blocklist):
|
def show_diffs(local_blocklist, remote_blocklist):
|
||||||
|
"""Shows a table in the CLI comparing the local and remote blocklist"""
|
||||||
from rich.table import Table
|
from rich.table import Table
|
||||||
from rich.console import Console
|
from rich.console import Console
|
||||||
table = Table(title="Differences", expand=True, show_lines=True)
|
table = Table(title="Differences", expand=True, show_lines=True)
|
||||||
|
Loading…
Reference in New Issue
Block a user