public interface Rule
Modifier and Type | Interface and Description |
---|---|
static class |
Rule.State
Defines possible Rule states.
|
Modifier and Type | Method and Description |
---|---|
CompletionStage<Void> |
delete()
Deletes the Rule.
|
CompletionStage<Void> |
disable()
Disables the Rule.
|
CompletionStage<Void> |
disable(boolean cancelRuleTasks)
Disables the Rule.
|
CompletionStage<Void> |
enable()
Enables the Rule.
|
CompletionStage<Void> |
fire()
Fires the Rule manually.
|
Action |
getAction()
Returns the action for this Rule.
|
String |
getDisplayName()
Returns the user-friendly display name of this Rule.
|
ExecOptions |
getExecOptions()
Returns the execution options of this Rule.
|
CompletionStage<Integer> |
getInvolvedDevicesCount(DeviceExecStatus.State deviceExecState)
Calculates the count of involved devices with given execution status in this Rule.
|
CompletionStage<DeviceRuleStatus> |
getInvolvedDeviceState(String deviceId)
Returns the execution status of a given device within this Rule.
|
CompletionStage<Date> |
getLastModified() |
CompletionStage<Date> |
getLastTriggered() |
CompletionStage<Map<String,Object>> |
getProperties()
Returns custom properties assigned to this Rule.
|
CompletionStage<Object> |
getProperty(String key)
Gets the value of a Rule property by property name.
|
String |
getRuleId()
Returns the id of this Rule.
|
Scope |
getScope()
Returns the Rule scope.
|
CompletionStage<Rule.State> |
getState()
Returns the state of this Rule.
|
CompletionStage<String> |
getStateDescription()
May return a text message explaining the Rule state.
|
CompletionStage<String> |
getTenantId()
Returns the id of the tenant created this Rule.
|
String |
getTextRepresentation()
Returns the JSON-representation of the Rule definition.
|
CompletionStage<Date> |
getTimeCreated() |
TriggerList |
getTrigger()
Returns the Rule trigger.
|
CompletionStage<Integer> |
getTriggersCount()
Tells how many times this Rule has been triggered.
|
CompletionStage<List<DeviceRuleStatus>> |
listInvolvedDevices(DeviceExecStatus.State deviceExecState)
Retrieves a list of all involved devices into this Rule with the respective execution status for each device.
|
com.bosch.iot.dm.util.PageIterator<DeviceRuleStatus> |
listInvolvedDevices(DeviceExecStatus.State deviceExecState,
int pageSize) |
FilteredSet<Task> |
listLaunchedTasks(String taskFilter)
Retrieves all Tasks originating from that Rule that satisfy given filtering criteria.
|
FilteredSet<Task> |
listLaunchedTasksForDevice(String deviceId,
String taskFilter)
Retrieves all Tasks originating from that Rule that include a given device, possible filtered by some Tasks criteria.
|
CompletionStage<Void> |
modify(String ruleDef)
Modifies existing Rule.
|
CompletionStage<Void> |
modify(String ruleDisplayName,
Scope scope,
TriggerList trigger,
ExecOptions options,
Action action)
Modifies existing Rule.
|
CompletionStage<Void> |
retryDevice(String deviceId)
Retries the rule over the device with the given device type and device id.
|
CompletionStage<Void> |
retryDevices(DeviceExecStatus.State[] statusFilter)
Retries the rule over the devices whose status satisfies the given status filter.
|
CompletionStage<Void> |
setProperties(Map<String,Object> properties,
boolean append)
Sets the custom Rule properties.
|
CompletionStage<Void> |
setProperty(String key,
Object value)
Sets custom Rule property.
|
void |
subscribeForRuleEvents(List<RuleEvent.Type> eventTypes,
StreamConsumer<RuleEvent> consumer) |
void |
subscribeForTaskEvents(List<TaskEvent.Type> eventTypes,
StreamConsumer<TaskEvent> consumer) |
CompletionStage<Rule.State> getState()
CompletionStage<String> getStateDescription()
"Rule failed to enable, Reason: some reason"
for Rules in state Rule.State.FAILED_TO_ENABLE
.CompletionStage<Integer> getTriggersCount()
CompletionStage<List<DeviceRuleStatus>> listInvolvedDevices(DeviceExecStatus.State deviceExecState)
DeviceExecStatus.State.RUNNING
if the device is in running status in at least one Task originated from that Rule.DeviceExecStatus.State.FINISHED_SUCCESS
,
DeviceExecStatus.State.FINISHED_ERROR
, DeviceExecStatus.State.FINISHED_SUCCESS
or
DeviceExecStatus.State.FINISHED_CANCELED
) corresponds to
the finish status from the latest Task (originating from that Rule) the has been involved in.deviceExecState
- filter on the execution status for the retrieved involved devices. For example, there could be retrieved
only devices that have finished the Rule execution with error (use: DeviceExecStatus.State.FINISHED_ERROR
)
or devices that have finished with any status (use: DeviceExecStatus.State.FINISHED
)DeviceExecStatus
objects representing the execution status of a single involved device.com.bosch.iot.dm.util.PageIterator<DeviceRuleStatus> listInvolvedDevices(DeviceExecStatus.State deviceExecState, int pageSize)
CompletionStage<DeviceRuleStatus> getInvolvedDeviceState(String deviceId)
deviceId
- device id.CompletionStage<Integer> getInvolvedDevicesCount(DeviceExecStatus.State deviceExecState)
deviceExecState
- filter on the execution status for the counted involved devices. For example, there could be counted
only devices that have finished the Task execution with error (use: DeviceExecStatus.State.FINISHED_ERROR
)
or devices that have finished with any status (use: DeviceExecStatus.State.FINISHED
)CompletionStage<Date> getTimeCreated()
CompletionStage<Date> getLastModified()
CompletionStage<Date> getLastTriggered()
FilteredSet<Task> listLaunchedTasks(String taskFilter)
taskFilter
- a json query filter over the Task attributes. ((errorCount > 0 | state == 2) & (ruleId != "R5K2A92DX8J" | !(action includes "myService.myMethod()")))
true
when the execution is paused die to time constraint restrictions.FilteredSet
from which the list of Tasks satisfying the filter could be listed
(see: FilteredSet.list()
) and arbitrary Tasks (potentially caught by events) could be matched
if they satisfy the filtering criteria of the FilteredSet
. See FilteredSet.match(Object)
.FilteredSet<Task> listLaunchedTasksForDevice(String deviceId, String taskFilter)
deviceId
- device idtaskFilter
- task filterString getRuleId()
Scope getScope()
TriggerList getTrigger()
ExecOptions getExecOptions()
Action getAction()
String getDisplayName()
CompletionStage<String> getTenantId()
CompletionStage<Void> enable()
Rule.State.ENABLED
and
may be triggered either manually or automatically regarding its defined triggers.CompletionStage<Void> disable()
Rule.State.DISABLED
and cannot be
triggered any more in this state. Invoking this method has the same effect as invoking the
disable(boolean)
method with argument true
, i.e., all running Tasks
originating from that Rule will be automatically canceled.CompletionStage<Void> disable(boolean cancelRuleTasks)
Rule.State.DISABLED
and cannot be
triggered any more in this state.cancelRuleTasks
- specifies whether all running Tasks originating from that Rule to be directly canceled
or should be left to complete normally. If Tasks are left to finish normally then Rule statistics (involved/finished devices, etc.)
may continue to change as long as Tasks reflecting those statistics are still working. But in any case - no new Tasks will be
anymore triggered as Rule is in state Rule.State.DISABLED
.CompletionStage<Void> delete()
CompletionStage<Void> modify(String ruleDisplayName, Scope scope, TriggerList trigger, ExecOptions options, Action action)
Rule.State.ENABLED
.
After modification, any previous execution information relate to that Rule
(Tasks, number of involved, finished devices, etc.) will be cleaned.ruleDisplayName
- user-friendly display name of the Rule.scope
- defines the initial execution scope of the Rule.
The Rule could be system-scoped or device-scoped and could cover arbitrary set of respective targets.trigger
- defines the triggering criteria for the Rule.options
- defines the execution options of the Rule.action
- the Rule action.CompletionStage<Void> modify(String ruleDef)
Rule.State.ENABLED
.
After modification, any previous execution information relate to that Rule
(Tasks, number of involved, finished devices, etc.) will be cleaned.ruleDef
- JSON-encoded Rule definition of the modified Rule. For details in the JSON definition, refer to
MassManagementEngine.createRule(String)
method.CompletionStage<Void> fire()
String getTextRepresentation()
MassManagementEngine.createRule(String)
. It exports the Rule as portable JSON text that can be
used further in creating a copy of this Rule via the MassManagementEngine.createRule(String)
method.CompletionStage<Map<String,Object>> getProperties()
setProperties(Map, boolean)
and setProperty(String, Object)
methods.CompletionStage<Void> setProperties(Map<String,Object> properties, boolean append)
properties
- Rule properties.append
- if true
the supplied properties will be appended/added to any properties currently existing for
this Rule, otherwise any existing properties will be fully replaced by the supplied ones.CompletionStage<Object> getProperty(String key)
key
- property nameCompletionStage<Void> setProperty(String key, Object value)
key
- property name.value
- property value.CompletionStage<Void> retryDevices(DeviceExecStatus.State[] statusFilter)
statusFilter
- status filterCompletionStage<Void> retryDevice(String deviceId)
deviceId
- device idvoid subscribeForRuleEvents(List<RuleEvent.Type> eventTypes, StreamConsumer<RuleEvent> consumer)
void subscribeForTaskEvents(List<TaskEvent.Type> eventTypes, StreamConsumer<TaskEvent> consumer)
Copyright © 2022 Bosch.IO GmbH. All rights reserved.