Skip to content
This repository has been archived by the owner on Oct 10, 2019. It is now read-only.

Commit

Permalink
Adds AlertType documentation and minor schema changes
Browse files Browse the repository at this point in the history
  • Loading branch information
Matthew Wilson committed Feb 26, 2019
1 parent 06e6ee1 commit d5fdccd
Show file tree
Hide file tree
Showing 9 changed files with 272 additions and 71 deletions.
1 change: 1 addition & 0 deletions services/web/docs/api.rst
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,4 @@ API
:caption: Contents:

Alert <api/alert>
AlertType <api/alert_type>
4 changes: 2 additions & 2 deletions services/web/docs/api/alert.rst
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
Alerts
******
Alert
*****

.. contents::
:backlinks: none
Expand Down
58 changes: 58 additions & 0 deletions services/web/docs/api/alert_type.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
AlertType
*********

.. contents::
:backlinks: none

Summary
-------

.. qrefflask:: project:create_app()
:endpoints: api.create_alert_type, api.read_alert_type, api.read_alert_types, api.update_alert_type, api.delete_alert_type
:order: path

Create
------

**JSON Schema**

Required parameters are in **bold**.

.. jsonschema:: ../../project/api/schemas/value_create.json

|
.. autoflask:: project:create_app()
:endpoints: api.create_alert_type

Read Single
-----------

.. autoflask:: project:create_app()
:endpoints: api.read_alert_type

Read Multiple
-------------

.. autoflask:: project:create_app()
:endpoints: api.read_alert_types

Update
------

**JSON Schema**

Required parameters are in **bold**.

.. jsonschema:: ../../project/api/schemas/value_update.json

|
.. autoflask:: project:create_app()
:endpoints: api.update_alert_type

Delete
------

.. autoflask:: project:create_app()
:endpoints: api.delete_alert_type
2 changes: 1 addition & 1 deletion services/web/docs/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
.. include:: ../../../README.rst

.. toctree::
:maxdepth: 1
:maxdepth: 2
:caption: Contents:

Overview <self>
Expand Down
72 changes: 31 additions & 41 deletions services/web/project/api/routes/alert.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
from project.api import bp
from project.api.decorators import check_if_token_required, validate_json, validate_schema
from project.api.errors import error_response
from project.api.schemas import alert_schema_create, alert_schema_update
from project.api.schemas import alert_create, alert_update
from project.models import Alert, AlertType, Event

"""
Expand All @@ -16,7 +16,7 @@
@bp.route('/alerts', methods=['POST'])
@check_if_token_required
@validate_json
@validate_schema(alert_schema_create)
@validate_schema(alert_create)
def create_alert():
""" Creates a new alert.
Expand All @@ -30,13 +30,11 @@ def create_alert():
Host: 127.0.0.1
Content-Type: application/json
[
{
"event": "Your event name",
"type": "SIEM",
"url": "http://your-siem.com/alert1"
}
]
{
"event": "Your event name",
"type": "SIEM",
"url": "http://your-siem.com/alert1"
}
**Example response**:
Expand All @@ -45,14 +43,12 @@ def create_alert():
HTTP/1.1 201 Created
Content-Type: application/json
[
{
"id": 1,
"event": "Your event name",
"type": "SIEM",
"url": "http://your-siem.com/alert1"
}
]
{
"id": 1,
"event": "Your event name",
"type": "SIEM",
"url": "http://your-siem.com/alert1"
}
:reqheader Authorization: Optional JWT Bearer token
:resheader Content-Type: application/json
Expand Down Expand Up @@ -122,14 +118,12 @@ def read_alert(alert_id):
HTTP/1.1 200 OK
Content-Type: application/json
[
{
"id": 1,
"event": "Your event name",
"type": "SIEM",
"url": "http://your-siem.com/alert1"
}
]
{
"id": 1,
"event": "Your event name",
"type": "SIEM",
"url": "http://your-siem.com/alert1"
}
:reqheader Authorization: Optional JWT Bearer token
:resheader Content-Type: application/json
Expand Down Expand Up @@ -228,7 +222,7 @@ def read_alerts():
@bp.route('/alerts/<int:alert_id>', methods=['PUT'])
@check_if_token_required
@validate_json
@validate_schema(alert_schema_update)
@validate_schema(alert_update)
def update_alert(alert_id):
""" Updates an existing alert.
Expand All @@ -242,13 +236,11 @@ def update_alert(alert_id):
Host: 127.0.0.1
Content-Type: application/json
[
{
"event": "Your other name",
"type": "SIEM 2",
"url": "http://your-siem2.com/alert2"
}
]
{
"event": "Your other name",
"type": "SIEM 2",
"url": "http://your-siem2.com/alert2"
}
**Example response**:
Expand All @@ -257,14 +249,12 @@ def update_alert(alert_id):
HTTP/1.1 200 OK
Content-Type: application/json
[
{
"id": 1,
"event": "Your other name",
"type": "SIEM 2",
"url": "http://your-siem2.com/alert2"
}
]
{
"id": 1,
"event": "Your other name",
"type": "SIEM 2",
"url": "http://your-siem2.com/alert2"
}
:reqheader Authorization: Optional JWT Bearer token
:resheader Content-Type: application/json
Expand Down

0 comments on commit d5fdccd

Please sign in to comment.