Skip to main content

Typed, dependency-free Python client for the OpenBucket management API

Project description

OpenBucket Python client

openbucket-client is the typed, dependency-free Python client for a running OpenBucket management API. It supports Python 3.10+ and uses only the standard library at runtime.

This package is a client, not a Python implementation of the OpenBucket daemon. Start the OpenBucket daemon separately, then point this client at its management URL. Object data is stored and served by that daemon.

Install

openbucket-client is not on PyPI yet. Install it from a checked-out OpenBucket repository:

python -m pip install ./python

After the first unified 0.1.1 release is visible on PyPI:

python -m pip install openbucket-client==0.1.1
pipx install openbucket-client==0.1.1
# or
uv tool install openbucket-client==0.1.1

The distribution is named openbucket-client; the import package is openbucket.

Python API

import os

from openbucket import OpenBucketClient

client = OpenBucketClient(
    os.environ.get("OPENBUCKET_API_URL", "http://127.0.0.1:7272"),
    os.environ["OPENBUCKET_ADMIN_TOKEN"],
)

print(client.status().storage.free_bytes)

bucket = client.create_bucket("project-assets")
uploaded = client.upload_file(
    bucket.name,
    "images/logo.svg",
    "logo.svg",
    content_type="image/svg+xml",
)
print(uploaded.etag)

share = client.create_share(bucket.name, uploaded.key, expires_in=3600)
print(share.url)

The client exposes immutable typed models and methods for:

  • daemon health, status, endpoints, and client configuration;
  • bucket creation, visibility, listing, and deletion;
  • object listing, streaming upload, download, metadata, and deletion;
  • S3 access-key creation, listing, and revocation;
  • expiring share URL creation;
  • request logs, analytics, and graceful daemon stop.

upload_file() streams from disk. download_to() streams to disk, uses an exclusive create by default, and can atomically replace a destination with overwrite=True. download_object() returns bytes and accepts max_bytes when the caller needs a memory safety bound.

Error handling

from openbucket import OpenBucketHTTPError

try:
    client.create_bucket("already-present")
except OpenBucketHTTPError as error:
    print(error.status)      # 409
    print(error.code)        # BucketAlreadyExists
    print(error.request_id)  # request correlation ID, when provided

Transport, protocol, configuration, and HTTP failures have separate exception types. The client does not follow redirects, preventing a management bearer token from being forwarded to another origin.

Command line

Set credentials in the environment so the token does not appear in shell history or the process list:

export OPENBUCKET_API_URL=http://127.0.0.1:7272
export OPENBUCKET_ADMIN_TOKEN='replace-with-the-daemon-token'

openbucket-client status
openbucket-client buckets list
openbucket-client buckets create project-assets
openbucket-client objects upload project-assets images/logo.svg ./logo.svg
openbucket-client objects download project-assets images/logo.svg ./downloaded.svg
openbucket-client share project-assets images/logo.svg --expires-in 3600
openbucket-client --json analytics

Use openbucket-client --help for the complete command tree. --token exists for automation environments that cannot inject variables, but the environment variable is safer for interactive use.

TLS and remote use

Use an HTTPS management URL for any connection that leaves localhost or a trusted private network. The bearer token grants full management access. Do not embed it in browser code, logs, container images, or source control. Python uses the platform/default CA trust store and honors the standard proxy environment variables.

Development and verification

The test suite performs real loopback HTTP requests against a threaded local HTTP server; it does not patch or mock urllib.

cd python
python -m unittest discover -s tests -v
python -m pip install -e '.[dev]'
ruff check .
mypy src/openbucket
python -m build
twine check dist/*
python -m pip install --force-reinstall dist/openbucket_client-0.1.1-py3-none-any.whl
openbucket-client --version

tox verifies the built wheel on every locally installed Python version from 3.10 through 3.14:

tox

Licensed under Apache-2.0. See LICENSE.

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

openbucket_client-0.1.5.tar.gz (22.3 kB view details)

Uploaded Source

Built Distribution

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

openbucket_client-0.1.5-py3-none-any.whl (19.8 kB view details)

Uploaded Python 3

File details

Details for the file openbucket_client-0.1.5.tar.gz.

File metadata

  • Download URL: openbucket_client-0.1.5.tar.gz
  • Upload date:
  • Size: 22.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.13

File hashes

Hashes for openbucket_client-0.1.5.tar.gz
Algorithm Hash digest
SHA256 c6507ce8599e97db06d2fe33d9ad901a096c5f560e15c94042f81fc20afee7cb
MD5 7db41c604fa3327558d12de32b2453fb
BLAKE2b-256 5c1ffbea725f6cb0eeee46cc4355491342ccfadbe6bbd8d74e6af2fbda05b788

See more details on using hashes here.

Provenance

The following attestation bundles were made for openbucket_client-0.1.5.tar.gz:

Publisher: release.yml on Razin-developer/openbucket

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

File details

Details for the file openbucket_client-0.1.5-py3-none-any.whl.

File metadata

File hashes

Hashes for openbucket_client-0.1.5-py3-none-any.whl
Algorithm Hash digest
SHA256 40bbbe9191b596788b254cfedc6db39adf38f62fb1bf9e176102a4a9c63d048f
MD5 a0c9536881bf4af685ed06f9dcc14400
BLAKE2b-256 e293892383761502f01320b1e9f1b44d0f68bddb0a6d7676b75122bf66c4fe62

See more details on using hashes here.

Provenance

The following attestation bundles were made for openbucket_client-0.1.5-py3-none-any.whl:

Publisher: release.yml on Razin-developer/openbucket

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