Skip to content

Commit

Permalink
Added docs for GET "/" and POST "/list" endpoints
Browse files Browse the repository at this point in the history
  • Loading branch information
benjaminastrand committed Oct 21, 2024
1 parent d2c0b3e commit 0a52a19
Showing 1 changed file with 195 additions and 0 deletions.
195 changes: 195 additions & 0 deletions fedn/network/api/v1/prediction_routes.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand All @@ -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)
Expand Down

0 comments on commit 0a52a19

Please sign in to comment.