Browse Source

Adding Docs > Cloning Checks

pull/342/head
Pēteris Caune 5 years ago
parent
commit
5d513658e3
No known key found for this signature in database GPG Key ID: E28D7679E9A9EDE2
4 changed files with 66 additions and 0 deletions
  1. BIN
      static/img/docs/create_copy.png
  2. +29
    -0
      templates/docs/cloning_checks.html
  3. +36
    -0
      templates/docs/cloning_checks.md
  4. +1
    -0
      templates/front/base_docs.html

BIN
static/img/docs/create_copy.png View File

Before After
Width: 562  |  Height: 474  |  Size: 37 KiB

+ 29
- 0
templates/docs/cloning_checks.html View 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 &quot;Create a Copy&quot; button" src="IMG_URL/create_copy.png" /></p>
<p>The "Create a Copy..." function creates a new check in the same project, and copies
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">&quot;SITE_ROOT/api/v1/checks/&quot;</span>
<span class="n">SOURCE_PROJECT_READONLY_KEY</span> <span class="o">=</span> <span class="s2">&quot;...&quot;</span>
<span class="n">TARGET_PROJECT_KEY</span> <span class="o">=</span> <span class="s2">&quot;...&quot;</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">&quot;X-Api-Key&quot;</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">&quot;checks&quot;</span><span class="p">]:</span>
<span class="nb">print</span><span class="p">(</span><span class="s2">&quot;Cloning </span><span class="si">%s</span><span class="s2">&quot;</span> <span class="o">%</span> <span class="n">check</span><span class="p">[</span><span class="s2">&quot;name&quot;</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">&quot;X-Api-Key&quot;</span><span class="p">:</span> <span class="n">TARGET_PROJECT_KEY</span><span class="p">})</span>
</code></pre></div>

+ 36
- 0
templates/docs/cloning_checks.md View File

@ -0,0 +1,36 @@
# Cloning Checks
You can individually clone individual checks SITE_NAME from the "Check Details"
page:
![The "Create a Copy" button](IMG_URL/create_copy.png)
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})
```

+ 1
- 0
templates/front/base_docs.html View File

@ -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="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="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="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> <li class="nav-header">Developer Tools</li>
{% include "front/docs_nav_item.html" with slug="api" title="Management API" %} {% include "front/docs_nav_item.html" with slug="api" title="Management API" %}


Loading…
Cancel
Save