Пример #1
0
def list_allocations():
    """
    Lists allocations.
    ---
    tags:
      - allocation
    parameters:
      - name: show
        in: query
        type: string
        description: Show different allocations
        default: current
        enum: [all, current, finished]
    responses:
      200:
        description: Allocations of Packet Tracer instances
        schema:
            properties:
                allocations:
                    type: array
                    items:
                      $ref: '#/definitions/allocate_instance_post_Allocation'
    """
    show_param = request.args.get("show")
    if show_param is None or show_param == "current":  # default option
        return get_json_allocations(Allocation.get_current())
    else:
        if show_param not in ("all", "current", "finished"):
            return BadRequest("The 'show' parameter must contain one of the following values: all, running or finished.")

        if show_param == "all":
            return get_json_allocations(Allocation.get_all())  # .limit(10)
        else:  # show_param is "finished":
            return get_json_allocations(Allocation.get_finished())
Пример #2
0
def list_allocations():
    """
    Lists allocations.
    ---
    tags:
      - allocation
    parameters:
      - name: show
        in: query
        type: string
        description: Show different allocations
        default: current
        enum: [all, current, finished]
    responses:
      200:
        description: Allocations of Packet Tracer instances
        schema:
            properties:
                allocations:
                    type: array
                    items:
                      $ref: '#/definitions/allocate_instance_post_Allocation'
    """
    show_param = request.args.get("show")
    if show_param is None or show_param == "current":  # default option
        return get_json_allocations(Allocation.get_current())
    else:
        if show_param not in ("all", "current", "finished"):
            return BadRequest(
                "The 'show' parameter must contain one of the following values: all, running or finished."
            )

        if show_param == "all":
            return get_json_allocations(Allocation.get_all())  # .limit(10)
        else:  # show_param is "finished":
            return get_json_allocations(Allocation.get_finished())