diff --git a/fedn/network/api/v1/prediction_routes.py b/fedn/network/api/v1/prediction_routes.py index d68b27110..6efc880f5 100644 --- a/fedn/network/api/v1/prediction_routes.py +++ b/fedn/network/api/v1/prediction_routes.py @@ -54,6 +54,121 @@ def start_session(): @bp.route("/", methods=["GET"]) @jwt_auth_required(role="admin") def get_predictions(): + """Get predictions + Retrieves a list of predictions based on the provided parameters. + By specifying a parameter in the url, you can filter the predictions based on that parameter, + and the response will contain only the predictions that match the filter. + --- + tags: + - Predictions + parameters: + - name: sender.name + in: query + required: false + type: string + description: Name of the sender + - name: sender.role + in: query + required: false + type: string + description: Role of the sender + - name: receiver.name + in: query + required: false + type: string + description: Name of the receiver + - name: receiver.role + in: query + required: false + type: string + description: Role of the receiver + - name: prediction_id + in: query + required: false + type: string + description: Prediction id of the prediction + - name: model_id + in: query + required: false + type: string + - name: correlation_id + in: query + required: false + type: string + description: Correlation id of the prediction + - name: X-Limit + in: header + required: false + type: integer + description: The maximum number of predictions to retrieve + - name: X-Skip + in: header + required: false + type: integer + description: The number of predictions to skip + - name: X-Sort-Key + in: header + required: false + type: string + description: The key to sort the predictions by + - name: X-Sort-Order + in: header + required: false + type: string + description: The order to sort the predictions in ('asc' or 'desc') + definitions: + Prediction: + type: object + properties: + id: + type: string + correlation_id: + type: string + prediction_id: + type: string + model_id: + type: string + timestamp: + type: object + format: date-time + data: + type: string + meta: + type: string + sender: + type: object + properties: + name: + type: string + role: + type: string + receiver: + type: object + properties: + name: + type: string + role: + type: string + responses: + 200: + description: A list of predictions and the total count. + schema: + type: object + properties: + count: + type: integer + result: + type: array + items: + $ref: '#/definitions/Prediction' + 500: + description: An error occurred + schema: + type: object + properties: + message: + type: string + """ try: limit, skip, sort_key, sort_order, use_typing = get_typed_list_headers(request.headers) kwargs = request.args.to_dict() @@ -72,6 +187,86 @@ def get_predictions(): @bp.route("/list", methods=["POST"]) @jwt_auth_required(role="admin") def list_predictions(): + """List predictions + Retrieves a list of predictions based on the provided parameters. + Works much like the GET predictions method, but allows for a more complex query. + By specifying a parameter in the body, you can filter the predictions based on that parameter, + and the response will contain only the predictions that match the filter. If the parameter value contains a comma, + the filter will be an "in" query, meaning that the predictions will be returned if the specified field contains any of the values in the parameter. + --- + tags: + - Predictions + parameters: + - name: prediction + in: body + required: false + schema: + type: object + properties: + sender.name: + type: string + description: Name of the sender + sender.role: + required: false + type: string + description: Role of the sender + receiver.name: + type: string + description: Name of the receiver + receiver.role: + required: false + type: string + description: Role of the receiver + prediction_id: + required: false + type: string + model_id: + required: false + type: string + correlation_id: + required: false + type: string + description: Correlation id of the status + - name: X-Limit + in: header + required: false + type: integer + description: The maximum number of predictions to retrieve + - name: X-Skip + in: header + required: false + type: integer + description: The number of predictions to skip + - name: X-Sort-Key + in: header + required: false + type: string + description: The key to sort the predictions by + - name: X-Sort-Order + in: header + required: false + type: string + description: The order to sort the predictions in ('asc' or 'desc') + responses: + 200: + description: A list of predictions and the total count. + schema: + type: object + properties: + count: + type: integer + result: + type: array + items: + $ref: '#/definitions/Prediction' + 500: + description: An error occurred + schema: + type: object + properties: + message: + type: string + """ try: limit, skip, sort_key, sort_order, use_typing = get_typed_list_headers(request.headers) kwargs = get_post_data_to_kwargs(request)