1 from PLC.Faults import *
2 from PLC.Method import Method
3 from PLC.Parameter import Parameter, Mixed
4 from PLC.Keys import Key, Keys
5 from PLC.Auth import PasswordAuth
7 class DeleteKey(Method):
11 Non-admins may only delete their own keys.
13 Returns 1 if successful, faults otherwise.
16 roles = ['admin', 'pi', 'tech', 'user']
23 returns = Parameter(int, '1 if successful')
25 def call(self, auth, key_id):
26 # Get associated key details
27 keys = Keys(self.api, [key_id]).values()
29 raise PLCInvalidArgument, "No such key"
32 if 'admin' not in self.caller['roles']:
33 if key['key_id'] not in self.caller['key_ids']:
34 raise PLCPermissionDenied, "Key must be associated with your account"