rules - Perseo command

This command allows you to list, create, get and delete rule entry for Perseo.

Common Options

Options Description
--host value, -h value specify host or alias
--token value specify oauth token
--service value, -s value specify FIWARE Service
--path value, -p value specify FIWARE ServicePath
--help show help (default: false)

List all rules

This command lists all rules.

ngsi rules [command options] list [options]

Options

Options Description
--limit value maximum number of rules (default: 0)
--offset value offset to skip a given number of rules at the beginning (default: 0)
--count print number of rules (default: false)
--raw print raw data (default: false)
--verbose, -v verbose (default: false)
--pretty, -P pretty format (default: false)
--help show help (default: false)

Examples

Request:

ngsi rules list
blood_rule_update

Create a rule

This command creates a rule.

ngsi rules [command options] create [options]

Options

Options Description
--data value, -d value rule data
--verbose, -v verbose (default: false)
--pretty, -P pretty format (default: false)
--help show help (default: false)

Examples

Request:

ngsi rules --host perseo create \
--data '{
    "name": "blood_rule_update",
    "text": "select *, *, ev.BloodPressure? as Pressure, ev.id? as Meter from pattern [every ev=iotEvent(cast(cast(BloodPressure?,String),float)>1.5 and type=\"BloodMeter\")]",
    "action": {
        "type": "update",
        "parameters": {
            "attributes": [
                {
                    "name": "abnormal",
                    "value": "true",
                    "type": "boolean"
                }
            ]
        }
    }
}

Get a rule

This command gets a rule.

ngsi rules [command options] get [options]

Options

Options Description
--name value, -n value rule name
--pretty, -P pretty format (default: false)
--help show help (default: false)

Examples

Request:

ngsi rules get --name blood_rule_update --pretty
{
  "error": null,
  "data": {
    "_id": "6024c5af8e2bfc0012c77487",
    "name": "blood_rule_update",
    "text": "select \"blood_rule_update\" as ruleName, *, *, ev.BloodPressure? as Pressure, ev.id? as Meter from pattern [every ev=iotEvent(cast(cast(BloodPressure?,String),float)>1.5 and type=\"BloodMeter\")]",
    "action": {
      "type": "update",
      "parameters": {
        "attributes": [
          {
            "name": "abnormal",
            "value": "true",
            "type": "boolean"
          }
        ]
      }
    },
    "subservice": "/",
    "service": "unknownt"
  }
}

Delete a rule

This command deletes a rule.

ngsi rules [command options] delete [options]

Options

Options Description
--name value, -n value rule name
--help show help (default: false)

Examples

Request:

ngsi rules delete --name blood_rule_update