A client library for accessing Unikraft Cloud Platform API
Project description
Unikraft Cloud Python SDK
This repository contains an auto-generated Go SDK which interfaces with Unikraft Cloud based on the public OpenAPI specification.
Get started with Unikraft Cloud Today
Sign up at https://console.unikraft.cloud/signup
Quickstart
#!/usr/bin/env python3
"""
List Instances Example
This example demonstrates how to use the Unikraft Cloud Platform SDK to list instances.
Usage:
python list_instances.py
Environment Variables:
UKC_TOKEN: Your Unikraft Cloud API token (required)
UKC_METRO: The metro URL (optional, defaults to fra0.kraft.cloud)
Example:
export UKC_TOKEN="your-api-token-here"
export UKC_METRO="https://api.fra0.kraft.cloud"
python list_instances.py
"""
import os
import sys
from unikraft_cloud_platform import AuthenticatedClient
from unikraft_cloud_platform.models import Instance
from unikraft_cloud_platform.models.get_instances_response import GetInstancesResponse
from unikraft_cloud_platform.api.instances import get_instances
from unikraft_cloud_platform.types import Response
def main():
# Read configuration from environment variables
token = os.getenv("UKC_TOKEN")
base_url = os.getenv("UKC_METRO", "https://api.fra0.kraft.cloud")
if not token:
print("Error: UKC_TOKEN environment variable is required", file=sys.stderr)
print("Please set your API token: export UKC_TOKEN='your-token-here'", file=sys.stderr)
sys.exit(1)
client = AuthenticatedClient(
base_url=base_url,
token=token,
)
# List all instances (empty body means get all instances)
with client as client:
response: Response[GetInstancesResponse] = get_instances.sync_detailed(
client=client,
body=[], # Empty list to get all instances
details=True
)
# Check if the request was successful
if response.status_code == 200 and response.parsed:
instances_response = response.parsed
# Check if we have data and instances
if instances_response.data and instances_response.data.instances:
print(f"Found {len(instances_response.data.instances)} instances:")
print("-" * 50)
for instance in instances_response.data.instances:
print(f"Name: {instance.name}")
print(f"UUID: {instance.uuid}")
print(f"State: {instance.state}")
print(f"Created: {instance.created_at}")
if instance.private_fqdn:
print(f"Private FQDN: {instance.private_fqdn}")
print("-" * 50)
else:
print("No instances found.")
else:
print(f"Failed to retrieve instances. Status code: {response.status_code}")
if response.parsed and response.parsed.message:
print(f"Error message: {response.parsed.message}")
if response.parsed and response.parsed.errors:
for error in response.parsed.errors:
print(f"Error: {error}")
if __name__ == "__main__":
main()
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 unikraft_cloud_platform-1.0.0.tar.gz.
File metadata
- Download URL: unikraft_cloud_platform-1.0.0.tar.gz
- Upload date:
- Size: 74.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.6.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
02bd525bbb2826e8335cfa950075c231348aae06b08e5847d9c814c3424c4352
|
|
| MD5 |
b423e156192dfe639e6d1052abfa1fd6
|
|
| BLAKE2b-256 |
481ca0080d8f7b897c2099002e303bd27f6d808c4c76b235b0e9879755daa190
|
File details
Details for the file unikraft_cloud_platform-1.0.0-py3-none-any.whl.
File metadata
- Download URL: unikraft_cloud_platform-1.0.0-py3-none-any.whl
- Upload date:
- Size: 272.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.6.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
7acb9643e38a71f4b6af698682c144ce366270e08435f07a3bdb1b0be48dd21d
|
|
| MD5 |
1dc544fb81f7d471a1fc9788595f0135
|
|
| BLAKE2b-256 |
a6eb25db6c315ee3799f51433cd1ee8c4178da8588703911752084d9c4878dc0
|