1
0
mirror of https://github.com/checktheroads/hyperglass synced 2024-05-11 05:55:08 +00:00

refactor front end params

This commit is contained in:
checktheroads
2020-01-28 12:03:47 -07:00
parent af0fac32d9
commit dc4baebfa3
10 changed files with 410 additions and 328 deletions

View File

@@ -8,6 +8,7 @@ from pydantic import constr
# Project Imports
from hyperglass.configuration.models._utils import HyperglassModel
from hyperglass.constants import SUPPORTED_QUERY_TYPES
class BgpCommunity(HyperglassModel):
@@ -77,6 +78,42 @@ class Queries(HyperglassModel):
"Prefix length must be smaller than /{m}. <b>{i}</b> is too specific."
)
@property
def map(self):
"""Return a dict of all query display names, internal names, and enable state.
Returns:
{dict} -- Dict of queries.
"""
_map = {}
for query in SUPPORTED_QUERY_TYPES:
query_obj = getattr(self, query)
_map[query] = {
"name": query,
"display_name": query_obj.display_name,
"enable": query_obj.enable,
}
return _map
@property
def list(self):
"""Return a list of all query display names, internal names, and enable state.
Returns:
{list} -- Dict of queries.
"""
_list = []
for query in SUPPORTED_QUERY_TYPES:
query_obj = getattr(self, query)
_list.append(
{
"name": query,
"display_name": query_obj.display_name,
"enable": query_obj.enable,
}
)
return _list
bgp_route: BgpRoute = BgpRoute()
bgp_community: BgpCommunity = BgpCommunity()
bgp_aspath: BgpAsPath = BgpAsPath()