6
6
7
7
# Project Model
8
8
project = ns .model ('Project' , {
9
- 'id' : fields .String (
10
- readOnly = True ,
11
- required = True ,
12
- title = 'Identifier' ,
13
- description = 'The unique id of the project'
14
- ),
15
- 'tenant_id' : fields .String (
16
- required = True ,
17
- title = 'Tenant' ,
18
- max_length = 64 ,
19
- description = 'The tenant this project belongs to'
20
- ),
21
9
'name' : fields .String (
22
10
required = True ,
23
11
title = 'Name' ,
37
25
})
38
26
39
27
28
+ project_response = ns .inherit ('ProjectResponse' , project , {
29
+ 'id' : fields .String (
30
+ readOnly = True ,
31
+ required = True ,
32
+ title = 'Identifier' ,
33
+ description = 'The unique identifier' ,
34
+ ),
35
+ 'created_at' : fields .Date (
36
+ readOnly = True ,
37
+ title = 'Created' ,
38
+ description = 'Date of creation'
39
+ ),
40
+ 'tenant_id' : fields .String (
41
+ readOnly = True ,
42
+ title = 'Tenant' ,
43
+ max_length = 64 ,
44
+ description = 'The tenant this belongs to' ,
45
+ ),
46
+ })
47
+
48
+
40
49
@ns .route ('' )
41
50
class Projects (Resource ):
42
51
@ns .doc ('list_projects' )
43
- @ns .marshal_list_with (project , code = 200 )
52
+ @ns .marshal_list_with (project_response , code = 200 )
44
53
def get (self ):
45
54
"""List all projects"""
46
55
return project_dao .get_all (), 200
47
56
48
57
@ns .doc ('create_project' )
49
58
@ns .expect (project )
50
- @ns .marshal_with (project , code = 201 )
59
+ @ns .marshal_with (project_response , code = 201 )
51
60
def post (self ):
52
61
"""Create a project"""
53
62
return project_dao .create (ns .payload ), 201
@@ -66,7 +75,7 @@ def post(self):
66
75
@ns .param ('uid' , 'The project identifier' )
67
76
class Project (Resource ):
68
77
@ns .doc ('get_project' )
69
- @ns .marshal_with (project )
78
+ @ns .marshal_with (project_response )
70
79
def get (self , uid ):
71
80
"""Retrieve a project"""
72
81
return project_dao .get (uid )
@@ -87,7 +96,7 @@ def post(self, uid):
87
96
88
97
@ns .doc ('put_project' )
89
98
@ns .expect (project )
90
- @ns .marshal_with (project )
99
+ @ns .marshal_with (project_response )
91
100
def put (self , uid ):
92
101
"""Create or replace a project"""
93
102
return project_dao .update (uid , ns .payload )
@@ -98,4 +107,3 @@ def delete(self, uid):
98
107
"""Deletes a project"""
99
108
project_dao .delete (uid )
100
109
return None , 204
101
-
0 commit comments