Assets¶
Accessed via client.assets.
pycomad.client.AssetsClient
¶
Methods for the /assets resource.
list
¶
Return all assets visible to the authenticated user.
Returns:
| Type | Description |
|---|---|
List[Asset]
|
List of :class: |
Raises:
| Type | Description |
|---|---|
ComadAuthError
|
If not authenticated. |
create
¶
create(name: str, asset_type: str, *, description: Optional[str] = None, caption: Optional[str] = None, keywords: Optional[str] = None, creator: Optional[str] = None, copyright_notice: Optional[str] = None, available: Optional[bool] = None, available_until: Optional[datetime] = None, is_locked: Optional[bool] = None, is_private: Optional[bool] = None, public_read: Optional[bool] = None, public_download: Optional[bool] = None, public_write: Optional[bool] = None, team_id: Optional[str] = None, custom_fields: Optional[Dict[str, Any]] = None) -> Asset
Create an asset record without uploading a file.
Use :meth:upload to create an asset and upload the file in one step.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
Asset name. |
required |
asset_type
|
str
|
MIME type (e.g. |
required |
description
|
Optional[str]
|
Free-text description. |
None
|
caption
|
Optional[str]
|
Display caption. |
None
|
keywords
|
Optional[str]
|
Comma-separated keywords. |
None
|
creator
|
Optional[str]
|
Author / creator name. |
None
|
copyright_notice
|
Optional[str]
|
Copyright string. |
None
|
available
|
Optional[bool]
|
Whether the asset is publicly available (default |
None
|
available_until
|
Optional[datetime]
|
Expiry datetime; the asset becomes unavailable after this. |
None
|
is_locked
|
Optional[bool]
|
Locked assets cannot be deleted (default |
None
|
is_private
|
Optional[bool]
|
Private to the uploader (default |
None
|
public_read
|
Optional[bool]
|
Allow unauthenticated read (default |
None
|
public_download
|
Optional[bool]
|
Allow unauthenticated download (default |
None
|
public_write
|
Optional[bool]
|
Allow unauthenticated write (default |
None
|
team_id
|
Optional[str]
|
Team to assign this asset to. |
None
|
custom_fields
|
Optional[Dict[str, Any]]
|
Arbitrary key/value pairs for team-defined custom fields. |
None
|
Returns:
| Type | Description |
|---|---|
Asset
|
The newly created :class: |
Raises:
| Type | Description |
|---|---|
ComadAuthError
|
If not authenticated. |
ComadValidationError
|
On a 400 response. |
upload
¶
upload(file: FileArg, *, name: Optional[str] = None, asset_type: Optional[str] = None, description: Optional[str] = None, caption: Optional[str] = None, keywords: Optional[str] = None, creator: Optional[str] = None, copyright_notice: Optional[str] = None, available: Optional[bool] = None, available_until: Optional[datetime] = None, is_locked: Optional[bool] = None, is_private: Optional[bool] = None, public_read: Optional[bool] = None, public_download: Optional[bool] = None, public_write: Optional[bool] = None, team_id: Optional[str] = None, custom_fields: Optional[Dict[str, Any]] = None) -> Asset
Create an asset record and upload the file in a single request.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
file
|
FileArg
|
File to upload — a path string, :class: |
required |
name
|
Optional[str]
|
Asset name; defaults to the filename if omitted. |
None
|
asset_type
|
Optional[str]
|
MIME type; inferred from the file extension if omitted. |
None
|
description
|
Optional[str]
|
Free-text description. |
None
|
caption
|
Optional[str]
|
Display caption. |
None
|
keywords
|
Optional[str]
|
Comma-separated keywords. |
None
|
creator
|
Optional[str]
|
Author / creator name. |
None
|
copyright_notice
|
Optional[str]
|
Copyright string. |
None
|
available
|
Optional[bool]
|
Whether the asset is publicly available (default |
None
|
available_until
|
Optional[datetime]
|
Expiry datetime (timezone-aware recommended). |
None
|
is_locked
|
Optional[bool]
|
Locked assets cannot be deleted (default |
None
|
is_private
|
Optional[bool]
|
Private to the uploader (default |
None
|
public_read
|
Optional[bool]
|
Allow unauthenticated read (default |
None
|
public_download
|
Optional[bool]
|
Allow unauthenticated download (default |
None
|
public_write
|
Optional[bool]
|
Allow unauthenticated write (default |
None
|
team_id
|
Optional[str]
|
Team to assign this asset to. |
None
|
custom_fields
|
Optional[Dict[str, Any]]
|
Arbitrary key/value pairs for team-defined custom fields. |
None
|
Returns:
| Type | Description |
|---|---|
Asset
|
The newly created :class: |
Raises:
| Type | Description |
|---|---|
ComadAuthError
|
If not authenticated. |
ComadValidationError
|
On a 400 response (e.g. missing required file). |
get
¶
Fetch an asset with its associated categories.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
asset_id
|
Union[UUID, str]
|
UUID of the asset. |
required |
Returns:
| Type | Description |
|---|---|
AssetWithCategories
|
class: |
Raises:
| Type | Description |
|---|---|
ComadNotFoundError
|
If the asset does not exist. |
ComadAuthError
|
If not authenticated. |
update
¶
update(asset_id: Union[UUID, str], *, name: Optional[str] = None, asset_type: Optional[str] = None, description: Optional[str] = None, caption: Optional[str] = None, keywords: Optional[str] = None, creator: Optional[str] = None, copyright_notice: Optional[str] = None, available: Optional[bool] = None, available_until: Optional[datetime] = None, is_locked: Optional[bool] = None, is_private: Optional[bool] = None, public_read: Optional[bool] = None, public_download: Optional[bool] = None, public_write: Optional[bool] = None, team_id: Optional[str] = None, custom_fields: Optional[Dict[str, Any]] = None) -> Asset
Update asset metadata; only supplied fields are changed.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
asset_id
|
Union[UUID, str]
|
UUID of the asset to update. |
required |
name
|
Optional[str]
|
New name. |
None
|
asset_type
|
Optional[str]
|
New MIME type. |
None
|
description
|
Optional[str]
|
New description. |
None
|
caption
|
Optional[str]
|
New caption. |
None
|
keywords
|
Optional[str]
|
New keywords. |
None
|
creator
|
Optional[str]
|
New creator. |
None
|
copyright_notice
|
Optional[str]
|
New copyright notice. |
None
|
available
|
Optional[bool]
|
New availability flag. |
None
|
available_until
|
Optional[datetime]
|
New expiry datetime. |
None
|
is_locked
|
Optional[bool]
|
New locked flag. |
None
|
is_private
|
Optional[bool]
|
New private flag. |
None
|
public_read
|
Optional[bool]
|
New public-read flag. |
None
|
public_download
|
Optional[bool]
|
New public-download flag. |
None
|
public_write
|
Optional[bool]
|
New public-write flag. |
None
|
team_id
|
Optional[str]
|
Reassign to a different team. |
None
|
custom_fields
|
Optional[Dict[str, Any]]
|
New custom field values (replaces existing). |
None
|
Returns:
| Type | Description |
|---|---|
Asset
|
The updated :class: |
Raises:
| Type | Description |
|---|---|
ComadNotFoundError
|
If the asset does not exist. |
ComadAuthError
|
If not authenticated. |
delete
¶
Delete an asset and remove its file from storage.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
asset_id
|
Union[UUID, str]
|
UUID of the asset to delete. |
required |
Raises:
| Type | Description |
|---|---|
ComadAuthError
|
If not authenticated or the asset is locked (403). |
ComadNotFoundError
|
If the asset does not exist. |
upload_file
¶
Upload (or replace) the file attached to an existing asset record.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
asset_id
|
Union[UUID, str]
|
UUID of the asset. |
required |
file
|
FileArg
|
File to upload — a path string, :class: |
required |
Returns:
| Type | Description |
|---|---|
Asset
|
The updated :class: |
Raises:
| Type | Description |
|---|---|
ComadNotFoundError
|
If the asset does not exist. |
ComadAuthError
|
If not authenticated. |
download
¶
Download the raw file bytes for an asset.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
asset_id
|
Union[UUID, str]
|
UUID of the asset. |
required |
Returns:
| Type | Description |
|---|---|
bytes
|
Raw file bytes. |
Raises:
| Type | Description |
|---|---|
ComadNotFoundError
|
If the asset does not exist. |
ComadAuthError
|
If not authenticated. |
thumbnail
¶
Fetch a thumbnail for an asset.
For images, PDFs, and Office/iWork documents, returns a PNG image. For all other types, returns an SVG icon.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
asset_id
|
Union[UUID, str]
|
UUID of the asset. |
required |
Returns:
| Type | Description |
|---|---|
bytes
|
Raw image bytes (PNG or SVG). |
Raises:
| Type | Description |
|---|---|
ComadNotFoundError
|
If the asset does not exist. |
ComadAuthError
|
If not authenticated. |
add_category
¶
Add a category to an asset.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
asset_id
|
Union[UUID, str]
|
UUID of the asset. |
required |
category_id
|
Union[UUID, str]
|
UUID of the category to add. |
required |
Raises:
| Type | Description |
|---|---|
ComadAuthError
|
If not authenticated. |
remove_category
¶
Remove a category from an asset.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
asset_id
|
Union[UUID, str]
|
UUID of the asset. |
required |
category_id
|
Union[UUID, str]
|
UUID of the category to remove. |
required |
Raises:
| Type | Description |
|---|---|
ComadAuthError
|
If not authenticated. |
usage
¶
Return current storage usage and plan limits for the authenticated user.
Returns:
| Type | Description |
|---|---|
UsageSummary
|
class: |
Raises:
| Type | Description |
|---|---|
ComadAuthError
|
If not authenticated or the user has no DAM access. |