1 from PLC.Faults import *
2 from PLC.Method import Method
3 from PLC.Parameter import Parameter, Mixed
4 from PLC.Persons import Person, Persons
5 from PLC.Keys import Key, Keys
6 from PLC.Auth import Auth
7 from PLC.Methods.GetKeys import GetKeys
9 class AdmGetPersonKeys(GetKeys):
11 Deprecated. Functionality can be implemented with GetPersons and
17 roles = ['admin', 'pi', 'user', 'tech']
21 Mixed(Person.fields['person_id'],
22 Person.fields['email']),
23 [Key.fields['key_id']]
26 returns = [Key.fields]
28 def call(self, auth, person_id_or_email):
29 # Get account information
30 persons = Persons(self.api, [person_id_or_email])
32 raise PLCInvalidArgument, "No such account"
36 if 'admin' not in self.caller['roles']:
37 if self.caller['person_id'] != person['person_id']:
38 raise PLCPermissionDenied, "Not allowed to view keys for specified account"
40 return GetKeys.call(self, auth, person['key_ids'])