from services.api_service import get_data, post_data, delete_data # Forward query params def get_fw_query_params(fw_option: str): if fw_option == 'none': return '' if fw_option == 'auto': return '?fw=auto' else: return '?fw=' + fw_option def fetch_fw_options(to_list=False) -> dict: response = get_data("/service/fw/") if to_list: return [option['url'] for option in response['fw']] fw_servers = {} for res in response['fw']: fw_servers[res['url']] = res['tasks'] / 100 return fw_servers def add_fw_option(url: str): request_data = { "url": url } post_data("/service/fw/", json=request_data) def del_fw_option(index: int): request_data = { "index": index } delete_data("/service/fw/", json=request_data)