DigitalTwinClient class

Constructors

DigitalTwinClient(IoTHubTokenCredentials)

Constructor which also creates an instance of the Protocol Layer Client used by the DigitalTwinClient.

Methods

getDigitalTwin(string)

Retrieve the Digital Twin of a given device.

getDigitalTwin(string, TripleValueCallback<DigitalTwin, HttpOperationResponse>)
invokeCommand(string, string, any, DigitalTwinInvokeRootLevelCommandOptionalParams)

Invoke a command on an component of a particular device and get the result of it.

invokeComponentCommand(string, string, string, any, DigitalTwinInvokeComponentCommandOptionalParams)

Invoke a command on an component of a particular device and get the result of it.

updateDigitalTwin(string, any[], string | TripleValueCallback<void, HttpOperationResponse>, TripleValueCallback<void, HttpOperationResponse>)
updateDigitalTwin(string, any[], string)

Update the Digital Twin of a given device using a patch object.

Constructor Details

DigitalTwinClient(IoTHubTokenCredentials)

Constructor which also creates an instance of the Protocol Layer Client used by the DigitalTwinClient.

new DigitalTwinClient(creds: IoTHubTokenCredentials)

Parameters

creds
IoTHubTokenCredentials

The IoTHub token credentials used for creating the Protocol Layer client.

Method Details

getDigitalTwin(string)

Retrieve the Digital Twin of a given device.

function getDigitalTwin(digitalTwinId: string): Promise<DigitalTwinResponse>

Parameters

digitalTwinId

string

The digital twin Id of the given device or module. Format of digitalTwinId is DeviceId[~ModuleId]. ModuleId is optional.

Returns

Promise<DigitalTwinResponse>

DigitalTwinResponse The return object containing the Digital Twin plus the HttpResponse.

getDigitalTwin(string, TripleValueCallback<DigitalTwin, HttpOperationResponse>)

function getDigitalTwin(digitalTwinId: string, callback: TripleValueCallback<DigitalTwin, HttpOperationResponse>)

Parameters

digitalTwinId

string

callback

TripleValueCallback<DigitalTwin, HttpOperationResponse>

invokeCommand(string, string, any, DigitalTwinInvokeRootLevelCommandOptionalParams)

Invoke a command on an component of a particular device and get the result of it.

function invokeCommand(digitalTwinId: string, commandName: string, argument: any, options?: DigitalTwinInvokeRootLevelCommandOptionalParams): Promise<DigitalTwinInvokeRootLevelCommandResponse>

Parameters

digitalTwinId

string

The digital twin Id of the given device.

commandName

string

argument

any

The argument of a command.

options

DigitalTwinInvokeRootLevelCommandOptionalParams

The optional parameter to set options including connectionTimeoutInSeconds and responseTimeoutInSeconds. The responseTimeoutInSeconds must be within [5; 300]

Returns

Promise<DigitalTwinInvokeRootLevelCommandResponse>

DigitalTwinInvokeRootLevelCommandResponse The result of the invoked command containing the result, status code, request ID and the parsed HttpResponse.

invokeComponentCommand(string, string, string, any, DigitalTwinInvokeComponentCommandOptionalParams)

Invoke a command on an component of a particular device and get the result of it.

function invokeComponentCommand(digitalTwinId: string, componentName: string, commandName: string, argument: any, options?: DigitalTwinInvokeComponentCommandOptionalParams): Promise<DigitalTwinInvokeComponentCommandResponse>

Parameters

digitalTwinId

string

The digital twin Id of the given device.

componentName

string

The component's name.

commandName

string

The command's name.

argument

any

The argument of a command.

options

DigitalTwinInvokeComponentCommandOptionalParams

The optional parameter to set options including connectionTimeoutInSeconds and responseTimeoutInSeconds. The responseTimeoutInSeconds must be within [5; 300]

Returns

Promise<DigitalTwinInvokeComponentCommandResponse>

DigitalTwinInvokeComponentCommandResponse The result of the invoked command containing the result, status code, request ID and the parsed HttpResponse.

updateDigitalTwin(string, any[], string | TripleValueCallback<void, HttpOperationResponse>, TripleValueCallback<void, HttpOperationResponse>)

function updateDigitalTwin(digitalTwinId: string, patch: any[], eTagOrCallback?: string | TripleValueCallback<void, HttpOperationResponse>, callback?: TripleValueCallback<void, HttpOperationResponse>)

Parameters

digitalTwinId

string

patch

any[]

eTagOrCallback

string | TripleValueCallback<void, HttpOperationResponse>

callback

TripleValueCallback<void, HttpOperationResponse>

updateDigitalTwin(string, any[], string)

Update the Digital Twin of a given device using a patch object.

function updateDigitalTwin(digitalTwinId: string, patch: any[], eTag?: string): Promise<DigitalTwinUpdateResponse>

Parameters

digitalTwinId

string

The digital twin Id of the given device.

patch

any[]

The patch objet contains the update part of a Digital Twin.

eTag

string

The eTag for identifying the patch.

Returns

Promise<DigitalTwinUpdateResponse>

DigitalTwinUpdateResponse The HTTPesponse.