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_implicit_flags: 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_computed_fields: ClassVar[Dict[str, ComputedFieldInfo]] = {}
A dictionary of computed field names and their corresponding ComputedFieldInfo objects.
- 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_hide_none_type': False, 'cli_implicit_flags': False, 'cli_parse_args': None, 'cli_parse_none_str': None, 'cli_prefix': '', 'cli_prog_name': None, 'cli_settings_source': None, 'cli_use_class_docs_for_groups': False, '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_', 'settings_'), '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].
- model_fields: ClassVar[Dict[str, FieldInfo]] = {'name': FieldInfo(annotation=str, required=True, title='System Name', description='Human readable name for the file system'), 'path': FieldInfo(annotation=Path, required=True, title='System Path', description='Absolute path to the mounted file system'), 'thresholds': FieldInfo(annotation=List[int], required=True, title='Notification Thresholds', description='Usage percentages to issue notifications for.'), 'type': FieldInfo(annotation=Literal['ihome', 'generic', 'beegfs'], required=True, title='System Type', description='Type of the file system')}
Metadata about the fields defined on the model, mapping of field names to [FieldInfo][pydantic.fields.FieldInfo] objects.
This replaces Model.__fields__ from Pydantic V1.
- 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_implicit_flags: bool | None = None, _secrets_dir: PathType | None = None, *, ihome_quota_path: Path = PosixPath('/ihome/crc/scripts/ihome_quota.json'), file_systems: List[FileSystemSchema] = [], uid_blacklist: Set[int | Tuple[int, int]] = [0], gid_blacklist: Set[int | Tuple[int, int]] = [0], disk_timeout: int = 30, log_level: Literal['DEBUG', 'INFO', 'WARNING', 'ERROR'] = 'INFO', log_path: Path | None = None, 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: 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_computed_fields: ClassVar[Dict[str, ComputedFieldInfo]] = {}
A dictionary of computed field names and their corresponding ComputedFieldInfo objects.
- 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_hide_none_type': False, 'cli_implicit_flags': False, 'cli_parse_args': None, 'cli_parse_none_str': None, 'cli_prefix': '', 'cli_prog_name': None, 'cli_settings_source': None, 'cli_use_class_docs_for_groups': False, '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_', 'settings_'), '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].
- model_fields: ClassVar[Dict[str, FieldInfo]] = {'admin_emails': FieldInfo(annotation=List[str], required=False, default=[], title='Administrator Emails', description='Admin users to contact when the application encounters a critical issue.'), 'db_url': FieldInfo(annotation=str, required=False, default='sqlite:////home/runner/work/quota_notifier/quota_notifier/docs/notifier_data.db', title='Database Path', description='URL for the application database. By default, a SQLITE database is created in the working directory.'), 'debug': FieldInfo(annotation=bool, required=False, default=False, title='Debug Mode', description='Disable database commits and email notifications. Useful for development and testing.'), 'disk_timeout': FieldInfo(annotation=int, required=False, default=30, title='File System Timeout', description='Give up on checking a file system after the given number of seconds.'), 'email_domain': FieldInfo(annotation=str, required=False, default='@domain.com', title='User Email Address Domain', description='String to append to usernames when generating user email addresses. The leading `@` is optional.'), 'email_from': FieldInfo(annotation=str, required=False, default='no-reply@domain.com', title='Email From Address', description='From address for automatically generated emails.'), 'email_subject': FieldInfo(annotation=str, required=False, default='CRC Disk Usage Alert', title='Email Subject Line', description='Subject line for automatically generated emails.'), 'file_systems': FieldInfo(annotation=List[FileSystemSchema], required=False, default=[], title='Monitored File Systems', description='List of additional settings that define which file systems to examine.'), 'gid_blacklist': FieldInfo(annotation=Set[Union[int, Tuple[int, int]]], required=False, default=[0], title='Blacklisted Group IDs', description='Do not notify groups with these ID values.'), 'ihome_quota_path': FieldInfo(annotation=Path, required=False, default=PosixPath('/ihome/crc/scripts/ihome_quota.json'), title='Ihome Quota Path', description='Path to ihome storage information.'), 'log_level': FieldInfo(annotation=Literal['DEBUG', 'INFO', 'WARNING', 'ERROR'], required=False, default='INFO', title='Logging Level', description='Application logging level.'), 'log_path': FieldInfo(annotation=Union[Path, NoneType], required=False, default_factory=<lambda>, title='Log Path', description='Optionally log application events to a file.'), 'smtp_host': FieldInfo(annotation=str, required=False, default='', title='SMTP Server Host Name', description='Name of the SMTP host server'), 'smtp_port': FieldInfo(annotation=int, required=False, default=0, title='SMTP Port Number', description='Port for the SMTP server'), 'uid_blacklist': FieldInfo(annotation=Set[Union[int, Tuple[int, int]]], required=False, default=[0], title='Blacklisted User IDs', description='Do not notify users with these ID values.')}
Metadata about the fields defined on the model, mapping of field names to [FieldInfo][pydantic.fields.FieldInfo] objects.
This replaces Model.__fields__ from Pydantic V1.
- 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