Statistics
| Branch: | Tag: | Revision:

root / docs / project-api-guide.rst @ e98239db

History | View | Annotate | Download (12 kB)

1
Projects
2
--------
3

    
4
Astakos allows users to create *projects*. Through a project, one can ask for
5
additional resources on the virtual infrastructure for a certain amount of
6
time. All users admitted to the project gain access to these resources.
7

    
8

    
9
Retrieve List of Projects
10
.........................
11

    
12
**GET** /account/v1.0/projects
13

    
14
Returns all accessible projects. See below.
15

    
16
====================  =========================
17
Request Header Name   Value
18
====================  =========================
19
X-Auth-Token          User authentication token
20
====================  =========================
21

    
22
Request can specify a filter.
23

    
24
**Example Request**:
25

    
26
.. code-block:: javascript
27

    
28
  {
29
      "filter": {
30
          "state": ["active", "suspended"],
31
          "owner": [uuid]
32
      }
33
  }
34

    
35
**Response Codes**:
36

    
37
======  =====================
38
Status  Description
39
======  =====================
40
200     Success
41
400     Bad Request
42
401     Unauthorized (Missing token)
43
500     Internal Server Error
44
======  =====================
45

    
46
**Example Successful Response**:
47

    
48
List of project details. See below.
49

    
50
Retrieve a Project
51
..................
52

    
53
**GET** /account/v1.0/projects/<proj_id>
54

    
55
====================  =========================
56
Request Header Name   Value
57
====================  =========================
58
X-Auth-Token          User authentication token
59
====================  =========================
60

    
61
A project is accessible when the request user is admin, project owner,
62
applicant or member, or the project is active.
63

    
64
**Response Codes**:
65

    
66
======  ============================
67
Status  Description
68
======  ============================
69
200     Success
70
401     Unauthorized (Missing token)
71
403     Forbidden
72
404     Not Found
73
500     Internal Server Error
74
======  ============================
75

    
76
**Example Successful Response**:
77

    
78
.. code-block:: javascript
79

    
80
  {
81
      "id": proj_id,
82
      "application": app_id,
83
      "state": "pending" | "active" | "denied" | "dismissed" | "cancelled" | "suspended" | "terminated",
84
      "creation_date": "2013-06-26T11:48:06.579100+00:00",
85
      "name": "name",
86
      "owner": uuid,
87
      "homepage": homepage or null,
88
      "description": description or null,
89
      "start_date": date,
90
      "end_date": date,
91
      "join_policy": "auto" | "moderated" | "closed",
92
      "leave_policy": "auto" | "moderated" | "closed",
93
      "max_members": natural number
94
      "resources": {"cyclades.vm": {"project_capacity": int or null,
95
                                    "member_capacity": int
96
                                   }
97
                   }
98
      # only if request user is admin or project owner:
99
      "comments": comments,
100
      "pending_application": last pending app id or null,
101
      "deactivation_date": date  # if applicable
102
  }
103

    
104
Create a Project
105
................
106

    
107
**POST** /account/v1.0/projects
108

    
109
====================  =========================
110
Request Header Name   Value
111
====================  =========================
112
X-Auth-Token          User authentication token
113
====================  =========================
114

    
115
**Example Request**:
116

    
117
.. code-block:: javascript
118

    
119
  {
120
      "name": name,
121
      "owner": uuid,  # if omitted, request user assumed
122
      "homepage": homepage,  # optional
123
      "description": description,  # optional
124
      "comments": comments,  # optional
125
      "start_date": date,  # optional
126
      "end_date": date,
127
      "join_policy": "auto" | "moderated" | "closed",  # default: "moderated"
128
      "leave_policy": "auto" | "moderated" | "closed",  # default: "auto"
129
      "resources": {"cyclades.vm": {"project_capacity": int or null,
130
                                    "member_capacity": int
131
                                   }
132
                   }
133
  }
134

    
135
**Response Codes**:
136

    
137
======  ============================
138
Status  Description
139
======  ============================
140
201     Created
141
400     Bad Request
142
401     Unauthorized (Missing token)
143
403     Forbidden
144
409     Conflict
145
500     Internal Server Error
146
======  ============================
147

    
148
**Example Successful Response**:
149

    
150
.. code-block:: javascript
151

    
152
  {
153
      "id": project_id,
154
      "application": application_id
155
  }
