
Retrieve the definition of all alert rules previously installed in this
REST API instance using the /v1/alert/{name} service.
| URL Parameters | |
|---|---|
| database? | Perform this operation on the named content database instead of the default content database associated with the REST API instance. Using an alternative database requires the "eval-in" privilege; for details, see Security Requirements in the REST Application Developer's Guide. |
| format? |
The expected content type of the results. This is equivalent to specifying
the format in the Accept header. The format parameter
overrides the Accept header if both are present. Accepted values:
xml and json. Default: xml.
|
| Request Headers | |
|---|---|
| Accept* |
The expected MIME type of the information in the response.
Accepted types: application/json or
application/xml. Ignored if the request includes a
format parameter value.
|
On success, MarkLogic Server responds with a 200 status. The data in
the response body is definitions of all installed rules. Results can
be returned as either XML or JSON, depending up on the format
request parameter or the Accept header setting. For details on the
format of rule definitions, see
Defining an Alerting Rule in the REST Application Developer's Guide.
If the Alerting API is not enabled, MarkLogic Server returns status 403.
rest-reader role, or the
following privilege:
http://marklogic.com/xdmp/privileges/rest-reader
The expected response type can be specified using either the
format parameter or Accept header. One or
the other must be supplied. If both are supplied and are different,
the format parameter takes precedence.
$ curl --anyauth --user user:password -X GET -i -H "Accept: application/xml" \
'http://localhost:8000/v1/alert/rules'
==> The definitions of all installed rules, as XML. MarkLogic Server
responds with output similar to the following:
HTTP/1.1 200 OK
Content-type: application/xml; charset=utf-8
Server: MarkLogic
Content-Length: 542
Connection: Keep-Alive
Keep-Alive: timeout=5
<rapi:rules xmlns:rapi="http://marklogic.com/rest-api">
<rapi:rule>
<rapi:name>example</rapi:name>
<rapi:description>An example rule.</rapi:description>
<search:search xmlns:search="http://marklogic.com/appservices/search">
<search:qtext>xdmp</search:qtext>
<search:options>
<search:term>
<search:term-option>case-sensitive</search:term-option>
</search:term>
</search:options>
</search:search>
<rapi:rule-metadata>
<author>me</author>
</rapi:rule-metadata>
</rapi:rule>
</rapi:rules>
$ curl --anyauth --user user:password -X GET -i -H "Accept: application/json" \
'http://localhost:8000/v1/alert/rules'
==> The definitions of all installed rules, as JSON. MarkLogic Server
responds with output similar to the following:
HTTP/1.1 200 OK
Content-type: application/json; charset=utf-8
Server: MarkLogic
Content-Length: 190
Connection: Keep-Alive
Keep-Alive: timeout=5
{ "rules": [
{ "rule": {
"name": "example",
"description": "An example rule.",
"search": {
"qtext": [ "xdmp" ],
"options": {
"term": { "term-option": [ "case-sensitive" ] }
}
},
"rule-metadata": { "author": "me" }
} }
] }
Stack Overflow: Get the most useful answers to questions from the MarkLogic community, or ask your own question.