Rules

1. rules()

Get the rules as a list.

Parameters: None

Return value: List of Rule Object

Return value example:

istack/iot/v1/rule Rule
name: inesa rule
enabled: False
events:
[
 ‘event0’
]
actions:
[
  ‘action0’
]
repeat_actions: False
time_constraints: []
admin: admin
state_timestamp: 1234068436465461

2. create_rule(rule)

Create a rule.

Parameters: rule (Rule)

Name Type Description
rule Rule A Rule Object.
name str name of the rule, required to be unique
enabled bool the switch of the rule, to decide if it works.
events list rule’s events list
actions list action list to emit
repeat_actions bool repeat or not
time_constraints list(RuleTimeConstraint) when to run the actions
admin str rule maker
state_timestamp Datetime last updated time

Parameters Example:

rule = Rule()
            rule.name = "2"
            rule.admin = "admin"
            rule.repeatable = True
            rule.enable = True
            rule.actions = [{
                "method": "PUT",
                "url": "http://10.200.46.120:10002/mgmt/action/00:23:23:23:23",
                "body": "{\"PUT_DEVICE\":{\"POWER\":{\"ON\":null}}}",
                "admin": "admin",
                "id": "032a38e0817e706e9185048cd90ac6d2",
                "name": "2"
            }] # one can also put action object inside
            rule.events = [{
                "uid": "10.200.44.80",
                "state": "23123",
                "admin": "admin",
                "id": "f3c734b7b96e9a4d3d680440332ae023",
                "name": "2222"
            },
            {
                "uid": "10.200.44.80",
                "state": "333",
                "admin": "admin",
                "id": "2963ebd8aaf983484b27049d2c81ba8a",
                "name": "333"
            }] # one can also put event object inside
            cloud.iot.create_rule(rule)

Return value: Rule Object

Return value example:

istack/iot/v1/rule Rule
name: inesa rule
enabled: False
events:    
[
 ‘event0’
]
actions:
[
  ‘action0’
]
repeat_actions: False
time_constraints: []
admin: admin
state_timestamp: 1234068436465461

3. delete_rule(rule)

Delete a rule.

Parameters: rule (Rule)

Name Type Description
rule Rule A Rule Object.
name str name of the rule, required to be unique
enabled bool the switch of the rule, to decide if it works.
events list rule’s events list
actions list action list to emit
repeat_actions bool repeat or not
time_constraints list(RuleTimeConstraint) when to run the actions
admin str rule maker
state_timestamp Datetime last updated time

Parameters Example:

rule = Rule()
            rule.name = "2"
            rule.admin = "admin"
            rule.repeatable = True
            rule.enable = True
            rule.actions = [{
                "method": "PUT",
                "url": "http://10.200.46.120:10002/mgmt/action/00:23:23:23:23",
                "body": "{\"PUT_DEVICE\":{\"POWER\":{\"ON\":null}}}",
                "admin": "admin",
                "id": "032a38e0817e706e9185048cd90ac6d2",
                "name": "2"
            }] # one can also put action object inside

            cloud.iot.delete_rule(rule)

Return value: deletion_message (string)

results matching ""

    No results matching ""