allow filters to be specified in most Get() calls
[plcapi.git] / PLC / Methods / GetNodeGroups.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.Auth import Auth
6 from PLC.NodeGroups import NodeGroup, NodeGroups
7
8 class GetNodeGroups(Method):
9     """
10     Returns an array of structs containing details about node groups.
11     If nodegroup_filter is specified and is an array of node group
12     identifiers or names, or a struct of node group attributes, only
13     node groups matching the filter will be returned.
14     """
15
16     roles = ['admin', 'pi', 'user', 'tech']
17
18     accepts = [
19         Auth(),
20         Mixed([Mixed(NodeGroup.fields['nodegroup_id'],
21                      NodeGroup.fields['name'])],
22               Filter(NodeGroup.fields))
23         ]
24
25     returns = [NodeGroup.fields]
26   
27     def call(self, auth, nodegroup_filter = None):
28         return NodeGroups(self.api, nodegroup_filter).values()