Python wrappers for Cognos Analytics REST API
This is a collection of Python wrapper methods for:
- Cognos Analytics REST API calls
- Cognos Mashup Services REST API calls to execute reports (just very basic)
- An example of how to use the 'unoffical' APIs like
/namespaces
calls to list groups & roles in namespace_folders
The goal is to be able to run code like this against your Cognos Analytics environment:
ca_service = CognosAnalyticsService(ca_url='https://your_cognos_dispatcher:9300')
# Login
ca_service.login(namespace='namespace',user='user',password='pwd')
# get list of content items from team folders
team_folders_items = ca_service.content.get_content_items(content_id='team_folders')
print(team_folders_items)
See samples.py for more examples of different services calls.
This code is inspired by tm1py, but is nowhere near as polished or tested, feel free to improve and expand. I'm releasing this as I might not have a chance to work on this in near future.
Please see the blog post for some background of how I've used this.
objects folder contains data classes
for various Cognos Analytics objects (users, groups, content items, etc)
services folder contains the wrappers for different endpoints for restapi, namely:
- cognos_analytics - main service that exposes all the other services
- content - content related methods, e.g. reading contents of a folder, updating permissions of a report
- groups & roles - groups & roles related methods, adding / removing groups or members
- namespaces - an 'unofficial' method for querying members of
namespace_folders
- an example of how methods used by Cognos Analytics UI can be included - report_data - Cognos Mashup Services wrapper to run the reports and return data
- rest - a wrapper around requests library for executing HTTP calls
- users - adding / removing users from namespace and copying user profiles and settings