Skip to content

Commit

Permalink
Fixes for InheritedProjectLeader Capability in API 2.8
Browse files Browse the repository at this point in the history
  • Loading branch information
Bryant Howell committed Feb 12, 2018
1 parent 05cb7f9 commit aee2ac4
Show file tree
Hide file tree
Showing 2 changed files with 112 additions and 1 deletion.
32 changes: 31 additions & 1 deletion tableau_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand Down Expand Up @@ -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,
Expand All @@ -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 = {
Expand Down
81 changes: 81 additions & 0 deletions tableau_rest_api/permissions.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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:
Expand Down Expand Up @@ -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'

Expand All @@ -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

Expand Down Expand Up @@ -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')
Expand Down Expand Up @@ -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')
Expand All @@ -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'
}
}

0 comments on commit aee2ac4

Please sign in to comment.