Groovy, REST and HPCM

One of the most important things that Oracle has come up with recently, is extending the capabilities of EPM products, using various REST APIs (Representational State Transfer). For instance, PBCS has a REST API that can be used to run business rules, or load data using these API calls. So does BICS.

Recently, Oracle also came out with the REST API for HPCM. An associate of mine, wanted to see if it was possible to use these APIs for automating routine HPCM tasks. My use case in this example is to use the REST API, to do something extremely simple, get a list of available applications from HPCM.

24_1_Doc

REST, allows us to use a few different methods. Those that apply primarily to us, as EPM developers, are GET, POST, PUT and DELETE. There’s nothing fancy about those methods. GET allows you to retrieve some data from an application. POST allows you to create an action (like executing a business rule). PUT allows you to make updates and DELETE, does what you think it would do. Now I am not a web developer, but the beauty of REST, is that you don’t need to be one. You can still do a variety of actions with this tool.

According to the screenshot above, we need a few things to make the REST call work:

  1. The base URI for Workspace, which is usually, something along the lines of: http://servername.com:19000
  2. We need to add on the name of the tool we are using, in this case, “profitability”.
  3. Specify the rest key word and the version of the API. In this case it’s “v1”, but be on the lookout for updated versions of the API (PBCS is on version 3 ATM).
  4. Finally, the “applications” key word.

If we add all of those together, we get a URI which looks like:

http://servername.com:19000/profitability/rest/v1/applications

If we just use that URI above, that’s not going to work. We need to provide a couple more details:

  • Authorization: whether it’s HPCM or PBCS, we need to provide authorization credentials that can be used as the authorization layer. EPM products require “basic” authorization.
  • Content Type: responses and parameters in Oracle’s REST world are encoded in JSON Think of this as a collection of arrays that can be passed seamlessly to web URLs.

There are different ways in which you can invoke these APIs. You could use Java, Python, cURL or Groovy. For the sake of this example, I’ll use Groovy, because, well, the name. Groovy can be downloaded from here and provides a console which can be used to run your code.

24_2_Console

Let’s try something super simple; let’s see what happens if we just try to access the basic Workspace URL through Groovy.

24_6_Code_1

If you run the script above, you should get the results below:

24_3_XML

You essentially get the XML source code from that URL as the result set.

Now, if we add all the components together, our extremely simplistic code might look like:

24_4_GET

And, if we execute it, we get the results, in JSON format:

24_5_Results

The result set contains a list of all HPCM application names, types and status messages. While this is an extremely simple REST example, the point here is to outline how Groovy and REST can be combined to streamline some of your automation requirements. This code can be wrapped around DOS/Shell/ODI. You can also perform tasks like execute calculations, run dimension builds and data loads (on PBCS) etc. We will look at other examples in later posts.

About Vijay Kurian

Known as the Clem Fandango of EPM consulting, Vijay Kurian has been developing enterprise solutions for companies for the last 12 years (increment years if reading post-2015). Having worked with Essbase, Planning, DRM and other assorted technologies during that time, he’s made the frankly, average decision, to write about them. He hopes to contribute frequently to US Weekly, People and Sensible Chuckle magazines on improving reporting solutions, creating master data management systems and zzz…

Leave a Reply

Your email address will not be published. Required fields are marked *