From 8f88fbf24f6891b4f1a14b9c6faf875613c1977e Mon Sep 17 00:00:00 2001 From: Umit Akkaya Date: Thu, 7 Sep 2017 20:44:34 +0200 Subject: [PATCH] Add filtering checks by tag to api documentation --- templates/front/docs_api.html | 10 ++++++++-- .../list_checks_request_filtered.html | 2 ++ .../snippets/list_checks_request_filtered.txt | 1 + .../list_checks_response_filtered.html | 19 +++++++++++++++++++ .../list_checks_response_filtered.txt | 18 ++++++++++++++++++ 5 files changed, 48 insertions(+), 2 deletions(-) create mode 100644 templates/front/snippets/list_checks_request_filtered.html create mode 100644 templates/front/snippets/list_checks_request_filtered.txt create mode 100644 templates/front/snippets/list_checks_response_filtered.html create mode 100644 templates/front/snippets/list_checks_response_filtered.txt diff --git a/templates/front/docs_api.html b/templates/front/docs_api.html index a5c9d39b..af5275e6 100644 --- a/templates/front/docs_api.html +++ b/templates/front/docs_api.html @@ -61,8 +61,8 @@ The response may contain a JSON document with additional data.
GET {{ SITE_ROOT }}/api/v1/checks/

- Returns a list of checks. This API call takes no parameters and returns - a JSON document with all checks in user's account. + Returns a list of checks. This API call takes only optional tag querystring parameter to filter checks by their tags. + If no parameter provided it returns a JSON document with all checks in user's account.

Example Request

{% include "front/snippets/list_checks_request.html" %} @@ -70,6 +70,12 @@ The response may contain a JSON document with additional data.

Example Response

{% include "front/snippets/list_checks_response.html" %} +

Example Request To Filter Checks By Their Tags

+{% include "front/snippets/list_checks_request_filtered.html" %} + +

Example Response Of Filtered Checks

+{% include "front/snippets/list_checks_response_filtered.html" %} + diff --git a/templates/front/snippets/list_checks_request_filtered.html b/templates/front/snippets/list_checks_request_filtered.html new file mode 100644 index 00000000..a604acf6 --- /dev/null +++ b/templates/front/snippets/list_checks_request_filtered.html @@ -0,0 +1,2 @@ +
curl --header "X-Api-Key: your-api-key" {{ SITE_ROOT }}/api/v1/checks/?tag=bar&tag=baz
+
diff --git a/templates/front/snippets/list_checks_request_filtered.txt b/templates/front/snippets/list_checks_request_filtered.txt new file mode 100644 index 00000000..b393688d --- /dev/null +++ b/templates/front/snippets/list_checks_request_filtered.txt @@ -0,0 +1 @@ +curl --header "X-Api-Key: your-api-key" SITE_ROOT/api/v1/checks/?tag=bar&tag=baz \ No newline at end of file diff --git a/templates/front/snippets/list_checks_response_filtered.html b/templates/front/snippets/list_checks_response_filtered.html new file mode 100644 index 00000000..530c1c7e --- /dev/null +++ b/templates/front/snippets/list_checks_response_filtered.html @@ -0,0 +1,19 @@ +
{
+  "checks": [
+    {
+      "last_ping": null,
+      "ping_url": "{{ PING_ENDPOINT }}9d17c61f-5c4f-4cab-b517-11e6b2679ced",
+      "next_ping": null,
+      "grace": 3600,
+      "name": "Api test 2",
+      "n_pings": 0,
+      "tags": "bar baz",
+      "pause_url": "{{ SITE_ROOT }}/api/v1/checks/9d17c61f-5c4f-4cab-b517-11e6b2679ced/pause",
+      "tz": "UTC",
+      "schedule": "0/10 * * * *",
+      "status": "new",
+      "update_url": "{{ SITE_ROOT }}/api/v1/checks/9d17c61f-5c4f-4cab-b517-11e6b2679ced"
+    }
+  ]
+}
+
diff --git a/templates/front/snippets/list_checks_response_filtered.txt b/templates/front/snippets/list_checks_response_filtered.txt new file mode 100644 index 00000000..870cfc1f --- /dev/null +++ b/templates/front/snippets/list_checks_response_filtered.txt @@ -0,0 +1,18 @@ +{ + "checks": [ + { + "last_ping": null, + "ping_url": "PING_ENDPOINT9d17c61f-5c4f-4cab-b517-11e6b2679ced", + "next_ping": null, + "grace": 3600, + "name": "Api test 2", + "n_pings": 0, + "tags": "bar baz", + "pause_url": "SITE_ROOT/api/v1/checks/9d17c61f-5c4f-4cab-b517-11e6b2679ced/pause", + "tz": "UTC", + "schedule": "0/10 * * * *", + "status": "new", + "update_url": "SITE_ROOT/api/v1/checks/9d17c61f-5c4f-4cab-b517-11e6b2679ced" + } + ] +} \ No newline at end of file