Attachments

set_attachment_fact(self, file_to_upload: str, fact_id: str, description: str = None, phase_name: str = None, html_rendering_hint: str = None, allow_large_files: bool = False) None

Set an attachment fact for a given asset. Supported for CPD version >= 4.6.5.

Parameters:
  • file_to_upload (str) – The file path of the attachment to be uploaded. This is the path to the file that will be added as an attachment.

  • fact_id (str) – The Fact ID against which the attachment will be uploaded. If no Fact ID is provided, the attachment will appear under ‘Other Attachments’ in the factsheet.

  • description (str) – (Optional) A description of the file to be attached.

  • phase_name (str) – (Optional) The phase name where the attachment should appear. Available options are specified in Phases.

  • html_rendering_hint (str) – (Optional) The HTML rendering hint for the attachment. Available options are specified in RenderingHints.

Example:
>>> model.set_attachment_fact(
...     file_to_upload="./artifacts/image.png",
...     description="Sample image",
...     fact_id="custom_fact_id",
...     phase_name="Design",
...     html_rendering_hint="inline"
... )
get_attachment_definitions(self, type_name: str = None) None

Displays all attachment fact definitions for model or model_usecase. Supported for CPD version >=4.6.5 :return: None :rtype: list()

The way to use me is:

>>> client.assets.get_attachment_definitions(type_name=<model or model_usecase>)
has_attachment(self, fact_id: str = None) bool

Check if attachment/s exist. Supported for CPD version >=4.6.5

Parameters:

fact_id (str, optional) – Id of attachment fact

Return type:

bool

The way to use me is :

>>> model.has_attachment()
>>> model.has_attachment(fact_id=<fact id>)
list_attachments(self, filter_by_factid: str = None, format: str = 'dict')

List available attachments facts. Supported for CPD version >=4.6.5

Parameters:
  • filter_by_factid (str) – (Optional) Fact id for the attachment to filter by

  • format (str) – Result output format. Default to dict. Available options are in FormatType

A way to use me is:

>>> model.list_attachments(format="str") # use this format if using output for `set_custom_fact()`
>>> model.list_attachments() # get all attachment facts
>>> model.list_attachments(filter_by_factid=<"fact_id_1">) # filter by associated fact_id_1
get_download_URL(self, attachment_id: str) str

Constructs and returns the download URL for a given attachment.

Args:

attachment_id (str): The unique identifier of the attachment.

Returns:

str: The URL that can be used to download the specified attachment.

Raises:

ValueError: If the attachment_id is invalid or if there is an issue generating the URL.

Example:
>>> url = model.get_download_URL(attachment_id="12345")
>>> print(url) 
remove_attachment(self, fact_id: str)

Remove available attachments facts for given id.Supported for CPD version >=4.6.5

Parameters:

fact_id (str) – Fact id of the attachment

A way to use me is:

>>> model.remove_attachment(fact_id=<fact id of attachment>)
remove_all_attachments(self)

Remove all attachments facts for given asset. Supported for CPD version >=4.6.5

A way to use me is:

>>> model.remove_all_attachments()