Skip to content

Commit

Permalink
swagger config for sublime endpoint (#13)
Browse files Browse the repository at this point in the history
  • Loading branch information
taylorwalton authored Jul 12, 2023
1 parent 18197dc commit 31cf27d
Show file tree
Hide file tree
Showing 2 changed files with 200 additions and 3 deletions.
6 changes: 3 additions & 3 deletions backend/app/routes/sublime.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,10 @@ def put_alert() -> jsonify:
try:
message_id = service.validate_payload(data=data)
service.store_alert(message_id=message_id)
return jsonify({"message": "Successfully stored payload.", "success": True}), 200
return jsonify({"message": "Successfully stored message ID.", "success": True}), 200
except InvalidPayloadError:
logger.error("Received invalid payload.")
return jsonify({"message": "Invalid payload.", "success": False}), 400
logger.error("Received invalid payload. No message ID found.")
return jsonify({"message": "Invalid payload. No message ID found", "success": False}), 400


@bp.route("/sublime/alerts", methods=["GET"])
Expand Down
197 changes: 197 additions & 0 deletions backend/app/static/swagger.json
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,14 @@
"description": "Find out more",
"url": "http://swagger.io"
}
},
{
"name": "Sublime",
"description": "Everything about Sublime",
"externalDocs": {
"description": "Find out more",
"url": "http://swagger.io"
}
}
],
"paths": {
Expand Down Expand Up @@ -1821,6 +1829,195 @@
"operationId": "getAllAlerts",
"tags": ["DFIR Iris"]
}
},
"/sublime/alerts": {
"get": {
"summary": "Get all alerts",
"description": "Endpoint to get all alerts.",
"responses": {
"200": {
"description": "Successful operation",
"content": {
"application/json": {
"schema": {
"type": "object",
"properties": {
"alerts": {
"type": "array",
"items": {
"type": "object",
"description": "Alert details"
}
}
}
}
}
}
},
"default": {
"description": "Unexpected error",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/Error"
}
}
}
}
},
"operationId": "getAllAlerts",
"tags": ["Sublime"]
}
},
"/sublime/alert": {
"post": {
"summary": "Create an alert",
"description": "Endpoint to create an alert.",
"requestBody": {
"description": "Alert details",
"content": {
"application/json": {
"schema": {
"type": "object",
"properties": {
"api_version": {
"type": "string",
"example": "1"
},
"created_at": {
"type": "string",
"format": "date-time",
"example": "2023-06-28T20:45:01.619833409Z"
},
"data": {
"type": "object",
"properties": {
"flagged_rules": {
"type": "array",
"items": {
"type": "object",
"properties": {
"id": {
"type": "string",
"example": "1845f3e6-e446-4f1a-b256-83539f850ed3"
},
"name": {
"type": "string",
"example": "Test rule"
},
"severity": {
"type": "string",
"nullable": true
},
"tags": {
"type": "array",
"items": {
"type": "string"
}
}
}
}
},
"message": {
"type": "object",
"properties": {
"canonical_id": {
"type": "string",
"example": "c6a577585601e9ac17c949a33f73956ec7ee9f2ad1c4209d7e69dda819a62969"
},
"external_id": {
"type": "string",
"example": "29082"
},
"id": {
"type": "string",
"example": "4a29ffda-3efe-4418-b9a0-c4e40878b7c5"
},
"mailbox": {
"type": "object",
"properties": {
"external_id": {
"type": "string",
"nullable": true
},
"id": {
"type": "string",
"example": "e921c909-e72a-4c9c-b56c-0dd59c7f49c3"
}
}
},
"message_source_id": {
"type": "string",
"example": "d4bc5aef-ee26-4c54-a43e-de5faa794575"
}
}
},
"triggered_actions": {
"type": "array",
"items": {
"type": "object",
"properties": {
"id": {
"type": "string",
"example": "2c16da90-6f79-496b-886a-bf382423762a"
},
"name": {
"type": "string",
"example": "Shuffle"
},
"type": {
"type": "string",
"example": "webhook"
}
}
}
}
}
},
"id": {
"type": "string",
"example": "30aae129-ec7a-4797-bcd4-a1e6e924e5db"
},
"type": {
"type": "string",
"example": "message.flagged"
}
}
}
}
}
},
"responses": {
"200": {
"description": "Successful operation",
"content": {
"application/json": {
"schema": {
"type": "object",
"properties": {
"alert": {
"type": "object",
"description": "Alert details"
}
}
}
}
}
},
"default": {
"description": "Unexpected error",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/Error"
}
}
}
}
},
"operationId": "createAlert",
"tags": ["Sublime"]
}
}
},
"components": {
Expand Down

0 comments on commit 31cf27d

Please sign in to comment.