Skip to main content

Get Device By ID

Description​

Gets device by ID via the web service.

Function Signature:​

def get_device_by_id(ws_config: WebServiceConfig, device_id: int) -> DeviceResult:

Parameters​

  • ws_config (WebServiceConfig): Configuration for the web service connection.
  • device_id (int): Device identifier.

Returns​

  • DeviceResult: A result object containing:
    • code: HTTP status code (200 for success, -1 for exceptions).
    • description: Response body or error message.
    • device: Parsed response data when available.

Example Usage​

# Example usage
ws_config = WebServiceConfig(access_key="key", secret_key="secret", base_url="https://api.example.com/")
device_id = 1
result = get_device_by_id(ws_config, device_id)
print(result)

Behavior​

  • Sends a signed request to the web service.
  • On success (code 200), response data is parsed into the result object.
  • On success, returns the computed value or result object.

Error Handling​

  • Exceptions set the result code to -1 and include an error message when implemented.