084350f8678c2a7b14598e1b7e164afa8dd35a72
[plcapi.git] / PLC / Methods / GetRoles.py
1 from PLC.Faults import *
2 from PLC.Method import Method
3 from PLC.Parameter import Parameter, Mixed
4 from PLC.Roles import Role, Roles
5 from PLC.Auth import PasswordAuth
6
7 class GetRoles(Method):
8     """
9     Get an array of structs containing details about all roles.
10     """
11
12     roles = ['admin', 'pi', 'user', 'tech']
13
14     accepts = [
15         PasswordAuth()
16         ]
17
18     returns = [Role.fields]
19
20     def call(self, auth):
21         
22         roles = Roles(self.api).values()
23
24         #turn each role into a real dict
25         roles = [dict(role) for role in roles]
26
27         return roles