Revision 0f2bd3f9 docs/project-api-guide.rst

b/docs/project-api-guide.rst
19 19
X-Auth-Token          User authentication token
20 20
====================  =========================
21 21

  
22
Request can specify a filter.
22
The request can include the following filters as GET parameters:
23
``state``, ``owner``, ``name``.
24

  
25
It also supports parameter ``mode`` with possible values: ``member``,
26
``default``. The former restricts the result to active projects where the
27
request user is an active member. By default it returns all accessible
28
projects; see below.
23 29

  
24 30
**Example Request**:
25 31

  
26 32
.. code-block:: javascript
27 33

  
28
  {
29
      "filter": {
30
          "state": ["active", "suspended"],
31
          "owner": [uuid]
32
      }
33
  }
34
GET /account/v1.0/projects?state=active&owner=uuid
34 35

  
35 36
**Response Codes**:
36 37

  
......
79 80

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

  
......
126 123
      "end_date": date,
127 124
      "join_policy": "auto" | "moderated" | "closed",  # default: "moderated"
128 125
      "leave_policy": "auto" | "moderated" | "closed",  # default: "auto"
129
      "resources": {"cyclades.vm": {"project_capacity": int or null,
126
      "resources": {"cyclades.vm": {"project_capacity": int,
130 127
                                    "member_capacity": int
131 128
                                   }
132 129
                   }
......
205 202
.. code-block:: javascript
206 203

  
207 204
  {
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"
205
      <action>: {"reason": reason,
206
                 "app_id": app_id  # only for app related actions
207
                }
331 208
  }
332 209

  
333
<action> can be one of "approve", "deny", "dismiss", "cancel".
210
<action> can be: "suspend", "unsuspend", "terminate", "reinstate",
211
"approve", "deny", "dismiss", "cancel". The last four actions operate on the
212
project's last application and require its ``app_id``.
334 213

  
335 214
**Response Codes**:
336 215

  
......
357 236
X-Auth-Token          User authentication token
358 237
====================  ============================
359 238

  
360
Get all accessible memberships. See below.
361

  
362
**Example Optional Request**
363

  
364
.. code-block:: javascript
365

  
366
  {
367
      "project": <proj_id>
368
  }
239
Get all accessible memberships. Filtering by project is possible via the GET
240
parameter ``project``.
369 241

  
370 242
**Response Codes**:
371 243

  

Also available in: Unified diff