mstrio > distribution_services > subscription > email_subscription

class mstrio.distribution_services.subscription.email_subscription.EmailSubscription(connection, id=None, subscription_id=None, project_id=None, project_name=None)

Bases: Subscription

Class representation of Strategy One Email Subscription object.

Parameters:
  • connection (Connection) –

  • id (str | None) –

  • subscription_id (str | None) –

  • project_id (str | None) –

  • project_name (str | None) –

add_recipient(recipients=None, recipient_id=None, recipient_type=None, recipient_include_type='TO')

Adds recipient to subscription. You can either specify id, type and include_type of single recipient, or just pass recipients list as a list of dictionaries.

Parameters:
  • recipients (list[dict] | dict | list[str] | str) –

    list of ids or dicts containing recipients, dict format: {“id”: recipient_id,

    ”type”: “CONTACT_GROUP” / “USER_GROUP” / “CONTACT” /

    ”USER” / “PERSONAL_ADDRESS” / “UNSUPPORTED”

    ”includeType”: “TO” / “CC” / “BCC”}

  • recipient_id (str | None) – id of the recipient

  • recipient_type (str | None) – type of the recipient

  • recipient_include_type (str) – include type of the recipient one of the following: “TO” / “CC” / “BCC”, by default “TO”

alter(name=None, multiple_contents=None, allow_delivery_changes=None, allow_personalization_changes=None, allow_unsubscribe=None, send_now=False, owner_id=None, schedules=None, contents=None, recipients=None, delivery=None, delivery_mode=None, custom_msg=None, delivery_expiration_date=None, delivery_expiration_timezone=None, contact_security=None, filename=None, compress=None, space_delimiter=None, email_subject=None, email_message=None, email_send_content_as=None, overwrite_older_version=None, zip_filename=None, zip_password_protect=None, zip_password=None, file_burst_sub_folder=None, printer_copies=None, printer_range_start=None, printer_range_end=None, printer_collated=None, printer_orientation=None, printer_use_print_range=None, cache_cache_type=None, cache_shortcut_cache_format=None, mobile_client_type=None, device_id=None, do_not_create_update_caches=None, re_run_hl=None, cache_library_cache_types=None, cache_reuse_dataset_cache=False, cache_is_all_library_users=False, delivery_notification_enabled=False, delivery_personal_notification_address_id=None)

Alter subscription.

Parameters:
  • name (str) – name of the subscription,

  • multiple_contents (bool, optional) – whether multiple contents are allowed

  • allow_delivery_changes (bool) – whether the recipients can change the delivery of the subscription,

  • allow_personalization_changes (bool) – whether the recipients can personalize the subscription,

  • allow_unsubscribe (bool) – whether the recipients can unsubscribe from the subscription,

  • send_now (bool) – indicates whether to execute the subscription immediately,

  • owner_id (str) – ID of the subscription owner, by default logged in user ID,

  • schedules (str | list[str] | Schedule | list[Schedule]) – Schedules IDs or Schedule objects,

  • contents (Content | list[Content]) – The content of the subscription.

  • recipients (list[str] | list[dict]) – list of recipients IDs or dicts,

  • delivery (Delivery, dict, optional) – delivery settings

  • delivery_mode (str, enum) – the subscription delivery mode [EMAIL, FILE, PRINTER, HISTORY_LIST, CACHE, MOBILE, FTP, SNAPSHOT, PERSONAL_VIEW, SHARED_LINK, UNSUPPORTED],

  • custom_msg (str, optional) – customized message displayed when Subscription has been successfully altered

  • delivery_expiration_date (str) – expiration date of the subscription, format should be yyyy-MM-dd,

  • delivery_expiration_timezone (str, optional) – expiration timezone of the subscription

  • contact_security (bool) – whether to use contact security for each contact group member,

  • filename (str) – the filename that will be delivered when the subscription is executed,

  • compress (bool) – whether to compress the file

  • space_delimiter (str) – space delimiter,

  • email_subject (str) – email subject associated with the subscription,

  • email_message (str) – email body of subscription,

  • email_send_content_as (str,enum) – [data, data_and_history_list, data_and_link_and_history_list, link_and_history_list],

  • overwrite_older_version (bool) – whether the current subscription will overwrite earlier versions of the same report or document in the history list,

  • zip_filename (str) – filename of the compressed content,

  • zip_password_protect (bool) – whether to password protect zip file,

  • zip_password (str) – optional password for the compressed file

  • file_burst_sub_folder (str) – burst sub folder,

  • printer_copies (int) – the number of copies that should be printed,

  • printer_range_start (int) – the number indicating the first report page that should be printed,

  • printer_range_end (int) – the number indicating the last report page that should be printed,

  • printer_collated (bool) – whether the printing should be collated,

  • printer_orientation (str,enum) – [ PORTRAIT, LANDSCAPE ]

  • printer_use_print_range (bool) – whether print range should be used,

  • cache_cache_type (str,enum) – [RESERVED, SHORTCUT, SHORTCUTWITHBOOKMARK]

  • cache_shortcut_cache_format (str,enum) – [RESERVED, JSON, BINARY, BOTH]

  • mobile_client_type (str,enum) – [PHONE, TABLET]

  • device_id (str) – the mobile target project,

  • do_not_create_update_caches (bool) – whether the current subscription will overwrite earlier versions of the same report or document in the history list,

  • re_run_hl (bool) – whether subscription will re-run against warehouse

  • cache_library_cache_types (list[LibraryCacheTypes | str], optional) – Set of library cache types, available types can be web, android, ios

  • cache_reuse_dataset_cache (bool) – Whether to reuse dataset cache

  • cache_is_all_library_users (bool) – Whether for all library users

  • delivery_notification_enabled (bool) – Whether notification is enabled, notification applies to cache

  • delivery_personal_notification_address_id (str, optional) – Notification details

