Merge from trunk
[plcapi.git] / trunk / PLC / Methods / AdmQueryPerson.py
diff --git a/trunk/PLC/Methods/AdmQueryPerson.py b/trunk/PLC/Methods/AdmQueryPerson.py
new file mode 100644 (file)
index 0000000..b41d0a5
--- /dev/null
@@ -0,0 +1,29 @@
+from PLC.Faults import *
+from PLC.Method import Method
+from PLC.Parameter import Parameter, Mixed
+from PLC.Persons import Person, Persons
+from PLC.Auth import Auth
+
+class AdmQueryPerson(Method):
+    """
+    Deprecated. See GetPersons.
+    """
+
+    status = "deprecated"
+
+    roles = ['admin', 'pi', 'user', 'tech']
+
+    accepts = [
+        Auth(),
+        {'email': Person.fields['email']}
+        ]
+
+    returns = [Person.fields['person_id']]
+
+    def call(self, auth, search_vals):
+        if 'email' in search_vals:
+            persons = Persons(self.api, [search_vals['email']])
+            if persons:
+                return [persons[0]['person_id']]
+
+        return []