This is an update to previous article that did the same with "pure APIs" request. In this example I am using Python mstrio library which contains user friendly methods that hide the complexity. As a result the code has been reduced from 200 to just 30 lines of code (!)
This script will perform the following:
# Authenticate: log in / Log out
# Create a new MSTR Project
# Create a new User Group
# Create a new User
# Create a new Security Role
# With the new User Group - assign new Security Role to the new Project
# With the new User Group - give MODIFY access to Shared Reports folder
# Remove default Security Role assignment for User Group EVERYONE
Note - I've added color formatting in the code below (http://hilite.me/). Code copied from here might not work due to indentation issues. In that case, use attached file with sample code.
Also this CRM is adding ';' near URLs (see below variable base_url)
Attached is the Jupyter Notebook file.
# This has been tested with Strategy 2021
from mstrio.connection import Connection
from mstrio.admin.usergroup import UserGroup
from mstrio.admin.user import User
from mstrio.admin.security_role import SecurityRole
from mstrio.admin.application import Environment, Application
from time import sleep
api_login, api_password = 'administrator', ''
base_url = 'http://warw7243-a.corp.Strategy.com:8080/MicroStrategyLibrary/'
keyword = str(input("Project name : "))
conn = Connection(base_url,api_login,api_password)
env_dev = Environment(connection=conn)
new_app = env_dev.create_application(name=keyword, description=keyword)
new_user = User.create(connection=conn, username=keyword, full_name=keyword)
new_group = UserGroup.create(connection=conn, name=keyword, members=[new_user.id])
new_secr = SecurityRole.create(connection=conn, name=keyword, description=keyword, privileges=[1,3])
ug_Everyone = UserGroup(connection=conn, id='C82C6B1011D2894CC0009D9F29718E4F')
sc_NormalUsers = "73F7482111D3596C60001B8F67019608"
ug_Everyone.revoke_security_role(security_role=sc_NormalUsers, application=new_app)
new_group.assign_security_role(security_role=new_secr.id, application=new_app)
sleep(10)
folder_SharedReports = "D3C7D461F69C4610AA6BAA5EF51F4125"
new_group.set_permission(to_objects=[folder_SharedReports], object_type=8, permission='Modify',
application=new_app, propagate_to_children=True)
conn.close()