Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

api update (/incidents) #93

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions app/api/routes.py
Original file line number Diff line number Diff line change
Expand Up @@ -332,3 +332,18 @@ def post(self, data):
"not modifying or opening new incident"
)
return incident


@bp.route("/v1/incidents", methods=["GET"])
class ApiIncidents(MethodView):
@bp.response(200, IncidentSchema(many=True))
def get(self):
"""Get all incidents
Retrieve a list of all incidents.
Example:
.. code-block:: console
curl http://localhost:5000/api/v1/incidents -X GET \\
-H 'Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6Ikp...'
"""
incidents = db.session.scalars(db.select(Incident)).all()
return incidents
17 changes: 16 additions & 1 deletion doc/source/api.rst
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,23 @@ You should encode the "SECRET_KEY" to get the token
>>> payload = {"status_dashboard": "dummy"}
>>> encoded = jwt.encode(payload, secret_key, algorithm="HS256")
>>> print(encoded)
eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJwYXlsb2FkIjoiU09NRV9QQVlMT0FEIn0.oLj3UE3cQaviTpjOn0J6v0KE_wvPowyk2MAyN_s00_8
eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJwYXlsb2FkIjoiU09NRV9Powyk2MN_s00_8

API usage examples
==================

.. code-block:: console

$ curl http://localhost:5000/api/v1/component_status -X POST \
-H 'Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6pX...' \
-H 'content-type:application/json' \
-d '{"impact": "minor", "name": "Component 1", \
"attributes":[{"name":"region","value":"Reg1"}]}'

.. code-block:: console

$ curl http://localhost:5000/api/v1/incidents -X GET \
-H 'Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6Ikp...'

API v1
======
Expand Down