DashboardsMixin#

class DashboardsMixin#

Bases: object

Methods Summary

create_dashboard_permissions(project_id, ...)

(re)Create dashboard permissions for a specific project.

delete_dashboard(project_id, dashboard_id)

Delete a specific dashboard from the given project.

delete_dashboard_permissions(project_id, ...)

Delete all permissions from the dashboard, so that the permissions fall back to default (project default, i.e. Admins and Members can read and edit, Readers can view only).

get_dashboard(project_id, dashboard_id)

Return a specific dashboard from the given project.

get_dashboard_permissions(project_id, ...)

Return the dashboard permissions for a specific dashboard from

get_dashboards(project_id)

Return all dashboard for the given project.

modify_dashboard(project_id, dashboard_id[, ...])

Update a dashboard.

move_dashboard(project_id, dashboard_id, after)

Move a dashboard.

new_dashboard(project_id, title[, search, ...])

Create a new dashboard.

set_default_dashboard_permissions(...)

This is a helper method to create default (admin-only) dashboard permissions with one call.

Methods Documentation

create_dashboard_permissions(project_id, dashboard_id, permissions_list)#

(re)Create dashboard permissions for a specific project.

Parameters
  • project_id – Project identifier

  • dashboard_id – Dashboard identifier

  • permissions_list – A list of all the permissions to create. The permissions_list must be superset of the default permissions for a dashboard, since it is impossible to remove the admin from a permission list

Returns

A list of the users/groups with permissions for the dashboard

Example:

permissions_list = [
    {
        'user_id': 'some_user_id',
        'permission': 'view_and_edit',
        'dashboard_id': 'dashboard_id'
    }
]

>>> client.create_dashboard_permissions('2aEVClLRRA-vCCIvnuEAvQ',
...                 'G0Tm2SQcTqu2d4GvfyrsMg', permissions_list)
{
    'permissions':
    [
        {
            'user_id': 'some_user_id',
            'permission': 'view_and_edit',
            'dashboard_id': 'dashboard_id'
        }
    ]
}
delete_dashboard(project_id, dashboard_id)#

Delete a specific dashboard from the given project.

Parameters
  • project_id – Project identifier

  • dashboard_id – Dashboard identifier

Returns

No return value.

Example:

>>> client.delete_dashboard('2aEVClLRRA-vCCIvnuEAvQ',
...                         'Ue1OceLkQlyz21wpPqml9Q')
delete_dashboard_permissions(project_id, dashboard_id)#

Delete all permissions from the dashboard, so that the permissions fall back to default (project default, i.e. Admins and Members can read and edit, Readers can view only)

Parameters
  • project_id – Project identifier

  • dashboard_id – Dashboard identifier

Returns

A 204 status code if successful

Example::
>>> client.delete_dashboard_permissions('2aEVClLRRA-vCCIvnuEAvQ',
...                 'G0Tm2SQcTqu2d4GvfyrsMg')
get_dashboard(project_id, dashboard_id)#

Return a specific dashboard from the given project.

Parameters
  • project_id – Project identifier

  • dashboard_id – Dashboard identifier

Returns

A dictionary of the given dashboard.

Example:

>>> client.get_dashboard('2aEVClLRRA-vCCIvnuEAvQ',
...                      'G0Tm2SQcTqu2d4GvfyrsMg')
{u'id': u'G0Tm2SQcTqu2d4GvfyrsMg',
 u'search': {u'query': u'Test'},
 u'title': u'Test',
 u'type': u'dashboard',
 u'theme_id': u'G0Tm2SQcTqu2d4GvfyrsMg',
 u'widgets': [{u'col': 1,
               u'id': 1,
               u'row': 1,
               u'size_x': 1,
               u'size_y': 1,
               u'title': u'Search Results',
               u'type': u'Search'}]}
get_dashboard_permissions(project_id, dashboard_id)#
Return the dashboard permissions for a specific dashboard from

the given project.

Parameters
  • project_id – Project identifier

  • dashboard_id – Dashboard identifier

Returns

