quota_notifier.settings
Application settings management.
Class definitions inheriting from BaseSettings
directly define
the settings file schema. The ApplicationSettings
class is used to manage
application settings in memory.
Module Contents
- class quota_notifier.settings.FileSystemSchema(_case_sensitive: bool | None = None, _nested_model_default_partial_update: bool | None = None, _env_prefix: str | None = None, _env_file: DotenvType | None = PosixPath('.'), _env_file_encoding: str | None = None, _env_ignore_empty: bool | None = None, _env_nested_delimiter: str | None = None, _env_parse_none_str: str | None = None, _env_parse_enums: bool | None = None, _cli_prog_name: str | None = None, _cli_parse_args: bool | list[str] | tuple[str, ...] | None = None, _cli_settings_source: CliSettingsSource[Any] | None = None, _cli_parse_none_str: str | None = None, _cli_hide_none_type: bool | None = None, _cli_avoid_json: bool | None = None, _cli_enforce_required: bool | None = None, _cli_use_class_docs_for_groups: bool | None = None, _cli_exit_on_error: bool | None = None, _cli_prefix: str | None = None, _cli_flag_prefix_char: str | None = None, _cli_implicit_flags: bool | None = None, _cli_ignore_unknown_args: bool | None = None, _cli_kebab_case: bool | None = None, _secrets_dir: PathType | None = None, *, name: str, path: Path, type: Literal['ihome', 'generic', 'beegfs'], thresholds: List[int])[source]
Defines the schema settings related to an individual file system
- name: str
- path: Path
- type: Literal['ihome', 'generic', 'beegfs']
- thresholds: List[int]
- classmethod validate_name(value: str) str [source]
Ensure the given name is not blank
- Parameters:
value – The name value to validate
- Returns:
The validated file system name
- classmethod validate_path(value: Path) Path [source]
Ensure the given system path exists
- Parameters:
value – The path value to validate
- Returns:
The validated path object
- Raises:
ValueError – If the path does not exist
- classmethod validate_thresholds(value: list) list [source]
Validate threshold values are between 0 and 100 (exclusive)
- Parameters:
value – List of threshold values to validate
- Returns:
The validated threshold values
- model_config: ClassVar[SettingsConfigDict] = {'arbitrary_types_allowed': True, 'case_sensitive': False, 'cli_avoid_json': False, 'cli_enforce_required': False, 'cli_exit_on_error': True, 'cli_flag_prefix_char': '-', 'cli_hide_none_type': False, 'cli_ignore_unknown_args': False, 'cli_implicit_flags': False, 'cli_kebab_case': False, 'cli_parse_args': None, 'cli_parse_none_str': None, 'cli_prefix': '', 'cli_prog_name': None, 'cli_use_class_docs_for_groups': False, 'enable_decoding': True, 'env_file': None, 'env_file_encoding': None, 'env_ignore_empty': False, 'env_nested_delimiter': None, 'env_parse_enums': None, 'env_parse_none_str': None, 'env_prefix': '', 'extra': 'forbid', 'json_file': None, 'json_file_encoding': None, 'nested_model_default_partial_update': False, 'protected_namespaces': ('model_validate', 'model_dump', 'settings_customise_sources'), 'secrets_dir': None, 'toml_file': None, 'validate_default': True, 'yaml_file': None, 'yaml_file_encoding': None}
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- class quota_notifier.settings.SettingsSchema(_case_sensitive: bool | None = None, _nested_model_default_partial_update: bool | None = None, _env_prefix: str | None = None, _env_file: DotenvType | None = PosixPath('.'), _env_file_encoding: str | None = None, _env_ignore_empty: bool | None = None, _env_nested_delimiter: str | None = None, _env_parse_none_str: str | None = None, _env_parse_enums: bool | None = None, _cli_prog_name: str | None = None, _cli_parse_args: bool | list[str] | tuple[str, ...] | None = None, _cli_settings_source: CliSettingsSource[Any] | None = None, _cli_parse_none_str: str | None = None, _cli_hide_none_type: bool | None = None, _cli_avoid_json: bool | None = None, _cli_enforce_required: bool | None = None, _cli_use_class_docs_for_groups: bool | None = None, _cli_exit_on_error: bool | None = None, _cli_prefix: str | None = None, _cli_flag_prefix_char: str | None = None, _cli_implicit_flags: bool | None = None, _cli_ignore_unknown_args: bool | None = None, _cli_kebab_case: bool | None = None, _secrets_dir: PathType | None = None, *, ihome_quota_path: ~pathlib.Path = PosixPath('/ihome/crc/scripts/ihome_quota.json'), file_systems: ~typing.List[~quota_notifier.settings.FileSystemSchema] = [], uid_blacklist: ~typing.Set[int | ~typing.Tuple[int, int]] = [0], gid_blacklist: ~typing.Set[int | ~typing.Tuple[int, int]] = [0], disk_timeout: int = 30, log_level: ~typing.Literal['DEBUG', 'INFO', 'WARNING', 'ERROR'] = 'INFO', log_path: ~pathlib.Path | None = <factory>, smtp_host: str = '', smtp_port: int = 0, db_url: str = 'sqlite:////home/runner/work/quota_notifier/quota_notifier/docs/notifier_data.db', email_from: str = 'no-reply@domain.com', email_subject: str = 'CRC Disk Usage Alert', email_domain: str = '@domain.com', admin_emails: ~typing.List[str] = [], debug: bool = False)[source]
Defines the schema and default values for top level application settings
- ihome_quota_path: Path
- file_systems: List[FileSystemSchema]
- uid_blacklist: Set[int | Tuple[int, int]]
- gid_blacklist: Set[int | Tuple[int, int]]
- disk_timeout: int
- log_level: Literal['DEBUG', 'INFO', 'WARNING', 'ERROR']
- log_path: Path | None
- smtp_host: str
- smtp_port: int
- db_url: str
- email_from: str
- email_subject: str
- email_domain: str
- admin_emails: List[str]
- debug: bool
- classmethod validate_unique_file_systems(value: List[FileSystemSchema]) List[FileSystemSchema] [source]
Ensure file systems have unique names/paths
- Parameters:
value – The file systems to validate
- Returns:
The validated file systems
- Raises:
ValueError – If the file system names and paths are not unique
- model_config: ClassVar[SettingsConfigDict] = {'arbitrary_types_allowed': True, 'case_sensitive': False, 'cli_avoid_json': False, 'cli_enforce_required': False, 'cli_exit_on_error': True, 'cli_flag_prefix_char': '-', 'cli_hide_none_type': False, 'cli_ignore_unknown_args': False, 'cli_implicit_flags': False, 'cli_kebab_case': False, 'cli_parse_args': None, 'cli_parse_none_str': None, 'cli_prefix': '', 'cli_prog_name': None, 'cli_use_class_docs_for_groups': False, 'enable_decoding': True, 'env_file': None, 'env_file_encoding': None, 'env_ignore_empty': False, 'env_nested_delimiter': None, 'env_parse_enums': None, 'env_parse_none_str': None, 'env_prefix': '', 'extra': 'forbid', 'json_file': None, 'json_file_encoding': None, 'nested_model_default_partial_update': False, 'protected_namespaces': ('model_validate', 'model_dump', 'settings_customise_sources'), 'secrets_dir': None, 'toml_file': None, 'validate_default': True, 'yaml_file': None, 'yaml_file_encoding': None}
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- class quota_notifier.settings.ApplicationSettings[source]
Configurable application settings object
Use the
configure
method to override individual default settings. Use theconfigure_from_file
method to load settings from a settings file.- classmethod set_from_file(path: Path) None [source]
Reset application settings to default values
Values defined in the given file path are used to override defaults.
- Parameters:
path – Path to load settings from