Skip to main content

Python SDK for the Driftstone API.

Project description

Driftstone - Python

Python SDK for the Driftstone repository API.

Install

pip install driftstone

Quick Start

from driftstone import Driftstone

client = Driftstone(api_key="your-api-key")

repo = client.repos.create(
    "hello-world",
)

upload = client.repos.create_upload(
    "hello-world",
    storage_dir="ver-1234abcd",
    branch="main",
    files=[{"name": "README.md", "hash": "64-character-sha256-or-client-hash"}],
)

# Upload each file to the returned signed URL with PUT and
# Content-Type: application/octet-stream.
for upload_url in upload.upload_urls:
    print(upload_url.name, upload_url.url)

client.repos.complete_upload("hello-world", upload.upload_id)

download = client.repos.create_download(
    "hello-world",
    type="main",
    files=[{"path": "ver-1234abcd/README.md"}],
)

for download_url in download.download_urls:
    print(download_url.path, download_url.url)

branch = client.repos.create_branch(
    "hello-world",
    "feature-readme",
    storage_dir="state-123",
    transforms={"README.md": "# Example Repo\nUpdated content.\n"},
)

empty_branch = client.repos.create_branch(
    "hello-world",
    "empty-feature",
    derive_from_main=False,
)

branch_upload = client.repos.create_upload(
    "hello-world",
    storage_dir="state-456",
    branch=branch.name,
    files=[{"name": "README.md", "hash": "64-character-sha256-or-client-hash"}],
)
client.repos.complete_upload("hello-world", branch_upload.upload_id)

print(repo.id, branch.name)

Using A Context Manager

from driftstone import Driftstone

with Driftstone(api_key="your-api-key") as client:
    repo = client.repos.get("hello-world")
    branches = client.repos.list_branches(repo.slug)

    print(repo.name, [branch.name for branch in branches])

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

driftstone-1.2.0.tar.gz (8.8 kB view details)

Uploaded Source

Built Distribution

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

driftstone-1.2.0-py3-none-any.whl (12.5 kB view details)

Uploaded Python 3

File details

Details for the file driftstone-1.2.0.tar.gz.

File metadata

  • Download URL: driftstone-1.2.0.tar.gz
  • Upload date:
  • Size: 8.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.7.6

File hashes

Hashes for driftstone-1.2.0.tar.gz
Algorithm Hash digest
SHA256 c646a1b5c9cbaafad0b4dd7ed87119100fc60e09a9c4363292d7ad04a9e0c316
MD5 47527825bfa188535f7dccd8421d5e69
BLAKE2b-256 fb58ca2867f9d6cd487c40f6bd4d3dbf017586faa6277bd8526fdb0a5c725e33

See more details on using hashes here.

File details

Details for the file driftstone-1.2.0-py3-none-any.whl.

File metadata

  • Download URL: driftstone-1.2.0-py3-none-any.whl
  • Upload date:
  • Size: 12.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.7.6

File hashes

Hashes for driftstone-1.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 acffa751c75a3575c6600118d0042b79d82f17e4c0e75b62fbf58bef7440e9ba
MD5 67f1e7909642bb2fb50d8f3350c6484b
BLAKE2b-256 6d4ce36c5206ed9ff60b39d19fd1c18714735fb6a5b26c0817c3e4cb83409d43

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