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