Async CLI for Portainer API with Git integration, health monitoring, image watching and event listening
Project description
homelab-portainer
Async CLI for Portainer API with Git integration, health monitoring, image watching and event listening.
Features
- Async HTTP Client - Full Portainer API coverage
- Stack Management - Git-based deploy with automatic commit/push/redeploy
- Container Management - Start, stop, restart, logs, stats
- Health Monitoring - Stack and container health checks
- Image Watcher - Monitor Docker images for updates
- Event Listener - Real-time Docker events streaming
Installation
pip install -e .
Quick Start
import asyncio
from portainer import PortainerClient, StackManager
async def main():
async with PortainerClient(
url="https://portainer:9443",
token="your-api-key",
) as client:
sm = StackManager(client)
stacks = await sm.list_stacks()
for s in stacks:
print(f"{s.name}: {s.status_text}")
asyncio.run(main())
CLI Usage
# Set token
$env:PORTAINER_TOKEN="your-token"
# List stacks
portainer stack list --url "https://portainer:9443" --token $env:PORTAINER_TOKEN
# Deploy stack
portainer stack deploy mystack "update message"
# Monitor images
portainer watch images --interval 6
# Listen to events
portainer events start --duration 30
Project Structure
portainer/
├── client.py # HTTP client (Portainer API)
├── models.py # Dataclass models
├── stack_manager.py # Stack operations + git
├── container_manager.py # Container operations
├── monitor.py # Health monitoring
├── watcher.py # ImageWatcher
├── listener.py # EventListener
└── cli.py # CLI
Development
# Install with dev dependencies
pip install -e ".[dev]"
# Run tests
pytest
# Linting
ruff check portainer/
# Type checking
mypy portainer/
License
MIT
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
aioportainer-0.1.2.tar.gz
(36.6 kB
view details)
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file aioportainer-0.1.2.tar.gz.
File metadata
- Download URL: aioportainer-0.1.2.tar.gz
- Upload date:
- Size: 36.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
9bd62e9cb08a9fd6fff62b1fc2099bc8d217e83174deeb00d9378b56f495e628
|
|
| MD5 |
421abf5446f5f4d84180ef9b4c2f5847
|
|
| BLAKE2b-256 |
375bde071346e68a0b5321df7bbd484df53207be340256549bb789e8b6f114f0
|
File details
Details for the file aioportainer-0.1.2-py3-none-any.whl.
File metadata
- Download URL: aioportainer-0.1.2-py3-none-any.whl
- Upload date:
- Size: 23.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
2db6e638b4d9bfacad81d83b2fd03f13cd3f08d76fcc065a5c81029012acea42
|
|
| MD5 |
fbf95484b902c13e62649e4a5c4ac7bd
|
|
| BLAKE2b-256 |
ade7cebbad476a828375e44df4b0f876f78c83645a55b774f18b00d5a0b04778
|