def get_homeowner(): service = zookeeper.get_service("homeowner-service") if service: manager = RequestManager(request, service) homeownerId = manager.authenticate() if homeownerId: return manager.get("homeowner/v1/Homeowner") return Response(response="Not Authorized", status=401) return Response(response="Error: Zookeeper down", status=503)
def get_problem(problemId): homeownerService = zookeeper.get_service("homeowner-service") if homeownerService: homeownerManager = RequestManager(request, homeownerService) homeownerId = homeownerManager.authenticate() if homeownerId: tenantService = zookeeper.get_service("problem-service") if tenantService: tenantManager = RequestManager(request, tenantService) return tenantManager.get("problem/v1/Problem/" + str(problemId)) return Response(response="Error: Tenant Not Available", status=503) return Response(response="Not Authorized", status=401) return Response(response="Error: Homeowner Not Available", status=503)
def get_tenants_by_house_id(houseId): homeownerService = zookeeper.get_service("homeowner-service") if homeownerService: homeownerManager = RequestManager(request, homeownerService) homeownerId = homeownerManager.authenticate() if homeownerId: tenantService = zookeeper.get_service("tenant-service") if tenantService: tenantManager = RequestManager(request, tenantService) return tenantManager.get("tenant/v1/House/" + str(houseId) + "/Tenant") return Response(response="Error: Tenant Not Available", status=503) return Response(response="Not Authorized", status=401) return Response(response="Error: Homeowner Not Available", status=503)
def get_homeowner_documents(houseId): homeownerService = zookeeper.get_service("homeowner-service") if homeownerService: homeownerManager = RequestManager(request, homeownerService) homeownerId = homeownerManager.authenticate() if homeownerId: documentService = zookeeper.get_service("document-service") if documentService: documentManager = RequestManager(request, documentService) return documentManager.get("document/v1/Document/" + str(houseId)) return Response(response="Error: Documents Not Available", status=503) return Response(response="Not Authorized", status=401) return Response(response="Error: Homeowner Not Available", status=503)
def get_problems(houseId): homeownerService = zookeeper.get_service("homeowner-service") if homeownerService: homeownerManager = RequestManager(request, homeownerService) homeownerId = homeownerManager.authenticate() if homeownerId: problemService = zookeeper.get_service("problem-service") if problemService: problemManager = RequestManager(request, problemService) return problemManager.get("problem/v1/House/" + str(houseId) + "/Problem") return Response(response="Error: problem service Not Available", status=503) return Response(response="Not Authorized", status=401) return Response(response="Error: Homeowner Not Available", status=503)