public class DeviceTwin extends Object
| Constructor and Description |
|---|
DeviceTwin(String connectionString)
Constructor to create instance from connection string.
|
DeviceTwin(String hostName,
com.azure.core.credential.AzureSasCredential azureSasCredential)
Create a new DeviceTwin instance.
|
DeviceTwin(String hostName,
com.azure.core.credential.AzureSasCredential azureSasCredential,
DeviceTwinClientOptions options)
Create a new DeviceTwin instance.
|
DeviceTwin(String connectionString,
DeviceTwinClientOptions options)
Constructor to create instance from connection string.
|
DeviceTwin(String hostName,
com.azure.core.credential.TokenCredential credential)
Create a new DeviceTwin instance.
|
DeviceTwin(String hostName,
com.azure.core.credential.TokenCredential credential,
DeviceTwinClientOptions options)
Create a new DeviceTwin instance.
|
| Modifier and Type | Method and Description |
|---|---|
static DeviceTwin |
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, DeviceTwinClientOptions) instead
since it does not declare this exception even though it constructs the same DeviceTwin. |
static DeviceTwin |
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, DeviceTwinClientOptions) instead
since it does not declare this exception even though it constructs the same DeviceTwin. |
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
True 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.
|
DeviceTwinDevice |
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. |
void |
updateTwin(DeviceTwinDevice device)
This method updates device twin for the specified device.
|
public DeviceTwin(String connectionString)
connectionString - The iot hub connection string.public DeviceTwin(String connectionString, DeviceTwinClientOptions options)
connectionString - The iot hub connection string.options - the configurable options for each operation on this client. May not be null.public DeviceTwin(String hostName, com.azure.core.credential.TokenCredential credential)
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. The provided tokens must be Json Web Tokens.public DeviceTwin(String hostName, com.azure.core.credential.TokenCredential credential, DeviceTwinClientOptions options)
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. The provided tokens must be Json Web Tokens.options - The connection options to use when connecting to the service.public DeviceTwin(String hostName, com.azure.core.credential.AzureSasCredential azureSasCredential)
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.public DeviceTwin(String hostName, com.azure.core.credential.AzureSasCredential azureSasCredential, DeviceTwinClientOptions options)
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 connection options to use when connecting to the service.@Deprecated public static DeviceTwin createFromConnectionString(String connectionString) throws IOException
DeviceTwin(String, DeviceTwinClientOptions) instead
since it does not declare this exception even though it constructs the same DeviceTwin.connectionString - The iot hub connection string.IOException - This exception is never thrown.@Deprecated public static DeviceTwin createFromConnectionString(String connectionString, DeviceTwinClientOptions options) throws IOException
DeviceTwin(String, DeviceTwinClientOptions) instead
since it does not declare this exception even though it constructs the same DeviceTwin.connectionString - The IoT hub connection string.options - The configurable options for each operation on this client. May not be null.IOException - This exception is never thrown.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
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.
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
updateTwin(DeviceTwinDevice device) to update desired properties.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
DeviceTwinDevice.setDesiredProperties(TwinCollection)
method.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
DeviceTwinDevice.setTags(TwinCollection) method.device - The device with a valid Id for which device twin is to be updated.UnsupportedOperationException - This exception is always thrown.public DeviceTwinDevice replaceTwin(DeviceTwinDevice device) throws IotHubException, IOException
device - The device twin object to replace the current device twin object.IotHubException - If any an IoT hub level exception is thrown. For instance,
if the request is unauthorized, a exception that extends IotHubException will be thrown.IOException - If the request failed to send to IoT hub.public Query queryTwin(String sqlQuery, Integer pageSize) throws IotHubException, IOException
sqlQuery - SQL-style query string to query Iot hub for Twin.pageSize - Size to limit query response by.Query Object to be used for looking up responses for this query.IotHubException - If query request was not successful at the Iot hub.IOException - If input parameters are invalid.public Query queryTwin(String sqlQuery) throws IotHubException, IOException
sqlQuery - SQL-style query string to query Iot hub for twin.Query Object to be used for looking up responses for this query.IotHubException - If query request was not successful at the Iot hub.IOException - If input parameters are invalid.public QueryCollection queryTwinCollection(String sqlQuery) throws MalformedURLException
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.sqlQuery - The SQL-style query to run.QueryCollection object that can be used to query the service.MalformedURLException - If twin query URL is not correct.public QueryCollection queryTwinCollection(String sqlQuery, Integer pageSize) throws MalformedURLException
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.sqlQuery - The SQL-style 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 - The Query object returned upon creation of query.True if next is available and false otherwise.IotHubException - If Iot hub could not respond back to the query successfully.IOException - If input parameter is incorrect.public DeviceTwinDevice getNextDeviceTwin(Query deviceTwinQuery) throws IOException, IotHubException, NoSuchElementException
deviceTwinQuery - The object corresponding to the query in request.IOException - If the input parameter is incorrect.IotHubException - If an unsuccessful response from IoT Hub is received.NoSuchElementException - If no additional element was found.public boolean hasNext(QueryCollection deviceTwinQueryCollection)
True if the provided deviceTwinQueryCollection has a next page to query.deviceTwinQueryCollection - The query to check.True if the provided deviceTwinQueryCollection has a next page to query, false otherwise.IllegalArgumentException - if the provided deviceTwinQueryCollection is null.public QueryCollectionResponse<DeviceTwinDevice> next(QueryCollection deviceTwinQueryCollection) throws IOException, IotHubException
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.
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 doesn't match expectations.public QueryCollectionResponse<DeviceTwinDevice> next(QueryCollection deviceTwinQueryCollection, QueryOptions options) throws IOException, IotHubException
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.
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 doesn'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 and time in UTC to start the job.maxExecutionTimeInSeconds - Max run time in seconds, I.E., the duration the job can run.Job class that represent this job on IoT hub.IOException - If the function contains invalid parameters.IotHubException - If the HTTP request failed.Copyright © 2022. All rights reserved.