Skip to content

opensampl.config.tp4100

Pydantic BaseSettings Management for the Microchip TP4100 connections.

Managed through environment in order to keep password as secure as possible.

TP4100Config

Bases: BaseSettings

Configuration settings for the Microchip TP4100 Connections

Handles grabbing the details from the environment (or .env file), all prefixed with TP4100__

Source code in opensampl/config/tp4100.py
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
class TP4100Config(BaseSettings):
    """
    Configuration settings for the Microchip TP4100 Connections

    Handles grabbing the details from the environment (or .env file), all prefixed with TP4100__
    """

    model_config = SettingsConfigDict(env_file=".env", extra="ignore", env_prefix="TP4100__")

    # TP4100 device connection settings
    HOST: str = Field(..., description="IP address or hostname of the TP4100 device")
    PORT: int = Field(443, description="HTTPS port for TP4100 web interface")
    USERNAME: str = Field(
        "admin", description=("Username for TP4100 login; Default is factory default according to user manual")
    )
    PASSWORD: str = Field(
        "Microchip", description=("Password for TP4100 login; Default is factory default according to user manual")
    )

    url: str = Field(default="", init=False)

    @model_validator(mode="after")
    def create_url(self):
        """Create https url for TP4100 Configuration"""
        self.url = f"https://{self.HOST}:{self.PORT}"
        return self

create_url()

Create https url for TP4100 Configuration

Source code in opensampl/config/tp4100.py
32
33
34
35
36
@model_validator(mode="after")
def create_url(self):
    """Create https url for TP4100 Configuration"""
    self.url = f"https://{self.HOST}:{self.PORT}"
    return self