Revision 52275074
b/snf-cyclades-app/synnefo/volume/urls.py | ||
---|---|---|
1 |
# Copyright 2013 GRNET S.A. All rights reserved. |
|
2 |
# |
|
3 |
# Redistribution and use in source and binary forms, with or |
|
4 |
# without modification, are permitted provided that the following |
|
5 |
# conditions are met: |
|
6 |
# |
|
7 |
# 1. Redistributions of source code must retain the above |
|
8 |
# copyright notice, this list of conditions and the following |
|
9 |
# disclaimer. |
|
10 |
# |
|
11 |
# 2. Redistributions in binary form must reproduce the above |
|
12 |
# copyright notice, this list of conditions and the following |
|
13 |
# disclaimer in the documentation and/or other materials |
|
14 |
# provided with the distribution. |
|
15 |
# |
|
16 |
# THIS SOFTWARE IS PROVIDED BY GRNET S.A. ``AS IS'' AND ANY EXPRESS |
|
17 |
# OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED |
|
18 |
# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR |
|
19 |
# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL GRNET S.A OR |
|
20 |
# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
|
21 |
# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
|
22 |
# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF |
|
23 |
# USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED |
|
24 |
# AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT |
|
25 |
# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN |
|
26 |
# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE |
|
27 |
# POSSIBILITY OF SUCH DAMAGE. |
|
28 |
# |
|
29 |
# The views and conclusions contained in the software and |
|
30 |
# documentation are those of the authors and should not be |
|
31 |
# interpreted as representing official policies, either expressed |
|
32 |
# or implied, of GRNET S.A. |
|
33 |
|
|
34 |
from django.conf.urls.defaults import patterns, include |
|
35 |
from django.http import HttpResponseNotAllowed |
|
36 |
from snf_django.lib import api |
|
37 |
from synnefo.volume import views |
|
38 |
|
|
39 |
|
|
40 |
def volume_demux(request): |
|
41 |
if request.method == 'GET': |
|
42 |
return views.list_volumes(request) |
|
43 |
elif request.method == 'POST': |
|
44 |
return views.create_volume(request) |
|
45 |
else: |
|
46 |
return HttpResponseNotAllowed(['GET', 'POST']) |
|
47 |
|
|
48 |
|
|
49 |
def volume_item_demux(request, volume_id): |
|
50 |
if request.method == "GET": |
|
51 |
return views.get_volume(request, volume_id) |
|
52 |
elif request.method == "PUT": |
|
53 |
return views.update_volume(request, volume_id) |
|
54 |
elif request.method == "DELETE": |
|
55 |
return views.delete_volume(request, volume_id) |
|
56 |
else: |
|
57 |
return HttpResponseNotAllowed(["GET", "PUT", "DELETE"]) |
|
58 |
|
|
59 |
|
|
60 |
def snapshot_demux(request): |
|
61 |
if request.method == 'GET': |
|
62 |
return views.list_snapshots(request) |
|
63 |
elif request.method == 'POST': |
|
64 |
return views.create_snapshot(request) |
|
65 |
else: |
|
66 |
return HttpResponseNotAllowed(['GET', 'POST']) |
|
67 |
|
|
68 |
|
|
69 |
def snapshot_item_demux(request, snapshot_id): |
|
70 |
if request.method == "GET": |
|
71 |
return views.get_snapshot(request, snapshot_id) |
|
72 |
elif request.method == "PUT": |
|
73 |
return views.update_snapshot(request, snapshot_id) |
|
74 |
elif request.method == "DELETE": |
|
75 |
return views.delete_snapshot(request, snapshot_id) |
|
76 |
else: |
|
77 |
return HttpResponseNotAllowed(["GET", "PUT", "DELETE"]) |
|
78 |
|
|
79 |
volume_v2_patterns = patterns( |
|
80 |
'', |
|
81 |
(r'^volumes/$', volume_demux), |
|
82 |
(r'^volumes/detail$', views.list_volumes, {'detail': True}), |
|
83 |
(r'^volumes/(\d+)(?:.json)?$', volume_item_demux), |
|
84 |
(r'^snapshots/$', snapshot_demux), |
|
85 |
(r'^snapshots/detail$', views.list_snapshots, {'detail': True}), |
|
86 |
(r'^snapshots/(\d+)(?:.json)?$', snapshot_item_demux), |
|
87 |
) |
|
88 |
|
|
89 |
urlpatterns = patterns( |
|
90 |
'', |
|
91 |
(r'^v2.0/', include(volume_v2_patterns)), |
|
92 |
(r'^.*', api.api_endpoint_not_found) |
|
93 |
) |
Also available in: Unified diff