Statistics
| Branch: | Tag: | Revision:

root / api / urls.py @ b9809f7c

History | View | Annotate | Download (1.9 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.api.emitter import Resource
8
from synnefo.api.handlers import *
9
from synnefo.api.authentication import TokenAuthentication
10
from synnefo.api.faults import fault
11

    
12
auth = TokenAuthentication()
13

    
14
def notFound(request):
15
    return fault.itemNotFound.response
16

    
17
limit_handler = Resource(LimitHandler, auth)
18
server_handler = Resource(ServerHandler, auth)
19
server_address_handler = Resource(ServerAddressHandler, auth)
20
server_actions_handler = Resource(ServerActionHandler, auth)
21
server_backup_handler = Resource(ServerBackupHandler, auth)
22
flavor_handler = Resource(FlavorHandler, auth)
23
image_handler = Resource(ImageHandler, auth)
24
shared_ip_group_handler = Resource(SharedIPGroupHandler, auth)
25

    
26
v10patterns = patterns('',
27
    url(r'^limits$', limit_handler),
28
    url(r'^servers$', server_handler),
29
    url(r'^servers/(?P<id>[^/]+)$', server_handler),
30
    url(r'^servers/(?P<id>[^/]+)/action$', server_actions_handler),
31
    url(r'^servers/(?P<id>[^/]+)/ips$', server_address_handler),
32
    url(r'^servers/(?P<id>[^/]+)/ips/private$', server_address_handler),
33
    url(r'^servers/(?P<id>[^/]+)/ips/public/(?P<address>[^/]+)$', server_address_handler),
34
    url(r'^servers/(?P<id>[^/]+)/backup_schedule', server_backup_handler),
35
    url(r'^flavors$', flavor_handler),
36
    url(r'^flavors/(?P<id>[^/]+)$', flavor_handler),
37
    url(r'^images$', image_handler),
38
    url(r'^images/(?P<id>[^/]+)$', image_handler),
39
    url(r'^shared_ip_groups$', shared_ip_group_handler),
40
    url(r'^shared_ip_groups/(?P<id>[^/]+)$', shared_ip_group_handler),
41
    (r'^.+', notFound), # catch-all
42
)
43

    
44
version_handler = Resource(VersionHandler)
45

    
46
urlpatterns = patterns('',
47
    url(r'^(?P<number>[^/]+)/?$', version_handler),
48
    url(r'^$', version_handler),
49
    (r'^v1.0/', include(v10patterns)),
50
    (r'^.+', notFound), # catch-all
51
)