X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=PLC%2FMethods%2FGetAddresses.py;h=b299295ee7e4d657841a691fb8dd37441c6550cb;hb=3a24db70ba35a4ffb85d5e7c761b5dbc87b93e40;hp=eea3885c0840b74fb39fc637affd0766b9c11c7a;hpb=73f8aff35c77b2b8c3c8326a4bf3f7faecde7878;p=plcapi.git diff --git a/PLC/Methods/GetAddresses.py b/PLC/Methods/GetAddresses.py index eea3885..b299295 100644 --- a/PLC/Methods/GetAddresses.py +++ b/PLC/Methods/GetAddresses.py @@ -1,41 +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.Sites import Site, Sites -from PLC.Auth import PasswordAuth +from PLC.Auth import Auth class GetAddresses(Method): """ - Get an array of structs containing the addresses of the specified - site. 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'] + roles = ['admin', 'pi', 'user', 'tech', 'node'] accepts = [ - PasswordAuth(), - Mixed(Site.fields['site_id'], - Site.fields['login_base']), - [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, site_id_or_login_base, address_id_list = None): - sites = Sites(self.api, [site_id_or_login_base]).values() - if not sites: - raise PLCInvalidArgument, "No such site" - site = sites[0] - - if address_id_list is None: - address_id_list = site['address_ids'] - else: - if set(address_id_list).intersection(site['address_ids']) != \ - set(address_id_list): - raise PLCInvalidArgument, "Invalid address ID(s)" - - addresses = Addresses(self.api, address_id_list).values() - - return addresses + def call(self, auth, address_filter = None, return_fields = None): + return Addresses(self.api, address_filter, return_fields)