def describe(schain: str, raw=False) -> None: status, payload = get_request(blueprint=BLUEPRINT_NAME, method='get', params={'schain_name': schain}) if status == 'ok': print_schain_info(payload, raw=raw) else: error_exit(payload, exit_code=CLIExitCodes.BAD_API_RESPONSE)
def get_schain_firewall_rules(schain: str) -> None: status, payload = get_request(blueprint=BLUEPRINT_NAME, method='firewall-rules', params={'schain_name': schain}) if status == 'ok': print_firewall_rules(payload['endpoints']) else: error_exit(payload, exit_code=CLIExitCodes.BAD_API_RESPONSE)
def show_config(name: str) -> None: status, payload = get_request(blueprint=BLUEPRINT_NAME, method='config', params={'schain_name': name}) if status == 'ok': pprint.pprint(payload) else: error_exit(payload, exit_code=CLIExitCodes.BAD_API_RESPONSE)
def get_wallet_info(_format): status, payload = get_request(BLUEPRINT_NAME, 'info') if status == 'ok': if _format == 'json': print(json.dumps(payload)) else: print_wallet_info(payload) else: error_exit(payload, exit_code=CLIExitCodes.BAD_API_RESPONSE)
def show_dkg_info(all_: bool = False) -> None: params = {'all': all_} status, payload = get_request(blueprint=BLUEPRINT_NAME, method='dkg-statuses', params=params) if status == 'ok': print_dkg_statuses(payload) else: error_exit(payload, exit_code=CLIExitCodes.BAD_API_RESPONSE)
def get_node_signature(validator_id): params = {'validator_id': validator_id} status, payload = get_request(blueprint=BLUEPRINT_NAME, method='signature', params=params) if status == 'ok': return payload['signature'] else: return payload
def show_schains() -> None: status, payload = get_request(blueprint=BLUEPRINT_NAME, method='list') if status == 'ok': schains = payload if not schains: print('No sChains found') return print_schains(schains) else: error_exit(payload, exit_code=CLIExitCodes.BAD_API_RESPONSE)
def get_containers(_all): status, payload = get_request( blueprint=BLUEPRINT_NAME, method='containers', params={'all': _all} ) if status == 'ok': print_containers(payload) else: error_exit(payload, exit_code=CLIExitCodes.BAD_API_RESPONSE)
def status(format): status, payload = get_request( blueprint=BLUEPRINT_NAME, method='exit/status' ) if status == 'ok': exit_status = payload if format == 'json': print(exit_status) else: print_exit_status(exit_status) else: error_exit(payload, exit_code=CLIExitCodes.BAD_API_RESPONSE)
def get_node_info(format): status, payload = get_request(blueprint=BLUEPRINT_NAME, method='info') if status == 'ok': node_info = payload['node_info'] if format == 'json': print(node_info) elif node_info['status'] == NodeStatuses.NOT_CREATED.value: print(TEXTS['service']['node_not_registered']) else: print_node_info(node_info, get_node_status(int(node_info['status']))) else: error_exit(payload, exit_code=CLIExitCodes.BAD_API_RESPONSE)
def get_schains_checks(json_format: bool = False) -> None: status, payload = get_request( blueprint=BLUEPRINT_NAME, method='schains' ) if status == 'ok': if not payload: print('No sChains found') return if json_format: print(json.dumps(payload)) else: print_schains_healthchecks(payload) else: error_exit(payload, exit_code=CLIExitCodes.BAD_API_RESPONSE)
def get_sgx_info(): status, payload = get_request( blueprint=BLUEPRINT_NAME, method='sgx' ) if status == 'ok': data = payload table_data = [ ['SGX info', ''], ['Server URL', data['sgx_server_url']], ['SGXWallet Version', data['sgx_wallet_version']], ['Node SGX keyname', data['sgx_keyname']], ['Status', data['status_name']] ] table = SingleTable(table_data) print(table.table) else: error_exit(payload, exit_code=CLIExitCodes.BAD_API_RESPONSE)
def status(): status, payload = get_request( blueprint=BLUEPRINT_NAME, method='status' ) if status == 'ok': if payload.get('is_empty'): print(TEXTS['ssl']['no_cert']) else: table_data = [ ['Issued to', payload['issued_to']], ['Expiration date', payload['expiration_date']] ] table = SingleTable(table_data) print('SSL certificates status:') print(table.table) else: error_exit(payload, exit_code=CLIExitCodes.BAD_API_RESPONSE)