nvflare.fuel.hci.client.api module¶
- class AdminAPI(user_name: str, service_finder: ServiceFinder, ca_cert: str = '', client_cert: str = '', client_key: str = '', upload_dir: str = '', download_dir: str = '', cmd_modules: List | None = None, poc: bool = False, debug: bool = False, session_event_cb=None, session_timeout_interval=None, session_status_check_interval=None)[source]¶
Bases:
AdminAPISpec
Underlying API to keep certs, keys and connection information and to execute admin commands through do_command.
- Parameters:
ca_cert – path to CA Cert file, by default provisioned rootCA.pem
client_cert – path to admin client Cert file, by default provisioned as client.crt
client_key – path to admin client Key file, by default provisioned as client.key
upload_dir – File transfer upload directory. Folders uploaded to the server to be deployed must be here. Folder must already exist and be accessible.
download_dir – File transfer download directory. Can be same as upload_dir. Folder must already exist and be accessible.
cmd_modules – command modules to load and register. Note that FileTransferModule is initialized here with upload_dir and download_dir if cmd_modules is None.
service_finder – used to obtain the primary service provider to set the host and port of the active server
user_name – Username to authenticate with FL server
poc – Whether to enable poc mode for using the proof of concept example without secure communication.
debug – Whether to print debug messages, which can help with diagnosing problems. False by default.
session_event_cb – the session event callback
session_timeout_interval – if specified, automatically close the session after inactive for this long
session_status_check_interval – how often to check session status with server
- check_command(command: str) CommandInfo [source]¶
Checks the specified command for processing info
- Parameters:
command – command to be checked
Returns: command processing info
- do_command(command)[source]¶
A convenient method to call commands using string.
- Parameters:
command (str) – command
- Returns:
Object containing status and details (or direct response from server, which originally was just time and data)
- login(username: str)[source]¶
Login using certification files and retrieve server side commands.
- Parameters:
username – Username
- Returns:
A dict of status and details
- class SessionEventType[source]¶
Bases:
object
- LOGIN_FAILURE = 'login_failure'¶
- LOGIN_SUCCESS = 'login_success'¶
- SERVER_ADDR_OBTAINED = 'server_addr_obtained'¶
- SESSION_CLOSED = 'session_closed'¶
- SESSION_TIMEOUT = 'session_timeout'¶
- SP_ADDR_CHANGED = 'sp_addr_changed'¶
- TRYING_LOGIN = 'trying_login'¶
- WAIT_FOR_SERVER_ADDR = 'wait_for_server_addr'¶
- session_event_cb_signature(event_type: str, info: str)[source]¶
This defines the signature of session_event callback. When creating the AdminAPI object, you can provide a session event callback function. This function is called when a session event happens.
- Parameters:
event_type – the event type
info – information of the event
Returns: