Statistics
| Branch: | Tag: | Revision:

root / docs / quota-api-guide.rst @ a4398c8c

History | View | Annotate | Download (7.5 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
              "available": 536870912,
69
              "limit": 1073741824,
70
              "used": 536870912
71
          },
72
          "cyclades.vm": {
73
              "available": 0,
74
              "limit": 2,
75
              "used": 2
76
          }
77
      },
78
      "project:1": {
79
          "cyclades.ram": {
80
              "available": 0,
81
              "limit": 2147483648,
82
              "used": 2147483648
83
          },
84
          "cyclades.vm": {
85
              "available": 3,
86
              "limit": 5,
87
              "used": 2
88
          }
89
      }
90
  }
91

    
92
Commissions
93
-----------
94

    
95
Issue Commission
96
................
97

    
98
**POST** /astakos/api/commissions
99

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

    
106
**Normal Response Code**: 201
107

    
108
**Error Response Codes**:
109

    
110
======  =======================================================
111
Status  Description
112
======  =======================================================
113
400     Commission failed due to invalid input data
114
401     Unauthorized (Missing token)
115
404     Cannot find one of the target holdings
116
413     A quantity fell below zero in one of the holdings
117
413     A quantity exceeded the capacity in one of the holdings
118
500     Internal Server Error
119
======  =======================================================
120

    
121
**Example Request**:
122

    
123
.. code-block:: javascript
124

    
125
  {
126
      "force": false,
127
      "auto_accept": false,
128
      "provisions": [
129
          {
130
              "holder": "c02f315b-7d84-45bc-a383-552a3f97d2ad",
131
              "source": "system",
132
              "resource": "cyclades.vm",
133
              "quantity": 1
134
          },
135
          {
136
              "holder": "c02f315b-7d84-45bc-a383-552a3f97d2ad",
137
              "source": "system",
138
              "resource": "cyclades.ram",
139
              "quantity": 536870912
140
          }
141
      ]
142
  }
143

    
144
**Example Successful Response**:
145

    
146
.. code-block:: javascript
147

    
148
  {
149
      "serial": 57
150
  }
151

    
152
**Example Failure Response**:
153

    
154
.. code-block:: javascript
155

    
156
  {
157
      "overLimit": {
158
          "message": "a human-readable error message",
159
          "code": 413,
160
          "data": {
161
              "provision": {
162
                  "holder": "c02f315b-7d84-45bc-a383-552a3f97d2ad",
163
                  "source": "system",
164
                  "resource": "cyclades.vm",
165
                  "quantity": 1
166
              },
167
              "name": "NoCapacityError",
168
              "available": 0
169
          }
170
      }
171
  }
172

    
173
Get Pending Commissions
174
.......................
175

    
176
**GET** /astakos/api/commissions
177

    
178
====================  ============================
179
Request Header Name   Value
180
====================  ============================
181
X-Auth-Token          Service authentication token
182
====================  ============================
183

    
184
**Normal Response Code**: 200
185

    
186
**Error Response Codes**:
187

    
188
======  ============================
189
Status  Description
190
======  ============================
191
401     Unauthorized (Missing token)
192
500     Internal Server Error
193
======  ============================
194

    
195
**Example Successful Response**:
196

    
197
.. code-block:: javascript
198

    
199
  [<serial>, ...]
200

    
201
Get the Description of a Commission
202
...................................
203

    
204
**GET** /astakos/api/commissions/<serial>
205

    
206
====================  ============================
207
Request Header Name   Value
208
====================  ============================
209
X-Auth-Token          Service authentication token
210
====================  ============================
211

    
212
**Normal Response Code**: 200
213

    
214
**Error Response Codes**:
215

    
216
======  ============================
217
Status  Description
218
======  ============================
219
401     Unauthorized (Missing token)
220
404     Commission Not Found
221
500     Internal Server Error
222
======  ============================
223

    
224
**Example Successful Response**:
225

    
226
.. code-block:: javascript
227

    
228
  {
229
      "serial": 57,
230
      "issue_time": "2013-04-08T10:19:15.0373",
231
      "provisions": [
232
          {
233
              "holder": "c02f315b-7d84-45bc-a383-552a3f97d2ad",
234
              "source": "system",
235
              "resource": "cyclades.vm",
236
              "quantity": 1
237
          },
238
          {
239
              "holder": "c02f315b-7d84-45bc-a383-552a3f97d2ad",
240
              "source": "system",
241
              "resource": "cyclades.ram",
242
              "quantity": 536870912
243
          }
244
      ]
245
  }
246

    
247
Accept or Reject a Commission
248
.............................
249

    
250
**POST** /astakos/api/commissions/<serial>/action
251

    
252
====================  ============================
253
Request Header Name   Value
254
====================  ============================
255
X-Auth-Token          Service authentication token
256
====================  ============================
257

    
258
**Normal Response Code**: 200
259

    
260
**Error Response Codes**:
261

    
262
======  ============================
263
Status  Description
264
======  ============================
265
401     Unauthorized (Missing token)
266
404     Commission Not Found
267
500     Internal Server Error
268
======  ============================
269

    
270
**Example Requests**:
271

    
272
.. code-block:: javascript
273

    
274
  {
275
      "accept": ""
276
  }
277

    
278
  {
279
      "reject": ""
280
  }
281

    
282
Accept or Reject Multiple Commissions
283
.....................................
284

    
285
**POST** /astakos/api/commissions/action
286

    
287
====================  ============================
288
Request Header Name   Value
289
====================  ============================
290
X-Auth-Token          Service authentication token
291
====================  ============================
292

    
293
**Normal Response Code**: 200
294

    
295
**Error Response Codes**:
296

    
297
======  ============================
298
Status  Description
299
======  ============================
300
401     Unauthorized (Missing token)
301
500     Internal Server Error
302
======  ============================
303

    
304
**Example Request**:
305

    
306
.. code-block:: javascript
307

    
308
  {
309
      "accept": [56, 57],
310
      "reject": [56, 58, 59]
311
  }
312

    
313
**Example Successful Response**:
314

    
315
.. code-block:: javascript
316

    
317
  { "accepted": [57],
318
    "rejected": [59],
319
    "failed": [
320
        [56, {
321
                 "badRequest": {
322
                     "message": "cannot both accept and reject serial 56",
323
                     "code": 400
324
                     }
325
                 }
326
        ],
327
        [58, {
328
                 "itemNotFound": {
329
                     "message": "serial 58 does not exist",
330
                     "code": 404
331
                     }
332
                 }
333
        ]
334
    ]
335
  }