Skip to main content

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.

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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

py_acs_sdk-1.0.6.tar.gz (62.0 kB view details)

Uploaded Source

Built Distribution

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

py_acs_sdk-1.0.6-py3-none-any.whl (87.3 kB view details)

Uploaded Python 3

File details

Details for the file py_acs_sdk-1.0.6.tar.gz.

File metadata

  • Download URL: py_acs_sdk-1.0.6.tar.gz
  • Upload date:
  • Size: 62.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for py_acs_sdk-1.0.6.tar.gz
Algorithm Hash digest
SHA256 d958bd34315e82ed791b97c6a91d2756efa5a253314976cef6540107226de7e2
MD5 2036cb62a1ddad4f3d469a36a6cd86e6
BLAKE2b-256 e427b8f2082a96ed9eaeedabe48b47c2727d7172486c5b3e82ed3e02b0ca4273

See more details on using hashes here.

Provenance

The following attestation bundles were made for py_acs_sdk-1.0.6.tar.gz:

Publisher: release.yml on vimal-dev/acs-sdk

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file py_acs_sdk-1.0.6-py3-none-any.whl.

File metadata

  • Download URL: py_acs_sdk-1.0.6-py3-none-any.whl
  • Upload date:
  • Size: 87.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for py_acs_sdk-1.0.6-py3-none-any.whl
Algorithm Hash digest
SHA256 d14b4544ceacba076602df24e4189c169567915950b6587b41ea7d5053fce2c7
MD5 d57195cff05cd93ef9988465eb329722
BLAKE2b-256 b3d79e25550a62be6a307977ec0d465f61a098eeeb7c96999c0c6771d606c414

See more details on using hashes here.

Provenance

The following attestation bundles were made for py_acs_sdk-1.0.6-py3-none-any.whl:

Publisher: release.yml on vimal-dev/acs-sdk

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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