From ea65e1d24bf9327edd2244a81e9c307f3001b16f Mon Sep 17 00:00:00 2001 From: Jonathan Voss Date: Mon, 17 Aug 2026 04:50:22 +0000 Subject: http-api: T9224: add ping endpoint to REST API --- src/services/api/rest/models.py | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) (limited to 'src/services/api/rest/models.py') diff --git a/src/services/api/rest/models.py b/src/services/api/rest/models.py index bfea17344..d3ee3a08e 100644 --- a/src/services/api/rest/models.py +++ b/src/services/api/rest/models.py @@ -304,6 +304,31 @@ class PoweroffModel(ApiModel): } +class PingModel(ApiModel): + op: StrictStr + host: StrictStr + count: StrictInt = 5 + vrf: StrictStr = None + + @field_validator('count') + @classmethod + def check_between(cls, count: int) -> int: + if not 1 <= count <= 10: + raise ValueError('count must be between 1 and 10') + return count + + class Config: + schema_extra = { + 'example': { + 'key': 'id_key', + 'op': 'ping', + 'host': 'host', + 'count': 5, + 'vrf': 'vrf', + } + } + + class TracerouteModel(ApiModel): op: StrictStr host: StrictStr -- cgit v1.2.3