Skip to main content

Python SDK for F5 Distributed Cloud APIs

Project description

f5xc-py-substrate

imge-substrate

Python SDK for F5 Distributed Cloud (XC) APIs that can be regenerated when the XC Open API Spec is updated.

This SDK aims to be a "safe" layer to build upon to prevent having to rework downstream dependencies post release/API changes.

Features

  • Full API coverage: 250+ resources generated from F5 XC OpenAPI specs
  • All operations: Both standard CRUD and CustomAPI operations are supported
  • Typed models: Pydantic v2 models with IDE autocomplete support
  • Lazy loading: Resources load on first access for fast startup

Installation

pip install f5xc-py-substrate

Or install from source:

git clone https://github.com/your-org/f5xc-py-substrate.git
cd f5xc-py-substrate
pip install -e .

Quick Start

from f5xc_py_substrate import Client

# Initialize with explicit credentials
client = Client(
    tenant_url="https://your-tenant.console.ves.volterra.io",
    token="your-api-token"
)

# Or use environment variables (F5XC_TENANT_URL, F5XC_API_TOKEN)
client = Client()

# List resources
lbs = client.http_loadbalancer.list(namespace="default")
for lb in lbs:
    print(lb.metadata.name)

API Design Pattern

F5 XC uses a metadata/spec pattern similar to Kubernetes:

Field Purpose
metadata Identity and organization: name, namespace, labels, annotations, description
spec Configuration: the actual resource settings
status Runtime state (read-only, returned by API)
# Creating a resource - you provide metadata + spec
client.http_loadbalancer.create(
    namespace="default",       # metadata.namespace
    name="my-lb",              # metadata.name
    labels={"env": "prod"},    # metadata.labels
    spec=...,                  # The configuration
)

# Reading a resource - you get metadata + spec + status
lb = client.http_loadbalancer.get(namespace="default", name="my-lb")
lb.metadata.name        # "my-lb"
lb.metadata.namespace   # "default"
lb.metadata.labels      # {"env": "prod"}
lb.spec                 # The configuration you provided
lb.status               # Runtime state from the system

If you've used kubectl, this will feel familiar. The SDK's create() and replace() methods accept metadata fields as top-level parameters for convenience.

Usage Examples

Get a Resource

lb = client.http_loadbalancer.get(namespace="default", name="my-lb")

# Access metadata and spec
print(lb.metadata.name)       # "my-lb"
print(lb.metadata.namespace)  # "default"
print(lb.metadata.labels)     # {"env": "prod"}
print(lb.spec)

Create a Resource

# Access spec models directly from the resource (no import needed)
client.http_loadbalancer.create(
    namespace="default",
    name="my-lb",
    spec=client.http_loadbalancer.CreateSpecType(
        domains=["example.com"],
    ),
    labels={"env": "prod"},
    description="Production load balancer",
)

# Or using raw body for full control
client.http_loadbalancer.create(
    namespace="default",
    name="my-lb",
    body={
        "metadata": {
            "name": "my-lb",
            "namespace": "default",
            "labels": {"env": "prod"},
        },
        "spec": {
            "domains": ["example.com"],
        },
    },
)

List with Filters

# Filter by labels
lbs = client.http_loadbalancer.list(
    namespace="default",
    label_filter="env in (staging, production)"
)

Replace a Resource

# Replace requires the complete spec, not just the changed fields
client.http_loadbalancer.replace(
    namespace="default",
    name="my-lb",
    spec=client.http_loadbalancer.ReplaceSpecType(
        domains=["example.com", "www.example.com"],
    ),
    description="Updated load balancer",
)

Delete a Resource

client.http_loadbalancer.delete(namespace="default", name="my-lb")

Serialization

All models include helper methods for serialization:

lb = client.http_loadbalancer.get(namespace="default", name="my-lb")

# To dictionary (excludes None values by default)
data = lb.to_dict()

# To JSON string (compact by default)
json_str = lb.to_json()
json_str = lb.to_json(indent=2)  # Pretty print

# To YAML (requires: pip install f5xc-py-substrate[yaml])
yaml_str = lb.to_yaml()

get() Response Filtering

By default, get() excludes verbose fields (forms, references, system_metadata) for cleaner output. Use include_all=True when you need the complete response:

# Default: clean response without verbose fields
lb = client.http_loadbalancer.get(namespace="default", name="my-lb")

# Full response with all fields
lb = client.http_loadbalancer.get(
    namespace="default",
    name="my-lb",
    include_all=True
)

See Advanced Usage for more details.

Available Resources

The SDK includes 250+ resources. Access any resource as an attribute on the client:

client.http_loadbalancer
client.origin_pool
client.healthcheck
client.namespace
client.virtual_host
# ... and many more

Documentation

Requirements

  • Python 3.9+
  • httpx
  • pydantic v2

License

This is free and unencumbered software released into the public domain. See LICENSE for details.

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

f5xc_py_substrate-0.1.0.tar.gz (837.1 kB view details)

Uploaded Source

Built Distribution

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

f5xc_py_substrate-0.1.0-py3-none-any.whl (1.5 MB view details)

Uploaded Python 3

File details

Details for the file f5xc_py_substrate-0.1.0.tar.gz.

File metadata

  • Download URL: f5xc_py_substrate-0.1.0.tar.gz
  • Upload date:
  • Size: 837.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for f5xc_py_substrate-0.1.0.tar.gz
Algorithm Hash digest
SHA256 c64a971e1eecfcf604a5dd26c4056ce6dc942955dc1c1abbbba22917e4751250
MD5 4539bae4fd781e31b252dd0c893c0fd5
BLAKE2b-256 16b1a35c823387fea9c0159fd4b1f84c7b6ab92110e9ae5743fd1ce88bf5cf3c

See more details on using hashes here.

Provenance

The following attestation bundles were made for f5xc_py_substrate-0.1.0.tar.gz:

Publisher: publish.yml on f5xc-TenantOps/f5xc-py-substrate

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file f5xc_py_substrate-0.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for f5xc_py_substrate-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 7810c0b0232f4ec0e06453336201634b7c1ccc7f621c3a3ef8cd2576e21e8829
MD5 a733b09eb9fac7c10312d21cf8374ef7
BLAKE2b-256 ff23a2157f60ee05db48d02791883155a43afb4db671c5400739881e0c860163

See more details on using hashes here.

Provenance

The following attestation bundles were made for f5xc_py_substrate-0.1.0-py3-none-any.whl:

Publisher: publish.yml on f5xc-TenantOps/f5xc-py-substrate

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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