3 # Thierry Parmentelat - INRIA
6 from PLC.Method import Method
7 from PLC.Parameter import Parameter, Mixed
8 from PLC.Auth import Auth
9 from PLC.Peers import Peer, Peers
11 can_update = lambda (field, value): field in \
12 ['peername', 'peer_url', 'key', 'cacert']
14 class AddPeer(Method):
18 Returns the new peer_id (> 0) if successful, faults otherwise.
23 peer_fields = dict(filter(can_update, Peer.fields.items()))
30 returns = Parameter(int, "New peer_id (> 0) if successful")
32 def call(self, auth, peer_fields):
33 peer = Peer(self.api, peer_fields);
35 self.event_objects = {'Peer': [peer['peer_id']]}
37 return peer['peer_id']