Merge remote-tracking branch 'origin/pycurl' into planetlab-4_0-branch
[plcapi.git] / PLC / Methods / AdmGetAllRoles.py
index 7dc2d15..2b88714 100644 (file)
@@ -1,11 +1,13 @@
 from PLC.Faults import *
 from PLC.Method import Method
 from PLC.Parameter import Parameter
-from PLC.Roles import Roles
-from PLC.Auth import PasswordAuth
+from PLC.Auth import Auth
+from PLC.Methods.GetRoles import GetRoles
 
-class AdmGetAllRoles(Method):
+class AdmGetAllRoles(GetRoles):
     """
+    Deprecated. See GetRoles.
+
     Return all possible roles as a struct:
 
     {'10': 'admin', '20': 'pi', '30': 'user', '40': 'tech'}
@@ -15,18 +17,16 @@ class AdmGetAllRoles(Method):
     identifiers.
     """
 
-    roles = ['admin', 'pi', 'user', 'tech']
-    accepts = [PasswordAuth()]
-    returns = dict
+    status = "deprecated"
 
-    def call(self, auth, person_id_or_email_list = None, return_fields = None):
-        roles = Roles(self.api)
+    returns = dict
 
-        # Just the role_id: name mappings
-        roles = dict(filter(lambda (role_id, name): isinstance(role_id, (int, long)), \
-                            roles.items()))
+    def call(self, auth):
+        roles_list = GetRoles.call(self, auth)
 
-        # Stringify the keys!
-        keys = map(str, roles.keys())
+        roles_dict = {}
+        for role in roles_list:
+            # Stringify the keys!
+            roles_dict[str(role['role_id'])] = role['name']
 
-        return dict(zip(keys, roles.values()))
+        return roles_dict