Browse Source

Minor cleanup, update CHANGELOG

pull/358/head
Pēteris Caune 5 years ago
parent
commit
da4cf5241e
No known key found for this signature in database GPG Key ID: E28D7679E9A9EDE2
6 changed files with 21 additions and 18 deletions
  1. +1
    -0
      CHANGELOG.md
  2. +1
    -2
      hc/api/tests/test_get_check.py
  3. +1
    -9
      hc/api/views.py
  4. +7
    -3
      templates/docs/api.html
  5. +10
    -3
      templates/docs/api.md
  6. +1
    -1
      templates/docs/cloning_checks.html

+ 1
- 0
CHANGELOG.md View File

@ -12,6 +12,7 @@ All notable changes to this project will be documented in this file.
- Zulip integration (#202)
- OpsGenie integration returns more detailed error messages
- Telegram integration returns more detailed error messages
- Added the "Get a single check" API call (#337)
### Bug Fixes
- The "render_docs" command checks if markdown and pygments is installed (#329)


+ 1
- 2
hc/api/tests/test_get_check.py View File

@ -1,5 +1,4 @@
from datetime import timedelta as td
import uuid
from django.utils.timezone import now
from hc.api.models import Channel, Check
@ -52,4 +51,4 @@ class GetCheckTestCase(BaseTestCase):
def test_it_handles_missing_check(self):
made_up_code = "07c2f548-9850-4b27-af5d-6c9dc157ec02"
r = self.get(made_up_code)
self.assertEqual(r.status_code, 404)
self.assertEqual(r.status_code, 404)

+ 1
- 9
hc/api/views.py View File

@ -191,7 +191,7 @@ def single(request, code):
try:
validate(request.json, schemas.check)
_update(check, request.json)
except (BadChannelException,ValidationError) as e:
except (BadChannelException, ValidationError) as e:
return JsonResponse({"error": str(e)}, status=400)
return JsonResponse(check.to_dict())
@ -208,14 +208,6 @@ def single(request, code):
return HttpResponse(status=405)
@csrf_exempt
@cors("POST", "DELETE")
@validate_json(schemas.check)
@authorize
def update(request, code):
single(request, code)
@cors("POST")
@csrf_exempt
@validate_json()


+ 7
- 3
templates/docs/api.html View File

@ -15,7 +15,7 @@ checks in user's account.</p>
<td><code>GET SITE_ROOT/api/v1/checks/</code></td>
</tr>
<tr>
<td><a href="#get-check">Create a single check</a></td>
<td><a href="#get-check">Get a single check</a></td>
<td><code>GET SITE_ROOT/api/v1/checks/&lt;uuid&gt;</code></td>
</tr>
<tr>
@ -178,15 +178,19 @@ is added. This identifier is stable across API calls. Example:</p>
</code></pre></div>
<h2 class="rule" id="get-check">Get a single Check</h2>
<h2 class="rule" id="get-check">Get a Single Check</h2>
<p><code>GET SITE_ROOT/api/v1/checks/&lt;uuid&gt;</code></p>
<p>Returns a JSON object containing information information from a single check.</p>
<p>Returns a JSON representation of a single check.</p>
<h3>Response Codes</h3>
<dl>
<dt>200 OK</dt>
<dd>The request succeeded.</dd>
<dt>401 Unauthorized</dt>
<dd>The API key is either missing or invalid.</dd>
<dt>403 Forbidden</dt>
<dd>Access denied, wrong API key.</dd>
<dt>404 Not Found</dt>
<dd>The specified check does not exist.</dd>
</dl>
<h3>Example Request</h3>
<div class="highlight"><pre><span></span><code>curl --header <span class="s2">&quot;X-Api-Key: your-api-key&quot;</span> SITE_ROOT/api/v1/checks/&lt;uuid&gt;


+ 10
- 3
templates/docs/api.md View File

@ -8,7 +8,7 @@ checks in user's account.
Endpoint Name | Endpoint Address
------------------------------------------------------|-------
[Get a list of existing checks](#list-checks) | `GET SITE_ROOT/api/v1/checks/`
[Create a single check](#get-check) | `GET SITE_ROOT/api/v1/checks/<uuid>`
[Get a single check](#get-check) | `GET SITE_ROOT/api/v1/checks/<uuid>`
[Create a new check](#create-check) | `POST SITE_ROOT/api/v1/checks/`
[Update an existing check](#update-check) | `POST SITE_ROOT/api/v1/checks/<uuid>`
[Pause monitoring of a check](#pause-check) | `POST SITE_ROOT/api/v1/checks/<uuid>/pause`
@ -158,10 +158,10 @@ is added. This identifier is stable across API calls. Example:
}
```
## Get a single Check {: #get-check .rule }
## Get a Single Check {: #get-check .rule }
`GET SITE_ROOT/api/v1/checks/<uuid>`
Returns a JSON object containing information information from a single check.
Returns a JSON representation of a single check.
### Response Codes
@ -171,6 +171,13 @@ Returns a JSON object containing information information from a single check.
401 Unauthorized
: The API key is either missing or invalid.
403 Forbidden
: Access denied, wrong API key.
404 Not Found
: The specified check does not exist.
### Example Request
```bash


+ 1
- 1
templates/docs/cloning_checks.html View File

@ -1,5 +1,5 @@
<h1>Cloning Checks</h1>
<p>You can individually clone individual checks SITE_NAME from the "Check Details"
<p>You can clone individual checks from the "Check Details"
page:</p>
<p><img alt="The &quot;Create a Copy&quot; button" src="IMG_URL/create_copy.png" /></p>
<p>The "Create a Copy..." function creates a new check in the same project, and copies


Loading…
Cancel
Save