DigitalTwinClient Class

A class to provide convenience APIs for DigitalTwin operations, based on top of the auto generated IotHub REST APIs

Inheritance
builtins.object
DigitalTwinClient

Constructor

DigitalTwinClient(connection_string=None, host=None, auth=None)

Methods

from_connection_string

Classmethod initializer for a DigitalTwinClient Service client. Creates DigitalTwinClient class from connection string.

After a successful creation the class has been authenticated with IoTHub and it is ready to call the member APIs to communicate with IoTHub.

from_token_credential

Classmethod initializer for a DigitalTwinClient Service client. Creates DigitalTwinClient class from host name url and Azure token credential.

After a successful creation the class has been authenticated with IoTHub and it is ready to call the member APIs to communicate with IoTHub.

get_digital_twin

Retrieve the Digital Twin of a given device. :param str digital_twin__id: The digital twin Id of the given device.

invoke_command

Invoke a command on a particular device and get the result of it. :param str digital_twin__id: The digital twin Id of the given device. :param str command_name: The command's name. :param str payload: The argument of a command. :param int connect_timeout_in_seconds: Maximum interval of time, in seconds, that the digital twin command will wait for the answer. :param int response_timeout_in_seconds: Maximum interval of time, in seconds, that the digital twin command will wait for the response. The value must be within 5-300.

invoke_component_command

Invoke a command on an component of a particular device and get the result of it. :param str digital_twin__id: The digital twin Id of the given device. :param str component_path: The component's name. :param str command_name: The command's name. :param str payload: The argument of a command. :param int connect_timeout_in_seconds: Maximum interval of time, in seconds, that the digital twin command will wait for the answer. :param int response_timeout_in_seconds: Maximum interval of time, in seconds, that the digital twin command will wait for the response. The value must be within 5-300. :type response_timeout_in_seconds: int

update_digital_twin

Update the Digital Twin Component of a given device using a patch object. :param str digital_twin__id: The digital twin Id of the given device. :param list[object]: The json-patch object to update the Digital Twin. :param str etag: The etag (if_match) value to use for the update operation.

from_connection_string

Classmethod initializer for a DigitalTwinClient Service client. Creates DigitalTwinClient class from connection string.

After a successful creation the class has been authenticated with IoTHub and it is ready to call the member APIs to communicate with IoTHub.

from_connection_string(connection_string)

Parameters

connection_string
str
Required

The IoTHub connection string used to authenticate connection with IoTHub.

connection_string
Required

Return type

from_token_credential

Classmethod initializer for a DigitalTwinClient Service client. Creates DigitalTwinClient class from host name url and Azure token credential.

After a successful creation the class has been authenticated with IoTHub and it is ready to call the member APIs to communicate with IoTHub.

from_token_credential(url, token_credential)

Parameters

url
str
Required

The Azure service url (host name).

token_credential
str
Required

The Azure token credential object.

token_credential
Required

Return type

get_digital_twin

Retrieve the Digital Twin of a given device. :param str digital_twin__id: The digital twin Id of the given device.

get_digital_twin(digital_twin_id)

Parameters

digital_twin_id
Required

Returns

The return object containing the Digital Twin.

invoke_command

Invoke a command on a particular device and get the result of it. :param str digital_twin__id: The digital twin Id of the given device. :param str command_name: The command's name. :param str payload: The argument of a command. :param int connect_timeout_in_seconds: Maximum interval of time, in seconds, that the digital twin command will wait for the answer. :param int response_timeout_in_seconds: Maximum interval of time, in seconds, that the digital twin command will wait for the response. The value must be within 5-300.

invoke_command(digital_twin_id, command_name, payload, connect_timeout_in_seconds=None, response_timeout_in_seconds=None)

Parameters

digital_twin_id
Required
command_name
Required
payload
Required
connect_timeout_in_seconds
default value: None
response_timeout_in_seconds
default value: None

Returns

The result of the invoked command.

invoke_component_command

Invoke a command on an component of a particular device and get the result of it. :param str digital_twin__id: The digital twin Id of the given device. :param str component_path: The component's name. :param str command_name: The command's name. :param str payload: The argument of a command. :param int connect_timeout_in_seconds: Maximum interval of time, in seconds, that the digital twin command will wait for the answer. :param int response_timeout_in_seconds: Maximum interval of time, in seconds, that the digital twin command will wait for the response. The value must be within 5-300. :type response_timeout_in_seconds: int

invoke_component_command(digital_twin_id, component_path, command_name, payload, connect_timeout_in_seconds=None, response_timeout_in_seconds=None)

Parameters

digital_twin_id
Required
component_path
Required
command_name
Required
payload
Required
connect_timeout_in_seconds
default value: None
response_timeout_in_seconds
default value: None

Returns

The result of the invoked command.

update_digital_twin

Update the Digital Twin Component of a given device using a patch object. :param str digital_twin__id: The digital twin Id of the given device. :param list[object]: The json-patch object to update the Digital Twin. :param str etag: The etag (if_match) value to use for the update operation.

update_digital_twin(digital_twin_id, digital_twin_patch, etag=None)

Parameters

digital_twin_id
Required
digital_twin_patch
Required
etag
default value: None

Returns

The return object containing the updated Digital Twin.