Subrack API

This module provides a HTTP server that acts as front end to a subrack.

class SubrackProtocol(*args, **kwargs)

Structural subtyping protocol for a subrack.

That is, specification of the interface that subrack hardware or simulator must fulfil in order that the web server defined here can interact with it.

__init__(*args, **kwargs)
execute_command(name, argument)

Execute a command on the subrack hardware/simulator.

Parameters:
  • name (str) – name of the command to execute.

  • argument (Optional[Any]) – argument to the command.

Return type:

Any

Returns:

a status information dictionary

get_attribute(name)

Get an attribute value on the subrack hardware/simulator.

Parameters:

name (str) – name of the attribute to be set.

Return type:

Any

Returns:

a status information dictionary

set_attribute(name, value)

Set an attribute value on the subrack hardware/simulator.

Parameters:
  • name (str) – name of the attribute to be set.

  • value (Any) – values to be set.

Return type:

Any

Returns:

the new value for the attribute

async get_bad_path(path)

Handle a GET request for any path not handled by one of the above routes.

The above routes handle all valid paths, so any path not already handled must be an invalid path. Therefore this method raises a 404 HTTP exception.

Parameters:

path (str) – the requested path.

Raises:

HTTPException – because this path is not valid.

Return type:

None

async get_json(request, type_parameter=Query(None), param=None, value=None)

Handle a GET request for the path “/get/json.htm”.

Parameters:
  • request (Request) – information about this request (used to get access to the backend subrack controller/simulator)

  • type_parameter (Optional[str]) – value of the “type” argument.

  • param (Optional[str]) – value of the “param” argument.

  • value (Optional[str]) – value of the “value” argument.

Return type:

dict[str, Any]

Returns:

a result dictionary