156

    
157

    
158
Modify a Project
159
................
160

    
161
**POST** /account/v1.0/projects/<proj_id>
162

    
163
====================  =========================
164
Request Header Name   Value
165
====================  =========================
166
X-Auth-Token          User authentication token
167
====================  =========================
168

    
169

    
170
**Example Request**:
171

    
172
As above.
173

    
174
**Response Codes**:
175

    
176
======  ============================
177
Status  Description
178
======  ============================
179
201     Created
180
400     Bad Request
181
401     Unauthorized (Missing token)
182
403     Forbidden
183
404     Not Found
184
409     Conflict
185
500     Internal Server Error
186
======  ============================
187

    
188
**Example Successful Response**:
189

    
190
As above.
191

    
192
Take Action on a Project
193
........................
194

    
195
**POST** /account/v1.0/projects/<proj_id>/action
196

    
197
====================  =========================
198
Request Header Name   Value
199
====================  =========================
200
X-Auth-Token          User authentication token
201
====================  =========================
202

    
203
**Example Request**:
204

    
205
.. code-block:: javascript
206

    
207
  {
208
      <action>: "reason"
209
  }
210

    
211
<action> can be: "suspend", "unsuspend", "terminate", "reinstate"
212

    
213
**Response Codes**:
214

    
215
======  ============================
216
Status  Description
217
======  ============================
218
200     Success
219
400     Bad Request
220
401     Unauthorized (Missing token)
221
403     Forbidden
222
404     Not Found
223
409     Conflict
224
500     Internal Server Error
225
======  ============================
226

    
227
Retrieve List of Applications
228
.............................
229

    
230
**GET** /account/v1.0/projects/apps
231

    
232
====================  =========================
233
Request Header Name   Value
234
====================  =========================
235
X-Auth-Token          User authentication token
236
====================  =========================
237

    
238
Get all accessible applications. See below.
239

    
240
**Example optional request**
241

    
242
.. code-block:: javascript
243

    
244
  {
245
      "project": <project_id>
246
  }
247

    
248
**Response Codes**:
249

    
250
======  ============================
251
Status  Description
252
======  ============================
253
200     Success
254
400     Bad Request
255
401     Unauthorized (Missing token)
256
500     Internal Server Error
257
======  ============================
258

    
259
**Example Successful Response**:
260

    
261
List of application details. See below.
262

    
263
Retrieve an Application
264
.......................
265

    
266
**GET** /account/v1.0/projects/apps/<app_id>
267

    
268
====================  =========================
269
Request Header Name   Value
270
====================  =========================
271
X-Auth-Token          User authentication token
272
====================  =========================
273

    
274
An application is accessible when the request user is admin or the
275
application owner/applicant.
276

    
277
**Response Codes**:
278

    
279
======  ============================
280
Status  Description
281
======  ============================
282
200     Success
283
401     Unauthorized (Missing token)
284
403     Forbidden
285
404     Not Found
286
500     Internal Server Error
287
======  ============================
288

    
289
**Example Successful Response**
290

    
291
.. code-block:: javascript
292

    
293
  {
294
      "id": app_id,
295
      "project": project_id,
296
      "state": "pending" | "approved" | "replaced" | "denied" | "dismissed" | "cancelled",
297
      "name": "name",
298
      "owner": uuid,
299
      "applicant": uuid,
300
      "homepage": homepage or null,
301
      "description": description or null,
302
      "start_date": date,
303
      "end_date": date,
304
      "join_policy": "auto" | "moderated" | "closed",
305
      "leave_policy": "auto" | "moderated" | "closed",
306
      "max_members": int or null
307
      "comments": comments,
308
      "resources": {"cyclades.vm": {"project_capacity": int or null,
309
                                    "member_capacity": int
310
                                   }
311
                   }
312
  }
313

    
314
Take Action on an Application
315
.............................
316

    
317
**POST** /account/v1.0/projects/apps/<app_id>/action
318

    
319
====================  ============================
320
Request Header Name   Value
321
====================  ============================
322
X-Auth-Token          User authentication token
323
====================  ============================
324

    
325
**Example Request**:
326

    
327
.. code-block:: javascript
328

    
329
  {
330
      <action>: "reason"
331
  }
