allow node authentication
[plcapi.git] / PLC / Methods / GetPeers.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.Peers import Peer, Peers
12
13 class GetPeers (Method):
14     """
15     Returns an array of structs containing details about peers. If
16     person_filter is specified and is an array of peer identifiers or
17     peer names, or a struct of peer attributes, only peers matching
18     the filter will be returned. If return_fields is specified, only the
19     specified details will be returned.
20     """
21
22     roles = ['admin', 'node']
23
24     accepts = [
25         Auth(),
26         Mixed([Mixed(Peer.fields['peer_id'],
27                      Peer.fields['peername'])],
28               Filter(Peer.fields)),
29         Parameter([str], "List of fields to return", nullok = True)        
30         ]
31
32     returns = [Peer.fields]
33
34     def call (self, auth, peer_filter = None, return_fields = None):
35         return Peers(self.api, peer_filter, return_fields)