1 from sfa.util.method import Method
2 from sfa.util.parameter import Parameter, Mixed
3 from sfa.trust.credential import Credential
5 class Register(Method):
7 Register an object with the registry. In addition to being stored in the
8 SFA database, the appropriate records will also be created in the
11 @param cred credential string
12 @param record_dict dictionary containing record fields
14 @return gid string representation
17 interfaces = ['registry']
20 Parameter(dict, "Record dictionary containing record fields"),
21 Mixed(Parameter(str, "Credential string"),
22 Parameter(type([str]), "List of credentials")),
25 returns = Parameter(int, "String representation of gid object")
27 def call(self, record, creds):
29 valid_creds = self.api.auth.checkCredentials(creds, 'register')
32 hrn = record.get('hrn', '')
33 self.api.auth.verify_object_permission(hrn)
36 origin_hrn = Credential(string=valid_creds[0]).get_gid_caller().get_hrn()
37 self.api.logger.info("interface: %s\tcaller-hrn: %s\ttarget-hrn: %s\tmethod-name: %s"%(self.api.interface, origin_hrn, hrn, self.name))
39 return self.api.manager.Register(self.api, record)