Attachment#
- class nominal.core.Attachment(rid: str, name: str, description: str, properties: Mapping[str, str], labels: Sequence[str], created_at: IntegralNanosecondsUTC, is_archived: bool)#
Bases:
HasRid,RefreshableGrpcMixin[Attachment]An uploaded file that can be attached to assets or runs.
- created_at: IntegralNanosecondsUTC#
- archive() None#
Archive this attachment. Archived attachments are not deleted, but are hidden from the UI.
Refreshes this instance from the update response without an additional fetch.
- Raises:
NominalError – If the archive request fails.
- get_contents() BinaryIO#
Retrieve the contents of this attachment. Returns a file-like object in binary mode for reading.
The contents are streamed from object storage through a short-lived presigned URI, the same storage that attachment uploads are written to. Close the returned stream when finished, e.g. with a
withblock.- Raises:
NominalError – If the download URI cannot be retrieved.
requests.RequestException – If downloading the contents fails.
- unarchive() None#
Unarchive this attachment, allowing it to be viewed in the UI.
Refreshes this instance from the update response without an additional fetch.
- Raises:
NominalError – If the unarchive request fails.
- update(*, name: str | None = None, description: str | None = None, properties: Mapping[str, str] | None = None, labels: Sequence[str] | None = None, is_archived: bool | None = None) Self#
Replace attachment metadata. Updates the current instance, and returns it.
None leaves a field unchanged. Updates refresh this instance from the response; when no fields are supplied, fetch the latest attachment instead.
- Parameters:
name – Replacement name.
description – Replacement description. An empty string clears it.
properties – Replacement properties. An empty mapping clears them.
labels – Replacement labels. An empty sequence clears them.
is_archived – True archives the attachment; False restores it.
- Returns:
This instance with refreshed metadata.
Note
This replaces the metadata rather than appending it. To append to labels or properties, merge them before calling this method. E.g.:
new_labels = ["new-label-a", "new-label-b", *attachment.labels] attachment = attachment.update(labels=new_labels)
- Raises:
NominalError – If the update request fails.