Revision 890c2065 docs/astakos-api-guide.rst

b/docs/astakos-api-guide.rst
20 20
=========================  ================================
21 21
Revision                   Description
22 22
=========================  ================================
23
0.13 (January 21, 2013)    Extend api to export user presentation & quota information.
23 24
0.6 (June 06, 2012)        Split service and admin API.
24 25
0.1 (Feb 10, 2012)         Initial release.
25 26
=========================  ================================
26 27

  
27
Admin API Operations
28
--------------------
28
Get Services
29
^^^^^^^^^^^^
29 30

  
30
The operations described in this chapter allow users to authenticate themselves and priviledged users (ex. helpdesk) to access other user information.
31
Returns a json formatted list containing information about the supported cloud services.
31 32

  
32
Most of the operations require a valid token assigned to users having the necessary permissions.
33
==================== =========  ==================
34
Uri                  Method     Description
35
==================== =========  ==================
36
``/im/get_services`` GET        Get cloud services
37
==================== =========  ==================
33 38

  
34
.. _authenticate-api-label:
39
Example reply:
35 40

  
36
Authenticate
37
^^^^^^^^^^^^
41
::
38 42

  
39
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`)
43
    [{"url": "/", "icon": "home-icon.png", "name": "grnet cloud", "id": "1"},
44
    {"url": "/okeanos.html", "name": "~okeanos", "id": "2"},
45
    {"url": "/ui/", "name": "pithos+", "id": "3"}]
46

  
47

  
48
Get Menu
49
^^^^^^^^
50

  
51
Returns a json formatted list containing the cloud bar links.
40 52

  
41 53
==================== =========  ==================
42 54
Uri                  Method     Description
43 55
==================== =========  ==================
44
``/im/authenticate`` GET        Authenticate user using token
56
``/im/get_menu``     GET        Get cloud bar menu
45 57
==================== =========  ==================
46 58

  
47
|
48

  
49
====================  ===========================
50
Request Header Name   Value
51
====================  ===========================
52
X-Auth-Token          Authentication token
53
====================  ===========================
59
Example reply if request user is not authenticated:
54 60

  
55
Extended information on the user serialized in the json format will be returned:
61
::
56 62

  
57
===========================  ============================
58
Name                         Description
59
===========================  ============================
60
username                     User uniq identifier
61
uniq                         User email (uniq identifier used by Astakos)
62
auth_token                   Authentication token
63
auth_token_expires           Token expiration date
64
auth_token_created           Token creation date
65
has_credits                  Whether user has credits
66
has_signed_terms             Whether user has aggred on terms
67
groups                       User groups
68
===========================  ============================
63
    [{"url": "/im/", "name": "Sign in"}]
69 64

  
70
Example reply:
65
Example reply if request user is authenticated:
71 66

  
72 67
::
73 68

  
74
  {"username": "4ad9f34d6e7a4992b34502d40f40cb",
75
  "uniq": "user@example.com"
76
  "auth_token": "0000",
77
  "auth_token_expires": "Fri, 29 Jun 2012 10:03:37 GMT",
78
  "auth_token_created": "Wed, 30 May 2012 10:03:37 GMT",
79
  "has_credits": false,
80
  "has_signed_terms": true}
69
    [{"url": "/im/login", "name": "user@example.com"},
70
    {"url": "/im/profile", "name": "My account"},
71
    {"url": "/im/logout", "name": "Sign out"}]
81 72

  
82
|
73
Admin API Operations
74
--------------------
83 75

  
84
=========================== =====================
85
Return Code                 Description
86
=========================== =====================
87
204 (No Content)            The request succeeded
88
400 (Bad Request)           Method not allowed or no user found
89
401 (Unauthorized)          Missing token or inactive user or penging approval terms
90
500 (Internal Server Error) The request cannot be completed because of an internal error
91
=========================== =====================
76
The operations described in this chapter allow users to authenticate themselves and priviledged users (ex. helpdesk) to access other user information.
92 77

  
93
Get User by email
94
^^^^^^^^^^^^^^^^^
78
Most of the operations require a valid token assigned to users having the necessary permissions.
95 79

  
96
Returns a json formatted dictionary containing information about a specific user
80
.. _authenticate-api-label:
81

  
82
Authenticate
83
^^^^^^^^^^^^
97 84

  
98
============================== =========  ==================
99
Uri                            Method     Description
100
============================== =========  ==================
101
``/im/admin/api/v2.0/users/``  GET        Get user information by email
102
============================== =========  ==================
85
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`)
86

  
87
==================== =========  ==================
88
Uri                  Method     Description
89
==================== =========  ==================
90
``/im/authenticate`` GET        Authenticate user using token
91
==================== =========  ==================
103 92

  
104 93
|
105 94

  
106 95
====================  ===========================
107 96
Request Header Name   Value
108 97
====================  ===========================
109
X-Auth-Token          Authentication token owned by
110
                      a user having or inheriting ``im.can_access_userinfo`` permission
