Metadata-Version: 2.1
Name: edpconfigprovider
Version: 0.1.0
Summary: Configuration provider library that abstracts fetching configuration from multiple backends
Author-email: Max Guenes <max.santos@e-deploy.com.br>
Requires-Python: <4,>=3.8
Description-Content-Type: text/markdown
Requires-Dist: edphelper==1.2.0
Provides-Extra: aws
Requires-Dist: boto3>=1.35.0; extra == "aws"

# EdpConfigProvider

A configuration provider library that abstracts fetching configuration from multiple backends (local JSON files, AWS AppConfig, AWS SSM Parameter Store) behind a unified interface.

## Installation

```bash
poetry install
```

For AWS support (AppConfig, SSM Parameter Store):

```bash
pip install edpconfigprovider[aws]
```

## Configuration Provider Type

The application uses the `CONFIG_PROVIDER_TYPE` environment variable to determine how configuration is loaded. Supported values are:

### JSON (local configuration)

- **json**: Loads configuration from a static JSON folder located beside the project folder. Use this for local development or static configuration scenarios.
    - **CONFIG_PATH**: path to `config.json`
    - **CONTEXT_CONFIG_DIRECTORY**: path to directory with context json files. Ex: `context/localhost.json`

### AWS AppConfig

- **aws_appconfig**: Loads configuration dynamically from AWS AppConfig. Recommended for production or dynamic configuration needs.
- **aws_appconfig_agent**: Uses AWS AppConfig as a Lambda agent for configuration management, enabling advanced AppConfig features and integration.
    - General Configuration
        - **AWS_APPCONFIG_APPLICATION_NAME**: AWS AppConfig Application Name
        - **AWS_APPCONFIG_PROFILE_NAME**: AWS AppConfig Profile Name
        - **AWS_APPCONFIG_ENVIRONMENT_NAME**: AWS AppConfig Environment Name
    - Contexts configuration
        - **AWS_APPCONFIG_CONTEXT_APPLICATION_NAME_FORMAT**: AWS AppConfig Application Name for a context_name. Ex: `sample-app-context-{}`, where the `{}` will be replaced for the `context_name` variable
        - **AWS_APPCONFIG_CONTEXT_PROFILE_NAME**: AWS AppConfig Profile Name for context configuration
        - **AWS_APPCONFIG_CONTEXT_ENVIRONMENT_NAME**: AWS AppConfig Environment Name for context configuration

### AWS SSM Parameter Store

- **aws_ssm**: Loads configuration from AWS SSM Parameter Store by path. All parameters under the given path are fetched recursively and returned as a nested dictionary (path segments become nested keys). SecureString values are decrypted automatically. `StringList` values are split by comma, and values that are valid JSON are parsed into their corresponding Python types.
    - **AWS_SSM_PARAMETER_PATH**: The SSM parameter path prefix to fetch (e.g., `/myapp/config/`)
    - **AWS_SSM_RECURSIVE**: Whether to fetch parameters recursively under the path (default: `true`)
    - **AWS_SSM_SPLIT_PATH**: Whether to split parameter path segments into nested dictionary keys (default: `true`). When `false`, parameters are returned as a flat dictionary keyed by their path relative to `AWS_SSM_PARAMETER_PATH`.
    - **AWS_SSM_DECRYPT**: Whether to decrypt SecureString parameters (default: `true`)

Set the `CONFIG_PROVIDER_TYPE` variable in your environment or `.env` file to control the configuration source.

## Scripts

Setup Claude Code skills (symlinks `.claude/skills/*` into `~/.claude/skills/`):

```bash
poetry run task setup-skills
```

## Usage

### Simple configuration

```python
from edpconfigprovider.builder import ConfigProviderBuilder

builder = ConfigProviderBuilder(transform_method=lambda data: MyConfig(**data))
config = builder.build_config()
```

### Context-based (multi-tenant) configuration

```python
from edpconfigprovider.builder import ContextConfigProviderBuilder

builder = ContextConfigProviderBuilder(transform_method=lambda name, data: MyContextConfig(**data))
config = builder.build_config(context_name="my-context")
```

### Custom providers

```python
from edpconfigprovider.builder._builder_registry import set_provider

set_provider("my_custom_type", my_provider_factory)
```
