MicroStrategy/mstrio-py

list_folders in object_management module does not list all folders

kkadu opened this issue · 1 comments

USE CASE:
I am planning to get list of all reports in my project using MSTRIO, however because of the large environment we have, I am planning to exclude reports from certain folders (using filters with list_reports, like PROFILE and USER SHARED). This would require me get a list of all folders first and then get list of reports from those folders (excluding the ones I don't need) in a loop format.

ISSUE:
To get a list of all folders in the project, I am using list_folders module from object_management package. The documentation mentions that it should "Get a list of folders - either all folders in a specific project or all folders that are outside of projects, called configuration-level folders."

However, when I execute the list_folders at the project level (folder_list = list_folders(conn, project_id=PROJECT_ID)), I only get the higher level folder (ancestors for those folders is level = 1) and we do not get "all" folders in the project i.e. the sub-folders or recursive folders as we do for list_reports etc.

EXPECTATION:
The expectation should be that list_folders should generate a list of all folders within the project and not just the level 2.

The report objects should have an ancestors property which is a list of containing folders. You can filter with that.

Checked and the folder list you get is only the top level because they also have an ancestors list.
https://demo.microstrategy.com/MicroStrategyLibrary/api-docs/index.html#/Browsing/getRootFolder

Probably a more Pythonic way to do this, but here's one I did to exclude a bunch of standardized objects I wasn't interested in.

resultsFiltered = []
        for r in results:
            if 'ancestors' in r:
                if len(r['ancestors']) >1:
                    if r['ancestors'][1]['name'] in ["System Objects","Object Templates","AutoStyles","Themes"]:
                        continue
                if len(r['ancestors']) >2:    
                    if r['ancestors'][2]['name'] in ["AutoStyles","Themes"]:  
                        continue
                resultsFiltered.append(r)