Rules Management

Rules

Rules management in Carriots

Create

Create rule

URL: http://api.carriots.com/rules/
HTTP method: POST

Attributes:

Attribute Description
name (mandatory) Text. 50 characters max.
Unique.
Rule name.
Example: parkingcontrol
description (optional) Text. 200 characters max.
Rule description.
Example: Temperature sensor
script (mandatory) Text. 50000 characters max.
Expression to be executed
enabled (mandatory) Boolean. Valid values: 0, 1, true or false.
Rule enabled, default true
Example: true

Response codes

Code Description
200 Operation successfull
Possible values:
- code: 2001 message: rule persisted details:
400 Request not valid
Possible values:
- code: 4001 message: Json bad formed details:
- code: 4003 message: validation error details: {field: error message,...}
404 Resource not found
503 Service unavailable.
- code: 5031 message: BD error details:
- code: 5032 message: exception details: {message: }
Show

Model show

URL: http://api.carriots.com/rules/-- ID_rule --/
HTTP method: GET
Response: json/xml

Response codes

Code Description
200 Operation successfull
Possible values:
- Rule JSon/xml object
400 Request not valid
Possible values:
- code: 4004 message: format parameter invalid {field: error message,...}
404 Resource not found
503 Service unavailable.
- code: 5031 message: BD error details:
- code: 5032 message: exception details: {message: }
List

Rules list, max. 1000

URL: http://api.carriots.com/rules/
HTTP method: GET
Response: json/xml

Parameters:

Attribute Description
name (optional) Text. 50 characters max.
Filter list result by field name.
Example: r001
enabled (optional) Boolean. Valid values: 0, 1, true or false.
Filter list result by field enabled.
Example: true
owner (optional) username.
Filter list result by field owner.
Example: jlopez
updater (optional) username.
Filter list result by field updater.
Example: jlopez
created_at (optional) Timestamp.
Filter list result by field created_at.
Example: 1337009328
to and from modificators allows to specify a range. Extreme values are included.
Example: created_at=1337009328
max (optional) Integer. Values between 1 and 1000.
Defines the number of results to be returned. Max and default value is 1000.
Example: 250
sort (optional) Field name.
Sort the result by the given field. Default value is name.
Example: creation_date
order (optional) Integer. Valid values: -1 or 1
Result order criteria: -1 for descending and 1 for ascending.
Example: -1
offset (optional) Integer.
Result offset. List will begin at the given offset.
Example: 100

Response codes

Code Description
200 Operation successfull
Possible values:
- total_documents:result numbers result: Rules JSON objects set
400 Request not valid
Possible values:
- code: 4004 message: format parameter invalid {field: error message,...}
503 Service unavailable.
- code: 5031 message: BD error details:
- code: 5032 message: exception details: {message: }
Update

Rule update

URL: http://api.carriots.com/rules/-- ID_rule --/
HTTP method: PUT

Response codes

Code Description
200 Operation successfull
Possible values:
- code: 2005 message: rule updated details:Rule JSON object
400 Request not valid
Possible values:
- code: 4001 message: nonexistent file details:
- code: 4003 message: validation error details:{field: error message,...}
- code: 4004 message: format parameter invalid details:{field: error message,...}
- code: 4005 message: concurrency error details:{version: }
404 Resource not found
503 Service unavailable.
- code: 5031 message: BD error details:
- code: 5032 message: exception details: {message: }
Delete

Rule delete

URL: http://api.carriots.com/rules/-- ID_rule --/
HTTP method: DELETE

Response codes

Code Description
200 Operation successfull
Possible values:
- code: 2004 message: rule deleted details:
404 Resource not found
503 Service unavailable.
- code: 5031 message: BD error details:
- code: 5032 message: exception details: {message: }

Listeners

Listeners management in Carriots

Create

Create listener

URL: http://api.carriots.com/listeners/
HTTP method: POST

Attributes:

Attribute Description
name (mandatory) Text. 50 characters max.
Unique.
Listener name.
Example: parkingcontrol
description (optional) Text. 200 characters max.
Listener description.
Example: Forbidden parking control
event (mandatory) Text, one of data_received or data_persisted
Event to listen.
Example: data_received
entity (mandatory) JSON with fileds: "entity_type" text, one of Project, Service, Group, Asset or Device
"id" text, entity id_developer
if_expression (mandatory) Text. 5000 characters max
Expression to be evaluated to determine then or else execution path
Example: context.data.tag==parking1
then_expression (optional) Text. 5000 characters max.
Expression to be executed if if_expression is evaluated to true
then_rule (optional) Rule id_developer
Rule to be executed if if_expression is evaluated to true
Example: forbiddentruerule@carriots
else_expression (optional) Text. 5000 characters max.
Expression to be executed if if_expression is evaluated to false
else_rule (optional) Rule id_developer
Rule to be executed if if_expression is evaluated to false
Example: forbiddenelserule@carriots
enabled (mandatory) Boolean. Valid values: 0, 1, true or false.
Listener enabled, default true
Example: true

Response codes

Code Description
200 Operation successfull
Possible values:
- code: 2001 message: listener persisted details:
400 Request not valid
Possible values:
- code: 4001 message: Json bad formed details:
- code: 4003 message: validation error details: {field: error message,...}
404 Resource not found
503 Service unavailable.
- code: 5031 message: BD error details:
- code: 5032 message: exception details: {message: }
Show

Listener show

URL: http://api.carriots.com/listeners/-- ID_listener --/
HTTP method: GET
Response: json/xml

Response codes

Code Description
200 Operation successfull
Possible values:
- Listener JSon/xml
400 Request not valid
Possible values:
- code: 4004 message: format parameter invalid {field: error message,...}
404 Resource not found
503 Service unavailable.
- code: 5031 message: BD error details:
- code: 5032 message: exception details: {message: }
List

Listeners list, max 1000

URL: http://api.carriots.com/listeners/
HTTP method: GET
Response: json/xml

Parameters:

Attribute Description
name (optional) Text. 50 characters max.
Filter list result by field name.
Example: l001
enabled (optional) Boolean. Valid values: 0, 1, true or false.
Filter list result by field enabled.
Example: true
owner (optional) username.
Filter list result by field owner.
Example: jlopez
updater (optional) username.
Filter list result by field updater.
Example: jlopez
created_at (optional) Timestamp.
Filter list result by field created_at.
Example: 1337009328
to and from modificators allows to specify a range. Extreme values are included.
Example: created_at=1337009328
max (optional) Integer. Values between 1 and 1000.
Defines the number of results to be returned. Max and default value is 1000.
Example: 250
sort (optional) Field name.
Sort the result by the given field. Default value is name.
Example: creation_date
order (optional) Integer. Valid values: -1 or 1
Result order criteria: -1 for descending and 1 for ascending.
Example: -1
offset (optional) Integer.
Result offset. List will begin at the given offset.
Example: 100

Response codes

Code Description
200 Operation successfull
Possible values:
- total_documents:result numbers result: Listeners JSON objects set
400 Request not valid
Possible values:
- code: 4004 message: format parameter invalid {field: error message,...}
503 Service unavailable.
- code: 5031 message: BD error details:
- code: 5032 message: exception details: {message: }
Update

Listener update

URL: http://api.carriots.com/listeners/-- ID_listener --/
HTTP method: PUT

Response codes

Code Description
200 Operation successfull
Possible values:
- code: 2005 message: listener updated details:Listener JSON object
400 Request not valid
Possible values:
- code: 4001 message: nonexistent file details:
- code: 4003 message: validation error details:{field: error message,...}
- code: 4004 message: format parameter invalid details:{field: error message,...}
- code: 4005 message: concurrency error details:{version: }
404 Resource not found
503 Service unavailable.
- code: 5031 message: BD error details:
- code: 5032 message: exception details: {message: }
Delete

Listener delete

URL: http://api.carriots.com/listeners/-- ID_listener --/
HTTP method: DELETE

Response codes

Code Description
200 Operation successfull
Possible values:
- code: 2004 message: listener deleted details:
404 Resource not found
503 Service unavailable.
- code: 5031 message: BD error details:
- code: 5032 message: exception details: {message: }