A dictionary containing:

  • permissions: A list of the dashboard permission dictionaries.

  • is_default: a boolean flag indicating whether these are the default permissions on the dashboard (based on project membership) or not (i.e. based on explicitly saved dashboard permissions)

Example:

>>> client.get_dashboard_permisssions('2aEVClLRRA-vCCIvnuEAvQ',
...                      'G0Tm2SQcTqu2d4GvfyrsMg')
{
    'permissions':
    [
        {
            'id': 'dashboard_permission_id',
            'user_id': 'some_user_id',
            'user': 'username',
            'project_role': 'member',
            'permission': 'view_and_edit',
            'dashboard_id': 'some_id'
        },
        {
            'id': 'dashboard_permission_id',
            'group_id': 'some_user_id',
            'group': 'group_name',
            'project_role': 'admin',
            'permission': 'view_and_edit',
            'dashboard_id': 'some_id'
        }
    ],
    'is_default': True
}
get_dashboards(project_id)#

Return all dashboard for the given project.

Parameters

project_id – Project identifier

Returns

A list of dashboard dictionaries.

Example:

>>> client.get_dashboards('2aEVClLRRA-vCCIvnuEAvQ')
[{u'id': u'G0Tm2SQcTqu2d4GvfyrsMg',
  u'search': {u'query': u'Test'},
  u'title': u'Test',
  u'type': u'dashboard',
  u'widgets': [{u'col': 1,
                u'id': 1,
                u'row': 1,
                u'size_x': 1,
                u'size_y': 1,
                u'title': u'Search Results',
                u'type': u'Search'}]}]
modify_dashboard(project_id, dashboard_id, title=None, search=None, type=None, column_count=None, row_height=None, theme_id=None, hide_title=None, reset_placement=None, sections=None, panels=None, sidepanel=None, loaders=None, widgets=None, mobileSections=None, desyncFromDesktop=None, restricted=None, default_store=None, master=None, role=None, transparent=None, layout=None, searchable=None, visible=None, communityWizard=None)#

Update a dashboard.

Parameters
  • project_id – Project identifier

  • dashboard_id – Dashboard identifier

  • title – Dashboard title

  • search – Search parameters for the dashboard

  • type – Dashboard type

  • column_count – Number of columns on this dashboard. Used by the frontend to render the widgets in the correct size.

  • row_height – Height in pixels of each row on this dashboard. Used by the frontend to render the widgets in the correct size.

  • theme_id – Associated theme id

  • hide_title – Boolean, whether to hide the dashboard title when shared

  • reset_placement – Position of the filter reset flyout, either left or right is supported

  • sections – Deprecated please use panels instead

  • panels – List of dashboard panels

  • widgets – Deprecated please use panels instead

  • sidepanel – Boolean, whether to show the sidepanel or not

  • mobileSections – Deprecated please use panels instead

  • desyncFromDesktop – Boolean, whether to sync the mobile content to desktop version or not

  • restricted – Boolean, whether the dashboard has permissions set

  • default_store – Dict, dashboard default store state to be saved with the dashboard

  • master – Deprecated, use role instead

  • role – str, Defines the role of a dashboard. Valid values are “search” & “normal”

  • transparent – Boolean, whether the dashboard uses a transparent background or not

  • layout – Dict, Dashboard layout configuration

  • searchable – Boolean, whether the dashboard is searchable or not

  • visible – Boolean, whether the dashboard is visible or not

  • communityWizard – Boolean, whether the dashboard opens the Community Wizard

Returns

A dictionary of the updated dashboard.

Example:

>>> client.modify_dashboard('2aEVClLRRA-vCCIvnuEAvQ',
...                         'YagQNSecR_ONHxwBmOkkeQ',
...                         search={'query': 'Demo'})
move_dashboard(project_id, dashboard_id, after)#

Move a dashboard.

Parameters
  • project_id – Project identifier

  • dashboard_id – Dashboard identifier

  • after – The dashboard identifier after which the dashboard should be moved. Can be None to move the dashboard to the beginning of the list.

Returns

No return value.

Example:

