diff --git a/src/middlewared/middlewared/api/v25_04_0/core.py b/src/middlewared/middlewared/api/v25_04_0/core.py index 202f3f292e81..4b58ffc83ad2 100644 --- a/src/middlewared/middlewared/api/v25_04_0/core.py +++ b/src/middlewared/middlewared/api/v25_04_0/core.py @@ -1,7 +1,25 @@ +from typing import Literal + from middlewared.api.base import BaseModel, ForUpdateMetaclass, single_argument_result -__all__ = ["CoreSetOptionsArgs", "CoreSetOptionsResult", "CoreSubscribeArgs", "CoreSubscribeResult", - "CoreUnsubscribeArgs", "CoreUnsubscribeResult"] +__all__ = [ + "CorePingArgs", + "CorePingResult", + "CoreSetOptionsArgs", + "CoreSetOptionsResult", + "CoreSubscribeArgs", + "CoreSubscribeResult", + "CoreUnsubscribeArgs", + "CoreUnsubscribeResult", +] + + +class CorePingArgs(BaseModel): + pass + + +class CorePingResult(BaseModel): + result: Literal["pong"] class CoreSetOptionsOptions(BaseModel, metaclass=ForUpdateMetaclass): diff --git a/src/middlewared/middlewared/service/core_service.py b/src/middlewared/middlewared/service/core_service.py index be9317566222..86ba073dd60a 100644 --- a/src/middlewared/middlewared/service/core_service.py +++ b/src/middlewared/middlewared/service/core_service.py @@ -19,7 +19,13 @@ from middlewared.api import api_method from middlewared.api.base.jsonschema import get_json_schema from middlewared.api.current import ( - CoreSetOptionsArgs, CoreSetOptionsResult, CoreSubscribeArgs, CoreSubscribeResult, CoreUnsubscribeArgs, + CorePingArgs, + CorePingResult, + CoreSetOptionsArgs, + CoreSetOptionsResult, + CoreSubscribeArgs, + CoreSubscribeResult, + CoreUnsubscribeArgs, CoreUnsubscribeResult, ) from middlewared.common.environ import environ_update @@ -522,8 +528,7 @@ async def event_send(self, name, event_type, kwargs=None): kwargs = kwargs or {} self.middleware.send_event(name, event_type, **kwargs) - @no_authz_required - @accepts() + @api_method(CorePingArgs, CorePingResult, authorization_required=False) def ping(self): """ Utility method which just returns "pong".