X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=PLC%2FMethods%2FGetSites.py;h=a97386cef863157655a9f109cc24e00d42c82186;hb=b3bb59d264e4bc94efdf4a407e8d93d1768b92c5;hp=1a1b902ca878aa6346dc6fa690c7a0a394a0b5f0;hpb=de3dbf467250b4cca3b1677009d5380f0f629b0e;p=plcapi.git diff --git a/PLC/Methods/GetSites.py b/PLC/Methods/GetSites.py index 1a1b902..a97386c 100644 --- a/PLC/Methods/GetSites.py +++ b/PLC/Methods/GetSites.py @@ -1,46 +1,33 @@ -import os - +# $Id$ +# $URL$ from PLC.Method import Method from PLC.Parameter import Parameter, Mixed -from PLC.Auth import PasswordAuth +from PLC.Filter import Filter +from PLC.Auth import Auth from PLC.Sites import Site, Sites class GetSites(Method): """ - Return an array of structs containing details about all sites. If - site_id_list is specified, only the specified sites will be - queried. - + Returns an array of structs containing details about sites. If + site_filter is specified and is an array of site identifiers or + hostnames, or a struct of site attributes, only sites 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', 'anonymous'] accepts = [ - PasswordAuth(), - [Mixed(Site.fields['site_id'], - Site.fields['login_base'])] + Auth(), + Mixed([Mixed(Site.fields['site_id'], + Site.fields['login_base'])], + Parameter(str,"login_base"), + Parameter(int,"site_id"), + Filter(Site.fields)), + Parameter([str], "List of fields to return", nullok = True) ] returns = [Site.fields] - event_type = 'Get' - object_type = 'Site' - object_ids = [] - - def __init__(self, *args, **kwds): - Method.__init__(self, *args, **kwds) - # Update documentation with list of default fields returned - self.__doc__ += os.linesep.join(Site.fields.keys()) - - def call(self, auth, site_id_or_login_base_list = None): - - # Get site information - sites = Sites(self.api, site_id_or_login_base_list) - - # get id of objects affected by this call - self.object_ids = sites.keys() - - # turn each site into a real dict. - sites = [dict(site) for site in sites.values()] - - return sites + def call(self, auth, site_filter = None, return_fields = None): + return Sites(self.api, site_filter, return_fields)