ComadClient¶
The top-level client. Instantiate once, call login(), then access resources through the sub-client attributes.
pycomad.ComadClient
¶
Client for the Comad Digital Asset Management (DAM) REST API.
Authentication is handled by the ullav-user-management service.
Call :meth:login before making any API requests; a
:exc:~pycomad.exceptions.ComadAuthError will be raised otherwise.
The JWT is stored in the session and attached to every subsequent
request automatically. Tokens expire according to the server's
configuration; call :meth:login again to refresh.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
api_url
|
str
|
Base URL of the Comad DAM server, e.g. |
required |
auth_url
|
Optional[str]
|
Base URL of the authentication service,
e.g. |
None
|
Example
.. code-block:: python
from pycomad import ComadClient
client = ComadClient(
api_url="http://localhost:8080",
auth_url="http://localhost:8081",
)
client.login(email="user@example.com", password="secret")
# Upload a file
asset = client.assets.upload("photo.jpg", creator="colin")
# Search by location
results = client.search.nearby(lat=53.3, lon=-6.2, radius_km=5)
# Categories
cats = client.categories.list()
cat = client.categories.create("Architecture", access_level="Global")
client.assets.add_category(asset.id, cat.id)
# Usage
usage = client.assets.usage()
print(f"{usage.asset_count} assets, {usage.used_bytes // 1024**2} MB used")
login
¶
Authenticate and store the JWT for subsequent requests.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
email
|
str
|
User email address. |
required |
password
|
str
|
User password. |
required |
Returns:
| Type | Description |
|---|---|
LoginInfo
|
class: |
LoginInfo
|
details, roles, and permissions. |
Raises:
| Type | Description |
|---|---|
ComadAuthError
|
If the credentials are invalid. |