allow filters to be specified in most Get() calls
[plcapi.git] / PLC / Methods / GetAddressTypes.py
1 from PLC.Faults import *
2 from PLC.Method import Method
3 from PLC.Parameter import Parameter, Mixed
4 from PLC.Filter import Filter
5 from PLC.AddressTypes import AddressType, AddressTypes
6 from PLC.Auth import Auth
7
8 class GetAddressTypes(Method):
9     """
10     Returns an array of structs containing details about address
11     types.  If address_type_filter is specified and is an array of
12     address type identifiers, or a struct of address type attributes,
13     only address types matching the filter will be returned.
14     """
15
16     roles = ['admin', 'pi', 'user', 'tech']
17
18     accepts = [
19         Auth(),
20         Mixed([Mixed(AddressType.fields['address_type_id'],
21                      AddressType.fields['name'])],
22               Filter(AddressType.fields))
23         ]
24
25     returns = [AddressType.fields]
26
27     def call(self, auth, address_type_filter = None):
28         return AddressTypes(self.api, address_type_filter).values()