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
|
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)
This method updates desired properties for the specified device.
|
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 stringIOException - This exception is thrown if the object creation failedpublic 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 failedIotHubException - This exception is thrown if the response verification failedpublic 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 failedIotHubException - This exception is thrown if the response verification failedpublic void updateDesiredProperties(DeviceTwinDevice device) throws IotHubException, IOException
device - The device with a valid id for which desired properties is to be updated.IOException - This exception is thrown if the IO operation failedIotHubException - This exception is thrown if the response verification failedpublic void replaceDesiredProperties(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 failedIotHubException - This exception is thrown if the response verification failedpublic void replaceTags(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 failedIotHubException - This exception is thrown if the response verification failedpublic Query queryTwin(String sqlQuery, Integer pageSize) throws IotHubException, IOException
sqlQuery - Sql query string to query IotHub for TwinpageSize - Size to limit query response byIotHubException - If Query request was not successful at the IotHubIOException - If input parameters are invalidpublic Query queryTwin(String sqlQuery) throws IotHubException, IOException
sqlQuery - Sql query string to query IotHub for TwinIotHubException - If Query request was not successful at the IotHubIOException - If input parameters are invalidpublic QueryCollection queryTwinCollection(String sqlQuery) throws MalformedURLException
sqlQuery - the sql query to runMalformedURLExceptionpublic QueryCollection queryTwinCollection(String sqlQuery, Integer pageSize) throws MalformedURLException
sqlQuery - the sql query to runpageSize - the number of results to return at a timeMalformedURLExceptionpublic boolean hasNextDeviceTwin(Query deviceTwinQuery) throws IotHubException, IOException
deviceTwinQuery - Query object returned upon creation of queryIotHubException - If IotHub could not respond back to the query successfullyIOException - If input parameter is incorrectpublic DeviceTwinDevice getNextDeviceTwin(Query deviceTwinQuery) throws IOException, IotHubException, NoSuchElementException
deviceTwinQuery - Object corresponding to the query in requestIOException - If input parameter is incorrectIotHubException - If a non successful response from IotHub is receivedNoSuchElementException - If no additional element was foundpublic boolean hasNext(QueryCollection deviceTwinQueryCollection)
deviceTwinQueryCollection - the query to checkIllegalArgumentException - if the provided deviceTwinQueryCollection is nullpublic 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 runnull if there is no next collectionIotHubException - 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 runoptions - 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 emptyupdateTwin - Twin object to use for the updatestartTimeUtc - Date time in Utc to start the jobmaxExecutionTimeInSeconds - Max execution time in seconds, i.e., ttl duration the job can runIOException - if the function contains invalid parametersIotHubException - if the http request failedCopyright © 2017. All rights reserved.