A Python SDK for the Incus API
Project description
Incus Python SDK
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 machinesimages- Manage images and aliasesnetworks- Manage networksprofiles- Manage profilesstorage_pools- Manage storage pools and volumescertificates- Manage certificatesoperations- Manage operationsprojects- Manage projectscluster- Manage clusters and cluster members
Error Handling
The SDK provides specific exception types for different error scenarios:
IncusError- Base exception for all Incus errorsIncusAPIError- Exception for API request failuresIncusConnectionError- Exception for connection failuresIncusOperationError- Exception for operation failuresIncusNotFoundError- Exception for resource not found errorsIncusAuthenticationError- Exception for authentication failuresIncusPermissionError- Exception for permission denied errors
License
MIT License
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 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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
46547cad41d84f39506ea2e1f51b556ffde8d990797637f61fb1dfbbbde2df25
|
|
| MD5 |
4a2b37c7c24495b07486cf3321a22cb2
|
|
| BLAKE2b-256 |
feda23bcb50ea299ecd23b25f94040e1638b1cf2404bc44ac7291e71e8f6a34f
|
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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
1630f3515cc3d2a7553f70793f2d217db758e5bff9f2f8efd92bd1ad562323b3
|
|
| MD5 |
71ddebb9af7bd5c8ab53715768e394c4
|
|
| BLAKE2b-256 |
e3f60ca1d2b7c401b52e3e6a1f927212fc28f18964bf62e7ba80d5e38b02e656
|