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

Feature/add dashboard creation #36

Draft
wants to merge 10 commits into
base: master
Choose a base branch
from
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ You usually don't need to deal with these functions directly (e.g. [get_item_inf
- [create_segment](https://github.com/vvaezian/metabase_api_python/blob/150c8143bf3ec964568d54bddd80bf9c1b2ca214/metabase_api/metabase_api.py#L486)
- [copy_card](https://github.com/vvaezian/metabase_api_python/blob/150c8143bf3ec964568d54bddd80bf9c1b2ca214/metabase_api/metabase_api.py#L530)
- [copy_pulse](https://github.com/vvaezian/metabase_api_python/blob/150c8143bf3ec964568d54bddd80bf9c1b2ca214/metabase_api/metabase_api.py#L591)
- [create_dashboard]
- [copy_dashboard](https://github.com/vvaezian/metabase_api_python/blob/150c8143bf3ec964568d54bddd80bf9c1b2ca214/metabase_api/metabase_api.py#L643)
- [copy_collection](https://github.com/vvaezian/metabase_api_python/blob/150c8143bf3ec964568d54bddd80bf9c1b2ca214/metabase_api/metabase_api.py#L736)
- [clone_card](https://github.com/vvaezian/metabase_api_python/blob/77ef837972bc169f96a3ca520da769e0b933e8a8/metabase_api/metabase_api.py#L1003)
Expand Down
29 changes: 29 additions & 0 deletions metabase_api/metabase_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -642,6 +642,35 @@ def create_segment(self, segment_name, column_name, column_values, segment_descr



def create_dashboard(self, name, description=None, parameters=None, cache_ttl=None, collection_id=None, collection_position=None, collection_name=None):
Copy link
Owner

Choose a reason for hiding this comment

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

"parameters" and "cache_ttl" are not used in the function.
The function should allow passing custom json as argument to customize the dashboard (I assume the "parameters" option was supposed to do that). Currently only the name and description of the dashboard are customizable using this function.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Got it, sorry to bother, I'm correcting this asap

assert name

json = {'name': name}
if description:
json['description'] = description

if collection_name:
collection_id = self.get_item_id('collection', collection_name)

if collection_id:
assert isinstance(collection_id, int)
assert collection_id != 0

json['collection_id'] = collection_id

if collection_position:
assert isinstance(collection_position, int)
assert collection_position != 0

json['collection_position'] = collection_position




res = self.post("/api/dashboard", json=json)



def copy_card(self, source_card_name=None, source_card_id=None,
source_collection_name=None, source_collection_id=None,
destination_card_name=None,
Expand Down