Merge from trunk
[plcapi.git] / trunk / PLC / Methods / GetSites.py
1 from PLC.Method import Method
2 from PLC.Parameter import Parameter, Mixed
3 from PLC.Filter import Filter
4 from PLC.Auth import Auth
5 from PLC.Sites import Site, Sites
6
7 class GetSites(Method):
8     """
9     Returns an array of structs containing details about sites. If
10     site_filter is specified and is an array of site identifiers or
11     hostnames, or a struct of site attributes, only sites matching the
12     filter will be returned. If return_fields is specified, only the
13     specified details will be returned.
14     """
15
16     roles = ['admin', 'pi', 'user', 'tech', 'node', 'anonymous']
17
18     accepts = [
19         Auth(),
20         Mixed([Mixed(Site.fields['site_id'],
21                      Site.fields['login_base'])],
22               Parameter(str,"login_base"),
23               Parameter(int,"site_id"),
24               Filter(Site.fields)),
25         Parameter([str], "List of fields to return", nullok = True)        
26         ]
27
28     returns = [Site.fields]
29
30     def call(self, auth, site_filter = None, return_fields = None):
31         return Sites(self.api, site_filter, return_fields)