mirror of
https://github.com/healthchecks/healthchecks.git
synced 2025-04-11 15:51:19 +00:00
API reference in Markdown
This commit is contained in:
parent
516143de8a
commit
dab0c4200e
39 changed files with 1070 additions and 830 deletions
CHANGELOG.md
hc/front
static/css
templates
docs
front
base_docs.htmldocs_api.htmldocs_single.html
snippets
create_check_request_a.htmlcreate_check_request_a.txtcreate_check_request_b.htmlcreate_check_request_b.txtcreate_check_response.htmlcreate_check_response.txtdelete_check_request.htmldelete_check_request.txtlist_channels_request.htmllist_channels_request.txtlist_channels_response.htmllist_channels_response.txtlist_checks_request.htmllist_checks_request.txtlist_checks_response.htmllist_checks_response.txtlist_checks_response_readonly.htmllist_checks_response_readonly.txtpause_check_request.htmlpause_check_request.txtpause_check_response.htmlpause_check_response.txtpython_requests_fail.htmlpython_requests_start.htmlupdate_check_request_a.htmlupdate_check_request_a.txtupdate_check_request_b.htmlupdate_check_request_b.txt
|
@ -7,6 +7,7 @@ All notable changes to this project will be documented in this file.
|
|||
- Improved UI to invite users from account's other projects (#258)
|
||||
- Experimental Prometheus metrics endpoint (#300)
|
||||
- Don't store user's current project in DB, put it explicitly in page URLs (#336)
|
||||
- API reference in Markdown
|
||||
|
||||
### Bug Fixes
|
||||
- The "render_docs" command checks if markdown and pygments is installed (#329)
|
||||
|
|
|
@ -44,18 +44,3 @@ class Command(BaseCommand):
|
|||
_process("powershell", lexers.shell.PowerShellLexer())
|
||||
_process("powershell_inline", lexers.shell.BashLexer())
|
||||
_process("ruby", lexers.RubyLexer())
|
||||
|
||||
# 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())
|
||||
_process("create_check_request_b", lexers.BashLexer())
|
||||
_process("update_check_request_a", lexers.BashLexer())
|
||||
_process("update_check_request_b", lexers.BashLexer())
|
||||
_process("create_check_response", lexers.JsonLexer())
|
||||
_process("pause_check_request", lexers.BashLexer())
|
||||
_process("pause_check_response", lexers.JsonLexer())
|
||||
_process("delete_check_request", lexers.BashLexer())
|
||||
|
|
|
@ -19,7 +19,7 @@ class Command(BaseCommand):
|
|||
self.stdout.write(f" pip install {e.name}\n\n")
|
||||
return
|
||||
|
||||
extensions = ["fenced_code", "codehilite", "tables"]
|
||||
extensions = ["fenced_code", "codehilite", "tables", "def_list", "attr_list"]
|
||||
ec = {"codehilite": {"css_class": "highlight"}}
|
||||
|
||||
docs_path = os.path.join(settings.BASE_DIR, "templates/docs")
|
||||
|
|
|
@ -91,7 +91,6 @@ urlpatterns = [
|
|||
path("integrations/", include(channel_urls)),
|
||||
path("projects/<uuid:code>/", include(project_urls)),
|
||||
path("docs/", views.serve_doc, name="hc-docs"),
|
||||
path("docs/api/", views.docs_api, name="hc-docs-api"),
|
||||
path("docs/cron/", views.docs_cron, name="hc-docs-cron"),
|
||||
path("docs/<slug:doc>/", views.serve_doc, name="hc-serve-doc"),
|
||||
]
|
||||
|
|
|
@ -278,6 +278,7 @@ def serve_doc(request, doc="introduction"):
|
|||
|
||||
content = open(path, "r", encoding="utf-8").read()
|
||||
content = content.replace("SITE_NAME", settings.SITE_NAME)
|
||||
content = content.replace("SITE_ROOT", settings.SITE_ROOT)
|
||||
content = content.replace("PING_URL", settings.PING_ENDPOINT + "your-uuid-here")
|
||||
content = content.replace("PING_ENDPOINT", settings.PING_ENDPOINT)
|
||||
content = content.replace("IMG_URL", os.path.join(settings.STATIC_URL, "img/docs"))
|
||||
|
@ -296,19 +297,6 @@ def serve_doc(request, doc="introduction"):
|
|||
return render(request, "front/docs_single.html", ctx)
|
||||
|
||||
|
||||
def docs_api(request):
|
||||
ctx = {
|
||||
"page": "docs",
|
||||
"section": "api",
|
||||
"SITE_ROOT": settings.SITE_ROOT,
|
||||
"PING_ENDPOINT": settings.PING_ENDPOINT,
|
||||
"default_timeout": int(DEFAULT_TIMEOUT.total_seconds()),
|
||||
"default_grace": int(DEFAULT_GRACE.total_seconds()),
|
||||
}
|
||||
|
||||
return render(request, "front/docs_api.html", ctx)
|
||||
|
||||
|
||||
def docs_cron(request):
|
||||
return render(request, "front/docs_cron.html", {})
|
||||
|
||||
|
|
|
@ -35,46 +35,12 @@ li + li.nav-header {
|
|||
font-family: monospace;
|
||||
}
|
||||
|
||||
.docs-heading {
|
||||
margin-top: 40px;
|
||||
}
|
||||
|
||||
h2.rule {
|
||||
border-top: 3px solid #eee;
|
||||
margin-top: 30px;
|
||||
padding-top: 30px;
|
||||
}
|
||||
|
||||
h3.api-section {
|
||||
font-size: 14px;
|
||||
font-weight: bold;
|
||||
margin: 20px 0;
|
||||
}
|
||||
|
||||
h3.docs-example {
|
||||
margin-top: 40px;
|
||||
}
|
||||
|
||||
.api-path {
|
||||
font-family: monospace;
|
||||
font-weight: bold;
|
||||
margin-bottom: 1em;
|
||||
background: #f5f5f5;
|
||||
color: #333;
|
||||
display: inline-block;
|
||||
padding: 2px 4px;
|
||||
border-radius: 2px;
|
||||
}
|
||||
|
||||
a.section {
|
||||
color: #000;
|
||||
text-decoration: none;
|
||||
}
|
||||
|
||||
a.section:hover {
|
||||
text-decoration: none;
|
||||
}
|
||||
|
||||
.page-docs code {
|
||||
padding: 2px 4px;
|
||||
font-size: 90%;
|
||||
|
@ -105,6 +71,12 @@ a.section:hover {
|
|||
font-weight: bold;
|
||||
}
|
||||
|
||||
.docs-content h3 {
|
||||
font-size: 14px;
|
||||
font-weight: bold;
|
||||
margin: 20px 0;
|
||||
}
|
||||
|
||||
.docs-content ul {
|
||||
padding-left: 15px;
|
||||
}
|
||||
|
@ -124,3 +96,39 @@ a.section:hover {
|
|||
max-width: 100%;
|
||||
}
|
||||
}
|
||||
|
||||
.docs-api table {
|
||||
width: 100%;
|
||||
margin: 8px 0;
|
||||
}
|
||||
|
||||
.docs-api th {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.docs-api td {
|
||||
padding: 8px;
|
||||
border: 1px solid #ddd;
|
||||
}
|
||||
|
||||
|
||||
.docs-api dl {
|
||||
display: grid;
|
||||
grid-template-columns: 120px auto;
|
||||
}
|
||||
|
||||
.docs-api dt {
|
||||
font-weight: normal;
|
||||
font-family: "Lucida Console", Monaco, monospace;
|
||||
}
|
||||
|
||||
.docs-api dt, .docs-api dd {
|
||||
border-top: 1px solid #DDD;
|
||||
padding: 8px 0;
|
||||
}
|
||||
|
||||
.rule + p code {
|
||||
font-size: 14px;
|
||||
font-weight: bold;
|
||||
padding: 2px 4px;
|
||||
}
|
||||
|
|
487
templates/docs/api.html
Normal file
487
templates/docs/api.html
Normal file
|
@ -0,0 +1,487 @@
|
|||
<h1>API Reference</h1>
|
||||
<p>SITE_NAME REST API supports listing, creating, updating, pausing and deleting
|
||||
checks in user's account.</p>
|
||||
<h2>API Endpoints</h2>
|
||||
<table>
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Endpoint Name</th>
|
||||
<th>Endpoint Address</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr>
|
||||
<td><a href="#list-checks">Get a list of existing checks</a></td>
|
||||
<td><code>GET SITE_ROOT/api/v1/checks/</code></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><a href="#create-check">Create a new check</a></td>
|
||||
<td><code>POST SITE_ROOT/api/v1/checks/</code></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><a href="#update-check">Update an existing check</a></td>
|
||||
<td><code>POST SITE_ROOT/api/v1/checks/<uuid></code></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><a href="#pause-check">Pause monitoring of a check</a></td>
|
||||
<td><code>POST SITE_ROOT/api/v1/checks/<uuid>/pause</code></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><a href="#delete-check">Delete check</a></td>
|
||||
<td><code>DELETE SITE_ROOT/api/v1/checks/<uuid></code></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><a href="#list-channels">Get a list of existing integrations</a></td>
|
||||
<td><code>GET SITE_ROOT/api/v1/channels/</code></td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
<h2>Authentication</h2>
|
||||
<p>Your requests to SITE_NAME REST API must authenticate using an
|
||||
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
|
||||
<strong>Project Settings</strong> page.</p>
|
||||
<table>
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Key Type</th>
|
||||
<th>Description</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr>
|
||||
<td>Regular API key</td>
|
||||
<td>Have full access to all documented API endpoints.</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Read-only API key</td>
|
||||
<td>Only work with the <a href="#list-checks">Get a list of existing checks</a> endpoint. Some fields are omitted from the API responses.</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
<p>The client can authenticate itself by sending an appropriate HTTP
|
||||
request header. The header's name should be <code>X-Api-Key</code> and
|
||||
its value should be your API key.</p>
|
||||
<p>Alternatively, for POST requests with a JSON request body,
|
||||
the client can include an <code>api_key</code> field in the JSON document.
|
||||
See below the "Create a check" section for an example.</p>
|
||||
<h2>API Requests</h2>
|
||||
<p>For POST requests, the SITE_NAME API expects request body to be
|
||||
a JSON document (<em>not</em> a <code>multipart/form-data</code> encoded form data).</p>
|
||||
<h2>API Responses</h2>
|
||||
<p>SITE_NAME uses HTTP status codes wherever possible.
|
||||
In general, 2xx class indicates success, 4xx indicates an client error,
|
||||
and 5xx indicates a server error.</p>
|
||||
<p>The response may contain a JSON document with additional data.</p>
|
||||
<h2 class="rule" id="list-checks">Get a List of Existing Checks</h2>
|
||||
<p><code>GET SITE_ROOT/api/v1/checks/</code></p>
|
||||
<p>Returns a list of checks belonging to the user, optionally filtered by
|
||||
one or more tags.</p>
|
||||
<h3>Query String Parameters</h3>
|
||||
<dl>
|
||||
<dt>tag=<value></dt>
|
||||
<dd>
|
||||
<p>Filters the checks, and returns only the checks that are tagged with the
|
||||
specified value.</p>
|
||||
<p>This parameter can be repeated multiple times.</p>
|
||||
<p>Example:</p>
|
||||
<p><code>SITE_ROOT/api/v1/checks/?tag=foo&amp;tag=bar</code></p>
|
||||
</dd>
|
||||
</dl>
|
||||
<h3>Example Request</h3>
|
||||
<div class="highlight"><pre><span></span><code>curl --header <span class="s2">"X-Api-Key: your-api-key"</span> SITE_ROOT/api/v1/checks/
|
||||
</code></pre></div>
|
||||
|
||||
|
||||
<h3>Example Response</h3>
|
||||
<div class="highlight"><pre><span></span><code><span class="p">{</span>
|
||||
<span class="nt">"checks"</span><span class="p">:</span> <span class="p">[</span>
|
||||
<span class="p">{</span>
|
||||
<span class="nt">"channels"</span><span class="p">:</span> <span class="s2">"4ec5a071-2d08-4baa-898a-eb4eb3cd6941,746a083e-f542-4554-be1a-707ce16d3acc"</span><span class="p">,</span>
|
||||
<span class="nt">"desc"</span><span class="p">:</span> <span class="s2">"Longer free-form description goes here"</span><span class="p">,</span>
|
||||
<span class="nt">"grace"</span><span class="p">:</span> <span class="mi">900</span><span class="p">,</span>
|
||||
<span class="nt">"last_ping"</span><span class="p">:</span> <span class="s2">"2017-01-04T13:24:39.903464+00:00"</span><span class="p">,</span>
|
||||
<span class="nt">"n_pings"</span><span class="p">:</span> <span class="mi">1</span><span class="p">,</span>
|
||||
<span class="nt">"name"</span><span class="p">:</span> <span class="s2">"Api test 1"</span><span class="p">,</span>
|
||||
<span class="nt">"next_ping"</span><span class="p">:</span> <span class="s2">"2017-01-04T14:24:39.903464+00:00"</span><span class="p">,</span>
|
||||
<span class="nt">"pause_url"</span><span class="p">:</span> <span class="s2">"SITE_ROOT/api/v1/checks/662ebe36-ecab-48db-afe3-e20029cb71e6/pause"</span><span class="p">,</span>
|
||||
<span class="nt">"ping_url"</span><span class="p">:</span> <span class="s2">"PING_ENDPOINT662ebe36-ecab-48db-afe3-e20029cb71e6"</span><span class="p">,</span>
|
||||
<span class="nt">"status"</span><span class="p">:</span> <span class="s2">"up"</span><span class="p">,</span>
|
||||
<span class="nt">"tags"</span><span class="p">:</span> <span class="s2">"foo"</span><span class="p">,</span>
|
||||
<span class="nt">"timeout"</span><span class="p">:</span> <span class="mi">3600</span><span class="p">,</span>
|
||||
<span class="nt">"update_url"</span><span class="p">:</span> <span class="s2">"SITE_ROOT/api/v1/checks/662ebe36-ecab-48db-afe3-e20029cb71e6"</span>
|
||||
<span class="p">},</span>
|
||||
<span class="p">{</span>
|
||||
<span class="nt">"channels"</span><span class="p">:</span> <span class="s2">""</span><span class="p">,</span>
|
||||
<span class="nt">"desc"</span><span class="p">:</span> <span class="s2">""</span><span class="p">,</span>
|
||||
<span class="nt">"grace"</span><span class="p">:</span> <span class="mi">3600</span><span class="p">,</span>
|
||||
<span class="nt">"last_ping"</span><span class="p">:</span> <span class="kc">null</span><span class="p">,</span>
|
||||
<span class="nt">"n_pings"</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span>
|
||||
<span class="nt">"name"</span><span class="p">:</span> <span class="s2">"Api test 2"</span><span class="p">,</span>
|
||||
<span class="nt">"next_ping"</span><span class="p">:</span> <span class="kc">null</span><span class="p">,</span>
|
||||
<span class="nt">"pause_url"</span><span class="p">:</span> <span class="s2">"SITE_ROOT/api/v1/checks/9d17c61f-5c4f-4cab-b517-11e6b2679ced/pause"</span><span class="p">,</span>
|
||||
<span class="nt">"ping_url"</span><span class="p">:</span> <span class="s2">"PING_ENDPOINT9d17c61f-5c4f-4cab-b517-11e6b2679ced"</span><span class="p">,</span>
|
||||
<span class="nt">"schedule"</span><span class="p">:</span> <span class="s2">"0/10 * * * *"</span><span class="p">,</span>
|
||||
<span class="nt">"status"</span><span class="p">:</span> <span class="s2">"new"</span><span class="p">,</span>
|
||||
<span class="nt">"tags"</span><span class="p">:</span> <span class="s2">"bar baz"</span><span class="p">,</span>
|
||||
<span class="nt">"tz"</span><span class="p">:</span> <span class="s2">"UTC"</span><span class="p">,</span>
|
||||
<span class="nt">"update_url"</span><span class="p">:</span> <span class="s2">"SITE_ROOT/api/v1/checks/9d17c61f-5c4f-4cab-b517-11e6b2679ced"</span>
|
||||
<span class="p">}</span>
|
||||
<span class="p">]</span>
|
||||
<span class="p">}</span>
|
||||
</code></pre></div>
|
||||
|
||||
|
||||
<p>When using the read-only API key, the following fields are omitted:
|
||||
<code>ping_url</code>, <code>update_url</code>, <code>pause_url</code>, <code>channels</code>. An extra <code>unique_key</code> field
|
||||
is added. This identifier is stable across API calls. Example:</p>
|
||||
<div class="highlight"><pre><span></span><code><span class="p">{</span>
|
||||
<span class="nt">"checks"</span><span class="p">:</span> <span class="p">[</span>
|
||||
<span class="p">{</span>
|
||||
<span class="nt">"desc"</span><span class="p">:</span> <span class="s2">"Longer free-form description goes here"</span><span class="p">,</span>
|
||||
<span class="nt">"grace"</span><span class="p">:</span> <span class="mi">900</span><span class="p">,</span>
|
||||
<span class="nt">"last_ping"</span><span class="p">:</span> <span class="s2">"2017-01-04T13:24:39.903464+00:00"</span><span class="p">,</span>
|
||||
<span class="nt">"n_pings"</span><span class="p">:</span> <span class="mi">1</span><span class="p">,</span>
|
||||
<span class="nt">"name"</span><span class="p">:</span> <span class="s2">"Api test 1"</span><span class="p">,</span>
|
||||
<span class="nt">"status"</span><span class="p">:</span> <span class="s2">"up"</span><span class="p">,</span>
|
||||
<span class="nt">"tags"</span><span class="p">:</span> <span class="s2">"foo"</span><span class="p">,</span>
|
||||
<span class="nt">"timeout"</span><span class="p">:</span> <span class="mi">3600</span><span class="p">,</span>
|
||||
<span class="nt">"unique_key"</span><span class="p">:</span> <span class="s2">"2872190d95224bad120f41d3c06aab94b8175bb6"</span>
|
||||
<span class="p">},</span>
|
||||
<span class="p">{</span>
|
||||
<span class="nt">"desc"</span><span class="p">:</span> <span class="s2">""</span><span class="p">,</span>
|
||||
<span class="nt">"grace"</span><span class="p">:</span> <span class="mi">3600</span><span class="p">,</span>
|
||||
<span class="nt">"last_ping"</span><span class="p">:</span> <span class="kc">null</span><span class="p">,</span>
|
||||
<span class="nt">"n_pings"</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span>
|
||||
<span class="nt">"name"</span><span class="p">:</span> <span class="s2">"Api test 2"</span><span class="p">,</span>
|
||||
<span class="nt">"next_ping"</span><span class="p">:</span> <span class="kc">null</span><span class="p">,</span>
|
||||
<span class="nt">"schedule"</span><span class="p">:</span> <span class="s2">"0/10 * * * *"</span><span class="p">,</span>
|
||||
<span class="nt">"status"</span><span class="p">:</span> <span class="s2">"new"</span><span class="p">,</span>
|
||||
<span class="nt">"tags"</span><span class="p">:</span> <span class="s2">"bar baz"</span><span class="p">,</span>
|
||||
<span class="nt">"tz"</span><span class="p">:</span> <span class="s2">"UTC"</span><span class="p">,</span>
|
||||
<span class="nt">"unique_key"</span><span class="p">:</span> <span class="s2">"9b5fc29129560ff2c5c1803803a7415e4f80cf7e"</span>
|
||||
<span class="p">}</span>
|
||||
<span class="p">]</span>
|
||||
<span class="p">}</span>
|
||||
</code></pre></div>
|
||||
|
||||
|
||||
<h2 class="rule" id="create-check">Create a Check</h2>
|
||||
<p><code>POST SITE_ROOT/api/v1/checks/</code></p>
|
||||
<p>Creates a new check and returns its ping URL.
|
||||
All request parameters are optional and will use their default
|
||||
values if omitted.</p>
|
||||
<p>This API call can be used to create both "simple" and "cron" checks.
|
||||
To create a "simple" check, specify the "timeout" parameter.
|
||||
To create a "cron" check, specify the "schedule" and "tz" parameters.</p>
|
||||
<h3>Request Parameters</h3>
|
||||
<dl>
|
||||
<dt>name</dt>
|
||||
<dd>
|
||||
<p>string, optional, default value: ""</p>
|
||||
<p>Name for the new check.</p>
|
||||
</dd>
|
||||
<dt>tags</dt>
|
||||
<dd>
|
||||
<p>string, optional, default value: ""</p>
|
||||
<p>A space-delimited list of tags for the new check.
|
||||
Example:</p>
|
||||
<p><pre>{"tags": "reports staging"}</pre></p>
|
||||
</dd>
|
||||
<dt>desc</dt>
|
||||
<dd>
|
||||
<p>string, optional.</p>
|
||||
<p>Description for the check.</p>
|
||||
</dd>
|
||||
<dt>timeout</dt>
|
||||
<dd>
|
||||
<p>number, optional, default value: {{ default_timeout }}.</p>
|
||||
<p>A number of seconds, the expected period of this check.</p>
|
||||
<p>Minimum: 60 (one minute), maximum: 2592000 (30 days).</p>
|
||||
<p>Example for 5 minute timeout:</p>
|
||||
<p><pre>{"kind": "simple", "timeout": 300}</pre></p>
|
||||
</dd>
|
||||
<dt>grace</dt>
|
||||
<dd>
|
||||
<p>number, optional, default value: {{ default_grace }}.</p>
|
||||
<p>A number of seconds, the grace period for this check.</p>
|
||||
<p>Minimum: 60 (one minute), maximum: 2592000 (30 days).</p>
|
||||
</dd>
|
||||
<dt>schedule</dt>
|
||||
<dd>
|
||||
<p>string, optional, default value: "<em> * </em> * *".</p>
|
||||
<p>A cron expression defining this check's schedule.</p>
|
||||
<p>If you specify both "timeout" and "schedule" parameters, "timeout" will be
|
||||
ignored and "schedule" will be used.</p>
|
||||
<p>Example for a check running every half-hour:</p>
|
||||
<p><pre>{"schedule": "0,30 * <em> * </em>"}</pre></p>
|
||||
</dd>
|
||||
<dt>tz</dt>
|
||||
<dd>
|
||||
<p>string, optional, default value: "UTC".</p>
|
||||
<p>Server's timezone. This setting only has effect in combination with the
|
||||
"schedule" paremeter.</p>
|
||||
<p>Example:</p>
|
||||
<p><pre>{"tz": "Europe/Riga"}</pre></p>
|
||||
</dd>
|
||||
<dt>channels</dt>
|
||||
<dd>
|
||||
<p>string, optional</p>
|
||||
<p>By default, if a check is created through API, no notification channels
|
||||
(integrations) are assigned to it. So, when the check goes up or down, no
|
||||
notifications will get sent.</p>
|
||||
<p>Set this field to a special value "*" to automatically assign all existing
|
||||
integrations.</p>
|
||||
<p>To assign specific integrations, use a comma-separated list of integration
|
||||
identifiers. Use the <a href="#list-channels">Get a List of Existing Integrations</a> call to
|
||||
look up integration identifiers.</p>
|
||||
</dd>
|
||||
<dt>unique</dt>
|
||||
<dd>
|
||||
<p>array of string values, optional, default value: [].</p>
|
||||
<p>Before creating a check, look for existing checks, filtered by fields listed
|
||||
in <code>unique</code>. If a matching check is found, return it with HTTP status code 200.
|
||||
If no matching check is found, proceed as normal: create a check and return it
|
||||
with HTTP status code 201.</p>
|
||||
<p>The accepted values are: <code>name</code>, <code>tags</code>, <code>timeout</code> and <code>grace</code>.</p>
|
||||
<p>Example:</p>
|
||||
<p><pre>{"name": "Backups", unique: ["name"]}</pre></p>
|
||||
<p>In this example, if a check named "Backups" exists, it will be returned.
|
||||
Otherwise, a new check will be created and returned.</p>
|
||||
</dd>
|
||||
</dl>
|
||||
<h3>Response Codes</h3>
|
||||
<dl>
|
||||
<dt>201 Created</dt>
|
||||
<dd>Returned if the check was successfully created.</dd>
|
||||
<dt>200 OK</dt>
|
||||
<dd>Returned if the <code>unique</code> parameter was used and an existing check was matched.</dd>
|
||||
<dt>403 Forbidden</dt>
|
||||
<dd>Returned if the account's check limit has been reached. For free accounts,
|
||||
the limit is 20 checks per account.</dd>
|
||||
</dl>
|
||||
<h3>Example Request</h3>
|
||||
<div class="highlight"><pre><span></span><code>curl SITE_ROOT/api/v1/checks/ <span class="se">\</span>
|
||||
--header <span class="s2">"X-Api-Key: your-api-key"</span> <span class="se">\</span>
|
||||
--data <span class="s1">'{"name": "Backups", "tags": "prod www", "timeout": 3600, "grace": 60}'</span>
|
||||
</code></pre></div>
|
||||
|
||||
|
||||
<p>Or, alternatively:</p>
|
||||
<div class="highlight"><pre><span></span><code>curl SITE_ROOT/api/v1/checks/ <span class="se">\</span>
|
||||
--data <span class="s1">'{"api_key": "your-api-key", "name": "Backups", "tags": "prod www", "timeout": 3600, "grace": 60}'</span>
|
||||
</code></pre></div>
|
||||
|
||||
|
||||
<h3>Example Response</h3>
|
||||
<div class="highlight"><pre><span></span><code><span class="p">{</span>
|
||||
<span class="nt">"channels"</span><span class="p">:</span> <span class="s2">""</span><span class="p">,</span>
|
||||
<span class="nt">"desc"</span><span class="p">:</span> <span class="s2">""</span><span class="p">,</span>
|
||||
<span class="nt">"grace"</span><span class="p">:</span> <span class="mi">60</span><span class="p">,</span>
|
||||
<span class="nt">"last_ping"</span><span class="p">:</span> <span class="kc">null</span><span class="p">,</span>
|
||||
<span class="nt">"n_pings"</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span>
|
||||
<span class="nt">"name"</span><span class="p">:</span> <span class="s2">"Backups"</span><span class="p">,</span>
|
||||
<span class="nt">"next_ping"</span><span class="p">:</span> <span class="kc">null</span><span class="p">,</span>
|
||||
<span class="nt">"pause_url"</span><span class="p">:</span> <span class="s2">"SITE_ROOT/api/v1/checks/f618072a-7bde-4eee-af63-71a77c5723bc/pause"</span><span class="p">,</span>
|
||||
<span class="nt">"ping_url"</span><span class="p">:</span> <span class="s2">"PING_ENDPOINTf618072a-7bde-4eee-af63-71a77c5723bc"</span><span class="p">,</span>
|
||||
<span class="nt">"status"</span><span class="p">:</span> <span class="s2">"new"</span><span class="p">,</span>
|
||||
<span class="nt">"tags"</span><span class="p">:</span> <span class="s2">"prod www"</span><span class="p">,</span>
|
||||
<span class="nt">"timeout"</span><span class="p">:</span> <span class="mi">3600</span><span class="p">,</span>
|
||||
<span class="nt">"update_url"</span><span class="p">:</span> <span class="s2">"SITE_ROOT/api/v1/checks/f618072a-7bde-4eee-af63-71a77c5723bc"</span><span class="p">,</span>
|
||||
<span class="p">}</span>
|
||||
</code></pre></div>
|
||||
|
||||
|
||||
<h2 class="rule" id="update-check">Update an Existing Check</h2>
|
||||
<p><code>POST SITE_ROOT/api/v1/checks/<uuid></code></p>
|
||||
<p>Updates an existing check. All request parameters are optional. The check is
|
||||
updated only with the supplied request parameters. If any parameter is omitted,
|
||||
its value is left unchanged.</p>
|
||||
<h3>Request Parameters</h3>
|
||||
<dl>
|
||||
<dt>name</dt>
|
||||
<dd>
|
||||
<p>string, optional.</p>
|
||||
<p>Name for the check.</p>
|
||||
</dd>
|
||||
<dt>tags</dt>
|
||||
<dd>
|
||||
<p>string, optional.</p>
|
||||
<p>A space-delimited list of tags for the check.</p>
|
||||
<p>Example:</p>
|
||||
<p><pre>{"tags": "reports staging"}</pre></p>
|
||||
</dd>
|
||||
<dt>desc</dt>
|
||||
<dd>
|
||||
<p>string, optional.</p>
|
||||
<p>Description for the check.</p>
|
||||
</dd>
|
||||
<dt>timeout</dt>
|
||||
<dd>
|
||||
<p>number, optional.</p>
|
||||
<p>A number of seconds, the expected period of this check.</p>
|
||||
<p>Minimum: 60 (one minute), maximum: 2592000 (30 days).</p>
|
||||
<p>Example for 5 minute timeout:</p>
|
||||
<p><pre>{"kind": "simple", "timeout": 300}</pre></p>
|
||||
</dd>
|
||||
<dt>grace</dt>
|
||||
<dd>
|
||||
<p>number, optional.</p>
|
||||
<p>A number of seconds, the grace period for this check.</p>
|
||||
<p>Minimum: 60 (one minute), maximum: 2592000 (30 days).</p>
|
||||
</dd>
|
||||
<dt>schedule</dt>
|
||||
<dd>
|
||||
<p>string, optional.</p>
|
||||
<p>A cron expression defining this check's schedule.</p>
|
||||
<p>If you specify both "timeout" and "schedule" parameters, "timeout" will be
|
||||
ignored and "schedule" will be used.</p>
|
||||
<p>Example for a check running every half-hour:</p>
|
||||
<p><pre>{"schedule": "0,30 * <em> * </em>"}</pre></p>
|
||||
</dd>
|
||||
<dt>tz</dt>
|
||||
<dd>
|
||||
<p>string, optional.</p>
|
||||
<p>Server's timezone. This setting only has effect in combination with the
|
||||
"schedule" paremeter.</p>
|
||||
<p>Example:</p>
|
||||
<p><pre>{"tz": "Europe/Riga"}</pre></p>
|
||||
</dd>
|
||||
<dt>channels</dt>
|
||||
<dd>
|
||||
<p>string, optional.</p>
|
||||
<p>Set this field to a special value "*" to automatically assign all existing
|
||||
notification channels.</p>
|
||||
<p>Set this field to a special value "" (empty string) to automatically <em>unassign</em>
|
||||
all notification channels.</p>
|
||||
<p>Set this field to a comma-separated list of channel identifiers to assign
|
||||
specific notification channels.</p>
|
||||
<p>Example:</p>
|
||||
<p><pre>{"channels": "4ec5a071-2d08-4baa-898a-eb4eb3cd6941,746a083e-f542-4554-be1a-707ce16d3acc"}</pre></p>
|
||||
</dd>
|
||||
</dl>
|
||||
<h3>Response Codes</h3>
|
||||
<dl>
|
||||
<dt>200 OK</dt>
|
||||
<dd>Returned if the check was successfully updated.</dd>
|
||||
</dl>
|
||||
<h3>Example Request</h3>
|
||||
<div class="highlight"><pre><span></span><code>curl SITE_ROOT/api/v1/checks/f618072a-7bde-4eee-af63-71a77c5723bc <span class="se">\</span>
|
||||
--header <span class="s2">"X-Api-Key: your-api-key"</span> <span class="se">\</span>
|
||||
--data <span class="s1">'{"name": "Backups", "tags": "prod www", "timeout": 3600, "grace": 60}'</span>
|
||||
</code></pre></div>
|
||||
|
||||
|
||||
<p>Or, alternatively:</p>
|
||||
<div class="highlight"><pre><span></span><code>curl SITE_ROOT/api/v1/checks/f618072a-7bde-4eee-af63-71a77c5723bc <span class="se">\</span>
|
||||
--data <span class="s1">'{"api_key": "your-api-key", "name": "Backups", "tags": "prod www", "timeout": 3600, "grace": 60}'</span>
|
||||
</code></pre></div>
|
||||
|
||||
|
||||
<h3>Example Response</h3>
|
||||
<div class="highlight"><pre><span></span><code><span class="p">{</span>
|
||||
<span class="nt">"channels"</span><span class="p">:</span> <span class="s2">""</span><span class="p">,</span>
|
||||
<span class="nt">"desc"</span><span class="p">:</span> <span class="s2">""</span><span class="p">,</span>
|
||||
<span class="nt">"grace"</span><span class="p">:</span> <span class="mi">60</span><span class="p">,</span>
|
||||
<span class="nt">"last_ping"</span><span class="p">:</span> <span class="kc">null</span><span class="p">,</span>
|
||||
<span class="nt">"n_pings"</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span>
|
||||
<span class="nt">"name"</span><span class="p">:</span> <span class="s2">"Backups"</span><span class="p">,</span>
|
||||
<span class="nt">"next_ping"</span><span class="p">:</span> <span class="kc">null</span><span class="p">,</span>
|
||||
<span class="nt">"pause_url"</span><span class="p">:</span> <span class="s2">"SITE_ROOT/api/v1/checks/f618072a-7bde-4eee-af63-71a77c5723bc/pause"</span><span class="p">,</span>
|
||||
<span class="nt">"ping_url"</span><span class="p">:</span> <span class="s2">"PING_ENDPOINTf618072a-7bde-4eee-af63-71a77c5723bc"</span><span class="p">,</span>
|
||||
<span class="nt">"status"</span><span class="p">:</span> <span class="s2">"new"</span><span class="p">,</span>
|
||||
<span class="nt">"tags"</span><span class="p">:</span> <span class="s2">"prod www"</span><span class="p">,</span>
|
||||
<span class="nt">"timeout"</span><span class="p">:</span> <span class="mi">3600</span><span class="p">,</span>
|
||||
<span class="nt">"update_url"</span><span class="p">:</span> <span class="s2">"SITE_ROOT/api/v1/checks/f618072a-7bde-4eee-af63-71a77c5723bc"</span><span class="p">,</span>
|
||||
<span class="p">}</span>
|
||||
</code></pre></div>
|
||||
|
||||
|
||||
<h2 class="rule" id="pause-check">Pause Monitoring of a Check</h2>
|
||||
<p><code>POST SITE_ROOT/api/v1/checks/<uuid>/pause</code></p>
|
||||
<p>Disables monitoring for a check, without removing it. The check goes into a "paused"
|
||||
state. You can resume monitoring of the check by pinging it.</p>
|
||||
<p>This API call has no request parameters.</p>
|
||||
<h3>Example Request</h3>
|
||||
<div class="highlight"><pre><span></span><code>curl SITE_ROOT/api/v1/checks/0c8983c9-9d73-446f-adb5-0641fdacc9d4/pause <span class="se">\</span>
|
||||
--request POST --header <span class="s2">"X-Api-Key: your-api-key"</span> --data <span class="s2">""</span>
|
||||
</code></pre></div>
|
||||
|
||||
|
||||
<p>Note: the <code>--data ""</code> argument forces curl to send a <code>Content-Length</code> request header
|
||||
even though the request body is empty. For HTTP POST requests, the <code>Content-Length</code>
|
||||
header is sometimes required by some network proxies and web servers.</p>
|
||||
<h3>Example Response</h3>
|
||||
<div class="highlight"><pre><span></span><code><span class="p">{</span>
|
||||
<span class="nt">"channels"</span><span class="p">:</span> <span class="s2">""</span><span class="p">,</span>
|
||||
<span class="nt">"desc"</span><span class="p">:</span> <span class="s2">""</span><span class="p">,</span>
|
||||
<span class="nt">"grace"</span><span class="p">:</span> <span class="mi">60</span><span class="p">,</span>
|
||||
<span class="nt">"last_ping"</span><span class="p">:</span> <span class="kc">null</span><span class="p">,</span>
|
||||
<span class="nt">"n_pings"</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span>
|
||||
<span class="nt">"name"</span><span class="p">:</span> <span class="s2">"Backups"</span><span class="p">,</span>
|
||||
<span class="nt">"next_ping"</span><span class="p">:</span> <span class="kc">null</span><span class="p">,</span>
|
||||
<span class="nt">"pause_url"</span><span class="p">:</span> <span class="s2">"SITE_ROOT/api/v1/checks/f618072a-7bde-4eee-af63-71a77c5723bc/pause"</span><span class="p">,</span>
|
||||
<span class="nt">"ping_url"</span><span class="p">:</span> <span class="s2">"PING_ENDPOINTf618072a-7bde-4eee-af63-71a77c5723bc"</span><span class="p">,</span>
|
||||
<span class="nt">"status"</span><span class="p">:</span> <span class="s2">"paused"</span><span class="p">,</span>
|
||||
<span class="nt">"tags"</span><span class="p">:</span> <span class="s2">"prod www"</span><span class="p">,</span>
|
||||
<span class="nt">"timeout"</span><span class="p">:</span> <span class="mi">3600</span><span class="p">,</span>
|
||||
<span class="nt">"update_url"</span><span class="p">:</span> <span class="s2">"SITE_ROOT/api/v1/checks/f618072a-7bde-4eee-af63-71a77c5723bc"</span>
|
||||
<span class="p">}</span>
|
||||
</code></pre></div>
|
||||
|
||||
|
||||
<h2 class="rule" id="delete-check">Delete Check</h2>
|
||||
<p><code>DELETE SITE_ROOT/api/v1/checks/<uuid></code></p>
|
||||
<p>Permanently deletes the check from user's account. Returns JSON representation of the
|
||||
check that was just deleted.</p>
|
||||
<p>This API call has no request parameters.</p>
|
||||
<h3>Example Request</h3>
|
||||
<div class="highlight"><pre><span></span><code>curl SITE_ROOT/api/v1/checks/f618072a-7bde-4eee-af63-71a77c5723bc <span class="se">\</span>
|
||||
--request DELETE --header <span class="s2">"X-Api-Key: your-api-key"</span>
|
||||
</code></pre></div>
|
||||
|
||||
|
||||
<h3>Example Response</h3>
|
||||
<div class="highlight"><pre><span></span><code><span class="p">{</span>
|
||||
<span class="nt">"channels"</span><span class="p">:</span> <span class="s2">""</span><span class="p">,</span>
|
||||
<span class="nt">"desc"</span><span class="p">:</span> <span class="s2">""</span><span class="p">,</span>
|
||||
<span class="nt">"grace"</span><span class="p">:</span> <span class="mi">60</span><span class="p">,</span>
|
||||
<span class="nt">"last_ping"</span><span class="p">:</span> <span class="kc">null</span><span class="p">,</span>
|
||||
<span class="nt">"n_pings"</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span>
|
||||
<span class="nt">"name"</span><span class="p">:</span> <span class="s2">"Backups"</span><span class="p">,</span>
|
||||
<span class="nt">"next_ping"</span><span class="p">:</span> <span class="kc">null</span><span class="p">,</span>
|
||||
<span class="nt">"pause_url"</span><span class="p">:</span> <span class="s2">"SITE_ROOT/api/v1/checks/f618072a-7bde-4eee-af63-71a77c5723bc/pause"</span><span class="p">,</span>
|
||||
<span class="nt">"ping_url"</span><span class="p">:</span> <span class="s2">"PING_ENDPOINTf618072a-7bde-4eee-af63-71a77c5723bc"</span><span class="p">,</span>
|
||||
<span class="nt">"status"</span><span class="p">:</span> <span class="s2">"new"</span><span class="p">,</span>
|
||||
<span class="nt">"tags"</span><span class="p">:</span> <span class="s2">"prod www"</span><span class="p">,</span>
|
||||
<span class="nt">"timeout"</span><span class="p">:</span> <span class="mi">3600</span><span class="p">,</span>
|
||||
<span class="nt">"update_url"</span><span class="p">:</span> <span class="s2">"SITE_ROOT/api/v1/checks/f618072a-7bde-4eee-af63-71a77c5723bc"</span><span class="p">,</span>
|
||||
<span class="p">}</span>
|
||||
</code></pre></div>
|
||||
|
||||
|
||||
<h2 class="rule" id="list-channels">Get a List of Existing Integrations</h2>
|
||||
<p><code>GET SITE_ROOT/api/v1/channels/</code></p>
|
||||
<p>Returns a list of integrations belonging to the user.</p>
|
||||
<h3>Example Request</h3>
|
||||
<div class="highlight"><pre><span></span><code>curl --header <span class="s2">"X-Api-Key: your-api-key"</span> SITE_ROOT/api/v1/channels/
|
||||
</code></pre></div>
|
||||
|
||||
|
||||
<h3>Example Response</h3>
|
||||
<div class="highlight"><pre><span></span><code><span class="p">{</span>
|
||||
<span class="nt">"channels"</span><span class="p">:</span> <span class="p">[</span>
|
||||
<span class="p">{</span>
|
||||
<span class="nt">"id"</span><span class="p">:</span> <span class="s2">"4ec5a071-2d08-4baa-898a-eb4eb3cd6941"</span><span class="p">,</span>
|
||||
<span class="nt">"name"</span><span class="p">:</span> <span class="s2">"My Work Email"</span><span class="p">,</span>
|
||||
<span class="nt">"kind"</span><span class="p">:</span> <span class="s2">"email"</span>
|
||||
<span class="p">},</span>
|
||||
<span class="p">{</span>
|
||||
<span class="nt">"id"</span><span class="p">:</span> <span class="s2">"746a083e-f542-4554-be1a-707ce16d3acc"</span><span class="p">,</span>
|
||||
<span class="nt">"name"</span><span class="p">:</span> <span class="s2">"My Phone"</span><span class="p">,</span>
|
||||
<span class="nt">"kind"</span><span class="p">:</span> <span class="s2">"sms"</span>
|
||||
<span class="p">}</span>
|
||||
<span class="p">]</span>
|
||||
<span class="p">}</span>
|
||||
</code></pre></div>
|
533
templates/docs/api.md
Normal file
533
templates/docs/api.md
Normal file
|
@ -0,0 +1,533 @@
|
|||
# API Reference
|
||||
|
||||
SITE_NAME REST API supports listing, creating, updating, pausing and deleting
|
||||
checks in user's account.
|
||||
|
||||
## API Endpoints
|
||||
|
||||
Endpoint Name | Endpoint Address
|
||||
------------------------------------------------------|-------
|
||||
[Get a list of existing checks](#list-checks) | `GET SITE_ROOT/api/v1/checks/`
|
||||
[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`
|
||||
[Delete check](#delete-check) | `DELETE SITE_ROOT/api/v1/checks/<uuid>`
|
||||
[Get a list of existing integrations](#list-channels) | `GET SITE_ROOT/api/v1/channels/`
|
||||
|
||||
## Authentication
|
||||
|
||||
Your requests to SITE_NAME REST API must authenticate using an
|
||||
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.
|
||||
|
||||
Key Type | Description
|
||||
-------------------|------------
|
||||
Regular API key | Have full access to all documented API endpoints.
|
||||
Read-only API key | Only work with the [Get a list of existing checks](#list-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.
|
||||
|
||||
|
||||
Alternatively, for POST requests with a JSON request body,
|
||||
the client can include an `api_key` field in the JSON document.
|
||||
See below the "Create a check" section for an example.
|
||||
|
||||
## API Requests
|
||||
|
||||
For POST requests, the SITE_NAME API expects request body to be
|
||||
a JSON document (*not* a `multipart/form-data` encoded form data).
|
||||
|
||||
## API Responses
|
||||
|
||||
SITE_NAME uses HTTP status codes wherever possible.
|
||||
In general, 2xx class indicates success, 4xx indicates an client error,
|
||||
and 5xx indicates a server error.
|
||||
|
||||
The response may contain a JSON document with additional data.
|
||||
|
||||
## Get a List of Existing Checks {: #list-checks .rule }
|
||||
|
||||
`GET SITE_ROOT/api/v1/checks/`
|
||||
|
||||
Returns a list of checks belonging to the user, optionally filtered by
|
||||
one or more tags.
|
||||
|
||||
### Query String Parameters
|
||||
|
||||
tag=<value>
|
||||
: Filters the checks, and returns only the checks that are tagged with the
|
||||
specified value.
|
||||
|
||||
This parameter can be repeated multiple times.
|
||||
|
||||
Example:
|
||||
|
||||
`SITE_ROOT/api/v1/checks/?tag=foo&tag=bar`
|
||||
|
||||
### Example Request
|
||||
|
||||
```bash
|
||||
curl --header "X-Api-Key: your-api-key" SITE_ROOT/api/v1/checks/
|
||||
```
|
||||
|
||||
### Example Response
|
||||
|
||||
```json
|
||||
{
|
||||
"checks": [
|
||||
{
|
||||
"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,
|
||||
"name": "Api test 1",
|
||||
"next_ping": "2017-01-04T14:24:39.903464+00:00",
|
||||
"pause_url": "SITE_ROOT/api/v1/checks/662ebe36-ecab-48db-afe3-e20029cb71e6/pause",
|
||||
"ping_url": "PING_ENDPOINT662ebe36-ecab-48db-afe3-e20029cb71e6",
|
||||
"status": "up",
|
||||
"tags": "foo",
|
||||
"timeout": 3600,
|
||||
"update_url": "SITE_ROOT/api/v1/checks/662ebe36-ecab-48db-afe3-e20029cb71e6"
|
||||
},
|
||||
{
|
||||
"channels": "",
|
||||
"desc": "",
|
||||
"grace": 3600,
|
||||
"last_ping": null,
|
||||
"n_pings": 0,
|
||||
"name": "Api test 2",
|
||||
"next_ping": null,
|
||||
"pause_url": "SITE_ROOT/api/v1/checks/9d17c61f-5c4f-4cab-b517-11e6b2679ced/pause",
|
||||
"ping_url": "PING_ENDPOINT9d17c61f-5c4f-4cab-b517-11e6b2679ced",
|
||||
"schedule": "0/10 * * * *",
|
||||
"status": "new",
|
||||
"tags": "bar baz",
|
||||
"tz": "UTC",
|
||||
"update_url": "SITE_ROOT/api/v1/checks/9d17c61f-5c4f-4cab-b517-11e6b2679ced"
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
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:
|
||||
|
||||
```json
|
||||
{
|
||||
"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"
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
|
||||
## Create a Check {: #create-check .rule }
|
||||
`POST SITE_ROOT/api/v1/checks/`
|
||||
|
||||
Creates a new check and returns its ping URL.
|
||||
All request parameters are optional and will use their default
|
||||
values if omitted.
|
||||
|
||||
This API call can be used to create both "simple" and "cron" checks.
|
||||
To create a "simple" check, specify the "timeout" parameter.
|
||||
To create a "cron" check, specify the "schedule" and "tz" parameters.
|
||||
|
||||
### Request Parameters
|
||||
|
||||
name
|
||||
: string, optional, default value: ""
|
||||
|
||||
Name for the new check.
|
||||
|
||||
tags
|
||||
: string, optional, default value: ""
|
||||
|
||||
A space-delimited list of tags for the new check.
|
||||
Example:
|
||||
|
||||
<pre>{"tags": "reports staging"}</pre>
|
||||
|
||||
desc
|
||||
: string, optional.
|
||||
|
||||
Description for the check.
|
||||
|
||||
timeout
|
||||
: number, optional, default value: {{ default_timeout }}.
|
||||
|
||||
A number of seconds, the expected period of this check.
|
||||
|
||||
Minimum: 60 (one minute), maximum: 2592000 (30 days).
|
||||
|
||||
Example for 5 minute timeout:
|
||||
|
||||
<pre>{"kind": "simple", "timeout": 300}</pre>
|
||||
|
||||
grace
|
||||
: number, optional, default value: {{ default_grace }}.
|
||||
|
||||
A number of seconds, the grace period for this check.
|
||||
|
||||
Minimum: 60 (one minute), maximum: 2592000 (30 days).
|
||||
|
||||
schedule
|
||||
: string, optional, default value: "* * * * *".
|
||||
|
||||
A cron expression defining this check's schedule.
|
||||
|
||||
If you specify both "timeout" and "schedule" parameters, "timeout" will be
|
||||
ignored and "schedule" will be used.
|
||||
|
||||
Example for a check running every half-hour:
|
||||
|
||||
<pre>{"schedule": "0,30 * * * *"}</pre>
|
||||
|
||||
tz
|
||||
: string, optional, default value: "UTC".
|
||||
|
||||
Server's timezone. This setting only has effect in combination with the
|
||||
"schedule" paremeter.
|
||||
|
||||
Example:
|
||||
|
||||
<pre>{"tz": "Europe/Riga"}</pre>
|
||||
|
||||
channels
|
||||
: string, optional
|
||||
|
||||
By default, if a check is created through API, no notification channels
|
||||
(integrations) are assigned to it. So, when the check goes up or down, no
|
||||
notifications will get sent.
|
||||
|
||||
Set this field to a special value "*" to automatically assign all existing
|
||||
integrations.
|
||||
|
||||
To assign specific integrations, use a comma-separated list of integration
|
||||
identifiers. Use the [Get a List of Existing Integrations](#list-channels) call to
|
||||
look up integration identifiers.
|
||||
|
||||
unique
|
||||
: array of string values, optional, default value: [].
|
||||
|
||||
Before creating a check, look for existing checks, filtered by fields listed
|
||||
in `unique`. If a matching check is found, return it with HTTP status code 200.
|
||||
If no matching check is found, proceed as normal: create a check and return it
|
||||
with HTTP status code 201.
|
||||
|
||||
The accepted values are: `name`, `tags`, `timeout` and `grace`.
|
||||
|
||||
Example:
|
||||
|
||||
<pre>{"name": "Backups", unique: ["name"]}</pre>
|
||||
|
||||
In this example, if a check named "Backups" exists, it will be returned.
|
||||
Otherwise, a new check will be created and returned.
|
||||
|
||||
### Response Codes
|
||||
|
||||
201 Created
|
||||
: Returned if the check was successfully created.
|
||||
|
||||
200 OK
|
||||
: Returned if the `unique` parameter was used and an existing check was matched.
|
||||
|
||||
403 Forbidden
|
||||
: Returned if the account's check limit has been reached. For free accounts,
|
||||
the limit is 20 checks per account.
|
||||
|
||||
### Example Request
|
||||
|
||||
```bash
|
||||
curl SITE_ROOT/api/v1/checks/ \
|
||||
--header "X-Api-Key: your-api-key" \
|
||||
--data '{"name": "Backups", "tags": "prod www", "timeout": 3600, "grace": 60}'
|
||||
```
|
||||
|
||||
Or, alternatively:
|
||||
|
||||
```bash
|
||||
curl SITE_ROOT/api/v1/checks/ \
|
||||
--data '{"api_key": "your-api-key", "name": "Backups", "tags": "prod www", "timeout": 3600, "grace": 60}'
|
||||
```
|
||||
|
||||
### Example Response
|
||||
|
||||
```json
|
||||
{
|
||||
"channels": "",
|
||||
"desc": "",
|
||||
"grace": 60,
|
||||
"last_ping": null,
|
||||
"n_pings": 0,
|
||||
"name": "Backups",
|
||||
"next_ping": null,
|
||||
"pause_url": "SITE_ROOT/api/v1/checks/f618072a-7bde-4eee-af63-71a77c5723bc/pause",
|
||||
"ping_url": "PING_ENDPOINTf618072a-7bde-4eee-af63-71a77c5723bc",
|
||||
"status": "new",
|
||||
"tags": "prod www",
|
||||
"timeout": 3600,
|
||||
"update_url": "SITE_ROOT/api/v1/checks/f618072a-7bde-4eee-af63-71a77c5723bc",
|
||||
}
|
||||
```
|
||||
|
||||
## Update an Existing Check {: #update-check .rule }
|
||||
|
||||
`POST SITE_ROOT/api/v1/checks/<uuid>`
|
||||
|
||||
Updates an existing check. All request parameters are optional. The check is
|
||||
updated only with the supplied request parameters. If any parameter is omitted,
|
||||
its value is left unchanged.
|
||||
|
||||
### Request Parameters
|
||||
|
||||
name
|
||||
: string, optional.
|
||||
|
||||
Name for the check.
|
||||
|
||||
tags
|
||||
: string, optional.
|
||||
|
||||
A space-delimited list of tags for the check.
|
||||
|
||||
Example:
|
||||
|
||||
<pre>{"tags": "reports staging"}</pre>
|
||||
|
||||
desc
|
||||
: string, optional.
|
||||
|
||||
Description for the check.
|
||||
|
||||
timeout
|
||||
: number, optional.
|
||||
|
||||
A number of seconds, the expected period of this check.
|
||||
|
||||
Minimum: 60 (one minute), maximum: 2592000 (30 days).
|
||||
|
||||
Example for 5 minute timeout:
|
||||
|
||||
<pre>{"kind": "simple", "timeout": 300}</pre>
|
||||
|
||||
grace
|
||||
: number, optional.
|
||||
|
||||
A number of seconds, the grace period for this check.
|
||||
|
||||
Minimum: 60 (one minute), maximum: 2592000 (30 days).
|
||||
|
||||
schedule
|
||||
: string, optional.
|
||||
|
||||
A cron expression defining this check's schedule.
|
||||
|
||||
If you specify both "timeout" and "schedule" parameters, "timeout" will be
|
||||
ignored and "schedule" will be used.
|
||||
|
||||
Example for a check running every half-hour:
|
||||
|
||||
<pre>{"schedule": "0,30 * * * *"}</pre>
|
||||
|
||||
tz
|
||||
: string, optional.
|
||||
|
||||
Server's timezone. This setting only has effect in combination with the
|
||||
"schedule" paremeter.
|
||||
|
||||
Example:
|
||||
|
||||
<pre>{"tz": "Europe/Riga"}</pre>
|
||||
|
||||
channels
|
||||
: string, optional.
|
||||
|
||||
Set this field to a special value "*" to automatically assign all existing
|
||||
notification channels.
|
||||
|
||||
Set this field to a special value "" (empty string) to automatically *unassign*
|
||||
all notification channels.
|
||||
|
||||
Set this field to a comma-separated list of channel identifiers to assign
|
||||
specific notification channels.
|
||||
|
||||
Example:
|
||||
|
||||
<pre>{"channels": "4ec5a071-2d08-4baa-898a-eb4eb3cd6941,746a083e-f542-4554-be1a-707ce16d3acc"}</pre>
|
||||
|
||||
|
||||
### Response Codes
|
||||
|
||||
200 OK
|
||||
: Returned if the check was successfully updated.
|
||||
|
||||
### Example Request
|
||||
|
||||
```bash
|
||||
curl SITE_ROOT/api/v1/checks/f618072a-7bde-4eee-af63-71a77c5723bc \
|
||||
--header "X-Api-Key: your-api-key" \
|
||||
--data '{"name": "Backups", "tags": "prod www", "timeout": 3600, "grace": 60}'
|
||||
```
|
||||
|
||||
Or, alternatively:
|
||||
|
||||
```bash
|
||||
curl SITE_ROOT/api/v1/checks/f618072a-7bde-4eee-af63-71a77c5723bc \
|
||||
--data '{"api_key": "your-api-key", "name": "Backups", "tags": "prod www", "timeout": 3600, "grace": 60}'
|
||||
```
|
||||
|
||||
### Example Response
|
||||
|
||||
```json
|
||||
{
|
||||
"channels": "",
|
||||
"desc": "",
|
||||
"grace": 60,
|
||||
"last_ping": null,
|
||||
"n_pings": 0,
|
||||
"name": "Backups",
|
||||
"next_ping": null,
|
||||
"pause_url": "SITE_ROOT/api/v1/checks/f618072a-7bde-4eee-af63-71a77c5723bc/pause",
|
||||
"ping_url": "PING_ENDPOINTf618072a-7bde-4eee-af63-71a77c5723bc",
|
||||
"status": "new",
|
||||
"tags": "prod www",
|
||||
"timeout": 3600,
|
||||
"update_url": "SITE_ROOT/api/v1/checks/f618072a-7bde-4eee-af63-71a77c5723bc",
|
||||
}
|
||||
```
|
||||
|
||||
## Pause Monitoring of a Check {: #pause-check .rule }
|
||||
|
||||
`POST SITE_ROOT/api/v1/checks/<uuid>/pause`
|
||||
|
||||
Disables monitoring for a check, without removing it. The check goes into a "paused"
|
||||
state. You can resume monitoring of the check by pinging it.
|
||||
|
||||
This API call has no request parameters.
|
||||
|
||||
### Example Request
|
||||
|
||||
```bash
|
||||
curl SITE_ROOT/api/v1/checks/0c8983c9-9d73-446f-adb5-0641fdacc9d4/pause \
|
||||
--request POST --header "X-Api-Key: your-api-key" --data ""
|
||||
```
|
||||
|
||||
Note: the `--data ""` argument forces curl to send a `Content-Length` request header
|
||||
even though the request body is empty. For HTTP POST requests, the `Content-Length`
|
||||
header is sometimes required by some network proxies and web servers.
|
||||
|
||||
### Example Response
|
||||
|
||||
```json
|
||||
{
|
||||
"channels": "",
|
||||
"desc": "",
|
||||
"grace": 60,
|
||||
"last_ping": null,
|
||||
"n_pings": 0,
|
||||
"name": "Backups",
|
||||
"next_ping": null,
|
||||
"pause_url": "SITE_ROOT/api/v1/checks/f618072a-7bde-4eee-af63-71a77c5723bc/pause",
|
||||
"ping_url": "PING_ENDPOINTf618072a-7bde-4eee-af63-71a77c5723bc",
|
||||
"status": "paused",
|
||||
"tags": "prod www",
|
||||
"timeout": 3600,
|
||||
"update_url": "SITE_ROOT/api/v1/checks/f618072a-7bde-4eee-af63-71a77c5723bc"
|
||||
}
|
||||
```
|
||||
|
||||
## Delete Check {: #delete-check .rule }
|
||||
|
||||
`DELETE SITE_ROOT/api/v1/checks/<uuid>`
|
||||
|
||||
Permanently deletes the check from user's account. Returns JSON representation of the
|
||||
check that was just deleted.
|
||||
|
||||
This API call has no request parameters.
|
||||
|
||||
### Example Request
|
||||
|
||||
```bash
|
||||
curl SITE_ROOT/api/v1/checks/f618072a-7bde-4eee-af63-71a77c5723bc \
|
||||
--request DELETE --header "X-Api-Key: your-api-key"
|
||||
```
|
||||
|
||||
### Example Response
|
||||
|
||||
```json
|
||||
{
|
||||
"channels": "",
|
||||
"desc": "",
|
||||
"grace": 60,
|
||||
"last_ping": null,
|
||||
"n_pings": 0,
|
||||
"name": "Backups",
|
||||
"next_ping": null,
|
||||
"pause_url": "SITE_ROOT/api/v1/checks/f618072a-7bde-4eee-af63-71a77c5723bc/pause",
|
||||
"ping_url": "PING_ENDPOINTf618072a-7bde-4eee-af63-71a77c5723bc",
|
||||
"status": "new",
|
||||
"tags": "prod www",
|
||||
"timeout": 3600,
|
||||
"update_url": "SITE_ROOT/api/v1/checks/f618072a-7bde-4eee-af63-71a77c5723bc",
|
||||
}
|
||||
```
|
||||
|
||||
## Get a List of Existing Integrations {: #list-channels .rule }
|
||||
|
||||
`GET SITE_ROOT/api/v1/channels/`
|
||||
|
||||
Returns a list of integrations belonging to the user.
|
||||
|
||||
### Example Request
|
||||
|
||||
```bash
|
||||
curl --header "X-Api-Key: your-api-key" SITE_ROOT/api/v1/channels/
|
||||
```
|
||||
|
||||
### Example Response
|
||||
|
||||
```json
|
||||
{
|
||||
"channels": [
|
||||
{
|
||||
"id": "4ec5a071-2d08-4baa-898a-eb4eb3cd6941",
|
||||
"name": "My Work Email",
|
||||
"kind": "email"
|
||||
},
|
||||
{
|
||||
"id": "746a083e-f542-4554-be1a-707ce16d3acc",
|
||||
"name": "My Phone",
|
||||
"kind": "sms"
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
|
@ -33,9 +33,7 @@
|
|||
{% include "front/docs_nav_item.html" with slug="attaching_logs" title="Attaching logs" %}
|
||||
|
||||
<li class="nav-header">Developer Tools</li>
|
||||
<li{% if section == "api" %} class="active"{% endif %}>
|
||||
<a href="{% url 'hc-docs-api' %}">Management API</a>
|
||||
</li>
|
||||
{% include "front/docs_nav_item.html" with slug="api" title="Management API" %}
|
||||
{% include "front/docs_nav_item.html" with slug="resources" title="Third-party resources" %}
|
||||
|
||||
<li class="nav-header">Cron</li>
|
||||
|
|
|
@ -1,500 +0,0 @@
|
|||
{% extends "front/base_docs.html" %}
|
||||
{% load compress static hc_extras %}
|
||||
|
||||
{% block title %}API Reference - {% site_name %}{% endblock %}
|
||||
|
||||
{% block description %}
|
||||
<meta name="description" content="Build advanced integrations and custom dashboards using {% site_name %} REST API calls.">
|
||||
{% endblock %}
|
||||
|
||||
{% block docs_content %}
|
||||
|
||||
<h2>API Reference</h2>
|
||||
<p>{% site_name %} REST API supports listing, creating,
|
||||
updating, pausing and deleting checks in user's account.
|
||||
</p>
|
||||
|
||||
<h2>API Endpoints</h2>
|
||||
<table class="table table-bordered">
|
||||
<tr>
|
||||
<td><a href="#list-checks">Get a list of existing checks</a></td>
|
||||
<td>
|
||||
<code>GET {{ SITE_ROOT }}/api/v1/checks/</code>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><a href="#create-check">Create a new check</a></td>
|
||||
<td>
|
||||
<code>POST {{ SITE_ROOT }}/api/v1/checks/</code>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><a href="#update-check">Update an existing check</a></td>
|
||||
<td>
|
||||
<code>POST {{ SITE_ROOT }}/api/v1/checks/<code></code>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><a href="#pause-check">Pause monitoring of a check</a></td>
|
||||
<td>
|
||||
<code>POST {{ SITE_ROOT }}/api/v1/checks/<code>/pause</code>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><a href="#delete-check">Delete check</a></td>
|
||||
<td>
|
||||
<code>DELETE {{ SITE_ROOT }}/api/v1/checks/<code></code>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><a href="#list-channels">Get a list of existing integrations</a></td>
|
||||
<td>
|
||||
<code>GET {{ SITE_ROOT }}/api/v1/channels/</code>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
<h2>Authentication</h2>
|
||||
<p>Your requests to {% site_name %} REST API must authenticate using an
|
||||
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
|
||||
<b>Project Settings</b> page.
|
||||
</p>
|
||||
|
||||
<table class="table table-bordered">
|
||||
<tr>
|
||||
<td>Regular API keys</td>
|
||||
<td>Have full access to all documented API endpoints.</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Read-only API keys</td>
|
||||
<td>Only work with the
|
||||
<a href="#list-checks">Get a list of existing checks</a>
|
||||
endpoint. Some fields are omitted from the API responses.</td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
<p>The client can authenticate itself by sending an appropriate HTTP
|
||||
request header. The header's name should be <code>X-Api-Key</code> and
|
||||
its value should be your API key.
|
||||
</p>
|
||||
|
||||
<p> Alternatively, for POST requests with a JSON request body,
|
||||
the client can include an <code>api_key</code> field in the JSON document.
|
||||
See below the "Create a check" section for an example.
|
||||
</p>
|
||||
|
||||
<h2>API Requests</h2>
|
||||
|
||||
<p>
|
||||
For POST requests, the {% site_name %} API expects request body to be
|
||||
a JSON document (<em>not</em> a <code>multipart/form-data</code> encoded
|
||||
form data).
|
||||
</p>
|
||||
|
||||
<h2>API Responses</h2>
|
||||
|
||||
<p>
|
||||
{% site_name %} uses HTTP status codes wherever possible.
|
||||
In general, 2xx class indicates success, 4xx indicates an client error,
|
||||
and 5xx indicates a server error.
|
||||
</p>
|
||||
|
||||
<p>
|
||||
The response may contain a JSON document with additional data.
|
||||
</p>
|
||||
|
||||
<!-- ********************************************************************** /-->
|
||||
|
||||
<a class="section" name="list-checks">
|
||||
<h2 class="rule">Get a List of Existing Checks</h2>
|
||||
</a>
|
||||
|
||||
<div class="api-path">GET {{ SITE_ROOT }}/api/v1/checks/</div>
|
||||
|
||||
<p>Returns a list of checks belonging to the user, optionally filtered by
|
||||
one or more tags.</p>
|
||||
|
||||
<h3 class="api-section">Query String Parameters</h3>
|
||||
<table class="table">
|
||||
<tr>
|
||||
<th>tag=<value></th>
|
||||
<td>
|
||||
<p>
|
||||
Filters the checks, and returns only the checks that
|
||||
are tagged with the specified value.
|
||||
</p>
|
||||
<p>
|
||||
This parameter can be repeated multiple times.
|
||||
</p>
|
||||
<p>Example:</p>
|
||||
<pre>{{ SITE_ROOT }}/api/v1/checks/?tag=foo&tag=bar</pre>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
<h3 class="api-section">Example Request</h3>
|
||||
{% include "front/snippets/list_checks_request.html" %}
|
||||
|
||||
<h3 class="api-section">Example Response</h3>
|
||||
{% include "front/snippets/list_checks_response.html" %}
|
||||
|
||||
<p>When using the read-only API key, the following fields are omitted:
|
||||
<code>ping_url</code>, <code>update_url</code>, <code>pause_url</code>,
|
||||
<code>channels</code>. An extra <code>unique_key</code> field is added.
|
||||
This identifier is stable across API calls. Example:
|
||||
</p>
|
||||
{% include "front/snippets/list_checks_response_readonly.html" %}
|
||||
|
||||
<!-- ********************************************************************** /-->
|
||||
|
||||
<a class="section" name="create-check">
|
||||
<h2 class="rule">Create a Check</h2>
|
||||
</a>
|
||||
|
||||
<div class="api-path">POST {{ SITE_ROOT }}/api/v1/checks/</div>
|
||||
|
||||
<strong></strong>
|
||||
|
||||
<p>
|
||||
Creates a new check and returns its ping URL.
|
||||
All request parameters are optional and will use their default
|
||||
values if omitted.
|
||||
</p>
|
||||
|
||||
<p>This API call can be used to create both "simple" and "cron" checks.
|
||||
To create a "simple" check, specify the "timeout" parameter.
|
||||
To create a "cron" check, specify the "schedule" and "tz" parameters.
|
||||
</p>
|
||||
|
||||
<h3 class="api-section">Request Parameters</h3>
|
||||
<table class="table">
|
||||
<tr>
|
||||
<th>name</th>
|
||||
<td>
|
||||
<p>string, optional, default value: ""</p>
|
||||
<p>Name for the new check.</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>tags</th>
|
||||
<td>
|
||||
<p>string, optional, default value: ""</p>
|
||||
<p>A space-delimited list of tags for the new check.</p>
|
||||
<p>Example:</p>
|
||||
<pre>{"tags": "reports staging"}</pre>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>desc</th>
|
||||
<td>
|
||||
<p>string, optional.</p>
|
||||
<p>Description for the check.</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>timeout</th>
|
||||
<td>
|
||||
<p>number, optional, default value: {{ default_timeout }}.</p>
|
||||
<p>A number of seconds, the expected period of this check.</p>
|
||||
<p>Minimum: 60 (one minute), maximum: 2592000 (30 days).</p>
|
||||
<p>Example for 5 minute timeout:</p>
|
||||
<pre>{"kind": "simple", "timeout": 300}</pre>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>grace</th>
|
||||
<td>
|
||||
<p>number, optional, default value: {{ default_grace }}.</p>
|
||||
<p>A number of seconds, the grace period for this check.</p>
|
||||
<p>Minimum: 60 (one minute), maximum: 2592000 (30 days).</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>schedule</th>
|
||||
<td>
|
||||
<p>string, optional, default value: "* * * * *".</p>
|
||||
<p>A cron expression defining this check's schedule.</p>
|
||||
<p>If you specify both "timeout" and "schedule" parameters,
|
||||
"timeout" will be ignored and "schedule" will be used.</p>
|
||||
<p>Example for a check running every half-hour:</p>
|
||||
<pre>{"schedule": "0,30 * * * *"}</pre>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>tz</th>
|
||||
<td>
|
||||
<p>string, optional, default value: "UTC".</p>
|
||||
<p>Server's timezone. This setting only has effect in combination
|
||||
with the "schedule" paremeter.</p>
|
||||
<p>Example:</p>
|
||||
<pre>{"tz": "Europe/Riga"}</pre>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>channels</th>
|
||||
<td>
|
||||
<p>string, optional</p>
|
||||
<p>By default, if a check is created through API, no notification
|
||||
channels (integrations) are assigned to it.
|
||||
So, when the check goes up or down, no notifications will get
|
||||
sent.</p>
|
||||
|
||||
<p>Set this field to a special value "*"
|
||||
to automatically assign all existing integrations.</p>
|
||||
|
||||
<p>To assign specific integrations, use a comma-separated
|
||||
list of integration identifiers. Use the
|
||||
<a href="#list-channels">Get a List of Existing Integrations</a>
|
||||
call to look up integration identifiers.
|
||||
</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>unique</th>
|
||||
<td>
|
||||
<p>array of string values, optional, default value: [].</p>
|
||||
<p>Before creating a check, look for existing checks, filtered
|
||||
by fields listed in <code>unique</code>. If a matching check is
|
||||
found, return it with HTTP status code 200. If no matching check is
|
||||
found, proceed as normal: create a check and return it
|
||||
with HTTP status code 201.</p>
|
||||
|
||||
<p>The accepted values are: <code>name</code>,
|
||||
<code>tags</code>, <code>timeout</code> and <code>grace</code>.</p>
|
||||
|
||||
<p>Example:</p>
|
||||
<pre>{"name": "Backups", unique: ["name"]}</pre>
|
||||
<p>In this example, if a check named "Backups" exists, it will
|
||||
be returned. Otherwise, a new check will be created and
|
||||
returned.</p>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
<h3 class="api-section">Response Codes</h3>
|
||||
<table class="table">
|
||||
<tr>
|
||||
<th>201 Created</th>
|
||||
<td>Returned if the check was successfully created.</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>200 OK</th>
|
||||
<td>Returned if the <code>unique</code> parameter was used and an
|
||||
existing check was matched.</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>403 Forbidden</th>
|
||||
<td>Returned if the account's check limit has been reached.
|
||||
For free accounts, the limit is 20 checks per account.</td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
<h3 class="api-section">Example Request</h3>
|
||||
{% include "front/snippets/create_check_request_a.html" %}
|
||||
<br>
|
||||
<p>Or, alternatively:</p>
|
||||
{% include "front/snippets/create_check_request_b.html" %}
|
||||
|
||||
|
||||
<h3 class="api-section">Example Response</h3>
|
||||
{% include "front/snippets/create_check_response.html" %}
|
||||
|
||||
<!-- ********************************************************************** /-->
|
||||
|
||||
<a class="section" name="update-check">
|
||||
<h2 class="rule">Update an Existing Check</h2>
|
||||
</a>
|
||||
|
||||
<div class="api-path">POST {{ SITE_ROOT }}/api/v1/checks/<code></div>
|
||||
|
||||
<strong></strong>
|
||||
|
||||
<p>
|
||||
Updates an existing check. All request parameters are optional. The
|
||||
check is updated only with the supplied request parameters.
|
||||
If any parameter is omitted, its value is left unchanged.
|
||||
</p>
|
||||
|
||||
<h3 class="api-section">Request Parameters</h3>
|
||||
<table class="table">
|
||||
<tr>
|
||||
<th>name</th>
|
||||
<td>
|
||||
<p>string, optional.</p>
|
||||
<p>Name for the check.</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>tags</th>
|
||||
<td>
|
||||
<p>string, optional.</p>
|
||||
<p>A space-delimited list of tags for the check.</p>
|
||||
<p>Example:</p>
|
||||
<pre>{"tags": "reports staging"}</pre>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>desc</th>
|
||||
<td>
|
||||
<p>string, optional.</p>
|
||||
<p>Description for the check.</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>timeout</th>
|
||||
<td>
|
||||
<p>number, optional.</p>
|
||||
<p>A number of seconds, the expected period of this check.</p>
|
||||
<p>Minimum: 60 (one minute), maximum: 2592000 (30 days).</p>
|
||||
<p>Example for 5 minute timeout:</p>
|
||||
<pre>{"kind": "simple", "timeout": 300}</pre>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>grace</th>
|
||||
<td>
|
||||
<p>number, optional.</p>
|
||||
<p>A number of seconds, the grace period for this check.</p>
|
||||
<p>Minimum: 60 (one minute), maximum: 2592000 (30 days).</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>schedule</th>
|
||||
<td>
|
||||
<p>string, optional.</p>
|
||||
<p>A cron expression defining this check's schedule.</p>
|
||||
<p>If you specify both "timeout" and "schedule" parameters,
|
||||
"timeout" will be ignored and "schedule" will be used.</p>
|
||||
<p>Example for a check running every half-hour:</p>
|
||||
<pre>{"schedule": "0,30 * * * *"}</pre>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>tz</th>
|
||||
<td>
|
||||
<p>string, optional.</p>
|
||||
<p>Server's timezone. This setting only has effect in combination
|
||||
with the "schedule" paremeter.</p>
|
||||
<p>Example:</p>
|
||||
<pre>{"tz": "Europe/Riga"}</pre>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>channels</th>
|
||||
<td>
|
||||
<p>string, optional.</p>
|
||||
<p>Set this field to a special value "*"
|
||||
to automatically assign all existing notification channels.
|
||||
</p>
|
||||
<p>Set this field to a special value "" (empty string)
|
||||
to automatically <em>unassign</em> all notification channels.
|
||||
</p>
|
||||
<p>Set this field to a comma-separated list of channel identifiers
|
||||
to assign specific notification channels.
|
||||
</p>
|
||||
<p>Example:</p>
|
||||
<pre>{"channels": "4ec5a071-2d08-4baa-898a-eb4eb3cd6941,746a083e-f542-4554-be1a-707ce16d3acc"}</pre>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
<h3 class="api-section">Response Codes</h3>
|
||||
<table class="table">
|
||||
<tr>
|
||||
<th>200 OK</th>
|
||||
<td>Returned if the check was successfully updated.</td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
<h3 class="api-section">Example Request</h3>
|
||||
{% include "front/snippets/update_check_request_a.html" %}
|
||||
<br>
|
||||
<p>Or, alternatively:</p>
|
||||
{% include "front/snippets/update_check_request_b.html" %}
|
||||
|
||||
|
||||
<h3 class="api-section">Example Response</h3>
|
||||
{% include "front/snippets/create_check_response.html" %}
|
||||
|
||||
<!-- ********************************************************************** /-->
|
||||
|
||||
<a class="section" name="pause-check">
|
||||
<h2 class="rule">Pause Monitoring of a Check</h2>
|
||||
</a>
|
||||
|
||||
<div class="api-path">POST {{ SITE_ROOT }}/api/v1/checks/<uuid>/pause</div>
|
||||
|
||||
<p>
|
||||
Disables monitoring for a check, without removing it. The check goes
|
||||
into a "paused" state. You can resume monitoring of the check by pinging
|
||||
it.
|
||||
</p>
|
||||
<p>
|
||||
This API call has no request parameters.
|
||||
</p>
|
||||
|
||||
<h3 class="api-section">Example Request</h3>
|
||||
|
||||
{% include "front/snippets/pause_check_request.html" %}
|
||||
|
||||
<p>Note: the <code>--data ""</code> argument forces curl to send a
|
||||
<code>Content-Length</code> request header even though the request body
|
||||
is empty. For HTTP POST requests, the <code>Content-Length</code> header
|
||||
is sometimes required by some network proxies and web servers.
|
||||
</p>
|
||||
|
||||
<h3 class="api-section">Example Response</h3>
|
||||
{% include "front/snippets/pause_check_response.html" %}
|
||||
|
||||
<!-- ********************************************************************** /-->
|
||||
|
||||
<a class="section" name="delete-check">
|
||||
<h2 class="rule">Delete Check</h2>
|
||||
</a>
|
||||
|
||||
<div class="api-path">DELETE {{ SITE_ROOT }}/api/v1/checks/<uuid></div>
|
||||
|
||||
<p>
|
||||
Permanently deletes the check from user's account. Returns JSON
|
||||
representation of the check that was just deleted.
|
||||
</p>
|
||||
<p>
|
||||
This API call has no request parameters.
|
||||
</p>
|
||||
|
||||
<h3 class="api-section">Example Request</h3>
|
||||
|
||||
{% include "front/snippets/delete_check_request.html" %}
|
||||
|
||||
<h3 class="api-section">Example Response</h3>
|
||||
{% include "front/snippets/create_check_response.html" %}
|
||||
|
||||
<!-- ********************************************************************** /-->
|
||||
|
||||
<a class="section" name="list-channels">
|
||||
<h2 class="rule">Get a List of Existing Integrations</h2>
|
||||
</a>
|
||||
|
||||
<div class="api-path">GET {{ SITE_ROOT }}/api/v1/channels/</div>
|
||||
|
||||
<p>Returns a list of integrations belonging to the user.</p>
|
||||
|
||||
<h3 class="api-section">Example Request</h3>
|
||||
{% include "front/snippets/list_channels_request.html" %}
|
||||
|
||||
<h3 class="api-section">Example Response</h3>
|
||||
{% include "front/snippets/list_channels_response.html" %}
|
||||
|
||||
|
||||
{% endblock %}
|
||||
|
||||
{% block scripts %}
|
||||
{% compress js %}
|
||||
<script src="{% static 'js/jquery-2.1.4.min.js' %}"></script>
|
||||
<script src="{% static 'js/bootstrap.min.js' %}"></script>
|
||||
<script src="{% static 'js/clipboard.min.js' %}"></script>
|
||||
<script src="{% static 'js/snippet-copy.js' %}"></script>
|
||||
{% endcompress %}
|
||||
{% endblock %}
|
|
@ -6,7 +6,7 @@
|
|||
{% block keywords %}{% endblock %}
|
||||
|
||||
{% block docs_content %}
|
||||
<div class="docs-content">{{ content|safe }}</div>
|
||||
<div class="docs-content docs-{{ section }}">{{ content|safe }}</div>
|
||||
{% endblock %}
|
||||
|
||||
{% block scripts %}
|
||||
|
|
|
@ -1,4 +0,0 @@
|
|||
<div class="highlight"><pre><span></span>curl {{ SITE_ROOT }}/api/v1/checks/ <span class="se">\</span>
|
||||
--header <span class="s2">"X-Api-Key: your-api-key"</span> <span class="se">\</span>
|
||||
--data <span class="s1">'{"name": "Backups", "tags": "prod www", "timeout": 3600, "grace": 60}'</span>
|
||||
</pre></div>
|
|
@ -1,3 +0,0 @@
|
|||
curl SITE_ROOT/api/v1/checks/ \
|
||||
--header "X-Api-Key: your-api-key" \
|
||||
--data '{"name": "Backups", "tags": "prod www", "timeout": 3600, "grace": 60}'
|
|
@ -1,3 +0,0 @@
|
|||
<div class="highlight"><pre><span></span>curl {{ SITE_ROOT }}/api/v1/checks/ <span class="se">\</span>
|
||||
--data <span class="s1">'{"api_key": "your-api-key", "name": "Backups", "tags": "prod www", "timeout": 3600, "grace": 60}'</span>
|
||||
</pre></div>
|
|
@ -1,2 +0,0 @@
|
|||
curl SITE_ROOT/api/v1/checks/ \
|
||||
--data '{"api_key": "your-api-key", "name": "Backups", "tags": "prod www", "timeout": 3600, "grace": 60}'
|
|
@ -1,16 +0,0 @@
|
|||
<div class="highlight"><pre><span></span><span class="p">{</span>
|
||||
<span class="nt">"channels"</span><span class="p">:</span> <span class="s2">""</span><span class="p">,</span>
|
||||
<span class="nt">"desc"</span><span class="p">:</span> <span class="s2">""</span><span class="p">,</span>
|
||||
<span class="nt">"grace"</span><span class="p">:</span> <span class="mi">60</span><span class="p">,</span>
|
||||
<span class="nt">"last_ping"</span><span class="p">:</span> <span class="kc">null</span><span class="p">,</span>
|
||||
<span class="nt">"n_pings"</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span>
|
||||
<span class="nt">"name"</span><span class="p">:</span> <span class="s2">"Backups"</span><span class="p">,</span>
|
||||
<span class="nt">"next_ping"</span><span class="p">:</span> <span class="kc">null</span><span class="p">,</span>
|
||||
<span class="nt">"pause_url"</span><span class="p">:</span> <span class="s2">"{{ SITE_ROOT }}/api/v1/checks/f618072a-7bde-4eee-af63-71a77c5723bc/pause"</span><span class="p">,</span>
|
||||
<span class="nt">"ping_url"</span><span class="p">:</span> <span class="s2">"{{ PING_ENDPOINT }}f618072a-7bde-4eee-af63-71a77c5723bc"</span><span class="p">,</span>
|
||||
<span class="nt">"status"</span><span class="p">:</span> <span class="s2">"new"</span><span class="p">,</span>
|
||||
<span class="nt">"tags"</span><span class="p">:</span> <span class="s2">"prod www"</span><span class="p">,</span>
|
||||
<span class="nt">"timeout"</span><span class="p">:</span> <span class="mi">3600</span><span class="p">,</span>
|
||||
<span class="nt">"update_url"</span><span class="p">:</span> <span class="s2">"{{ SITE_ROOT }}/api/v1/checks/f618072a-7bde-4eee-af63-71a77c5723bc"</span><span class="p">,</span>
|
||||
<span class="p">}</span>
|
||||
</pre></div>
|
|
@ -1,15 +0,0 @@
|
|||
{
|
||||
"channels": "",
|
||||
"desc": "",
|
||||
"grace": 60,
|
||||
"last_ping": null,
|
||||
"n_pings": 0,
|
||||
"name": "Backups",
|
||||
"next_ping": null,
|
||||
"pause_url": "SITE_ROOT/api/v1/checks/f618072a-7bde-4eee-af63-71a77c5723bc/pause",
|
||||
"ping_url": "PING_ENDPOINTf618072a-7bde-4eee-af63-71a77c5723bc",
|
||||
"status": "new",
|
||||
"tags": "prod www",
|
||||
"timeout": 3600,
|
||||
"update_url": "SITE_ROOT/api/v1/checks/f618072a-7bde-4eee-af63-71a77c5723bc",
|
||||
}
|
|
@ -1,3 +0,0 @@
|
|||
<div class="highlight"><pre><span></span>curl {{ SITE_ROOT }}/api/v1/checks/f618072a-7bde-4eee-af63-71a77c5723bc <span class="se">\</span>
|
||||
--request DELETE --header <span class="s2">"X-Api-Key: your-api-key"</span>
|
||||
</pre></div>
|
|
@ -1,2 +0,0 @@
|
|||
curl SITE_ROOT/api/v1/checks/f618072a-7bde-4eee-af63-71a77c5723bc \
|
||||
--request DELETE --header "X-Api-Key: your-api-key"
|
|
@ -1,2 +0,0 @@
|
|||
<div class="highlight"><pre><span></span>curl --header <span class="s2">"X-Api-Key: your-api-key"</span> {{ SITE_ROOT }}/api/v1/channels/
|
||||
</pre></div>
|
|
@ -1 +0,0 @@
|
|||
curl --header "X-Api-Key: your-api-key" SITE_ROOT/api/v1/channels/
|
|
@ -1,15 +0,0 @@
|
|||
<div class="highlight"><pre><span></span><span class="p">{</span>
|
||||
<span class="nt">"channels"</span><span class="p">:</span> <span class="p">[</span>
|
||||
<span class="p">{</span>
|
||||
<span class="nt">"id"</span><span class="p">:</span> <span class="s2">"4ec5a071-2d08-4baa-898a-eb4eb3cd6941"</span><span class="p">,</span>
|
||||
<span class="nt">"name"</span><span class="p">:</span> <span class="s2">"My Work Email"</span><span class="p">,</span>
|
||||
<span class="nt">"kind"</span><span class="p">:</span> <span class="s2">"email"</span>
|
||||
<span class="p">},</span>
|
||||
<span class="p">{</span>
|
||||
<span class="nt">"id"</span><span class="p">:</span> <span class="s2">"746a083e-f542-4554-be1a-707ce16d3acc"</span><span class="p">,</span>
|
||||
<span class="nt">"name"</span><span class="p">:</span> <span class="s2">"My Phone"</span><span class="p">,</span>
|
||||
<span class="nt">"kind"</span><span class="p">:</span> <span class="s2">"sms"</span>
|
||||
<span class="p">}</span>
|
||||
<span class="p">]</span>
|
||||
<span class="p">}</span>
|
||||
</pre></div>
|
|
@ -1,14 +0,0 @@
|
|||
{
|
||||
"channels": [
|
||||
{
|
||||
"id": "4ec5a071-2d08-4baa-898a-eb4eb3cd6941",
|
||||
"name": "My Work Email",
|
||||
"kind": "email"
|
||||
},
|
||||
{
|
||||
"id": "746a083e-f542-4554-be1a-707ce16d3acc",
|
||||
"name": "My Phone",
|
||||
"kind": "sms"
|
||||
}
|
||||
]
|
||||
}
|
|
@ -1,2 +0,0 @@
|
|||
<div class="highlight"><pre><span></span>curl --header <span class="s2">"X-Api-Key: your-api-key"</span> {{ SITE_ROOT }}/api/v1/checks/
|
||||
</pre></div>
|
|
@ -1 +0,0 @@
|
|||
curl --header "X-Api-Key: your-api-key" SITE_ROOT/api/v1/checks/
|
|
@ -1,36 +0,0 @@
|
|||
<div class="highlight"><pre><span></span><span class="p">{</span>
|
||||
<span class="nt">"checks"</span><span class="p">:</span> <span class="p">[</span>
|
||||
<span class="p">{</span>
|
||||
<span class="nt">"channels"</span><span class="p">:</span> <span class="s2">"4ec5a071-2d08-4baa-898a-eb4eb3cd6941,746a083e-f542-4554-be1a-707ce16d3acc"</span><span class="p">,</span>
|
||||
<span class="nt">"desc"</span><span class="p">:</span> <span class="s2">"Longer free-form description goes here"</span><span class="p">,</span>
|
||||
<span class="nt">"grace"</span><span class="p">:</span> <span class="mi">900</span><span class="p">,</span>
|
||||
<span class="nt">"last_ping"</span><span class="p">:</span> <span class="s2">"2017-01-04T13:24:39.903464+00:00"</span><span class="p">,</span>
|
||||
<span class="nt">"n_pings"</span><span class="p">:</span> <span class="mi">1</span><span class="p">,</span>
|
||||
<span class="nt">"name"</span><span class="p">:</span> <span class="s2">"Api test 1"</span><span class="p">,</span>
|
||||
<span class="nt">"next_ping"</span><span class="p">:</span> <span class="s2">"2017-01-04T14:24:39.903464+00:00"</span><span class="p">,</span>
|
||||
<span class="nt">"pause_url"</span><span class="p">:</span> <span class="s2">"{{ SITE_ROOT }}/api/v1/checks/662ebe36-ecab-48db-afe3-e20029cb71e6/pause"</span><span class="p">,</span>
|
||||
<span class="nt">"ping_url"</span><span class="p">:</span> <span class="s2">"{{ PING_ENDPOINT }}662ebe36-ecab-48db-afe3-e20029cb71e6"</span><span class="p">,</span>
|
||||
<span class="nt">"status"</span><span class="p">:</span> <span class="s2">"up"</span><span class="p">,</span>
|
||||
<span class="nt">"tags"</span><span class="p">:</span> <span class="s2">"foo"</span><span class="p">,</span>
|
||||
<span class="nt">"timeout"</span><span class="p">:</span> <span class="mi">3600</span><span class="p">,</span>
|
||||
<span class="nt">"update_url"</span><span class="p">:</span> <span class="s2">"{{ SITE_ROOT }}/api/v1/checks/662ebe36-ecab-48db-afe3-e20029cb71e6"</span>
|
||||
<span class="p">},</span>
|
||||
<span class="p">{</span>
|
||||
<span class="nt">"channels"</span><span class="p">:</span> <span class="s2">""</span><span class="p">,</span>
|
||||
<span class="nt">"desc"</span><span class="p">:</span> <span class="s2">""</span><span class="p">,</span>
|
||||
<span class="nt">"grace"</span><span class="p">:</span> <span class="mi">3600</span><span class="p">,</span>
|
||||
<span class="nt">"last_ping"</span><span class="p">:</span> <span class="kc">null</span><span class="p">,</span>
|
||||
<span class="nt">"n_pings"</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span>
|
||||
<span class="nt">"name"</span><span class="p">:</span> <span class="s2">"Api test 2"</span><span class="p">,</span>
|
||||
<span class="nt">"next_ping"</span><span class="p">:</span> <span class="kc">null</span><span class="p">,</span>
|
||||
<span class="nt">"pause_url"</span><span class="p">:</span> <span class="s2">"{{ SITE_ROOT }}/api/v1/checks/9d17c61f-5c4f-4cab-b517-11e6b2679ced/pause"</span><span class="p">,</span>
|
||||
<span class="nt">"ping_url"</span><span class="p">:</span> <span class="s2">"{{ PING_ENDPOINT }}9d17c61f-5c4f-4cab-b517-11e6b2679ced"</span><span class="p">,</span>
|
||||
<span class="nt">"schedule"</span><span class="p">:</span> <span class="s2">"0/10 * * * *"</span><span class="p">,</span>
|
||||
<span class="nt">"status"</span><span class="p">:</span> <span class="s2">"new"</span><span class="p">,</span>
|
||||
<span class="nt">"tags"</span><span class="p">:</span> <span class="s2">"bar baz"</span><span class="p">,</span>
|
||||
<span class="nt">"tz"</span><span class="p">:</span> <span class="s2">"UTC"</span><span class="p">,</span>
|
||||
<span class="nt">"update_url"</span><span class="p">:</span> <span class="s2">"{{ SITE_ROOT }}/api/v1/checks/9d17c61f-5c4f-4cab-b517-11e6b2679ced"</span>
|
||||
<span class="p">}</span>
|
||||
<span class="p">]</span>
|
||||
<span class="p">}</span>
|
||||
</pre></div>
|
|
@ -1,35 +0,0 @@
|
|||
{
|
||||
"checks": [
|
||||
{
|
||||
"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,
|
||||
"name": "Api test 1",
|
||||
"next_ping": "2017-01-04T14:24:39.903464+00:00",
|
||||
"pause_url": "SITE_ROOT/api/v1/checks/662ebe36-ecab-48db-afe3-e20029cb71e6/pause",
|
||||
"ping_url": "PING_ENDPOINT662ebe36-ecab-48db-afe3-e20029cb71e6",
|
||||
"status": "up",
|
||||
"tags": "foo",
|
||||
"timeout": 3600,
|
||||
"update_url": "SITE_ROOT/api/v1/checks/662ebe36-ecab-48db-afe3-e20029cb71e6"
|
||||
},
|
||||
{
|
||||
"channels": "",
|
||||
"desc": "",
|
||||
"grace": 3600,
|
||||
"last_ping": null,
|
||||
"n_pings": 0,
|
||||
"name": "Api test 2",
|
||||
"next_ping": null,
|
||||
"pause_url": "SITE_ROOT/api/v1/checks/9d17c61f-5c4f-4cab-b517-11e6b2679ced/pause",
|
||||
"ping_url": "PING_ENDPOINT9d17c61f-5c4f-4cab-b517-11e6b2679ced",
|
||||
"schedule": "0/10 * * * *",
|
||||
"status": "new",
|
||||
"tags": "bar baz",
|
||||
"tz": "UTC",
|
||||
"update_url": "SITE_ROOT/api/v1/checks/9d17c61f-5c4f-4cab-b517-11e6b2679ced"
|
||||
}
|
||||
]
|
||||
}
|
|
@ -1,29 +0,0 @@
|
|||
<div class="highlight"><pre><span></span><span class="p">{</span>
|
||||
<span class="nt">"checks"</span><span class="p">:</span> <span class="p">[</span>
|
||||
<span class="p">{</span>
|
||||
<span class="nt">"desc"</span><span class="p">:</span> <span class="s2">"Longer free-form description goes here"</span><span class="p">,</span>
|
||||
<span class="nt">"grace"</span><span class="p">:</span> <span class="mi">900</span><span class="p">,</span>
|
||||
<span class="nt">"last_ping"</span><span class="p">:</span> <span class="s2">"2017-01-04T13:24:39.903464+00:00"</span><span class="p">,</span>
|
||||
<span class="nt">"n_pings"</span><span class="p">:</span> <span class="mi">1</span><span class="p">,</span>
|
||||
<span class="nt">"name"</span><span class="p">:</span> <span class="s2">"Api test 1"</span><span class="p">,</span>
|
||||
<span class="nt">"status"</span><span class="p">:</span> <span class="s2">"up"</span><span class="p">,</span>
|
||||
<span class="nt">"tags"</span><span class="p">:</span> <span class="s2">"foo"</span><span class="p">,</span>
|
||||
<span class="nt">"timeout"</span><span class="p">:</span> <span class="mi">3600</span><span class="p">,</span>
|
||||
<span class="nt">"unique_key"</span><span class="p">:</span> <span class="s2">"2872190d95224bad120f41d3c06aab94b8175bb6"</span>
|
||||
<span class="p">},</span>
|
||||
<span class="p">{</span>
|
||||
<span class="nt">"desc"</span><span class="p">:</span> <span class="s2">""</span><span class="p">,</span>
|
||||
<span class="nt">"grace"</span><span class="p">:</span> <span class="mi">3600</span><span class="p">,</span>
|
||||
<span class="nt">"last_ping"</span><span class="p">:</span> <span class="kc">null</span><span class="p">,</span>
|
||||
<span class="nt">"n_pings"</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span>
|
||||
<span class="nt">"name"</span><span class="p">:</span> <span class="s2">"Api test 2"</span><span class="p">,</span>
|
||||
<span class="nt">"next_ping"</span><span class="p">:</span> <span class="kc">null</span><span class="p">,</span>
|
||||
<span class="nt">"schedule"</span><span class="p">:</span> <span class="s2">"0/10 * * * *"</span><span class="p">,</span>
|
||||
<span class="nt">"status"</span><span class="p">:</span> <span class="s2">"new"</span><span class="p">,</span>
|
||||
<span class="nt">"tags"</span><span class="p">:</span> <span class="s2">"bar baz"</span><span class="p">,</span>
|
||||
<span class="nt">"tz"</span><span class="p">:</span> <span class="s2">"UTC"</span><span class="p">,</span>
|
||||
<span class="nt">"unique_key"</span><span class="p">:</span> <span class="s2">"9b5fc29129560ff2c5c1803803a7415e4f80cf7e"</span>
|
||||
<span class="p">}</span>
|
||||
<span class="p">]</span>
|
||||
<span class="p">}</span>
|
||||
</pre></div>
|
|
@ -1,28 +0,0 @@
|
|||
{
|
||||
"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"
|
||||
}
|
||||
]
|
||||
}
|
|
@ -1,3 +0,0 @@
|
|||
<div class="highlight"><pre><span></span>curl {{ SITE_ROOT }}/api/v1/checks/0c8983c9-9d73-446f-adb5-0641fdacc9d4/pause <span class="se">\</span>
|
||||
--request POST --header <span class="s2">"X-Api-Key: your-api-key"</span> --data <span class="s2">""</span>
|
||||
</pre></div>
|
|
@ -1,2 +0,0 @@
|
|||
curl SITE_ROOT/api/v1/checks/0c8983c9-9d73-446f-adb5-0641fdacc9d4/pause \
|
||||
--request POST --header "X-Api-Key: your-api-key" --data ""
|
|
@ -1,16 +0,0 @@
|
|||
<div class="highlight"><pre><span></span><span class="p">{</span>
|
||||
<span class="nt">"channels"</span><span class="p">:</span> <span class="s2">""</span><span class="p">,</span>
|
||||
<span class="nt">"desc"</span><span class="p">:</span> <span class="s2">""</span><span class="p">,</span>
|
||||
<span class="nt">"grace"</span><span class="p">:</span> <span class="mi">60</span><span class="p">,</span>
|
||||
<span class="nt">"last_ping"</span><span class="p">:</span> <span class="kc">null</span><span class="p">,</span>
|
||||
<span class="nt">"n_pings"</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span>
|
||||
<span class="nt">"name"</span><span class="p">:</span> <span class="s2">"Backups"</span><span class="p">,</span>
|
||||
<span class="nt">"next_ping"</span><span class="p">:</span> <span class="kc">null</span><span class="p">,</span>
|
||||
<span class="nt">"pause_url"</span><span class="p">:</span> <span class="s2">"{{ SITE_ROOT }}/api/v1/checks/f618072a-7bde-4eee-af63-71a77c5723bc/pause"</span><span class="p">,</span>
|
||||
<span class="nt">"ping_url"</span><span class="p">:</span> <span class="s2">"{{ PING_ENDPOINT }}f618072a-7bde-4eee-af63-71a77c5723bc"</span><span class="p">,</span>
|
||||
<span class="nt">"status"</span><span class="p">:</span> <span class="s2">"paused"</span><span class="p">,</span>
|
||||
<span class="nt">"tags"</span><span class="p">:</span> <span class="s2">"prod www"</span><span class="p">,</span>
|
||||
<span class="nt">"timeout"</span><span class="p">:</span> <span class="mi">3600</span><span class="p">,</span>
|
||||
<span class="nt">"update_url"</span><span class="p">:</span> <span class="s2">"{{ SITE_ROOT }}/api/v1/checks/f618072a-7bde-4eee-af63-71a77c5723bc"</span>
|
||||
<span class="p">}</span>
|
||||
</pre></div>
|
|
@ -1,15 +0,0 @@
|
|||
{
|
||||
"channels": "",
|
||||
"desc": "",
|
||||
"grace": 60,
|
||||
"last_ping": null,
|
||||
"n_pings": 0,
|
||||
"name": "Backups",
|
||||
"next_ping": null,
|
||||
"pause_url": "SITE_ROOT/api/v1/checks/f618072a-7bde-4eee-af63-71a77c5723bc/pause",
|
||||
"ping_url": "PING_ENDPOINTf618072a-7bde-4eee-af63-71a77c5723bc",
|
||||
"status": "paused",
|
||||
"tags": "prod www",
|
||||
"timeout": 3600,
|
||||
"update_url": "SITE_ROOT/api/v1/checks/f618072a-7bde-4eee-af63-71a77c5723bc"
|
||||
}
|
|
@ -5,9 +5,9 @@
|
|||
<span class="c1"># Do your number crunching, backup dumping, newsletter sending work here.</span>
|
||||
<span class="c1"># Return a truthy value on success.</span>
|
||||
<span class="c1"># Return a falsy value or throw an exception on failure.</span>
|
||||
<span class="k">return</span> <span class="bp">True</span>
|
||||
<span class="k">return</span> <span class="kc">True</span>
|
||||
|
||||
<span class="n">success</span> <span class="o">=</span> <span class="bp">False</span>
|
||||
<span class="n">success</span> <span class="o">=</span> <span class="kc">False</span>
|
||||
<span class="k">try</span><span class="p">:</span>
|
||||
<span class="n">success</span> <span class="o">=</span> <span class="n">do_work</span><span class="p">()</span>
|
||||
<span class="k">finally</span><span class="p">:</span>
|
||||
|
|
|
@ -14,7 +14,7 @@
|
|||
|
||||
<span class="c1"># TODO: run the job here</span>
|
||||
<span class="n">fib</span> <span class="o">=</span> <span class="k">lambda</span> <span class="n">n</span><span class="p">:</span> <span class="n">n</span> <span class="k">if</span> <span class="n">n</span> <span class="o"><</span> <span class="mi">2</span> <span class="k">else</span> <span class="n">fib</span><span class="p">(</span><span class="n">n</span> <span class="o">-</span> <span class="mi">1</span><span class="p">)</span> <span class="o">+</span> <span class="n">fib</span><span class="p">(</span><span class="n">n</span> <span class="o">-</span> <span class="mi">2</span><span class="p">)</span>
|
||||
<span class="k">print</span><span class="p">(</span><span class="s2">"F(42) = </span><span class="si">%d</span><span class="s2">"</span> <span class="o">%</span> <span class="n">fib</span><span class="p">(</span><span class="mi">42</span><span class="p">))</span>
|
||||
<span class="nb">print</span><span class="p">(</span><span class="s2">"F(42) = </span><span class="si">%d</span><span class="s2">"</span> <span class="o">%</span> <span class="n">fib</span><span class="p">(</span><span class="mi">42</span><span class="p">))</span>
|
||||
|
||||
<span class="c1"># Signal success:</span>
|
||||
<span class="n">requests</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="n">URL</span><span class="p">)</span>
|
||||
|
|
|
@ -1,4 +0,0 @@
|
|||
<div class="highlight"><pre><span></span>curl {{ SITE_ROOT }}/api/v1/checks/f618072a-7bde-4eee-af63-71a77c5723bc <span class="se">\</span>
|
||||
--header <span class="s2">"X-Api-Key: your-api-key"</span> <span class="se">\</span>
|
||||
--data <span class="s1">'{"name": "Backups", "tags": "prod www", "timeout": 3600, "grace": 60}'</span>
|
||||
</pre></div>
|
|
@ -1,3 +0,0 @@
|
|||
curl SITE_ROOT/api/v1/checks/f618072a-7bde-4eee-af63-71a77c5723bc \
|
||||
--header "X-Api-Key: your-api-key" \
|
||||
--data '{"name": "Backups", "tags": "prod www", "timeout": 3600, "grace": 60}'
|
|
@ -1,3 +0,0 @@
|
|||
<div class="highlight"><pre><span></span>curl {{ SITE_ROOT }}/api/v1/checks/f618072a-7bde-4eee-af63-71a77c5723bc <span class="se">\</span>
|
||||
--data <span class="s1">'{"api_key": "your-api-key", "name": "Backups", "tags": "prod www", "timeout": 3600, "grace": 60}'</span>
|
||||
</pre></div>
|
|
@ -1,2 +0,0 @@
|
|||
curl SITE_ROOT/api/v1/checks/f618072a-7bde-4eee-af63-71a77c5723bc \
|
||||
--data '{"api_key": "your-api-key", "name": "Backups", "tags": "prod www", "timeout": 3600, "grace": 60}'
|
Loading…
Add table
Reference in a new issue