Constants & Enums
Relevant source files
The following files were used as context for generating this wiki page:
The flext-target-ldap project utilizes a centralized constants management system to maintain consistency across the LDAP synchronization domain. These constants govern environment configuration, default connection parameters, and the structural requirements of LDAP entries. The architecture relies on a base constants class that is exposed via lazy loading to ensure optimal performance while providing a single source of truth for the target's behavior.
Sources: src/flext_target_ldap/_constants/base.py, src/flext_target_ldap/_constants/init.py
Core Domain Constants
The primary constants for the target LDAP domain are defined in the FlextTargetLdapConstantsBase class. This class establishes the foundation for environment variable prefixes, default operational flags, and canonical connection defaults.
Environment and Operations
The system uses a specific environment prefix for configuration and defines the default behavior for entry lifecycle management (creation, updates, and deletions).
| Constant | Value | Description |
|---|---|---|
ENV_PREFIX | "FLEXT_TARGET_LDAP_" | Prefix used for environment-based configuration. |
CREATE_MISSING_ENTRIES | True | Default flag to create entries not found in the target. |
UPDATE_EXISTING_ENTRIES | True | Default flag to update entries that already exist. |
DELETE_REMOVED_ENTRIES | False | Default flag for handling entries removed from source. |
Sources: src/flext_target_ldap/_constants/base.py:17-24
Connection and Structural Defaults
These constants define the default state for LDAP server interactions when explicit configuration is missing.
| Constant | Value | Description |
|---|---|---|
DEFAULT_HOST | "localhost" | Default LDAP server hostname. |
DEFAULT_BIND_DN | "" | Default Distinguished Name for binding. |
DEFAULT_OBJECT_CLASS | "top" | The base object class for all entries. |
DEFAULT_BASE_DN | "dc=example,dc=com" | Default search and operation base. |
Sources: src/flext_target_ldap/_constants/base.py:27-32, src/flext_target_ldap/_constants/base.py:53
Configuration and Token Keys
The project maintains a standardized set of string tokens used as keys across utilities, settings, and sinks. This prevents "magic strings" and ensures that configuration mappings remain consistent throughout the data flow.
The diagram shows how constant keys are distributed between connection settings and entry processing logic.
Sources: src/flext_target_ldap/_constants/base.py:37-51
Model Validation Constants and Rules
Validation logic within the project models often relies on hardcoded business rules that act as implicit enums for transformation and entry types.
Transformation Rule Constants
The AttributeMapping model validates transformation rules against a specific set of allowed strings. These act as the functional enum for data normalization during the sync process.
lowercaseuppercasetrimnormalize
Sources: src/flext_target_ldap/models.py:82-87
Entry Type Constants
LDAP entries are categorized by type, with "generic" serving as the default. Specific logic exists for structural types defined in the Entry model:
usergroupougeneric(Default)
Sources: src/flext_target_ldap/models.py:133-138
Test Constants Namespace
For testing environments, the project extends the base constants to include test-specific values. The TestsFlextTargetLdapConstants class combines production constants with testing utilities.
The class diagram illustrates the inheritance pattern used to merge production and testing constant namespaces.
Sources: tests/constants.py:17-30
Internal Operation Enums
While not explicitly defined as Python Enum classes, several internal operations rely on fixed constant values from the ldap3 library or inherited from flext-ldap. For example, modification operations are strictly governed by:
REPLACE: Used during entry modification to overwrite existing attributes.
Sources: src/flext_target_ldap/_utilities/client.py:68, src/flext_target_ldap/settings.py:110-120
Conclusion
Constants and Enums in flext-target-ldap provide a rigid framework for LDAP operations. By centralizing host defaults, environment prefixes, and allowed transformation rules in src/flext_target_ldap/_constants/base.py and src/flext_target_ldap/models.py, the project ensures that both the configuration layer and the data processing sinks operate on a unified set of definitions.