Skip to content

Commit ad77389

Browse files
author
EliuX
committed
Rename API models
1 parent 04a16e7 commit ad77389

File tree

4 files changed

+40
-40
lines changed

4 files changed

+40
-40
lines changed

time_tracker_api/activities/activities_namespace.py

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
ns = Namespace('activities', description='API for activities')
55

66
# Activity Model
7-
activity = ns.model('Activity', {
7+
activity_input = ns.model('ActivityInput', {
88
'name': fields.String(
99
required=True,
1010
title='Name',
@@ -27,24 +27,24 @@
2727
}
2828
activity_response_fields.update(audit_fields)
2929

30-
activity_response = ns.inherit(
31-
'ActivityResponse',
32-
activity,
30+
activity = ns.inherit(
31+
'Activity',
32+
activity_input,
3333
activity_response_fields
3434
)
3535

3636

3737
@ns.route('')
3838
class Activities(Resource):
3939
@ns.doc('list_activities')
40-
@ns.marshal_list_with(activity_response, code=200)
40+
@ns.marshal_list_with(activity, code=200)
4141
def get(self):
4242
"""List all available activities"""
4343
return []
4444

4545
@ns.doc('create_activity')
46-
@ns.expect(activity)
47-
@ns.marshal_with(activity_response, code=201)
46+
@ns.expect(activity_input)
47+
@ns.marshal_with(activity, code=201)
4848
@ns.response(400, 'Invalid format of the attributes of the activity.')
4949
def post(self):
5050
"""Create a single activity"""
@@ -56,7 +56,7 @@ def post(self):
5656
@ns.param('id', 'The unique identifier of the activity')
5757
class Activity(Resource):
5858
@ns.doc('get_activity')
59-
@ns.marshal_with(activity_response)
59+
@ns.marshal_with(activity)
6060
def get(self, id):
6161
"""Retrieve all the data of a single activity"""
6262
return {}
@@ -69,8 +69,8 @@ def delete(self, id):
6969

7070
@ns.doc('put_activity')
7171
@ns.response(400, 'Invalid format of the attributes of the activity.')
72-
@ns.expect(activity)
73-
@ns.marshal_with(activity_response)
72+
@ns.expect(activity_input)
73+
@ns.marshal_with(activity)
7474
def put(self, id):
7575
"""Updates an activity"""
7676
return ns.payload

time_tracker_api/projects/projects_namespace.py

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
ns = Namespace('projects', description='API for projects (clients)')
77

88
# Project Model
9-
project = ns.model('Project', {
9+
project_input = ns.model('ProjectInput', {
1010
'name': fields.String(
1111
required=True,
1212
title='Name',
@@ -35,24 +35,24 @@
3535
}
3636
project_response_fields.update(audit_fields)
3737

38-
project_response = ns.inherit(
39-
'ProjectResponse',
40-
project,
38+
project = ns.inherit(
39+
'Project',
40+
project_input,
4141
project_response_fields
4242
)
4343

4444

4545
@ns.route('')
4646
class Projects(Resource):
4747
@ns.doc('list_projects')
48-
@ns.marshal_list_with(project_response, code=200)
48+
@ns.marshal_list_with(project, code=200)
4949
def get(self):
5050
"""List all projects"""
5151
return project_dao.get_all(), 200
5252

5353
@ns.doc('create_project')
54-
@ns.expect(project)
55-
@ns.marshal_with(project_response, code=201)
54+
@ns.expect(project_input)
55+
@ns.marshal_with(project, code=201)
5656
def post(self):
5757
"""Create a project"""
5858
return project_dao.create(ns.payload), 201
@@ -71,7 +71,7 @@ def post(self):
7171
@ns.param('uid', 'The project identifier')
7272
class Project(Resource):
7373
@ns.doc('get_project')
74-
@ns.marshal_with(project_response)
74+
@ns.marshal_with(project)
7575
def get(self, uid):
7676
"""Retrieve a project"""
7777
return project_dao.get(uid)
@@ -90,8 +90,8 @@ def post(self, uid):
9090
abort(message=str(e), code=404)
9191

9292
@ns.doc('put_project')
93-
@ns.expect(project)
94-
@ns.marshal_with(project_response)
93+
@ns.expect(project_input)
94+
@ns.marshal_with(project)
9595
def put(self, uid):
9696
"""Create or replace a project"""
9797
return project_dao.update(uid, ns.payload)

time_tracker_api/technologies/technologies_namespace.py

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
ns = Namespace('technologies', description='API for technologies used')
55

66
# Technology Model
7-
technology = ns.model('Technology', {
7+
technology_input = ns.model('TechnologyInput', {
88
'name': fields.String(
99
required=True,
1010
title='Name',
@@ -23,24 +23,24 @@
2323
}
2424
technology_response_fields.update(audit_fields)
2525

26-
technology_response = ns.inherit(
27-
'TechnologyResponse',
28-
technology,
26+
technology = ns.inherit(
27+
'Technology',
28+
technology_input,
2929
technology_response_fields
3030
)
3131

3232

3333
@ns.route('')
3434
class Technologies(Resource):
3535
@ns.doc('list_technologies')
36-
@ns.marshal_list_with(technology_response, code=200)
36+
@ns.marshal_list_with(technology, code=200)
3737
def get(self):
3838
"""List all technologies"""
3939
return [], 200
4040

4141
@ns.doc('create_technology')
42-
@ns.expect(technology)
43-
@ns.marshal_with(technology_response, code=201)
42+
@ns.expect(technology_input)
43+
@ns.marshal_with(technology, code=201)
4444
def post(self):
4545
"""Create a technology"""
4646
return ns.payload, 201
@@ -51,14 +51,14 @@ def post(self):
5151
@ns.param('uid', 'The technology identifier')
5252
class Technology(Resource):
5353
@ns.doc('get_technology')
54-
@ns.marshal_with(technology_response)
54+
@ns.marshal_with(technology)
5555
def get(self, uid):
5656
"""Retrieve a technology"""
5757
return {}
5858

5959
@ns.doc('put_technology')
60-
@ns.expect(technology)
61-
@ns.marshal_with(technology_response)
60+
@ns.expect(technology_input)
61+
@ns.marshal_with(technology)
6262
def put(self, uid):
6363
"""Updates a technology"""
6464
return ns.payload()

time_tracker_api/time_entries/time_entries_namespace.py

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
ns = Namespace('time-entries', description='API for time entries')
66

77
# TimeEntry Model
8-
time_entry = ns.model('TimeEntry', {
8+
time_entry_input = ns.model('TimeEntryInput', {
99
'project_id': fields.String(
1010
required=True,
1111
title='Project',
@@ -55,9 +55,9 @@
5555
}
5656
time_entry_response_fields.update(audit_fields)
5757

58-
time_entry_response = ns.inherit(
59-
'TimeEntryResponse',
60-
time_entry,
58+
time_entry = ns.inherit(
59+
'TimeEntry',
60+
time_entry_input,
6161
time_entry_response_fields,
6262
)
6363

@@ -67,14 +67,14 @@
6767
@ns.route('')
6868
class TimeEntries(Resource):
6969
@ns.doc('list_time_entries')
70-
@ns.marshal_list_with(time_entry_response, code=200)
70+
@ns.marshal_list_with(time_entry, code=200)
7171
def get(self):
7272
"""List all available time entries"""
7373
return model.find_all()
7474

7575
@ns.doc('create_time_entry')
76-
@ns.expect(time_entry)
77-
@ns.marshal_with(time_entry_response, code=201)
76+
@ns.expect(time_entry_input)
77+
@ns.marshal_with(time_entry, code=201)
7878
@ns.response(400, 'Invalid format of the attributes of the time entry')
7979
def post(self):
8080
"""Starts a time entry by creating it"""
@@ -86,7 +86,7 @@ def post(self):
8686
@ns.param('id', 'The unique identifier of the time entry')
8787
class TimeEntry(Resource):
8888
@ns.doc('get_time_entry')
89-
@ns.marshal_with(time_entry_response)
89+
@ns.marshal_with(time_entry)
9090
def get(self, id):
9191
"""Retrieve all the data of a single time entry"""
9292
return {}
@@ -99,8 +99,8 @@ def delete(self, id):
9999

100100
@ns.doc('put_time_entry')
101101
@ns.response(400, 'Invalid format of the attributes of the time entry.')
102-
@ns.expect(time_entry)
103-
@ns.marshal_with(time_entry_response)
102+
@ns.expect(time_entry_input)
103+
@ns.marshal_with(time_entry)
104104
def put(self, id):
105105
"""Updates a time entry"""
106106
return ns.payload

0 commit comments

Comments
 (0)