>>> client.move_dashboard('2aEVClLRRA-vCCIvnuEAvQ',
...                       'Ue1OceLkQlyz21wpPqml9Q',
...                       'nJXpKUSERmSgQRjxX7LrZw')
new_dashboard(project_id, title, search=None, type=None, column_count=None, row_height=None, theme_id=None, hide_title=None, reset_placement=None, sections=None, panels=None, sidepanel=None, mobileSections=None, loaders=None, desyncFromDesktop=None, dashboard_id=None, restricted=None, default_store=None, transparent=None, layout=None, searchable=None, visible=None, communityWizard=None)#

Create a new dashboard.

Parameters
  • project_id – Project identifier

  • title – Dashboard title

  • search – Search parameters for the dashboard

  • type – Dashboard type (dashboard or result). The latter is used for the chart view in the UI and not displayed as a dashboard tab.

  • column_count – Number of columns on this dashboard. Used by the frontend to render the widgets in the correct size.

  • row_height – Height in pixels of each row on this dashboard. Used by the frontend to render the widgets in the correct size.

  • theme_id – Dashboard theme identifier

  • hide_title – Boolean, whether to hide the dashboard title when shared

  • reset_placement – Position of the filter reset flyout, either left or right is supported

  • sections – Deprecated please use panels instead

  • panels – List of dashboard panels

  • sidepanel – Boolean, whether to show the sidepanel or not

  • mobileSections – Deprecated please use panels instead

  • desyncFromDesktop – Boolean, whether to prevent syncing the mobile content to desktop version or not

  • dashboard_id – Optional string parameter to create the dashboard with the provided id. The length of the parameter must be 22 characters. Useful when exporting and importing projects across multiple Squirro servers.

  • restricted – Boolean, whether the dashboard has permissions set

  • default_store – Dict, dashboard default store state to be saved with the dashboard

  • transparent – Boolean, whether the dashboard uses a transparent background or not

  • layout – Dict, Dashboard layout configuration

  • searchable – Boolean, whether the dashboard is searchable or not

  • visible – Boolean, whether the dashboard is visible or not

  • communityWizard – Boolean, whether the dashboard uses the communityWizard

Returns

A list of dashboard dictionaries.

Example:

