From: Naman Munet Date: Thu, 26 Dec 2024 08:48:00 +0000 (+0530) Subject: mgr/dashboard: adding & exposing Param Class to support EndpointDoc creation X-Git-Tag: testing/HEAD-reef-debug~32^2 X-Git-Url: http://git.apps.os.sepia.ceph.com/?a=commitdiff_plain;h=78fc1b51f7a505dce6efd4799175384260bbeb70;p=ceph-ci.git mgr/dashboard: adding & exposing Param Class to support EndpointDoc creation Fixes: https://tracker.ceph.com/issues/69272 Signed-off-by: Naman Munet --- 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