allow filters to be specified in most Get() calls
[plcapi.git] / PLC / Methods / GetNodeNetworks.py
1 from PLC.Faults import *
2 from PLC.Method import Method
3 from PLC.Parameter import Parameter, Mixed
4 from PLC.Filter import Filter
5 from PLC.NodeNetworks import NodeNetwork, NodeNetworks
6 from PLC.Auth import Auth
7
8 class GetNodeNetworks(Method):
9     """
10     Returns an array of structs containing details about node network
11     interfacess. If nodenetworks_filter is specified and is an array
12     of node network identifiers, or a struct of node network
13     attributes, only node network interfaces matching the filter will
14     be returned.
15     """
16
17     roles = ['admin', 'pi', 'user', 'tech']
18
19     accepts = [
20         Auth(),
21         Mixed([NodeNetwork.fields['nodenetwork_id']],
22               Filter(NodeNetwork.fields))
23         ]
24
25     returns = [NodeNetwork.fields]
26
27     def call(self, auth, nodenetwork_filter = None):
28         return NodeNetworks(self.api, nodenetwork_filter).values()