Skip to content

Commit

Permalink
add core.ping to new api (#14980)
Browse files Browse the repository at this point in the history
  • Loading branch information
yocalebo authored Nov 19, 2024
1 parent 16cccbe commit 6d8486a
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 5 deletions.
22 changes: 20 additions & 2 deletions src/middlewared/middlewared/api/v25_04_0/core.py
Original file line number Diff line number Diff line change
@@ -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):
Expand Down
11 changes: 8 additions & 3 deletions src/middlewared/middlewared/service/core_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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".
Expand Down

0 comments on commit 6d8486a

Please sign in to comment.