Create rule

post

/fleetMonitoring/clientapi/v2/rules/

This operation creates a new instance of a rule that is applicable to the entire application.

Request

Supported Media Types
Header Parameters
  • To allow targeting requests to different organizations. The header value should contain the organization identifier(orgId). This header is optional, if not provided orgId will be ORA_DEFAULT_ORG
Body ()
Root Schema : Rule_create
Type: object
Show Source
Nested Schema : actions
Type: array
Rule actions
Show Source
Nested Schema : config
Type: object
Additional Properties Allowed
Show Source
  • Map of the following type: Map<String, String>
Rule Config
Show Source
Nested Schema : predicates
Type: array
Rule Predicates
Show Source
Nested Schema : sources
Type: object
Additional Properties Allowed
Show Source
  • Map of the following type: Map<String, String>
Rule Sources
Show Source
Nested Schema : Action_create
Type: object
Show Source
Nested Schema : config
Type: object
Additional Properties Allowed
Show Source
  • Map of the following type: Map<String, String>
Config of Action
Show Source
Nested Schema : tags
Type: array
Tags of Action
Show Source
Nested Schema : Predicate_create
Type: object
Show Source
Nested Schema : config
Type: object
Additional Properties Allowed
Show Source
  • Map of the following type: Map<String, String>
Config of Predicate
Show Source
Back to Top

Response

Supported Media Types

202 Response

Successfully processed.
Body ()
Root Schema : Rule_receive
Type: object
Show Source
Nested Schema : actions
Type: array
Rule actions
Show Source
Nested Schema : config
Type: object
Additional Properties Allowed
Show Source
  • Map of the following type: Map<String, String>
Rule Config
Show Source
Nested Schema : predicates
Type: array
Rule Predicates
Show Source
Nested Schema : sources
Type: object
Additional Properties Allowed
Show Source
  • Map of the following type: Map<String, String>
Rule Sources
Show Source
Nested Schema : Action_receive
Type: object
Show Source
Nested Schema : config
Type: object
Additional Properties Allowed
Show Source
  • Map of the following type: Map<String, String>
Config of Action
Show Source
Nested Schema : tags
Type: array
Tags of Action
Show Source
Nested Schema : Predicate_receive
Type: object
Show Source
Nested Schema : config
Type: object
Additional Properties Allowed
Show Source
  • Map of the following type: Map<String, String>
Config of Predicate
Show Source

400 Response

Bad Request. The request could not be understood by the server due to malformed syntax. The client SHOULD NOT repeat the request without modifications.

401 Response

Unauthorized. The request requires user authentication.

403 Response

Forbidden. The server understood the request, but is refusing to fulfill it. Authorization will not help and the request SHOULD NOT be repeated.

406 Response

Not Acceptable. The resource identified by the request is only capable of generating response entities which have content characteristics not acceptable according to the accept headers sent in the request.

415 Response

Unsupported Media Type. The request entity has a media type which the server or resource does not support.
Back to Top

Examples

curl -X POST 
   -u <username>:<password>
   -H 'Accept: application/json'
   -H 'Content-Type: application/json'
   https://iotserver/fleetMonitoring/clientapi/v2/rules

Example of Request Body

The following example shows the content of the request body in JSON format:


ALERT RULE

The following example shows the content of the request body in JSON format to create an alert rule:

{
"name": "Vehicle Alert Rule",
"sources": {
"vehicle":["Vehicle_2", "Vehicle_1"]
},
"predicates": [{
"type": "alert",
"config": {
"formats": ["urn:com:oracle:iot:device:obd2:vehicle_started"]
}
}],
"predicateCombination": "all_of",
"actions": [{
"type": "TRIGGERINCIDENT",
"config": {
"summary": "Vehicle Started Alert rule",
"incidentType": "MAINTENANCE",
"priority": "LOW",
"description": ""
},
"tags": ["Vehicle started Alert"]
}]
}


THRESHOLD RULE

The following example shows the content of the request body in JSON format to create a threshold rule:

{
"name": "Vehicle Threshold rule",
"sources": {
"vehicle": ["Vehicle_2", "Vehicle_1"]
},
"predicates": [{
"type": "threshold",
"config": {
"attributeSource": "businessObject",
"attributeName": "metric/sys_openIncidents",
"threshold": "1",
"attributeType": "NUMBER",
"operator": "gt"
}
}],
"predicateCombination": "all_of",
"actions": [{
"type": "TRIGGERALERT",
"config": {
"summary": "Vehicle Threshold rule",
"severity": "SIGNIFICANT",
"suppressionPeriod": 60000,
"includeSourceAttributes": false,
"includeContextInfo": false,
"includeRootMessagePayload": false,
"messageFormat": "urn:com:oracle:iot:platform:violation:fm:speed"
}
}]
}


