Models

Note

End users typically do not need to interact with these models directly. They are internal building blocks used by GPPConfig to validate, load, and serialize the configuration file. You will rarely (if ever) instantiate these models manually.

The GPP Client uses Pydantic models to validate and serialize the contents of the configuration file. These models ensure:

  • Consistent schema validation

  • Automatic empty-string cleanup

  • Correct serialization back to TOML or JSON

Tokens Model

Tokens stores API tokens for each defined environment.

Empty strings in the TOML file are automatically converted to None during validation.

from gpp_client.config.models import Tokens

tokens = Tokens(DEVELOPMENT="abc", STAGING="")
print(tokens.STAGING)   # → None

When serializing back to TOML or JSON, None becomes an empty string.

ConfigFile Model

ConfigFile represents the full configuration file.

Fields include:

  • env — active environment

  • disable_env_vars — whether environment vars are used

  • tokens — the environment token container

Example file:

env = "PRODUCTION"
disable_env_vars = false

[tokens]
DEVELOPMENT = ""
STAGING = "staging-token"
PRODUCTION = "prod-token"

Interaction With GPPConfig

The GPPConfig class wraps this model and provides:

  • File I/O

  • Token/Env mutation helpers

  • Runtime convenience methods

See Config for the operational interface.

API Reference

class gpp_client.config.models.Tokens(*, DEVELOPMENT: str | None = None, STAGING: str | None = None, PRODUCTION: str | None = None)[source]

Bases: BaseModel

Tokens for different GPP environments.

DEVELOPMENT: str | None
PRODUCTION: str | None
STAGING: str | None
classmethod empty_string_to_none(value)[source]

Convert empty strings to None.

Parameters:

value (str | None) – The value to validate.

Returns:

The validated value.

Return type:

str | None

model_config: ClassVar[ConfigDict] = {}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

classmethod none_to_empty_string(value: str | None) str[source]
class gpp_client.config.models.ConfigFile(*, env: GPPEnvironment = GPPEnvironment.PRODUCTION, disable_env_vars: bool = False, tokens: Tokens = Tokens(DEVELOPMENT=None, STAGING=None, PRODUCTION=None))[source]

Bases: BaseModel

GPP client configuration file model.

disable_env_vars: bool
env: GPPEnvironment
classmethod get_enum_value(value: GPPEnvironment) str[source]
model_config: ClassVar[ConfigDict] = {}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

tokens: Tokens