Planning Analytics

 View Only

REST API Examples with Javascript - Listing Adminhosts and TM1Servers

By Edward Stuart posted Mon November 07, 2022 04:03 AM

  

REST API Examples with Javascript – Adminhosts and TM1Servers

The Planning analytics with Watson REST API has been available since 2016 and a few commercial applications have been created to fulfill many needs and requirements. In addition, there are some open-source/ community based resources to interact with your models in Python, Power Shell and Excel among others.

One of the challenges I’ve felt when working with the REST API is that I create lots of organisation specific scripts which are designed to fit the core requirement, these have tended to be Power Shell based as this is the main consistent tool I have available across the models I work with. What I would ideally like is a consistent GUI based tool which I could take between infrastructures/ environments.

As a learning tool and a simple GUI to the REST API I’ve created a web browser based client which required no installation, no downloads once the client is installed (i.e. no package updates), contains no databases and could easily be lifted and shifted between multiple implementations with low configuration.

All the code used is pure/ plain/ vanilla JavaScript which means it uses no additional libraries and will work in all modern web browsers. The code could be used with Script Lab in Excel or as plain script files without the HTML/ CSS components used in the web client.

This is a learning tool for interacting with the REST API. The intention is to build out core functionality for getting access to Adminhosts, models, configuration and model objects (cubes, dimensions, processes etc..) and in many cases this will mirror existing functionality. However, there will be some efficiencies found and there will be the ability to set a profile/ configuration for your models.

The vision (at the moment) is users can create their own custom pages/ scripts which they can choose to add to the open-source project or not (to be hosted on GitHub) and they can contribute to the overall project.

Blog topics to follow in the coming weeks:

  • Logging into a TM1 Model
  • Listing all End Points for a Model (Singleton/ EntitySet etc..)
  • The GitHub project, how to download the code, use the model and contribute
  • Connecting to GitHub and pulling code from GitHub pages

The goal of the project is to present a simple GUI that can keep models in sync either through direct connection between servers via REST API and/ or via a GitHub repository.

The following is a quick look at the first implementation of this client:

Opening Screen for Javascript REST API Client listing Planning Analytics and Github options

The main page gives the option to switch between Planning Analytics and Github. Github is not the target of this blog post but provides a link in to the Github API to pull repositories and associated objects.

Select Planning Analytics:

No Adminhosts have been input so we see a button to

The Adminhost screen will notify if an Adminhost already exists and gives the option to add another. If we select add new Adminhost we see:

A new form pops up and we can input Transfer Protocol, Adminhost and Port Number


The user would input the Transfer Protocol, Adminhost and Port Number. It is populated with a default reference to localhost which will work if you are running the client directly on the server in question otherwise you will need to update this reference.

The previously input Adminhost details are now available as an Adminhost URL

When you set the Adminhost the screen will update to show the full URL to the Adminhost.

You can add as many Adminhosts to this page as required.

Technote: We use LocalStorage to hold this information in an array, this information is not held anywhere other than the users web browser that updated the information. We could use SessionStorage to add additional security but I felt clearing the cache on your browser was sufficient to clear the storage as opposed to SessionStorage which would require re-inputting this information each time you used the Client.

Further reading:

sessionStorage: https://developer.mozilla.org/en-US/docs/Web/API/Window/sessionStorage

localStorage: https://developer.mozilla.org/en-US/docs/Web/API/Window/localStorage

I’ve now added two servers to my Adminhost array and both can be seen on the Adminhost page:

Two Adminhost URLs are now visible as part of the adminhost page

I can now click the Adminhost I want to interact with:

Listing of all TM1Servers currently running on Spitfire-Prod Server

I clicked on my Spitfire-Prod server and I can see a title listing the server I have selected as a header with the URL specified previously and now I can see all the models that are running on the server.

The look and feel is still to be worked on but behind the scenes, as we loop through each server we are checking if there is a HTTPPortNumber and if so then colour the box holding the server information Green, otherwise Red.

In future blog posts/ videos I will be looking to make changes to the Configuration endpoints to show this in action.

It is also important to note that this is a Client to access the REST API for IBM Planning analytics with Watson. The API can only work with servers that are currently running, if you have switched off your server then it will not appear in the list.


#PlanningAnalyticswithWatson
0 comments
27 views

Permalink