Skip to main content

A modern and pythonic Python SDK for the Cloudpepper API.

Project description

Cloudpepper API Python SDK

PyPI version Python Support License: MIT

A modern, async-first Python SDK for the Cloudpepper API. Manage your Odoo instances, servers, backups, and users programmatically with ease.

Features

  • ๐Ÿš€ Async/Await Support - Built on httpx for high-performance async operations
  • ๐ŸŽฏ Type-Safe - Full type hints with Pydantic models for auto-completion and validation
  • ๐Ÿ”ง Comprehensive - Complete coverage of the Cloudpepper API
  • ๐Ÿ“ฆ Easy to Use - Intuitive, resource-based API design
  • ๐Ÿ›ก๏ธ Error Handling - Custom exceptions for better error management
  • ๐Ÿ”„ Context Manager - Automatic resource cleanup with async context managers

Installation

Install from PyPI using pip:

pip install cloudpepper

Quick Start

import asyncio
from cloudpepper import Cloudpepper

async def main():
    async with Cloudpepper(api_key="your_api_key") as client:
        # List all servers
        servers = await client.servers.list()
        print(f"Found {len(servers)} servers")
        
        # List all instances
        instances = await client.instances.list()
        for instance in instances:
            print(f"Instance: {instance.name} ({instance.status})")

asyncio.run(main())

Usage Examples

Server Management

from cloudpepper import Cloudpepper
from cloudpepper.models import ServerCreate

async with Cloudpepper(api_key="your_api_key") as client:
    # Create a new server
    server = await client.servers.create(
        ServerCreate(
            type="cloudpepper",
            region="fra",
            plan="vhp-2c-4gb-amd",
            config={"odoo_version": "17.0"}
        )
    )
    print(f"Server created: {server.id}")
    
    # Get server details
    server_detail = await client.servers.get(server.id)
    print(f"Server status: {server_detail.status}")
    
    # Update server
    await client.servers.update(
        server.id,
        name="Production Server"
    )
    
    # Delete server
    await client.servers.delete(server.id)

Instance Management

from cloudpepper import Cloudpepper
from cloudpepper.models import InstanceCreate

async with Cloudpepper(api_key="your_api_key") as client:
    # Create a new Odoo instance
    instance = await client.instances.create(
        InstanceCreate(
            server_id="server-uuid",
            config={
                "name": "mycompany",
                "domain": "mycompany.example.com",
                "odoo_version": "17.0"
            }
        )
    )
    
    # Get instance status
    status = await client.instances.get_status(instance.id)
    print(f"Instance status: {status}")
    
    # Restart instance
    await client.instances.restart(instance.id)
    
    # Stop instance
    await client.instances.stop(instance.id)
    
    # Start instance
    await client.instances.start(instance.id)

Backup Management

async with Cloudpepper(api_key="your_api_key") as client:
    # List all backups
    backups = await client.backups.list()
    
    # Get specific backup
    backup = await client.backups.get("backup-id")
    
    # Add backup schedule
    schedule = await client.backup_schedules.add(
        instance_id="instance-uuid",
        schedule="0 2 * * *",  # Daily at 2 AM
        retention=7
    )
    
    # Update backup schedule
    await client.backup_schedules.update(
        instance_id="instance-uuid",
        schedule_id=schedule.id,
        retention=14
    )
    
    # Delete backup schedule
    await client.backup_schedules.delete(
        instance_id="instance-uuid",
        schedule_id=schedule.id
    )

User Management

async with Cloudpepper(api_key="your_api_key") as client:
    # List all users
    users = await client.users.list()
    
    # Create a new user
    user = await client.users.create(
        email="user@example.com",
        password="secure_password",
        role="USER"
    )
    
    # Update user permissions
    await client.users.update(
        user_id=user.uid,
        role="ADMIN"
    )
    
    # Delete user
    await client.users.delete(user.uid)

Module Management

async with Cloudpepper(api_key="your_api_key") as client:
    # Add a module to an instance
    module = await client.instances.add_module(
        instance_id="instance-uuid",
        repo="https://github.com/OCA/web.git",
        branch="17.0"
    )
    
    # Update module
    await client.instances.update_module(
        instance_id="instance-uuid",
        module_id=module["id"],
        branch="18.0"
    )
    
    # Delete module
    await client.instances.delete_module(
        instance_id="instance-uuid",
        module_id=module["id"]
    )

