Exemplo n.º 1
0
 async def http_update(self, request):
     """
     ---
     description: Update an actor
     tags:
     - Actor
     parameters:
     - name: "id"
       in: "path"
       description: "Actor ID"
       required: true
       type: "integer"
       format: "int64"
     - in: body
       name: body
       description: Update an actor
       required: false
       schema:
         type: object
         properties:
           name:
             type: string
           type:
             type: string
           config:
             props: object
     responses:
         "200":
             description: successful operation
     """
     id = request.match_info['id']
     data = await request.json()
     actor = Actor(id=id, name=data.get("name"), props=Props(data.get("props", {})), type=data.get("type"))
     return web.json_response(data=(await self.controller.update(actor)).to_dict())
Exemplo n.º 2
0
    async def http_add(self, request):
        """
        ---
        description: add one Actor
        tags:
        - Actor
        parameters:
        - in: body
          name: body
          description: Created an actor
          required: true
          
          schema:
            type: object
            
            properties:
              name:
                type: string
              type:
                type: string
              props:
                type: object
            example: 
              name: "Actor 1"
              type: "CustomActor"
              props: {}
              
        responses:
            "204":
                description: successful operation
        """
        data = await request.json()
        actor = Actor(name=data.get("name"),
                      props=Props(data.get("props", {})),
                      type=data.get("type"))
        response_data = await self.controller.add(actor)

        return web.json_response(data=response_data.to_dict())