Skip to main content

A Python SDK for the Incus API

Project description

Incus Python SDK

Documentation PyPI version Python versions

A Python SDK for interacting with the Incus API. This SDK provides a simple and intuitive way to manage Incus containers, virtual machines, and other resources using Python.

Installation

pip install incus-sdk

Documentation

Comprehensive documentation is available at https://orbical-dev.github.io/incus_sdk/

The documentation includes:

  • Installation instructions
  • Quick start guide
  • API reference
  • Code examples
  • Error handling guide
  • Contributing guidelines

Local Development

To build and view the documentation locally:

# Install documentation dependencies
pip install -r docs/requirements.txt

# Build and serve the documentation
cd docs
mkdocs serve

Then open http://127.0.0.1:8000 in your browser.

Features

  • Full support for Incus REST API
  • Asynchronous operation support
  • Easy management of containers, virtual machines, networks, profiles, storage pools, and clusters
  • Certificate-based authentication
  • Support for local and remote Incus servers
  • Comprehensive error handling with specific exception types
  • Project-based resource management

Quick Start

from incus_sdk import Client

# Connect to local Incus socket
client = Client()

# List all instances
instances = client.instances.list()
for instance in instances:
    print(f"Instance: {instance.name}, Status: {instance.status}")

# Create a new container
container = client.instances.create(
    name="my-container",
    source={
        "type": "image",
        "protocol": "simplestreams",
        "server": "https://images.linuxcontainers.org",
        "alias": "ubuntu/22.04"
    },
    wait=True
)

# Start the container
container.start(wait=True)

# Create a network
network = client.networks.create(
    name="my-network",
    config={
        "ipv4.address": "10.0.0.1/24",
        "ipv4.nat": "true"
    }
)

# Error handling
try:
    instance = client.instances.get("non-existent")
except incus_sdk.IncusNotFoundError as e:
    print(f"Instance not found: {e}")

Documentation

For detailed documentation, visit https://incus-sdk.readthedocs.io

Available API Clients

The SDK provides the following API clients:

  • instances - Manage containers and virtual machines
  • images - Manage images and aliases
  • networks - Manage networks
  • profiles - Manage profiles
  • storage_pools - Manage storage pools and volumes
  • certificates - Manage certificates
  • operations - Manage operations
  • projects - Manage projects
  • cluster - Manage clusters and cluster members

Error Handling

The SDK provides specific exception types for different error scenarios:

  • IncusError - Base exception for all Incus errors
  • IncusAPIError - Exception for API request failures
  • IncusConnectionError - Exception for connection failures
  • IncusOperationError - Exception for operation failures
  • IncusNotFoundError - Exception for resource not found errors
  • IncusAuthenticationError - Exception for authentication failures
  • IncusPermissionError - Exception for permission denied errors

License

MIT License

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

incus_sdk-1.0.0.tar.gz (18.7 kB view details)

Uploaded Source

Built Distribution

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

incus_sdk-1.0.0-py3-none-any.whl (29.5 kB view details)

Uploaded Python 3

File details

Details for the file incus_sdk-1.0.0.tar.gz.

File metadata

  • Download URL: incus_sdk-1.0.0.tar.gz
  • Upload date:
  • Size: 18.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.3

File hashes

Hashes for incus_sdk-1.0.0.tar.gz
Algorithm Hash digest
SHA256 46547cad41d84f39506ea2e1f51b556ffde8d990797637f61fb1dfbbbde2df25
MD5 4a2b37c7c24495b07486cf3321a22cb2
BLAKE2b-256 feda23bcb50ea299ecd23b25f94040e1638b1cf2404bc44ac7291e71e8f6a34f

See more details on using hashes here.

File details

Details for the file incus_sdk-1.0.0-py3-none-any.whl.

File metadata

  • Download URL: incus_sdk-1.0.0-py3-none-any.whl
  • Upload date:
  • Size: 29.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.3

File hashes

Hashes for incus_sdk-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 1630f3515cc3d2a7553f70793f2d217db758e5bff9f2f8efd92bd1ad562323b3
MD5 71ddebb9af7bd5c8ab53715768e394c4
BLAKE2b-256 e3f60ca1d2b7c401b52e3e6a1f927212fc28f18964bf62e7ba80d5e38b02e656

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