DeviceTwin 类

定义

Use the DeviceTwin class to manage the device twins in IoT hubs.

public class DeviceTwin
继承
java.lang.Object
DeviceTwin

构造函数

DeviceTwin(String connectionString)

Constructor to create instance from connection string.

DeviceTwin(String connectionString, DeviceTwinClientOptions options)

Constructor to create instance from connection string.

DeviceTwin(String hostName, AzureSasCredential azureSasCredential)

Create a new DeviceTwin instance.

DeviceTwin(String hostName, AzureSasCredential azureSasCredential, DeviceTwinClientOptions options)

Create a new DeviceTwin instance.

DeviceTwin(String hostName, TokenCredential credential)

Create a new DeviceTwin instance.

DeviceTwin(String hostName, TokenCredential credential, DeviceTwinClientOptions options)

Create a new DeviceTwin instance.

方法

createFromConnectionString(String connectionString)

Static constructor to create instance from connection string.

<xreftitle>Deprecated</xreftitle>

<xrefdescription>

  <p>because this method declares a thrown IOException even though it never throws an IOException. Users are recommended to use <xref uid="com.microsoft.azure.sdk.iot.service.devicetwin.DeviceTwin.DeviceTwin(String,DeviceTwinClientOptions)" data-throw-if-not-resolved="false" data-raw-source="DeviceTwin(String, DeviceTwinClientOptions)"></xref> instead since it does not declare this exception even though it constructs the same DeviceTwin. </p>

</xrefdescription>

createFromConnectionString(String connectionString, DeviceTwinClientOptions options)

Static constructor to create instance from connection string.

<xreftitle>Deprecated</xreftitle>

<xrefdescription>

  <p>because this method declares a thrown IOException even though it never throws an IOException. Users are recommended to use <xref uid="com.microsoft.azure.sdk.iot.service.devicetwin.DeviceTwin.DeviceTwin(String,DeviceTwinClientOptions)" data-throw-if-not-resolved="false" data-raw-source="DeviceTwin(String, DeviceTwinClientOptions)"></xref> instead since it does not declare this exception even though it constructs the same DeviceTwin. </p>

</xrefdescription>

getNextDeviceTwin(Query deviceTwinQuery)

Returns the next device twin document.

getTwin(DeviceTwinDevice device)

This method retrieves device twin for the specified device.

hasNext(QueryCollection deviceTwinQueryCollection)

ReturnsTrue 

</code> if the provided<code>deviceTwinQueryCollection 

</code> has a next page to query. </p>
hasNextDeviceTwin(Query deviceTwinQuery)

Returns the availability of next twin element upon query. If non was found, Query is sent over again and response is updated accordingly until no response for the query was found.

next(QueryCollection deviceTwinQueryCollection)

Returns the next DeviceTwinDevice collection for the given query alongside the continuation token needed for querying the next page.

This function shall update a local continuation token continuously to continue the query so you don't need to re-supply the returned continuation token.

next(QueryCollection deviceTwinQueryCollection, QueryOptions options)

Returns the next DeviceTwinDevice collection for the given query alongside the continuation token needed for querying the next page.

This function shall update a local continuation token continuously to continue the query so you don't need to re-supply the returned continuation token unless you want to continue the query from a different starting point. To do that, set your new continuation token in the query options object.

The provided option's page size shall override any previously saved page size.

queryTwin(String sqlQuery)

SQL-style query for twin.

queryTwin(String sqlQuery, Integer pageSize)

SQL-style query for twin.

queryTwinCollection(String sqlQuery)

Create a QueryCollection object that can be used to query whole pages of results at a time. QueryCollection objects also allow you to provide a continuation token for the query to pick up from.

queryTwinCollection(String sqlQuery, Integer pageSize)

Create a QueryCollection object that can be used to query whole pages of results at a time. QueryCollection objects also allow you to provide a continuation token for the query to pick up from.

replaceDesiredProperties(DeviceTwinDevice device)

This method replaces desired properties for the specified device. desired properties can be input via device's setDesiredProperties(TwinCollection desiredProperties) method.

replaceTags(DeviceTwinDevice device)

This method replaces tags for the specified device. Tags can be input via device's setTags(TwinCollection tag) method.

replaceTwin(DeviceTwinDevice device)

Replace the full device twin for a given device with the provided device twin.

scheduleUpdateTwin(String queryCondition, DeviceTwinDevice updateTwin, Date startTimeUtc, long maxExecutionTimeInSeconds)

Creates a new Job to update twin tags and desired properties on one or multiple devices.

updateDesiredProperties(DeviceTwinDevice device)

This method updates desired properties for the specified device.

<xreftitle>Deprecated</xreftitle>

<xrefdescription>

  <p>Use <xref uid="com.microsoft.azure.sdk.iot.service.devicetwin.DeviceTwin.updateTwin(DeviceTwinDevice)" data-throw-if-not-resolved="false" data-raw-source="updateTwin(DeviceTwinDevice device)"></xref> to update desired properties. </p>

</xrefdescription>

updateTwin(DeviceTwinDevice device)

This method updates device twin for the specified device.

This API uses the IoT Hub PATCH API when sending updates, but it sends the full twin with each patch update. As a result, devices subscribed to twin will receive notifications that each property is changed when this API is called, even if only some of the properties were changed.

See PATCH for more details.

适用于