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
9 from geni.registry import Registries
13 List the records in an authority.
15 @param cred credential string specifying the rights of the caller
16 @param hrn human readable name of authority to list
17 @return list of record dictionaries
20 interfaces = ['registry']
23 Parameter(str, "Credential string"),
24 Parameter(str, "Human readable name (hrn)")
27 returns = [GeniRecord]
29 def call(self, cred, hrn):
31 self.api.auth.check(cred, 'list')
34 if not self.api.auth.hierarchy.auth_exists(hrn):
35 raise MissingAuthority(hrn)
36 table = self.api.auth.get_auth_table(hrn)
37 records = table.list()
38 except MissingAuthority:
39 # is this a foreign authority
40 registries = Registries(self.api)
41 credential = self.api.getCredential()
42 for registry in registries:
43 if hrn.startswith(registry) and registry not in [self.api.hrn]:
44 record_list = registries[registry].list(credential, hrn)
45 for record in record_list:
46 records.append(record.as_dict())