From aee2ac41b26f51aebc3a8cdb8f7a4f84a5ca0fba Mon Sep 17 00:00:00 2001 From: Bryant Howell Date: Mon, 12 Feb 2018 14:13:00 -0600 Subject: [PATCH] Fixes for InheritedProjectLeader Capability in API 2.8 --- tableau_base.py | 32 ++++++++++++- tableau_rest_api/permissions.py | 81 +++++++++++++++++++++++++++++++++ 2 files changed, 112 insertions(+), 1 deletion(-) diff --git a/tableau_base.py b/tableau_base.py index a6c7240..c589b2c 100644 --- a/tableau_base.py +++ b/tableau_base.py @@ -104,6 +104,7 @@ def __init__(self): u'Download Full Data' : u'ViewUnderlyingData', u'Web Edit': u'WebAuthoring', u'Save': u'Write', + u'Inherited Project Leader': u'InheritedProjectLeader', u'all': u'all' # special command to do everything } @@ -181,6 +182,35 @@ def __init__(self): ) } + capabilities_2_8 = { + u"project": (u"Read", u"Write", u'ProjectLeader', u'InheritedProjectLeader'), + u"workbook": ( + u'Read', + u'ExportImage', + u'ExportData', + u'ViewComments', + u'AddComment', + u'Filter', + u'ViewUnderlyingData', + u'ShareView', + u'WebAuthoring', + u'Write', + u'ExportXml', + u'ChangeHierarchy', + u'Delete', + u'ChangePermissions', + + ), + u"datasource": ( + u'Read', + u'Connect', + u'Write', + u'ExportXml', + u'Delete', + u'ChangePermissions' + ) + } + self.available_capabilities = { u"2.0": capabilities_2_0, u"2.1": capabilities_2_1, @@ -190,7 +220,7 @@ def __init__(self): u'2.5': capabilities_2_1, u'2.6': capabilities_2_1, u'2.7': capabilities_2_1, - u'2.8': capabilities_2_1 + u'2.8': capabilities_2_8 } self.datasource_class_map = { diff --git a/tableau_rest_api/permissions.py b/tableau_rest_api/permissions.py index cec7106..991b3dc 100644 --- a/tableau_rest_api/permissions.py +++ b/tableau_rest_api/permissions.py @@ -101,9 +101,14 @@ def set_capability(self, capability_name, mode): :type mode: unicode :return: """ + if capability_name not in self.__server_to_rest_capability_map.values(): # If it's the Tableau UI naming, translate it over if capability_name in self.__server_to_rest_capability_map: + # InheritedProjectLeader (2.8+) is Read-Only + if capability_name == u'InheritedProjectLeader': + self.log(u'InheritedProjectLeader permission is read-only, skipping') + return if capability_name != u'all': capability_name = self.__server_to_rest_capability_map[capability_name] else: @@ -119,6 +124,9 @@ def set_capability_to_unspecified(self, capability_name): if capability_name not in self.capabilities: # If it's the Tableau UI naming, translate it over if capability_name in self.__server_to_rest_capability_map: + if capability_name == u'InheritedProjectLeader': + self.log(u'InheritedProjectLeader permission is read-only, skipping') + return if capability_name != u'all': capability_name = self.__server_to_rest_capability_map[capability_name] else: @@ -151,6 +159,8 @@ def set_all_to_allow(self): :return: """ for cap in self.capabilities: + if cap == u'InheritedProjectLeader': + continue if cap != u'all': self.capabilities[cap] = u'Allow' @@ -159,6 +169,8 @@ def set_all_to_unspecified(self): :return: """ for cap in self.capabilities: + if cap == u'InheritedProjectLeader': + continue if cap != u'all': self.capabilities[cap] = None @@ -230,6 +242,34 @@ def __init__(self, group_or_user, group_or_user_luid): } +class WorkbookPermissions28(Permissions): + def __init__(self, group_or_user, group_or_user_luid): + Permissions.__init__(self, group_or_user, group_or_user_luid, u'workbook') + for cap in self.available_capabilities[u'2.8'][u'workbook']: + if cap != u'all': + self.capabilities[cap] = None + self.role_set = { + u"Viewer": { + u'all': None, + u'View': u'Allow', + u'Export Image': u'Allow', + u'View Summary Data': u'Allow', + u'View Comments': u'Allow', + u'Add Comment': u'Allow' + }, + u"Interactor": { + u'all': u'Allow', + u'Download': None, + u'Move': None, + u'Delete': None, + u'Set Permissions': None, + u'Save': None + }, + u"Editor": { + u'all': u'Allow' + } + } + class ProjectPermissions20(Permissions): def __init__(self, group_or_user, group_or_user_luid): Permissions.__init__(self, group_or_user, group_or_user_luid, u'project') @@ -261,6 +301,29 @@ def __init__(self, group_or_user, group_or_user_luid): } +class ProjectPermissions28(Permissions): + def __init__(self, group_or_user, group_or_user_luid): + Permissions.__init__(self, group_or_user, group_or_user_luid, u'project') + for cap in self.available_capabilities[u'2.8'][u'project']: + if cap != u'all': + self.capabilities[cap] = None + self.role_set = { + u"Viewer": { + u'all': None, + u"View": u"Allow" + }, + u"Publisher": { + u'all': None, + u"View": u"Allow", + u"Save": u"Allow" + }, + u"Project Leader": { + u'all': None, + u"Project Leader": u"Allow" + } + } + + class DatasourcePermissions20(Permissions): def __init__(self, group_or_user, group_or_user_luid): Permissions.__init__(self, group_or_user, group_or_user_luid, u'datasource') @@ -285,3 +348,21 @@ def __init__(self, group_or_user, group_or_user_luid): u'all': u'Allow' } } + + +class DatasourcePermissions28(Permissions): + def __init__(self, group_or_user, group_or_user_luid): + Permissions.__init__(self, group_or_user, group_or_user_luid, u'datasource') + for cap in self.available_capabilities[u'2.8'][u'datasource']: + if cap != u'all': + self.capabilities[cap] = None + self.role_set = { + u"Connector": { + u'all': None, + u'View': u'Allow', + u'Connect': u'Allow' + }, + u"Editor": { + u'all': u'Allow' + } + }