Branch 5.0 for module PLCAPI created from tag PLCAPI-4.2-8
[plcapi.git] / PLC / Methods / AdmGetAllRoles.py
1 from PLC.Faults import *
2 from PLC.Method import Method
3 from PLC.Parameter import Parameter
4 from PLC.Auth import Auth
5 from PLC.Methods.GetRoles import GetRoles
6
7 class AdmGetAllRoles(GetRoles):
8     """
9     Deprecated. See GetRoles.
10
11     Return all possible roles as a struct:
12
13     {'10': 'admin', '20': 'pi', '30': 'user', '40': 'tech'}
14
15     Note that because of XML-RPC marshalling limitations, the keys to
16     this struct are string representations of the integer role
17     identifiers.
18     """
19
20     status = "deprecated"
21
22     returns = dict
23
24     def call(self, auth):
25         roles_list = GetRoles.call(self, auth)
26
27         roles_dict = {}
28         for role in roles_list:
29             # Stringify the keys!
30             roles_dict[str(role['role_id'])] = role['name']
31
32         return roles_dict