>>> client.new_dashboard('2aEVClLRRA-vCCIvnuEAvQ', title='Sample')
    {u'column_count': 16,
     u'hide_title': False,
     u'id': u'8N38s1XsTAKE39TFC4kTkg',
     u'reset_placement': u'right',
     u'row_height': 55,
     u'search': None,
     u'panels': [],
     u'default_store': {},
     u'desyncFromDesktop': False,
     u'sidepanel': False,
     u'transparent': False,
     u'theme': {
         u'definition': {
             u'activeColor': u'#e55100',
             u'background': u'#ffffff',
             u'borderColor': u'#BDBDBD',
             u'borderRadius': 2,
             u'headerHeight': 30,
             u'marginBottom': 70,
             u'marginLeft': 10,
             u'marginRight': 10,
             u'marginTop': 10,
             u'titleColor': u'#616161',
             u'titleFontSize': 17,
             u'titleFontWeight': u'normal',
             u'titleTextAlignment': u'left',
             u'widgetGap': 5,
             u'widgets': {
                 u'Chord': {
                     u'activeBackground': u'#f5f5f5',
                     u'activeColor': u'#e55100',
                     u'background': u'#ffffff',
                     u'chartColorScheme': [
                         u'#4b8ecc',
                         u'#348f5f',
                         u'#ec6a2b',
                         u'#807dba',
                         u'#fec44f',
                         u'#009994',
                         u'#d43131',
                         u'#0d7074'
                     ],
                     u'headerAlignment': u'left',
                     u'headerBackground': u'#F5F5F5',
                     u'headerColor': u'#b6b6b6',
                     u'headerFontSize': 17,
                     u'headerFontWeight': u'normal',
                     u'linkBackground': u'#f5f5f5',
                     u'linkColor': u'#2196F3',
                     u'paddingBottom': 10,
                     u'paddingLeft': 10,
                     u'paddingRight': 10,
                     u'paddingTop': 5,
                     u'primaryButtonGradient1': u'#1484f9',
                     u'primaryButtonGradient2': u'#156fcc',
                     u'textColor': u'#212121'
                     },
                 u'Connection': {
                     u'color': u'#212121',
                     u'fontAlign': u'center',
                     u'fontSize': u'13',
                     u'fontWeight': u'normal',
                     u'hoverColor': u'#E3F2FD',
                     u'labelColor': u'#212121',
                     u'primaryButtonGradient1': u'#FFECB3',
                     u'primaryButtonGradient2': u'#EF5350'
                 },
                 u'Facets': {u'labelColor': u'#212121'},
                 u'FacetsHistogram': {
                     u'labelColor': u'#212121',
                     u'legendColor': u'#212121'
                 },
                 u'FacetsList': {
                     u'activeColor': u'#e55100',
                     u'barColor': u'#1484f9',
                     u'facetValueColor': u'#bdbdbd'
                 },
                 u'FacetsTable': {
                     u'activeBackground': u'#F5F5F5',
                     u'activeColor': u'#e55100',
                     u'headerColor': u'#616161'
                 },
                 u'Frequency': {u'labelColor': u'#212121'},
                 u'HorizontalResultList': {
                     u'linkColor': u'#2196F3',
                     u'subtitleColor': u'#616161'
                 },
                 u'IFrame': {},
                 u'Keywords': {
                     u'barColor': u'#1484f9',
                     u'headerColor': u'#616161',
                     u'linkColor': u'#2196F3'
                 },
                 u'PredQuery': {
                     u'activeBackground': u'#F5F5F5',
                     u'activeColor': u'#e55100'
                 },
                 u'Search': {
                     u'activeColor': u'#e55100',
                     u'titleColor': u'#616161',
                     u'titleColorRead': u'#212121',
                     u'titleFontSize': 15,
                     u'titleFontSizeRead': 15,
                     u'titleFontWeight': u'bolder',
                     u'titleFontWeightRead': u'bolder',
                     u'titleTextAlignment': u'left',
                     u'titleTextAlignmentRead': u'left'
                 },
                 u'SearchQuery': {
                     u'backgroundColor': u'#428bca',
                     u'borderColor': u'#1e88e5',
                     u'textColor': u'#ffffff'
                 },
                 u'SignificantTerms': {},
                 u'TagCloud': {},
                 u'default': {
                     u'activeBackground': u'#f5f5f5',
                     u'activeColor': u'#e55100',
                     u'background': u'#ffffff',
                     u'chartColorScheme': [
                         u'#64b5f6',
                         u'#E57373',
                         u'#FFD54F',
                         u'#81C784',
                         u'#7986CB',
                         u'#4DD0E1',
                         u'#F06292',
                         u'#AED581',
                         u'#A1887F',
                         u'#FFB74D',
                         u'#4FC3F7',
                         u'#FF8A65',
                         u'#DCE775',
                         u'#BA68C8'
                     ],
                     u'headerAlignment': u'left',
                     u'headerBackground': u'#F5F5F5',
                     u'headerColor': u'#616161',
                     u'headerFontSize': 17,
                     u'headerFontWeight': u'normal',
                     u'linkBackground': u'#f5f5f5',
                     u'linkColor': u'#2196F3',
                     u'paddingBottom': 10,
                     u'paddingLeft': 10,
                     u'paddingRight': 10,
                     u'paddingTop': 5,
                     u'textColor': u'#212121'
                 }
             }
         },
         u'id': u'ofVfiQ-uRWSZeGFZspH9nQ',
         u'scope': u'default',
         u'title': u'Squirro Default'},
        u'theme_id': u'ofVfiQ-uRWSZeGFZspH9nQ',
        u'title': u'foo',
        u'type': u'dashboard',
        u'layout': {},
        u'searchable': u'false',
        u'visible': u'true',
    }
set_default_dashboard_permissions(project_id, dashboard_id)#

This is a helper method to create default (admin-only) dashboard permissions with one call. It is equivalent to get_dashboard_permissions followed by set_dashboard_permissions (with an appropriate response handling from the get call)

Parameters
  • project_id – Project identifier

  • dashboard_id – Dashboard identifier

Returns

201 if successful, or 400 if the dashboard already had custom permissions in place.