public class DeviceTwin extends Object
Constructor and Description |
---|
DeviceTwin() |
Modifier and Type | Method and Description |
---|---|
static DeviceTwin |
createFromConnectionString(String connectionString)
Static constructor to create instance from connection string.
|
static DeviceTwin |
createFromConnectionString(String connectionString,
DeviceTwinClientOptions options)
Static constructor to create instance from connection string.
|
DeviceTwinDevice |
getNextDeviceTwin(Query deviceTwinQuery)
Returns the next device twin document.
|
void |
getTwin(DeviceTwinDevice device)
This method retrieves device twin for the specified device.
|
boolean |
hasNext(QueryCollection deviceTwinQueryCollection)
Returns if the provided deviceTwinQueryCollection has a next page to query.
|
boolean |
hasNextDeviceTwin(Query deviceTwinQuery)
Returns the availability of next twin element upon query.
|
QueryCollectionResponse<DeviceTwinDevice> |
next(QueryCollection deviceTwinQueryCollection)
Returns the next DeviceTwinDevice collection for the given query alongside the continuation token needed for querying the next page.
|
QueryCollectionResponse<DeviceTwinDevice> |
next(QueryCollection deviceTwinQueryCollection,
QueryOptions options)
Returns the next DeviceTwinDevice collection for the given query alongside the continuation token needed for querying the next page.
|
Query |
queryTwin(String sqlQuery)
Sql style query for twin.
|
Query |
queryTwin(String sqlQuery,
Integer pageSize)
Sql style query for twin.
|
QueryCollection |
queryTwinCollection(String sqlQuery)
Create a QueryCollection object that can be used to query whole pages of results at a time.
|
QueryCollection |
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.
|
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() to update desired properties.
|
void |
updateTwin(DeviceTwinDevice device)
This method updates device twin for the specified device.
|
public static DeviceTwin createFromConnectionString(String connectionString) throws IOException
connectionString
- The iot hub connection string.IOException
- This exception is thrown if the object creation failed.public static DeviceTwin createFromConnectionString(String connectionString, DeviceTwinClientOptions options) throws IOException
connectionString
- The iot hub connection string.options
- the configurable options for each operation on this client. May not be null.IOException
- This exception is thrown if the object creation failed.public void getTwin(DeviceTwinDevice device) throws IotHubException, IOException
device
- The device with a valid id for which device twin is to be retrieved.IOException
- This exception is thrown if the IO operation failed.IotHubException
- This exception is thrown if the response verification failed.public void updateTwin(DeviceTwinDevice device) throws IotHubException, IOException
device
- The device with a valid id for which device twin is to be updated.IOException
- This exception is thrown if the IO operation failed.IotHubException
- This exception is thrown if the response verification failed.@Deprecated public void updateDesiredProperties(DeviceTwinDevice device) throws UnsupportedOperationException
device
- The device with a valid id for which desired properties is to be updated.UnsupportedOperationException
- This exception is always thrown.public void replaceDesiredProperties(DeviceTwinDevice device) throws UnsupportedOperationException
device
- The device with a valid id for which device twin is to be updated.UnsupportedOperationException
- This exception is always thrown.public void replaceTags(DeviceTwinDevice device) throws UnsupportedOperationException
device
- The device with a valid id for which device twin is to be updated.UnsupportedOperationException
- This exception is always thrown.public Query queryTwin(String sqlQuery, Integer pageSize) throws IotHubException, IOException
sqlQuery
- Sql query string to query IotHub for Twin.pageSize
- Size to limit query response by.IotHubException
- If Query request was not successful at the IotHub.IOException
- If input parameters are invalid.public Query queryTwin(String sqlQuery) throws IotHubException, IOException
sqlQuery
- Sql query string to query IotHub for Twin.IotHubException
- If Query request was not successful at the IotHub.IOException
- If input parameters are invalid.public QueryCollection queryTwinCollection(String sqlQuery) throws MalformedURLException
sqlQuery
- the sql query to run.MalformedURLException
- If twin query url is not correct.public QueryCollection queryTwinCollection(String sqlQuery, Integer pageSize) throws MalformedURLException
sqlQuery
- the sql query to run.pageSize
- the number of results to return at a time.MalformedURLException
- If twin query url is not correct.public boolean hasNextDeviceTwin(Query deviceTwinQuery) throws IotHubException, IOException
deviceTwinQuery
- Query object returned upon creation of query.IotHubException
- If IotHub could not respond back to the query successfully.IOException
- If input parameter is incorrect.public DeviceTwinDevice getNextDeviceTwin(Query deviceTwinQuery) throws IOException, IotHubException, NoSuchElementException
deviceTwinQuery
- Object corresponding to the query in request.IOException
- If input parameter is incorrect.IotHubException
- If a non successful response from IotHub is received.NoSuchElementException
- If no additional element was found.public boolean hasNext(QueryCollection deviceTwinQueryCollection)
deviceTwinQueryCollection
- the query to check.IllegalArgumentException
- if the provided deviceTwinQueryCollection is null.public QueryCollectionResponse<DeviceTwinDevice> next(QueryCollection deviceTwinQueryCollection) throws IOException, IotHubException
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.
deviceTwinQueryCollection
- the query to run.null
if there is no next collection.IotHubException
- If an IotHubException occurs when querying the service.IOException
- If an IotHubException occurs when querying the service or if the results of that query don't match expectations.public QueryCollectionResponse<DeviceTwinDevice> next(QueryCollection deviceTwinQueryCollection, QueryOptions options) throws IOException, IotHubException
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.
deviceTwinQueryCollection
- the query to run.options
- the query options to run the query with. If the continuation token in these options is null, the internally saved continuation token shall be used.
The page size set in the options will override any previously set page size.null
if there is no next collection.IotHubException
- If an IotHubException occurs when querying the service.IOException
- If an IotHubException occurs when querying the service or if the results of that query don't match expectations.public Job scheduleUpdateTwin(String queryCondition, DeviceTwinDevice updateTwin, Date startTimeUtc, long maxExecutionTimeInSeconds) throws IOException, IotHubException
queryCondition
- Query condition to evaluate which devices to run the job on. It can be null
or empty.updateTwin
- Twin object to use for the update.startTimeUtc
- Date time in Utc to start the job.maxExecutionTimeInSeconds
- Max execution time in seconds, i.e., ttl duration the job can run.IOException
- if the function contains invalid parameters.IotHubException
- if the http request failed.Copyright © 2020. All rights reserved.