b4ea459864a87af609c1fd5f4fb23186f02e767b
[plcapi.git] / PLC / Methods / GetNodeTags.py
1 # $Id$
2 #
3 # Thierry Parmentelat - INRIA
4 #
5 # $Revision: 9423 $
6 #
7 from PLC.Faults import *
8 from PLC.Method import Method
9 from PLC.Parameter import Parameter, Mixed
10 from PLC.Filter import Filter
11 from PLC.Auth import Auth
12
13 from PLC.NodeTags import NodeTag, NodeTags
14 from PLC.Sites import Site, Sites
15 from PLC.Nodes import Node, Nodes
16
17 class GetNodeTags(Method):
18     """
19     Returns an array of structs containing details about
20     nodes and related tags.
21
22     If node_tag_filter is specified and is an array of
23     node tag identifiers, only node tags matching
24     the filter will be returned. If return_fields is specified, only
25     the specified details will be returned.
26     """
27
28     roles = ['admin', 'pi', 'user', 'node']
29
30     accepts = [
31         Auth(),
32         Mixed([NodeTag.fields['node_tag_id']],
33               Parameter(int,"Node tag id"),
34               Filter(NodeTag.fields)),
35         Parameter([str], "List of fields to return", nullok = True)
36         ]
37
38     returns = [NodeTag.fields]
39     
40
41     def call(self, auth, node_tag_filter = None, return_fields = None):
42
43         node_tags = NodeTags(self.api, node_tag_filter, return_fields)
44
45         return node_tags