Error Handling

The SDK provides custom exceptions for better error management:

from cloudpepper import Cloudpepper
from cloudpepper.exceptions import (
    AuthenticationError,
    NotFoundError,
    ValidationError,
    RateLimitError,
    ServerError
)

async with Cloudpepper(api_key="your_api_key") as client:
    try:
        server = await client.servers.get("non-existent-id")
    except AuthenticationError:
        print("Invalid API key")
    except NotFoundError:
        print("Server not found")
    except ValidationError as e:
        print(f"Invalid request: {e.message}")
    except RateLimitError:
        print("Rate limit exceeded")
    except ServerError:
        print("Server error occurred")

Configuration

Custom Base URL

client = Cloudpepper(
    api_key="your_api_key",
    base_url="https://custom.api.cloudpepper.io"
)

Timeout Configuration

import httpx

client = Cloudpepper(api_key="your_api_key")
client.client.timeout = httpx.Timeout(60.0, connect=10.0)

API Resources

The SDK provides access to the following Cloudpepper API resources:

  • Servers - Create, manage, and monitor cloud servers
  • Instances - Deploy and manage Odoo instances
  • Backups - Manage backups and backup schedules
  • Backup Providers - Configure backup storage providers
  • Users - Manage user accounts and permissions
  • Instance Templates - Create reusable instance configurations

Development

Setup Development Environment

# Clone the repository
git clone https://github.com/labiso-gmbh/cloudpepper-api-python-sdk.git
cd cloudpepper-api-python-sdk

# Install in development mode with dev dependencies
pip install -e '.[dev]'

Run Tests

# Run all tests
pytest

# Run with coverage
pytest --cov=src/cloudpepper --cov-report=html

# Run specific test file
pytest tests/test_instances.py

Project Structure

cloudpepper-api-python-sdk/
โ”œโ”€โ”€ src/
โ”‚   โ””โ”€โ”€ cloudpepper/
โ”‚       โ”œโ”€โ”€ __init__.py
โ”‚       โ”œโ”€โ”€ client.py           # Main client class
โ”‚       โ”œโ”€โ”€ exceptions.py       # Custom exceptions
โ”‚       โ”œโ”€โ”€ models.py          # Pydantic models
โ”‚       โ””โ”€โ”€ resources/         # API resource classes
โ”‚           โ”œโ”€โ”€ base.py
โ”‚           โ”œโ”€โ”€ servers.py
โ”‚           โ”œโ”€โ”€ instances.py
โ”‚           โ”œโ”€โ”€ backups.py
โ”‚           โ””โ”€โ”€ users.py
โ”œโ”€โ”€ tests/                     # Test suite
โ”œโ”€โ”€ pyproject.toml            # Project configuration
โ””โ”€โ”€ README.md

Requirements

  • Python >= 3.8
  • httpx
  • pydantic

License

This project is licensed under the MIT License - see the LICENSE file for details.

Support

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

Changelog

Version 0.1.0 (2025-11-20)

  • Initial release
  • Async/await support with httpx
  • Full API coverage for servers, instances, backups, and users
  • Type-safe Pydantic models
  • Custom exception handling
  • Comprehensive test suite

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

cloudpepper-0.1.1.tar.gz (27.5 kB view details)

Uploaded Source

Built Distribution

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

cloudpepper-0.1.1-py3-none-any.whl (10.0 kB view details)

Uploaded Python 3

File details

Details for the file cloudpepper-0.1.1.tar.gz.

File metadata

  • Download URL: cloudpepper-0.1.1.tar.gz
  • Upload date:
  • Size: 27.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for cloudpepper-0.1.1.tar.gz
Algorithm Hash digest
SHA256 cc1c247067922a69d2e65ab6bbfbae34be4123becfee83aadfa8dfe874ff72d5
MD5 7b9c9925985a674bae66e07fc46ff8fd
BLAKE2b-256 1e20919013125f88668c6dad99fac0698aa6055c880bcef71be24ae28e70372c

See more details on using hashes here.

File details

Details for the file cloudpepper-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: cloudpepper-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 10.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for cloudpepper-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 516e2d8f30444e75cc4befc2205042f76394fa723f8071e111763df48572c635
MD5 a985cb7cbc38087b278093c243c19aed
BLAKE2b-256 be93c6a5a131eea198ccfb18b618219e765c96ff3577ad7f812cf3c4022a65b7

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