Interface ITaskRequestBuilder
interface ITaskRequestBuilder
Extends com.amazon.apmf.IStandard
The ITaskRequestBuilder allows callers to encode execution parameters of a Task.
A TaskRequest consists of the name of the Task handler to run, an unique id associated
with the submission, zero or more constraint sets and an optional persistence flag.
Methods
requireDeviceIdle()
Add a constraint which requires the device to be idle for the Task to be eligible for execution. Note that calling this method is optional.ITaskRequestBuilder*requireDeviceIdle()
Returns
ITaskRequestBuilder*
An ITaskRequestBuilder instance that can be used for further calls.
requireInternet()
Add a constraint which requires the device to be connected to the internet for the Task to be eligible for execution. Note that calling this method is optional.ITaskRequestBuilder*requireInternet()
Returns
ITaskRequestBuilder*
An ITaskRequestBuilder instance that can be used for further calls.
requireReboot()
Add a constraint which requires the device to be rebooted before the Task is eligible for execution. This constraint does not guarantee immediate execution after the device is rebooted, just sometime after. This constraint is incompatible withITaskRequestBuilder*requireReboot()
requireTime and requireMessaging.
Only one of these constraints may be set in a Task Request to decide when a Task must be
executed. If set with a repeating flag, each iteration will run at most once every boot.
Note: Calling this method is optional.
Returns
ITaskRequestBuilder*
An ITaskRequestBuilder instance that can be used for further calls.
requireTime()
Add a time properties object that requires that the Task execute subject to time constraints. The constraint can be a combination of a delay or start time, an execution window and/ or a repetition interval. This constraint is incompatible withITaskRequestBuilder*requireTime(ITimeProperties*properties)
requireReboot and
requireMessaging.
Only one of these constraints may be set in a Task Request to decide when a Task must be
executed.
Parameters
properties
ITimeProperties* — Required
The time properties to associate with the Task Request.
Note: Calling this method is optional.
Returns
ITaskRequestBuilder*
An ITaskRequestBuilder instance that can be used for further calls.
requireMessaging()
Add a constraint that allows the Task to be triggered when a Message is sent. Currently, messages refer to both uri triggers sent from Event Manager and Message Router. This constraint may also be configured such that it is satisfied multiple times allowing the Task to be repeated. This constraint is incompatible withITaskRequestBuilder*requireMessaging(stringmessageUri)
requireTime and requireReboot.
Only one of these constraints may be set in a Task Request to decide when a Task must be
repeated.
Parameters
messageUri
string — Required
A string identifying the message Uri of interest.
Indicate this constraint may be satisfied multiple times by setting repeating().
Note that payloads are not persisted across restarts or reboots.
Returns
ITaskRequestBuilder*
An ITaskRequestBuilder instance that can be used for further calls.
retryPolicy()
Configure a retry policy for this Task. A user configured retry policy is used when the Task posts a temporary failure result. If the system is under resource pressure a running task may be interrupted. In such situations the Task Manager performs automatic retries even if a retry policy was not set. SeeITaskRequestBuilder*retryPolicy(IRetryPolicy*retryPolicy)
IRetryPolicyBuilder for details.
Note that calling this method is optional.
Note that calling this method additional times will replace the previous policy.
Parameters
retryPolicy
IRetryPolicy* — Required
A retry policy defining how system should act on failed runs of the Task.
Returns
ITaskRequestBuilder*
An ITaskRequestBuilder instance that can be used for further calls.
persistAfterAppDeath()
Instruct the system that this Task needs to be run across app restarts or system reboot. Note that calling this method is optional. Note that Task Manager will automatically remove non-persistent Tasks (meaning if persist() is not called) when app process terminates for any reason.ITaskRequestBuilder*persistAfterAppDeath()
Returns
ITaskRequestBuilder*
An ITaskRequestBuilder instance that can be used for further calls.
data()
Attach a strongly typed input payload to theITaskRequestBuilder*data(com.amazon.apmf.IStandard*attachment)
ITaskRequest. The payload may be any valid
Omnikit Data Object.
Parameters
attachment
com.amazon.apmf.IStandard* — Required
The Omnikit Data Object to attach to this request.
Returns
ITaskRequestBuilder*
An ITaskRequestBuilder instance that can be used for further calls.
name()
Set the unique name of the task to which this result applies. If the name is not set, the task name is the system generated Uuid. Note that the submitted task name may be at most 32 bytes in size. Note that the name must be unique within an application package. Note that the name can be reused once a task is completed or cancelled.ITaskRequestBuilder*name(stringtaskName)
Parameters
taskName
string — Required
A unique task name to identify the task
Returns
ITaskRequestBuilder*
An ITaskRequestBuilder instance that can be used for further calls.
Throws
com.amazon.apmf.InvalidArgumentError— in the build function is the name is not unique, or the name is more than 32 bytes in size.
repeating()
Indicate that the task should be run again based on a constraint. This is only compatible with time or messaging constraints.ITaskRequestBuilder*repeating()
Returns
ITaskRequestBuilder*
An ITaskRequestBuilder instance that can be used for further calls.
build()
Builds a TaskRequest with the set parameters.ITaskRequest*build(stringcomponentName)
Parameters
componentName
string — Required
A string identifier of the Task handler to execute.
Call this method after setting all parameters using the ‘set’ methods.
Note that the componentName must be a lifecycle component identified in the manifest.
Returns
ITaskRequest*
A TaskRequest instance to be given to TaskManager for submit(), update() etc.
Throws
com.amazon.apmf.InvalidArgumentError— If any set member variable is invalid.

