This commit was manufactured by cvs2svn to create branch
[plcapi.git] / PLC / Methods / SliceUsersList.py
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
7 from PLC.Methods.GetSlices import GetSlices
8 from PLC.Methods.GetPersons import GetPersons
9
10 class SliceUsersList(GetSlices, GetPersons):
11     """
12     Deprecated. Can be implemented with GetSlices and GetPersons.
13
14     List users that are members of the named slice.
15
16     Users may only query slices of which they are members. PIs may
17     query any of the slices at their sites. Admins may query any
18     slice. If a slice that cannot be queried is specified details 
19     about that slice will not be returned.
20     """
21
22     roles = ['admin', 'pi', 'user']
23
24     accepts = [
25         Auth(),
26         Slice.fields['name']
27         ]
28
29     returns = [Person.fields['email']]
30     
31
32     def call(self, auth, slice_name):
33
34         slice_filter = [slice_name]
35         slices = GetSlices.call(self, auth, slice_filter)
36         if not slices:
37             return []
38         slice = slices[0]
39      
40         persons = GetPersons.call(self, auth, slice['person_ids'])
41         person_emails = [person['email'] for person in persons]
42
43         return person_emails