Attachments

set_attachment_fact(file_to_upload, description, fact_id, html_rendering_hint=None)

Set attachment fact for given model use case. Supported for CPD version >=4.6.5.

Parameters:
  • file_to_upload (str) – Attachment file path to upload.

  • description (str) – Description about the attachment file.

  • fact_id (str) – Fact id for the attachment.

  • html_rendering_hint (str) – (Optional) html rendering hint. Available options are in RenderingHints.

Example usage:

>>> model.set_attachment_fact(file_to_upload="./artifacts/image.png",description="Example image for the model use case.",fact_id="custom_fact_id")
>>> model.set_attachment_fact(file_to_upload="./artifacts/image.png",description="Example image for the model use case.",fact_id="custom_fact_id", html_rendering_hint="render_hint")
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
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()