Skip to main content

TTL-LAMa Python SDK

This synchronous client supports TTL-LAMa API v1 authentication, users, devices, profiles and leases. It does not depend on the CLI. Global configuration and web routes are outside its scope.

See README.fr.md for the French guide.

Install

Use Python 3.12 or newer in a virtual environment:

python -m pip install ./sdk/python

From the SDK repository root, install the development dependencies with python -m pip install -e './python[test]' and run python -m pytest python/tests.

Usage

from getpass import getpass
from ttlama_sdk import TTLLama

with TTLLama("https://ttl-lama.example") as ttl:
    ttl.login("admin", getpass("Password: "))
    user = ttl.user.get("USER_UUID")
    ttl.user.assign_profile(user["id"], 1)
    ttl.auth.logout()

Alternatively, pass an existing token with TTLLama(url, token=token). Internal login handles the CSRF token and associated cookie, then uses a Bearer token. The token remains in memory and is available as ttl.token; callers must keep it secret. Closing the client does not revoke the session. Logout revokes the current session; changing the password revokes all of the user's sessions.

Administrator operations are available on ttl.user, ttl.device, ttl.lease, and ttl.profile. The current user's account and resources are available on ttl.me, ttl.me.devices, and ttl.me.leases. List methods accept API filters as keyword arguments. Create and update methods accept API fields as keyword arguments. Results are JSON dictionaries or lists, and 204 responses return None. User creation without a supplied password in internal mode returns user and generated_password; an explicitly supplied password is not returned.

For OIDC device authorization, use ttl.auth.oidc_device() and poll with ttl.auth.oidc_poll(device_code) at the provider's interval. Increase the interval for slow_down; denied and expired end the flow. A completed poll stores the token automatically. ttl.auth.oidc_exchange(ticket) exchanges a one-time CLI ticket. The application is responsible for displaying the user code and verification URL, opening a browser if needed, and polling.

Register only the client's WireGuard public key. Keep the private key local and fill the returned configuration template locally. Destination filtering by profile requires appropriate external network configuration.

Errors inherit from TTLamaError. APIError exposes status_code and an optional lease_id; HTTP 400, 401, 403, 404, 409 and 503 map to ValidationError, AuthenticationError, AuthorizationError, NotFoundError, ConflictError and ProvisioningError. Default timeouts are 5 seconds for ordinary requests and 60 seconds for lease provisioning; configure them using timeout and lease_timeout. Mutations are never retried automatically: after a timeout or 503, inspect the lease state before retrying.

Metadata

Release files for ttlama-sdk 0.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for ttlama-sdk 0.1.0
File Size Uploaded Provenance Actions
ttlama_sdk-0.1.0.tar.gz 13.1 kB Without provenance Details for ttlama_sdk-0.1.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for ttlama-sdk 0.1.0
File Interpreter ABI Platform Actions
ttlama_sdk-0.1.0-py3-none-any.whl Python 3 none any Details for ttlama_sdk-0.1.0-py3-none-any.whl

Total release size: 21.3 kB

Release files / ttlama_sdk-0.1.0.tar.gz

Download URL ttlama_sdk-0.1.0.tar.gz
Size 13.1 kB
Tags Source
SHA-256 checksum
How to use checksums
4526395361beb0e175870ed328580e980bedb3fc826d436c3e874e94c9aa9153
BLAKE2b-256 checksum
How to use checksums
f49076b7efbc2f5d8c60ff5580c6065a56ac5a72b766bf946d66c02bdc66d7a5
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.14.10

Release files / ttlama_sdk-0.1.0-py3-none-any.whl

Download URL ttlama_sdk-0.1.0-py3-none-any.whl
Size 8.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
53e3b321ffc4b2f0fceefa27c493ad4cf0f8da5dbd45079dd7e1845050185a6c
BLAKE2b-256 checksum
How to use checksums
e8d48aa8796769c67b60fa6c87fb55efef042334abe3ca31f9d5a14f95f14c3b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.14.10

Security for ttlama-sdk 0.1.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page