Metadata-Version: 2.4
Name: openimis-be-api_etl
Version: 1.2.0
Summary: The openIMIS Backend api_etl reference module.
Home-page: https://openimis.org/
Author: Kamil Malinowski
Author-email: kmalinowski@soldevelo.com
License: GNU AGPL v3
Classifier: Environment :: Web Environment
Classifier: Framework :: Django
Classifier: Framework :: Django :: 4.2
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: GNU Affero General Public License v3
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python
Classifier: Programming Language :: Python :: 3.10
Description-Content-Type: text/markdown
License-File: LICENSE.md
Requires-Dist: django
Requires-Dist: django-db-signals
Requires-Dist: djangorestframework
Requires-Dist: openimis-be-core
Requires-Dist: openimis-be-individual
Requires-Dist: requests
Dynamic: author
Dynamic: author-email
Dynamic: classifier
Dynamic: description
Dynamic: description-content-type
Dynamic: home-page
Dynamic: license
Dynamic: license-file
Dynamic: requires-dist
Dynamic: summary

# openIMIS Backend api_etl reference module

# API ETL Configuration and Adapter Extension Guide

## Default Configuration Example

The following is a sample configuration (`DEFAULT_CONFIG`) that enables connection to an example API. This configuration is used to control authentication, data source connection, and field mappings for an adapter:

```python
DEFAULT_CONFIG = {
    "auth_type": "basic",  # Options: noauth, basic, bearer
    "auth_basic_username": "<USERNAME>",  # Basic auth username
    "auth_basic_password": "<PASSWORD>",  # Basic auth password
    "auth_bearer_token": "",  # Bearer token for 'bearer' auth_type

    "source_http_method": "post",  # HTTP method for requests.request
    "source_url": "http://41.175.18.170:8070/api/mobile/v1/beneficiary/active/search",
    "source_headers": {
        "Content-Type": "application/x-www-form-urlencodedc",
        "Accept": "application/json"
    },
    "source_batch_size": 50,  # Number of records to fetch in one batch

    "adapter_first_name_field": "firstName",
    "adapter_last_name_field": "lastName",
    "adapter_dob_field": "dateOfBirth",

    "skip_integration_test": False  # Must be False for production deployments
}
```

## Creating a New Adapter

To implement a new adapter, you must:

1. **Extend the base Adapter class** provided by the project.

   * Base Adapter class source: [`base.py`](https://github.com/openimis/openimis-be-api_etl_py/blob/release/24.10/api_etl/adapters/base.py)

2. **Create a new class** that inherits from this base class.

   * Reference implementation: [`exampleIndividialAdapter.py`](https://github.com/openimis/openimis-be-api_etl_py/blob/release/24.10/api_etl/adapters/exampleIndividialAdapter.py)

3. **Implement the required methods and logic** in your subclass based on the data structure and behavior needed.

4. **Register the adapter** in the appropriate place if required for discovery or configuration.

### Example

```python
from api_etl.adapters.base import BaseAdapter

class MyCustomAdapter(BaseAdapter):
    def transform(self, record):
        # Implement transformation logic here
        pass
```

This modular architecture allows easy customization and extension to support different data sources and APIs.
