svn keywords
[plcapi.git] / PLC / Methods / GetAddresses.py
index eea3885..a45cc87 100644 (file)
@@ -1,41 +1,32 @@
+# $Id$
+# $URL$
 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)