ScheduledJobsClient Class

  • java.lang.Object
    • com.microsoft.azure.sdk.iot.service.jobs.ScheduledJobsClient

public class ScheduledJobsClient

Use the ScheduledJobsClient to schedule and cancel jobs for a group of devices using IoT hub.

Constructor Summary

Constructor Description
ScheduledJobsClient(String connectionString)

Constructor to create instance from connection string

ScheduledJobsClient(String hostName, AzureSasCredential azureSasCredential)

Create a new ScheduledJobsClient instance.

ScheduledJobsClient(String hostName, AzureSasCredential azureSasCredential, ScheduledJobsClientOptions clientOptions)

Create a new ScheduledJobsClient instance.

ScheduledJobsClient(String connectionString, ScheduledJobsClientOptions clientOptions)

Constructor to create instance from connection string

ScheduledJobsClient(String hostName, TokenCredential credential)

Create a new ScheduledJobsClient instance.

ScheduledJobsClient(String hostName, TokenCredential credential, ScheduledJobsClientOptions clientOptions)

Create a new ScheduledJobsClient instance.

Method Summary

Modifier and Type Method and Description
ScheduledJob cancel(String jobId)

Cancel a current jod on the IoTHub

ScheduledJob get(String jobId)

Get the current job on the iotHub.

JobQueryResponse query(ScheduledJobType jobType, ScheduledJobStatus jobStatus)

Query from your IoT Hub's set of scheduled jobs by job type and job status.

JobQueryResponse query(ScheduledJobType jobType, ScheduledJobStatus jobStatus, QueryPageOptions options)

Query from your IoT Hub's set of scheduled jobs by job type and job status.

JobQueryResponse query(String query)

Query from your IoT Hub's set of scheduled jobs.

JobQueryResponse query(String query, QueryPageOptions options)

Query from your IoT Hub's set of scheduled jobs.

ScheduledJob scheduleDirectMethod(String jobId, String queryCondition, String methodName, Date startTimeUtc)

Creates a new ScheduledJob to invoke method on one or multiple devices

ScheduledJob scheduleDirectMethod(String jobId, String queryCondition, String methodName, Date startTimeUtc, DirectMethodsJobOptions options)

Creates a new ScheduledJob to invoke method on one or multiple devices

ScheduledJob scheduleUpdateTwin(String jobId, String queryCondition, Twin updateTwin, Date startTimeUtc, long maxExecutionTimeInSeconds)

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

Constructor Details

ScheduledJobsClient

public ScheduledJobsClient(String connectionString)

Constructor to create instance from connection string

Parameters:

connectionString - The iot hub connection string

ScheduledJobsClient

public ScheduledJobsClient(String hostName, AzureSasCredential azureSasCredential)

Create a new ScheduledJobsClient instance.

Parameters:

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.

ScheduledJobsClient

public ScheduledJobsClient(String hostName, AzureSasCredential azureSasCredential, ScheduledJobsClientOptions clientOptions)

Create a new ScheduledJobsClient instance.

Parameters:

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.
clientOptions - The connection clientOptions to use when connecting to the service.

ScheduledJobsClient

public ScheduledJobsClient(String connectionString, ScheduledJobsClientOptions clientOptions)

Constructor to create instance from connection string

Parameters:

connectionString - The iot hub connection string
clientOptions - The connection clientOptions to use when connecting to the service.

ScheduledJobsClient

public ScheduledJobsClient(String hostName, TokenCredential credential)

Create a new ScheduledJobsClient instance.

Parameters:

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.

ScheduledJobsClient

public ScheduledJobsClient(String hostName, TokenCredential credential, ScheduledJobsClientOptions clientOptions)

Create a new ScheduledJobsClient instance.

Parameters:

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.
clientOptions - The connection clientOptions to use when connecting to the service.

Method Details

cancel

public ScheduledJob cancel(String jobId)

Cancel a current jod on the IoTHub

Parameters:

jobId - Unique ScheduledJob Id for this job

Returns:

the cancelled job

Throws:

