Browse Source

Mention SITE_NAME in README, better docs for the `unique` API field.

pull/90/head
Pēteris Caune 8 years ago
parent
commit
9a00fd9944
4 changed files with 72 additions and 17 deletions
  1. +25
    -5
      README.md
  2. +6
    -6
      hc/settings.py
  3. +8
    -0
      static/css/docs.css
  4. +33
    -6
      templates/front/docs_api.html

+ 25
- 5
README.md View File

@ -67,6 +67,26 @@ The site should now be running at `http://localhost:8080`
To log into Django administration site as a super user,
visit `http://localhost:8080/admin`
## Configuration
Site configuration is kept in `hc/settings.py`. Additional configuration
is loaded from `hc/local_settings.py` file, if it exists. You
can create this file (should be right next to `settings.py` in the filesystem)
and override settings as needed.
Some useful settings keys to override are:
`SITE_ROOT` is used to build fully qualified URLs for pings, and for use in
emails and notifications. Example:
SITE_ROOT = "https://my-monitoring-project.com"`
`SITE_NAME` has the default value of "healthchecks.io" and is used throughout
the templates. Replace it with your own name to personalize your installation.
Example:
SITE_NAME = "My Monitoring Project"
## Database Configuration
Database configuration is stored in `hc/settings.py` and can be overriden
@ -112,7 +132,6 @@ configuration from environment variables like so:
}
## Sending Emails
healthchecks must be able to send email messages, so it can send out login
@ -125,6 +144,7 @@ scenes. For example, the healthchecks.io site uses
[django-ses-backend](https://github.com/piotrbulinski/django-ses-backend/)
and the email configuration in `hc/local_settings.py` looks as follows:
DEFAULT_FROM_EMAIL = '[email protected]'
DJMAIL_REAL_BACKEND = 'django_ses_backend.SESBackend'
AWS_SES_ACCESS_KEY_ID = "put-access-key-here"
AWS_SES_SECRET_ACCESS_KEY = "put-secret-access-key-here"
@ -180,11 +200,11 @@ There are separate Django management commands for each task:
```
$ ./manage.py pruneusers
```
```
When you first try these commands on your data, it is a good idea to
test them on a copy of your database, not on the live database right away.
In a production setup, you should also have regular, automated database
When you first try these commands on your data, it is a good idea to
test them on a copy of your database, not on the live database right away.
In a production setup, you should also have regular, automated database
backups set up.
## Integrations


+ 6
- 6
hc/settings.py View File

@ -84,7 +84,7 @@ TEST_RUNNER = 'hc.api.tests.CustomRunner'
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.sqlite3',
'NAME': './hc.sqlite',
'NAME': './hc.sqlite',
}
}
@ -93,9 +93,9 @@ DATABASES = {
if os.environ.get("DB") == "postgres":
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.postgresql',
'NAME': 'hc',
'USER': 'postgres',
'ENGINE': 'django.db.backends.postgresql',
'USER': 'postgres',
'NAME': 'hc',
'TEST': {'CHARSET': 'UTF8'}
}
}
@ -104,8 +104,8 @@ if os.environ.get("DB") == "mysql":
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.mysql',
'USER': 'root',
'NAME': 'hc',
'USER': 'root',
'NAME': 'hc',
'TEST': {'CHARSET': 'UTF8'}
}
}


+ 8
- 0
static/css/docs.css View File

@ -50,4 +50,12 @@ a.section {
a.section:hover {
text-decoration: none;
}
.page-docs code {
padding: 2px 4px;
font-size: 90%;
color: #427d5e;
background-color: #f2f9f6;
border-radius: 4px;
}

+ 33
- 6
templates/front/docs_api.html View File

@ -35,7 +35,7 @@ its value should be your API key.
<p>
For POST requests, the {% site_name %} API expects request body to be
a JSON document (<em>not</em> a <code>mulitpart/form-data</code> encoded
a JSON document (<em>not</em> a <code>multipart/form-data</code> encoded
form data).
</p>
@ -99,6 +99,8 @@ The response may contain a JSON document with additional data.
<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>
@ -107,6 +109,8 @@ The response may contain a JSON document with additional data.
<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: 604800 (one week).</p>
<p>Example for 5 minute timeout:</p>
<pre>{"timeout": 300}</pre>
</td>
</tr>
<tr>
@ -130,15 +134,38 @@ The response may contain a JSON document with additional data.
<tr>
<th>unique</th>
<td>
<p>array of strings, optional, default value: [].</p>
<p>Tells the API to only create a new check if the combination of fields
in <code>unqiue</code> is unique. The fields currently supported are
name, tags, timeout, and grace. If a new check is created the API returns
a 201 code, otherwise it returns a 200 code.</p>
<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>
</table>
<h3 class="api-section">Example Request</h3>
{% include "front/snippets/create_check_request.html" %}


Loading…
Cancel
Save