addressing some of the remaining occurrences of SfaRecord
[sfa.git] / sfa / methods / List.py
1
2 from sfa.util.xrn import urn_to_hrn
3 from sfa.util.method import Method
4
5 from sfa.trust.credential import Credential
6
7 from sfa.storage.parameter import Parameter, Mixed
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     # xxx used to be [SfaRecord]
26     returns = [Parameter(dict, "registry record")]
27     
28     def call(self, xrn, creds):
29         hrn, type = urn_to_hrn(xrn)
30         valid_creds = self.api.auth.checkCredentials(creds, 'list')
31
32         #log the call
33         origin_hrn = Credential(string=valid_creds[0]).get_gid_caller().get_hrn()
34         self.api.logger.info("interface: %s\tcaller-hrn: %s\ttarget-hrn: %s\tmethod-name: %s"%(self.api.interface, origin_hrn, hrn, self.name))
35        
36         return self.api.manager.List(self.api, xrn)