Metadata-Version: 2.3
Name: nextpertise-envy-settings
Version: 0.1.0
Summary: Reusable Pydantic BaseSettings loader for Keycloak-secured Envy environments
License: MIT
Author: Len van Essen
Author-email: len@wndr.digital
Requires-Python: >=3.9,<4.0
Classifier: License :: OSI Approved :: MIT License
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Requires-Dist: pydantic (>=1.10,<2.0)
Requires-Dist: requests (>=2.31,<3.0)
Description-Content-Type: text/markdown

# nextpertise-envy-settings

A reusable Pydantic `BaseSettings` subclass that fetches environment variables from an Envy API using a Keycloak-secured token. It automatically writes these variables to a `.env.envy` file and prepends it to your environment configuration.

---

## ✨ Features

- ✅ Compatible with **Pydantic v1**
- 🔐 Uses **OAuth2 client credentials** flow via Keycloak
- 📄 Automatically fetches and stores `.env.envy`
- 🧠 Prepend `.env.envy` to Pydantic's `env_file` list
- 🛡 Graceful fallback to existing file if API fails

---

## 📦 Installation

```bash
poetry add envy-settings

Or with pip:

pip install envy-settings


⸻

🚀 Usage

from envy_settings import EnvySettings

class Settings(EnvySettings):
    mysql_user: str

    class Config(EnvySettings.Config):
        envy_url = "https://myenvy.com"
        envy_keycloak_url = "https://mykeycloak.com/realms/realm"
        envy_keycloak_client_id = "your-clientid"
        envy_keycloak_token = "your-client-secret"
        envy_environment = "your-environment"
        env_file = (".env",)


⸻

🔧 Environment Variables (optional)

Instead of hardcoding the config, you can also use these environment variables:

Variable	Description
ENV_API_BASE_URL	Base URL for Envy API
ENV_API_KEYCLOAK_URL	Keycloak realm URL
ENV_API_KEYCLOAK_CLIENT_ID	OAuth2 client ID
ENV_API_KEYCLOAK_TOKEN	OAuth2 client secret
ENV_API_ENVIRONMENT	Target environment name


⸻

📁 Example .env.envy

MYSQL_USER=abc
MYSQL_PASSWORD=xyz
REDIS_HOST=localhost

