Getting Started with the Oracle Analytics Cloud Rest API

This is a brief introduction into the Oracle Analytics Cloud Rest API; there isn’t any documentation on it yet – so this should get you started.

First impressions of it are really good – it seems pretty rich & fully featured. Our initial use case is to fill the gap created by the changes in the Essbase Security model – we can’t use MAXL to dynamically assign security any more – it all has to be done via the rest API. All these functions run using CURL

 

Scenario

We’re going to run the following scenarios in this demo:

  • Create a Group
  • Create a Power User
  • Create a Filter
  • Assign the Group to the Filter

These are the typical scenarios we need to run in any cube automation. The rest of the “standard” cube build steps remain supported directly by MAXL.

Prerequisites

I’ve used the following variables for the commands:

set User=cloud.user
set Password=password
set Server=localhost:9000
set App=TBC
Set Cube=TBC
Set FilterName=QBXFilter
Set UserName=QBXUser
Set GroupName=QBXTestGroup

Steps

Create a Group

Create a json file “creategroup.json” with the following structure:

{ 
"name": "QBXTestGroup",
"description": "QBXTestGroup",
"role": "User",
"groups": []
}

Run the following command:

curl -X POST -u %User%:%Password% -H "Accept: application/json" -H "Content-Type: application/json" http://%Server%/essbase/rest/v1/groups --data-binary @creategroup.json

And you should get the following result:

{
  "name" : "QBXTestGroup",
  "description" : "QBXTestGroup",
  "role" : "User",
  "links" : [ {
    "rel" : "get",
    "href" : "http://localhost:9000/essbase/rest/v1/groups/QBXTestGroup",
    "method" : "GET"
  }, {
    "rel" : "edit",
    "href" : "http://localhost:9000/essbase/rest/v1/groups/QBXTestGroup",
    "method" : "PUT"
  }, {
    "rel" : "delete",
    "href" : "http://localhost:9000/essbase/rest/v1/groups/QBXTestGroup",
    "method" : "DELETE"
  } ]
}

Create a Power User

Create a users csv file:

QBXUser,,,password,Power User, 

Now run the following command:

curl -X POST -u %User%:%Password% -H "Accept: application/octet-stream" -H "Content-Type: application/octet-stream" http://%Server%/essbase/rest/v1/users --data-binary @input_users.csv

And you should get the following response:

1,Info,User created successfully

Create a Filter

Create a json file as follows:

{ 
       "name": "QBXFilter",
       "rows":
       [
           {
               "access": "Read",
               "mbrSpec": "@IDESCENDANTS(East)"
           }
       ]
}

And run the following :

curl -X POST -u %User%:%Password% -H "Accept: application/json" -HContent-type:application/json "http://%Server%/essbase/rest/v1/applications/%App%/databases/%Cube%/filters" --data-binary @%FilterName%.json

Which returns the following :

{
  "name" : "QBXFilter",
  "links" : [ {
    "rel" : "get",
    "href" : "http://localhost:9000/essbase/rest/v1/applications/TBC/databases/TBC/filters/QBXFilter",
    "method" : "GET"
  }, {
    "rel" : "delete",
    "href" : "http://localhost:9000/essbase/rest/v1/applications/TBC/databases/TBC/filters/QBXFilter",
    "method" : "DELETE"
  }, {
    "rel" : "edit",
    "href" : "http://localhost:9000/essbase/rest/v1/applications/TBC/databases/TBC/filters/QBXFilter",
    "method" : "PUT"
  }, {
    "rel" : "rows",
    "href" : "http://localhost:9000/essbase/rest/v1/applications/TBC/databases/TBC/filters/QBXFilter/rows",
    "method" : "GET"
  } ]
}

Assign the Group to the Filter

Create a json file as follows:

{ 
                "id": "QBXTestGroup",
                "group": "true"
}

And Run the command:

curl -X POST -u %User%:%Password% -H "Accept: application/json" -HContent-type:application/json "http://%Server%/essbase/rest/v1/applications/%App%/databases/%Cube%/filters/%FilterName%/permissions" --data-binary @filterassign.json

Returning:

{
  "id" : "QBXTestGroup",
  "group" : true
}

Demo Script

The full demo script of everything above – plus also some cleanup, can be downloaded here.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s