Skip to content

Commit d175844

Browse files
authored
Merge pull request #12 from ioet/feature/create-technologies-spec#7
Closes #7
2 parents e775a26 + f5bbf77 commit d175844

File tree

2 files changed

+82
-0
lines changed

2 files changed

+82
-0
lines changed

time_tracker_api/api.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,5 +11,8 @@
1111
from time_tracker_api.activities import activities_api
1212
api.add_namespace(activities_api.ns)
1313

14+
from time_tracker_api.technologies import technologies_api
15+
api.add_namespace(technologies_api.ns)
16+
1417
from time_tracker_api.time_entries import time_entry_api
1518
api.add_namespace(time_entry_api.ns)
Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
from flask_restplus import Namespace, Resource, fields
2+
3+
ns = Namespace('technologies', description='API for technologies used')
4+
5+
# Technology Model
6+
technology = ns.model('Technology', {
7+
'name': fields.String(
8+
required=True,
9+
title='Name',
10+
max_length=50,
11+
description='Name of the technology'
12+
),
13+
})
14+
15+
technology_response = ns.inherit('TechnologyResponse', technology, {
16+
'id': fields.String(
17+
readOnly=True,
18+
required=True,
19+
title='Identifier',
20+
description='The unique identifier',
21+
),
22+
'created_at': fields.Date(
23+
readOnly=True,
24+
title='Created',
25+
description='Date of creation'
26+
),
27+
'created_by': fields.String(
28+
readOnly=True,
29+
title='Creator',
30+
max_length=64,
31+
description='User that created it',
32+
),
33+
'tenant_id': fields.String(
34+
readOnly=True,
35+
title='Tenant',
36+
max_length=64,
37+
description='The tenant this belongs to',
38+
),
39+
})
40+
41+
42+
@ns.route('')
43+
class Technologies(Resource):
44+
@ns.doc('list_technologies')
45+
@ns.marshal_list_with(technology_response, code=200)
46+
def get(self):
47+
"""List all technologies"""
48+
return [], 200
49+
50+
@ns.doc('create_technology')
51+
@ns.expect(technology)
52+
@ns.marshal_with(technology_response, code=201)
53+
def post(self):
54+
"""Create a technology"""
55+
return ns.payload, 201
56+
57+
58+
@ns.route('/<string:uid>')
59+
@ns.response(404, 'Technology not found')
60+
@ns.param('uid', 'The technology identifier')
61+
class Technology(Resource):
62+
@ns.doc('get_technology')
63+
@ns.marshal_with(technology_response)
64+
def get(self, uid):
65+
"""Retrieve a technology"""
66+
return {}
67+
68+
@ns.doc('put_technology')
69+
@ns.expect(technology)
70+
@ns.marshal_with(technology_response)
71+
def put(self, uid):
72+
"""Updates a technology"""
73+
return ns.payload()
74+
75+
@ns.doc('delete_technology')
76+
@ns.response(204, 'Technology deleted successfully')
77+
def delete(self, uid):
78+
"""Deletes a technology"""
79+
return None, 204

0 commit comments

Comments
 (0)