Statistics
| Branch: | Tag: | Revision:

root / docs / quota-api-guide.rst @ 480974e6

History | View | Annotate | Download (8.9 kB)

1
Resources
2
---------
3

    
4
Get Resource List
5
.................
6

    
7
**GET** /astakos/api/resources
8

    
9
**Normal Response Code**: 200
10

    
11
**Error Response Codes**:
12

    
13
======  =====================
14
Status  Description
15
======  =====================
16
500     Internal Server Error
17
======  =====================
18

    
19
**Example Successful Response**:
20

    
21
.. code-block:: javascript
22

    
23
  {
24
      "cyclades.vm": {
25
          "unit": null,
26
          "description": "Number of virtual machines",
27
          "service": "cyclades"
28
          },
29
      "cyclades.ram": {
30
          "unit": "bytes",
31
          "description": "Virtual machine memory",
32
          "service": "cyclades"
33
          }
34
  }
35

    
36
Quotas
37
------
38

    
39
Get Quotas
40
..........
41

    
42
**GET** /astakos/api/quotas
43

    
44
====================  =========================
45
Request Header Name   Value
46
====================  =========================
47
X-Auth-Token          User authentication token
48
====================  =========================
49

    
50
**Normal Response Code**: 200
51

    
52
**Error Response Codes**:
53

    
54
======  ============================
55
Status  Description
56
======  ============================
57
401     Unauthorized (Missing token)
58
500     Internal Server Error
59
======  ============================
60

    
61
**Example Successful Response**:
62

    
63
.. code-block:: javascript
64

    
65
  {
66
      "system": {
67
          "cyclades.ram": {
68
              "usage": 536870912,
69
              "limit": 1073741824,
70
              "pending": 0
71

    
72
          },
73
          "cyclades.vm": {
74
              "usage": 2,
75
              "limit": 2,
76
              "pending": 0
77
          }
78
      },
79
      "project:1": {
80
          "cyclades.ram": {
81
              "usage": 2147483648,
82
              "limit": 2147483648,
83
              "pending": 0
84
          },
85
          "cyclades.vm": {
86
              "usage": 2,
87
              "limit": 5,
88
              "pending": 1
89
          }
90
      }
91
  }
92

    
93
Get Quotas per Service
94
......................
95

    
96
**GET** /astakos/api/service_quotas
97

    
98
====================  ============================
99
Request Header Name   Value
100
====================  ============================
101
X-Auth-Token          Service authentication token
102
====================  ============================
103

    
104
Optional GET parameter: ?user=<uuid>
105

    
106
**Normal Response Code**: 200
107

    
108
**Error Response Codes**:
109

    
110
======  ============================
111
Status  Description
112
======  ============================
113
401     Unauthorized (Missing token)
114
500     Internal Server Error
115
======  ============================
116

    
117
**Example Successful Response**:
118

    
119
.. code-block:: javascript
120

    
121
  {
122
      "1a6165d0-5020-4b6d-a4ad-83476632a584": {
123
          "system": {
124
              "cyclades.ram": {
125
                  "usage": 536870912,
126
                  "limit": 1073741824,
127
                  "pending": 0
128
              },
129
              "cyclades.vm": {
130
                  "usage": 2,
131
                  "limit": 2,
132
                  "pending": 0
133
              }
134
          },
135
          "project:1": {
136
              "cyclades.ram": {
137
                  "usage": 2147483648,
138
                  "limit": 2147483648,
139
                  "pending": 0
140
              },
141
              "cyclades.vm": {
142
                  "usage": 2,
143
                  "limit": 5,
144
                  "pending": 1
145
              }
146
          }
147
      }
148
  }
149

    
150
Commissions
151
-----------
152

    
153
Issue Commission
154
................
155

    
156
**POST** /astakos/api/commissions
157

    
158
====================  ============================
159
Request Header Name   Value
160
====================  ============================
161
X-Auth-Token          Service authentication token
162
====================  ============================
163

    
164
**Normal Response Code**: 201
165

    
166
**Error Response Codes**:
167

    
168
======  =======================================================
169
Status  Description
170
======  =======================================================
171
400     Commission failed due to invalid input data
172
401     Unauthorized (Missing token)
173
404     Cannot find one of the target holdings
174
413     A quantity fell below zero in one of the holdings
175
413     A quantity exceeded the capacity in one of the holdings
176
500     Internal Server Error
177
======  =======================================================
178

    
179
**Example Request**:
180

    
181
.. code-block:: javascript
182

    
183
  {
184
      "force": false,
185
      "auto_accept": false,
186
      "provisions": [
187
          {
188
              "holder": "c02f315b-7d84-45bc-a383-552a3f97d2ad",
189
              "source": "system",
190
              "resource": "cyclades.vm",
191
              "quantity": 1
192
          },
193
          {
194
              "holder": "c02f315b-7d84-45bc-a383-552a3f97d2ad",
195
              "source": "system",
196
              "resource": "cyclades.ram",
197
              "quantity": 536870912
198
          }
199
      ]
200
  }