available_bursting_attributes()

Get a list of available attributes for bursting feature.

Return type:

dict

available_recipients()

List available recipients for subscription content.

Return type:

list[dict]

classmethod bulk_from_dict(source_list, connection=None, to_snake_case=True, with_missing_value=False)

Creates multiple objects from a list of dictionaries. For each dictionary provided the keys in camel case are changed to object’s attribute names (by default in snake case) and dict values are composed to their proper data types such as Enums, list of Enums etc. as specified in the object’s _FROM_DICT_MAP.

Parameters:
  • cls (T) – Class (type) of the objects that should be created.

  • source_list (List[Dict[str, Any]]) – A list of dictionaries from which the objects will be constructed.

  • connection (Connection, optional) – A MSTR Connection object. Defaults to None.

  • to_snake_case (bool, optional) – Set to True if attribute names should be converted from camel case to snake case. Defaults to True.

  • with_missing_value (bool) – (bool, optional): If True, class attributes possible to fetch and missing in source will be set as MissingValue objects.

Returns:

A list of objects of type T.

Return type:

T

classmethod create(connection, name, project_id=None, project_name=None, allow_delivery_changes=None, allow_personalization_changes=None, allow_unsubscribe=True, send_now=None, owner_id=None, schedules=None, contents=None, recipients=None, delivery_expiration_date=None, delivery_expiration_timezone=None, contact_security=None, space_delimiter=None, email_subject=None, email_message=None, email_send_content_as='data', overwrite_older_version=False, filename=None, compress=False, zip_filename=None, zip_password_protect=None, zip_password=None)

Creates a new email subscription.

Parameters:
  • connection (Connection) – a Strategy One connection object

  • name (str) – name of the subscription,

  • project_id (str, optional) – project ID,

  • project_name (str, optional) – project name,

  • allow_delivery_changes (bool, optional) – whether the recipients can change the delivery of the subscription,

  • allow_personalization_changes (bool, optional) – whether the recipients can personalize the subscription,

  • allow_unsubscribe (bool, optional) – whether the recipients can unsubscribe from the subscription,

  • send_now (bool, optional) – indicates whether to execute the subscription immediately,

  • owner_id (str, optional) – ID of the subscription owner, by default logged in user ID,

  • schedules (str | list[str] | Schedule | list[Schedule], optional) – Schedules IDs or Schedule objects,

  • contents (Content | list[Content], optional) – The content settings.

  • recipients (list[str] | list[dict], optional) – list of recipients IDs or dicts (for example users ids or usergroups ids),

  • delivery_expiration_date (str, optional) – expiration date of the subscription, format should be yyyy - MM - dd,

  • delivery_expiration_timezone (str, optional) – expiration timezone of the subscription, example value ‘Europe/London’

  • contact_security (bool) – whether to use contact security for each contact group member

  • filename (str, optional) – the filename that will be delivered when the subscription is executed,

  • compress (bool) – whether to compress the file

  • space_delimiter (str, optional) – space delimiter,

  • email_subject (str, optional) – email subject associated with the subscription,

  • email_message (str, optional) – email body of subscription,

  • email_send_content_as (str, enum) – [data, data_and_history_list, data_and_link_and_history_list, link_and_history_list],

  • overwrite_older_version (bool) – whether the current subscription will overwrite earlier versions of the same report or document in the history list,

  • zip_filename (str, optional) – filename of the compressed content,

  • zip_password_protect (bool, optional) – whether to password protect zip file,

  • zip_password (str, optional) – optional password for the compressed file

