-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathroot.py
More file actions
62 lines (51 loc) · 1.54 KB
/
root.py
File metadata and controls
62 lines (51 loc) · 1.54 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
from pecan import expose
from pecan import route
from pecan import request
from bigbang.api.controller import base
from bigbang.api.controller import types
from bigbang.api.controller import link
from bigbang.api.controller.v1 import controller as v1controller
class Version(base.APIBase):
fields = {
'id': {
'validate': types.Text.validate
},
'link': {
'validate': types.List(types.Custom(link.Link)).validate
}
}
@staticmethod
def convert(id):
version = Version()
version.id = id
version.link = [link.Link.make_link('self', request.host_url,
id, '', bookmark=True)]
return version
class Root(base.APIBase):
fields = {
'id': {
'validate': types.Text.validate
},
'description': {
'validate': types.Text.validate
},
'versions': {
'validate': types.List(types.Custom(Version)).validate
},
'default_version': {
'validate': types.Custom(Version).validate
},
}
@staticmethod
def convert():
root = Root()
root.name = "OpenStack Valence API"
root.description = ("Valence is an OpenStack project")
root.versions = [Version.convert('v1')]
root.default_version = Version.convert('v1')
return root
class RootController(object):
@expose('json')
def index(self):
return Root.convert()
route(RootController, 'v1', v1controller.V1Controller())