diff --git a/code/backend/nest_backend/__main__.py b/code/backend/nest_backend/__main__.py index 70b0549..fa5d6e7 100644 --- a/code/backend/nest_backend/__main__.py +++ b/code/backend/nest_backend/__main__.py @@ -28,7 +28,8 @@ app.add_url_rule("/api/v1/repositories//conditions", view_func=page_rep methods=["GET", "POST"]) app.add_url_rule("/api/v1/repositories//alerts", view_func=page_repository_alerts, methods=["GET", "POST"]) -app.add_url_rule("/api/v1/conditions/", view_func=page_condition, methods=["GET", "PATCH", "DELETE"]) +app.add_url_rule("/api/v1/conditions/", view_func=page_condition, methods=["GET", "PATCH", "DELETE"]) +app.add_url_rule("/api/v1/alerts/", view_func=page_alert, methods=["GET", "PATCH", "DELETE"]) app.register_error_handler(Exception, error_handler) app.register_blueprint(swagger_ui_blueprint, url_prefix=SWAGGER_URL) diff --git a/code/backend/nest_backend/api_schemas.py b/code/backend/nest_backend/api_schemas.py index 3d84528..9a7848f 100644 --- a/code/backend/nest_backend/api_schemas.py +++ b/code/backend/nest_backend/api_schemas.py @@ -36,6 +36,10 @@ class IntegerParameterSchema(Schema): rid = fields.Integer(description="The target numeric id.") +class AlertParameterSchema(Schema): + rid = fields.Integer(description="The target numeric id.") + + class CreateUser(Schema): email = fields.String(description="The new user's email.") username = fields.String(description="The new user's username.") diff --git a/code/backend/nest_backend/api_spec.py b/code/backend/nest_backend/api_spec.py index 2d98960..aed57af 100644 --- a/code/backend/nest_backend/api_spec.py +++ b/code/backend/nest_backend/api_spec.py @@ -29,6 +29,7 @@ spec.components.schema("RepositoryUpdate", schema=RepositoryUpdate) spec.components.schema("CreateRepository", schema=CreateRepository) spec.components.schema("CreateCondition", schema=CreateCondition) spec.components.schema("ConditionParameter", schema=ConditionParameterSchema) +spec.components.schema("AlertParameter", schema=AlertParameterSchema) spec.components.schema("Alert", schema=Alert) spec.components.schema("CreateAlert", schema=CreateAlert) spec.components.security_scheme("jwt", {"type": "http", "scheme": "bearer", "bearerFormat": "JWT"}) diff --git a/code/backend/nest_backend/routes/repository/alerts/__init__.py b/code/backend/nest_backend/routes/repository/alerts/__init__.py index 2763c14..3858608 100644 --- a/code/backend/nest_backend/routes/repository/alerts/__init__.py +++ b/code/backend/nest_backend/routes/repository/alerts/__init__.py @@ -1 +1,2 @@ -from .repository_alerts import page_repository_alerts \ No newline at end of file +from .repository_alerts import page_repository_alerts +from .alert import page_alert \ No newline at end of file diff --git a/code/backend/nest_backend/routes/repository/alerts/alert.py b/code/backend/nest_backend/routes/repository/alerts/alert.py index 4b0262f..87ab122 100644 --- a/code/backend/nest_backend/routes/repository/alerts/alert.py +++ b/code/backend/nest_backend/routes/repository/alerts/alert.py @@ -9,22 +9,22 @@ import datetime @cross_origin() @jwt_required() @repository_auth -def page_repository(aid): +def page_alert(aid): """ --- get: - summary: Get details about a repository. + summary: Get details about an alert. parameters: - in: path - schema: IntegerParameterSchema + schema: AlertParameterSchema security: - jwt: [] responses: '200': - description: The details about the requested schema. The schema is incapsulated in Success. + description: The details about the requested alert. The schema is incapsulated in Success. content: application/json: - schema: Repository + schema: Alert '404': description: Could not find the requested repository. content: @@ -41,12 +41,12 @@ def page_repository(aid): application/json: schema: Error tags: - - repository-related + - alert-related delete: - summary: Deletes a repository. + summary: Deletes an alert. parameters: - in: path - schema: IntegerParameterSchema + schema: AlertParameterSchema security: - jwt: [] responses: @@ -73,26 +73,26 @@ def page_repository(aid): application/json: schema: Error tags: - - repository-related + - alert-related patch: - summary: Updates a repository. + summary: Updates an alert. security: - jwt: [] requestBody: required: true content: application/json: - schema: RepositoryUpdate + schema: CreateAlert parameters: - in: path - schema: IntegerParameterSchema + schema: AlertParameterSchema responses: '200': description: The repository has been updated successfully. content: application/json: - schema: Repository + schema: Alert '404': description: Could not find the requested repository. content: @@ -109,48 +109,7 @@ def page_repository(aid): application/json: schema: Error tags: - - repository-related - put: - summary: Overwrites a repository. - security: - - jwt: [] - requestBody: - required: true - content: - application/json: - schema: Repository - parameters: - - in: path - schema: IntegerParameterSchema - - responses: - '200': - description: The repository has been updated successfully. - content: - application/json: - schema: Repository - '404': - description: Could not find the requested repository. - content: - application/json: - schema: Error - '403': - description: The user is not authorized. - content: - application/json: - schema: Error - '401': - description: The user is not logged in. - content: - application/json: - schema: Error - '400': - description: The request was malformed. - content: - application/json: - schema: Error - tags: - - repository-related + - alert-related """ user = find_user(get_jwt_identity()) alert = Alert.query.filter_by(id=aid).first()