4 from geni.util.faults import *
5 from geni.util.method import Method
6 from geni.util.parameter import Parameter, Mixed
7 from geni.util.auth import Auth
8 from geni.util.record import GeniRecord
10 from geni.server.registry import Registries
14 List the records in an authority.
16 @param cred credential string specifying the rights of the caller
17 @param hrn human readable name of authority to list
18 @return list of record dictionaries
21 interfaces = ['registry']
24 Parameter(str, "Credential string"),
25 Parameter(str, "Human readable name (hrn)")
28 returns = [GeniRecord]
30 def call(self, cred, hrn):
32 self.api.auth.check(cred, 'list')
35 if not self.api.auth.hierarchy.auth_exists(hrn):
36 raise MissingAuthority(hrn)
37 table = self.api.auth.get_auth_table(hrn)
38 records = table.list()
39 except MissingAuthority:
40 # is this a foreign authority
41 registries = Registries(self.api)
42 credential = self.api.getCredential()
43 for registry in registries:
44 if hrn.startswith(registry) and registry not in [self.api.hrn]:
45 record_list = registries[registry].list(credential, hrn)
46 for record in record_list:
47 records.append(record.as_dict())