99from authentication .interface import AuthTuple
1010from authorization .middleware import authorize
1111from configuration import configuration
12- from models .config import Action , Configuration
12+ from models .config import Action
13+ from models .responses import (
14+ ConfigurationResponse ,
15+ ForbiddenResponse ,
16+ InternalServerErrorResponse ,
17+ UnauthorizedResponse ,
18+ )
1319from utils .endpoints import check_configuration_loaded
1420
1521logger = logging .getLogger (__name__ )
1622router = APIRouter (tags = ["config" ])
1723
1824
1925get_config_responses : dict [int | str , dict [str , Any ]] = {
20- 200 : {
21- "name" : "foo bar baz" ,
22- "service" : {
23- "host" : "localhost" ,
24- "port" : 8080 ,
25- "auth_enabled" : False ,
26- "workers" : 1 ,
27- "color_log" : True ,
28- "access_log" : True ,
29- "tls_config" : {
30- "tls_certificate_path" : "config/certificate.crt" ,
31- "tls_key_path" : "config/private.key" ,
32- "tls_key_password" : None ,
33- },
34- },
35- "llama_stack" : {
36- "url" : "http://localhost:8321" ,
37- "api_key" : "*****" ,
38- "use_as_library_client" : False ,
39- "library_client_config_path" : None ,
40- },
41- "user_data_collection" : {
42- "feedback_enabled" : True ,
43- "feedback_storage" : "/tmp/data/feedback" ,
44- "transcripts_enabled" : False ,
45- "transcripts_storage" : None ,
46- },
47- "mcp_servers" : [
48- {"name" : "server1" , "provider_id" : "provider1" , "url" : "http://url.com:1" },
49- {"name" : "server2" , "provider_id" : "provider2" , "url" : "http://url.com:2" },
50- {"name" : "server3" , "provider_id" : "provider3" , "url" : "http://url.com:3" },
51- ],
52- },
53- 503 : {
54- "detail" : {
55- "response" : "Configuration is not loaded" ,
56- }
57- },
26+ 200 : ConfigurationResponse .openapi_response (),
27+ 401 : UnauthorizedResponse .openapi_response (
28+ examples = ["missing header" , "missing token" ]
29+ ),
30+ 403 : ForbiddenResponse .openapi_response (examples = ["endpoint" ]),
31+ 500 : InternalServerErrorResponse .openapi_response (examples = ["configuration" ]),
5832}
5933
6034
6337async def config_endpoint_handler (
6438 auth : Annotated [AuthTuple , Depends (get_auth_dependency ())],
6539 request : Request ,
66- ) -> Configuration :
40+ ) -> ConfigurationResponse :
6741 """
6842 Handle requests to the /config endpoint.
6943
7044 Process GET requests to the /config endpoint and returns the
7145 current service configuration.
7246
7347 Returns:
74- Configuration : The loaded service configuration object .
48+ ConfigurationResponse : The loaded service configuration response .
7549 """
7650 # Used only for authorization
7751 _ = auth
@@ -82,4 +56,4 @@ async def config_endpoint_handler(
8256 # ensure that configuration is loaded
8357 check_configuration_loaded (configuration )
8458
85- return configuration .configuration
59+ return ConfigurationResponse ( configuration = configuration .configuration )
0 commit comments