332

    
333
<action> can be one of "approve", "deny", "dismiss", "cancel".
334

    
335
**Response Codes**:
336

    
337
======  ============================
338
Status  Description
339
======  ============================
340
200     Success
341
400     Bad Request
342
401     Unauthorized (Missing token)
343
403     Forbidden
344
404     Not Found
345
409     Conflict
346
500     Internal Server Error
347
======  ============================
348

    
349
Retrieve List of Memberships
350
............................
351

    
352
**GET** /account/v1.0/projects/memberships
353

    
354
====================  ============================
355
Request Header Name   Value
356
====================  ============================
357
X-Auth-Token          User authentication token
358
====================  ============================
359

    
360
Get all accessible memberships. See below.
361

    
362
**Example Optional Request**
363

    
364
.. code-block:: javascript
365

    
366
  {
367
      "project": <proj_id>
368
  }
369

    
370
**Response Codes**:
371

    
372
======  ============================
373
Status  Description
374
======  ============================
375
200     Success
376
400     Bad Request
377
401     Unauthorized (Missing token)
378
500     Internal Server Error
379
======  ============================
380

    
381
**Example Successful Response**
382

    
383
List of memberships. See below.
384

    
385
Retrieve a Membership
386
.....................
387

    
388
**GET** /account/v1.0/projects/memberships/<memb_id>
389

    
390
====================  ============================
391
Request Header Name   Value
392
====================  ============================
393
X-Auth-Token          User authentication token
394
====================  ============================
395

    
396
A membership is accessible if the request user is admin, project owner or
397
the member.
398

    
399
**Response Codes**:
400

    
401
======  ============================
402
Status  Description
403
======  ============================
404
200     Success
405
401     Unauthorized (Missing token)
406
403     Forbidden
407
404     Not Found
408
500     Internal Server Error
409
======  ============================
410

    
411
**Example Successful Response**
412

    
413
.. code-block:: javascript
414

    
415
  {
416
      "id": id,
417
      "user": uuid,
418
      "project": project_id,
419
      "state": "requested" | "accepted" | "leave_requested" | "suspended" | "rejected" | "cancelled" | "removed",
420
      "requested": last_request_date,
421
      "accepted": last_acceptance_date,
422
      "removed": last_removal_date,
423
      "allowed_actions": ["leave", "cancel", "accept", "reject", "remove"],
424
  }
425

    
426
Take Action on a Membership
427
...........................
428

    
429
**POST** /account/v1.0/projects/memberships/<memb_id>/action
430

    
431
====================  ============================
432
Request Header Name   Value
433
====================  ============================
434
X-Auth-Token          User authentication token
435
====================  ============================
436

    
437
**Example Request**
438

    
439
.. code-block:: javascript
440

    
441
  {
442
      <action>: "reason"
443
  }
444

    
445
<action> can be one of: "leave", "cancel", "accept", "reject", "remove"
446

    
447
**Response Codes**:
448

    
449
======  ============================
450
Status  Description
451
======  ============================
452
200     Success
453
400     Bad Request
454
401     Unauthorized (Missing token)
455
403     Forbidden
456
404     Not Found
457
409     Conflict
458
500     Internal Server Error
459
======  ============================
460

    
461
Create a Membership
462
...................
463

    
464
**POST** /account/v1.0/projects/memberships
465

    
466
====================  ============================
467
Request Header Name   Value
468
====================  ============================
469
X-Auth-Token          User authentication token
470
====================  ============================
471

    
472
**Example Requests**
473

    
474
.. code-block:: javascript
475

    
476
  {
477
      "join": {
478
          "project": proj_id
479
      }
480
  }
481

    
482
.. code-block:: javascript
483

    
484
  {
485
      "enroll": {
486
          "project": proj_id,
487
          "user": "user@example.org"
488
      }
489
  }
490

    
491
**Response Codes**:
492

    
493
======  ============================
494
Status  Description
495
======  ============================
496
200     Success
497
400     Bad Request
498
401     Unauthorized (Missing token)
499
403     Forbidden
500
409     Conflict
501
500     Internal Server Error
502
======  ============================
503

    
504
**Example Response**
505

    
506
.. code-block:: javascript
507

    
508
  {
509
      "id": membership_id
510
  }