forked from GithubBackups/healthchecks
Adding Docs > Cloning Checks
This commit is contained in:
parent
bf1294a100
commit
5d513658e3
BIN
static/img/docs/create_copy.png
Normal file
BIN
static/img/docs/create_copy.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 37 KiB |
29
templates/docs/cloning_checks.html
Normal file
29
templates/docs/cloning_checks.html
Normal file
@ -0,0 +1,29 @@
|
||||
<h1>Cloning Checks</h1>
|
||||
<p>You can individually clone individual checks SITE_NAME from the "Check Details"
|
||||
page:</p>
|
||||
<p><img alt="The "Create a Copy" button" src="IMG_URL/create_copy.png" /></p>
|
||||
<p>The "Create a Copy..." function creates a new check in the same project, and copies
|
||||
over the following:</p>
|
||||
<ul>
|
||||
<li>Name, tags, description</li>
|
||||
<li>Schedule</li>
|
||||
<li>Assigned notification methods</li>
|
||||
</ul>
|
||||
<p>The newly created check has a different ping URL and it starts with an empty log.</p>
|
||||
<h2>Cloning All Checks Into a New Project</h2>
|
||||
<p>It is sometimes useful to clone an entire project. For example, when recreating
|
||||
an existing deployment in a new region. The SITE_NAME web interface does
|
||||
not have a function to clone an entire project, but this can be done relatively
|
||||
easily using the <a href="../api/">Management API</a> calls. Below is an example using Python
|
||||
and the requests library:</p>
|
||||
<div class="highlight"><pre><span></span><code><span class="kn">import</span> <span class="nn">requests</span>
|
||||
|
||||
<span class="n">API_URL</span> <span class="o">=</span> <span class="s2">"SITE_ROOT/api/v1/checks/"</span>
|
||||
<span class="n">SOURCE_PROJECT_READONLY_KEY</span> <span class="o">=</span> <span class="s2">"..."</span>
|
||||
<span class="n">TARGET_PROJECT_KEY</span> <span class="o">=</span> <span class="s2">"..."</span>
|
||||
|
||||
<span class="n">r</span> <span class="o">=</span> <span class="n">requests</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="n">API_URL</span><span class="p">,</span> <span class="n">headers</span><span class="o">=</span><span class="p">{</span><span class="s2">"X-Api-Key"</span><span class="p">:</span> <span class="n">SOURCE_PROJECT_READONLY_KEY</span><span class="p">})</span>
|
||||
<span class="k">for</span> <span class="n">check</span> <span class="ow">in</span> <span class="n">r</span><span class="o">.</span><span class="n">json</span><span class="p">()[</span><span class="s2">"checks"</span><span class="p">]:</span>
|
||||
<span class="nb">print</span><span class="p">(</span><span class="s2">"Cloning </span><span class="si">%s</span><span class="s2">"</span> <span class="o">%</span> <span class="n">check</span><span class="p">[</span><span class="s2">"name"</span><span class="p">])</span>
|
||||
<span class="n">requests</span><span class="o">.</span><span class="n">post</span><span class="p">(</span><span class="n">API_URL</span><span class="p">,</span> <span class="n">json</span><span class="o">=</span><span class="n">check</span><span class="p">,</span> <span class="n">headers</span><span class="o">=</span><span class="p">{</span><span class="s2">"X-Api-Key"</span><span class="p">:</span> <span class="n">TARGET_PROJECT_KEY</span><span class="p">})</span>
|
||||
</code></pre></div>
|
36
templates/docs/cloning_checks.md
Normal file
36
templates/docs/cloning_checks.md
Normal file
@ -0,0 +1,36 @@
|
||||
# Cloning Checks
|
||||
|
||||
You can individually clone individual checks SITE_NAME from the "Check Details"
|
||||
page:
|
||||
|
||||

|
||||
|
||||
The "Create a Copy..." function creates a new check in the same project, and copies
|
||||
over the following:
|
||||
|
||||
* Name, tags, description
|
||||
* Schedule
|
||||
* Assigned notification methods
|
||||
|
||||
The newly created check has a different ping URL and it starts with an empty log.
|
||||
|
||||
## Cloning All Checks Into a New Project
|
||||
|
||||
It is sometimes useful to clone an entire project. For example, when recreating
|
||||
an existing deployment in a new region. The SITE_NAME web interface does
|
||||
not have a function to clone an entire project, but this can be done relatively
|
||||
easily using the [Management API](../api/) calls. Below is an example using Python
|
||||
and the requests library:
|
||||
|
||||
```python
|
||||
import requests
|
||||
|
||||
API_URL = "SITE_ROOT/api/v1/checks/"
|
||||
SOURCE_PROJECT_READONLY_KEY = "..."
|
||||
TARGET_PROJECT_KEY = "..."
|
||||
|
||||
r = requests.get(API_URL, headers={"X-Api-Key": SOURCE_PROJECT_READONLY_KEY})
|
||||
for check in r.json()["checks"]:
|
||||
print("Cloning %s" % check["name"])
|
||||
requests.post(API_URL, json=check, headers={"X-Api-Key": TARGET_PROJECT_KEY})
|
||||
```
|
@ -31,6 +31,7 @@
|
||||
{% include "front/docs_nav_item.html" with slug="signalling_failures" title="Signalling failures" %}
|
||||
{% include "front/docs_nav_item.html" with slug="measuring_script_run_time" title="Measuring script run time" %}
|
||||
{% include "front/docs_nav_item.html" with slug="attaching_logs" title="Attaching logs" %}
|
||||
{% include "front/docs_nav_item.html" with slug="cloning_checks" title="Cloning Checks" %}
|
||||
|
||||
<li class="nav-header">Developer Tools</li>
|
||||
{% include "front/docs_nav_item.html" with slug="api" title="Management API" %}
|
||||
|
Loading…
x
Reference in New Issue
Block a user