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 Get an array of structs containing the keys for the specified
10 key_ids. If key_id_list is not specified, all keys
13 Admin may get all keys. Non-admins can only get their own keys
16 roles = ['admin', 'pi', 'user', 'tech']
20 [Key.fields['key_id']]
23 returns = [Key.fields]
25 def call(self, auth, key_id_list = None):
27 #if we are not admin, make sure to only return our own keys
28 if 'admin' not in self.caller['roles']:
29 if key_id_list is None:
30 key_id_list = self.caller['key_ids']
32 valid_keys = lambda x: x in self.caller['key_ids']
33 key_id_list = filter(valid_keys, key_id_list)
35 keys = Keys(self.api, key_id_list).values()
37 # Filter out undesired or None fields (XML-RPC cannot marshal
38 # None) and turn each key into a real dict.
39 valid_return_fields_only = lambda (key, value): value is not None
40 keys = [dict(filter(valid_return_fields_only, key.items())) \