from PLC.Method import Method
from PLC.Parameter import Parameter, Mixed
from PLC.PCUs import PCU, PCUs
-from PLC.Auth import PasswordAuth
-from PLC.Methods.GetPCUs import GetPCUs
+from PLC.Auth import Auth
-class AdmGetPowerControlUnitNodes(GetPCUs):
+class AdmGetPowerControlUnitNodes(Method):
"""
Deprecated. See GetPCUs.
their sites.
"""
+ status = "deprecated"
+
roles = ['admin', 'pi', 'tech']
accepts = [
- PasswordAuth(),
+ Auth(),
PCU.fields['pcu_id']
]
'port_number': Parameter(int, "Port number")}]
def call(self, auth, pcu_id):
- pcus = GetPCUs.call(self, auth, [pcu_id])
+ pcus = PCUs(self.api, [pcu_id])
if not pcus:
raise PLCInvalidArgument, "No such PCU"
pcu = pcus[0]
+ if 'admin' not in self.caller['roles']:
+ if pcu['site_id'] not in self.caller['site_ids']:
+ raise PLCPermissionDenied, "Not allowed to view that PCU"
+
return [{'node_id': node_id, 'port_number': port} \
for (node_id, port) in zip(pcu['node_ids'], pcu['ports'])]