DeviceTwin Class
- java.
lang. Object - com.
microsoft. azure. sdk. iot. service. devicetwin. DeviceTwin
- com.
public class DeviceTwin
Constructor Summary
Constructor | Description |
---|---|
DeviceTwin(String connectionString) |
Constructor to create instance from connection string. |
DeviceTwin(String hostName, AzureSasCredential azureSasCredential) |
Create a new Device |
DeviceTwin(String hostName, AzureSasCredential azureSasCredential, DeviceTwinClientOptions options) |
Create a new Device |
DeviceTwin(String hostName, TokenCredential credential) |
Create a new Device |
DeviceTwin(String hostName, TokenCredential credential, DeviceTwinClientOptions options) |
Create a new Device |
DeviceTwin(String connectionString, DeviceTwinClientOptions options) |
Constructor to create instance from connection string. |
Method Summary
Modifier and Type | Method and Description |
---|---|
static
Device |
createFromConnectionString(String connectionString)
Deprecated
because this method declares a thrown IOException even though it never throws an IOException. Users are recommended to use DeviceTwin(String connectionString, DeviceTwinClientOptions options) instead since it does not declare this exception even though it constructs the same Device
Static constructor to create instance from connection string. |
static
Device |
createFromConnectionString(String connectionString, DeviceTwinClientOptions options)
Deprecated
because this method declares a thrown IOException even though it never throws an IOException. Users are recommended to use DeviceTwin(String connectionString, DeviceTwinClientOptions options) instead since it does not declare this exception even though it constructs the same Device
Static constructor to create instance from connection string. |
synchronized
Device |
getNextDeviceTwin(Query deviceTwinQuery)
Returns the next device twin document. |
void |
getTwin(DeviceTwinDevice device)
This method retrieves device twin for the specified device. |
synchronized boolean |
hasNext(QueryCollection deviceTwinQueryCollection)
Returns |
synchronized boolean |
hasNextDeviceTwin(Query deviceTwinQuery)
Returns the availability of next twin element upon query. |
synchronized
Query |
next(QueryCollection deviceTwinQueryCollection)
Returns the next DeviceTwinDevice collection for the given query alongside the continuation token needed for querying the next page. |
synchronized
Query |
next(QueryCollection deviceTwinQueryCollection, QueryOptions options)
Returns the next DeviceTwinDevice collection for the given query alongside the continuation token needed for querying the next page. |
synchronized Query |
queryTwin(String sqlQuery)
SQL-style query for twin. |
synchronized Query |
queryTwin(String sqlQuery, Integer pageSize)
SQL-style query for twin. |
synchronized
Query |
queryTwinCollection(String sqlQuery)
Create a QueryCollection object that can be used to query whole pages of results at a time. |
synchronized
Query |
queryTwinCollection(String sqlQuery, Integer pageSize)
Create a QueryCollection object that can be used to query whole pages of results at a time. |
void |
replaceDesiredProperties(DeviceTwinDevice device)
This method replaces desired properties for the specified device. |
void |
replaceTags(DeviceTwinDevice device)
This method replaces tags for the specified device. |
Device |
replaceTwin(DeviceTwinDevice device)
Replace the full device twin for a given device with the provided device twin. |
Job |
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. |
void |
updateDesiredProperties(DeviceTwinDevice device)
Deprecated
Use updateTwin(DeviceTwinDevice device) to update desired properties.
This method updates desired properties for the specified device. |
synchronized void |
updateTwin(DeviceTwinDevice device)
This method updates device twin for the specified device. |
Methods inherited from java.lang.Object
Constructor Details
DeviceTwin
public DeviceTwin(String connectionString)
Constructor to create instance from connection string.
Parameters:
DeviceTwin
public DeviceTwin(String hostName, AzureSasCredential azureSasCredential)
Create a new DeviceTwin instance.
Parameters:
DeviceTwin
public DeviceTwin(String hostName, AzureSasCredential azureSasCredential, DeviceTwinClientOptions options)
Create a new DeviceTwin instance.
Parameters:
DeviceTwin
public DeviceTwin(String hostName, TokenCredential credential)
Create a new DeviceTwin instance.
Parameters:
DeviceTwin
public DeviceTwin(String hostName, TokenCredential credential, DeviceTwinClientOptions options)
Create a new DeviceTwin instance.
Parameters:
DeviceTwin
public DeviceTwin(String connectionString, DeviceTwinClientOptions options)
Constructor to create instance from connection string.
Parameters:
Method Details
createFromConnectionString
public static DeviceTwin createFromConnectionString(String connectionString)
Deprecated
Static constructor to create instance from connection string.
Parameters:
Returns:
Throws:
createFromConnectionString
public static DeviceTwin createFromConnectionString(String connectionString, DeviceTwinClientOptions options)
Deprecated
Static constructor to create instance from connection string.
Parameters:
null
.
Returns:
Throws:
getNextDeviceTwin
public synchronized DeviceTwinDevice getNextDeviceTwin(Query deviceTwinQuery)
Returns the next device twin document.
Parameters:
Returns:
Throws:
getTwin
public void getTwin(DeviceTwinDevice device)
This method retrieves device twin for the specified device.
Parameters:
Throws:
hasNext
public synchronized boolean hasNext(QueryCollection deviceTwinQueryCollection)
Returns True
if the provided deviceTwinQueryCollection
has a next page to query.
Parameters:
Returns:
True
if the provided deviceTwinQueryCollection has a next page to query, false
otherwise.hasNextDeviceTwin
public synchronized boolean 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.
Parameters:
Returns:
True
if next is available and false
otherwise.Throws:
next
public synchronized QueryCollectionResponse
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.
Parameters:
Returns:
null
if there is no next collection.Throws:
next
public synchronized QueryCollectionResponse
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.
Parameters:
null
, the internally saved continuation token shall be used. The page size set in the options will
override any previously set page size.
Returns:
null
if there is no next collection.Throws:
queryTwin
public synchronized Query queryTwin(String sqlQuery)
SQL-style query for twin.
Parameters:
Returns:
Throws:
queryTwin
public synchronized Query queryTwin(String sqlQuery, Integer pageSize)
SQL-style query for twin.
Parameters:
Returns:
Throws:
queryTwinCollection
public synchronized QueryCollection 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.
Parameters:
Returns:
Throws:
queryTwinCollection
public synchronized QueryCollection 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.
Parameters:
Returns:
Throws:
replaceDesiredProperties
public void replaceDesiredProperties(DeviceTwinDevice device)
This method replaces desired properties for the specified device. desired properties can be input via device's setDesiredProperties(TwinCollection desiredProperties) method.
Parameters:
Throws:
replaceTags
public void replaceTags(DeviceTwinDevice device)
This method replaces tags for the specified device. Tags can be input via device's setTags(TwinCollection tag) method.
Parameters:
Throws:
replaceTwin
public DeviceTwinDevice replaceTwin(DeviceTwinDevice device)
Replace the full device twin for a given device with the provided device twin.
Parameters:
Returns:
Throws:
scheduleUpdateTwin
public Job 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.
Parameters:
null
or
empty.
Returns:
Throws:
updateDesiredProperties
public void updateDesiredProperties(DeviceTwinDevice device)
Deprecated
This method updates desired properties for the specified device.
Parameters:
Throws:
updateTwin
public synchronized void 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.
Parameters:
Throws: