1 from PLC.Faults import *
2 from PLC.Method import Method
3 from PLC.Parameter import Parameter, Mixed
4 from PLC.PCUTypes import PCUType, PCUTypes
5 from PLC.Auth import Auth
6 from PLC.Filter import Filter
8 class GetPCUTypes(Method):
10 Returns an array of PCU Types.
13 roles = ['admin', 'pi', 'user', 'tech', 'node']
17 Mixed([PCUType.fields['pcu_type_id'],
18 PCUType.fields['model']],
19 Filter(PCUType.fields)),
20 Parameter([str], "List of fields to return", nullok = True)
23 returns = [PCUType.fields]
26 def call(self, auth, pcu_type_filter = None, return_fields = None):
28 #Must query at least pcu_type_id
29 if return_fields is not None:
31 if 'pcu_type_id' not in return_fields:
32 return_fields.append('pcu_type_id')
33 added_fields.append('pcu_type_id')
34 if 'pcu_protocol_types' in return_fields and \
35 'pcu_protocol_type_ids' not in return_fields:
36 return_fields.append('pcu_protocol_type_ids')
37 added_fields.append('pcu_protocol_type_ids')
41 pcu_types = PCUTypes(self.api, pcu_type_filter, return_fields)
43 # remove added fields and protocol_types
44 for added_field in added_fields:
45 for pcu_type in pcu_types:
46 del pcu_type[added_field]