def get(self, actor_id): logger.debug("top of GET /actors/{}/workers for tenant {}.".format( actor_id, g.tenant)) dbid = Actor.get_dbid(g.tenant, actor_id) try: Actor.from_db(actors_store[dbid]) except KeyError: logger.debug("did not find actor: {}.".format(actor_id)) raise ResourceError("No actor found with id: {}.".format(actor_id), 404) try: workers = Worker.get_workers(dbid) except WorkerException as e: logger.debug( "did not find workers for actor: {}.".format(actor_id)) raise ResourceError(e.msg, 404) result = [] for id, worker in workers.items(): worker.update({'id': id}) try: w = Worker(**worker) result.append(w.display()) except Exception as e: logger.error( "Unable to instantiate worker in workers endpoint from description: {}. " .format(worker)) return ok(result=result, msg="Workers retrieved successfully.")
def get(self, actor_id, worker_id): logger.debug("top of GET /actors/{}/workers/{}.".format(actor_id, worker_id)) id = Actor.get_dbid(g.tenant, actor_id) try: Actor.from_db(actors_store[id]) except KeyError: logger.debug("Did not find actor: {}.".format(actor_id)) raise ResourceError("No actor found with id: {}.".format(actor_id), 404) try: worker = Worker.get_worker(id, worker_id) except WorkerException as e: logger.debug("Did not find worker: {}. actor: {}.".format(worker_id, actor_id)) raise ResourceError(e.msg, 404) # worker is an honest python dictionary with a single key, the id of the worker. need to # convert it to a Worker object worker.update({'id': worker_id}) w = Worker(**worker) return ok(result=w.display(), msg="Worker retrieved successfully.")