98
X-Auth-Token          User authentication token
111 99
====================  ===========================
112 100

  
113 101
|
......
115 103
======================  =========================
116 104
Request Parameter Name  Value
117 105
======================  =========================
118
name                    Email
106
usage                    (optional)
119 107
======================  =========================
120 108

  
109
Extended information on the user serialized in the json format will be returned:
121 110

  
122
|
123

  
124
=========================== =====================
125
Return Code                 Description
126
=========================== =====================
127
200 (OK)                    The request succeeded
128
400 (Bad Request)           Method not allowed
129
401 (Unauthorized)          Missing or invalid token or unauthorized user
130
404 (Not Found)             Missing email or inactive user
131
500 (Internal Server Error) The request cannot be completed because of an internal error
132
=========================== =====================
111
===========================  ============================
112
Name                         Description
113
===========================  ============================
114
displayname                     User displayname
115
uuid                         User unique identifier
116
email                        List with user emails
117
name                         User full name
118
auth_token_created           Token creation date
119
auth_token_expires           Token expiration date
120
usage                        List of user resource usage (if usage request parameter is present)
121
===========================  ============================
133 122

  
134
Example reply:
123
Example reply without `usage` request parameter:
135 124

  
136 125
::
137 126

  
138
    {"username": "7e530044f90a4e7ba2cb94f3a26c40",
139
    "auth_token_created": "Wed, 30 May 2012 10:03:37 GMT",
140
    "name": "Firstname Surname",
141
    "groups": ["default"],
142
    "user_permissions": [],
143
    "has_credits": false,
144
    "auth_token_expires":"Fri, 29 Jun 2012 10:03:37 GMT",
145
    "enabled": true,
146
    "email": ["user@example.com"],
147
    "id": 4}
127
  {"id": "12",
128
  "displayname": "user@example.com",
129
  "uuid": "a9dc21d2-bcb2-4104-9a9e-402b7c70d6d8",
130
  "email": "[user@example.com]",
131
  "name": "Firstname Lastname",
132
  "auth_token_created": "Wed, 30 May 2012 10:03:37 GMT",
133
  "auth_token_expires": "Fri, 29 Jun 2012 10:03:37 GMT"}
148 134

  
149
Get User by username
150
^^^^^^^^^^^^^^^^^^^^
135
Example reply with `usage` request parameter:
151 136

  
152
Returns a json formatted dictionary containing information about a specific user
153

  
154
======================================== =========  ==================
155
Uri                                      Method     Description
156
======================================== =========  ==================
157
``/im/admin/api/v2.0/users/{username}``  GET        Get user information by username
158
======================================== =========  ==================
137
::
159 138

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

  
162
====================  ===========================
163
Request Header Name   Value
164
====================  ===========================
165
X-Auth-Token          Authentication token owned
166
                      by a user having or inheriting ``im.can_access_userinfo`` permission
