diff options
| author | John Estabrook <jestabro@vyos.io> | 2026-08-24 10:40:13 -0500 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2026-08-24 10:40:13 -0500 |
| commit | 745a4afd9bab8a99fdfdb38febe7bf39ac8e5a25 (patch) | |
| tree | 6d39c115ec2403d3dd45417704adee43d5a22d1f /src/services/api/rest/models.py | |
| parent | 0712fac9dddb4dbfede4409867d2973ccbfb5aa2 (diff) | |
| parent | ea65e1d24bf9327edd2244a81e9c307f3001b16f (diff) | |
| download | vyos-1x-745a4afd9bab8a99fdfdb38febe7bf39ac8e5a25.tar.gz vyos-1x-745a4afd9bab8a99fdfdb38febe7bf39ac8e5a25.zip | |
Merge pull request #5415 from jvoss/api_ping
http-api: T9224: add ping endpoint to REST API
Diffstat (limited to 'src/services/api/rest/models.py')
| -rw-r--r-- | src/services/api/rest/models.py | 25 |
1 files changed, 25 insertions, 0 deletions
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 |
