depot-client
Python client library for Depot. Provides both synchronous and asynchronous APIs through an intuitive Pythonic interface.
Installation
pip install depot-client
Usage
Basic Example
from depot_client import Client
with Client(token=DEPOT_API_TOKEN) as client:
# Create a project
project = client.create_project(
name="my-project",
region_id="us-east-1"
)
# Create a build
with client.create_endpoint(project_id=project.project_id) as endpoint:
# Write certificates to files
with open("client.crt", "w") as f:
f.write(endpoint.cert)
with open("client.key", "w") as f:
f.write(endpoint.key)
with open("ca.crt", "w") as f:
f.write(endpoint.ca_cert)
# Use with buildctl:
# buildctl --addr endpoint.endpoint \
# --tlsservername endpoint.server_name \
# --tlscacert ca.crt \
# --tlscert client.crt \
# --tlskey client.key \
# build --frontend dockerfile.v0
Async Support
The library provides async versions of all operations:
from depot_client import AsyncClient
import aiofiles
async with AsyncClient(token=DEPOT_API_TOKEN) as client:
async with await client.create_endpoint(project_id=PROJECT_ID) as endpoint:
# Write certificates to files
async with aiofiles.open("client.crt", "w") as f:
await f.write(endpoint.cert)
async with aiofiles.open("client.key", "w") as f:
await f.write(endpoint.key)
async with aiofiles.open("ca.crt", "w") as f:
await f.write(endpoint.ca_cert)
# Use with buildctl:
# buildctl --addr endpoint.endpoint \
# --tlsservername endpoint.server_name \
# --tlscacert ca.crt \
# --tlscert client.crt \
# --tlskey client.key \
# build --frontend dockerfile.v0
Project Operations
# List projects
projects = client.list_projects()
# Create and manage tokens
token = client.create_token(
project_id=project.project_id,
description="CI/CD token"
)
# Configure trust policies
policy = client.add_trust_policy(
project_id=project.project_id,
github={
"repository_owner": "org",
"repository": "repo"
}
)
Build Operations
# Create and track builds
build = client.create_build(project_id=PROJECT_ID)
# Get a shareable URL for the build
share_url = client.share_build(build.build_id)
# List project builds
builds = client.list_builds(project_id=PROJECT_ID)
Features
- Pythonic interface to Depot's API
- Context manager support for proper resource cleanup
- Full async/await support using
AsyncClient - Type hints throughout for better IDE integration
- Automatic handling of BuildKit endpoint lifecycle
- Comprehensive error handling
API Reference
Client Methods
Project Operations
list_projects() -> List[ProjectInfo]: List all available projectscreate_project(name: str, region_id: str) -> ProjectInfo: Create a new projectget_project(project_id: str) -> ProjectInfo: Get project detailsdelete_project(project_id: str) -> None: Delete a projectreset_project(project_id: str) -> None: Reset project state
Token Management
list_tokens(project_id: str) -> List[TokenInfo]: List project tokenscreate_token(project_id: str, description: str) -> TokenCreationInfo: Create new tokenupdate_token(token_id: str, description: str) -> None: Update token descriptiondelete_token(token_id: str) -> None: Delete token
Trust Policies
list_trust_policies(project_id: str) -> List[TrustPolicy]: List trust policiesadd_trust_policy(project_id: str, github: Optional[dict] = None, circleci: Optional[dict] = None, buildkite: Optional[dict] = None) -> TrustPolicy: Add trust policyremove_trust_policy(project_id: str, trust_policy_id: str) -> None: Remove trust policy
Build Operations
create_build(project_id: str) -> Build: Create new buildfinish_build(build_id: str, error: Optional[str] = None) -> None: Complete buildshare_build(build_id: str) -> str: Create a shareable URL for the buildstop_sharing_build(build_id: str) -> None: Revoke the shareable URL for the buildget_build(build_id: str) -> BuildInfo: Get build infolist_builds(project_id: str) -> List[BuildInfo]: List project builds
BuildKit Integration
create_endpoint(project_id: str, platform: Optional[str] = None) -> Endpoint: Create a BuildKit endpoint
Environment Variables
DEPOT_API_TOKEN: Your Depot API token for authentication
Development
# Install development dependencies
pip install -e ".[test]"
# Run tests
pytest
# Build package
make build
# Generate API bindings
make protos
make api
License
Apache License 2.0
Metadata
Release files for depot-client 0.0.22
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| depot_client-0.0.22.tar.gz | 28.5 kB | Without provenance | Details for depot_client-0.0.22.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| depot_client-0.0.22-py3-none-any.whl | Python 3 | none | any | Details for depot_client-0.0.22-py3-none-any.whl |
Total release size: 61.4 kB
Release files / depot_client-0.0.22.tar.gz
| Download URL | depot_client-0.0.22.tar.gz |
|---|---|
| Size | 28.5 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
04597445785a17089851327f6f340a68b4f56cd60a95372de2c11addceb67261
|
|
BLAKE2b-256 checksum How to use checksums |
8c7a59ec28f221ad551ed8fd536d3eec7caf31971729b8369aed85026a3fc536
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.11.9
|
Release files / depot_client-0.0.22-py3-none-any.whl
| Download URL | depot_client-0.0.22-py3-none-any.whl |
|---|---|
| Size | 33.0 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
0aad6cc3e9134479de4b57773fae17c004655be431a0eb020d4f5d2dc0961408
|
|
BLAKE2b-256 checksum How to use checksums |
6869627c2790f850855cb02c355f2cc3f824bb830a11c3e41ba9b41b84b0e76e
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.11.9
|
Security for depot-client 0.0.22
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.