Notes

To create a subscription with prompts, you need to provide the report instance ID with answered prompts for each content. Example: >>>contents=[ >>> Content( >>> id=”<report_id>”, >>> type=Content.Type.REPORT, >>> personalization=Content.Properties( >>> format_type=Content.Properties.FormatType.PDF, >>> prompt=Content.Properties.Prompt( >>> enabled=True, >>> instance_id=”<instance_id>”, >>> ), >>> ), >>> ), >>>]

delete(force=False)

Delete a subscription. Returns True if deletion was successful.

Parameters:

force (bool, optional) – If True, no additional prompt will be shown before deleting the subscription. Defaults to False.

Return type:

bool

execute()

Executes a subscription with given name or GUID for given project.

Return type:

None

fetch(attr=None)

Fetch the latest object’s state from the I-Server.

Note

This method can overwrite local changes made to the object.

Parameters:
  • attr (Optional[str]) – Attribute name to be fetched. If not specified

  • dictionary. (it will use all getters specified in _API_GETTERS) –

  • None. (Defaults to) –

Raises:

ValueError – If attr cannot be fetched.

Return type:

None

classmethod from_dict(source, connection=None, project_id=None, project_name=None)

Initialize Subscription object from dictionary. Specify either project_id or project_name. When project_id is provided (not None), project_name is omitted

Parameters:
  • source (dict[str, Any]) –

  • connection (Connection) –

  • project_id (str | None) –

  • project_name (str | None) –

Return type:

Subscription

list_properties(excluded_properties=None)

Fetches all attributes from the server and converts all properties of the object to a dictionary.

Parameters:

excluded_properties (list[str], optional) – A list of object properties that should be excluded from the dict. Defaults to None.

Returns:

A dictionary which keys are object’s attribute names, and

which values are object’s attribute values.

Return type:

dict

print()

Pretty Print all properties of the object.

Return type:

None

remove_recipient(recipients)

Removes recipient from given subscription in given project.

Parameters:

recipients (list[str] | list[dict]) –

list of ids or dicts containing recipients, dict format: {“id”: recipient_id,

”type”: “CONTACT_GROUP” / “USER_GROUP” / “CONTACT” /

”USER” / “PERSONAL_ADDRESS” / “UNSUPPORTED”

”includeType”: “TO” / “CC” / “BCC”}

classmethod to_csv(objects, name, path=None, properties=None)

Exports MSTR objects to a csv file.

Optionally, saves only the object properties specified in the properties parameter.

Parameters:
  • objects (T | list[T]) – List of objects of the same type that

  • exported. (will be) –

  • name (str) – The name of the csv file ending with ‘.csv’

  • path (Optional[str], optional) – A path to the directory where the file will be saved. Defaults to None.

  • properties (Optional[list[str]], optional) – A list of object’s attribute names that should be included in the exported file. Defaults to None.

Raises:
  • TypeError – If objects is not of type T or list of type T

  • objects.

Return type:

None

to_dataframe()

Converts all properties of the object to a dataframe.

Returns:

A DataFrame object containing object properties.

Return type:

DataFrame

to_dict(camel_case=True)

Converts an object to a dictionary excluding object’s private properties. When converting the object to a dictionary, the object’s attributes become the dictionary’s keys and are in camel case by default Attribute values stored as objects are automatically converted to non-/ primitive data structures.

Parameters:

camel_case (bool, optional) – Set to True if attribute names should be converted from snake case to camel case. Defaults to True.

Returns:

A dictionary representation of object’s attributes and values.

By default, the dictionary keys are in camel case.

Return type:

dict

update_properties()

Save compatible local changes of the object attributes to the I-Server. Changes are retrieved from the self._altered_properties dictionary. After the process of update has finished, self._altered_properties is cleared. For this method to work properly, you must override the _alter_properties() method in a subclass.

Raises:

requests.HTTPError – If I-Server raises exception

Return type:

None