trimmed useless imports, unstarred all imports
[sfa.git] / sfa / methods / List.py
1
2 from sfa.util.xrn import urn_to_hrn
3 from sfa.util.method import Method
4 from sfa.util.parameter import Parameter, Mixed
5 from sfa.util.record import SfaRecord
6 from sfa.trust.credential import Credential
7
8 class List(Method):
9     """
10     List the records in an authority. 
11
12     @param cred credential string specifying the rights of the caller
13     @param hrn human readable name of authority to list (hrn or urn)
14     @return list of record dictionaries         
15     """
16     interfaces = ['registry']
17     
18     accepts = [
19         Parameter(str, "Human readable name (hrn or urn)"),
20         Mixed(Parameter(str, "Credential string"),
21               Parameter(type([str]), "List of credentials")),
22         ]
23
24     returns = [SfaRecord]
25     
26     def call(self, xrn, creds):
27         hrn, type = urn_to_hrn(xrn)
28         valid_creds = self.api.auth.checkCredentials(creds, 'list')
29
30         #log the call
31         origin_hrn = Credential(string=valid_creds[0]).get_gid_caller().get_hrn()
32         self.api.logger.info("interface: %s\tcaller-hrn: %s\ttarget-hrn: %s\tmethod-name: %s"%(self.api.interface, origin_hrn, hrn, self.name))
33        
34         manager = self.api.get_interface_manager()
35         return manager.list(self.api, xrn)