167
====================  ===========================
168 216

  
169 217
|
170 218

  
171 219
=========================== =====================
172 220
Return Code                 Description
173 221
=========================== =====================
174
200 (OK)                    The request succeeded
175
400 (Bad Request)           Method not allowed
176
401 (Unauthorized)          Missing or invalid token or unauthorized user
177
404 (Not Found)             Invalid username
222
204 (No Content)            The request succeeded
223
400 (Bad Request)           Method not allowed or no user found
224
401 (Unauthorized)          Missing token or inactive user or penging approval terms
178 225
500 (Internal Server Error) The request cannot be completed because of an internal error
179 226
=========================== =====================
180 227

  
181
Example reply:
182

  
183
::
184

  
185
    {"username": "7e530044f90a4e7ba2cb94f3a26c40",
186
    "auth_token_created": "Wed, 30 May 2012 10:03:37 GMT",
187
    "name": "Firstname Surname",
188
    "groups": ["default"],
189
    "user_permissions": [],
190
    "has_credits": false,
191
    "auth_token_expires":
192
    "Fri, 29 Jun 2012 10:03:37 GMT",
193
    "enabled": true,
194
    "email": ["user@example.com"],
195
    "id": 4}
196

  
197
Get Services
198
^^^^^^^^^^^^
199

  
200
Returns a json formatted list containing information about the supported cloud services.
201

  
202
==================== =========  ==================
203
Uri                  Method     Description
204
==================== =========  ==================
205
``/im/get_services`` GET        Get cloud services
206
==================== =========  ==================
207

  
208
Example reply:
209

  
210
::
211

  
212
    [{"url": "/", "icon": "home-icon.png", "name": "grnet cloud", "id": "1"},
213
    {"url": "/okeanos.html", "name": "~okeanos", "id": "2"},
214
    {"url": "/ui/", "name": "pithos+", "id": "3"}]
215

  
216

  
217
Get Menu
218
^^^^^^^^
219

  
220
Returns a json formatted list containing the cloud bar links. 
221

  
222
==================== =========  ==================
223
Uri                  Method     Description
224
==================== =========  ==================
225
``/im/get_menu``     GET        Get cloud bar menu
226
==================== =========  ==================
227

  
228
Example reply if request user is not authenticated:
229

  
230
::
231

  
232
    [{"url": "/im/", "name": "Sign in"}]
233

  
234
Example reply if request user is authenticated:
235

  
236
::
237

  
238
    [{"url": "/im/login", "name": "user@example.com"},
239
    {"url": "/im/profile", "name": "My account"},
240
    {"url": "/im/logout", "name": "Sign out"}]
241

  
242
Service API Operations
243
----------------------
244

  
245
The operations described in this chapter allow services to access user information and perform specific tasks.
246

  
247
The operations require a valid service token.
248 228

  
249 229
Send feedback
250 230
^^^^^^^^^^^^^
......
254 234
========================= =========  ==================
255 235
Uri                       Method     Description
256 236
========================= =========  ==================
257
``/im/service/feedback``  POST       Send feedback
237
``/feedback``             POST       Send feedback
258 238
========================= =========  ==================
259 239

  
260 240
|
......
262 242
====================  ============================
263 243
Request Header Name   Value
264 244
====================  ============================
265
X-Auth-Token          Service Authentication token
245
X-Auth-Token          User authentication token
266 246
====================  ============================
267 247

  
268 248
|
......
270 250
======================  =========================
271 251
Request Parameter Name  Value
272 252
======================  =========================
273
auth_token              User token
274 253
feedback_msg            Feedback message
275 254
feedback_data           Additional information about service client status
276 255
======================  =========================
......
281 260
Return Code                 Description
282 261
=========================== =====================
283 262
200 (OK)                    The request succeeded
263
502 (Bad Gateway)           Send feedback failure
284 264
400 (Bad Request)           Method not allowed or missing or invalid user token parameter or invalid message data
285 265
401 (Unauthorized)          Missing or expired service token
286 266
500 (Internal Server Error) The request cannot be completed because of an internal error
287 267
=========================== =====================
288 268

  
289
Get User by email
290
^^^^^^^^^^^^^^^^^
269
Get User catalog
270
^^^^^^^^^^^^^^^^
291 271

  
292 272
Returns a json formatted dictionary containing information about a specific user
293 273

  
294 274
================================ =========  ==================
295 275
Uri                              Method     Description
296 276
================================ =========  ==================
297
``/im/service/api/v2.0/users/``  GET        Get user information by email
277
``/user_catalogs``               POST       Get 2 catalogs containing uuid to displayname mapping and the opposite
298 278
================================ =========  ==================
299 279

  
300 280
|
......
302 282
====================  ============================
303 283
Request Header Name   Value
304 284
====================  ============================
305
X-Auth-Token          Service Authentication token
285
X-Auth-Token          User authentication token
306 286
====================  ============================
307 287

  
308 288
|
309 289

  
310
======================  =========================
311
Request Parameter Name  Value
312
======================  =========================
313
name                    Email
314
======================  =========================
315

  
316
|
317

  
318
=========================== =====================
319
Return Code                 Description
320
=========================== =====================
321
200 (OK)                    The request succeeded
322
400 (Bad Request)           Method not allowed
323
401 (Unauthorized)          Missing or expired or invalid service token
324
404 (Not Found)             Missing email or inactive user
325
500 (Internal Server Error) The request cannot be completed because of an internal error
326
=========================== =====================
290
The request body is a json formatted dictionary containing a list with uuids and another list of displaynames to translate.
327 291

  
328
Example reply:
292
Example request content:
329 293

  
330 294
::
331 295

  
332
    {"username": "7e530044f90a4e7ba2cb94f3a26c40",
333
    "auth_token_created": "Wed, 30 May 2012 10:03:37 GMT",
334
    "name": "Firstname Surname",
335
    "groups": ["default"],
336
    "user_permissions": [],
337
    "has_credits": false,
338
    "auth_token_expires":"Fri, 29 Jun 2012 10:03:37 GMT",
339
    "enabled": true,
340
    "email": ["user@example.com"],
341
    "id": 4}
