From e7e492333076cfe2f3520abcc340f59f6a1b1095 Mon Sep 17 00:00:00 2001 From: Craig Oates Date: Thu, 9 Jan 2020 15:18:40 +0000 Subject: [PATCH] add get latest (all) device status to YAML (A.P.I.) file. --- app/api.py | 3 +++ app/swagger.yml | 25 +++++++++++++++++++++++++ 2 files changed, 28 insertions(+) diff --git a/app/api.py b/app/api.py index e7b6f14..37ac134 100644 --- a/app/api.py +++ b/app/api.py @@ -32,3 +32,6 @@ def get_all_status_log(device): def get_all_status_logs_for_every_device(): return get_services.get_all_status_changes_from_database() + +def get_current_status_for_all_devices(): + return get_services.get_latest_status_for_all_devices() diff --git a/app/swagger.yml b/app/swagger.yml index 3d1c372..3633052 100644 --- a/app/swagger.yml +++ b/app/swagger.yml @@ -413,3 +413,28 @@ paths: schema: type: object additionalProperties: True + + /status/latest: + get: + operationId: api.get_current_status_for_all_devices + tags: + - Request Device Status + summary: >- + Returns the last recorded status change of every device in the + database. + description: >- + Use this U.R.L. to retrieve the last recorded status change of + every device used in this project. There is no example of the + data returned because I can't seem to replicate it as a YAML + schema which is understood by Swagger. Because of this. the + return type is registered as a free-form object. To see what + the data looks like when it is returned, I recommend you use + the "Try it out!" button to see a working example. + responses: + 200: + description: >- + The last recorded status change of every device in this + project was retrieved successfully. + schema: + type: object + additionalProperties: True