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 attachment fact for a given asset. Supported for CPD version >=4.6.5. :param str file_to_upload: File Path. Path of the file which needs to be uploaded as an attachment. :param str fact_id: Fact ID against which the attachment needs to be uploaded. If no fact ID is passed,
it will be found under ‘Other Attachments’ in the factsheet.
- Parameters:
description (str) – (Optional) Description of the file to be attached.
phase_name (str) – (Optional) Phase name in which the attachment should appear. Available options are in
Phases
.html_rendering_hint (str) – (Optional) HTML rendering hint. Available options are in
RenderingHints
.
A way to use this function is: >>> 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()