Python SDK for Apache CloudStack API
Project description
Apache CloudStack Python SDK
A Python SDK for the Apache CloudStack API that provides a simple and type-safe interface to manage resources. All the available API action are documented here Apache CloudStack API
Features
- 🔐 Type-Safe - Built with Pydantic for request/response validation
- 🚀 Async Support - Built on httpx for modern async HTTP requests
- 📦 Easy Configuration - Simple configuration management
- 🧪 Well Tested - Comprehensive test suite with pytest
- 🔄 Automatic Retry - Built-in retry logic with exponential backoff
- 🔑 Request Signing - Automatic HMAC-SHA1 request signing
- 💻 CLI Tool - Command-line interface for quick operations
Requirements
- Python >= 3.12
Installation
pip install py-acs-sdk
Getting Started
Basic Setup
from acs_sdk import ApacheCloudStackClient, ApacheCloudStackConfig
# Create a configuration
config = ApacheCloudStackConfig(
endpoint="https://your-cloudstack-endpoint/api",
api_key="your_api_key",
api_secret="your_api_secret"
)
# Initialize the CloudStack client
client = ApacheCloudStackClient(config)
Making API Calls
# List users
response = client.call('listUsers')
# Get user with parameters
user_response = client.call('getUser', {'userid': '123'})
# Don't forget to close the client
client.close()
Async API Calls
import asyncio
from acs_sdk import ApacheCloudStackAsyncClient, ApacheCloudStackConfig
async def main():
config = ApacheCloudStackConfig(
endpoint="https://your-cloudstack-endpoint/api",
api_key="your_api_key",
api_secret="your_api_secret"
)
async with ApacheCloudStackAsyncClient(config) as client:
response = await client.call_async('listUsers')
print(response)
asyncio.run(main())
Command-Line Interface (CLI)
The SDK includes a CLI tool for quick operations without writing code.
Setup Environment Variables
export CLOUDSTACK_ENDPOINT="https://your-cloudstack-endpoint/api"
export CLOUDSTACK_API_KEY="your_api_key"
export CLOUDSTACK_API_SECRET="your_api_secret"
Available Commands
# List all regions
acs list-regions
# List all users
acs list-users
# View help
acs --help
acs list-regions --help
CLI Options
You can also provide options directly:
acs --endpoint "https://..." --api-key "..." --api-secret "..." list-regions
Project Structure
src/
├── acs_sdk/
│ ├── client/ # HTTP client implementation
│ ├── core/ # Retry logic and request signing
│ ├── schemas/ # Configuration schemas
│ ├── exceptions/ # Custom exceptions
│ └── cli.py # Command-line interface
tests/
├── unit/ # Unit tests
└── conftest.py # Pytest configuration
Development
Setup Development Environment
# Create virtual environment
python -m venv .venv
source .venv/bin/activate # On Windows: .venv\Scripts\activate
# Install dependencies with dev tools
pip install -e ".[dev]"
Running Tests
# Run all tests with coverage
pytest
# Run specific test file
pytest tests/unit/test_client.py
# Run with coverage report
pytest --cov=acs_sdk --cov-report=html
Code Structure
- Client - Handles HTTP requests to Apache CloudStack API
- Core - Retry logic and request signing utilities
- Schemas - Pydantic models for configuration validation
- CLI - Command-line interface for CloudStack operations
Dependencies
- httpx (>=0.28.1) - Modern HTTP client for async support
- pydantic (>=2.12.5) - Data validation and serialization
- click (>=8.3.1) - Command-line interface creation
License
MIT
Author
Vimal Saini - vimal.saini25@gmail.com
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
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 py_acs_sdk-1.0.12.tar.gz.
File metadata
- Download URL: py_acs_sdk-1.0.12.tar.gz
- Upload date:
- Size: 90.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
89cf3d043a11f2910dfe26d1f9b97d183c3f98cee58feca8e03d39aac776d166
|
|
| MD5 |
e3cca97ca3955482f5ae02cf7b526cbf
|
|
| BLAKE2b-256 |
dae56390a350de418dbb148b59aaba6307f782193b39c696d3926869f0c62bad
|
Provenance
The following attestation bundles were made for py_acs_sdk-1.0.12.tar.gz:
Publisher:
release.yml on vimal-dev/acs-sdk
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
py_acs_sdk-1.0.12.tar.gz -
Subject digest:
89cf3d043a11f2910dfe26d1f9b97d183c3f98cee58feca8e03d39aac776d166 - Sigstore transparency entry: 2218034501
- Sigstore integration time:
-
Permalink:
vimal-dev/acs-sdk@b9df2d458fe13ddbb2b7b045c6d5b219af35be88 -
Branch / Tag:
refs/tags/v1.0.12 - Owner: https://github.com/vimal-dev
-
Access:
private
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@b9df2d458fe13ddbb2b7b045c6d5b219af35be88 -
Trigger Event:
push
-
Statement type:
File details
Details for the file py_acs_sdk-1.0.12-py3-none-any.whl.
File metadata
- Download URL: py_acs_sdk-1.0.12-py3-none-any.whl
- Upload date:
- Size: 125.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
225a19d29febff11b3ea3b8fd3f0132ab916536b90a47e141db94b1ff3557183
|
|
| MD5 |
0c7f98a5f2962a8a1f6e039216db2d68
|
|
| BLAKE2b-256 |
f32ca07908b1750b38fdab67a2e5f588e48bda8b8aa439fad22ee158ceab2e8f
|
Provenance
The following attestation bundles were made for py_acs_sdk-1.0.12-py3-none-any.whl:
Publisher:
release.yml on vimal-dev/acs-sdk
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
py_acs_sdk-1.0.12-py3-none-any.whl -
Subject digest:
225a19d29febff11b3ea3b8fd3f0132ab916536b90a47e141db94b1ff3557183 - Sigstore transparency entry: 2218034560
- Sigstore integration time:
-
Permalink:
vimal-dev/acs-sdk@b9df2d458fe13ddbb2b7b045c6d5b219af35be88 -
Branch / Tag:
refs/tags/v1.0.12 - Owner: https://github.com/vimal-dev
-
Access:
private
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@b9df2d458fe13ddbb2b7b045c6d5b219af35be88 -
Trigger Event:
push
-
Statement type: