support for negation with fields starting with ~
[plcapi.git] / PLC / Methods / GetForeignNodes.py
1 #
2 # Thierry Parmentelat - INRIA
3
4
5 from PLC.Faults import *
6 from PLC.Method import Method
7 from PLC.Parameter import Parameter, Mixed
8 from PLC.Filter import Filter
9 from PLC.Auth import Auth
10
11 from PLC.ForeignNodes import ForeignNode, ForeignNodes
12
13 class GetForeignNodes(Method):
14     """
15     Returns an array of structs containing details about foreign
16     nodes. If foreign_node_filter is specified and is an array of
17     foreign node identifiers or hostnames, or a struct of foreign node
18     attributes, only foreign nodes matching the filter will be
19     returned. If return_fields is specified, only the specified
20     details will be returned.
21     """
22
23     roles = ['admin']
24
25     accepts = [
26         Auth(),
27         Mixed([Mixed(ForeignNode.fields['node_id'],
28                      ForeignNode.fields['hostname'])],
29               Filter(ForeignNode.fields)),
30         Parameter([str], "List of fields to return", nullok = True)
31         ]
32     
33     returns = [ForeignNode.fields]
34
35     def call(self, auth, foreign_node_filter = None, return_fields = None):
36         return ForeignNodes(self.api, foreign_node_filter, return_fields)