forked from docker/docs
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
6579 lines (5571 loc) · 405 KB
/
index.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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<meta content="IE=edge,chrome=1" http-equiv="X-UA-Compatible">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
<title>Docker Cloud API reference</title>
<link href="stylesheets/screen.css" rel="stylesheet" type="text/css" media="screen" />
<link href="stylesheets/print.css" rel="stylesheet" type="text/css" media="print" />
<script type="text/javascript">
!function(){var analytics=window.analytics=window.analytics||[];if(!analytics.initialize)if(analytics.invoked)window.console&&console.error&&console.error("Segment snippet included twice.");else{analytics.invoked=!0;analytics.methods=["trackSubmit","trackClick","trackLink","trackForm","pageview","identify","reset","group","track","ready","alias","debug","page","once","off","on"];analytics.factory=function(t){return function(){var e=Array.prototype.slice.call(arguments);e.unshift(t);analytics.push(e);return analytics}};for(var t=0;t<analytics.methods.length;t++){var e=analytics.methods[t];analytics[e]=analytics.factory(e)}analytics.load=function(t){var e=document.createElement("script");e.type="text/javascript";e.async=!0;e.src=("https:"===document.location.protocol?"https://":"http://")+"cdn.segment.com/analytics.js/v1/"+t+"/analytics.min.js";var n=document.getElementsByTagName("script")[0];n.parentNode.insertBefore(e,n)};analytics.SNIPPET_VERSION="4.0.0";
analytics.load("IWj9D0UpZHZdZUZX9jl98PcpBFWBnBMy");
analytics.page();
}}();
</script>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.3/jquery.min.js"></script>
<script src="javascripts/all.js" type="text/javascript"></script>
<script>
$(function() {
setupLanguages(["http","go","python","shell"]);
});
</script>
</head>
<body class="index">
<a href="#" id="nav-button">
<span>
NAV
<img src="images/navbar.png" />
</span>
</a>
<div class="tocify-wrapper">
<div class="logo">
<img src="images/docker-cloud.svg" />
</div>
<div class="lang-selector">
<a href="#" data-language-name="http">http</a>
<a href="#" data-language-name="go">go</a>
<a href="#" data-language-name="python">python</a>
<a href="#" data-language-name="shell">CLI</a>
</div>
<div class="search">
<input type="text" class="search" id="input-search" placeholder="Search">
</div>
<ul class="search-results"></ul>
<div id="toc">
</div>
</div>
<div class="page-wrapper">
<div class="dark-box"></div>
<div class="content">
<h1 id="introduction">Introduction</h1>
<p>Docker Cloud currently offers a <strong>HTTP REST API</strong> and a <strong>Websocket Stream API</strong> which are used by both the <a href="https://cloud.docker.com/">Web UI</a> and the <a href="https://github.com/docker/dockercloud-cli">CLI</a>. This API documentation contains all API operations currently supported in the platform and provides examples of how to execute them using our Command Line Interface (CLI), <a href="https://github.com/docker/python-dockercloud">Python SDK</a> and <a href="https://github.com/docker/go-dockercloud">Go SDK</a>.</p>
<h1 id="authentication">Authentication</h1>
<p>In order to be able to make requests to the Docker Cloud API, you should first obtain an ApiKey for your account. For this, log into Docker Cloud, click on the menu on the upper right corner of the screen, select <strong>Account info</strong> and then select <strong>API keys</strong>.</p>
<h2 id="rest-api">REST API</h2>
<pre class="highlight python"><code><span class="kn">import</span> <span class="nn">dockercloud</span>
<span class="n">dockercloud</span><span class="o">.</span><span class="n">user</span> <span class="o">=</span> <span class="s">"username"</span>
<span class="n">dockercloud</span><span class="o">.</span><span class="n">apikey</span> <span class="o">=</span> <span class="s">"apikey"</span>
</code></pre>
<pre class="highlight go"><code><span class="k">import</span><span class="x"> </span><span class="s">"github.com/docker/go-dockercloud/dockercloud"</span><span class="x">
</span><span class="n">dockercloud</span><span class="o">.</span><span class="n">User</span><span class="x"> </span><span class="o">=</span><span class="x"> </span><span class="s">"username"</span><span class="x">
</span><span class="n">dockercloud</span><span class="o">.</span><span class="n">ApiKey</span><span class="x"> </span><span class="o">=</span><span class="x"> </span><span class="s">"apikey"</span><span class="x">
</span></code></pre>
<pre class="highlight http"><code><span class="nf">GET</span> <span class="nn">/api/app/v1/service/</span> <span class="k">HTTP</span><span class="o">/</span><span class="m">1.1</span>
<span class="na">Host</span><span class="p">:</span> <span class="s">cloud.docker.com</span>
<span class="na">Authorization</span><span class="p">:</span> <span class="s">Basic dXNlcm5hbWU6YXBpa2V5</span>
<span class="na">Accept</span><span class="p">:</span> <span class="s">application/json</span>
</code></pre>
<pre class="highlight shell"><code><span class="nb">export </span><span class="nv">DOCKERCLOUD_USER</span><span class="o">=</span>username
<span class="nb">export </span><span class="nv">DOCKERCLOUD_APIKEY</span><span class="o">=</span>apikey
</code></pre>
<blockquote>
<p>Make sure to replace <code class="prettyprint">username</code> with your username and <code class="prettyprint">apikey</code> with your API key.</p>
</blockquote>
<p>The Docker Cloud REST API is reachable through the following hostname:</p>
<p><code class="prettyprint">https://cloud.docker.com/</code></p>
<p>All requests should be sent to this endpoint using <code class="prettyprint">Basic</code> authentication using your API key as password:</p>
<p><code class="prettyprint">Authorization: Basic dXNlcm5hbWU6YXBpa2V5</code></p>
<p>HTTP responses are given in JSON format, so the following <code class="prettyprint">Accept</code> header is required for every API call:</p>
<p><code class="prettyprint">Accept: application/json</code></p>
<h3 id="namespaced-endpoints">Namespaced endpoints</h3>
<p>Endpoints that are labeled as “namespaced” allow the users to operate over
different namespaces, for example over an individual user namespace, or the
namespace of an organization the user is a member of. A namespace identifies the
owner of the resource.</p>
<p>The namespace is optional. If left blank, it defaults to the authenticated user
in the request. The namespace is set before the resource in the URL schema:
<code class="prettyprint">https://cloud.docker.com/api/<subsystem>/<version>/(optional_namespace/)<resource>/</code></p>
<p>Examples:</p>
<ul>
<li>The user <code class="prettyprint">exampleuser</code> wants to operate on the node cluster list endpoint in their own namespace. They can use either of the following urls:
<ul>
<li>https://cloud.docker.com/api/infra/v1/nodecluster/ (namespace omitted, so will use the user authenticated in the request)</li>
<li>https://cloud.docker.com/api/infra/v1/exampleuser/nodecluster/</li>
</ul></li>
<li>The user wants to operate on the node cluster list endpoint in an organization called <code class="prettyprint">exampleorg</code> (which they have permission to see):
<ul>
<li>https://cloud.docker.com/api/infra/v1/exampleorg/nodecluster/</li>
</ul></li>
</ul>
<h3 id="namespaced-endpoints-in-the-docker-cloud-cli">Namespaced endpoints in the docker-cloud CLI</h3>
<p>If you are using namespaces with the <code class="prettyprint">docker-cloud</code> CLI, set them by changing
the value of the <code class="prettyprint">DOCKERCLOUD_NAMESPACE</code> environment variable. You can either
set this globally, or specify it before each CLI command. To learn more, see the
<a href="https://github.com/docker/dockercloud-cli#namespace">Docker Cloud CLI README</a>.</p>
<h2 id="stream-api">Stream API</h2>
<pre class="highlight python"><code><span class="kn">import</span> <span class="nn">websocket</span>
<span class="kn">import</span> <span class="nn">base64</span>
<span class="n">header</span> <span class="o">=</span> <span class="s">"Authorization: Basic </span><span class="si">%</span><span class="s">s"</span> <span class="o">%</span> <span class="n">base64</span><span class="o">.</span><span class="n">b64encode</span><span class="p">(</span><span class="s">"</span><span class="si">%</span><span class="s">s:</span><span class="si">%</span><span class="s">s"</span> <span class="o">%</span> <span class="p">(</span><span class="n">username</span><span class="p">,</span> <span class="n">password</span><span class="p">))</span>
<span class="n">ws</span> <span class="o">=</span> <span class="n">websocket</span><span class="o">.</span><span class="n">WebSocketApp</span><span class="p">(</span><span class="s">'wss://ws.cloud.docker.com/v1/events'</span><span class="p">,</span> <span class="n">header</span><span class="o">=</span><span class="p">[</span><span class="n">header</span><span class="p">])</span>
</code></pre>
<pre class="highlight go"><code><span class="k">import</span><span class="x"> </span><span class="s">"github.com/gorilla/websocket"</span><span class="x">
</span><span class="k">import</span><span class="x"> </span><span class="s">"encoding/base64"</span><span class="x">
</span><span class="k">var</span><span class="x"> </span><span class="n">StreamUrl</span><span class="x"> </span><span class="o">=</span><span class="x"> </span><span class="s">"wss://ws.cloud.docker.com:443/v1/events"</span><span class="x">
</span><span class="n">sEnc</span><span class="x"> </span><span class="o">:=</span><span class="x"> </span><span class="n">base64</span><span class="o">.</span><span class="n">StdEncoding</span><span class="o">.</span><span class="n">EncodeToString</span><span class="p">([]</span><span class="kt">byte</span><span class="p">(</span><span class="n">User</span><span class="x"> </span><span class="o">+</span><span class="x"> </span><span class="s">":"</span><span class="x"> </span><span class="o">+</span><span class="x"> </span><span class="n">ApiKey</span><span class="p">))</span><span class="x">
</span><span class="n">header</span><span class="x"> </span><span class="o">:=</span><span class="x"> </span><span class="n">http</span><span class="o">.</span><span class="n">Header</span><span class="p">{}</span><span class="x">
</span><span class="n">header</span><span class="o">.</span><span class="n">Add</span><span class="p">(</span><span class="s">"Authorization"</span><span class="p">,</span><span class="x"> </span><span class="n">fmt</span><span class="o">.</span><span class="n">Sprintf</span><span class="p">(</span><span class="s">"Basic %s"</span><span class="p">,</span><span class="x"> </span><span class="n">sEnc</span><span class="p">))</span><span class="x">
</span><span class="k">var</span><span class="x"> </span><span class="n">Dialer</span><span class="x"> </span><span class="n">websocket</span><span class="o">.</span><span class="n">Dialer</span><span class="x">
</span><span class="n">ws</span><span class="p">,</span><span class="x"> </span><span class="n">_</span><span class="p">,</span><span class="x"> </span><span class="n">err</span><span class="x"> </span><span class="o">:=</span><span class="x"> </span><span class="n">Dialer</span><span class="o">.</span><span class="n">Dial</span><span class="p">(</span><span class="n">url</span><span class="p">,</span><span class="x"> </span><span class="n">header</span><span class="p">)</span><span class="x">
</span><span class="k">if</span><span class="x"> </span><span class="n">err</span><span class="x"> </span><span class="o">!=</span><span class="x"> </span><span class="no">nil</span><span class="x"> </span><span class="p">{</span><span class="x">
</span><span class="n">log</span><span class="o">.</span><span class="n">Println</span><span class="p">(</span><span class="n">err</span><span class="p">)</span><span class="x">
</span><span class="p">}</span><span class="x">
</span></code></pre>
<pre class="highlight http"><code><span class="nf">GET</span> <span class="nn">/api/audit/v1/events</span> <span class="k">HTTP</span><span class="o">/</span><span class="m">1.1</span>
<span class="na">Host</span><span class="p">:</span> <span class="s">ws.cloud.docker.com</span>
<span class="na">Authorization</span><span class="p">:</span> <span class="s">Basic dXNlcm5hbWU6YXBpa2V5</span>
<span class="na">Connection</span><span class="p">:</span> <span class="s">Upgrade</span>
<span class="na">Upgrade</span><span class="p">:</span> <span class="s">websocket</span>
</code></pre>
<pre class="highlight shell"><code><span class="nb">export </span><span class="nv">DOCKERCLOUD_USER</span><span class="o">=</span>username
<span class="nb">export </span><span class="nv">DOCKERCLOUD_APIKEY</span><span class="o">=</span>apikey
</code></pre>
<blockquote>
<p>Make sure to replace <code class="prettyprint">username</code> with your username and <code class="prettyprint">apikey</code> with your API key.</p>
</blockquote>
<p>The Docker Cloud Stream API is reachable through the following hostname:</p>
<p><code class="prettyprint">wss://ws.cloud.docker.com/</code></p>
<p>The Stream API requires the same authentication mechanism as the REST API:</p>
<p><code class="prettyprint">Authorization: Basic dXNlcm5hbWU6YXBpa2V5</code></p>
<h2 id="api-roles">API roles</h2>
<blockquote>
<p>The CLI and the SDKs will detect this environment variable and automatically use it</p>
</blockquote>
<p>If you give an <a href="/docker-cloud/apps/api-roles/">API role</a> to a container, the environment variable <code class="prettyprint">DOCKERCLOUD_AUTH</code> inside the container will have the contents of the <code class="prettyprint">Authorization</code> header that you can use to authenticate against the REST or Stream APIs:</p>
<p><code class="prettyprint">curl -H "Authorization: $DOCKERCLOUD_AUTH" https://cloud.docker.com/api/app/v1/service/</code></p>
<h1 id="actions">Actions</h1>
<h2 id="action">Action</h2>
<blockquote>
<p>Example</p>
</blockquote>
<pre class="highlight json"><code><span class="p">{</span><span class="w">
</span><span class="nt">"action"</span><span class="p">:</span><span class="w"> </span><span class="s2">"Cluster Create"</span><span class="p">,</span><span class="w">
</span><span class="nt">"end_date"</span><span class="p">:</span><span class="w"> </span><span class="s2">"Wed, 17 Sep 2014 08:26:22 +0000"</span><span class="p">,</span><span class="w">
</span><span class="nt">"ip"</span><span class="p">:</span><span class="w"> </span><span class="s2">"56.78.90.12"</span><span class="p">,</span><span class="w">
</span><span class="nt">"is_user_action"</span><span class="p">:</span><span class="w"> </span><span class="kc">true</span><span class="p">,</span><span class="w">
</span><span class="nt">"can_be_canceled"</span><span class="p">:</span><span class="w"> </span><span class="kc">false</span><span class="p">,</span><span class="w">
</span><span class="nt">"location"</span><span class="p">:</span><span class="w"> </span><span class="s2">"New York, USA"</span><span class="p">,</span><span class="w">
</span><span class="nt">"method"</span><span class="p">:</span><span class="w"> </span><span class="s2">"POST"</span><span class="p">,</span><span class="w">
</span><span class="nt">"object"</span><span class="p">:</span><span class="w"> </span><span class="s2">"/api/infra/v1/user_namespace/cluster/eea638f4-b77a-4183-b241-22dbd7866f22/"</span><span class="p">,</span><span class="w">
</span><span class="nt">"path"</span><span class="p">:</span><span class="w"> </span><span class="s2">"/api/infra/v1/user_namespace/cluster/"</span><span class="p">,</span><span class="w">
</span><span class="nt">"resource_uri"</span><span class="p">:</span><span class="w"> </span><span class="s2">"/api/audit/v1/action/6246c558-976c-4df6-ba60-eb1a344a17af/"</span><span class="p">,</span><span class="w">
</span><span class="nt">"start_date"</span><span class="p">:</span><span class="w"> </span><span class="s2">"Wed, 17 Sep 2014 08:26:22 +0000"</span><span class="p">,</span><span class="w">
</span><span class="nt">"state"</span><span class="p">:</span><span class="w"> </span><span class="s2">"Success"</span><span class="p">,</span><span class="w">
</span><span class="nt">"user"</span><span class="p">:</span><span class="w"> </span><span class="s2">"user_namespace"</span><span class="p">,</span><span class="w">
</span><span class="nt">"user_agent"</span><span class="p">:</span><span class="w"> </span><span class="s2">"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_9_4) AppleWebKit/537.78.2 (KHTML, like Gecko) Version/7.0.6 Safari/537.78.2"</span><span class="p">,</span><span class="w">
</span><span class="nt">"uuid"</span><span class="p">:</span><span class="w"> </span><span class="s2">"6246c558-976c-4df6-ba60-eb1a344a17af"</span><span class="w">
</span><span class="p">}</span><span class="w">
</span></code></pre>
<p>An action represents an API call by a user. Details of the API call such as timestamp, origin IP address, and user agent are logged in the action object.</p>
<p>Simple API calls that do not require asynchronous execution will return immediately with the appropriate HTTP error code and an action object will be created either in <code class="prettyprint">Success</code> or <code class="prettyprint">Failed</code> states. API calls that do require asynchronous execution will return HTTP code <code class="prettyprint">202 Accepted</code> immediately and create an action object in <code class="prettyprint">In progress</code> state, which will change to <code class="prettyprint">Success</code> or <code class="prettyprint">Failed</code> state depending on the outcome of the operation being performed. In both cases the response will include a <code class="prettyprint">X-DockerCloud-Action-URI</code> header with the resource URI of the created action.</p>
<h3 id="attributes">Attributes</h3>
<table><thead>
<tr>
<th style="text-align: left">Attribute</th>
<th style="text-align: left">Description</th>
</tr>
</thead><tbody>
<tr>
<td style="text-align: left">resource_uri</td>
<td style="text-align: left">A unique API endpoint that represents the action</td>
</tr>
<tr>
<td style="text-align: left">uuid</td>
<td style="text-align: left">A unique identifier for the action generated automatically on creation</td>
</tr>
<tr>
<td style="text-align: left">object</td>
<td style="text-align: left">The API object (resource URI) to which the action applies to</td>
</tr>
<tr>
<td style="text-align: left">action</td>
<td style="text-align: left">Name of the operation performed/being performed</td>
</tr>
<tr>
<td style="text-align: left">method</td>
<td style="text-align: left">HTTP method used to access the API</td>
</tr>
<tr>
<td style="text-align: left">path</td>
<td style="text-align: left">HTTP path of the API accessed</td>
</tr>
<tr>
<td style="text-align: left">user</td>
<td style="text-align: left">The user authenticated in the request that created the action</td>
</tr>
<tr>
<td style="text-align: left">user_agent</td>
<td style="text-align: left">The user agent provided by the client when accessing the API endpoint</td>
</tr>
<tr>
<td style="text-align: left">start_date</td>
<td style="text-align: left">Date and time when the API call was performed and the operation started processing</td>
</tr>
<tr>
<td style="text-align: left">end_date</td>
<td style="text-align: left">Date and time when the API call finished processing</td>
</tr>
<tr>
<td style="text-align: left">state</td>
<td style="text-align: left">State of the operation (see table below)</td>
</tr>
<tr>
<td style="text-align: left">ip</td>
<td style="text-align: left">IP address of the user that performed the API call</td>
</tr>
<tr>
<td style="text-align: left">location</td>
<td style="text-align: left">Geographic location of the IP address of the user that performed the API call</td>
</tr>
<tr>
<td style="text-align: left">is_user_action</td>
<td style="text-align: left">If the action has been triggered by the user</td>
</tr>
<tr>
<td style="text-align: left">can_be_canceled</td>
<td style="text-align: left">If the action can be canceled by the user in the middle of its execution</td>
</tr>
<tr>
<td style="text-align: left">can_be_retried</td>
<td style="text-align: left">If the action can be retried by the user</td>
</tr>
</tbody></table>
<h3 id="action-states">Action states</h3>
<table><thead>
<tr>
<th style="text-align: left">State</th>
<th style="text-align: left">Description</th>
</tr>
</thead><tbody>
<tr>
<td style="text-align: left">Pending</td>
<td style="text-align: left">The action needed asynchronous execution and it is waiting for an in progress action</td>
</tr>
<tr>
<td style="text-align: left">In progress</td>
<td style="text-align: left">The action needed asynchronous execution and is being performed</td>
</tr>
<tr>
<td style="text-align: left">Canceling</td>
<td style="text-align: left">The action is being canceled by user request</td>
</tr>
<tr>
<td style="text-align: left">Canceled</td>
<td style="text-align: left">The action has been canceled</td>
</tr>
<tr>
<td style="text-align: left">Success</td>
<td style="text-align: left">The action was executed successfully</td>
</tr>
<tr>
<td style="text-align: left">Failed</td>
<td style="text-align: left">There was an issue when the action was being performed. Check the logs for more information.</td>
</tr>
</tbody></table>
<h2 id="list-all-actions">List all actions</h2>
<pre class="highlight python"><code><span class="kn">import</span> <span class="nn">dockercloud</span>
<span class="n">actions</span> <span class="o">=</span> <span class="n">dockercloud</span><span class="o">.</span><span class="n">Action</span><span class="o">.</span><span class="nb">list</span><span class="p">()</span>
</code></pre>
<pre class="highlight go"><code><span class="k">import</span><span class="x"> </span><span class="s">"github.com/docker/go-dockercloud/dockercloud"</span><span class="x">
</span><span class="n">actionList</span><span class="p">,</span><span class="x"> </span><span class="n">err</span><span class="x"> </span><span class="o">:=</span><span class="x"> </span><span class="n">dockercloud</span><span class="o">.</span><span class="n">ListActions</span><span class="p">()</span><span class="x">
</span><span class="k">if</span><span class="x"> </span><span class="n">err</span><span class="x"> </span><span class="o">!=</span><span class="x"> </span><span class="no">nil</span><span class="x"> </span><span class="p">{</span><span class="x">
</span><span class="n">log</span><span class="o">.</span><span class="n">Println</span><span class="p">(</span><span class="n">err</span><span class="p">)</span><span class="x">
</span><span class="p">}</span><span class="x">
</span><span class="n">log</span><span class="o">.</span><span class="n">Println</span><span class="p">(</span><span class="n">actionList</span><span class="p">)</span><span class="x">
</span></code></pre>
<pre class="highlight http"><code><span class="nf">GET</span> <span class="nn">/api/audit/v1/action/</span> <span class="k">HTTP</span><span class="o">/</span><span class="m">1.1</span>
<span class="na">Host</span><span class="p">:</span> <span class="s">cloud.docker.com</span>
<span class="na">Authorization</span><span class="p">:</span> <span class="s">Basic dXNlcm5hbWU6YXBpa2V5</span>
<span class="na">Accept</span><span class="p">:</span> <span class="s">application/json</span>
</code></pre>
<pre class="highlight shell"><code>docker-cloud action ls
</code></pre>
<p>Lists all actions in chronological order. Returns a list of <code class="prettyprint">Action</code> objects.</p>
<h3 id="endpoint-type">Endpoint Type</h3>
<p>Available in Docker Cloud’s <strong>REST API</strong></p>
<h3 id="http-request">HTTP Request</h3>
<p><code class="prettyprint">GET /api/audit/v1/action/</code></p>
<h3 id="query-parameters">Query Parameters</h3>
<table><thead>
<tr>
<th style="text-align: left">Parameter</th>
<th style="text-align: left">Description</th>
</tr>
</thead><tbody>
<tr>
<td style="text-align: left">uuid</td>
<td style="text-align: left">Filter by UUID.</td>
</tr>
<tr>
<td style="text-align: left">state</td>
<td style="text-align: left">Filter by state. Possible values: <code class="prettyprint">In progress</code>, <code class="prettyprint">Success</code>, <code class="prettyprint">Failed</code></td>
</tr>
<tr>
<td style="text-align: left">start_date</td>
<td style="text-align: left">Filter by start date. Valid filtering values are <code class="prettyprint">start_date__gte</code> (after or on the date supplied) and <code class="prettyprint">start_date__lte</code> (before or on the date supplied)</td>
</tr>
<tr>
<td style="text-align: left">end_date</td>
<td style="text-align: left">Filter by end date. Valid filtering values are <code class="prettyprint">end_date__gte</code> (after or on the date supplied) and <code class="prettyprint">end_date__lte</code> (before or on the date supplied)</td>
</tr>
<tr>
<td style="text-align: left">object</td>
<td style="text-align: left">Filter by resource URI of the related object. This filter can only be combined with ‘include_related’ filter</td>
</tr>
<tr>
<td style="text-align: left">include_related</td>
<td style="text-align: left">There is a parent-child relationship between Docker Cloud objects, described in table <code class="prettyprint">Relationships between Docker Cloud objects</code>. If set to 'true’, will include the actions of the related objects to the object specified in “object” filter parameter. Possible values: 'true’ or 'false’</td>
</tr>
</tbody></table>
<h2 id="relationships-between-docker-cloud-objects">Relationships between Docker Cloud objects</h2>
<table><thead>
<tr>
<th style="text-align: left">Object</th>
<th style="text-align: left">Relationships</th>
</tr>
</thead><tbody>
<tr>
<td style="text-align: left">Container</td>
<td style="text-align: left">Container, service, stack (if any)</td>
</tr>
<tr>
<td style="text-align: left">Service</td>
<td style="text-align: left">All containers in the service, service, stack (if any)</td>
</tr>
<tr>
<td style="text-align: left">Stack</td>
<td style="text-align: left">All services in the stack, all containers in every service in the stack, stack</td>
</tr>
<tr>
<td style="text-align: left">Node</td>
<td style="text-align: left">Node, node cluster (if any)</td>
</tr>
<tr>
<td style="text-align: left">Node cluster</td>
<td style="text-align: left">All nodes in the cluster, node cluster</td>
</tr>
</tbody></table>
<h2 id="get-an-action-by-uuid">Get an action by UUID</h2>
<pre class="highlight python"><code><span class="kn">import</span> <span class="nn">dockercloud</span>
<span class="n">action</span> <span class="o">=</span> <span class="n">dockercloud</span><span class="o">.</span><span class="n">Action</span><span class="o">.</span><span class="n">fetch</span><span class="p">(</span><span class="s">"7eaf7fff-882c-4f3d-9a8f-a22317ac00ce"</span><span class="p">)</span>
</code></pre>
<pre class="highlight go"><code><span class="k">import</span><span class="x"> </span><span class="s">"github.com/docker/go-dockercloud/dockercloud"</span><span class="x">
</span><span class="n">action</span><span class="p">,</span><span class="x"> </span><span class="n">err</span><span class="x"> </span><span class="o">:=</span><span class="x"> </span><span class="n">dockercloud</span><span class="o">.</span><span class="n">GetAction</span><span class="p">(</span><span class="s">"7eaf7fff-882c-4f3d-9a8f-a22317ac00ce"</span><span class="p">)</span><span class="x">
</span><span class="k">if</span><span class="x"> </span><span class="n">err</span><span class="x"> </span><span class="o">!=</span><span class="x"> </span><span class="no">nil</span><span class="x"> </span><span class="p">{</span><span class="x">
</span><span class="n">log</span><span class="o">.</span><span class="n">Println</span><span class="p">(</span><span class="n">err</span><span class="p">)</span><span class="x">
</span><span class="p">}</span><span class="x">
</span><span class="n">log</span><span class="o">.</span><span class="n">Println</span><span class="p">(</span><span class="n">action</span><span class="p">)</span><span class="x">
</span></code></pre>
<pre class="highlight http"><code><span class="nf">GET</span> <span class="nn">/api/audit/v1/action/7eaf7fff-882c-4f3d-9a8f-a22317ac00ce/</span> <span class="k">HTTP</span><span class="o">/</span><span class="m">1.1</span>
<span class="na">Host</span><span class="p">:</span> <span class="s">cloud.docker.com</span>
<span class="na">Authorization</span><span class="p">:</span> <span class="s">Basic dXNlcm5hbWU6YXBpa2V5</span>
<span class="na">Accept</span><span class="p">:</span> <span class="s">application/json</span>
</code></pre>
<pre class="highlight shell"><code>docker-cloud action inspect 7eaf7fff
</code></pre>
<p>Get all the details of an specific action</p>
<h3 id="endpoint-type">Endpoint Type</h3>
<p>Available in Docker Cloud’s <strong>REST API</strong></p>
<h3 id="http-request">HTTP Request</h3>
<p><code class="prettyprint">GET /api/audit/v1/action/(uuid)/</code></p>
<h3 id="path-parameters">Path Parameters</h3>
<table><thead>
<tr>
<th style="text-align: left">Parameter</th>
<th style="text-align: left">Description</th>
</tr>
</thead><tbody>
<tr>
<td style="text-align: left">uuid</td>
<td style="text-align: left">The UUID of the action to retrieve</td>
</tr>
</tbody></table>
<h2 id="get-the-logs-of-an-action">Get the logs of an action</h2>
<blockquote>
<p>Example log line</p>
</blockquote>
<pre class="highlight json"><code><span class="p">{</span><span class="w">
</span><span class="nt">"type"</span><span class="p">:</span><span class="w"> </span><span class="s2">"log"</span><span class="p">,</span><span class="w">
</span><span class="nt">"log"</span><span class="p">:</span><span class="w"> </span><span class="s2">"Log line from the action"</span><span class="p">,</span><span class="w">
</span><span class="nt">"timestamp"</span><span class="p">:</span><span class="w"> </span><span class="mi">1433779324</span><span class="w">
</span><span class="p">}</span><span class="w">
</span></code></pre>
<pre class="highlight python"><code><span class="kn">import</span> <span class="nn">dockercloud</span>
<span class="k">def</span> <span class="nf">log_handler</span><span class="p">(</span><span class="n">message</span><span class="p">):</span>
<span class="k">print</span> <span class="n">message</span>
<span class="n">action</span> <span class="o">=</span> <span class="n">dockercloud</span><span class="o">.</span><span class="n">Action</span><span class="o">.</span><span class="n">fetch</span><span class="p">(</span><span class="s">"7eaf7fff-882c-4f3d-9a8f-a22317ac00ce"</span><span class="p">)</span>
<span class="n">action</span><span class="o">.</span><span class="n">logs</span><span class="p">(</span><span class="n">tail</span><span class="o">=</span><span class="mi">300</span><span class="p">,</span> <span class="n">follow</span><span class="o">=</span><span class="bp">True</span><span class="p">,</span> <span class="n">log_handler</span><span class="o">=</span><span class="n">log_handler</span><span class="p">)</span>
</code></pre>
<pre class="highlight go"><code><span class="k">import</span><span class="x"> </span><span class="s">"github.com/docker/go-dockercloud/dockercloud"</span><span class="x">
</span><span class="n">c</span><span class="x"> </span><span class="o">:=</span><span class="x"> </span><span class="nb">make</span><span class="p">(</span><span class="k">chan</span><span class="x"> </span><span class="n">dockercloud</span><span class="o">.</span><span class="n">Logs</span><span class="p">)</span><span class="x">
</span><span class="n">action</span><span class="p">,</span><span class="x"> </span><span class="n">err</span><span class="x"> </span><span class="o">:=</span><span class="x"> </span><span class="n">dockercloud</span><span class="o">.</span><span class="n">GetAction</span><span class="p">(</span><span class="s">"7eaf7fff-882c-4f3d-9a8f-a22317ac00ce"</span><span class="p">)</span><span class="x">
</span><span class="k">if</span><span class="x"> </span><span class="n">err</span><span class="x"> </span><span class="o">!=</span><span class="x"> </span><span class="no">nil</span><span class="x"> </span><span class="p">{</span><span class="x">
</span><span class="n">log</span><span class="o">.</span><span class="n">Println</span><span class="p">(</span><span class="n">err</span><span class="p">)</span><span class="x">
</span><span class="p">}</span><span class="x">
</span><span class="k">go</span><span class="x"> </span><span class="n">action</span><span class="o">.</span><span class="n">GetLogs</span><span class="p">(</span><span class="n">c</span><span class="p">)</span><span class="x">
</span><span class="k">for</span><span class="x"> </span><span class="p">{</span><span class="x">
</span><span class="n">log</span><span class="o">.</span><span class="n">Println</span><span class="p">(</span><span class="o"><-</span><span class="n">c</span><span class="p">)</span><span class="x">
</span><span class="p">}</span><span class="x">
</span></code></pre>
<pre class="highlight http"><code><span class="nf">GET</span> <span class="nn">/api/audit/v1/action/7eaf7fff-882c-4f3d-9a8f-a22317ac00ce/logs/</span> <span class="k">HTTP</span><span class="o">/</span><span class="m">1.1</span>
<span class="na">Host</span><span class="p">:</span> <span class="s">ws.cloud.docker.com</span>
<span class="na">Authorization</span><span class="p">:</span> <span class="s">Basic dXNlcm5hbWU6YXBpa2V5</span>
<span class="na">Connection</span><span class="p">:</span> <span class="s">Upgrade</span>
<span class="na">Upgrade</span><span class="p">:</span> <span class="s">websocket</span>
</code></pre>
<pre class="highlight shell"><code>docker-cloud action logs 7eaf7fff-882c-4f3d-9a8f-a22317ac00ce
</code></pre>
<p>Get the logs of the specified action.</p>
<h3 id="endpoint-type">Endpoint Type</h3>
<p>Available in Docker Cloud’s <strong>STREAM API</strong></p>
<h3 id="http-request">HTTP Request</h3>
<p><code class="prettyprint">GET /api/audit/v1/action/(uuid)/logs/</code></p>
<h3 id="path-parameters">Path Parameters</h3>
<table><thead>
<tr>
<th style="text-align: left">Parameter</th>
<th style="text-align: left">Description</th>
</tr>
</thead><tbody>
<tr>
<td style="text-align: left">uuid</td>
<td style="text-align: left">The UUID of the action to retrieve logs</td>
</tr>
</tbody></table>
<h3 id="query-parameters">Query Parameters</h3>
<table><thead>
<tr>
<th style="text-align: left">Parameter</th>
<th style="text-align: left">Description</th>
</tr>
</thead><tbody>
<tr>
<td style="text-align: left">tail</td>
<td style="text-align: left">Number of lines to show from the end of the logs (default: <code class="prettyprint">300</code>)</td>
</tr>
<tr>
<td style="text-align: left">follow</td>
<td style="text-align: left">Whether to stream logs or close the connection immediately (default: true)</td>
</tr>
</tbody></table>
<h2 id="cancel-an-action">Cancel an action</h2>
<pre class="highlight http"><code><span class="nf">POST</span> <span class="nn">/api/audit/v1/action/7eaf7fff-882c-4f3d-9a8f-a22317ac00ce/cancel/</span> <span class="k">HTTP</span><span class="o">/</span><span class="m">1.1</span>
<span class="na">Host</span><span class="p">:</span> <span class="s">cloud.docker.com</span>
<span class="na">Authorization</span><span class="p">:</span> <span class="s">Basic dXNlcm5hbWU6YXBpa2V5</span>
<span class="na">Accept</span><span class="p">:</span> <span class="s">application/json</span>
</code></pre>
<pre class="highlight go"><code><span class="k">import</span><span class="x"> </span><span class="s">"github.com/docker/go-dockercloud/dockercloud"</span><span class="x">
</span><span class="n">action</span><span class="p">,</span><span class="x"> </span><span class="n">err</span><span class="x"> </span><span class="o">:=</span><span class="x"> </span><span class="n">dockercloud</span><span class="o">.</span><span class="n">GetAction</span><span class="p">(</span><span class="s">"7eaf7fff-882c-4f3d-9a8f-a22317ac00ce"</span><span class="p">)</span><span class="x">
</span><span class="k">if</span><span class="x"> </span><span class="n">err</span><span class="x"> </span><span class="o">!=</span><span class="x"> </span><span class="no">nil</span><span class="x"> </span><span class="p">{</span><span class="x">
</span><span class="n">log</span><span class="o">.</span><span class="n">Println</span><span class="p">(</span><span class="n">err</span><span class="p">)</span><span class="x">
</span><span class="p">}</span><span class="x">
</span><span class="n">action</span><span class="p">,</span><span class="x"> </span><span class="n">err</span><span class="x"> </span><span class="o">=</span><span class="x"> </span><span class="n">action</span><span class="o">.</span><span class="n">Cancel</span><span class="p">()</span><span class="x">
</span><span class="k">if</span><span class="x"> </span><span class="n">err</span><span class="x"> </span><span class="o">!=</span><span class="x"> </span><span class="no">nil</span><span class="x"> </span><span class="p">{</span><span class="x">
</span><span class="n">log</span><span class="o">.</span><span class="n">Println</span><span class="p">(</span><span class="n">err</span><span class="p">)</span><span class="x">
</span><span class="p">}</span><span class="x">
</span><span class="n">log</span><span class="o">.</span><span class="n">Println</span><span class="p">(</span><span class="n">action</span><span class="p">)</span><span class="x">
</span></code></pre>
<p>Cancels an action in Pending or In progress state.</p>
<h3 id="endpoint-type">Endpoint Type</h3>
<p>Available in Docker Cloud’s <strong>REST API</strong></p>
<h3 id="http-request">HTTP Request</h3>
<p><code class="prettyprint">POST /api/audit/v1/action/(uuid)/cancel/</code></p>
<h3 id="path-parameters">Path Parameters</h3>
<table><thead>
<tr>
<th style="text-align: left">Parameter</th>
<th style="text-align: left">Description</th>
</tr>
</thead><tbody>
<tr>
<td style="text-align: left">uuid</td>
<td style="text-align: left">The UUID of the action to cancel</td>
</tr>
</tbody></table>
<h2 id="retry-an-action">Retry an action</h2>
<pre class="highlight python"><code><span class="kn">import</span> <span class="nn">dockercloud</span>
<span class="k">def</span> <span class="nf">log_handler</span><span class="p">(</span><span class="n">message</span><span class="p">):</span>
<span class="k">print</span> <span class="n">message</span>
<span class="n">action</span> <span class="o">=</span> <span class="n">dockercloud</span><span class="o">.</span><span class="n">Action</span><span class="o">.</span><span class="n">fetch</span><span class="p">(</span><span class="s">"7eaf7fff-882c-4f3d-9a8f-a22317ac00ce"</span><span class="p">)</span>
<span class="n">action</span><span class="o">.</span><span class="n">logs</span><span class="p">(</span><span class="n">tail</span><span class="o">=</span><span class="mi">300</span><span class="p">,</span> <span class="n">follow</span><span class="o">=</span><span class="bp">True</span><span class="p">,</span> <span class="n">log_handler</span><span class="o">=</span><span class="n">log_handler</span><span class="p">)</span>
</code></pre>
<pre class="highlight http"><code><span class="nf">POST</span> <span class="nn">/api/audit/v1/action/7eaf7fff-882c-4f3d-9a8f-a22317ac00ce/retry/</span> <span class="k">HTTP</span><span class="o">/</span><span class="m">1.1</span>
<span class="na">Host</span><span class="p">:</span> <span class="s">cloud.docker.com</span>
<span class="na">Authorization</span><span class="p">:</span> <span class="s">Basic dXNlcm5hbWU6YXBpa2V5</span>
<span class="na">Accept</span><span class="p">:</span> <span class="s">application/json</span>
</code></pre>
<pre class="highlight go"><code><span class="k">import</span><span class="x"> </span><span class="s">"github.com/docker/go-dockercloud/dockercloud"</span><span class="x">
</span><span class="n">action</span><span class="p">,</span><span class="x"> </span><span class="n">err</span><span class="x"> </span><span class="o">:=</span><span class="x"> </span><span class="n">dockercloud</span><span class="o">.</span><span class="n">GetAction</span><span class="p">(</span><span class="s">"7eaf7fff-882c-4f3d-9a8f-a22317ac00ce"</span><span class="p">)</span><span class="x">
</span><span class="k">if</span><span class="x"> </span><span class="n">err</span><span class="x"> </span><span class="o">!=</span><span class="x"> </span><span class="no">nil</span><span class="x"> </span><span class="p">{</span><span class="x">
</span><span class="n">log</span><span class="o">.</span><span class="n">Println</span><span class="p">(</span><span class="n">err</span><span class="p">)</span><span class="x">
</span><span class="p">}</span><span class="x">
</span><span class="n">action</span><span class="p">,</span><span class="x"> </span><span class="n">err</span><span class="x"> </span><span class="o">=</span><span class="x"> </span><span class="n">action</span><span class="o">.</span><span class="n">Retry</span><span class="p">()</span><span class="x">
</span><span class="k">if</span><span class="x"> </span><span class="n">err</span><span class="x"> </span><span class="o">!=</span><span class="x"> </span><span class="no">nil</span><span class="x"> </span><span class="p">{</span><span class="x">
</span><span class="n">log</span><span class="o">.</span><span class="n">Println</span><span class="p">(</span><span class="n">err</span><span class="p">)</span><span class="x">
</span><span class="p">}</span><span class="x">
</span><span class="n">log</span><span class="o">.</span><span class="n">Println</span><span class="p">(</span><span class="n">action</span><span class="p">)</span><span class="x">
</span></code></pre>
<pre class="highlight shell"><code>docker-cloud action logs 7eaf7fff-882c-4f3d-9a8f-a22317ac00ce
</code></pre>
<p>Retries an action in Success, Failed or Canceled state.</p>
<h3 id="endpoint-type">Endpoint Type</h3>
<p>Available in Docker Cloud’s <strong>REST API</strong></p>
<h3 id="http-request">HTTP Request</h3>
<p><code class="prettyprint">POST /api/audit/v1/action/(uuid)/retry/</code></p>
<h3 id="path-parameters">Path Parameters</h3>
<table><thead>
<tr>
<th style="text-align: left">Parameter</th>
<th style="text-align: left">Description</th>
</tr>
</thead><tbody>
<tr>
<td style="text-align: left">uuid</td>
<td style="text-align: left">The UUID of the action to retry</td>
</tr>
</tbody></table>
<h1 id="providers">Providers</h1>
<h2 id="provider">Provider</h2>
<blockquote>
<p>Example</p>
</blockquote>
<pre class="highlight json"><code><span class="p">{</span><span class="w">
</span><span class="nt">"available"</span><span class="p">:</span><span class="w"> </span><span class="kc">true</span><span class="p">,</span><span class="w">
</span><span class="nt">"label"</span><span class="p">:</span><span class="w"> </span><span class="s2">"Digital Ocean"</span><span class="p">,</span><span class="w">
</span><span class="nt">"name"</span><span class="p">:</span><span class="w"> </span><span class="s2">"digitalocean"</span><span class="p">,</span><span class="w">
</span><span class="nt">"regions"</span><span class="p">:</span><span class="w"> </span><span class="p">[</span><span class="w">
</span><span class="s2">"/api/infra/v1/region/digitalocean/ams1/"</span><span class="p">,</span><span class="w">
</span><span class="s2">"/api/infra/v1/region/digitalocean/ams2/"</span><span class="p">,</span><span class="w">
</span><span class="s2">"/api/infra/v1/region/digitalocean/ams3/"</span><span class="p">,</span><span class="w">
</span><span class="s2">"/api/infra/v1/region/digitalocean/lon1/"</span><span class="p">,</span><span class="w">
</span><span class="s2">"/api/infra/v1/region/digitalocean/nyc1/"</span><span class="p">,</span><span class="w">
</span><span class="s2">"/api/infra/v1/region/digitalocean/nyc2/"</span><span class="p">,</span><span class="w">
</span><span class="s2">"/api/infra/v1/region/digitalocean/nyc3/"</span><span class="p">,</span><span class="w">
</span><span class="s2">"/api/infra/v1/region/digitalocean/sfo1/"</span><span class="p">,</span><span class="w">
</span><span class="s2">"/api/infra/v1/region/digitalocean/sgp1/"</span><span class="w">
</span><span class="p">],</span><span class="w">
</span><span class="nt">"resource_uri"</span><span class="p">:</span><span class="w"> </span><span class="s2">"/api/infra/v1/provider/digitalocean/"</span><span class="w">
</span><span class="p">}</span><span class="w">
</span></code></pre>
<p>A provider is a representation of a cloud provider supported by Docker Cloud. Providers have one or more regions where nodes are deployed.</p>
<h3 id="attributes">Attributes</h3>
<table><thead>
<tr>
<th>Attribute</th>
<th>Description</th>
</tr>
</thead><tbody>
<tr>
<td>resource_uri</td>
<td>A unique API endpoint that represents the provider</td>
</tr>
<tr>
<td>name</td>
<td>A unique identifier for the provider</td>
</tr>
<tr>
<td>label</td>
<td>A user-friendly name for the provider</td>
</tr>
<tr>
<td>regions</td>
<td>A list of resource URIs of the regions available in this provider</td>
</tr>
<tr>
<td>available</td>
<td>Whether the provider is currently available for new node deployments</td>
</tr>
</tbody></table>
<h2 id="list-all-providers">List all providers</h2>
<pre class="highlight python"><code><span class="kn">import</span> <span class="nn">dockercloud</span>
<span class="n">providers</span> <span class="o">=</span> <span class="n">dockercloud</span><span class="o">.</span><span class="n">Provider</span><span class="o">.</span><span class="nb">list</span><span class="p">()</span>
</code></pre>
<pre class="highlight http"><code><span class="nf">GET</span> <span class="nn">/api/infra/v1/provider/</span> <span class="k">HTTP</span><span class="o">/</span><span class="m">1.1</span>
<span class="na">Host</span><span class="p">:</span> <span class="s">cloud.docker.com</span>
<span class="na">Authorization</span><span class="p">:</span> <span class="s">Basic dXNlcm5hbWU6YXBpa2V5</span>
<span class="na">Accept</span><span class="p">:</span> <span class="s">application/json</span>
</code></pre>
<pre class="highlight go"><code><span class="k">import</span><span class="x"> </span><span class="s">"github.com/docker/go-dockercloud/dockercloud"</span><span class="x">
</span><span class="n">providerList</span><span class="p">,</span><span class="x"> </span><span class="n">err</span><span class="x"> </span><span class="o">:=</span><span class="x"> </span><span class="n">dockercloud</span><span class="o">.</span><span class="n">ListProviders</span><span class="p">()</span><span class="x">
</span><span class="k">if</span><span class="x"> </span><span class="n">err</span><span class="x"> </span><span class="o">!=</span><span class="x"> </span><span class="no">nil</span><span class="x"> </span><span class="p">{</span><span class="x">
</span><span class="n">log</span><span class="o">.</span><span class="n">Println</span><span class="p">(</span><span class="n">err</span><span class="p">)</span><span class="x">
</span><span class="p">}</span><span class="x">
</span><span class="n">log</span><span class="o">.</span><span class="n">Println</span><span class="p">(</span><span class="n">providerList</span><span class="p">)</span><span class="x">
</span></code></pre>
<pre class="highlight shell"><code>docker-cloud nodecluster provider
</code></pre>
<p>Lists all supported cloud providers. Returns a list of <code class="prettyprint">Provider</code> objects.</p>
<h3 id="endpoint-type">Endpoint Type</h3>
<p>Available in Docker Cloud’s <strong>REST API</strong></p>
<h3 id="http-request">HTTP Request</h3>
<p><code class="prettyprint">GET /api/infra/v1/provider/</code></p>
<h3 id="query-parameters">Query Parameters</h3>
<table><thead>
<tr>
<th>Parameter</th>
<th>Description</th>
</tr>
</thead><tbody>
<tr>
<td>name</td>
<td>Filter by provider name</td>
</tr>
</tbody></table>
<h2 id="get-an-individual-provider">Get an individual provider</h2>
<pre class="highlight python"><code><span class="kn">import</span> <span class="nn">dockercloud</span>
<span class="n">provider</span> <span class="o">=</span> <span class="n">dockercloud</span><span class="o">.</span><span class="n">Provider</span><span class="o">.</span><span class="n">fetch</span><span class="p">(</span><span class="s">"digitalocean"</span><span class="p">)</span>
</code></pre>
<pre class="highlight go"><code><span class="k">import</span><span class="x"> </span><span class="s">"github.com/docker/go-dockercloud/dockercloud"</span><span class="x">
</span><span class="n">provider</span><span class="p">,</span><span class="x"> </span><span class="n">err</span><span class="x"> </span><span class="o">:=</span><span class="x"> </span><span class="n">dockercloud</span><span class="o">.</span><span class="n">GetProvider</span><span class="p">(</span><span class="s">"digitalocean"</span><span class="p">)</span><span class="x">
</span><span class="k">if</span><span class="x"> </span><span class="n">err</span><span class="x"> </span><span class="o">!=</span><span class="x"> </span><span class="no">nil</span><span class="x"> </span><span class="p">{</span><span class="x">
</span><span class="n">log</span><span class="o">.</span><span class="n">Println</span><span class="p">(</span><span class="n">err</span><span class="p">)</span><span class="x">
</span><span class="p">}</span><span class="x">
</span><span class="n">log</span><span class="o">.</span><span class="n">Println</span><span class="p">(</span><span class="n">provider</span><span class="p">)</span><span class="x">
</span></code></pre>
<pre class="highlight http"><code><span class="nf">GET</span> <span class="nn">/api/infra/v1/provider/digitalocean/</span> <span class="k">HTTP</span><span class="o">/</span><span class="m">1.1</span>
<span class="na">Host</span><span class="p">:</span> <span class="s">cloud.docker.com</span>
<span class="na">Authorization</span><span class="p">:</span> <span class="s">Basic dXNlcm5hbWU6YXBpa2V5</span>
<span class="na">Accept</span><span class="p">:</span> <span class="s">application/json</span>
</code></pre>
<p>Get all the details of a specific provider</p>
<h3 id="endpoint-type">Endpoint Type</h3>
<p>Available in Docker Cloud’s <strong>REST API</strong></p>
<h3 id="http-request">HTTP Request</h3>
<p><code class="prettyprint">GET /api/infra/v1/provider/(name)/</code></p>
<h3 id="path-parameters">Path Parameters</h3>
<table><thead>
<tr>
<th>Parameter</th>
<th>Description</th>
</tr>
</thead><tbody>
<tr>
<td>name</td>
<td>The name of the provider to retrieve</td>
</tr>
</tbody></table>
<h1 id="regions">Regions</h1>
<h2 id="region">Region</h2>
<blockquote>
<p>Example</p>
</blockquote>
<pre class="highlight json"><code><span class="p">{</span><span class="w">
</span><span class="nt">"availability_zones"</span><span class="p">:</span><span class="w"> </span><span class="p">[],</span><span class="w">
</span><span class="nt">"available"</span><span class="p">:</span><span class="w"> </span><span class="kc">true</span><span class="p">,</span><span class="w">
</span><span class="nt">"label"</span><span class="p">:</span><span class="w"> </span><span class="s2">"Amsterdam 2"</span><span class="p">,</span><span class="w">
</span><span class="nt">"name"</span><span class="p">:</span><span class="w"> </span><span class="s2">"ams2"</span><span class="p">,</span><span class="w">
</span><span class="nt">"node_types"</span><span class="p">:</span><span class="w"> </span><span class="p">[</span><span class="w">
</span><span class="s2">"/api/infra/v1/nodetype/digitalocean/1gb/"</span><span class="p">,</span><span class="w">
</span><span class="s2">"/api/infra/v1/nodetype/digitalocean/2gb/"</span><span class="p">,</span><span class="w">
</span><span class="s2">"/api/infra/v1/nodetype/digitalocean/4gb/"</span><span class="p">,</span><span class="w">
</span><span class="s2">"/api/infra/v1/nodetype/digitalocean/8gb/"</span><span class="p">,</span><span class="w">
</span><span class="s2">"/api/infra/v1/nodetype/digitalocean/16gb/"</span><span class="p">,</span><span class="w">
</span><span class="s2">"/api/infra/v1/nodetype/digitalocean/32gb/"</span><span class="p">,</span><span class="w">
</span><span class="s2">"/api/infra/v1/nodetype/digitalocean/48gb/"</span><span class="p">,</span><span class="w">
</span><span class="s2">"/api/infra/v1/nodetype/digitalocean/64gb/"</span><span class="w">
</span><span class="p">],</span><span class="w">
</span><span class="nt">"provider"</span><span class="p">:</span><span class="w"> </span><span class="s2">"/api/infra/v1/provider/digitalocean/"</span><span class="p">,</span><span class="w">
</span><span class="nt">"resource_uri"</span><span class="p">:</span><span class="w"> </span><span class="s2">"/api/infra/v1/region/digitalocean/ams2/"</span><span class="w">
</span><span class="p">}</span><span class="w">
</span></code></pre>
<p>A region is a representation of an entire or a subset of a data center of a cloud provider. It can contain availability zones (depending on the provider) and one or more node types.</p>
<h3 id="attributes">Attributes</h3>
<table><thead>
<tr>
<th>Attribute</th>
<th>Description</th>
</tr>
</thead><tbody>
<tr>
<td>resource_uri</td>
<td>A unique API endpoint that represents the region</td>
</tr>
<tr>
<td>name</td>
<td>An identifier for the region</td>
</tr>
<tr>
<td>label</td>
<td>A user-friendly name for the region</td>
</tr>
<tr>
<td>node_types</td>
<td>A list of resource URIs of the node types available in the region</td>
</tr>
<tr>
<td>availability_zones</td>
<td>A list of resource URIs of the availability zones available in the region</td>
</tr>
<tr>
<td>provider</td>
<td>The resource URI of the provider of the region</td>
</tr>
<tr>
<td>available</td>
<td>Whether the region is currently available for new node deployments</td>
</tr>
</tbody></table>
<h2 id="list-all-regions">List all regions</h2>
<pre class="highlight python"><code><span class="kn">import</span> <span class="nn">dockercloud</span>
<span class="n">regions</span> <span class="o">=</span> <span class="n">dockercloud</span><span class="o">.</span><span class="n">Region</span><span class="o">.</span><span class="nb">list</span><span class="p">()</span>
</code></pre>
<pre class="highlight http"><code><span class="nf">GET</span> <span class="nn">/api/infra/v1/region/</span> <span class="k">HTTP</span><span class="o">/</span><span class="m">1.1</span>
<span class="na">Host</span><span class="p">:</span> <span class="s">cloud.docker.com</span>
<span class="na">Authorization</span><span class="p">:</span> <span class="s">Basic dXNlcm5hbWU6YXBpa2V5</span>
<span class="na">Accept</span><span class="p">:</span> <span class="s">application/json</span>
</code></pre>
<pre class="highlight go"><code><span class="k">import</span><span class="x"> </span><span class="s">"github.com/docker/go-dockercloud/dockercloud"</span><span class="x">
</span><span class="n">regionList</span><span class="p">,</span><span class="x"> </span><span class="n">err</span><span class="x"> </span><span class="o">:=</span><span class="x"> </span><span class="n">dockercloud</span><span class="o">.</span><span class="n">ListRegions</span><span class="p">()</span><span class="x">
</span><span class="k">if</span><span class="x"> </span><span class="n">err</span><span class="x"> </span><span class="o">!=</span><span class="x"> </span><span class="no">nil</span><span class="x"> </span><span class="p">{</span><span class="x">
</span><span class="n">log</span><span class="o">.</span><span class="n">Println</span><span class="p">(</span><span class="n">err</span><span class="p">)</span><span class="x">
</span><span class="p">}</span><span class="x">
</span><span class="n">log</span><span class="o">.</span><span class="n">Println</span><span class="p">(</span><span class="n">regionList</span><span class="p">)</span><span class="x">
</span></code></pre>
<pre class="highlight shell"><code>docker-cloud nodecluster region
</code></pre>
<p>Lists all regions of all supported cloud providers. Returns a list of <code class="prettyprint">Region</code> objects.</p>
<h3 id="endpoint-type">Endpoint Type</h3>
<p>Available in Docker Cloud’s <strong>REST API</strong></p>
<h3 id="http-request">HTTP Request</h3>
<p><code class="prettyprint">GET /api/infra/v1/region/</code></p>
<h3 id="query-parameters">Query Parameters</h3>
<table><thead>
<tr>
<th>Parameter</th>
<th>Description</th>
</tr>
</thead><tbody>
<tr>
<td>name</td>
<td>Filter by region name</td>
</tr>
<tr>
<td>provider</td>
<td>Filter by resource URI of the target provider</td>
</tr>
</tbody></table>
<h2 id="get-an-individual-region">Get an individual region</h2>
<pre class="highlight python"><code><span class="kn">import</span> <span class="nn">dockercloud</span>
<span class="n">region</span> <span class="o">=</span> <span class="n">dockercloud</span><span class="o">.</span><span class="n">Region</span><span class="o">.</span><span class="n">fetch</span><span class="p">(</span><span class="s">"digitalocean/lon1"</span><span class="p">)</span>
</code></pre>
<pre class="highlight go"><code><span class="k">import</span><span class="x"> </span><span class="s">"github.com/docker/go-dockercloud/dockercloud"</span><span class="x">
</span><span class="n">region</span><span class="p">,</span><span class="x"> </span><span class="n">err</span><span class="x"> </span><span class="o">:=</span><span class="x"> </span><span class="n">dockercloud</span><span class="o">.</span><span class="n">GetRegion</span><span class="p">(</span><span class="s">"digitalocean"</span><span class="p">,</span><span class="s">"lon1"</span><span class="p">)</span><span class="x">
</span><span class="k">if</span><span class="x"> </span><span class="n">err</span><span class="x"> </span><span class="o">!=</span><span class="x"> </span><span class="no">nil</span><span class="x"> </span><span class="p">{</span><span class="x">
</span><span class="n">log</span><span class="o">.</span><span class="n">Println</span><span class="p">(</span><span class="n">err</span><span class="p">)</span><span class="x">
</span><span class="p">}</span><span class="x">
</span><span class="n">log</span><span class="o">.</span><span class="n">Println</span><span class="p">(</span><span class="n">region</span><span class="p">)</span><span class="x">
</span></code></pre>
<pre class="highlight http"><code><span class="nf">GET</span> <span class="nn">/api/infra/v1/region/digitalocean/lon1/</span> <span class="k">HTTP</span><span class="o">/</span><span class="m">1.1</span>
<span class="na">Host</span><span class="p">:</span> <span class="s">cloud.docker.com</span>
<span class="na">Authorization</span><span class="p">:</span> <span class="s">Basic dXNlcm5hbWU6YXBpa2V5</span>
<span class="na">Accept</span><span class="p">:</span> <span class="s">application/json</span>
</code></pre>
<p>Get all the details of a specific region</p>
<h3 id="endpoint-type">Endpoint Type</h3>
<p>Available in Docker Cloud’s <strong>REST API</strong></p>
<h3 id="http-request">HTTP Request</h3>
<p><code class="prettyprint">GET /api/infra/v1/region/(provider.name)/(name)/</code></p>
<h3 id="path-parameters">Path Parameters</h3>
<table><thead>
<tr>
<th>Parameter</th>
<th>Description</th>
</tr>
</thead><tbody>
<tr>
<td>name</td>
<td>The name of the region to retrieve</td>
</tr>
<tr>
<td>provider.name</td>
<td>The name of the provider of the region</td>
</tr>
</tbody></table>
<h1 id="availability-zones">Availability Zones</h1>
<h2 id="availability-zone">Availability Zone</h2>
<blockquote>
<p>Example</p>
</blockquote>
<pre class="highlight json"><code><span class="p">{</span><span class="w">
</span><span class="nt">"available"</span><span class="p">:</span><span class="w"> </span><span class="kc">true</span><span class="p">,</span><span class="w">
</span><span class="nt">"name"</span><span class="p">:</span><span class="w"> </span><span class="s2">"ap-northeast-1a"</span><span class="p">,</span><span class="w">
</span><span class="nt">"region"</span><span class="p">:</span><span class="w"> </span><span class="s2">"/api/infra/v1/region/az/ap-northeast-1/"</span><span class="p">,</span><span class="w">
</span><span class="nt">"resource_uri"</span><span class="p">:</span><span class="w"> </span><span class="s2">"/api/infra/v1/az/aws/ap-northeast-1/ap-northeast-1a/"</span><span class="w">
</span><span class="p">}</span><span class="w">
</span></code></pre>
<p>An Availability Zone is an isolated location inside a region. Providers that support availability zones: AWS</p>
<h3 id="attributes">Attributes</h3>
<table><thead>
<tr>
<th>Attribute</th>
<th>Description</th>
</tr>
</thead><tbody>
<tr>
<td>available</td>
<td>Whether the availability zone is currently available for new node deployments</td>