2
2
Core FastAPI app (setup, middleware)
3
3
"""
4
4
from pathlib import Path
5
- from typing import Optional
5
+ from typing import Annotated , Optional
6
6
7
7
from fastapi import APIRouter , Body , Depends , Request , Response
8
8
from fastapi .encoders import jsonable_encoder
15
15
from jbi .runner import IgnoreInvalidRequestError , execute_action
16
16
from jbi .services import bugzilla , jira
17
17
18
+ _settings = Annotated [Settings , Depends (get_settings )]
19
+ _actions = Annotated [Actions , Depends (get_actions )]
20
+ _version = Annotated [dict , Depends (get_version )]
18
21
router = APIRouter ()
19
22
20
23
21
24
@router .get ("/" , include_in_schema = False )
22
- def root (request : Request , settings : Settings = Depends ( get_settings ) ):
25
+ def root (request : Request , settings : _settings ):
23
26
"""Expose key configuration"""
24
27
return {
25
28
"title" : request .app .title ,
@@ -35,7 +38,7 @@ def root(request: Request, settings: Settings = Depends(get_settings)):
35
38
36
39
@router .get ("/__heartbeat__" )
37
40
@router .head ("/__heartbeat__" )
38
- def heartbeat (response : Response , actions : Actions = Depends ( get_actions ) ):
41
+ def heartbeat (response : Response , actions : _actions ):
39
42
"""Return status of backing services, as required by Dockerflow."""
40
43
health_map = {
41
44
"bugzilla" : bugzilla .check_health (),
@@ -57,17 +60,17 @@ def lbheartbeat():
57
60
58
61
59
62
@router .get ("/__version__" )
60
- def version (version_json = Depends ( get_version ) ):
63
+ def version (version_json : _version ):
61
64
"""Return version.json, as required by Dockerflow."""
62
65
return version_json
63
66
64
67
65
68
@router .post ("/bugzilla_webhook" )
66
69
def bugzilla_webhook (
67
70
request : Request ,
71
+ actions : _actions ,
72
+ settings : _settings ,
68
73
webhook_request : BugzillaWebhookRequest = Body (..., embed = False ),
69
- actions : Actions = Depends (get_actions ),
70
- settings : Settings = Depends (get_settings ),
71
74
):
72
75
"""API endpoint that Bugzilla Webhook Events request"""
73
76
webhook_request .rid = request .state .rid
@@ -80,8 +83,8 @@ def bugzilla_webhook(
80
83
81
84
@router .get ("/whiteboard_tags/" )
82
85
def get_whiteboard_tags (
86
+ actions : _actions ,
83
87
whiteboard_tag : Optional [str ] = None ,
84
- actions : Actions = Depends (get_actions ),
85
88
):
86
89
"""API for viewing whiteboard_tags and associated data"""
87
90
if existing := actions .get (whiteboard_tag ):
@@ -103,8 +106,8 @@ def get_jira_projects():
103
106
@router .get ("/powered_by_jbi/" , response_class = HTMLResponse )
104
107
def powered_by_jbi (
105
108
request : Request ,
109
+ actions : _actions ,
106
110
enabled : Optional [bool ] = None ,
107
- actions : Actions = Depends (get_actions ),
108
111
):
109
112
"""API for `Powered By` endpoint"""
110
113
context = {
0 commit comments