X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=PLC%2FMethods%2FGetAddresses.py;h=24d5aa28d9642c4bb3260cb7bda845312336cf2f;hb=34e1a55391f712d24f3932b98c7f26fcbd84baea;hp=b5240a5961af9ab70394835f356b046b784e5c5f;hpb=88fb75528cb840d3c339ffbce65252333a941961;p=plcapi.git diff --git a/PLC/Methods/GetAddresses.py b/PLC/Methods/GetAddresses.py index b5240a5..24d5aa2 100644 --- a/PLC/Methods/GetAddresses.py +++ b/PLC/Methods/GetAddresses.py @@ -1,29 +1,30 @@ from PLC.Faults import * from PLC.Method import Method from PLC.Parameter import Parameter, Mixed +from PLC.Filter import Filter from PLC.Addresses import Address, Addresses -from PLC.Auth import PasswordAuth +from PLC.Auth import Auth class GetAddresses(Method): """ - Get an array of structs containing details about addresses. If - address_id_list is specified, only the specified addresses will be - queried. + Returns an array of structs containing details about addresses. If + address_filter is specified and is an array of address + identifiers, or a struct of address attributes, only addresses + matching the filter will be returned. If return_fields is + specified, only the specified details will be returned. """ roles = ['admin', 'pi', 'user', 'tech'] accepts = [ - PasswordAuth(), - [Address.fields['address_id']], + Auth(), + Mixed([Address.fields['address_id']], + Filter(Address.fields)), + Parameter([str], "List of fields to return", nullok = True) ] returns = [Address.fields] + - def call(self, auth, address_id_list = None): - addresses = Addresses(self.api, address_id_list).values() - - # Turn each address into a real dict - addresses = [dict(address) for address in addresses] - - return addresses + def call(self, auth, address_filter = None, return_fields = None): + return Addresses(self.api, address_filter, return_fields)