Skip to content

Commit 752bf66

Browse files
removes unnecessary response data from PUT/DELETE
1 parent b7c897f commit 752bf66

18 files changed

+96
-194
lines changed

README.md

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -102,21 +102,21 @@ sequenceDiagram
102102
User ->> API: POST /model
103103
API ->> MongoDB: Persist API Model as a document
104104
MongoDB -->> API: Model ID
105-
API -->> User: ModelCreated View
105+
API -->> User: 201 ModelCreated View
106106
107107
User ->> API: GET /model/:id
108108
API ->> MongoDB: Read API Model document
109109
MongoDB -->> API: API Model document
110-
API -->> User: API ModelView
110+
API -->> User: 200 API ModelView
111111
112112
User ->> API: PUT /model/:id
113113
API ->> MongoDB: Update API Model document
114-
API -->> User: ModelUpdated View
114+
API -->> User: 204
115115
116116
User ->> API: DELETE /model/:id
117117
API ->> MongoDB: Delete API Model document
118118
MongoDB -->> API: Deletion Confirmation
119-
API -->> User: ModelDeleted View
119+
API -->> User: 204
120120
121121
```
122122

@@ -126,19 +126,19 @@ sequenceDiagram
126126
participant User
127127
participant API
128128
participant MongoDB
129-
participant Rocketpy lib
129+
participant RocketPy lib
130130
131-
User ->> API: GET /summary/model/:id
132-
API -->> MongoDB: Retrieve Rocketpy native class
133-
MongoDB -->> API: Rocketpy native class
134-
API ->> Rocketpy lib: Simulate Rocketpy native class
135-
Rocketpy lib -->> API: Simulation Results
131+
User ->> API: GET model/:id/simulate/
132+
API -->> MongoDB: Retrieve API Model document
133+
MongoDB -->> API: API Model document
134+
API ->> RocketPy: Initialize RocketPy native class and simulate
135+
RocketPy lib -->> API: Simulation Results
136136
API -->> User: Simulation Results
137137
138138
User ->> API: GET /model/:id/rocketpy
139-
API -->> MongoDB: Retrieve Rocketpy Model
140-
MongoDB -->> API: Rocketpy Model
141-
API ->> Rocketpy lib: Rocketpy Model
142-
Rocketpy lib -->> API: Rocketpy native class
143-
API -->> User: Rocketpy native class as .dill binary
139+
API -->> MongoDB: Retrieve API Model document
140+
MongoDB -->> API: API Model document
141+
API ->> RocketPy: Initialize RocketPy native class
142+
RocketPy lib -->> API: RocketPy native class
143+
API -->> User: RocketPy native class as .dill binary (amd64)
144144
```

lib/controllers/flight.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
ControllerInterface,
33
controller_exception_handler,
44
)
5-
from lib.views.flight import FlightSimulation, FlightUpdated
5+
from lib.views.flight import FlightSimulation
66
from lib.models.flight import FlightModel
77
from lib.models.environment import EnvironmentModel
88
from lib.models.rocket import RocketModel
@@ -24,7 +24,7 @@ def __init__(self):
2424
@controller_exception_handler
2525
async def update_environment_by_flight_id(
2626
self, flight_id: str, *, environment: EnvironmentModel
27-
) -> FlightUpdated:
27+
) -> None:
2828
"""
2929
Update a models.Flight.environment in the database.
3030
@@ -33,20 +33,20 @@ async def update_environment_by_flight_id(
3333
environment: models.Environment
3434
3535
Returns:
36-
views.FlightUpdated
36+
None
3737
3838
Raises:
3939
HTTP 404 Not Found: If the flight is not found in the database.
4040
"""
4141
flight = await self.get_flight_by_id(flight_id)
4242
flight.environment = environment
4343
self.update_flight_by_id(flight_id, flight)
44-
return FlightUpdated(flight_id=flight_id)
44+
return
4545

4646
@controller_exception_handler
4747
async def update_rocket_by_flight_id(
4848
self, flight_id: str, *, rocket: RocketModel
49-
) -> FlightUpdated:
49+
) -> None:
5050
"""
5151
Update a models.Flight.rocket in the database.
5252
@@ -55,15 +55,15 @@ async def update_rocket_by_flight_id(
5555
rocket: models.Rocket
5656
5757
Returns:
58-
views.FlightUpdated
58+
None
5959
6060
Raises:
6161
HTTP 404 Not Found: If the flight is not found in the database.
6262
"""
6363
flight = await self.get_flight_by_id(flight_id)
6464
flight.rocket = rocket
6565
self.update_flight_by_id(flight_id, flight)
66-
return FlightUpdated(flight_id=flight_id)
66+
return
6767

