forked from mirrors/thatmattlove-hyperglass
fix & clean up api response models
This commit is contained in:
parent
213da6380b
commit
20ae02e2e5
1 changed files with 6 additions and 25 deletions
|
|
@ -1,7 +1,7 @@
|
||||||
"""Response model."""
|
"""Response model."""
|
||||||
|
|
||||||
# Standard Library
|
# Standard Library
|
||||||
from typing import Dict, List, Union, Optional
|
import typing as t
|
||||||
|
|
||||||
# Third Party
|
# Third Party
|
||||||
from pydantic import BaseModel, StrictInt, StrictStr, StrictBool, constr, validator
|
from pydantic import BaseModel, StrictInt, StrictStr, StrictBool, constr, validator
|
||||||
|
|
@ -19,8 +19,8 @@ class QueryError(BaseModel):
|
||||||
|
|
||||||
output: StrictStr
|
output: StrictStr
|
||||||
level: ErrorName = "danger"
|
level: ErrorName = "danger"
|
||||||
id: Optional[StrictStr]
|
id: t.Optional[StrictStr]
|
||||||
keywords: List[StrictStr] = []
|
keywords: t.List[StrictStr] = []
|
||||||
|
|
||||||
@validator("output")
|
@validator("output")
|
||||||
def validate_output(cls: "QueryError", value):
|
def validate_output(cls: "QueryError", value):
|
||||||
|
|
@ -62,12 +62,12 @@ class QueryError(BaseModel):
|
||||||
class QueryResponse(BaseModel):
|
class QueryResponse(BaseModel):
|
||||||
"""Query response model."""
|
"""Query response model."""
|
||||||
|
|
||||||
output: Union[Dict, StrictStr]
|
output: t.Union[t.Dict, StrictStr]
|
||||||
level: ResponseLevel = "success"
|
level: ResponseLevel = "success"
|
||||||
random: StrictStr
|
random: StrictStr
|
||||||
cached: StrictBool
|
cached: StrictBool
|
||||||
runtime: StrictInt
|
runtime: StrictInt
|
||||||
keywords: List[StrictStr] = []
|
keywords: t.List[StrictStr] = []
|
||||||
timestamp: StrictStr
|
timestamp: StrictStr
|
||||||
format: ResponseFormat = "text/plain"
|
format: ResponseFormat = "text/plain"
|
||||||
|
|
||||||
|
|
@ -144,31 +144,12 @@ Paths: (12 available, best #1, table default)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
class Vrf(BaseModel):
|
|
||||||
"""Response model for /api/devices VRFs."""
|
|
||||||
|
|
||||||
name: StrictStr
|
|
||||||
display_name: StrictStr
|
|
||||||
|
|
||||||
class Config:
|
|
||||||
"""Pydantic model configuration."""
|
|
||||||
|
|
||||||
title = "VRF"
|
|
||||||
description = "VRF attributes"
|
|
||||||
schema_extra = {
|
|
||||||
"examples": [
|
|
||||||
{"name": "default", "display_name": "Global Routing Table"},
|
|
||||||
{"name": "customer_vrf_name", "display_name": "Customer Name"},
|
|
||||||
]
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
class RoutersResponse(BaseModel):
|
class RoutersResponse(BaseModel):
|
||||||
"""Response model for /api/devices list items."""
|
"""Response model for /api/devices list items."""
|
||||||
|
|
||||||
id: StrictStr
|
id: StrictStr
|
||||||
name: StrictStr
|
name: StrictStr
|
||||||
group: StrictStr
|
group: t.Union[StrictStr, None]
|
||||||
|
|
||||||
class Config:
|
class Config:
|
||||||
"""Pydantic model configuration."""
|
"""Pydantic model configuration."""
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue