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.1.tar.gz (6.6 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.1-py3-none-any.whl (7.0 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: opensecureconf_client-1.0.1.tar.gz
  • Upload date:
  • Size: 6.6 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.1.tar.gz
Algorithm Hash digest
SHA256 76d9f409cd9ce503356e281d47457798bc541449cf5aa7fd0e102cf9b5e3b475
MD5 051e1236b2f3b6b5052ffa7bab4239cc
BLAKE2b-256 26134659350f19a3d010b4efb213d56321e373b87fcd302cb432670b8dd91e7a

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for opensecureconf_client-1.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 03a50b6778d32bb267cd735fa74890d78dfe3c3c3ba959beacc58af2962cdd28
MD5 d91b7a0248fafc15480a0a6d97201cfc
BLAKE2b-256 495aa57b227a4524a44197b902113db0a6306934e9daed7cd4e5e8af11cd2189

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