|
<h1>Cloning Checks</h1>
|
|
<p>You can clone individual checks 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 you can clone all checks in the
|
|
project relatively easily using the <a href="../api/">Management API</a> calls.
|
|
Below is an example using Python and the <a href="https://requests.readthedocs.io/en/master/">requests</a> library:</p>
|
|
<div class="python 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>
|