svn keywords
[plcapi.git] / PLC / Methods / SliceListUserSlices.py
1 # $Id$
2 # $URL$
3 from PLC.Method import Method
4 from PLC.Parameter import Parameter, Mixed
5 from PLC.Filter import Filter
6 from PLC.Auth import Auth
7 from PLC.Slices import Slice, Slices
8 from PLC.Persons import Person, Persons
9 from PLC.Methods.GetSlices import GetSlices
10 from PLC.Methods.GetPersons import GetPersons
11
12 class SliceListUserSlices(GetSlices, GetPersons):
13     """
14     Deprecated. Can be implemented with GetPersons and GetSlices.
15
16     Return the slices the specified user (by email address) is a member of.
17
18     Users may only query slices of which they are members. PIs may
19     query any of the slices at their sites. Admins may query any
20     slice. If a slice that cannot be queried is specified in
21     slice_filter, details about that slice will not be returned.
22     """
23
24     status = "deprecated"
25
26     roles = ['admin', 'pi', 'user']
27
28     accepts = [
29         Auth(),
30         Person.fields['email']
31         ]
32
33     returns = [Slice.fields['name']]
34     
35
36     def call(self, auth, email):
37
38         persons = GetPersons.call(self, auth, [email])
39         if not persons:
40                 return []
41         person = persons[0]
42         slice_ids = person['slice_ids']
43         if not slice_ids:
44                 return []
45         
46         slices = GetSlices.call(self, auth, slice_ids)
47         slice_names = [slice['name'] for slice in slices]
48
49         return slice_names