kasuvia-media-client
Shared internal client for talking to kasuvia-media-system. Every Kasuvia
microservice that needs to upload/confirm/delete media goes through this
package instead of hand-rolling its own HTTP client — the goal is that a bug
in "how we auth to kasuvia-media-system" or "how we retry" is fixed in one
file, not four.
Contents
client.py—MediaSystemClient, async (httpx.AsyncClient). Use from FastAPI services:kasuvia-store-management,kasuvia-cms,kasuvia-website-builder-system.sync_client.py—SyncMediaSystemClient, sync (httpx.Client), identical method contract. Use fromkasuvia-auth(Django, coded fully synchronously).auth.py— builds theX-Internal-Serviceheader.retry.py— shared retry policy: 3 attempts, exponential backoff 1s/2s/4s, only on network failures and 502/503/504 (not on 4xx — those are permanent rejections, retrying wastes the attempt budget).exceptions.py—MediaClientErrorand subclasses (MediaUploadError,PresignedUrlExpiredError,MediaValidationError,MediaNotFoundError,MediaServiceUnavailableError), mapped from HTTP status codes.types.py— shared request/response models (PresignedUrlRequest,PresignedUrlResponse,ConfirmUploadRequest,MediaAssetResponse) and theContextconstants used across every domain.
Usage (async — FastAPI services)
from kasuvia_media_client import MediaSystemClient, PresignedUrlRequest, ConfirmUploadRequest, Context
client = MediaSystemClient(
base_url=settings.KASUVIA_MEDIA_SYSTEM_URL,
internal_service_secret=settings.INTERNAL_SERVICE_SECRET,
)
presigned = await client.get_presigned_url(
PresignedUrlRequest(
filename=file.filename,
content_type=file.content_type,
business_id=business_id,
context=Context.PRODUCT,
entity_id=product_id,
)
)
# ... client PUTs the file bytes directly to `presigned.presigned_url` ...
asset = await client.confirm_upload(
ConfirmUploadRequest(
storage_path=presigned.storage_path,
business_id=business_id,
original_filename=file.filename,
content_type=file.content_type,
size=file_size,
context=Context.PRODUCT,
entity_id=product_id,
)
)
Usage (sync — kasuvia-auth / Django)
Same shapes, no await:
from kasuvia_media_client import SyncMediaSystemClient, PresignedUrlRequest, Context
client = SyncMediaSystemClient(
base_url=settings.KASUVIA_MEDIA_SYSTEM_URL,
internal_service_secret=settings.INTERNAL_SERVICE_SECRET,
)
presigned = client.get_presigned_url(
PresignedUrlRequest(
filename=filename,
content_type=content_type,
business_id=business_id,
context=Context.USER_AVATAR,
entity_id=user_id,
)
)
Development
pip install -e ".[test]"
pytest
Metadata
Release files for kasuvia-media-client 0.1.0
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 | |
|---|---|---|---|---|
| kasuvia_media_client-0.1.0.tar.gz | 19.9 kB | Without provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| kasuvia_media_client-0.1.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 32.9 kB
Release files / kasuvia_media_client-0.1.0.tar.gz
| Download URL | kasuvia_media_client-0.1.0.tar.gz |
|---|---|
| Size | 19.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
6faf5fb4784df884570972eb54442b7c9b9eb5b87e15cec0d56f126bb6cfba5b
|
|
BLAKE2b-256 checksum How to use checksums |
e2b65313848edd0eadf766197b8f8e22e7078041ccc16e24f58e5369888b6693
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Release files / kasuvia_media_client-0.1.0-py3-none-any.whl
| Download URL | kasuvia_media_client-0.1.0-py3-none-any.whl |
|---|---|
| Size | 13.0 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
d30f8b285e8af8de0c35ebe5aadbcd7ee73ce7a8ab5c98292b78f5b8560cda37
|
|
BLAKE2b-256 checksum How to use checksums |
43fea22e8fbdad90fb807dda6387f5ff8ef385ea114b6811b98f45ec1fac5868
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Security for kasuvia-media-client 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.