1 from PLC.Method import Method
2 from PLC.Parameter import Parameter, Mixed
3 from PLC.Filter import Filter
4 from PLC.Auth import Auth
5 from PLC.Slices import Slice, Slices
6 from PLC.Persons import Person, Persons
8 class SliceUsersList(Method):
10 Deprecated. Can be implemented with GetSlices.
12 List users that are members of the named slice.
14 Users may only query slices of which they are members. PIs may
15 query any of the slices at their sites. Admins may query any
16 slice. If a slice that cannot be queried is specified details
17 about that slice will not be returned.
20 roles = ['admin', 'pi', 'user']
27 returns = [Person.fields['email']]
30 def call(self, auth, slice_name):
31 # If we are not admin, make sure to return only viewable
33 slice_filter = [slice_name]
34 slices = Slices(self.api, slice_filter)
36 raise PLCInvalidArgument, "No such slice"
39 if 'admin' not in self.caller['roles']:
40 # Get slices that we are able to view
41 valid_slice_ids = self.caller['slice_ids']
42 if 'pi' in self.caller['roles'] and self.caller['site_ids']:
43 sites = Sites(self.api, self.caller['site_ids'])
45 valid_slice_ids += site['slice_ids']
47 if not valid_slice_ids:
50 if slice['slice_id'] not in valid_slice_ids:
53 persons = Persons(self.api, slice['person_ids'])
54 person_names = [person['email'] for person in persons]