Statistics
| Branch: | Tag: | Revision:

root / docs / astakos-api-guide.rst @ 79b5d61b

History | View | Annotate | Download (14.7 kB)

1
Astakos API
2
===========
3

    
4
This is Astakos API guide.
5

    
6
Overview
7
--------
8

    
9

    
10
Astakos service co-ordinates the access to resources (and the subsequent
11
permission model) and acts as the single point of registry and entry to the
12
GRNET cloud services.
13

    
14
This document's goals is to describe the APIs to the outer world.
15
Make sure you have read the :ref:`astakos` general architecture first.
16

    
17
Document Revisions
18
^^^^^^^^^^^^^^^^^^
19

    
20
=========================  ================================
21
Revision                   Description
22
=========================  ================================
23
0.14 (May 02, 2013)        Change URIs (keep also the old ones until the next version)
24
0.13 (January 21, 2013)    Extend api to export user presentation & quota information.
25
0.6 (June 06, 2012)        Split service and admin API.
26
0.1 (Feb 10, 2012)         Initial release.
27
=========================  ================================
28

    
29
Get Services
30
^^^^^^^^^^^^
31

    
32
Returns a json formatted list containing information about the supported cloud services.
33

    
34
============================= =========  ==================
35
Uri                           Method     Description
36
============================= =========  ==================
37
``/astakos/api/get_services`` GET        Get cloud services
38
============================= =========  ==================
39

    
40
Example reply:
41

    
42
::
43

    
44
    [{"url": "/", "icon": "home-icon.png", "name": "grnet cloud", "id": "1"},
45
    {"url": "/okeanos.html", "name": "~okeanos", "id": "2"},
46
    {"url": "/ui/", "name": "pithos+", "id": "3"}]
47

    
48
.. warning:: The service is also available under ``/im/get_services``.
49
     It  will be removed in the next version.
50

    
51

    
52
Get Menu
53
^^^^^^^^
54

    
55
Returns a json formatted list containing the cloud bar links.
56

    
57
========================= =========  ==================
58
Uri                       Method     Description
59
========================= =========  ==================
60
``/astakos/api/get_menu`` GET        Get cloud bar menu
61
========================= =========  ==================
62

    
63
Example reply if request user is not authenticated:
64

    
65
::
66

    
67
    [{"url": "/im/", "name": "Sign in"}]
68

    
69
Example reply if request user is authenticated:
70

    
71
::
72

    
73
    [{"url": "/im/", "name": "user@example.com"},
74
    {"url": "/im/landing", "name": "Dashboard"},
75
    {"url": "/im/logout", "name": "Sign out"}]
76

    
77
.. warning:: The service is also available under ``/im/get_menu``.
78
     It  will be removed in the next version.
79

    
80
Admin API Operations
81
--------------------
82

    
83
The operations described in this chapter allow users to authenticate themselves, send feedback and get user uuid/displayname mappings.
84

    
85
All the operations require a valid user token.
86

    
87
.. _authenticate-api-label:
88

    
89
Authenticate
90
^^^^^^^^^^^^
91

    
92
Authenticate API requests require a token. An application that wishes to connect to Astakos, but does not have a token, should redirect the user to ``/login``. (see :ref:`authentication-label`)
93

    
94
============================= =========  ==================
95
Uri                           Method     Description
96
============================= =========  ==================
97
``/astakos/api/authenticate`` GET        Authenticate user using token
98
============================= =========  ==================
99

    
100
|
101

    
102
====================  ===========================
103
Request Header Name   Value
104
====================  ===========================
105
X-Auth-Token          User authentication token
106
====================  ===========================
107

    
108
|
109

    
110
======================  =========================
111
Request Parameter Name  Value
112
======================  =========================
113
usage                    (optional)
114
======================  =========================
115

    
116
Extended information on the user serialized in the json format will be returned:
117

    
118
===========================  ============================
119
Name                         Description
120
===========================  ============================
121
displayname                     User displayname
122
uuid                         User unique identifier
123
email                        List with user emails
124
name                         User full name
125
auth_token_created           Token creation date
126
auth_token_expires           Token expiration date
127
usage                        List of user resource usage (if usage request parameter is present)
128
===========================  ============================
129

    
130
Example reply without `usage` request parameter:
131

    
132
::
133

    
134
  {"id": "12",
135
  "displayname": "user@example.com",
136
  "uuid": "a9dc21d2-bcb2-4104-9a9e-402b7c70d6d8",
137
  "email": "[user@example.com]",
138
  "name": "Firstname Lastname",
139
  "auth_token_created": "Wed, 30 May 2012 10:03:37 GMT",
140
  "auth_token_expires": "Fri, 29 Jun 2012 10:03:37 GMT"}
