mstrio > distribution_services > subscription > dynamic_recipient_list

class mstrio.distribution_services.subscription.dynamic_recipient_list.DynamicRecipientList(connection, id=None, name=None, project_id=None, project_name=None)

Bases: EntityBase, DeleteMixin

Python representation of Strategy One DynamicRecipientList object.

Parameters:
  • connection (Connection) –

  • id (str | None) –

  • name (str | None) –

  • project_id (str | None) –

  • project_name (str | None) –

id

DynamicRecipientList’s ID

name

DynamicRecipientList’s name

description

DynamicRecipientList’s description

source_report_id

Id of the Report that is the source of the DynamicRecipientList

physical_address

Physical Address for the DynamicRecipientList

linked_user

Linked User for the DynamicRecipientList

device

Device for the DynamicRecipientList

recipient_name

Recipient Name for the DynamicRecipientList

notification_address

Notification Address for the DynamicRecipientList

notification_device

Notification Device for the DynamicRecipientList

personalization

Personalization for the DynamicRecipientList

class MappingField(attribute_id, attribute_form_id)

Bases: Dictable

Python representation of a Mapping Field.

Parameters:
  • attribute_id (str) –

  • attribute_form_id (str) –

attribute_id

ID of the mapped attribute

Type:

str

attribute_form_id

ID of the mapped attribute’s form

Type:

str

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 from_dict(source, connection=None, to_snake_case=True, with_missing_value=False)

Creates an object from a dictionary. The dictionary’s 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 _FROM_DICT_MAP.

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

  • source (Dict[str, Any]) – A dictionary from which an object 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:

An object of type T.

Return type:

T

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

attribute_form_id: str
attribute_id: str
alter(name=None, source_report_id=None, physical_address=None, linked_user=None, device=None, description=None, recipient_name=None, notification_address=None, notification_device=None, personalization=None)

Alter a DynamicRecipientList’s specified properties

Note

If one alters the source_report_id, all existing Mapping Fields also need to be updated to reflect the new source report.

Parameters:
  • name (string, optional) – DynamicRecipientList’s name

  • source_report_id (string, optional) – ID of the Report that is the source of the DynamicRecipientList

  • physical_address (MappingField, optional) – Mapping Field representing the Physical Address for the DynamicRecipientList

  • linked_user (MappingField, optional) – Mapping Field representing the Linked User for the DynamicRecipientList

  • device (MappingField, optional) – Mapping Field representing the Device for the DynamicRecipientList

  • description (string, optional) – DynamicRecipientList’s description

  • recipient_name (MappingField, optional) – Mapping Field representing the Recipient Name for the DynamicRecipientList

  • notification_address (MappingField, optional) – Mapping Field representing the Notification Address for the DynamicRecipientList

  • notification_device (MappingField, optional) – Mapping Field representing the Notification Device for the DynamicRecipientList

  • personalization (MappingField, optional) – Mapping Field representing the Personalization for the DynamicRecipientList

Return type:

None

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, source_report_id, physical_address, linked_user, device, project_id=None, project_name=None, description=None, recipient_name=None, notification_address=None, notification_device=None, personalization=None)

Create a new DynamicRecipientList with specified properties.

Parameters:
  • name (string) – DynamicRecipientList’s name

  • source_report_id (string) – ID of the Report that is the source of the DynamicRecipientList

  • physical_address (MappingField) – Mapping Field representing the Physical Address for the DynamicRecipientList

  • linked_user (MappingField) – Mapping Field representing the Linked User for the DynamicRecipientList

  • device (MappingField) – Mapping Field representing the Device for the DynamicRecipientList

  • project_id (string, optional) – ID of the project in which the DynamicRecipientList is to be created, if not provided, ID will be taken from project_name, if neither is provided, project will be extracted from the connection

  • project_name (string, optional) – name of the project in which the DynamicRecipientList is to be created

  • description (string, optional) – DynamicRecipientList’s description

  • recipient_name (MappingField, optional) – Mapping Field representing the Recipient Name for the DynamicRecipientList

  • notification_address (MappingField, optional) – Mapping Field representing the Notification Address for the DynamicRecipientList

  • notification_device (MappingField, optional) – Mapping Field representing the Notification Device for the DynamicRecipientList

  • personalization (MappingField, optional) – Mapping Field representing the Personalization for the DynamicRecipientList

  • connection (Connection) –

Returns:

DynamicRecipientList class object.

Return type:

DynamicRecipientList

delete(force=False)

Delete object.

Parameters:
  • force (bool) – If True, then no additional prompt will be shown before deleting object.

  • self (Entity) –

Returns:

True on success. False otherwise.

Return type:

bool

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, to_snake_case=True, with_missing_value=False)
Overrides Dictable.from_dict() to instantiate an object from

a dictionary without calling any additional getters.

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

  • source (dict[str, Any]) – a dictionary from which an object will be constructed.

  • connection (Connection) – A Strategy One Connection object.

  • to_snake_case (bool, optional) – Set to True if attribute names should be converted from camel case to snake case, default 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:

An object of type T.

Return type:

T

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

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

mstrio.distribution_services.subscription.dynamic_recipient_list.list_dynamic_recipient_lists(connection, project_id=None, project_name=None, to_dictionary=False, limit=None, **filters)

Get list of Dynamic Recipient List objects or dicts with them.

Note

When project_id is specified, project_name is omitted. If neither is specified then project_id from connection object is taken.

Parameters:
  • connection (Connection) – Strategy One connection object returned by connection.Connection()

  • project_id (str, optional) – ID of the project to list the metrics from

  • project_name (str, optional) – name of the project

  • to_dictionary (bool, optional) – If True returns list of dictionaries, by default (False) returns DynamicRecipientList objects

  • limit (integer, optional) – limit the number of elements returned. If None all object are returned

  • **filters – Available filter parameters: [‘name’, ‘id’, ‘description’, ‘source_report_id’, ‘physical_address’, ‘linked_user’, ‘device’]

Returns:

list with DynamicRecipientList objects or list of dictionaries

Return type:

list[DynamicRecipientList] | list[dict]