cancel
Showing results for 
Search instead for 
Did you mean: 

Can you use export/import to make a copy of a dashboard, but with changes?

bpeikes
9 - Travel Pro
9 - Travel Pro

We are trying to streamline our work flow, and automate parts of it. We use Sisense to embed analytics into a desktop application, using SSO and embed links.

Each client has their own datamodel/connection, dashboard and user group. For example: (XX is client code)
Connection/model: Prod-OurProductA-XX
Dashboard: Prod-OurProductA-XX
UserGroup: Prod-OurProductA-XX

UserGroup is used to set the share permissions for Dashboard and Connection and give clients view only access to their dashboards and data.

We develop improvements to the dashboards using development connections and dashboards, like:
Connection/model: Dev-OurProductA-Test
Dashboard: Dev-OurProductA-Test

We also have a Connection and Dashboard, which is the most current version of the model and the dashboard, which should be used as a template for new clients. Example:
Connection/model: ProdTemplate-OurProductA
Dashboard: ProdTemplate-OurProductA

As part of our workflow, what we would like to be able to do when we have a new client:
1) Export (or pull from source control), our Connection/model
2) Update some of the queries and the connection
3) Import the updated Connection/model as a new connection named:
     Prod-OurProductA-NEWCLIENT

We would also like to do the same with the Dashboard, namely
1) Export (or pull from source control), the template dashboard
2) Replace the connection with newly created one
3) Import the the updated Dashboard as a new one named:
     Prod-OurProductA-NEWCLIENT

Question 1
How do you import the dashboard as a new one? Do you leave the OID and dashboardids in the template, and specify "duplicate" when importing?

Question 2
How would you replace an existing Dashboard. i.e. We're done developing new dashboard, we want to then
1) Import it over our Template
2) Take the new Template, and import it "into" all of the existing dashboards, while keeping their oids so that their embedded links do not change? That that even a good idea?

3 REPLIES 3

bluemetrics
8 - Cloud Apps
8 - Cloud Apps

Hi bpeikes,

Our team developed a Python API for Sisense that makes a lot of the tasks you described faster and automated. For example, the code below could be used to perform the tasks described for datamodels:

from sisense import Sisense
import json

host = 'https://your_sisense_url'
token = 'your_api_token'
elasticube_name = 'Name of the elasticube you wish to duplicate'

sisense = Sisense(host, token) # Connection to Sisense

# sisense.datamodel.list() # Lists datamodels, good for testing the connection
# sisense.elasticube.all() # Same but for elasticubes on Windows

# Get the cube by it's name and uses it to get the datamodel
cube = sisense.elasticube.get(elasticube_name)
model = sisense.datamodel.get(cube.oid)

# Exports the datamodel to a JSON file
filepath = 'Model.smodel'
model.do_export(filepath)

# Imports the JSON file for editing
with open(filepath, 'r') as file:
	smodel = json.load(file)

# Change model's properties (some connection parameter, for example)
smodel['datasets'][0]['connection']['parameters'] = ...

# Exports the altered JSON
with open(filepath, 'w') as file:
	json.dump(smodel, file, indent=4)

# Imports the altered datamodel as a new one in Sisense
sisense.datamodel.do_import('New Datamodel', filepath)

There are also very similar functions that allow you to do the same with dashboards.
To use the Sisense API for Python, you will need to install it using pip as below:

pip install sisense

There's also documentation on getting started using the Python library: Sisense API — sisense documentation

If you have any questions don't be afraid to reach us out!

Best regards,
BlueMetrics

That looks great! How do you use the module to get your api token? Looked at the docs and it wasnt clear?

I know we can get one from the web ui, but I’d rather the people using the script to just need their username and pwd.

Currently, we don't support username and password authentication. This will come up on soon. If you want, you can create your own function or fork the project on GitHub. The function would look something like:

import requests

def login(username: str, password: str) -> str:
    data = {'username': username, 'password': passoword}
    headers = {
        'accept': 'application/json', 
        'Content-Type': 'application/x-www-form-urlencoded'
    }

    response = requests.post('https://your_app_url/api/v1/authentication/login', headers=headers, data=data)
    response.raise_for_status()

    content = response.json()
    if content['success']:
        return content['access_token']

    raise ValueError(content['message'])

I hope this helps.

Best regards, 

BlueMetrics