1
Fork 0
mirror of https://github.com/pds-nest/nest.git synced 2024-11-25 14:34:19 +00:00
This commit is contained in:
Lorenzo Balugani 2021-05-07 19:31:57 +02:00
parent 783d6de392
commit 0fe508071c
5 changed files with 23 additions and 57 deletions

View file

@ -28,7 +28,8 @@ app.add_url_rule("/api/v1/repositories/<int:rid>/conditions", view_func=page_rep
methods=["GET", "POST"])
app.add_url_rule("/api/v1/repositories/<int:rid>/alerts", view_func=page_repository_alerts,
methods=["GET", "POST"])
app.add_url_rule("/api/v1/conditions/<int:cid>", view_func=page_condition, methods=["GET", "PATCH", "DELETE"])
app.add_url_rule("/api/v1/conditions/<int:aid>", view_func=page_condition, methods=["GET", "PATCH", "DELETE"])
app.add_url_rule("/api/v1/alerts/<int:aid>", 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)

View file

@ -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.")

View file

@ -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"})

View file

@ -1 +1,2 @@
from .repository_alerts import page_repository_alerts
from .alert import page_alert

View file

@ -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()