securevault 0.1.0
Python client for SecureVault - secure secrets management
Requires Python: >=3.7

# SecureVault Python Client

Python wrapper for the SecureVault CLI tool.

## Installation

```bash
pip install securevault
```

Or install from source:

```bash
cd wrappers/python
pip install -e .
```

## Prerequisites

- SecureVault CLI must be installed and available in your PATH
- Python 3.7 or higher

## Quick Start

```python
from securevault import VaultClient

# Initialize client
vault = VaultClient()

# Set a secret
vault.set('api_key', 'my-secret-key')

# Get a secret
api_key = vault.get('api_key')
print(f"API Key: {api_key}")

# List all secrets
secrets = vault.list()
print(f"Secrets: {secrets}")

# Check if secret exists
if vault.exists('api_key'):
    print("API key is configured")

# Delete a secret
vault.delete('api_key')
```

## Usage Examples

### Context Manager

```python
from securevault import VaultClient

with VaultClient() as vault:
    vault.set('temp_key', 'temp_value')
    value = vault.get('temp_key')
    print(value)
```

### Load Secrets into Environment

```python
from securevault import VaultClient
import os

vault = VaultClient()

# Load all secrets as environment variables
vault.load_env()

# Access from environment
api_key = os.getenv('API_KEY')

# Load with prefix
vault.load_env(prefix='APP_')
# Now accessible as APP_API_KEY, APP_DB_PASSWORD, etc.
```

### Get All Secrets

```python
from securevault import VaultClient

vault = VaultClient()

# Get all secrets as dictionary
secrets = vault.get_all()
for name, value in secrets.items():
    print(f"{name}: {value}")
```

### Export/Import

```python
from securevault import VaultClient

vault = VaultClient()

# Export to JSON
vault.export_to_file('secrets.json')

# Import from JSON
vault.import_from_file('secrets.json')
```

### Async Support

```python
import asyncio
from securevault import AsyncVaultClient

async def main():
    vault = AsyncVaultClient()
    
    # All methods are async
    await vault.set('api_key', 'secret123')
    api_key = await vault.get('api_key')
    print(api_key)
    
    secrets = await vault.list()
    print(secrets)

asyncio.run(main())
```

### Custom CLI Path

```python
from securevault import VaultClient

# Specify custom path to CLI
vault = VaultClient(cli_path='/custom/path/to/securevault')
```

## API Reference

### `VaultClient`

#### Methods

- `get(name: str) -> str` - Get a secret value
- `set(name: str, value: str, description: Optional[str] = None)` - Set a secret
- `delete(name: str)` - Delete a secret
- `list() -> List[str]` - List all secret names
- `exists(name: str) -> bool` - Check if a secret exists
- `get_all() -> Dict[str, str]` - Get all secrets as dictionary
- `load_env(prefix: str = '')` - Load secrets into environment variables
- `export_to_file(filepath: str)` - Export secrets to JSON file
- `import_from_file(filepath: str)` - Import secrets from JSON file

### `AsyncVaultClient`

Async version with the same methods, but all are async/await.

## Error Handling

```python
from securevault import VaultClient, VaultError, SecretNotFoundError

vault = VaultClient()

try:
    value = vault.get('nonexistent')
except SecretNotFoundError:
    print("Secret not found")
except VaultError as e:
    print(f"Vault error: {e}")
```

## Development

### Running Tests

```bash
pip install -e ".[dev]"
pytest
```

### Running Async Tests

```bash
pytest -v tests/test_async.py
```

## License

MIT

## Author

JahDev