nvflare.fuel.hci.reg module

class CommandEntry(scope, name, desc, usage, handler, authz_func, visible, confirm)[source]

Bases: object

Contains information about a command. This is registered in Scope within CommandRegister.

Parameters
  • scope – scope for this command

  • name – command name

  • desc – command description text

  • usage – string to show usage of the command

  • handler – function to call for executing the command

  • authz_func – authorization function to run to get a tuple of (valid, authz_ctx) in AuthzFilter

  • visible – whether the command is visible or not

  • confirm – whether the command needs confirmation to execute

class CommandModule[source]

Bases: object

Base class containing CommandModuleSpec.

close()[source]
get_spec() CommandModuleSpec[source]
class CommandModuleSpec(name: str, cmd_specs: List[CommandSpec])[source]

Bases: object

Specification for a command module containing a list of commands in the form of CommandSpec.

Parameters
  • name – becomes the scope name of the commands in cmd_specs when registered in CommandRegister

  • cmd_specs – list of CommandSpec objects with

class CommandRegister(app_ctx)[source]

Bases: object

Object containing the commands in scopes once they have been registered.

ServerCommandRegister is derived from this class and calls the handler of the command through process_command and _do_command. This is also used to register commands for the admin client.

Parameters

app_ctx – app context

add_command(scope_name, cmd_name, desc, usage, handler, authz_func, visible, confirm)[source]
finalize(add_cmd_func=None)[source]
get_command_entries(cmd_name: str)[source]
register_module(module: CommandModule, include_invisible=True)[source]
class CommandSpec(name: str, description: str, usage: str, handler_func, authz_func=None, visible=True, confirm=None)[source]

Bases: object

Specification of a command within a CommandModuleSpec to register into CommandRegister as a CommandEntry.

Parameters
  • name – command name

  • description – command description text

  • usage – string to show usage of the command

  • handler_func – function to call for executing the command

  • authz_func – authorization function to run to get a tuple of (valid, authz_ctx) in AuthzFilter

  • visible – whether the command is visible or not

  • confirm – whether the command needs confirmation to execute

valid_confirms = ['none', 'yesno', 'auth']