Skip to main content

Xenfra SDK: Core engine and utilities for the Xenfra platform.

Project description

Xenfra Python SDK

The official, open-source Python SDK for interacting with the Xenfra API.

This SDK provides a simple and Pythonic interface for developers and AI Agents to programmatically manage infrastructure, deployments, and other platform resources.

Installation

pip install xenfra-sdk

Basic Usage

Initialize the client with your API token (or ensure the XENFRA_TOKEN environment variable is set).

import os
from xenfra_sdk import XenfraClient
from xenfra_sdk.exceptions import XenfraAPIError

client = XenfraClient(token=os.getenv("XENFRA_TOKEN"))

try:
    projects = client.projects.list()
    for p in projects:
        print(f"Found project: {p.name} (Status: {p.status})")
except XenfraAPIError as e:
    print(f"API Error: {e.detail}")

Usage for Agentic Workflows

The Xenfra SDK is designed to be used as a "tool" by AI Agents (e.g., OpenAI Assistants). The Pydantic models are compatible with function-calling schemas, allowing an agent to easily call these methods.

Here is a conceptual example of how an agent might use the SDK to fulfill a user's request.

# This is a conceptual representation of an agent's internal logic.
# The agent would be configured with functions that call these SDK methods.

def list_all_projects():
    """Lists all available projects in the Xenfra account."""
    return client.projects.list()

def create_new_deployment(project_name: str, git_repo: str, branch: str = "main"):
    """
    Creates a new deployment for a project.
    
    Args:
        project_name: The name for the new deployment.
        git_repo: The URL of the git repository to deploy.
        branch: The branch to deploy (defaults to 'main').
    """
    return client.deployments.create(
        project_name=project_name,
        git_repo=git_repo,
        branch=branch,
        framework="fastapi" # Framework detection would be part of a more complex agent
    )

# --- Agent Execution Flow ---

# User prompt: "Deploy my new app from github.com/user/my-app"

# 1. Agent decides which tool to use: `create_new_deployment`
# 2. Agent extracts parameters:
#    - project_name = "my-app" (inferred)
#    - git_repo = "https://github.com/user/my-app"
# 3. Agent calls the tool:
#    create_new_deployment(
#        project_name="my-app",
#        git_repo="https://github.com/user/my-app"
#    )

Error Handling

The SDK uses custom exceptions for clear error handling. All API-related errors will raise a XenfraAPIError, which contains the status_code and a detail message from the API response.

from xenfra_sdk.exceptions import XenfraAPIError, AuthenticationError

try:
    # Make an API call
    ...
except AuthenticationError as e:
    print("Authentication failed. Please check your token.")
except XenfraAPIError as e:
    print(f"An API error occurred with status {e.status_code}: {e.detail}")

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

xenfra_sdk-0.2.7.tar.gz (85.6 kB view details)

Uploaded Source

Built Distribution

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

xenfra_sdk-0.2.7-py3-none-any.whl (105.5 kB view details)

Uploaded Python 3

File details

Details for the file xenfra_sdk-0.2.7.tar.gz.

File metadata

  • Download URL: xenfra_sdk-0.2.7.tar.gz
  • Upload date:
  • Size: 85.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.9.29 {"installer":{"name":"uv","version":"0.9.29","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for xenfra_sdk-0.2.7.tar.gz
Algorithm Hash digest
SHA256 38d400b96a40992843e29156187e9ff48384369f227802e3fa3977b4baf36b54
MD5 f85c231ca5047a998e2b346e8277bdbb
BLAKE2b-256 39a2dd63bc5d1e96efed4db036fb41e69057bcd053f27580d7fb3e4572eb5c9f

See more details on using hashes here.

File details

Details for the file xenfra_sdk-0.2.7-py3-none-any.whl.

File metadata

  • Download URL: xenfra_sdk-0.2.7-py3-none-any.whl
  • Upload date:
  • Size: 105.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.9.29 {"installer":{"name":"uv","version":"0.9.29","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for xenfra_sdk-0.2.7-py3-none-any.whl
Algorithm Hash digest
SHA256 be2f9e9056611cce9bc2f2a9e7afea29cb89fe59f86f6e2b2b151a06cb054f2f
MD5 0ae7a1507cf5318f58143c7d2b910545
BLAKE2b-256 87b3d33c7e81dac5ba90c638bfcaab94c4257f3ff73fd8411d38d9f1c272975d

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