This project includes demo scripts using the Sisense Datamodels API, which can be utilized to automate Datamodel creation and maintenance.
Note: this demo utilizes the V2 REST API which is currently available only with Sisense for Linux L8.0.2 and higher
The repository includes all the assets (such as an CSV files) required to set up this demo. Below you will find instructions for set up, customization and contributions.
For more information about the Sisense Datamodels API, please refer to the Sisense Datamodels API Guide and the V2 REST API Reference
Within this document:
External documents:
Make sure you have met the following prerequisites prior to starting:
- Have a Sisense L8.0.2 or later version deployed and activated on a Linux server cluster
- Have the credentials of a user with sufficient permissions ("Data Designer" or higher) and generated an API token - See Using the Sisense REST API
- Have NodeJS and NPM installed and up-to-date
- Clone or download this repository
- Run
npm install
- Rename
shared.js.template
toshared.js
- Configure the API token and Sisense base URL in
shared.js
This package includes several demo scripts, written in Node.js, that show various operations and use-cases being achieved using the Datamodels API.
This demo script uploads the included demo.csv
to a Sisense server, and creates a new Datamodel schema based on this CSV file.
To Run:
node demo.js
What it does
- Uploads
demo.csv
to the Sisense server - Creates a blank new
extract
type datamodel - Creates a CSV type dataset
- Creates a table from the CSV
- Adds a custom column to the table and hides 2 other columns
- Creates a custom dataset
- Creates a custom table
- Creates a relation between the CSV table and the custom table
- Builds the datamodel
This demo script uploads the included demo.csv
and demo2.csv
to a Sisense server, creates a new Datamodel schema based on the first CSV file and then changes connectivity to the second CSV file.
To Run:
node change-connection.js
What it does
- Uploads
demo.csv
anddemo2.csv
to the Sisense server - Creates a blank new
extract
type datamodel - Creates a CSV type dataset
- Creates a table from the CSV
- Adds a custom column to the table and hides 2 other columns
- Updates the dataset connection to
demo2.csv
- Updates the table's
id
property according to new CSV file name - Builds the datamodel
Available on: Sisense Linux L8.0.3.150 or later
This demo script downloads all available Datamodel schemas, without data, as .smodel
files, which can be imported to Sisense via UI or API, into a folder called backup
.
To Run:
node export-all.js
What it does
- Creates a folder called
backup
if one doesn't already exist - Gets the
OID
andtitle
of all available Datamodel entities - For each Datamodel found:
- Exports the Datamodel
- Stores the response JSON as
.smodel
This demo uses Node.js with a minimal set of dependencies, listed below.
A shared configuration file, shared.js
is used by all of the demo scripts. It contains only constants that are common to all scripts - configuration specific to only one demo script should generally be kept within the script.
Additionally, it contains several helper modules used by the demo scripts:
- A very simple "client" module is provided in the file
client.js
, to handle the correct formatting of RESTful HTTP requests to the Sisense V2 API. This module takes care of constructing the full requst URI, appending the correct headers and so on. - A separate module (
upload.js
) handles validating and uploading files to Sisense for use as file-based data sources (CSV/Excel)
These helper modules should be re-used and extended as needed.
Dependencies
All of the dependencies below are used by the demo scripts for convenience and are not required to use the Sisense Datamodels API.
Name | Type | Source | Version | Description |
---|---|---|---|---|
request | Node.js | NPM | 2.88.0 | HTTP request library |
request-promise-native | Node.js | NPM | 1.0.7 | Native Promise based wrapper for request |
Additionally, this project lists eslint
and several plugins for it as a DevDependency used to validate the code format.
File Structure
./
├── .gitignore --> Git tracking ignore list
├── .eslintrc --> EsLint configuration
├── .eslintignore --> EsLint checking ignore list
├── readme.md --> This README file
├── LICENSE --> License info
├── CONTRIBUTING.md --> Contribution guidelines
├── package.json --> NPM
├── shared.js.template --> Template for configuration
├── client.js --> Shared library for running RESTful requests to the Sisense V2 REST API
├── upload.js --> Shared library for uploading CSV/XLSX files to Sisense
├── demo.js --> Demo #1 - Create datamodel from scratch
├── change-connection.js --> Demo #2 - Change connection of a dataset
├── export-all.js --> Demo #3 - Export all Datamodel schemas
└── assets/
├── demo.csv --> Sample data
├── demo2.csv --> Sample data
└── tenants.xlsx --> Sample data