mstrio > distribution_services > subscription > subscription_manager

class mstrio.distribution_services.subscription.subscription_manager.SubscriptionManager(connection, project_id=None, project_name=None)

Bases: object

Manage subscriptions.

Parameters:
  • connection (Connection) –

  • project_id (str | None) –

  • project_name (str | None) –

available_bursting_attributes(content)

Get a list of available attributes for bursting feature, for a given content.

Parameters:

content (dict | Content) – content dictionary or Content object (from subscription.content)

Return type:

list[dict]

available_recipients(content_id=None, content_type=None, content=None, delivery_type='EMAIL')

List available recipients for a subscription contents. Specify either both content_id and content_type or just content object.

Parameters:
  • content_id (str) – ID of the content.

  • content_type (str | Type) – type of the content.

  • content (Content) – Content object.

  • delivery_type (str | DeliveryMode) – The delivery type of the subscription.

Return type:

list[dict]

create_copy(subscription, name=None, project_id=None, project_name=None, send_now=False)

Create a copy of the subscription on the I-Server.

Parameters:
  • subscription (Subscription | str) – Subscription object or ID of the subscription to be copied

  • name (str | None) – New name of the object. If None, a default name is generated, such as ‘Old Name (1)’

  • project_id (str | None) – Project ID

  • project_name (str | None) – Project name. If neither project_id nor project_name is provided, the project ID from the source subscription is used.

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

Returns:

New object, the copied subscription. The subscription’s name might be changed to avoid conflicts with existing objects.

delete(subscriptions, force=False)

Deletes all passed subscriptions. Returns True if successfully removed all subscriptions.

Parameters:
  • subscriptions (list[Subscription] | list[str]) – list of subscriptions to be deleted

  • force (bool, optional) – if True skips the prompt asking for confirmation before deleting subscriptions. False by default.

Return type:

bool

execute(subscriptions)

Executes all passed subscriptions.

Parameters:

subscriptions (list[Subscription] | list[str]) – list of subscription objects or subscription ids to be executed

Return type:

None

list_subscriptions(to_dictionary=False, limit=None, last_run=False, **filters)

Get all subscriptions as list of Subscription objects or dictionaries.

Optionally filter the subscriptions by specifying filters.

Parameters:
  • to_dictionary (bool) – If True returns a list of subscription dicts, otherwise returns a list of subscription objects

  • limit (int | None) – limit the number of elements returned. If None (default), all objects are returned.

  • last_run (bool) – If True, adds the last time that the subscription ran.

  • **filters – Available filter parameters: [‘id’, ‘name’, ‘editable’, ‘allowDeliveryChanges’, ‘allowPersonalizationChanges’, ‘allowUnsubscribe’, ‘dateCreated’, ‘dateModified’, ‘owner’, ‘schedules’, ‘contents’, ‘recipients’, ‘delivery’]

mstrio.distribution_services.subscription.subscription_manager.dispatch_from_dict(source, connection, project_id)

Returns the subscription type object from the provided source

Parameters:
  • source (dict) – dictionary of an object to return from the specified subscription

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

  • project_id (str) – Project ID

mstrio.distribution_services.subscription.subscription_manager.get_subscription_type_from_delivery_mode(mode)

Returns the subscription type of the provided Delivery Mode.

Parameters:

mode (DeliveryMode) – DeliveryMode object of which to get the subscription type

mstrio.distribution_services.subscription.subscription_manager.list_subscriptions(connection, project_id=None, project_name=None, to_dictionary=False, limit=None, last_run=False, **filters)

Get all subscriptions per project as list of Subscription objects or dictionaries.

Optionally filter the subscriptions by specifying filters. Specify either project_id or project_name. When project_id is provided (not None), project_name is omitted.

Note: When project_id is None and project_name is None, then its value is overwritten by project_id from connection object.

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

  • project_id (str | None) – Project ID

  • project_name (str | None) – Project name

  • to_dictionary (bool) – If True returns a list of subscription dicts, otherwise (default) returns a list of subscription objects

  • limit (int | None) – limit the number of elements returned. If None (default), all objects are returned.

  • last_run (bool) – If True, adds the last time that the subscription ran.

  • **filters – Available filter parameters: [‘id’, ‘multiple_contents’, ‘name’, ‘editable’, ‘allow_delivery_changes’ ‘allow_personalization_changes’, ‘allow_unsubscribe’, ‘date_created’, ‘date_modified’, ‘owner’, ‘delivery’]

Return type:

list[Subscription] | list[dict]