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.Sites import Site, Sites
6 from PLC.Auth import PasswordAuth
8 from PLC.Methods.AdmGetPersons import AdmGetPersons
10 class AdmGetPersonSites(AdmGetPersons):
12 Returns the sites that the specified person is associated with as
13 an array of site identifiers.
15 Admins may retrieve details about anyone. Users and techs may only
16 retrieve details about themselves. PIs may retrieve details about
17 themselves and others at their sites.
20 roles = ['admin', 'pi', 'user', 'tech']
24 Mixed(Person.fields['person_id'],
25 Person.fields['email'])
28 returns = [Site.fields['site_id']]
30 def call(self, auth, person_id_or_email):
31 persons = AdmGetPersons.call(self, auth, [person_id_or_email])
33 # AdmGetPersons() validates person_id_or_email
37 # Filter out deleted sites
38 sites = Sites(self.api, persons['site_ids'])
40 return [site['site_id'] for site in sites]