1 from PLC.Faults import *
2 from PLC.Method import Method
3 from PLC.Parameter import Parameter, Mixed
4 from PLC.PCUs import PCU, PCUs
5 from PLC.Auth import Auth
9 Return an array of structs containing details about PCUs. If
10 pcu_id_list is specified, only the specified PCUs will be queried.
12 Admin may query all PCUs. Non-admins may only query the PCUs at
16 roles = ['admin', 'pi', 'tech']
20 [PCU.fields['pcu_id']]
23 returns = [PCU.fields]
25 def call(self, auth, pcu_ids = None):
26 # If we are not admin, make sure to only return our own PCUs
27 if 'admin' not in self.caller['roles']:
28 # Get list of PCUs that we are able to view
30 if self.caller['site_ids']:
31 sites = Sites(self.api, self.caller['site_ids']).values()
33 valid_pcu_ids += site['pcu_ids']
35 pcu_ids = set(pcu_ids).intersection(valid_pcu_ids)
39 return PCUs(self.api, pcu_ids).values()