Last active
February 11, 2016 03:27
-
-
Save MrCreosote/b221bbbac60e7f0586ae to your computer and use it in GitHub Desktop.
Hide public workspaces via the administration interface
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
''' | |
Makes the specified workspaces non-public. | |
Parameters: | |
wsclient - an initialized workspace client. The user logged into the client | |
must be a workspace administrator. | |
wslist - a list of workspace IDs and / or names. | |
''' | |
def hidePublicWorkspaces(wsclient, wslist): | |
adminname = wsclient._headers['AUTHORIZATION'].split('|')[0].split('=')[1] | |
for ws in wslist: | |
try: | |
wsi = {'id': int(ws)} | |
except: | |
wsi = {'workspace': ws} | |
prevperm = wsclient.get_permissions(wsi)[adminname] | |
permsparams = {'users': [adminname], | |
'new_permission': 'a'} | |
permsparams.update(wsi) | |
wsclient.administer({'command': 'setPermissions', | |
'params': permsparams, | |
'user': adminname | |
}) | |
del permsparams['users'] | |
permsparams['new_permission'] = 'n' | |
wsclient.administer({'command': 'setGlobalPermission', | |
'params': permsparams, | |
'user': adminname | |
}) | |
permsparams.update({'users': [adminname], | |
'new_permission': prevperm | |
}) | |
wsclient.administer({'command': 'setPermissions', | |
'params': permsparams, | |
'user': adminname | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Usage: