(most) all functions now take SessionAuth in addition to PasswordAuth
[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.AddressTypes import AddressType, AddressTypes
5 from PLC.Auth import Auth
6
7 class GetAddressTypes(Method):
8     """
9     Get an array of structs containing details about valid address
10     types. If address_type_id_or_name_list is specified, only the
11     specified address types will be queried.
12     """
13
14     roles = ['admin', 'pi', 'user', 'tech']
15
16     accepts = [
17         Auth(),
18         [Mixed(AddressType.fields['address_type_id'],
19                AddressType.fields['name'])]
20         ]
21
22     returns = [AddressType.fields]
23
24     def call(self, auth, address_type_id_or_name_list = None):
25         address_types = AddressTypes(self.api, address_type_id_or_name_list).values()
26
27         return address_types