296
  {"displaynames": ["user1@example.com", "user2@example.com"],
297
   "uuids":["ff53baa9-c025-4d56-a6e3-963db0438830", "a9dc21d2-bcb2-4104-9a9e-402b7c70d6d8"]}
342 298

  
343
Get User by username
344
^^^^^^^^^^^^^^^^^^^^
345

  
346
Returns a json formatted dictionary containing information about a specific user
299
Example reply:
347 300

  
348
========================================== =========  ==================
349
Uri                                        Method     Description
350
========================================== =========  ==================
351
``/im/service/api/v2.0/users/{username}``  GET        Get user information by username
352
========================================== =========  ==================
301
::
353 302

  
354
|
303
  {"displayname_catalog": {"user1@example.com": "a9dc21d2-bcb2-4104-9a9e-402b7c70d6d8",
304
                           "user2@example.com": "816351c7-7405-4f26-a968-6380cf47ba1f"},
305
  'uuid_catalog': {"a9dc21d2-bcb2-4104-9a9e-402b7c70d6d8": "user1@example.com",
306
                   "ff53baa9-c025-4d56-a6e3-963db0438830": "user2@example.com"}}
355 307

  
356
====================  ============================
357
Request Header Name   Value
358
====================  ============================
359
X-Auth-Token          Service Authentication token
360
====================  ============================
361 308

  
362 309
|
363 310

  
......
365 312
Return Code                 Description
366 313
=========================== =====================
367 314
200 (OK)                    The request succeeded
368
400 (Bad Request)           Method not allowed
315
400 (Bad Request)           Method not allowed or request body is not json formatted
369 316
401 (Unauthorized)          Missing or expired or invalid service token
370
404 (Not Found)             Invalid username
371 317
500 (Internal Server Error) The request cannot be completed because of an internal error
372 318
=========================== =====================
373

  
374
Example reply:
375

  
376
::
377

  
378
    {"username": "7e530044f90a4e7ba2cb94f3a26c40",
379
    "auth_token_created": "Wed, 30 May 2012 10:03:37 GMT",
380
    "name": "Firstname Surname",
381
    "groups": ["default"],
382
    "user_permissions": [],
383
    "has_credits": false,
384
    "auth_token_expires":
385
    "Fri, 29 Jun 2012 10:03:37 GMT",
386
    "enabled": true,
387
    "email": ["user@example.com"],
388
    "id": 4}

Also available in: Unified diff