svn keywords
[plcapi.git] / PLC / Methods / SliceUsersList.py
index 9100691..2c39925 100644 (file)
@@ -1,13 +1,17 @@
+# $Id$
+# $URL$
 from PLC.Method import Method
 from PLC.Parameter import Parameter, Mixed
 from PLC.Filter import Filter
 from PLC.Auth import Auth
 from PLC.Slices import Slice, Slices
 from PLC.Persons import Person, Persons
+from PLC.Methods.GetSlices import GetSlices
+from PLC.Methods.GetPersons import GetPersons
 
-class SliceUsersList(Method):
+class SliceUsersList(GetSlices, GetPersons):
     """
-    Deprecated. Can be implemented with GetSlices.
+    Deprecated. Can be implemented with GetSlices and GetPersons.
 
     List users that are members of the named slice.
 
@@ -17,6 +21,8 @@ class SliceUsersList(Method):
     about that slice will not be returned.
     """
 
+    status = "deprecated"
+
     roles = ['admin', 'pi', 'user']
 
     accepts = [
@@ -28,29 +34,14 @@ class SliceUsersList(Method):
     
 
     def call(self, auth, slice_name):
-       # If we are not admin, make sure to return only viewable
-       # slices.
+
        slice_filter = [slice_name]
-        slices = Slices(self.api, slice_filter)
+        slices = GetSlices.call(self, auth, slice_filter)
        if not slices:
-            raise PLCInvalidArgument, "No such slice"
+            return []
        slice = slices[0]
      
-       if 'admin' not in self.caller['roles']:
-            # Get slices that we are able to view
-            valid_slice_ids = self.caller['slice_ids']
-            if 'pi' in self.caller['roles'] and self.caller['site_ids']:
-                sites = Sites(self.api, self.caller['site_ids'])
-                for site in sites:
-                    valid_slice_ids += site['slice_ids']
-
-            if not valid_slice_ids:
-                return []
-
-           if slice['slice_id'] not in valid_slice_ids:
-               return []
-       
-       persons = Persons(self.api, slice['person_ids'])
-       person_names = [person['email'] for person in persons]
-
-        return person_names
+       persons = GetPersons.call(self, auth, slice['person_ids'])
+       person_emails = [person['email'] for person in persons]
+
+        return person_emails