2020-01-28 09:52:54 -07:00
|
|
|
"""Validation model for Redis cache config."""
|
|
|
|
|
2020-02-03 02:35:11 -07:00
|
|
|
# Standard Library
|
2020-02-01 16:11:01 -10:00
|
|
|
from typing import Union
|
|
|
|
|
2020-02-03 02:35:11 -07:00
|
|
|
# Third Party
|
|
|
|
from pydantic import Field, StrictInt, StrictStr, StrictBool, IPvAnyAddress
|
2020-01-28 09:52:54 -07:00
|
|
|
|
2020-02-03 02:35:11 -07:00
|
|
|
# Project
|
2020-01-28 09:52:54 -07:00
|
|
|
from hyperglass.configuration.models._utils import HyperglassModel
|
|
|
|
|
|
|
|
|
|
|
|
class Cache(HyperglassModel):
|
|
|
|
"""Validation model for params.cache."""
|
|
|
|
|
2020-02-01 16:11:01 -10:00
|
|
|
host: Union[IPvAnyAddress, StrictStr] = Field(
|
|
|
|
"localhost", title="Host", description="Redis server IP address or hostname."
|
|
|
|
)
|
|
|
|
port: StrictInt = Field(6379, title="Port", description="Redis server TCP port.")
|
|
|
|
database: StrictInt = Field(
|
|
|
|
0, title="Database ID", description="Redis server database ID."
|
|
|
|
)
|
|
|
|
timeout: StrictInt = Field(
|
|
|
|
120,
|
|
|
|
title="Timeout",
|
|
|
|
description="Time in seconds query output will be kept in the Redis cache.",
|
|
|
|
)
|
|
|
|
show_text: StrictBool = Field(
|
|
|
|
True,
|
|
|
|
title="Show Text",
|
2020-02-08 00:58:32 -07:00
|
|
|
description="Show the [cache](/fixme) text in the hyperglass UI.",
|
2020-02-01 16:11:01 -10:00
|
|
|
)
|
|
|
|
|
|
|
|
class Config:
|
|
|
|
"""Pydantic model configuration."""
|
|
|
|
|
|
|
|
title = "Cache"
|
|
|
|
description = "Redis server & cache timeout configuration."
|
2020-02-08 00:58:32 -07:00
|
|
|
schema_extra = {"level": 2}
|