From 1b3d7e8c0ad3e98c94dd272b324c61cac9ab03a7 Mon Sep 17 00:00:00 2001 From: Bram Daams Date: Tue, 17 Dec 2019 15:47:13 +0100 Subject: [PATCH] being able to set/update the description of a check when creating/updating using the api --- hc/api/tests/test_update_check.py | 2 ++ hc/api/views.py | 3 +++ templates/front/docs_api.html | 14 ++++++++++++++ 3 files changed, 19 insertions(+) diff --git a/hc/api/tests/test_update_check.py b/hc/api/tests/test_update_check.py index 40004e45..c6d78cc3 100644 --- a/hc/api/tests/test_update_check.py +++ b/hc/api/tests/test_update_check.py @@ -20,6 +20,7 @@ class UpdateCheckTestCase(BaseTestCase): "api_key": "X" * 32, "name": "Foo", "tags": "bar,baz", + "desc": "My description", "timeout": 3600, "grace": 60, }, @@ -32,6 +33,7 @@ class UpdateCheckTestCase(BaseTestCase): assert "ping_url" in doc self.assertEqual(doc["name"], "Foo") self.assertEqual(doc["tags"], "bar,baz") + self.assertEqual(doc["desc"], "My description") self.assertEqual(doc["last_ping"], None) self.assertEqual(doc["n_pings"], 0) diff --git a/hc/api/views.py b/hc/api/views.py index 6a9b2cbb..2e7a9830 100644 --- a/hc/api/views.py +++ b/hc/api/views.py @@ -70,6 +70,9 @@ def _update(check, spec): if "tags" in spec: check.tags = spec["tags"] + if "desc" in spec: + check.desc = spec["desc"] + if "timeout" in spec and "schedule" not in spec: check.kind = "simple" check.timeout = td(seconds=spec["timeout"]) diff --git a/templates/front/docs_api.html b/templates/front/docs_api.html index c2db1f80..bb147283 100644 --- a/templates/front/docs_api.html +++ b/templates/front/docs_api.html @@ -186,6 +186,13 @@ To create a "cron" check, specify the "schedule" and "tz" parameters.
{"tags": "reports staging"}
+ + desc + +

string, optional.

+

Description for the check.

+ + timeout @@ -328,6 +335,13 @@ To create a "cron" check, specify the "schedule" and "tz" parameters.
{"tags": "reports staging"}
+ + desc + +

string, optional.

+

Description for the check.

+ + timeout