141

    
142
Example reply with `usage` request parameter:
143

    
144
::
145

    
146
  {"id": "12",
147
  "displayname": "user@example.com",
148
  "uuid": "a9dc21d2-bcb2-4104-9a9e-402b7c70d6d8",
149
  "email": "[user@example.com]",
150
  "name": "Firstname Lastname",
151
  "auth_token_created": "Wed, 30 May 2012 10:03:37 GMT",
152
  "auth_token_expires": "Fri, 29 Jun 2012 10:03:37 GMT",
153
  "usage": [{"currValue": 4536392,
154
             "display_name": "Storage Space",
155
             "description": "Pithos account diskspace",
156
             "verbose_name": "Storage Space",
157
             "help_text_input_each": "This is the total amount of space on Pithos that will be granted to each user of this Project ", "maxValue": 5368710653,
158
             "pluralized_display_name": "Storage Space",
159
             "report_desc": "Storage Space",
160
             "help_text": "This is the space on Pithos for storing files and VM Images. ",
161
             "is_abbreviation": false,
162
             "placeholder": "eg. 10GB",
163
             "unit": "bytes",
164
             "name": "pithos+.diskspace"},
165
            {"currValue": 0,
166
             "display_name": "System Disk",
167
             "description": "Virtual machine disk size",
168
             "verbose_name": "System Disk",
169
             "help_text_input_each": "This is the total amount of System Disk that will be granted to each user of this Project (this refers to the total System Disk of all VMs, not each VM's System Disk)  ",
170
             "maxValue": 53687091200,
171
             "pluralized_display_name": "System Disk",
172
             "report_desc": "System Disk",
173
             "help_text": "This is the System Disk that the VMs have that run the OS ",
174
             "is_abbreviation": false,
175
             "placeholder": "eg. 5GB, 2GB etc",
176
             "unit": "bytes",
177
             "name": "cyclades.disk"},
178
            {"currValue": 0,
179
             "display_name": "CPU",
180
             "description": "Number of virtual machine processors",
181
             "verbose_name": "cpu",
182
             "help_text_input_each": "This is the total number of CPUs that will be granted to each user of this Project (on all VMs)  ", "maxValue": 6, "pluralized_display_name": "CPUs",
183
             "report_desc": "CPUs",
184
             "help_text": "CPUs used by VMs ",
185
             "is_abbreviation": true,
186
             "placeholder": "eg. 1",
187
             "unit": "",
188
             "name": "cyclades.cpu"},
189
            {"currValue": 0,
190
             "display_name": "RAM",
191
             "description": "Virtual machines",
192
             "verbose_name": "ram",
193
             "help_text_input_each": "This is the total amount of RAM that will be granted to each user of this Project (on all VMs)  ", "maxValue": 6442450944,
194
             "pluralized_display_name": "RAM",
195
             "report_desc": "RAM",
196
             "help_text": "RAM used by VMs ",
197
             "is_abbreviation": true,
198
             "placeholder": "eg. 4GB",
199
             "unit": "bytes", "name": "cyclades.ram"},
200
            {"currValue": 0, "display_name": "VM",
201
             "description": "Number of virtual machines",
202
             "verbose_name": "vm", "help_text_input_each": "This is the total number of VMs that will be granted to each user of this Project ", "maxValue": 2,
203
             "pluralized_display_name": "VMs",
204
             "report_desc": "Virtual Machines",
205
             "help_text": "These are the VMs one can create on the Cyclades UI ",
206
             "is_abbreviation": true, "placeholder": "eg. 2",
207
             "unit": "",
208
             "name": "cyclades.vm"},
209
            {"currValue": 0,
210
             "display_name": "private network",
211
             "description": "Private networks",
212
             "verbose_name": "private network",
213
             "help_text_input_each": "This is the total number of Private Networks that will be granted to each user of this Project ",
214
             "maxValue": 1,
215
             "pluralized_display_name": "private networks",
216
             "report_desc": "Private Networks",
217
             "help_text": "These are the Private Networks one can create on the Cyclades UI. ",
218
             "is_abbreviation": false,
219
             "placeholder": "eg. 1",
220
             "unit": "",
221
             "name": "cyclades.network.private"}]}
222

    
223

    
224
|
225

    
226
=========================== =====================
227
Return Code                 Description
228
=========================== =====================
229
204 (No Content)            The request succeeded
230
400 (Bad Request)           Method not allowed or no user found
231
401 (Unauthorized)          Missing token or inactive user or penging approval terms
232
500 (Internal Server Error) The request cannot be completed because of an internal error
233
=========================== =====================
234

    
235
.. warning:: The service is also available under ``/im/authenticate``.
236
     It  will be removed in the next version.