GEO FENCE RULE

The following example shows the content of the request body in JSON format to create a geo fence rule:

{
"name": "Shipment Fence Rule",
"sources": {
"shipment": "ALL"
},
"predicates": [{
"type": "geo",
"config": {
"fences": ["Fence1"],
"direction": "entered"
}
}],
"predicateCombination": "all_of",
"actions": [{
"type": "TRIGGERINCIDENT",
"config": {
"summary": "Shepment Fence Rule",
"incidentType": "MAINTENANCE",
"priority": "LOW",
"description": "Shipment entered into Fence1"
},
"tags": []
}]
}

VEHICLE TYPE RULE

The following example shows the content of the request body in JSON format to create a vehicle type rule:

 
{
"name":"Vehicle Type Rule",
"sources":{
"vehicleType":"VehicleTypeName"
},
"predicates":[
{
"type":"threshold",
"config":{
"attributeSource":"businessObject",
"attributeName":"metric/sys_openIncidents",
"threshold":"1",
"attributeType":"NUMBER",
"operator":"gt"
}
}
],
"predicateCombination":"all_of",
"actions":[
{
"type":"TRIGGERINCIDENT",
"config":{
"summary":"Test Incident",
"incidentType":"MAINTENANCE",
"priority":"LOW",
"description":""
},
"tags":[

]
}
]
}

Example of Response Body

The following example shows the content of the response body in JSON format:

 {
"lastModifiedTime":1469184297746,
"sources":{
"sources_key1":"sources_value1",
},
"predicateCombination":"ANY_OF",
"lastModifiedTimeAsString":"2016-07-22T10:44:57.746Z",
"description":"Detailed description",
"predicates":[
{
"type":"THRESHOLD",
"config":{
"config_key1":"config_value1",
"config_key2":"config_value2",
"config_key3":"config_value3"
}
}
],
"system":false,
"createdTimeAsString":"2016-07-22T10:44:57.746Z",
"name":"Rule name",
"createdTime":1469184297746,
"links":[
{
"rel":"self",
"href":"https://iotserver/fleetMonitoring/clientapi/version/resource/path"
},
{
"rel":"canonical",
"href":"https://iotserver/fleetMonitoring/clientapi/version/resource/path"
}
],
"id":"3e99b034006-2ef3",
"state":"ENABLED",
"applicationId":"25ce2c6d4ebc-1c62",
"config":{
"config_key1":"config_value1",
"config_key2":"config_value2",
"config_key3":"config_value3"
},
"actions":[
{
"type":"TRIGGERINCIDENT",
"config":{
"priority":"LOW",
"summary":"New Incident",
"incidentType":"MAINTENANCE",
"description":"Description"
},
"tags":[]
}
]
}



Complete cURL Example

The following example shows a complete cURL command that you can use to perform the described operation:

curl -X POST 
   -u <username>:<password>
   -H 'Accept: application/json'
   -H 'Content-Type: application/json'
   -d '{"predicates":[{"type":"Type of Predicate, One of [THRESHOLD, GEO, ALERT].","config":{"config_key1":"config_value1","config_key2":"config_value2","config_key3":"config_value3"}}],"sources":{"sources_key1":"sources_value1","sources_key2":"sources_value2","sources_key3":"sources_value3"},"predicateCombination":"The manner in which to combine rule predicates. One of [ANY_OF, ALL_OF].","name":"The name of the rule.","description":"The detailed description of the rule.","state":"The state of the rule. One of [ENABLED, DISABLED, INVALID].","config":{"config_key1":"config_value1","config_key2":"config_value2","config_key3":"config_value3"},"actions":[{"type":"Type of Action, One of [TRIGGERALERT, TRIGGERINCIDENT, TRIGGERWARNING, TRIGGERSOURCEPROCEDURE, TRIGGER_CW_DEVICE_ACTION, TRIGGER_CW_SEND_MESSAGE].","config":{"config_key1":"config_value1","config_key2":"config_value2","config_key3":"config_value3"},"tags":["tags_1","tags_2","tags_3"]}]}'
   https://iotserver/fleetMonitoring/clientapi/v2/rules



Note that in the request, https://iotserver will be replaced by the name and port of your assigned IoT Cloud Service instance. The format of the Cloud Service instance is https://myinstance-myidentitydomain.iot.us.oraclecloud.com and the default port is 443.
Back to Top