|
10 | 10 |
|
11 | 11 | from ....db.database import get_db_session |
12 | 12 | from ....db.models import User, LedgerEntryType |
13 | | -from ....dependencies import get_current_user, get_api_key_user |
| 13 | +from ....dependencies import get_current_user, get_user_jwt_or_api_key |
14 | 14 | from ....services.billing_service import billing_service |
15 | 15 | from ....crud import credits as credits_crud |
16 | 16 | from ....schemas.billing import ( |
|
40 | 40 | async def get_balance( |
41 | 41 | request: Request, |
42 | 42 | db: AsyncSession = Depends(get_db_session), |
43 | | - current_user: User = Depends(get_current_user), |
| 43 | + current_user: User = Depends(get_user_jwt_or_api_key), |
44 | 44 | ): |
45 | 45 | """ |
46 | 46 | Get current credit balance for the authenticated user. |
| 47 | +
|
| 48 | + Authenticate with either a Cognito JWT or an ``sk-…`` API key. |
47 | 49 | |
48 | 50 | Returns: |
49 | 51 | - paid: Paid bucket balance (posted, holds, available) |
@@ -132,11 +134,13 @@ async def list_transactions( |
132 | 134 | from_date: Optional[datetime] = Query(default=None, alias="from"), |
133 | 135 | to_date: Optional[datetime] = Query(default=None, alias="to"), |
134 | 136 | db: AsyncSession = Depends(get_db_session), |
135 | | - current_user: User = Depends(get_current_user), |
| 137 | + current_user: User = Depends(get_user_jwt_or_api_key), |
136 | 138 | ): |
137 | 139 | """ |
138 | 140 | Get paginated list of credit transactions (ledger entries). |
139 | | - |
| 141 | +
|
| 142 | + Authenticate with either a Cognito JWT or an ``sk-…`` API key. |
| 143 | +
|
140 | 144 | Parameters: |
141 | 145 | - limit: Maximum number of items to return (1-∞) |
142 | 146 | - offset: Number of items to skip |
@@ -226,11 +230,13 @@ async def get_monthly_spending( |
226 | 230 | year: int = Query(default=None, description="Year for spending data (defaults to current year)"), |
227 | 231 | mode: SpendingModeEnum = Query(default=SpendingModeEnum.gross), |
228 | 232 | db: AsyncSession = Depends(get_db_session), |
229 | | - current_user: User = Depends(get_current_user), |
| 233 | + current_user: User = Depends(get_user_jwt_or_api_key), |
230 | 234 | ): |
231 | 235 | """ |
232 | 236 | Get monthly spending metrics for a year. |
233 | | - |
| 237 | +
|
| 238 | + Authenticate with either a Cognito JWT or an ``sk-…`` API key. |
| 239 | +
|
234 | 240 | Parameters: |
235 | 241 | - year: Year to get spending for (defaults to current year) |
236 | 242 | - mode: |
@@ -300,11 +306,13 @@ async def list_usage( |
300 | 306 | to_date: Optional[datetime] = Query(default=None, alias="to"), |
301 | 307 | model: Optional[str] = Query(default=None), |
302 | 308 | db: AsyncSession = Depends(get_db_session), |
303 | | - current_user: User = Depends(get_current_user), |
| 309 | + current_user: User = Depends(get_user_jwt_or_api_key), |
304 | 310 | ): |
305 | 311 | """ |
306 | 312 | Get paginated list of usage entries (posted usage charges only). |
307 | | - |
| 313 | +
|
| 314 | + Authenticate with either a Cognito JWT or an ``sk-…`` API key. |
| 315 | +
|
308 | 316 | Parameters: |
309 | 317 | - limit: Maximum number of items to return (1-∞) |
310 | 318 | - offset: Number of items to skip |
@@ -374,11 +382,13 @@ async def list_usage_for_month( |
374 | 382 | limit: int = Query(default=50, ge=1), |
375 | 383 | offset: int = Query(default=0, ge=0), |
376 | 384 | db: AsyncSession = Depends(get_db_session), |
377 | | - current_user: User = Depends(get_current_user), |
| 385 | + current_user: User = Depends(get_user_jwt_or_api_key), |
378 | 386 | ): |
379 | 387 | """ |
380 | 388 | Get paginated list of usage entries for a specific month. |
381 | | - |
| 389 | +
|
| 390 | + Authenticate with either a Cognito JWT or an ``sk-…`` API key. |
| 391 | +
|
382 | 392 | Parameters: |
383 | 393 | - year: Year |
384 | 394 | - month: Month (1-12) |
|
0 commit comments