From 78fc1b51f7a505dce6efd4799175384260bbeb70 Mon Sep 17 00:00:00 2001 From: Naman Munet Date: Thu, 26 Dec 2024 14:18:00 +0530 Subject: [PATCH] mgr/dashboard: adding & exposing Param Class to support EndpointDoc creation Fixes: https://tracker.ceph.com/issues/69272 Signed-off-by: Naman Munet --- src/pybind/mgr/dashboard/controllers/__init__.py | 3 ++- src/pybind/mgr/dashboard/controllers/_docs.py | 9 ++++++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/src/pybind/mgr/dashboard/controllers/__init__.py b/src/pybind/mgr/dashboard/controllers/__init__.py index af3f276ebfa..3db5da5d323 100755 --- a/src/pybind/mgr/dashboard/controllers/__init__.py +++ b/src/pybind/mgr/dashboard/controllers/__init__.py @@ -2,7 +2,7 @@ from ._api_router import APIRouter from ._auth import ControllerAuthMixin from ._base_controller import BaseController from ._crud import CRUDCollectionMethod, CRUDEndpoint, CRUDResourceMethod, SecretStr -from ._docs import APIDoc, EndpointDoc +from ._docs import APIDoc, EndpointDoc, Param from ._endpoint import Endpoint, Proxy from ._helpers import ENDPOINT_MAP, allow_empty_body, \ generate_controller_routes, json_error_page, validate_ceph_type @@ -23,6 +23,7 @@ __all__ = [ 'Task', 'ControllerAuthMixin', 'EndpointDoc', + 'Param', 'APIDoc', 'allow_empty_body', 'ENDPOINT_MAP', diff --git a/src/pybind/mgr/dashboard/controllers/_docs.py b/src/pybind/mgr/dashboard/controllers/_docs.py index 5bd7a5a7a6e..7301875f6b4 100644 --- a/src/pybind/mgr/dashboard/controllers/_docs.py +++ b/src/pybind/mgr/dashboard/controllers/_docs.py @@ -1,4 +1,4 @@ -from typing import Any, Dict, List, Optional, Tuple, Union +from typing import Any, Dict, List, NamedTuple, Optional, Tuple, Type, Union from ..api.doc import SchemaInput, SchemaType @@ -115,6 +115,13 @@ class EndpointDoc: # noqa: N802 return func +class Param(NamedTuple): + type: Union[Type, List[Type]] + description: str + optional: bool = False + default: Optional[Any] = None + + class APIDoc(object): def __init__(self, description="", group=""): self.tag = group -- 2.39.5