From 10593de581b62d33ca1e2a3bc5e761487cb1e65f Mon Sep 17 00:00:00 2001 From: checktheroads Date: Mon, 13 Jul 2020 02:17:56 -0700 Subject: [PATCH] fix double RPKI status checking --- hyperglass/api/models/response.py | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/hyperglass/api/models/response.py b/hyperglass/api/models/response.py index 92721e8..5f34677 100644 --- a/hyperglass/api/models/response.py +++ b/hyperglass/api/models/response.py @@ -1,21 +1,24 @@ """Response model.""" # Standard Library -from typing import List, Union, Optional +from typing import Dict, List, Union, Optional # Third Party from pydantic import BaseModel, StrictInt, StrictStr, StrictBool, constr # Project from hyperglass.configuration import params -from hyperglass.parsing.models.serialized import ParsedRoutes + +ErrorName = constr(regex=r"(success|warning|error|danger)") +ResponseLevel = constr(regex=r"success") +ResponseFormat = constr(regex=r"(application\/json|text\/plain)") class QueryError(BaseModel): """Query response model.""" output: StrictStr = params.messages.general - level: constr(regex=r"(success|warning|error|danger)") = "danger" + level: ErrorName = "danger" id: Optional[StrictStr] keywords: List[StrictStr] = [] @@ -57,14 +60,14 @@ class QueryError(BaseModel): class QueryResponse(BaseModel): """Query response model.""" - output: Union[ParsedRoutes, StrictStr] - level: constr(regex=r"success") = "success" + output: Union[Dict, StrictStr] + level: ResponseLevel = "success" random: StrictStr cached: StrictBool runtime: StrictInt keywords: List[StrictStr] = [] timestamp: StrictStr - format: constr(regex=r"(application\/json|text\/plain)") = "text/plain" + format: ResponseFormat = "text/plain" class Config: """Pydantic model configuration."""