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 AdmDeletePersonKeys(Method):
10 Deprecated. Functionality can be implemented with GetPersons and
13 Deletes the specified keys. Non-admins may only delete their own
16 Returns 1 if successful, faults otherwise.
21 roles = ['admin', 'pi', 'tech', 'user']
25 Mixed(Person.fields['person_id'],
26 Person.fields['email']),
27 [Key.fields['key_id']]
30 returns = Parameter(int, '1 if successful')
32 def call(self, auth, person_id_or_email, key_ids):
33 # Get account information
34 persons = Persons(self.api, [person_id_or_email])
36 raise PLCInvalidArgument, "No such account"
39 PLCCheckLocalPerson(person,"AdmDeletePersonKeys")
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 = set(key_ids).intersection(person['key_ids'])
49 # Get associated key details
50 keys = Keys(self.api, key_ids)