DigitalTwinClient Class

  • java.lang.Object
    • com.microsoft.azure.sdk.iot.service.digitaltwin.DigitalTwinClient

public class DigitalTwinClient

The Digital Twins Service Client contains methods to retrieve and update digital twin information, and invoke commands on a digital twin device.

Constructor Summary

Constructor Description
DigitalTwinClient(String connectionString)

Creates an implementation instance of DigitalTwins that is used to invoke the Digital Twin features

DigitalTwinClient(String hostName, AzureSasCredential azureSasCredential)

Creates an implementation instance of DigitalTwins that is used to invoke the Digital Twin features

DigitalTwinClient(String hostName, AzureSasCredential azureSasCredential, DigitalTwinClientOptions options)

Creates an implementation instance of DigitalTwins that is used to invoke the Digital Twin features

DigitalTwinClient(String connectionString, DigitalTwinClientOptions options)

Creates an implementation instance of DigitalTwins that is used to invoke the Digital Twin features

DigitalTwinClient(String hostName, TokenCredential credential)

Creates an implementation instance of DigitalTwins that is used to invoke the Digital Twin features

DigitalTwinClient(String hostName, TokenCredential credential, DigitalTwinClientOptions options)

Creates an implementation instance of DigitalTwins that is used to invoke the Digital Twin features

Method Summary

Modifier and Type Method and Description
DigitalTwinClient createFromConnectionString(String connectionString)

Creates an implementation instance of DigitalTwins that is used to invoke the Digital Twin features

<T> T getDigitalTwin(String digitalTwinId, Class<T> clazz)

Gets a digital twin.

<T> ServiceResponseWithHeaders<T, DigitalTwinGetHeaders> getDigitalTwinWithResponse(String digitalTwinId, Class<T> clazz)

Gets a digital twin.

DigitalTwinCommandResponse invokeCommand(String digitalTwinId, String commandName)

Invoke a command on a digital twin.

DigitalTwinCommandResponse invokeCommand(String digitalTwinId, String commandName, String payload)

Invoke a command on a digital twin.

ServiceResponseWithHeaders<DigitalTwinCommandResponse, DigitalTwinInvokeCommandHeaders> invokeCommandWithResponse(String digitalTwinId, String commandName, String payload, DigitalTwinInvokeCommandRequestOptions options)

Invoke a command on a digital twin.

DigitalTwinCommandResponse invokeComponentCommand(String digitalTwinId, String componentName, String commandName)

Invoke a command on a digital twin component.

DigitalTwinCommandResponse invokeComponentCommand(String digitalTwinId, String componentName, String commandName, String payload)

Invoke a command on a digital twin component.

ServiceResponseWithHeaders<DigitalTwinCommandResponse, DigitalTwinInvokeCommandHeaders> invokeComponentCommandWithResponse(String digitalTwinId, String componentName, String commandName, String payload, DigitalTwinInvokeCommandRequestOptions options)

Invoke a command on a digital twin component.

void updateDigitalTwin(String digitalTwinId, List<Object> digitalTwinUpdateOperations)

Updates a digital twin.

ServiceResponseWithHeaders<Void, DigitalTwinUpdateHeaders> updateDigitalTwinWithResponse(String digitalTwinId, List<Object> digitalTwinUpdateOperations)

Updates a digital twin.

ServiceResponseWithHeaders<Void, DigitalTwinUpdateHeaders> updateDigitalTwinWithResponse(String digitalTwinId, List<Object> digitalTwinUpdateOperations, DigitalTwinUpdateRequestOptions options)

Updates a digital twin.

Constructor Details

DigitalTwinClient

public DigitalTwinClient(String connectionString)

Creates an implementation instance of DigitalTwins that is used to invoke the Digital Twin features

Parameters:

connectionString - The IoT Hub connection string

DigitalTwinClient

public DigitalTwinClient(String hostName, AzureSasCredential azureSasCredential)

Creates an implementation instance of DigitalTwins that is used to invoke the Digital Twin features

Parameters:

hostName - The hostname of your IoT Hub instance (For instance, "your-iot-hub.azure-devices.net")
azureSasCredential - The SAS token provider that will be used for authentication.

DigitalTwinClient

public DigitalTwinClient(String hostName, AzureSasCredential azureSasCredential, DigitalTwinClientOptions options)

Creates an implementation instance of DigitalTwins that is used to invoke the Digital Twin features

Parameters:

hostName - The hostname of your IoT Hub instance (For instance, "your-iot-hub.azure-devices.net")
azureSasCredential - The SAS token provider that will be used for authentication.
options - The optional settings for this client. May not be null.

DigitalTwinClient

public DigitalTwinClient(String connectionString, DigitalTwinClientOptions options)

Creates an implementation instance of DigitalTwins that is used to invoke the Digital Twin features

Parameters:

connectionString - The IoT Hub connection string
options - The optional settings for this client. May not be null.

DigitalTwinClient

public DigitalTwinClient(String hostName, TokenCredential credential)

Creates an implementation instance of DigitalTwins that is used to invoke the Digital Twin features

Parameters:

hostName - The hostname of your IoT Hub instance (For instance, "your-iot-hub.azure-devices.net")
credential - The custom TokenCredential that will provide authentication tokens to this library when they are needed.

DigitalTwinClient

public DigitalTwinClient(String hostName, TokenCredential credential, DigitalTwinClientOptions options)

