async def http_add(self, request): """ --- description: Add tags: - Step parameters: - in: body name: body description: Created an step required: true schema: type: object responses: "200": description: successful operation """ data = await request.json() step = Step(name=data.get("name"), props=Props(data.get("props", {})), type=data.get("type")) response_data = await self.controller.add(step) return web.json_response(data=response_data.to_dict())
def create(self, data): id = data.get("id") name = data.get("name") type = data.get("type") status = StepState(data.get("status", "I")) props = Props(data.get("props", {})) try: type_cfg = self.types.get(type) clazz = type_cfg.get("class") instance = clazz(self.cbpi, id, name, props, self.done) except Exception as e: logging.warning("Failed to create step instance %s - %s" % (id, e)) instance = None step=Step(id, name, type=type, status=status, instance=instance, props=props ) return step
async def http_update(self, request): """ --- description: Update tags: - Step parameters: - in: body name: body description: Created an kettle required: false schema: type: object responses: "200": description: successful operation """ data = await request.json() id = request.match_info['id'] step = Step(id, data.get("name"), Props(data.get("props", {})), data.get("type")) return web.json_response((await self.controller.update(step)).to_dict())