Network

class pyniryo_nate.components.Network(http_client: HttpClient, mqtt_client: MqttClient, correlation_id: str)[source]

Bases: BaseAPIComponent

Network component for inspecting and configuring the robot’s network interfaces.

Methods

close

Close the component and release any resources if needed.

get_all_interfaces

Get the actual state of all network interfaces.

get_interface_config

Get the configuration of a network interface.

get_interface_state

Get the actual state of a network interface.

on_interface_state

Set a callback to be called when the state of a network interface changes.

reset

Reset network settings to their default values.

set_interface_config

Update the configuration of a network interface.

Parameters:
  • http_client (HttpClient)

  • mqtt_client (MqttClient)

  • correlation_id (str)

get_all_interfaces() → list[InterfaceState][source]

Get the actual state of all network interfaces.

Returns:

The list of all network interfaces’ states.

Return type:

list[InterfaceState]

get_interface_state(interface_id: str) → InterfaceState[source]

Get the actual state of a network interface.

Parameters:

interface_id (str) – The ID of the network interface.

Returns:

The current state of the network interface.

Return type:

InterfaceState

get_interface_config(interface_id: str) → InterfaceConfig[source]

Get the configuration of a network interface.

Parameters:

interface_id (str) – The ID of the network interface.

Returns:

The current configuration of the network interface.

Return type:

InterfaceConfig

set_interface_config(interface_id: str, config: InterfaceConfig) → InterfaceConfig[source]

Update the configuration of a network interface.

Parameters:
  • interface_id (str) – The ID of the network interface.

  • config (InterfaceConfig) – The configuration to apply.

Returns:

The updated configuration of the network interface.

Return type:

InterfaceConfig

reset(interfaces: list[str] | None = None) → None[source]

Reset network settings to their default values.

Parameters:

interfaces (list[str] | None) – The IDs of the network interfaces to reset. If None, reset all the interfaces.

Return type:

None

on_interface_state(interface_id: str, callback: Callable[[InterfaceState], None]) → Callable[[], None][source]

Set a callback to be called when the state of a network interface changes.

Parameters:
  • interface_id (str) – The ID of the network interface to subscribe to.

  • callback (Callable[[InterfaceState], None]) – The callback function that takes an InterfaceState parameter.

Return type:

Callable[[], None]