-
Notifications
You must be signed in to change notification settings - Fork 93
/
snapshots.html
70 lines (52 loc) · 15.5 KB
/
snapshots.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
<!DOCTYPE html> <html> <head> <title>snapshots.js</title> <meta http-equiv="content-type" content="text/html; charset=UTF-8"> <link rel="stylesheet" media="all" href="../../docco.css" /> </head> <body> <div id="container"> <div id="background"></div> <div id="jump_to"> Jump To … <div id="jump_wrapper"> <div id="jump_page"> <a class="source" href="../..//jitsu/api/apps.html"> jitsu/api/apps.html </a> <a class="source" href="../..//jitsu/api/client.html"> jitsu/api/client.html </a> <a class="source" href="../..//jitsu/api/snapshots.html"> jitsu/api/snapshots.html </a> <a class="source" href="../..//jitsu/api/users.html"> jitsu/api/users.html </a> <a class="source" href="../..//jitsu/commands/apps.html"> jitsu/commands/apps.html </a> <a class="source" href="../..//jitsu/commands/config.html"> jitsu/commands/config.html </a> <a class="source" href="../..//jitsu/commands/help.html"> jitsu/commands/help.html </a> <a class="source" href="../..//jitsu/commands/package.html"> jitsu/commands/package.html </a> <a class="source" href="../..//jitsu/commands/snapshots.html"> jitsu/commands/snapshots.html </a> <a class="source" href="../..//jitsu/commands/users.html"> jitsu/commands/users.html </a> <a class="source" href="../..//jitsu/commands.html"> jitsu/commands.html </a> <a class="source" href="../..//jitsu/config.html"> jitsu/config.html </a> <a class="source" href="../..//jitsu/package.html"> jitsu/package.html </a> <a class="source" href="../..//jitsu/properties.html"> jitsu/properties.html </a> <a class="source" href="../..//jitsu/utils/base64.html"> jitsu/utils/base64.html </a> <a class="source" href="../..//jitsu/utils/index.html"> jitsu/utils/index.html </a> <a class="source" href="../..//jitsu.html"> jitsu.html </a> </div> </div> </div> <table cellpadding="0" cellspacing="0"> <thead> <tr> <th class="docs"> <h1> snapshots.js </h1> </th> <th class="code"> </th> </tr> </thead> <tbody> <tr id="section-1"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-1">¶</a> </div> </td> <td class="code"> <div class="highlight"><pre><span class="cm">/*</span>
<span class="cm"> * snapshots.js: Client for the Nodejitsu snapshots API.</span>
<span class="cm"> *</span>
<span class="cm"> * (C) 2010, Nodejitsu Inc.</span>
<span class="cm"> *</span>
<span class="cm"> */</span>
<span class="kd">var</span> <span class="nx">util</span> <span class="o">=</span> <span class="nx">require</span><span class="p">(</span><span class="s1">'util'</span><span class="p">),</span>
<span class="nx">winston</span> <span class="o">=</span> <span class="nx">require</span><span class="p">(</span><span class="s1">'winston'</span><span class="p">),</span>
<span class="nx">jitsu</span> <span class="o">=</span> <span class="nx">require</span><span class="p">(</span><span class="s1">'jitsu'</span><span class="p">);</span></pre></div> </td> </tr> <tr id="section-2"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-2">¶</a> </div> <h3>function Snapshots (options)</h3>
<h4>@options {Object} Options for this instance</h4>
<p>Constructor function for the Apps resource responsible
with Nodejitsu's Snapshots API</p> </td> <td class="code"> <div class="highlight"><pre><span class="kd">var</span> <span class="nx">Snapshots</span> <span class="o">=</span> <span class="nx">exports</span><span class="p">.</span><span class="nx">Snapshots</span> <span class="o">=</span> <span class="kd">function</span> <span class="p">(</span><span class="nx">options</span><span class="p">)</span> <span class="p">{</span>
<span class="nx">jitsu</span><span class="p">.</span><span class="nx">api</span><span class="p">.</span><span class="nx">Client</span><span class="p">.</span><span class="nx">call</span><span class="p">(</span><span class="k">this</span><span class="p">,</span> <span class="nx">options</span><span class="p">);</span>
<span class="p">};</span></pre></div> </td> </tr> <tr id="section-3"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-3">¶</a> </div> <p>Inherit from Client base object</p> </td> <td class="code"> <div class="highlight"><pre><span class="nx">util</span><span class="p">.</span><span class="nx">inherits</span><span class="p">(</span><span class="nx">Snapshots</span><span class="p">,</span> <span class="nx">jitsu</span><span class="p">.</span><span class="nx">api</span><span class="p">.</span><span class="nx">Client</span><span class="p">);</span></pre></div> </td> </tr> <tr id="section-4"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-4">¶</a> </div> <h3>function list (name, callback)</h3>
<h4>@name {string} Name of the application to list snapshots for.</h4>
<h4>@callback {function} Continuation to pass control to when complete</h4>
<p>Lists all applications for the authenticated user</p> </td> <td class="code"> <div class="highlight"><pre><span class="nx">Snapshots</span><span class="p">.</span><span class="nx">prototype</span><span class="p">.</span><span class="nx">list</span> <span class="o">=</span> <span class="kd">function</span> <span class="p">(</span><span class="nx">name</span><span class="p">,</span> <span class="nx">callback</span><span class="p">)</span> <span class="p">{</span>
<span class="nx">winston</span><span class="p">.</span><span class="nx">info</span><span class="p">(</span><span class="s1">'Listing snapshots for '</span> <span class="o">+</span> <span class="nx">name</span><span class="p">.</span><span class="nx">magenta</span><span class="p">);</span>
<span class="k">this</span><span class="p">.</span><span class="nx">_request</span><span class="p">(</span><span class="s1">'GET'</span><span class="p">,</span> <span class="p">[</span><span class="s1">'apps'</span><span class="p">,</span> <span class="nx">jitsu</span><span class="p">.</span><span class="nx">config</span><span class="p">.</span><span class="nx">username</span><span class="p">,</span> <span class="nx">name</span><span class="p">,</span> <span class="s1">'snapshots'</span><span class="p">],</span> <span class="nx">callback</span><span class="p">,</span> <span class="kd">function</span> <span class="p">(</span><span class="nx">res</span><span class="p">,</span> <span class="nx">result</span><span class="p">)</span> <span class="p">{</span>
<span class="nx">callback</span><span class="p">(</span><span class="kc">null</span><span class="p">,</span> <span class="nx">result</span><span class="p">.</span><span class="nx">snapshots</span><span class="p">);</span>
<span class="p">});</span>
<span class="p">};</span></pre></div> </td> </tr> <tr id="section-5"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-5">¶</a> </div> <h3>function create (name, snapshot, callback)</h3>
<h4>@name {string} Name of the application to create a snapshot for.</h4>
<h4>@snapshot {Buffer} Data for the application snapshot (tar+gzip).</h4>
<h4>@callback {function} Continuation to pass control to when complete</h4>
<p>Creates a snapshot for the application with <code>app.name = name</code> using
the <code>*.tgz</code> package data in <code>snapshot</code>. </p> </td> <td class="code"> <div class="highlight"><pre><span class="nx">Snapshots</span><span class="p">.</span><span class="nx">prototype</span><span class="p">.</span><span class="nx">create</span> <span class="o">=</span> <span class="kd">function</span> <span class="p">(</span><span class="nx">appName</span><span class="p">,</span> <span class="nx">snapshotName</span><span class="p">,</span> <span class="nx">filename</span><span class="p">,</span> <span class="nx">callback</span><span class="p">)</span> <span class="p">{</span>
<span class="kd">var</span> <span class="nx">url</span> <span class="o">=</span> <span class="p">[</span><span class="s1">'apps'</span><span class="p">,</span> <span class="nx">jitsu</span><span class="p">.</span><span class="nx">config</span><span class="p">.</span><span class="nx">username</span><span class="p">,</span> <span class="nx">appName</span><span class="p">,</span> <span class="s1">'snapshots'</span><span class="p">,</span> <span class="nx">snapshotName</span><span class="p">];</span>
<span class="k">this</span><span class="p">.</span><span class="nx">_upload</span><span class="p">(</span><span class="nx">url</span><span class="p">,</span> <span class="s1">'application/octet-stream'</span><span class="p">,</span> <span class="nx">filename</span><span class="p">,</span> <span class="nx">callback</span><span class="p">,</span> <span class="kd">function</span> <span class="p">(</span><span class="nx">res</span><span class="p">,</span> <span class="nx">body</span><span class="p">)</span> <span class="p">{</span>
<span class="nx">callback</span><span class="p">(</span><span class="kc">null</span><span class="p">);</span>
<span class="p">});</span>
<span class="p">};</span></pre></div> </td> </tr> <tr id="section-6"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-6">¶</a> </div> <h3>function create (name, snapshot, callback)</h3>
<h4>@name {string} Name of the application to destroy a snapshot for.</h4>
<h4>@callback {function} Continuation to pass control to when complete</h4>
<p>Destroys a snapshot for the application with <code>app.name = name</code> and
<code>snapshot.id === snapshotName</code>.</p> </td> <td class="code"> <div class="highlight"><pre><span class="nx">Snapshots</span><span class="p">.</span><span class="nx">prototype</span><span class="p">.</span><span class="nx">destroy</span> <span class="o">=</span> <span class="kd">function</span> <span class="p">(</span><span class="nx">appName</span><span class="p">,</span> <span class="nx">snapshotName</span><span class="p">,</span> <span class="nx">callback</span><span class="p">)</span> <span class="p">{</span>
<span class="kd">var</span> <span class="nx">url</span> <span class="o">=</span> <span class="p">[</span><span class="s1">'apps'</span><span class="p">,</span> <span class="nx">jitsu</span><span class="p">.</span><span class="nx">config</span><span class="p">.</span><span class="nx">username</span><span class="p">,</span> <span class="nx">appName</span><span class="p">,</span> <span class="s1">'snapshots'</span><span class="p">,</span> <span class="nx">snapshotName</span><span class="p">];</span>
<span class="k">this</span><span class="p">.</span><span class="nx">_request</span><span class="p">(</span><span class="s1">'DELETE'</span><span class="p">,</span> <span class="nx">url</span><span class="p">,</span> <span class="nx">callback</span><span class="p">,</span> <span class="kd">function</span> <span class="p">(</span><span class="nx">res</span><span class="p">,</span> <span class="nx">body</span><span class="p">)</span> <span class="p">{</span>
<span class="nx">callback</span><span class="p">();</span>
<span class="p">});</span>
<span class="p">};</span></pre></div> </td> </tr> <tr id="section-7"> <td class="docs"> <div class="pilwrap"> <a class="pilcrow" href="#section-7">¶</a> </div> <h3>function activate (name, snapshot, callback)</h3>
<h4>@name {string} Name of the application to activate a snapshot for.</h4>
<h4>@snapshot {string} Name of the snapshot to activate.</h4>
<h4>@callback {function} Continuation to pass control to when complete</h4>
<p>Activates a snapshot for the application with <code>app.name = name</code> and
<code>snapshot.id === snapshotName</code>.</p> </td> <td class="code"> <div class="highlight"><pre><span class="nx">Snapshots</span><span class="p">.</span><span class="nx">prototype</span><span class="p">.</span><span class="nx">activate</span> <span class="o">=</span> <span class="kd">function</span> <span class="p">(</span><span class="nx">appName</span><span class="p">,</span> <span class="nx">snapshotName</span><span class="p">,</span> <span class="nx">callback</span><span class="p">)</span> <span class="p">{</span>
<span class="kd">var</span> <span class="nx">url</span> <span class="o">=</span> <span class="p">[</span><span class="s1">'apps'</span><span class="p">,</span> <span class="nx">jitsu</span><span class="p">.</span><span class="nx">config</span><span class="p">.</span><span class="nx">username</span><span class="p">,</span> <span class="nx">appName</span><span class="p">,</span> <span class="s1">'snapshots'</span><span class="p">,</span> <span class="nx">snapshotName</span><span class="p">,</span> <span class="s1">'activate'</span><span class="p">];</span>
<span class="k">this</span><span class="p">.</span><span class="nx">_request</span><span class="p">(</span><span class="s1">'POST'</span><span class="p">,</span> <span class="nx">url</span><span class="p">,</span> <span class="nx">callback</span><span class="p">,</span> <span class="kd">function</span> <span class="p">(</span><span class="nx">res</span><span class="p">,</span> <span class="nx">body</span><span class="p">)</span> <span class="p">{</span>
<span class="nx">callback</span><span class="p">();</span>
<span class="p">});</span>
<span class="p">};</span>
</pre></div> </td> </tr> </tbody> </table> </div> </body> </html>