Commit c9508a51 authored by Tanner Prestegard's avatar Tanner Prestegard

Adding functions for permissions

Added functions for getting permission lists and details, as well as
exposing/hiding superevents and events to the public.
parent a87160cb
......@@ -1815,6 +1815,71 @@ class GraceDb(GsiRest):
response = FakeResponse(r_json, response.status)
return response
@event_or_superevent
def permissions(self, object_id, group_name=None, *args, **kwargs):
"""
Get a list of permissions by group for an event or superevent.
Signature:
permissions(object_id, group_name=None)
Arguments:
object_id: event graceid or superevent id
group_name: name of group whose permissions should be shown
(optional, list of permissions for all groups is
shown otherwise)
NOTE: not currently implemented for events.
"""
is_superevent = kwargs.pop('is_superevent', False)
if is_superevent:
if group_name:
template = self.templates[
'superevent-permission-detail-template']
else:
template = self.templates[
'superevent-permission-list-template']
uri_kwargs = {'superevent_id': object_id}
else:
raise NotImplementedError('Not implemented for events')
if group_name:
uri_kwargs['name'] = group_name
uri = template.format(**uri_kwargs)
return self.get(uri)
@event_or_superevent
def modify_permissions(self, object_id, action, *args, **kwargs):
"""
Expose or hide an event or superevent to/from the public.
Requires specific server-side permissions.
Signature:
modify_permissions(object_id, action
Arguments:
object_id: event graceid or superevent id
action: 'expose' or 'hide'
NOTE: not currently implemented for events.
"""
if (action not in ['expose', 'hide']):
raise ValueError('action should be \'expose\' or \'hide\'')
is_superevent = kwargs.pop('is_superevent', False)
if is_superevent:
template = self.templates[
'superevent-permission-modify-template']
uri_kwargs = {'superevent_id': object_id}
else:
raise NotImplementedError('Not implemented for events')
uri = template.format(**uri_kwargs)
body = {'action': action}
return self.post(uri, body=body)
#-----------------------------------------------------------------
# TBD
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment