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
9 Return an array of structs containing details about keys. If
10 key_id_list is specified, only the specified keys will be queried.
12 Admin may query all keys. Non-admins may only query their own
16 roles = ['admin', 'pi', 'user', 'tech']
20 [Key.fields['key_id']]
23 returns = [Key.fields]
25 def call(self, auth, key_id_list = None):
26 # If we are not admin, make sure to only return our own keys
27 if 'admin' not in self.caller['roles']:
29 key_id_list = self.caller['key_ids']
31 valid_keys = lambda x: x in self.caller['key_ids']
32 key_id_list = filter(valid_keys, key_id_list)
34 keys = Keys(self.api, key_id_list).values()
36 # Turn each key into a real dict
37 keys = [dict(key) for key in keys]