237

    
238

    
239
Send feedback
240
^^^^^^^^^^^^^
241

    
242
Post user feedback.
243

    
244
========================= =========  ==================
245
Uri                       Method     Description
246
========================= =========  ==================
247
``astakos/api/feedback``  POST       Send feedback
248
========================= =========  ==================
249

    
250
|
251

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

    
258
|
259

    
260
======================  =========================
261
Request Parameter Name  Value
262
======================  =========================
263
feedback_msg            Feedback message
264
feedback_data           Additional information about service client status
265
======================  =========================
266

    
267
|
268

    
269
=========================== =====================
270
Return Code                 Description
271
=========================== =====================
272
200 (OK)                    The request succeeded
273
502 (Bad Gateway)           Send feedback failure
274
400 (Bad Request)           Method not allowed or invalid message data
275
401 (Unauthorized)          Missing or expired user token
276
500 (Internal Server Error) The request cannot be completed because of an internal error
277
=========================== =====================
278

    
279
Get User catalogs
280
^^^^^^^^^^^^^^^^^
281

    
282
Return a json formatted dictionary containing information about a specific user
283

    
284
================================ =========  ==================
285
Uri                              Method     Description
286
================================ =========  ==================
287
``astakos/api/user_catalogs``    POST       Get 2 catalogs containing uuid to displayname mapping and the opposite
288
================================ =========  ==================
289

    
290
|
291

    
292
====================  ============================
293
Request Header Name   Value
294
====================  ============================
295
X-Auth-Token          User authentication token
296
====================  ============================
297

    
298
|
299

    
300
The request body is a json formatted dictionary containing a list with uuids and another list of displaynames to translate.
301

    
302
Example request content:
303

    
304
::
305

    
306
  {"displaynames": ["user1@example.com", "user2@example.com"],
307
   "uuids":["ff53baa9-c025-4d56-a6e3-963db0438830", "a9dc21d2-bcb2-4104-9a9e-402b7c70d6d8"]}
308

    
309
Example reply:
310

    
311
::
312

    
313
  {"displayname_catalog": {"user1@example.com": "a9dc21d2-bcb2-4104-9a9e-402b7c70d6d8",
314
                           "user2@example.com": "816351c7-7405-4f26-a968-6380cf47ba1f"},
315
  'uuid_catalog': {"a9dc21d2-bcb2-4104-9a9e-402b7c70d6d8": "user1@example.com",
316
                   "ff53baa9-c025-4d56-a6e3-963db0438830": "user2@example.com"}}
317

    
318

    
319
|
320

    
321
=========================== =====================
322
Return Code                 Description
323
=========================== =====================
324
200 (OK)                    The request succeeded
325
400 (Bad Request)           Method not allowed or request body is not json formatted
326
401 (Unauthorized)          Missing or expired or invalid user token
327
500 (Internal Server Error) The request cannot be completed because of an internal error
328
=========================== =====================
329

    
330
Service API Operations
331
----------------------
332

    
333
The operations described in this chapter allow services to get user uuid/displayname mappings.
334

    
335
All the operations require a valid service token.
336

    
337
Get User catalogs
338
^^^^^^^^^^^^^^^^^
339

    
340
Return a json formatted dictionary containing information about a specific user
341

    
342
===================================== =========  ==================
343
Uri                                   Method     Description
344
===================================== =========  ==================
345
``astakos/api/service/user_catalogs`` POST       Get 2 catalogs containing uuid to displayname mapping and the opposite
346
===================================== =========  ==================
347

    
348
|
349

    
350
====================  ============================
351
Request Header Name   Value
352
====================  ============================
353
X-Auth-Token          Service authentication token
354
====================  ============================
355

    
356
|
357

    
358
The request body is a json formatted dictionary containing a list with uuids and another list of displaynames to translate.
359
If instead of list null is passed then the response contains the information for all the system users (For discretion purposes
360
this behavior is **not** exposed in the respective call of the User API).
361

    
362
Example request content:
363

    
364
::
365

    
366
  {"displaynames": ["user1@example.com", "user2@example.com"],
367
   "uuids":["ff53baa9-c025-4d56-a6e3-963db0438830", "a9dc21d2-bcb2-4104-9a9e-402b7c70d6d8"]}
368

    
369
Example reply:
370

    
371
::
372

    
373
  {"displayname_catalog": {"user1@example.com": "a9dc21d2-bcb2-4104-9a9e-402b7c70d6d8",
374
                           "user2@example.com": "816351c7-7405-4f26-a968-6380cf47ba1f"},
375
  'uuid_catalog': {"a9dc21d2-bcb2-4104-9a9e-402b7c70d6d8": "user1@example.com",
376
                   "ff53baa9-c025-4d56-a6e3-963db0438830": "user2@example.com"}}
377

    
378

    
379
|
380

    
381
=========================== =====================
382
Return Code                 Description
383
=========================== =====================
384
200 (OK)                    The request succeeded
385
400 (Bad Request)           Method not allowed or request body is not json formatted
386
401 (Unauthorized)          Missing or expired or invalid service token
387
500 (Internal Server Error) The request cannot be completed because of an internal error
388
=========================== =====================