6868
@controller_exception_handler
6969
async def get_rocketpy_flight_binary(

lib/models/environment.py

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -26,15 +26,11 @@ class EnvironmentModel(ApiBaseModel):
2626

2727
@staticmethod
2828
def UPDATED():
29-
from lib.views.environment import EnvironmentUpdated
30-
31-
return EnvironmentUpdated()
29+
return
3230

3331
@staticmethod
3432
def DELETED():
35-
from lib.views.environment import EnvironmentDeleted
36-
37-
return EnvironmentDeleted()
33+
return
3834

3935
@staticmethod
4036
def CREATED(model_id: str):

lib/models/flight.py

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -46,15 +46,11 @@ def get_additional_parameters(self):
4646

4747
@staticmethod
4848
def UPDATED():
49-
from lib.views.flight import FlightUpdated
50-
51-
return FlightUpdated()
49+
return
5250

5351
@staticmethod
5452
def DELETED():
55-
from lib.views.flight import FlightDeleted
56-
57-
return FlightDeleted()
53+
return
5854

5955
@staticmethod
6056
def CREATED(model_id: str):

lib/models/motor.py

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -82,15 +82,11 @@ def set_motor_kind(self, motor_kind: MotorKinds):
8282

8383
@staticmethod
8484
def UPDATED():
85-
from lib.views.motor import MotorUpdated
86-
87-
return MotorUpdated()
85+
return
8886

8987
@staticmethod
9088
def DELETED():
91-
from lib.views.motor import MotorDeleted
92-
93-
return MotorDeleted()
89+
return
9490

9591
@staticmethod
9692
def CREATED(model_id: str):

lib/models/rocket.py

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -39,15 +39,11 @@ class RocketModel(ApiBaseModel):
3939

4040
@staticmethod
4141
def UPDATED():
42-
from lib.views.rocket import RocketUpdated
43-
44-
return RocketUpdated()
42+
return
4543

4644
@staticmethod
4745
def DELETED():
48-
from lib.views.rocket import RocketDeleted
49-
50-
return RocketDeleted()
46+
return
5147

5248
@staticmethod
5349
def CREATED(model_id: str):

lib/routes/environment.py

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,6 @@
99
EnvironmentSimulation,
1010
EnvironmentCreated,
1111
EnvironmentRetrieved,
12-
EnvironmentUpdated,
13-
EnvironmentDeleted,
1412
)
1513
from lib.models.environment import EnvironmentModel
1614
from lib.controllers.environment import EnvironmentController
@@ -28,7 +26,7 @@
2826
tracer = trace.get_tracer(__name__)
2927

3028

31-
@router.post("/")
29+
@router.post("/", status_code=201)
3230
async def create_environment(
3331
environment: EnvironmentModel,
3432
) -> EnvironmentCreated:
@@ -56,10 +54,10 @@ async def read_environment(environment_id: str) -> EnvironmentRetrieved:
5654
return await controller.get_environment_by_id(environment_id)
5755

5856

59-
@router.put("/{environment_id}")
57+
@router.put("/{environment_id}", status_code=204)
6058
async def update_environment(
6159
environment_id: str, environment: EnvironmentModel
62-
) -> EnvironmentUpdated:
60+
) -> None:
6361
"""
6462
Updates an existing environment
6563
@@ -76,8 +74,8 @@ async def update_environment(
7674
)
7775

7876

79-
@router.delete("/{environment_id}")
80-
async def delete_environment(environment_id: str) -> EnvironmentDeleted:
77+
@router.delete("/{environment_id}", status_code=204)
78+
async def delete_environment(environment_id: str) -> None:
8179
"""
8280
Deletes an existing environment
8381

lib/routes/flight.py

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,6 @@
99
FlightSimulation,
1010
FlightCreated,
1111
FlightRetrieved,
12-
FlightUpdated,
13-
FlightDeleted,
1412
)
1513
from lib.models.environment import EnvironmentModel
1614
from lib.models.flight import FlightModel
@@ -31,7 +29,7 @@
3129
tracer = trace.get_tracer(__name__)
3230

3331

34-
@router.post("/")
32+
@router.post("/", status_code=201)
3533
async def create_flight(
3634
flight: FlightModel, motor_kind: MotorKinds
3735
) -> FlightCreated:
@@ -60,10 +58,10 @@ async def read_flight(flight_id: str) -> FlightRetrieved:
6058
return await controller.get_flight_by_id(flight_id)
6159

6260

63-
@router.put("/{flight_id}")
61+
@router.put("/{flight_id}", status_code=204)
6462
async def update_flight(
6563
flight_id: str, flight: FlightModel, motor_kind: MotorKinds
66-
) -> FlightUpdated:
64+
) -> None:
6765
"""
6866
Updates an existing flight
6967
@@ -79,8 +77,8 @@ async def update_flight(
7977
return await controller.put_flight_by_id(flight_id, flight)
8078

8179

82-
@router.delete("/{flight_id}")
83-
async def delete_flight(flight_id: str) -> FlightDeleted:
80+
@router.delete("/{flight_id}", status_code=204)
81+
async def delete_flight(flight_id: str) -> None:
8482
"""
8583
Deletes an existing flight
8684
@@ -125,10 +123,10 @@ async def get_rocketpy_flight_binary(flight_id: str):
125123
)
126124