IOException - if the function cannot create a URL for the job, or the IO failed on request
IotHubException - if the http request failed

get

public ScheduledJob get(String jobId)

Get the current job on the iotHub.

Parameters:

jobId - Unique ScheduledJob Id for this job

Returns:

the retrieved job

Throws:

IOException - if the function cannot create a URL for the job, or the IO failed on request
IotHubException - if the http request failed

query

public JobQueryResponse query(ScheduledJobType jobType, ScheduledJobStatus jobStatus)

Query from your IoT Hub's set of scheduled jobs by job type and job status.

Parameters:

jobType - The type of the job (methods or twin).
jobStatus - The status of the job ("completed", for example)

Returns:

The pageable set of Jobs that were queried.

Throws:

IOException - If IoT Hub cannot be reached due to network level issues.
IotHubException - If the request fails for non-network level issues such as throttling.

query

public JobQueryResponse query(ScheduledJobType jobType, ScheduledJobStatus jobStatus, QueryPageOptions options)

Query from your IoT Hub's set of scheduled jobs by job type and job status.

Parameters:

jobType - The type of the job (methods or twin).
jobStatus - The status of the job ("completed", for example)
options - The optional parameters used to decide how the query's results are returned. May not be null.

Returns:

The pageable set of Jobs that were queried.

Throws:

IOException - If IoT Hub cannot be reached due to network level issues.
IotHubException - If the request fails for non-network level issues such as throttling.

query

public JobQueryResponse query(String query)

Query from your IoT Hub's set of scheduled jobs.

Parameters:

query - The IoT Hub query for selecting which jobs to get.

Returns:

The pageable set of Jobs that were queried.

Throws:

IOException - If IoT Hub cannot be reached due to network level issues.
IotHubException - If the request fails for non-network level issues such as an incorrectly formatted query.

query

public JobQueryResponse query(String query, QueryPageOptions options)

Query from your IoT Hub's set of scheduled jobs.

Parameters:

query - The IoT Hub query for selecting which jobs to get.
options - The optional parameters used to decide how the query's results are returned. May not be null.

Returns:

The pageable set of Jobs that were queried.

Throws:

IOException - If IoT Hub cannot be reached due to network level issues.
IotHubException - If the request fails for non-network level issues such as an incorrectly formatted query.

scheduleDirectMethod

public ScheduledJob scheduleDirectMethod(String jobId, String queryCondition, String methodName, Date startTimeUtc)

Creates a new ScheduledJob to invoke method on one or multiple devices

Parameters:

jobId - Unique ScheduledJob Id for this job
queryCondition -

Query condition to evaluate which devices to run the job on. It can benull 

</code> or empty </p>
methodName - Method name to be invoked
startTimeUtc - Date time in Utc to start the job

Returns:

a jobResult object

Throws:

IOException - if the function cannot create a URL for the job, or the IO failed on request
IotHubException - if the http request failed

scheduleDirectMethod

public ScheduledJob scheduleDirectMethod(String jobId, String queryCondition, String methodName, Date startTimeUtc, DirectMethodsJobOptions options)

Creates a new ScheduledJob to invoke method on one or multiple devices

Parameters:

jobId - Unique ScheduledJob Id for this job
queryCondition -

Query condition to evaluate which devices to run the job on. It can benull 

</code> or empty </p>
methodName - Method name to be invoked
startTimeUtc - Date time in Utc to start the job
options - the optional parameters for this request. May not be null.

Returns:

a jobResult object

Throws:

IOException - if the function cannot create a URL for the job, or the IO failed on request
IotHubException - if the http request failed

scheduleUpdateTwin

public ScheduledJob scheduleUpdateTwin(String jobId, String queryCondition, Twin updateTwin, Date startTimeUtc, long maxExecutionTimeInSeconds)

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

Parameters:

jobId - Unique ScheduledJob Id for this job
queryCondition -

Query condition to evaluate which devices to run the job on. It can benull 

</code> or empty </p>
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

Returns:

a jobResult object

Throws:

IOException - if the function cannot create a URL for the job
IotHubException - if the http request failed

Applies to