From: Mark Huang Date: Fri, 20 Oct 2006 18:06:42 +0000 (+0000) Subject: - add backward compatibility function X-Git-Tag: pycurl-7_13_1~503 X-Git-Url: http://git.onelab.eu/?a=commitdiff_plain;h=4329f18589934d6fa45b6cd680d02faa86420535;p=plcapi.git - add backward compatibility function --- diff --git a/PLC/Methods/AdmGetSiteTechContacts.py b/PLC/Methods/AdmGetSiteTechContacts.py new file mode 100644 index 00000000..93a98196 --- /dev/null +++ b/PLC/Methods/AdmGetSiteTechContacts.py @@ -0,0 +1,45 @@ +from PLC.Faults import * +from PLC.Method import Method +from PLC.Parameter import Parameter, Mixed +from PLC.Sites import Site, Sites +from PLC.Persons import Person, Persons +from PLC.Auth import PasswordAuth + +class AdmGetSiteTechContacts(Method): + """ + Deprecated. Functionality can be implemented with GetSites and + GetPersons. + + Return a list of person_ids of the technical contacts for the site + specified. + """ + + status = "deprecated" + + roles = ['admin'] + + accepts = [ + PasswordAuth(), + Mixed(Site.fields['site_id'], + Site.fields['login_base']) + ] + + returns = Site.fields['person_ids'] + + def call(self, auth, site_id_or_login_base): + # Authenticated function + assert self.caller is not None + + # Get site information + sites = Sites(self.api, [site_id_or_login_base]).values() + if not sites: + raise PLCInvalidArgument, "No such site" + + site = sites[0] + + persons = Persons(self.api, site['person_ids']).values() + + has_tech_role = lambda person: 'tech' in person['roles'] + techs = filter(has_tech_role, persons) + + return [tech['person_id'] for tech in techs]