trimmed useless imports, unstarred all imports
[sfa.git] / sfa / methods / get_registries.py
1 from sfa.util.xrn import urn_to_hrn
2 from sfa.util.method import Method
3 from sfa.util.parameter import Parameter, Mixed
4 from sfa.server.registry import Registries
5
6 class get_registries(Method):
7     """
8     Get a list of connection information for all known registries.      
9
10     @param cred credential string specifying the rights of the caller
11     @param a Human readable name (hrn or urn), or list of names or None
12     @return list of dictionaries with aggregate information.  
13     """
14
15     interfaces = ['registry', 'aggregate', 'slicemgr']
16     
17     accepts = [
18         Parameter(str, "Credential string"),
19         Mixed(Parameter(str, "Human readable name (hrn or urn)"),
20               Parameter(None, "hrn not specified"))
21         ]
22
23     returns = [Parameter(dict, "Registry interface information")]
24     
25     def call(self, cred, xrn = None):
26         hrn, type = urn_to_hrn(xrn)
27         self.api.auth.check(cred, 'list')
28         registries = Registries(self.api).values()
29         if hrn:
30             registries = [reg for reg in registries if reg['hrn'] == hrn] 
31         return registries