forked from xcarpentier/developers.scalingo.com
-
Notifications
You must be signed in to change notification settings - Fork 0
/
environment.html
243 lines (194 loc) · 12 KB
/
environment.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
---
layout: default
title: Environment variables
---
<div class='row'><div class='col-xs-12 col-sm-6 sidebar-text'><h1 id="environment-variables">Environment variables</h1>
<p>We do not automatically restart your application when you create/update/delete
an environment variable, you have to do it yourself when all the modifications
have been done. Look at the <a href="/apps.html#restart-an-application">‘restart
application’</a> endpoint.</p>
</div><div class='hidden-xs col-xs-12 col-sm-6 sidebar-code'></div></div><div class='row'><div class='col-xs-12 col-sm-6 sidebar-text'>
<p><strong>Environment variable attributes</strong></p>
<table class="table">
<thead>
<tr>
<th>field</th>
<th>type</th>
<th>description</th>
</tr>
</thead>
<tbody>
<tr>
<td>id</td>
<td>string</td>
<td>unique ID of variable</td>
</tr>
<tr>
<td>name</td>
<td>string</td>
<td>name</td>
</tr>
<tr>
<td>value</td>
<td>string</td>
<td>value</td>
</tr>
</tbody>
</table>
</div><div class='col-xs-12 col-sm-6 sidebar-code'>
<p>Example object:</p>
<div class="highlighter-rouge"><pre class="highlight"><code><span class="p">{</span><span class="w">
</span><span class="s2">"id"</span><span class="p">:</span><span class="w"> </span><span class="s2">"541013a9736f7563d5050000"</span><span class="p">,</span><span class="w">
</span><span class="s2">"name"</span><span class="p">:</span><span class="w"> </span><span class="s2">"MONGO_URL"</span><span class="p">,</span><span class="w">
</span><span class="s2">"value"</span><span class="p">:</span><span class="w"> </span><span class="s2">"mongodb://user:password@host:port/db"</span><span class="w">
</span><span class="p">}</span><span class="w">
</span></code></pre>
</div>
</div></div><div class='row'><div class='col-xs-12 col-sm-6 sidebar-text'>
<h2 id="list-environment-variables-of-an-app">List environment variables of an app</h2>
</div><div class='hidden-xs col-xs-12 col-sm-6 sidebar-code'></div></div><div class='row'><div class='col-xs-12 col-sm-6 sidebar-text'>
<p><code class="highlighter-rouge">GET https://api.scalingo.com/v1/apps/[:app]/variables</code></p>
<p>All the variables are returned, without interpolating anything.</p>
<h3 id="parameters">Parameters</h3>
<ul>
<li>
<p><code class="highlighter-rouge">aliases</code>: (default: <code class="highlighter-rouge">true</code>)</p>
<p>true:</p>
<div class="highlighter-rouge"><pre class="highlight"><code>SCALINGO_MONGO_URL=mongodb://user:password@host:port/db
DATABASE_URL=$SCALINGO_MONGO_URL
</code></pre>
</div>
<p><code class="highlighter-rouge">false</code>:</p>
<div class="highlighter-rouge"><pre class="highlight"><code>SCALINGO_MONGO_URL=mongodb://user:password@host:port/db
DATABASE_URL=mongodb://user:password@host:port/db
</code></pre>
</div>
</li>
</ul>
</div><div class='col-xs-12 col-sm-6 sidebar-code'>
<p>Example request</p>
<div class="highlighter-rouge"><pre class="highlight"><code>curl -H <span class="s2">"Accept: application/json"</span> -H <span class="s2">"Content-Type: application/json"</span> <span class="se">\</span>
-X GET -u :<span class="nv">$AUTH_TOKEN</span> https://api.scalingo.com/v1/apps/example-app/variables
</code></pre>
</div>
<p>Returns 200 OK</p>
<p>Response</p>
<div class="highlighter-rouge"><pre class="highlight"><code><span class="p">{</span><span class="w">
</span><span class="s2">"variables"</span><span class="p">:</span><span class="w"> </span><span class="p">[</span><span class="w">
</span><span class="p">{</span><span class="w">
</span><span class="s2">"id"</span><span class="p">:</span><span class="w"> </span><span class="s2">"541013a9736f7563d5050000"</span><span class="p">,</span><span class="w">
</span><span class="s2">"name"</span><span class="p">:</span><span class="w"> </span><span class="s2">"MONGO_URL"</span><span class="p">,</span><span class="w">
</span><span class="s2">"value"</span><span class="p">:</span><span class="w"> </span><span class="s2">"mongodb://user:password@host:port/db"</span><span class="w">
</span><span class="p">},</span><span class="w">
</span><span class="p">{</span><span class="w">
</span><span class="s2">"id"</span><span class="p">:</span><span class="w"> </span><span class="s2">"54101384736f7563d5040000"</span><span class="p">,</span><span class="w">
</span><span class="s2">"name"</span><span class="p">:</span><span class="w"> </span><span class="s2">"RAILS_PRODUCTION"</span><span class="p">,</span><span class="w">
</span><span class="s2">"value"</span><span class="p">:</span><span class="w"> </span><span class="s2">"production"</span><span class="w">
</span><span class="p">}</span><span class="w">
</span><span class="p">]</span><span class="w">
</span><span class="p">}</span><span class="w">
</span></code></pre>
</div>
</div></div><div class='row'><div class='col-xs-12 col-sm-6 sidebar-text'>
<h2 id="add-environment-variables-to-an-app">Add environment variables to an app</h2>
</div><div class='hidden-xs col-xs-12 col-sm-6 sidebar-code'></div></div><div class='row'><div class='col-xs-12 col-sm-6 sidebar-text'>
<p><code class="highlighter-rouge">POST https://api.scalingo.com/v1/apps/[:app]/variables</code></p>
</div><div class='col-xs-12 col-sm-6 sidebar-code'>
<p>Example request</p>
<div class="highlighter-rouge"><pre class="highlight"><code>curl -H <span class="s2">"Accept: application/json"</span> -H <span class="s2">"Content-Type: application/json"</span> <span class="se">\</span>
-X POST -u :<span class="nv">$AUTH_TOKEN</span> https://api.scalingo.com/v1/apps/example-app/variables -d <span class="se">\</span>
<span class="s1">'{
"variable": {
"name":"RAILS_ENV",
"value":"production"
}
}'</span>
</code></pre>
</div>
<p>Returns 201 Created</p>
<p>Response</p>
<div class="highlighter-rouge"><pre class="highlight"><code><span class="p">{</span><span class="w">
</span><span class="s2">"variable"</span><span class="p">:</span><span class="w"> </span><span class="p">{</span><span class="w">
</span><span class="s2">"id"</span><span class="p">:</span><span class="w"> </span><span class="s2">"541013a9736f7563d5050000"</span><span class="p">,</span><span class="w">
</span><span class="s2">"name"</span><span class="p">:</span><span class="w"> </span><span class="s2">"RAILS_ENV"</span><span class="p">,</span><span class="w">
</span><span class="s2">"value"</span><span class="p">:</span><span class="w"> </span><span class="s2">"production"</span><span class="w">
</span><span class="p">}</span><span class="w">
</span><span class="p">}</span><span class="w">
</span></code></pre>
</div>
</div></div><div class='row'><div class='col-xs-12 col-sm-6 sidebar-text'>
<h2 id="bulk-update-of-the-environment-of-an-app">Bulk update of the environment of an app</h2>
</div><div class='hidden-xs col-xs-12 col-sm-6 sidebar-code'></div></div><div class='row'><div class='col-xs-12 col-sm-6 sidebar-text'>
<p>The bulk update will create or update all the variables sent in the body</p>
<p><code class="highlighter-rouge">PUT https://api.scalingo.com/v1/apps/[:app]/variables</code></p>
</div><div class='col-xs-12 col-sm-6 sidebar-code'>
<p>Example request</p>
<div class="highlighter-rouge"><pre class="highlight"><code>curl -H <span class="s2">"Accept: application/json"</span> -H <span class="s2">"Content-Type: application/json"</span> <span class="se">\</span>
-X PUT -u :<span class="nv">$AUTH_TOKEN</span> https://api.scalingo.com/v1/apps/example-app/variables -d <span class="se">\</span>
<span class="s1">'{
"variables": [{
"name":"RAILS_ENV",
"value":"production"
},{
"name":"RACK_ENV",
"value":"production"
}]
}'</span>
</code></pre>
</div>
<p>Returns 200 OK</p>
<p>Response</p>
<div class="highlighter-rouge"><pre class="highlight"><code><span class="p">{</span><span class="w">
</span><span class="s2">"variables"</span><span class="p">:</span><span class="w"> </span><span class="p">[{</span><span class="w">
</span><span class="s2">"id"</span><span class="p">:</span><span class="w"> </span><span class="s2">"541013a9736f7563d5050000"</span><span class="p">,</span><span class="w">
</span><span class="s2">"name"</span><span class="p">:</span><span class="s2">"RAILS_ENV"</span><span class="p">,</span><span class="w">
</span><span class="s2">"value"</span><span class="p">:</span><span class="s2">"production"</span><span class="w">
</span><span class="p">},{</span><span class="w">
</span><span class="s2">"id"</span><span class="p">:</span><span class="w"> </span><span class="s2">"541013a9736f7563d5050001"</span><span class="p">,</span><span class="w">
</span><span class="s2">"name"</span><span class="p">:</span><span class="s2">"RACK_ENV"</span><span class="p">,</span><span class="w">
</span><span class="s2">"value"</span><span class="p">:</span><span class="s2">"production"</span><span class="w">
</span><span class="p">}]</span><span class="w">
</span><span class="p">}</span><span class="w">
</span></code></pre>
</div>
</div></div><div class='row'><div class='col-xs-12 col-sm-6 sidebar-text'>
<h2 id="update-an-environment-variable">Update an environment variable</h2>
</div><div class='hidden-xs col-xs-12 col-sm-6 sidebar-code'></div></div><div class='row'><div class='col-xs-12 col-sm-6 sidebar-text'>
<p><code class="highlighter-rouge">PATCH https://api.scalingo.com/v1/apps/[:app]/variables/[:variable_id]</code></p>
<p>Update an environment variable, only the value can be updated, if your want to
change the name, create a new one.</p>
</div><div class='col-xs-12 col-sm-6 sidebar-code'>
<p>Example request</p>
<div class="highlighter-rouge"><pre class="highlight"><code>curl -H <span class="s2">"Accept: application/json"</span> -H <span class="s2">"Content-Type: application/json"</span> -u :<span class="nv">$AUTH_TOKEN</span> <span class="se">\</span>
-X PATCH https://api.scalingo.com/v1/apps/example-app/variables/54101384736f7563d5040000 -d <span class="se">\</span>
<span class="s1">'{
"variable": {
"value":"staging"
}
}'</span>
</code></pre>
</div>
<p>Returns 200 OK</p>
<p>Reponse</p>
<div class="highlighter-rouge"><pre class="highlight"><code><span class="p">{</span><span class="w">
</span><span class="s2">"variable"</span><span class="p">:</span><span class="w"> </span><span class="p">{</span><span class="w">
</span><span class="s2">"id"</span><span class="p">:</span><span class="w"> </span><span class="s2">"54101384736f7563d5040000"</span><span class="p">,</span><span class="w">
</span><span class="s2">"name"</span><span class="p">:</span><span class="w"> </span><span class="s2">"RAILS_PRODUCTION"</span><span class="p">,</span><span class="w">
</span><span class="s2">"value"</span><span class="p">:</span><span class="w"> </span><span class="s2">"staging"</span><span class="w">
</span><span class="p">}</span><span class="w">
</span><span class="p">}</span><span class="w">
</span></code></pre>
</div>
</div></div><div class='row'><div class='col-xs-12 col-sm-6 sidebar-text'>
<h2 id="delete-an-environment-variable">Delete an environment variable</h2>
</div><div class='hidden-xs col-xs-12 col-sm-6 sidebar-code'></div></div><div class='row'><div class='col-xs-12 col-sm-6 sidebar-text'>
<p><code class="highlighter-rouge">DELETE https://api.scalingo.com/v1/apps/[:app]/variables/[:variable_id]</code></p>
<p>Delete definitively an environment variable of an app.</p>
</div><div class='col-xs-12 col-sm-6 sidebar-code'>
<p>Example request</p>
<div class="highlighter-rouge"><pre class="highlight"><code>curl -H <span class="s2">"Accept: application/json"</span> -H <span class="s2">"Content-Type: application/json"</span> -u :<span class="nv">$AUTH_TOKEN</span> <span class="se">\</span>
-X DELETE https://api.scalingo.com/v1/apps/example-app/variables/54101384736f7563d5040000
</code></pre>
</div>
<p>Returns 204 No Content</p>
</div></div>