diff --git a/hc/front/management/commands/pygmentize.py b/hc/front/management/commands/pygmentize.py index 59a4e717..9f8ce124 100644 --- a/hc/front/management/commands/pygmentize.py +++ b/hc/front/management/commands/pygmentize.py @@ -47,6 +47,7 @@ class Command(BaseCommand): # API examples _process("list_checks_request", lexers.BashLexer()) _process("list_checks_response", lexers.JsonLexer()) + _process("list_checks_response_readonly", lexers.JsonLexer()) _process("list_channels_request", lexers.BashLexer()) _process("list_channels_response", lexers.JsonLexer()) _process("create_check_request_a", lexers.BashLexer()) diff --git a/templates/front/docs_api.html b/templates/front/docs_api.html index 80b4fb02..c2db1f80 100644 --- a/templates/front/docs_api.html +++ b/templates/front/docs_api.html @@ -56,11 +56,25 @@

Authentication

Your requests to {% site_name %} REST API must authenticate using an -API key. By default, an user account on {% site_name %} doesn't have -an API key. You can create read-write and read-only API keys -in the Project Settings page. +API key. Each project in your {% site_name %} account has separate API keys. +There are no account-wide API keys. By default, a project on {% site_name %} doesn't have +an API key. You can create read-write and read-only API keys in the +Project Settings page.

+ + + + + + + + + +
Regular API keysHave full access to all documented API endpoints.
Read-only API keysOnly work with the + Get a list of existing checks + endpoint. Some fields are omitted from the API responses.
+

The client can authenticate itself by sending an appropriate HTTP request header. The header's name should be X-Api-Key and its value should be your API key. @@ -126,6 +140,13 @@ one or more tags.

Example Response

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

When using the read-only API key, the following fields are omitted: + ping_url, update_url, pause_url, + channels. An extra unique_key field is added. + This identifier is stable across API calls. Example: +

+{% include "front/snippets/list_checks_response_readonly.html" %} + diff --git a/templates/front/snippets/list_checks_response_readonly.html b/templates/front/snippets/list_checks_response_readonly.html new file mode 100644 index 00000000..d123702e --- /dev/null +++ b/templates/front/snippets/list_checks_response_readonly.html @@ -0,0 +1,29 @@ +
{
+  "checks": [
+    {
+      "desc": "Longer free-form description goes here",
+      "grace": 900,
+      "last_ping": "2017-01-04T13:24:39.903464+00:00",
+      "n_pings": 1,
+      "name": "Api test 1",
+      "status": "up",
+      "tags": "foo",
+      "timeout": 3600,
+      "unique_key": "2872190d95224bad120f41d3c06aab94b8175bb6"
+    },
+    {
+      "desc": "",
+      "grace": 3600,
+      "last_ping": null,
+      "n_pings": 0,
+      "name": "Api test 2",
+      "next_ping": null,
+      "schedule": "0/10 * * * *",
+      "status": "new",
+      "tags": "bar baz",
+      "tz": "UTC",
+      "unique_key": "9b5fc29129560ff2c5c1803803a7415e4f80cf7e"
+    }
+  ]
+}
+
diff --git a/templates/front/snippets/list_checks_response_readonly.txt b/templates/front/snippets/list_checks_response_readonly.txt new file mode 100644 index 00000000..a6e43685 --- /dev/null +++ b/templates/front/snippets/list_checks_response_readonly.txt @@ -0,0 +1,28 @@ +{ + "checks": [ + { + "desc": "Longer free-form description goes here", + "grace": 900, + "last_ping": "2017-01-04T13:24:39.903464+00:00", + "n_pings": 1, + "name": "Api test 1", + "status": "up", + "tags": "foo", + "timeout": 3600, + "unique_key": "2872190d95224bad120f41d3c06aab94b8175bb6" + }, + { + "desc": "", + "grace": 3600, + "last_ping": null, + "n_pings": 0, + "name": "Api test 2", + "next_ping": null, + "schedule": "0/10 * * * *", + "status": "new", + "tags": "bar baz", + "tz": "UTC", + "unique_key": "9b5fc29129560ff2c5c1803803a7415e4f80cf7e" + } + ] +} \ No newline at end of file