Revision b32b5995

b/docs/dev-guide.rst
16 16

  
17 17
   IM API <astakos-api-guide>
18 18

  
19
Resource and Quota API (Astakos)
20
================================
21

  
22
.. toctree::
23
    :maxdepth: 2
24

  
25
    Resource and Quota API <quota-api-guide.rst>
26

  
19 27
Compute API (Cyclades)
20 28
======================
21 29

  
b/docs/quota-api-guide.rst
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
      "client_key": "cyclades",
127
      "force": false,
128
      "auto_accept": false,
129
      "provisions": [
130
          {
131
              "holder": "c02f315b-7d84-45bc-a383-552a3f97d2ad",
132
              "source": "system",
133
              "resource": "cyclades.vm",
134
              "quantity": 1
135
          },
136
          {
137
              "holder": "c02f315b-7d84-45bc-a383-552a3f97d2ad",
138
              "source": "system",
139
              "resource": "cyclades.ram",
140
              "quantity": 536870912
141
          }
142
      ]
143
  }
144

  
145
**Example Successful Response**:
146

  
147
.. code-block:: javascript
148

  
149
  {
150
      "serial": 57
151
  }
152

  
153
**Example Failure Response**:
154

  
155
.. code-block:: javascript
156

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

  
174
Get Pending Commissions
175
.......................
176

  
177
**GET** /astakos/api/commissions
178

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

  
185
======================  ======================
186
Request Parameter Name  Value
187
======================  ======================
188
client_key              Quotaholder client key
189
======================  ======================
190

  
191
**Normal Response Code**: 200
192

  
193
**Error Response Codes**:
194

  
195
======  ============================
196
Status  Description
197
======  ============================
198
401     Unauthorized (Missing token)
199
500     Internal Server Error
200
======  ============================
201

  
202
**Example Successful Response**:
203

  
204
.. code-block:: javascript
205

  
206
  [<serial>, ...]
207

  
208
Get the Description of a Commission
209
...................................
210

  
211
**GET** /astakos/api/commissions/<serial>
212

  
213
====================  ============================
214
Request Header Name   Value
215
====================  ============================
216
X-Auth-Token          Service authentication token
217
====================  ============================
218

  
219
======================  ======================
220
Request Parameter Name  Value
221
======================  ======================
222
client_key              Quotaholder client key
223
======================  ======================
224

  
225
**Normal Response Code**: 200
226

  
227
**Error Response Codes**:
228

  
229
======  ============================
230
Status  Description
231
======  ============================
232
401     Unauthorized (Missing token)
233
404     Commission Not Found
234
500     Internal Server Error
235
======  ============================
236

  
237
**Example Successful Response**:
238

  
239
.. code-block:: javascript
240

  
241
  {
242
      "serial": 57,
243
      "issue_time": "2013-04-08T10:19:15.0373",
244
      "provisions": [
245
          {
246
              "holder": "c02f315b-7d84-45bc-a383-552a3f97d2ad",
247
              "source": "system",
248
              "resource": "cyclades.vm",
249
              "quantity": 1
250
          },
251
          {
252
              "holder": "c02f315b-7d84-45bc-a383-552a3f97d2ad",
253
              "source": "system",
254
              "resource": "cyclades.ram",
255
              "quantity": 536870912
256
          }
257
      ]
258
  }
259

  
260
Accept or Reject a Commission
261
.............................
262

  
263
**POST** /astakos/api/commissions/<serial>/action
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 Requests**:
284

  
285
.. code-block:: javascript
286

  
287
  {
288
      "client_key": "cyclades",
289
      "accept": ""
290
  }
291

  
292
  {
293
      "client_key": "cyclades",
294
      "reject": ""
295
  }
296

  
297
Accept or Reject Multiple Commissions
298
.....................................
299

  
300
**POST** /astakos/api/commissions/action
301

  
302
====================  ============================
303
Request Header Name   Value
304
====================  ============================
305
X-Auth-Token          Service authentication token
306
====================  ============================
307

  
308
**Normal Response Code**: 200
309

  
310
**Error Response Codes**:
311

  
312
======  ============================
313
Status  Description
314
======  ============================
315
401     Unauthorized (Missing token)
316
500     Internal Server Error
317
======  ============================
318

  
319
**Example Request**:
320

  
321
.. code-block:: javascript
322

  
323
  {
324
      "client_key": "cyclades",
325
      "accept": [56, 57],
326
      "reject": [56, 58, 59]
327
  }
328

  
329
**Example Successful Response**:
330

  
331
.. code-block:: javascript
332

  
333
  { "accepted": [57],
334
    "rejected": [59],
335
    "failed": [
336
        [56, {
337
                 "badRequest": {
338
                     "message": "cannot both accept and reject serial 56",
339
                     "code": 400
340
                     }
341
                 }
342
        ],
343
        [58, {
344
                 "itemNotFound": {
345
                     "message": "serial 58 does not exist",
346
                     "code": 404
347
                     }
348
                 }
349
        ]
350
    ]
351
  }
352

  

Also available in: Unified diff