Statistics
| Branch: | Tag: | Revision:

root / snf-cyclades-app / synnefo / volume / urls.py @ 0a83201b

History | View | Annotate | Download (3.4 kB)

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