<jupyter_start><jupyter_text>Getting IDs of Enabled Users<jupyter_code>user_list=UserGroup(connection=conn, id='UserGroup ID').list_members()
enabled_users=[u["id"] for u in user_list if u["enabled"]]
print(enabled_users)
subs_mngr = SubscriptionManager(conn, project_name='MicroStrategy Tutorial')
for sub in subs_mngr.list_subscriptions(to_dictionary=False):
    print(sub.id, sub.owner['id'], sub.owner['name'])
    #print(sub.__dict__)
for sub in subs_mngr.list_subscriptions(to_dictionary=False):
    if sub.owner['id'] not in enabled_users:
        print(sub.id, sub.owner['id'], sub.owner['name'])
        sub.delete(force=True)<jupyter_output><empty_output><jupyter_text>Create an orphan subscription<jupyter_code>from mstrio.distribution_services import EmailSubscription, Content
from datetime import datetime

project_id = 'Insert Project ID'
recipient_ids = ["Insert Recipient ID"]
content_id = 'Insert Content ID'
schedule_id = 'Insert Schedule ID'
owner_id = 'Insert Owner ID'
subscription_name = 'REST_API_'+datetime.now().strftime("%Y-%m-%d__%H-%M")
subject_txt='Email Subject'
message_txt="Message Text"
EmailSubscription.create(connection=conn,
                         name=subscription_name,
                         owner_id=owner_id,
                         project_id=project_id,
                         send_now = True,
                         contents=[Content(id=content_id, type='report', name='Report 1',
                                           personalization=Content.Properties(format_type='EXCEL'))],
                         schedules_ids=[schedule_id],
                         recipients=recipient_ids,
                         email_subject=subject_txt,
                         email_message=message_txt,
                         email_send_content_as="data")
for sub in subs_mngr.list_subscriptions(to_dictionary=False, owner={'id':'Insert Owner ID'}):
    print(sub.id, sub.owner['id'], sub.owner['name'])<jupyter_output><empty_output>