Maintenance will be performed on git.ligo.org, chat.ligo.org, containers.ligo.org, and docs.ligo.org on the morning of Tuesday 11th August 2020, starting at approximately 9am PDT. It is expected to take around 20 minutes and there will be a short period of downtime (less than five minutes) towards the end of the maintenance window. Please direct any comments, questions, or concerns to computing-help@ligo.org.

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