Python API Reference
Relevant source files
The following files were used as context for generating this wiki page:
The flext-dbt-ldif Python API provides a structured interface for transforming LDAP Data Interchange Format (LDIF) data into dbt-compatible models and orchestrating data transformation workflows. It abstracts complex LDIF parsing, validation, and model generation logic into high-level methods used for enterprise data engineering.
Sources: README.md, src/flext_dbt_ldif/__init__.py:46-77, tests/unit/test_services_and_api.py:22-26
API Architecture
The project utilizes a facade-based architecture where the FlextDbtLdif class serves as the primary entry point. This class delegates operations to specialized internal services, including clients for data interaction and core components for model generation and analytics.
Dependency and Lazy Loading
The API employs a lazy-loading mechanism to optimize import times. Public interfaces are defined in an export map and installed into the package namespace at runtime.
The diagram shows the package initialization flow and the delegation from the main API facade to the underlying service and client layers.
Sources: src/flext_dbt_ldif/__init__.py:13-77, src/flext_dbt_ldif/_exports_lazy_part_01.py:10-44
Core API Reference: FlextDbtLdif
The FlextDbtLdif class provides the high-level methods for handling LDIF files. It inherits from or delegates to FlextDbtLdifServiceMixin.Service to perform its operations.
Key Methods
| Method | Parameters | Return Type | Description |
|---|---|---|---|
process_ldif_file | ldif_file, generate_models, run_transformations | Result[WorkflowResult] | Runs a complete end-to-end workflow from parsing to dbt transformation. |
validate_ldif_quality | ldif_file | Result[ParseValidationResult] | Assesses the quality and schema compliance of an LDIF file. |
generate_ldif_models | entries, overwrite | Result[ModelGenerationResult] | Generates dbt staging and analytics models based on LDIF entry patterns. |
Sources: tests/unit/test_services_and_api.py:28-106, tests/unit/test_services.py:126-174
Workflow Execution Flow
When process_ldif_file is invoked, the API orchestrates several stages including parsing, validation, model generation (optional), and dbt transformation execution.
The sequence diagram illustrates the internal delegation and data flow when executing a full LDIF processing workflow.
Sources: tests/unit/test_services_and_api.py:35-59, tests/unit/test_services.py:126-174
Service and Client Layers
The API surface is supported by underlying service mixins and client implementations that handle the technical details of data processing.
FlextDbtLdifServiceMixin
This mixin provides the implementation for orchestrating high-level tasks.
- Model Generation: Uses
ModelGeneratorto createstg_ldif_entries(staging) andanalytics_ldif_insights(analytics) models. - Data Quality: Executes the
run_data_quality_assessmentlogic to generate quality scores.
Sources: tests/unit/test_services.py:24-124, tests/unit/test_core.py:23-45
FlextDbtLdifCore.Core
Core components handle the logic for analyzing data patterns and defining model structures.
- Analytics: Analyzes entry patterns, identifying total entries and unique Distinguished Names (DNs).
- ModelGenerator: Defines the default naming conventions and structures for generated dbt SQL files.
Sources: tests/unit/test_core.py:47-81
Configuration and Settings
The API is configured via FlextDbtLdifSettings, which can be fetched globally.
| Option | Type | Description |
|---|---|---|
project_dir | Path | The directory where dbt models and LDIF files are managed. |
generate_models | bool | Whether to automatically generate dbt models during processing. |
run_transformations | bool | Whether to trigger dbt transformation runs after model generation. |
Sources: tests/unit/test_api_surface.py:32-34, tests/unit/test_core.py:23-32
Data Structures
The API utilizes Pydantic-based models for structured data exchange.
| Structure | Fields | Description |
|---|---|---|
WorkflowResult | ldif_file, entry_count, validation_status, workflow_status | Summary of an end-to-end processing run. |
ParseValidationResult | entry_count, quality_score, validation_status | Metrics from the LDIF parsing and quality assessment phase. |
DbtModel | name, dbt_model_type, ldif_source, sql_content | Representation of a dbt model to be written to disk. |
Sources: tests/unit/test_services_and_api.py:40-45, tests/unit/test_services.py:73-89
Conclusion
The flext-dbt-ldif Python API provides a unified, service-oriented interface for LDIF data transformation. By leveraging a facade pattern and internal service orchestration, it allows developers to process LDAP data into dbt environments with minimal boilerplate while maintaining strict validation and quality standards.