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