Skip to main content

CASFA (Content-Addressable Storage for Agents) Python SDK

Project description

CASFA Python SDK

Python client for CASFA (Content-Addressable Storage for Agents).

Installation

pip install casfa-client

Quick Start

Agent Token Authentication

import asyncio
from casfa import create_casfa_client, CasfaClientConfig, TokenAuthConfig

async def main():
    # Create client with agent token
    client = create_casfa_client(CasfaClientConfig(
        base_url="https://casfa.example.com",
        auth=TokenAuthConfig(type="token", token="casfa_xxx"),
        realm_id="user:ABC123",
    ))

    # Get realm usage
    result = await client.realm.get_usage()
    if result.ok:
        print(f"Nodes: {result.data.node_count}")
        print(f"Bytes: {result.data.total_bytes}")
    else:
        print(f"Error: {result.error.message}")

    # List depots
    result = await client.depots.list()
    if result.ok:
        for depot in result.data.items:
            print(f"Depot: {depot.title} (v{depot.version})")

    await client.close()

asyncio.run(main())

Ticket Authentication

from casfa import create_casfa_client, CasfaClientConfig, TicketAuthConfig

async def process_with_ticket(ticket_id: str):
    client = create_casfa_client(CasfaClientConfig(
        base_url="https://casfa.example.com",
        auth=TicketAuthConfig(type="ticket", ticket_id=ticket_id),
    ))

    # Read nodes allowed by ticket scope
    result = await client.nodes.get(key="node:abc123...")
    if result.ok:
        data = result.data  # bytes
        # Process data...

    # Commit output
    result = await client.tickets.commit(
        ticket_id=ticket_id,
        output="node:result123...",
    )

    await client.close()

API Reference

Client Creation

from casfa import create_casfa_client, CasfaClientConfig

client = create_casfa_client(CasfaClientConfig(
    base_url="https://casfa.example.com",
    auth=auth_config,  # TokenAuthConfig, TicketAuthConfig, etc.
    realm_id="user:ABC123",  # Optional
))

API Namespaces

Namespace Description
client.oauth OAuth/Cognito authentication
client.auth AWP clients and Agent tokens
client.admin Admin user management
client.mcp MCP JSON-RPC tool calls
client.realm Realm info and usage
client.tickets Ticket management
client.depots Depot management
client.nodes Node storage operations

Result Pattern

All API methods return FetchResult[T]:

result = await client.tickets.create(...)

if result.ok:
    ticket = result.data  # TicketInfo
    print(ticket.ticket_id)
else:
    error = result.error  # CasfaError
    print(f"Error: {error.code} - {error.message}")

Authentication Types

Type Config Header
Agent Token TokenAuthConfig AgentToken {token}
Ticket TicketAuthConfig Ticket {ticketId}
User OAuth UserAuthConfig Bearer {accessToken}
P256 (AWP) P256AuthConfig X-AWP-* headers

Development

# Install dev dependencies
pip install -e ".[dev]"

# Run tests
pytest

# Type check
mypy casfa

# Lint
ruff check casfa

License

MIT

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

casfa_client-0.1.0.tar.gz (24.4 kB view details)

Uploaded Source

Built Distribution

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

casfa_client-0.1.0-py3-none-any.whl (30.1 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: casfa_client-0.1.0.tar.gz
  • Upload date:
  • Size: 24.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.12

File hashes

Hashes for casfa_client-0.1.0.tar.gz
Algorithm Hash digest
SHA256 89c8c73df56b3810dd1b2c46d3a0ab04a663dde499516150672680d5e35775d8
MD5 3c10c6883c9a17fe0ca81e081bd3adfb
BLAKE2b-256 5c60a989edc6c827ff90da2e442f4830fe6dae1d2bda54f915f0faad869e0f83

See more details on using hashes here.

File details

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

File metadata

  • Download URL: casfa_client-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 30.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.12

File hashes

Hashes for casfa_client-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 0ec5c29cbe0ec72a92a8bee3b132ea6075cc8e0a785dfa5c0fadbba30997529e
MD5 895c6a3b1b1c84935627237f38759588
BLAKE2b-256 42aea70de6eb0e0c0b64af0c1782abe1a8732fa71c69d06c69a5051922608aa9

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