Skip to content

config

Core module for oqtopus-client.

Classes:

OqtopusConfig dataclass

OqtopusConfig(
    base_url: str,
    api_token: str | None = None,
    proxy: str | None = None,
    timeout: float = 30.0,
    retry_max_attempts: int = 3,
    retry_backoff_seconds: float = 0.2,
    retry_status_codes: frozenset[int] | None = None,
    retry_methods: frozenset[str] | None = None,
)

Shared client configuration bundle.

Attributes:

  • base_url (str) –

    OQTOPUS API base URL.

  • api_token (str | None) –

    API token string.

  • timeout (float) –

    HTTP request timeout seconds.

  • retry_max_attempts (int) –

    Max retry attempts for retryable requests.

  • retry_backoff_seconds (float) –

    Exponential backoff base seconds.

  • retry_status_codes (frozenset[int] | None) –

    HTTP status codes treated as retryable.

  • retry_methods (frozenset[str] | None) –

    HTTP methods treated as retryable.

Methods:

  • from_env

    Load configuration from environment variables.

  • from_file

    Load configuration from an INI-style profile file.

from_env classmethod

from_env(
    *,
    base_url_env: str = DEFAULT_BASE_URL_ENV,
    proxy_env: str = DEFAULT_PROXY_ENV,
    api_token_env: str = DEFAULT_API_TOKEN_ENV,
) -> OqtopusConfig

Load configuration from environment variables.

Parameters:

  • base_url_env

    (Optional, default: DEFAULT_BASE_URL_ENV ) –

    Environment variable name used for the API base URL. Defaults to OQTOPUS_BASE_URL.

  • proxy_env

    (Optional, default: DEFAULT_PROXY_ENV ) –

    Environment variable name used for the proxy URL. Defaults to OQTOPUS_PROXY.

  • api_token_env

    (Optional, default: DEFAULT_API_TOKEN_ENV ) –

    Environment variable name used for the API token. Defaults to OQTOPUS_API_TOKEN.

Returns:

  • OqtopusConfig

    Configuration loaded from environment variables.

Raises:

  • ValueError

    If the base URL environment variable is not set.

from_file classmethod

from_file(
    section: str = DEFAULT_SECTION,
    path: str | Path | object = _DEFAULT_CONFIG_PATH,
) -> OqtopusConfig

Load configuration from an INI-style profile file.

Parameters:

  • section

    (Optional, default: DEFAULT_SECTION ) –

    INI section name to load. Defaults to default.

  • path

    (Optional, default: _DEFAULT_CONFIG_PATH ) –

    Config file path. When omitted, this method reads $XDG_CONFIG_HOME/oqtopus/config.ini if XDG_CONFIG_HOME is set; otherwise it reads ~/.config/oqtopus/config.ini.

Example

OqtopusClient(OqtopusConfig.from_file("oqtopus-dev"))

Returns:

  • OqtopusConfig

    Configuration loaded from the requested profile.

Raises:

  • ValueError

    If section or path is invalid, or if the profile is missing required values.