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
8 class AdmDeleteAllPersonKeys(Method):
10 Deprecated. Functionality can be implemented with GetPersons and
13 Deletes all of the keys associated with an account. Non-admins may
14 only delete their own keys.
16 Non-admins may only delete their own keys.
18 Returns 1 if successful, faults otherwise.
23 roles = ['admin', 'pi', 'tech', 'user']
27 Mixed(Person.fields['person_id'],
28 Person.fields['email'])
31 returns = Parameter(int, '1 if successful')
33 def call(self, auth, person_id_or_email):
34 # Get account information
35 persons = Persons(self.api, [person_id_or_email])
37 raise PLCInvalidArgument, "No such account"
39 person = persons.values()[0]
41 if 'admin' not in self.caller['roles']:
42 if self.caller['person_id'] != person['person_id']:
43 raise PLCPermissionDenied, "Not allowed to update specified account"
45 key_ids = person['key_ids']
49 # Get associated key details
50 keys = Keys(self.api, key_ids).values()