Skip to main content

Simple Python client for Config Lake - fetch and decrypt configurations and secrets

Project description

Config Lake - Python Client

Simple Python client library for Config Lake - fetch and decrypt configurations and secrets from your centralized config management server.

Features

  • 🔐 Secure: End-to-end encryption for secrets
  • 🚀 Simple: Easy-to-use API with minimal setup
  • Fast: Lightweight with minimal dependencies
  • 🛡️ Safe: Input validation and error handling

Installation

pip install configlake

Quick Start

import configlake

# Configuration
API_URL = "http://localhost:5000"
API_TOKEN = "your-api-token"
PROJECT_ID = 1
ENVIRONMENT = "production"

# Get plain-text configurations
configs = configlake.get_config(API_URL, API_TOKEN, PROJECT_ID, ENVIRONMENT)
print("Database URL:", configs.get("DATABASE_URL"))

# Get decrypted secrets
secrets = configlake.get_secrets(API_URL, API_TOKEN, PROJECT_ID, ENVIRONMENT)
print("API Key:", secrets.get("SECRET_API_KEY"))

# Get both configs and secrets together
all_data = configlake.get_all_details(API_URL, API_TOKEN, PROJECT_ID, ENVIRONMENT)
print("Configs:", all_data["configs"])
print("Secrets:", all_data["secrets"])

API Reference

get_config(base_url, token, project_id, environment)

Fetches plain-text configuration values for a specific project and environment.

Parameters:

  • base_url (str): Base URL of your Config Lake server
  • token (str): Your API authentication token
  • project_id (int): ID of the project
  • environment (str): Name of the environment (e.g., "dev", "staging", "production")

Returns: Dictionary of configuration key-value pairs

get_secrets(base_url, token, project_id, environment)

Fetches and decrypts secret values for a specific project and environment.

Parameters:

  • base_url (str): Base URL of your Config Lake server
  • token (str): Your API authentication token
  • project_id (int): ID of the project
  • environment (str): Name of the environment

Returns: Dictionary of decrypted secret key-value pairs

get_all_details(base_url, token, project_id, environment)

Fetches both configurations and secrets in a single request.

Parameters:

  • base_url (str): Base URL of your Config Lake server
  • token (str): Your API authentication token
  • project_id (int): ID of the project
  • environment (str): Name of the environment

Returns: Dictionary containing:

  • configs: Dictionary of configuration values
  • secrets: Dictionary of decrypted secret values
  • project_id: The project ID
  • environment: The environment name

Backwards Compatibility

The library also supports the original function names:

# These work the same as the new function names
configs = configlake.getConfig(API_URL, API_TOKEN, PROJECT_ID, ENVIRONMENT)
secrets = configlake.getSecrets(API_URL, API_TOKEN, PROJECT_ID, ENVIRONMENT)
all_data = configlake.getAllDetails(API_URL, API_TOKEN, PROJECT_ID, ENVIRONMENT)

Error Handling

The library raises ConfigLakeError for various error conditions:

try:
    configs = configlake.get_config(API_URL, API_TOKEN, PROJECT_ID, ENVIRONMENT)
except configlake.ConfigLakeError as e:
    print(f"Error fetching config: {e}")

Environment Variables

You can store your configuration in environment variables:

import os
import configlake

API_URL = os.getenv("CONFIGLAKE_URL", "http://localhost:5000")
API_TOKEN = os.getenv("CONFIGLAKE_TOKEN")
PROJECT_ID = int(os.getenv("CONFIGLAKE_PROJECT_ID", "1"))
ENVIRONMENT = os.getenv("CONFIGLAKE_ENVIRONMENT", "development")

configs = configlake.get_config(API_URL, API_TOKEN, PROJECT_ID, ENVIRONMENT)

Requirements

  • Python 3.7+
  • requests
  • cryptography

License

MIT License - see LICENSE file for details.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

configlake-1.1.0.tar.gz (4.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

configlake-1.1.0-py3-none-any.whl (4.3 kB view details)

Uploaded Python 3

File details

Details for the file configlake-1.1.0.tar.gz.

File metadata

  • Download URL: configlake-1.1.0.tar.gz
  • Upload date:
  • Size: 4.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.3

File hashes

Hashes for configlake-1.1.0.tar.gz
Algorithm Hash digest
SHA256 e39dea038a71fe82f1483aab3803e59568ae3d9f5b35ef46473a7eb92a323dd2
MD5 5f89b88af96ae76c6ac8ed8a8512cfc1
BLAKE2b-256 fd7e7437bb8495f559733d5131c808e35370d69adaef74300bff3df7f5183d06

See more details on using hashes here.

File details

Details for the file configlake-1.1.0-py3-none-any.whl.

File metadata

  • Download URL: configlake-1.1.0-py3-none-any.whl
  • Upload date:
  • Size: 4.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.3

File hashes

Hashes for configlake-1.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 968b179ab1dc73a9582502336bbf36ac5a8ca7576b66f3e56005fb1f6e1a8090
MD5 39a55d4df1e53ecf332ff80da7440fb4
BLAKE2b-256 570f591b37fdbefa87a636a2dbb3486617277ff5a1a95471286df9abebe280ac

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page