Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4,355 changes: 3,721 additions & 634 deletions docs/openapi.json

Large diffs are not rendered by default.

24 changes: 5 additions & 19 deletions src/app/endpoints/authorized.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,26 +12,12 @@
logger = logging.getLogger(__name__)
router = APIRouter(tags=["authorized"])


authorized_responses: dict[int | str, dict[str, Any]] = {
200: {
"description": "The user is logged-in and authorized to access OLS",
"model": AuthorizedResponse,
},
400: {
"description": "Missing or invalid credentials provided by client for the noop and "
"noop-with-token authentication modules",
"model": UnauthorizedResponse,
},
401: {
"description": "Missing or invalid credentials provided by client for the "
"k8s authentication module",
"model": UnauthorizedResponse,
},
403: {
"description": "User is not authorized",
"model": ForbiddenResponse,
},
200: AuthorizedResponse.openapi_response(),
401: UnauthorizedResponse.openapi_response(
examples=["missing header", "missing token"]
),
403: ForbiddenResponse.openapi_response(examples=["endpoint"]),
}


Expand Down
58 changes: 16 additions & 42 deletions src/app/endpoints/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,52 +9,26 @@
from authentication.interface import AuthTuple
from authorization.middleware import authorize
from configuration import configuration
from models.config import Action, Configuration
from models.config import Action
from models.responses import (
ConfigurationResponse,
ForbiddenResponse,
InternalServerErrorResponse,
UnauthorizedResponse,
)
from utils.endpoints import check_configuration_loaded

logger = logging.getLogger(__name__)
router = APIRouter(tags=["config"])


get_config_responses: dict[int | str, dict[str, Any]] = {
200: {
"name": "foo bar baz",
"service": {
"host": "localhost",
"port": 8080,
"auth_enabled": False,
"workers": 1,
"color_log": True,
"access_log": True,
"tls_config": {
"tls_certificate_path": "config/certificate.crt",
"tls_key_path": "config/private.key",
"tls_key_password": None,
},
},
"llama_stack": {
"url": "http://localhost:8321",
"api_key": "*****",
"use_as_library_client": False,
"library_client_config_path": None,
},
"user_data_collection": {
"feedback_enabled": True,
"feedback_storage": "/tmp/data/feedback",
"transcripts_enabled": False,
"transcripts_storage": None,
},
"mcp_servers": [
{"name": "server1", "provider_id": "provider1", "url": "http://url.com:1"},
{"name": "server2", "provider_id": "provider2", "url": "http://url.com:2"},
{"name": "server3", "provider_id": "provider3", "url": "http://url.com:3"},
],
},
503: {
"detail": {
"response": "Configuration is not loaded",
}
},
200: ConfigurationResponse.openapi_response(),
401: UnauthorizedResponse.openapi_response(
examples=["missing header", "missing token"]
),
403: ForbiddenResponse.openapi_response(examples=["endpoint"]),
500: InternalServerErrorResponse.openapi_response(examples=["configuration"]),
}


Expand All @@ -63,15 +37,15 @@
async def config_endpoint_handler(
auth: Annotated[AuthTuple, Depends(get_auth_dependency())],
request: Request,
) -> Configuration:
) -> ConfigurationResponse:
"""
Handle requests to the /config endpoint.

Process GET requests to the /config endpoint and returns the
current service configuration.

Returns:
Configuration: The loaded service configuration object.
ConfigurationResponse: The loaded service configuration response.
"""
# Used only for authorization
_ = auth
Expand All @@ -82,4 +56,4 @@ async def config_endpoint_handler(
# ensure that configuration is loaded
check_configuration_loaded(configuration)

return configuration.configuration
return ConfigurationResponse(configuration=configuration.configuration)
Loading
Loading