Browse Source

Add the "desc" field (check's description) to API responses

pull/194/head
Pēteris Caune 6 years ago
parent
commit
5cbd99cb5c
No known key found for this signature in database GPG Key ID: E28D7679E9A9EDE2
9 changed files with 23 additions and 4 deletions
  1. +6
    -0
      CHANGELOG.md
  2. +2
    -1
      hc/api/models.py
  3. +2
    -0
      hc/api/tests/test_list_checks.py
  4. +1
    -0
      templates/front/snippets/create_check_response.html
  5. +1
    -0
      templates/front/snippets/create_check_response.txt
  6. +4
    -2
      templates/front/snippets/list_checks_response.html
  7. +3
    -1
      templates/front/snippets/list_checks_response.txt
  8. +2
    -0
      templates/front/snippets/pause_check_response.html
  9. +2
    -0
      templates/front/snippets/pause_check_response.txt

+ 6
- 0
CHANGELOG.md View File

@ -1,6 +1,12 @@
# Changelog
All notable changes to this project will be documented in this file.
## Unreleased
### Improvements
- Add the "desc" field (check's description) to API responses
## 1.5.0 - 2019-02-04
### Improvements


+ 2
- 1
hc/api/models.py View File

@ -193,7 +193,8 @@ class Check(models.Model):
"status": self.get_status(),
"channels": ",".join(sorted(channel_codes)),
"last_ping": isostring(self.last_ping),
"next_ping": isostring(self.get_grace_start())
"next_ping": isostring(self.get_grace_start()),
"desc": self.desc
}
if self.kind == "simple":


+ 2
- 0
hc/api/tests/test_list_checks.py View File

@ -20,6 +20,7 @@ class ListChecksTestCase(BaseTestCase):
self.a1.n_pings = 0
self.a1.status = "new"
self.a1.tags = "a1-tag a1-additional-tag"
self.a1.desc = "This is description"
self.a1.save()
self.a2 = Check(project=self.project, name="Alice 2")
@ -56,6 +57,7 @@ class ListChecksTestCase(BaseTestCase):
self.assertEqual(a1["n_pings"], 0)
self.assertEqual(a1["status"], "new")
self.assertEqual(a1["channels"], str(self.c1.code))
self.assertEqual(a1["desc"], "This is description")
update_url = settings.SITE_ROOT + "/api/v1/checks/%s" % self.a1.code
pause_url = update_url + "/pause"


+ 1
- 0
templates/front/snippets/create_check_response.html View File

@ -1,5 +1,6 @@
<div class="highlight"><pre><span></span><span class="p">{</span>
<span class="nt">&quot;channels&quot;</span><span class="p">:</span> <span class="s2">&quot;&quot;</span><span class="p">,</span>
<span class="nt">&quot;desc&quot;</span><span class="p">:</span> <span class="s2">&quot;&quot;</span><span class="p">,</span>
<span class="nt">&quot;grace&quot;</span><span class="p">:</span> <span class="mi">60</span><span class="p">,</span>
<span class="nt">&quot;last_ping&quot;</span><span class="p">:</span> <span class="kc">null</span><span class="p">,</span>
<span class="nt">&quot;n_pings&quot;</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span>


+ 1
- 0
templates/front/snippets/create_check_response.txt View File

@ -1,5 +1,6 @@
{
"channels": "",
"desc": "",
"grace": 60,
"last_ping": null,
"n_pings": 0,


+ 4
- 2
templates/front/snippets/list_checks_response.html View File

@ -1,8 +1,9 @@
<div class="highlight"><pre><span></span><span class="p">{</span>
<span class="nt">&quot;checks&quot;</span><span class="p">:</span> <span class="p">[</span>
<span class="p">{</span>
<span class="nt">&quot;channels&quot;</span><span class="p">:</span> <span class="s2">&quot;4ec5a071-2d08-4baa-898a-eb4eb3cd6941,746a083e-f542-4554-be1a-707ce16d3acc&quot;</span>
<span class="s2">&quot;grace&quot;</span><span class="p">:</span> <span class="mi">900</span><span class="p">,</span>
<span class="nt">&quot;channels&quot;</span><span class="p">:</span> <span class="s2">&quot;4ec5a071-2d08-4baa-898a-eb4eb3cd6941,746a083e-f542-4554-be1a-707ce16d3acc&quot;</span><span class="p">,</span>
<span class="nt">&quot;desc&quot;</span><span class="p">:</span> <span class="s2">&quot;Longer free-form description goes here&quot;</span><span class="p">,</span>
<span class="nt">&quot;grace&quot;</span><span class="p">:</span> <span class="mi">900</span><span class="p">,</span>
<span class="nt">&quot;last_ping&quot;</span><span class="p">:</span> <span class="s2">&quot;2017-01-04T13:24:39.903464+00:00&quot;</span><span class="p">,</span>
<span class="nt">&quot;n_pings&quot;</span><span class="p">:</span> <span class="mi">1</span><span class="p">,</span>
<span class="nt">&quot;name&quot;</span><span class="p">:</span> <span class="s2">&quot;Api test 1&quot;</span><span class="p">,</span>
@ -16,6 +17,7 @@
<span class="p">},</span>
<span class="p">{</span>
<span class="nt">&quot;channels&quot;</span><span class="p">:</span> <span class="s2">&quot;&quot;</span><span class="p">,</span>
<span class="nt">&quot;desc&quot;</span><span class="p">:</span> <span class="s2">&quot;&quot;</span><span class="p">,</span>
<span class="nt">&quot;grace&quot;</span><span class="p">:</span> <span class="mi">3600</span><span class="p">,</span>
<span class="nt">&quot;last_ping&quot;</span><span class="p">:</span> <span class="kc">null</span><span class="p">,</span>
<span class="nt">&quot;n_pings&quot;</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span>


+ 3
- 1
templates/front/snippets/list_checks_response.txt View File

@ -1,7 +1,8 @@
{
"checks": [
{
"channels": "4ec5a071-2d08-4baa-898a-eb4eb3cd6941,746a083e-f542-4554-be1a-707ce16d3acc"
"channels": "4ec5a071-2d08-4baa-898a-eb4eb3cd6941,746a083e-f542-4554-be1a-707ce16d3acc",
"desc": "Longer free-form description goes here",
"grace": 900,
"last_ping": "2017-01-04T13:24:39.903464+00:00",
"n_pings": 1,
@ -16,6 +17,7 @@
},
{
"channels": "",
"desc": "",
"grace": 3600,
"last_ping": null,
"n_pings": 0,


+ 2
- 0
templates/front/snippets/pause_check_response.html View File

@ -1,4 +1,6 @@
<div class="highlight"><pre><span></span><span class="p">{</span>
<span class="nt">&quot;channels&quot;</span><span class="p">:</span> <span class="s2">&quot;&quot;</span><span class="p">,</span>
<span class="nt">&quot;desc&quot;</span><span class="p">:</span> <span class="s2">&quot;&quot;</span><span class="p">,</span>
<span class="nt">&quot;grace&quot;</span><span class="p">:</span> <span class="mi">60</span><span class="p">,</span>
<span class="nt">&quot;last_ping&quot;</span><span class="p">:</span> <span class="kc">null</span><span class="p">,</span>
<span class="nt">&quot;n_pings&quot;</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span>


+ 2
- 0
templates/front/snippets/pause_check_response.txt View File

@ -1,4 +1,6 @@
{
"channels": "",
"desc": "",
"grace": 60,
"last_ping": null,
"n_pings": 0,


Loading…
Cancel
Save