Exemple #1
0
    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())
Exemple #2
0
    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
Exemple #3
0
    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())