root / api / urls.py @ 9071888e
History | View | Annotate | Download (4 kB)
1 |
# vim: ts=4 sts=4 et ai sw=4 fileencoding=utf-8
|
---|---|
2 |
#
|
3 |
# Copyright ÃÂé 2010 Greek Research and Technology Network
|
4 |
#
|
5 |
|
6 |
from django.conf.urls.defaults import * |
7 |
from synnefo.helpers import url_with_format |
8 |
from synnefo.api.resource import Resource |
9 |
from synnefo.api.handlers import * |
10 |
from synnefo.api.authentication import TokenAuthentication |
11 |
from synnefo.api.faults import fault |
12 |
|
13 |
auth = TokenAuthentication() |
14 |
|
15 |
def notFound(request): |
16 |
return fault.itemNotFound.response
|
17 |
|
18 |
limit_handler = Resource(LimitHandler, auth) |
19 |
server_handler = Resource(ServerHandler, auth) |
20 |
server_address_handler = Resource(ServerAddressHandler, auth) |
21 |
server_actions_handler = Resource(ServerActionHandler, auth) |
22 |
server_backup_handler = Resource(ServerBackupHandler, auth) |
23 |
flavor_handler = Resource(FlavorHandler, auth) |
24 |
image_handler = Resource(ImageHandler, auth) |
25 |
shared_ip_group_handler = Resource(SharedIPGroupHandler, auth) |
26 |
virtual_machine_group_handler = Resource(VirtualMachineGroupHandler, auth) |
27 |
disk_handler = Resource(DiskHandler, auth) |
28 |
|
29 |
def url_with_format(regex, *args, **kwargs): |
30 |
if regex[-1] == '$': |
31 |
regex = regex[:-1]
|
32 |
regex = regex + r'(\.(?P<emitter_format>json|xml))?$'
|
33 |
return url(regex, *args, **kwargs)
|
34 |
|
35 |
# The Rackspace v1.0 Cloud Servers API
|
36 |
v10patterns = patterns('',
|
37 |
url_with_format(r'^limits$', limit_handler),
|
38 |
url_with_format(r'^servers$', server_handler),
|
39 |
url_with_format(r'^servers/(?P<id>[^/]+)$', server_handler),
|
40 |
url_with_format(r'^servers/(?P<id>[^/]+)/action$', server_actions_handler),
|
41 |
url_with_format(r'^servers/(?P<id>[^/]+)/ips$', server_address_handler),
|
42 |
url_with_format(r'^servers/(?P<id>[^/]+)/ips/private$', server_address_handler),
|
43 |
url_with_format(r'^servers/(?P<id>[^/]+)/ips/public/(?P<address>[^/]+)$', server_address_handler),
|
44 |
url_with_format(r'^servers/(?P<id>[^/]+)/backup_schedule', server_backup_handler),
|
45 |
url_with_format(r'^flavors$', flavor_handler),
|
46 |
url_with_format(r'^flavors/(?P<id>[^/]+)$', flavor_handler),
|
47 |
url_with_format(r'^images$', image_handler),
|
48 |
url_with_format(r'^images/(?P<id>[^/]+)$', image_handler),
|
49 |
url_with_format(r'^shared_ip_groups$', shared_ip_group_handler),
|
50 |
url_with_format(r'^shared_ip_groups/(?P<id>[^/]+)$', shared_ip_group_handler),
|
51 |
url_with_format(r'^groups$', virtual_machine_group_handler),
|
52 |
url_with_format(r'^groups/(?P<id>[^/]+)$', virtual_machine_group_handler),
|
53 |
url(r'^.+', notFound), # catch-all |
54 |
) |
55 |
|
56 |
# The Rackspace v1.0 Cloud Servers API + GRNET v1.0 extension
|
57 |
v10grnet10patterns = patterns('',
|
58 |
url_with_format(r'^limits$', limit_handler),
|
59 |
url_with_format(r'^servers$', server_handler),
|
60 |
url_with_format(r'^servers/(?P<id>[^/]+)$', server_handler),
|
61 |
url_with_format(r'^servers/(?P<id>[^/]+)/action$', server_actions_handler),
|
62 |
url_with_format(r'^servers/(?P<id>[^/]+)/ips$', server_address_handler),
|
63 |
url_with_format(r'^servers/(?P<id>[^/]+)/ips/private$', server_address_handler),
|
64 |
url_with_format(r'^servers/(?P<id>[^/]+)/ips/public/(?P<address>[^/]+)$', server_address_handler),
|
65 |
url_with_format(r'^servers/(?P<id>[^/]+)/backup_schedule', server_backup_handler),
|
66 |
url_with_format(r'^flavors$', flavor_handler),
|
67 |
url_with_format(r'^flavors/(?P<id>[^/]+)$', flavor_handler),
|
68 |
url_with_format(r'^images$', image_handler),
|
69 |
url_with_format(r'^images/(?P<id>[^/]+)$', image_handler),
|
70 |
url_with_format(r'^shared_ip_groups$', shared_ip_group_handler),
|
71 |
url_with_format(r'^shared_ip_groups/(?P<id>[^/]+)$', shared_ip_group_handler),
|
72 |
url_with_format(r'^groups$', virtual_machine_group_handler),
|
73 |
url_with_format(r'^disks$', disk_handler),
|
74 |
url_with_format(r'^disks/(?P<id>[^/]+)$', disk_handler),
|
75 |
url_with_format(r'^groups/(?P<id>[^/]+)$', virtual_machine_group_handler),
|
76 |
url(r'^.+', notFound), # catch-all |
77 |
) |
78 |
|
79 |
version_handler = Resource(VersionHandler) |
80 |
|
81 |
urlpatterns = patterns('',
|
82 |
url_with_format(r'^(?P<number>[^/]+)/?$', version_handler),
|
83 |
url(r'^$', version_handler),
|
84 |
url(r'^v1.0/', include(v10patterns)),
|
85 |
url(r'^v1.0grnet1/', include(v10grnet10patterns)),
|
86 |
url(r'^.+', notFound), # catch-all |
87 |
) |