Core
IoT Platform v2.x
2

search #

Searches for notification rules.


Query Syntax #

HTTP #

[//]: # (URL: http://kuzzle:7512/notifications/:index/_search[?from=<int>][&size=<int>])
[//]: # (Method: POST)
[//]: # (Body:)
{
  "query": {
    // query
  },
  "aggregations": {
      // ...
  },
  "sort": {
    // sort
  },
}

Javascript #

kuzzle.query({
  controller: 'notifications',
  action: 'search',
  index: '<index>',
  from: 0, // integer
  size: 10, // integer
  body: {
    query: {
      // query
    },
    sort: {
      // sort
    },
  },
});

Arguments #

  • index : Tenant index
  • from : Offset of the first notification rule to fetch
  • size : Maximum number of notification rules to fetch

Optional: #

  • query: the search query itself, using the ElasticSearch Query DSL
  • aggregations: control how the search result should be aggregated
  • sort: contains a list of fields, used to sort search results, in order of importance

Response #

Returns a list of notification rules.

{
  "status": 200,
  "action": "search",
  "controller": "notification-rules",
  "error": null,
  "headers": {},
  "index": "<index>",
  "node": "<node-id>",
  "requestId": "<request-id>",
  "result": {
    "hits": [
      {
        "_id": "<notification-rule-id>",
        "_score": 1,
        "_source": {
          "type": "notification-rules",
          "notification-rules": {
            "name": "My notification rule",
            "description": "Example notification rule",
            "filters": {},
            "linkedAlertRules": [],
            "plannings": [
              {
                "channels": [
                  "email"
                ],
                "recipients": [],
                "days": {
                  "mon": true,
                  "tue": true,
                  "wed": false,
                  "thu": false,
                  "fri": false,
                  "sat": false,
                  "sun": false
                },
                "range": {
                  "allDay": true,
                  "start": "09:00",
                  "end": "17:00"
                },
                "timezone": "Europe/Paris"
              }
            ],
            "emailAction": {
              "message": "A new alert has been triggered.",
              "subject": "New alert",
              "client": "smtp",
              "enabled": true,
              "tenant": "<index>"
            },
            "smsAction": {
              "message": "A new alert has been triggered.",
              "subject": "",
              "client": "twilio",
              "enabled": true,
              "tenant": "<index>"
            }
          },
          "_kuzzle_info": {
            "author": "user",
            "createdAt": 1600000000000,
            "updatedAt": null,
            "updater": null
          }
        },
        "collection": "config",
        "index": "<index>"
      }
    ],
    "fetched": 1,
    "total": 1
  }
}