b41d0a5a5cdc68271941af1109d2f82292c24bd8
[plcapi.git] / PLC / Methods / AdmQueryPerson.py
1 from PLC.Faults import *
2 from PLC.Method import Method
3 from PLC.Parameter import Parameter, Mixed
4 from PLC.Persons import Person, Persons
5 from PLC.Auth import Auth
6
7 class AdmQueryPerson(Method):
8     """
9     Deprecated. See GetPersons.
10     """
11
12     status = "deprecated"
13
14     roles = ['admin', 'pi', 'user', 'tech']
15
16     accepts = [
17         Auth(),
18         {'email': Person.fields['email']}
19         ]
20
21     returns = [Person.fields['person_id']]
22
23     def call(self, auth, search_vals):
24         if 'email' in search_vals:
25             persons = Persons(self.api, [search_vals['email']])
26             if persons:
27                 return [persons[0]['person_id']]
28
29         return []