Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

#[UIC-1885] User should able to replicate dashboard via a REST Call #224

Merged
merged 5 commits into from
Aug 7, 2019

Conversation

arpit-agarwal
Copy link

@arpit-agarwal arpit-agarwal commented Aug 5, 2019

CATEGORY

Choose one

  • Bug Fix
  • Enhancement (new features, refinement)
  • Refactor
  • Add tests
  • Build / Development Environment
  • Documentation

SUMMARY

Exposed a replicate_dashboard endpoint to replicate a dashboard from a given JSON template.
REST API Details:

  • endpoint: superset/replicate_dashboard
  • headers: none
  • database_name: name of database to be created
  • sqlalchemy_uri: uri for database connection as per sqlalchemy spec
  • extra: additional configuration to establish connection via sqlalchemy_uri
  • impersonate_user: True | False case sensitive
  • dashboard_title: title of dashboard to be created
  • tables: A map of tableplachoder as key and schema.table_name as value
{"datasource_name": "default.master1_agg_stats_per_circle_15min"}
  • template: template json to be imported
  • csrf_token: token received from /superset/csrf_token/ endpoint to avoid CSRF attack

Template JSON: User can create a template json by following steps

  • Open a RVF instance and go to dashboard list
  • Select the dashboard you want to create as template
  • Export the dashboard
  • Remove datasources from the JSON. In case you won't remove it will be ignored
  • set slug value as null
  • for each slice in dashboard replace datasource_name with tableplachoder. Where tableplachoder is key in tables parameter corresponding to datasource to be used in this slice

POSTMAN: https://www.getpostman.com/collections/f1e82aece15702b7dc3a

Expectation & Limitations

Feature set

  1. You should be able to create a new dashboard based own tempalte JSON
  2. database connection and tables will be auto created

Limitation

  1. Table name has to be different per instance of REST API execution [issue]
  2. Failure messages are not graceful
  3. Tables across database instance has to be unique [issue]
  4. Only single database(hive instance) can be used in a dashboard.
  5. Template JSOn should only have single dashboard serialised

TEST PLAN

ADDITIONAL INFORMATION

  • Has associated issue:
  • Changes UI
  • Requires DB Migration.
  • Confirm DB Migration upgrade and downgrade tested.
  • Introduces new feature or API
  • Removes existing feature or API

REVIEWERS

@jitendra-kumawat

Arpit Agarwal added 2 commits August 6, 2019 17:07
UIC-1904 #time 30m Knox rule and son encoding handling
UIC-1904 #time 10m remove unneeded API
database_id = create_database(database_name,sqlalchemy_uri,extra,impersonate_user)

dashboard_title = request.form.get('dashboard_title')
tablesparam = json.loads(r''+request.form.get('tables'))

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please replace tablesparam with tables_param to make it more readable.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure will do

def import_dashboard_json(session, data, import_time=None):
current_tt = int(time.time())
import_time = current_tt if import_time is None else import_time
dashboard = data['dashboards'][0]

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is there any key with which we can retrieve the value here or has it to be on 0th index always?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is array we can iterate but as mentioned we are only supporting single dashboard at this point of time.

There will more changes than just iteration we need to take care (rest API signature will change). Hence will differ it till a ask come or we hit a persuasive usecase

Copy link

@bipinsoniguavus bipinsoniguavus left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@arpit-agarwal arpit-agarwal merged commit 8a2ccd7 into master Aug 7, 2019
@arpit-agarwal arpit-agarwal deleted the feature/UIC-1885-replicate-dashboard branch August 7, 2019 10:24
@arpit-agarwal arpit-agarwal changed the title #UIC-1885 User should able to replicate dashboard via a REST Call #[UIC-1885] User should able to replicate dashboard via a REST Call Aug 7, 2019
arpit-agarwal pushed a commit that referenced this pull request Aug 7, 2019
* feat(replicate-dashboard):  added code for replicate dashboard
* feat(replicate-dashboard):  rename and text fix
* feat(replicate-dashboard):  Knox rule and json encoding handling
* feat(replicate-dashboard):  remove unneeded API
* feat(replicate-dashboard):  review comment
@arpit-agarwal arpit-agarwal mentioned this pull request Aug 7, 2019
12 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants