Core Data Models
Relevant source files
The following files were used as context for generating this wiki page:
The Core Data Models in flext-target-ldap provide a unified framework for representing, validating, and processing LDAP directory entries within a Singer-compatible ETL pipeline. These models bridge the gap between flat Singer source records and the hierarchical, attribute-heavy structure of LDAP directories.
The architecture follows the FLEXT ecosystem standards, utilizing nested domain classes for composition and rigorous validation. This ensures that data transformed for LDAP loading adheres to both structural requirements (like Distinguished Names) and business rules (like required object classes for specific entry types).
Sources: src/flext_target_ldap/models.py:15-28, src/flext_target_ldap/api.py:31-40
Unified LDAP Domain Models
The primary entry point for domain modeling is FlextTargetLdapModels, which consolidates LDAP target domain entities. It uses a nested class structure to organize different aspects of the LDAP ecosystem, such as entries, attribute mappings, and transformation rules.
TargetLdap Entry Model
The Entry model represents a complete LDAP object. It includes logic for calculating parent Distinguished Names (DNs) and Relative Distinguished Names (RDNs), as well as validating mandatory attributes based on object classes (e.g., sn and cn for person entries).
The diagram above illustrates the composition of the unified LDAP models.
Sources: src/flext_target_ldap/models.py:100-210
| Field | Type | Description |
|---|---|---|
distinguished_name | NonEmptyStr | The full LDAP DN (e.g., uid=jdoe,dc=example,dc=com). |
object_classes | MutableSequence[str] | List of LDAP object classes; defaults to including top. |
attributes | Mapping | Key-value pairs of LDAP attributes and their values. |
entry_type | str | Categorization (user, group, ou, etc.). |
Sources: src/flext_target_ldap/models.py:105-135
Sink Models and Stream Specialization
The project implements specialized "Sinks" that inherit from FlextTargetLdapBaseSink. These sinks encapsulate the logic for translating specific Singer streams into LDAP operations.
Sink Hierarchy
The sink hierarchy shows how specific entry types inherit common LDAP processing logic.
Sources: src/flext_target_ldap/_models/sinks.py:23-533, src/flext_target_ldap/api.py:65-85
Data Flow: Record to LDAP Entry
When a record is processed, the sink performs a series of transformations defined by the models:
- DN Construction: The sink builds the Distinguished Name using settings like
base_dnanduser_rdn_attribute. - Attribute Mapping: Singer fields are mapped to LDAP attributes using the
AttributeMappingrules. - Object Class Assignment: Standard classes (like
inetOrgPersonfor users) are merged with configured custom classes. - Persistence: The model determines whether to
adda new entry ormodifyan existing one based on theupdate_existing_entriesconfiguration.
Sources: src/flext_target_ldap/_models/sinks.py:326-440, src/flext_target_ldap/api.py:133-165
Configuration and Settings Models
The FlextTargetLdapSettings model handles the validation and normalization of target configurations. It includes a unique normalization step that flattens standard Singer JSON configuration into a structured connection object and operation parameters.
Key Configuration Options
| Option | Type | Default | Description |
|---|---|---|---|
base_dn | str | Required | The root DN for all operations. |
create_missing_entries | bool | True | Whether to attempt an LDAP ADD if entry is missing. |
update_existing_entries | bool | False | Whether to attempt an LDAP MODIFY if entry exists. |
attribute_mapping | dict | {} | Map of Singer fields to LDAP attributes. |
object_classes | list | ['top'] | Default object classes for new entries. |
Sources: src/flext_target_ldap/settings.py:101-163
Processing Result Models
To track performance and errors across batches, the FlextTargetLdapProcessingResult model maintains mutable counters.
The diagram shows how the processing result tracks outcomes of LDAP operations.
Sources: src/flext_target_ldap/_models/sinks.py:67-75, src/flext_target_ldap/_models/sinks.py:270-324
Summary
The core data models in flext-target-ldap ensure that data integrity is maintained between ephemeral Singer streams and persistent LDAP directories. By centralizing validation in the Entry and AttributeMapping models and specializing processing logic in typed sinks (Users, Groups, OUs), the system provides a robust, extensible framework for directory synchronization.
Sources: src/flext_target_ldap/models.py:22-35, src/flext_target_ldap/api.py:31-45