Skip to main content

Python client library for OpenSecureConf encrypted configuration management API

Project description

OpenSecureConf Python Client

A Python client library for interacting with the OpenSecureConf API, which provides encrypted configuration management with multithreading support.

Features

  • 🔐 Encrypted Configuration Management: Securely store and retrieve encrypted configurations
  • 🚀 Simple API: Intuitive interface for CRUD operations
  • 🛡️ Type-Safe: Fully typed with comprehensive error handling
  • Async Support: Works with OpenSecureConf's asynchronous API
  • 🔄 Context Manager: Automatic resource cleanup
  • 📦 Lightweight: Minimal dependencies (only requests)

Installation

pip install opensecureconf-client

Quick Start

from opensecureconf_client import OpenSecureConfClient

# Initialize the client
client = OpenSecureConfClient(
    base_url="http://localhost:9000",
    user_key="my-secure-key-min-8-chars"
)

# Create a configuration
config = client.create(
    key="database",
    value={"host": "localhost", "port": 5432, "username": "admin"},
    category="production"
)

# Read a configuration
config = client.read("database")
print(config["value"])  # {'host': 'localhost', 'port': 5432, 'username': 'admin'}

# Update a configuration
client.update(
    key="database",
    value={"host": "db.example.com", "port": 5432, "username": "admin"}
)

# List all configurations
configs = client.list_all(category="production")
for cfg in configs:
    print(f"{cfg['key']}: {cfg['value']}")

# Delete a configuration
client.delete("database")

# Close the client (or use context manager)
client.close()

Using Context Manager

from opensecureconf_client import OpenSecureConfClient

with OpenSecureConfClient(base_url="http://localhost:9000", user_key="my-key") as client:
    config = client.create("app", {"version": "1.0.0"})
    print(config)
# Session automatically closed

API Reference

OpenSecureConfClient

Main client class for interacting with the OpenSecureConf API.

Constructor

OpenSecureConfClient(
    base_url: str,
    user_key: str,
    timeout: int = 30,
    verify_ssl: bool = True
)

Parameters:

  • base_url: The base URL of the OpenSecureConf API server
  • user_key: User encryption key for authentication (minimum 8 characters)
  • timeout: Request timeout in seconds (default: 30)
  • verify_ssl: Whether to verify SSL certificates (default: True)

Methods

get_service_info() -> Dict[str, Any]

Get information about the OpenSecureConf service.

create(key: str, value: Dict[str, Any], category: Optional[str] = None) -> Dict[str, Any]

Create a new encrypted configuration entry.

read(key: str) -> Dict[str, Any]

Read and decrypt a configuration entry by key.

update(key: str, value: Dict[str, Any], category: Optional[str] = None) -> Dict[str, Any]

Update an existing configuration entry.

delete(key: str) -> Dict[str, str]

Delete a configuration entry permanently.

list_all(category: Optional[str] = None) -> List[Dict[str, Any]]

List all configurations with optional category filter.

Error Handling

The client provides specific exceptions for different error scenarios:

from opensecureconf_client import (
    OpenSecureConfClient,
    AuthenticationError,
    ConfigurationNotFoundError,
    ConfigurationExistsError,
    OpenSecureConfError
)

try:
    config = client.create("mykey", {"data": "value"})
except AuthenticationError:
    print("Invalid user key")
except ConfigurationExistsError:
    print("Configuration already exists")
except ConfigurationNotFoundError:
    print("Configuration not found")
except OpenSecureConfError as e:
    print(f"API error: {e}")

Exception Hierarchy

  • OpenSecureConfError (base exception)
    • AuthenticationError - Invalid or missing user key
    • ConfigurationNotFoundError - Configuration key does not exist
    • ConfigurationExistsError - Configuration key already exists

Requirements

  • Python 3.8 or higher
  • requests >= 2.28.0

Development

Setting Up Development Environment

# Clone the repository
git clone https://github.com/lordraw77/OpenSecureConf.git
cd opensecureconf-client

# Install with development dependencies
pip install -e ".[dev]"

# Run tests
pytest

# Run tests with coverage
pytest --cov=opensecureconf_client

# Format code
black opensecureconf_client.py

# Lint code
flake8 opensecureconf_client.py

License

MIT License - see LICENSE file for details

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

Links

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

opensecureconf_client-1.0.2.tar.gz (6.7 kB view details)

Uploaded Source

Built Distribution

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

opensecureconf_client-1.0.2-py3-none-any.whl (7.2 kB view details)

Uploaded Python 3

File details

Details for the file opensecureconf_client-1.0.2.tar.gz.

File metadata

  • Download URL: opensecureconf_client-1.0.2.tar.gz
  • Upload date:
  • Size: 6.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.12

File hashes

Hashes for opensecureconf_client-1.0.2.tar.gz
Algorithm Hash digest
SHA256 0e9a70c9840c92305226f9e1ef3dddd7754f47b8ec2725bd7e68580c9375a82a
MD5 2ebf786a91b6d1055cf0119cb5a835bc
BLAKE2b-256 d7011133017b2667d1aead959d37b41bedc2ada6479052b1a8e05e6aa3e3f461

See more details on using hashes here.

File details

Details for the file opensecureconf_client-1.0.2-py3-none-any.whl.

File metadata

File hashes

Hashes for opensecureconf_client-1.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 185ceec46d6f85dced796b965ca394d455acf909b1a7d79e7c9e6cef52a950ec
MD5 d6f33e675ed37852384951c4afaa9628
BLAKE2b-256 872636ca4d3c0700eff495fdf885b9f6232869a0101485ba6fcc4d050ac816dd

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