"""RedPepper Manager configuration"""

import pathlib
import secrets

import pydantic

from redpepper.common.config import BaseConfig, ConnectionConfig, TLSConfig

DEFAULT_CONFIG_FILE = "/etc/redpepper/agent.yml"


class AgentConfig(BaseConfig, ConnectionConfig, TLSConfig):
    # Connection
    manager_host: str = "localhost"
    manager_port: int = 7051

    # Auth
    agent_id: str = pydantic.Field(
        default_factory=lambda: "autogenerated_" + secrets.token_hex(8)
    )
    agent_secret: pydantic.SecretStr = pydantic.Field(
        default_factory=lambda: secrets.token_urlsafe(32)
    )

    # Paths
    operation_modules_cache_dir: pydantic.DirectoryPath = pathlib.Path(
        "/var/lib/redpepper-agent/operations"
    )

    # Timeouts
    data_request_timeout: int = 5
    hello_timeout: int = 3

    # Defaults
    tls_key_file: pydantic.FilePath = pathlib.Path("/etc/redpepper/agent-key.pem")
    tls_cert_file: pydantic.FilePath = pathlib.Path("/etc/redpepper/agent.pem")
