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.1.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.1-py3-none-any.whl (19.8 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: openbucket_client-0.1.1.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.1.tar.gz
Algorithm Hash digest
SHA256 bcbb2c7396a0fa6464105e1ad62e7be8ebb52239041d5fb9be97ad849048a47a
MD5 eac0b8666ba6f2841ae6b57558bc55f4
BLAKE2b-256 d8a04aab6ea2f5aeabc782f75e676d829afc507139968936e46b666d184d1e97

See more details on using hashes here.

Provenance

The following attestation bundles were made for openbucket_client-0.1.1.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.1-py3-none-any.whl.

File metadata

File hashes

Hashes for openbucket_client-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 db309f14a71a0a41976feb746cc921f9db146aa060a53e5a42f187cbbe1c5136
MD5 661f13e520d46e28b2a44b2073185665
BLAKE2b-256 7844b5f6dda1612d902ac25764b3afeff6fbac28d52e6ff241889eb234f64a2d

See more details on using hashes here.

Provenance

The following attestation bundles were made for openbucket_client-0.1.1-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