Creates an implementation instance of DigitalTwins that is used to invoke the Digital Twin features

Parameters:

hostName - The hostname of your IoT Hub instance (For instance, "your-iot-hub.azure-devices.net")
credential - The custom TokenCredential that will provide authentication tokens to this library when they are needed.
options - The optional settings for this client. May not be null.

Method Details

createFromConnectionString

public static DigitalTwinClient createFromConnectionString(String connectionString)

Creates an implementation instance of DigitalTwins that is used to invoke the Digital Twin features

Parameters:

connectionString - The IoT Hub connection string

Returns:

The instantiated DigitalTwinClient.

getDigitalTwin

public T getDigitalTwin(String digitalTwinId, Class clazz)

Gets a digital twin.

Parameters:

digitalTwinId - The Id of the digital twin.
clazz - The class to deserialize the application/json into.

Returns:

The application/json of the digital twin.

getDigitalTwinWithResponse

public ServiceResponseWithHeaders getDigitalTwinWithResponse(String digitalTwinId, Class clazz)

Gets a digital twin.

Parameters:

digitalTwinId - The Id of the digital twin.
clazz - The class to deserialize the application/json into.

Returns:

A ServiceResponseWithHeaders representing deserialized application/json of the digital twin with DigitalTwinGetHeaders.

invokeCommand

public DigitalTwinCommandResponse invokeCommand(String digitalTwinId, String commandName)

Invoke a command on a digital twin.

Parameters:

digitalTwinId - The Id of the digital twin.
commandName - The command to be invoked.

Returns:

A DigitalTwinCommandResponse which contains the application/json command invocation response.

invokeCommand

public DigitalTwinCommandResponse invokeCommand(String digitalTwinId, String commandName, String payload)

Invoke a command on a digital twin.

Parameters:

digitalTwinId - The Id of the digital twin.
commandName - The command to be invoked.
payload - The command payload.

Returns:

A DigitalTwinCommandResponse which contains the application/json command invocation response.

invokeCommandWithResponse

public ServiceResponseWithHeaders invokeCommandWithResponse(String digitalTwinId, String commandName, String payload, DigitalTwinInvokeCommandRequestOptions options)

Invoke a command on a digital twin.

Parameters:

digitalTwinId - The Id of the digital twin.
commandName - The command to be invoked.
payload - The command payload.
options - The optional settings for this request.

Returns:

A ServiceResponseWithHeaders with DigitalTwinInvokeRootLevelCommandHeaders and DigitalTwinCommandResponse which contains the application/json command invocation response.

invokeComponentCommand

public DigitalTwinCommandResponse invokeComponentCommand(String digitalTwinId, String componentName, String commandName)

Invoke a command on a digital twin component.

Parameters:

digitalTwinId - The Id of the digital twin.
componentName - The component name under which the command is defined.
commandName - The command to be invoked.

Returns:

A DigitalTwinCommandResponse which contains the application/json command invocation response.

invokeComponentCommand

public DigitalTwinCommandResponse invokeComponentCommand(String digitalTwinId, String componentName, String commandName, String payload)

Invoke a command on a digital twin component.

Parameters:

digitalTwinId - The Id of the digital twin.
componentName - The component name under which the command is defined.
commandName - The command to be invoked.
payload - The command payload.

Returns:

A DigitalTwinCommandResponse which contains the application/json command invocation response.

invokeComponentCommandWithResponse

public ServiceResponseWithHeaders invokeComponentCommandWithResponse(String digitalTwinId, String componentName, String commandName, String payload, DigitalTwinInvokeCommandRequestOptions options)

Invoke a command on a digital twin component.

Parameters:

digitalTwinId - The Id of the digital twin.
componentName - The component name under which the command is defined.
commandName - The command to be invoked.
payload - The command payload.
options - The optional settings for this request.

Returns:

A ServiceResponseWithHeaders with DigitalTwinInvokeRootLevelCommandHeaders and DigitalTwinCommandResponse which contains the application/json command invocation response.

updateDigitalTwin

public Void updateDigitalTwin(String digitalTwinId, List digitalTwinUpdateOperations)

Updates a digital twin.

Parameters:

digitalTwinId - The Id of the digital twin.
digitalTwinUpdateOperations - The JSON patch to apply to the specified digital twin. This argument can be created using UpdateOperationUtility.

updateDigitalTwinWithResponse

public ServiceResponseWithHeaders updateDigitalTwinWithResponse(String digitalTwinId, List digitalTwinUpdateOperations)

Updates a digital twin.

Parameters:

digitalTwinId - The Id of the digital twin.
digitalTwinUpdateOperations - The JSON patch to apply to the specified digital twin. This argument can be created using UpdateOperationUtility.

Returns:

A ServiceResponseWithHeaders with DigitalTwinUpdateHeaders.

updateDigitalTwinWithResponse

public ServiceResponseWithHeaders updateDigitalTwinWithResponse(String digitalTwinId, List digitalTwinUpdateOperations, DigitalTwinUpdateRequestOptions options)

Updates a digital twin.

Parameters:

digitalTwinId - The Id of the digital twin.
digitalTwinUpdateOperations - The JSON patch to apply to the specified digital twin. This argument can be created using UpdateOperationUtility.
options - The optional settings for this request.

Returns:

A ServiceResponseWithHeaders with DigitalTwinUpdateHeaders.

Applies to