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