d5cb8eb777d6f2cfa451e6e6f163dbdb2385b1ee
[plcapi.git] / PLC / Methods / GetNodeGroups.py
1 # $Id$
2 # $URL$
3 from PLC.Faults import *
4 from PLC.Method import Method
5 from PLC.Parameter import Parameter, Mixed
6 from PLC.Filter import Filter
7 from PLC.Auth import Auth
8 from PLC.NodeGroups import NodeGroup, NodeGroups
9
10 class GetNodeGroups(Method):
11     """
12     Returns an array of structs containing details about node groups.
13     If nodegroup_filter is specified and is an array of node group
14     identifiers or names, or a struct of node group attributes, only
15     node groups matching the filter will be returned. If return_fields
16     is specified, only the specified details will be returned.
17     """
18
19     roles = ['admin', 'pi', 'user', 'tech', 'node', 'anonymous']
20
21     accepts = [
22         Auth(),
23         Mixed([Mixed(NodeGroup.fields['nodegroup_id'],
24                      NodeGroup.fields['groupname'])],
25               Filter(NodeGroup.fields)),
26         Parameter([str], "List of fields to return", nullok = True)
27         ]
28
29     returns = [NodeGroup.fields]
30
31     def call(self, auth, nodegroup_filter = None, return_fields = None):
32         return NodeGroups(self.api, nodegroup_filter, return_fields)