127125

128-
@router.put("/{flight_id}/environment")
126+
@router.put("/{flight_id}/environment", status_code=204)
129127
async def update_flight_environment(
130128
flight_id: str, environment: EnvironmentModel
131-
) -> FlightUpdated:
129+
) -> None:
132130
"""
133131
Updates flight environment
134132
@@ -145,12 +143,12 @@ async def update_flight_environment(
145143
)
146144

147145

148-
@router.put("/{flight_id}/rocket")
146+
@router.put("/{flight_id}/rocket", status_code=204)
149147
async def update_flight_rocket(
150148
flight_id: str,
151149
rocket: RocketModel,
152150
motor_kind: MotorKinds,
153-
) -> FlightUpdated:
151+
) -> None:
154152
"""
155153
Updates flight rocket.
156154

lib/routes/motor.py

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,6 @@
99
MotorSimulation,
1010
MotorCreated,
1111
MotorRetrieved,
12-
MotorUpdated,
13-
MotorDeleted,
1412
)
1513
from lib.models.motor import MotorModel, MotorKinds
1614
from lib.controllers.motor import MotorController
@@ -28,7 +26,7 @@
2826
tracer = trace.get_tracer(__name__)
2927

3028

31-
@router.post("/")
29+
@router.post("/", status_code=201)
3230
async def create_motor(
3331
motor: MotorModel, motor_kind: MotorKinds
3432
) -> MotorCreated:
@@ -57,10 +55,10 @@ async def read_motor(motor_id: str) -> MotorRetrieved:
5755
return await controller.get_motor_by_id(motor_id)
5856

5957

60-
@router.put("/{motor_id}")
58+
@router.put("/{motor_id}", status_code=204)
6159
async def update_motor(
6260
motor_id: str, motor: MotorModel, motor_kind: MotorKinds
63-
) -> MotorUpdated:
61+
) -> None:
6462
"""
6563
Updates an existing motor
6664
@@ -76,8 +74,8 @@ async def update_motor(
7674
return await controller.put_motor_by_id(motor_id, motor)
7775

7876

79-
@router.delete("/{motor_id}")
80-
async def delete_motor(motor_id: str) -> MotorDeleted:
77+
@router.delete("/{motor_id}", status_code=204)
78+
async def delete_motor(motor_id: str) -> None:
8179
"""
8280
Deletes an existing motor
8381

lib/routes/rocket.py

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,6 @@
99
RocketSimulation,
1010
RocketCreated,
1111
RocketRetrieved,
12-
RocketUpdated,
13-
RocketDeleted,
1412
)
1513
from lib.models.rocket import RocketModel
1614
from lib.models.motor import MotorKinds
@@ -29,7 +27,7 @@
2927
tracer = trace.get_tracer(__name__)
3028

3129

32-
@router.post("/")
30+
@router.post("/", status_code=201)
3331
async def create_rocket(
3432
rocket: RocketModel, motor_kind: MotorKinds
3533
) -> RocketCreated:
@@ -58,10 +56,10 @@ async def read_rocket(rocket_id: str) -> RocketRetrieved:
5856
return await controller.get_rocket_by_id(rocket_id)
5957

6058

61-
@router.put("/{rocket_id}")
59+
@router.put("/{rocket_id}", status_code=204)
6260
async def update_rocket(
6361
rocket_id: str, rocket: RocketModel, motor_kind: MotorKinds
64-
) -> RocketUpdated:
62+
) -> None:
6563
"""
6664
Updates an existing rocket
6765
@@ -77,8 +75,8 @@ async def update_rocket(
7775
return await controller.put_rocket_by_id(rocket_id, rocket)
7876

7977

80-
@router.delete("/{rocket_id}")
81-
async def delete_rocket(rocket_id: str) -> RocketDeleted:
78+
@router.delete("/{rocket_id}", status_code=204)
79+
async def delete_rocket(rocket_id: str) -> None:
8280
"""
8381
Deletes an existing rocket
8482

lib/views/environment.py

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -61,11 +61,3 @@ class EnvironmentCreated(ApiBaseView):
6161
class EnvironmentRetrieved(ApiBaseView):
6262
message: str = "Environment successfully retrieved"
6363
environment: EnvironmentView
64-
65-
66-
class EnvironmentUpdated(ApiBaseView):
67-
message: str = "Environment successfully updated"
68-
69-
70-
class EnvironmentDeleted(ApiBaseView):
71-
message: str = "Environment successfully deleted"

0 commit comments

Comments
 (0)