Python client library for the Comad DAM (Digital Asset Management) API
Project description
pycomad
Python client library for the Comad DAM (Digital Asset Management) API.
Installation
pip install pycomad
Quick start
from pycomad import ComadClient
client = ComadClient(
api_url="http://localhost:8080",
auth_url="http://localhost:8081", # ullav-user-management service
)
client.login(email="user@example.com", password="secret")
# Upload a file (creates the record and uploads in one step)
asset = client.assets.upload("photo.jpg", creator="alice", is_private=False)
# Or create a record first, then upload the file
record = client.assets.create("Report", "application/pdf")
client.assets.upload_file(record.id, "report.pdf")
# Download and thumbnail
raw_bytes = client.assets.download(asset.id)
thumb_png = client.assets.thumbnail(asset.id)
# Categories
cat = client.categories.create("Architecture", access_level="Global")
client.assets.add_category(asset.id, cat.id)
detail = client.assets.get(asset.id) # AssetWithCategories
# Search
results = client.search.search(q="photo", creator="alice")
nearby = client.search.nearby(lat=53.3, lon=-6.2, radius_km=5)
# Metadata (EXIF / IPTC / XMP)
meta = client.metadata.get(asset.id)
if meta.exif:
print(meta.exif.get("camera_make"))
# Usage quotas
usage = client.assets.usage()
print(f"{usage.asset_count} assets, {usage.used_bytes // 1024**2} MB used")
# ZIP batch import
result = client.zip.upload("photos.zip", creator="alice")
print(f"Imported {len(result.assets)} assets into {len(result.categories)} categories")
Example: upload a file
Print asset details after uploading a local file:
import os
from pycomad import ComadClient
client = ComadClient(
api_url=os.environ["COMAD_API_URL"],
auth_url=os.environ.get("COMAD_AUTH_URL", os.environ["COMAD_API_URL"]),
)
client.login(email=os.environ["COMAD_EMAIL"], password=os.environ["COMAD_PASSWORD"])
asset = client.assets.upload("photo.jpg", creator="alice")
print(f"{asset.name} ({asset.asset_type}, {asset.size:,} bytes) id={asset.id}")
A runnable version of this script is at examples/upload_asset.py.
Authentication
ComadClient authenticates against the ullav-user-management service, which
issues the JWT accepted by the Comad DAM server.
api_url— Comad DAM server base URL (e.g.http://comad-server:8080)auth_url— auth service base URL (e.g.http://ullav-user-management:8081); omit if both services are behind the same proxy
Call client.login(email, password) before any other method. Tokens expire
according to the server's configuration; call login() again to refresh.
Resource clients
| Attribute | Resource |
|---|---|
client.assets |
Asset CRUD, file upload/download/thumbnail, category links, usage |
client.metadata |
EXIF/IPTC/XMP metadata get and refresh |
client.search |
Full-text and metadata-driven search, geo search |
client.categories |
Category CRUD (hierarchical tree) |
client.custom_field_schemas |
Team custom field schema CRUD |
client.zip |
ZIP batch import |
File uploads
client.assets.upload() and client.assets.upload_file() accept:
- A file path as a
strorpathlib.Path - An already-open binary file object (
IO[bytes])
The MIME type is inferred from the file extension if asset_type is omitted.
Error handling
from pycomad import ComadAuthError, ComadNotFoundError, ComadValidationError
try:
asset = client.assets.get("non-existent-id")
except ComadNotFoundError:
print("not found")
except ComadAuthError:
client.login(email, password) # token expired — re-authenticate
except ComadValidationError as e:
print("bad request:", e)
| Exception | HTTP status |
|---|---|
ComadAuthError |
401 / 403, or login() not called |
ComadNotFoundError |
404 |
ComadValidationError |
400 |
ComadServerError |
5xx |
ComadError |
base class |
Access levels
Use the AccessLevel enumeration or plain strings when creating categories:
from pycomad import AccessLevel
client.categories.create("Press", access_level=AccessLevel.GLOBAL)
client.categories.create("Internal", access_level="Private") # equivalent
Licence
MIT
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file pycomad-0.1.0.tar.gz.
File metadata
- Download URL: pycomad-0.1.0.tar.gz
- Upload date:
- Size: 21.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ae07bd551f30c25fa5552b527bb3dea102e949e520c1af4b18ffc892330bfec5
|
|
| MD5 |
99ab634a39051db3c19baef90c8eb5af
|
|
| BLAKE2b-256 |
1f4a51aa58920135443f847a0aeca8b33143fc406bd194112664d6c65b704d3d
|
File details
Details for the file pycomad-0.1.0-py3-none-any.whl.
File metadata
- Download URL: pycomad-0.1.0-py3-none-any.whl
- Upload date:
- Size: 15.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
5636477f655b72cbe1b4896cce148317c2e597b50362da0bfe61f4ea4c345ae2
|
|
| MD5 |
af1913ce03cb61e1bb86b4640a36764e
|
|
| BLAKE2b-256 |
39fd21e0106062df31e1b25ca2f113f5e850c2c587b3dab23338f1f240c23259
|