201

    
202
**Example Successful Response**:
203

    
204
.. code-block:: javascript
205

    
206
  {
207
      "serial": 57
208
  }
209

    
210
**Example Failure Response**:
211

    
212
.. code-block:: javascript
213

    
214
  {
215
      "overLimit": {
216
          "message": "a human-readable error message",
217
          "code": 413,
218
          "data": {
219
              "provision": {
220
                  "holder": "c02f315b-7d84-45bc-a383-552a3f97d2ad",
221
                  "source": "system",
222
                  "resource": "cyclades.vm",
223
                  "quantity": 1
224
              },
225
              "name": "NoCapacityError",
226
              "limit": 2,
227
              "usage": 2
228
          }
229
      }
230
  }
231

    
232
Get Pending Commissions
233
.......................
234

    
235
**GET** /astakos/api/commissions
236

    
237
====================  ============================
238
Request Header Name   Value
239
====================  ============================
240
X-Auth-Token          Service authentication token
241
====================  ============================
242

    
243
**Normal Response Code**: 200
244

    
245
**Error Response Codes**:
246

    
247
======  ============================
248
Status  Description
249
======  ============================
250
401     Unauthorized (Missing token)
251
500     Internal Server Error
252
======  ============================
253

    
254
**Example Successful Response**:
255

    
256
.. code-block:: javascript
257

    
258
  [<serial>, ...]
259

    
260
Get the Description of a Commission
261
...................................
262

    
263
**GET** /astakos/api/commissions/<serial>
264

    
265
====================  ============================
266
Request Header Name   Value
267
====================  ============================
268
X-Auth-Token          Service authentication token
269
====================  ============================
270

    
271
**Normal Response Code**: 200
272

    
273
**Error Response Codes**:
274

    
275
======  ============================
276
Status  Description
277
======  ============================
278
401     Unauthorized (Missing token)
279
404     Commission Not Found
280
500     Internal Server Error
281
======  ============================
282

    
283
**Example Successful Response**:
284

    
285
.. code-block:: javascript
286

    
287
  {
288
      "serial": 57,
289
      "issue_time": "2013-04-08T10:19:15.0373",
290
      "provisions": [
291
          {
292
              "holder": "c02f315b-7d84-45bc-a383-552a3f97d2ad",
293
              "source": "system",
294
              "resource": "cyclades.vm",
295
              "quantity": 1
296
          },
297
          {
298
              "holder": "c02f315b-7d84-45bc-a383-552a3f97d2ad",
299
              "source": "system",
300
              "resource": "cyclades.ram",
301
              "quantity": 536870912
302
          }
303
      ]
304
  }
305

    
306
Accept or Reject a Commission
307
.............................
308

    
309
**POST** /astakos/api/commissions/<serial>/action
310

    
311
====================  ============================
312
Request Header Name   Value
313
====================  ============================
314
X-Auth-Token          Service authentication token
315
====================  ============================
316

    
317
**Normal Response Code**: 200
318

    
319
**Error Response Codes**:
320

    
321
======  ============================
322
Status  Description
323
======  ============================
324
401     Unauthorized (Missing token)
325
404     Commission Not Found
326
500     Internal Server Error
327
======  ============================
328

    
329
**Example Requests**:
330

    
331
.. code-block:: javascript
332

    
333
  {
334
      "accept": ""
335
  }
336

    
337
  {
338
      "reject": ""
339
  }
340

    
341
Accept or Reject Multiple Commissions
342
.....................................
343

    
344
**POST** /astakos/api/commissions/action
345

    
346
====================  ============================
347
Request Header Name   Value
348
====================  ============================
349
X-Auth-Token          Service authentication token
350
====================  ============================
351

    
352
**Normal Response Code**: 200
353

    
354
**Error Response Codes**:
355

    
356
======  ============================
357
Status  Description
358
======  ============================
359
401     Unauthorized (Missing token)
360
500     Internal Server Error
361
======  ============================
362

    
363
**Example Request**:
364

    
365
.. code-block:: javascript
366

    
367
  {
368
      "accept": [56, 57],
369
      "reject": [56, 58, 59]
370
  }
371

    
372
**Example Successful Response**:
373

    
374
.. code-block:: javascript
375

    
376
  { "accepted": [57],
377
    "rejected": [59],
378
    "failed": [
379
        [56, {
380
                 "badRequest": {
381
                     "message": "cannot both accept and reject serial 56",
382
                     "code": 400
383
                     }
384
                 }
385
        ],
386
        [58, {
387
                 "itemNotFound": {
388
                     "message": "serial 58 does not exist",
389
                     "code": 404
390
                     }
391
                 }
392
        ]
393
    ]
394
  }