File tree 4 files changed +18
-13
lines changed
4 files changed +18
-13
lines changed Original file line number Diff line number Diff line change @@ -108,6 +108,7 @@ async def post_subscription_allocation(
108
108
@router .get ("/allocations" , response_model = List [AllocationListItem ])
109
109
async def get_subscription_allocations (
110
110
subscription : SubscriptionItem , _ : UserRBAC = Depends (token_admin_verified )
111
- ) -> Any :
111
+ ) -> List [ AllocationListItem ] :
112
112
"""Return a list of allocations for a subscription."""
113
- return await get_allocations (subscription .sub_id )
113
+ rows = await get_allocations (subscription .sub_id )
114
+ return [AllocationListItem (** dict (x )) for x in rows ]
Original file line number Diff line number Diff line change 2
2
3
3
import datetime
4
4
from datetime import timedelta
5
- from typing import Any , List , Optional
5
+ from typing import Any , List
6
6
7
7
from fastapi import Depends , HTTPException
8
8
from sqlalchemy import insert
@@ -143,9 +143,10 @@ async def check_approval(approval: Approval) -> None:
143
143
@router .get ("/approvals" , response_model = List [ApprovalListItem ])
144
144
async def get_subscription_approvals (
145
145
subscription : SubscriptionItem , _ : UserRBAC = Depends (token_admin_verified )
146
- ) -> Optional [ List [ApprovalListItem ] ]:
146
+ ) -> List [ApprovalListItem ]:
147
147
"""Returns a list approvals for a subscription."""
148
- return await get_approvals (subscription .sub_id )
148
+ rows = await get_approvals (subscription .sub_id )
149
+ return [ApprovalListItem (** dict (x )) for x in rows ]
149
150
150
151
151
152
@router .post ("/approve" , status_code = 200 )
Original file line number Diff line number Diff line change @@ -214,21 +214,22 @@ async def calc_cost_recovery_app(
214
214
@router .post ("/cli-cost-recovery" , response_model = List [CostRecovery ])
215
215
async def post_calc_cost_recovery_cli (
216
216
recovery_month : CostRecoveryMonth , user : UserRBAC = Depends (token_admin_verified )
217
- ) -> Any :
217
+ ) -> List [ CostRecovery ] :
218
218
"""Route for the CLI to trigger cost recovery calculation."""
219
- resp = await calc_cost_recovery (
219
+ rows = await calc_cost_recovery (
220
220
recovery_month , commit_transaction = True , admin = user .oid
221
221
)
222
222
223
- return resp
223
+ return [ CostRecovery ( ** dict ( x )) for x in rows ]
224
224
225
225
226
226
@router .get ("/cli-cost-recovery" , response_model = List [CostRecovery ])
227
227
async def get_calc_cost_recovery_cli (
228
228
recovery_month : CostRecoveryMonth , user : UserRBAC = Depends (token_admin_verified )
229
- ) -> Any :
229
+ ) -> List [ CostRecovery ] :
230
230
"""Route for the CLI to do a dry-run of the cost recovery calculation."""
231
- result = await calc_cost_recovery (
231
+ rows = await calc_cost_recovery (
232
232
recovery_month , commit_transaction = False , admin = user .oid
233
233
)
234
- return result
234
+
235
+ return [CostRecovery (** dict (x )) for x in rows ]
Original file line number Diff line number Diff line change @@ -280,7 +280,9 @@ async def post_cm_usage(
280
280
281
281
282
282
@router .get ("/all-cm-usage" , response_model = List [CMUsage ])
283
- async def get_cm_usage (_ : UserRBAC = Depends (token_admin_verified )) -> Any :
283
+ async def get_cm_usage (_ : UserRBAC = Depends (token_admin_verified )) -> List [ CMUsage ] :
284
284
"""Get all cost-management data."""
285
285
cm_query = select ([accounting_models .costmanagement ])
286
- return await database .fetch_all (cm_query )
286
+ rows = [dict (x ) for x in await database .fetch_all (cm_query )]
287
+ result = [CMUsage (** x ) for x in rows ]
288
+ return result
You can’t perform that action at this time.
0 commit comments