mirror of
https://github.com/PiBrewing/craftbeerpi4.git
synced 2024-11-25 00:18:17 +01:00
log http endpoint swagger doc added
This commit is contained in:
parent
bbbfe92aab
commit
30efc95462
3 changed files with 178 additions and 66 deletions
|
@ -2,17 +2,8 @@
|
|||
<project version="4">
|
||||
<component name="ChangeListManager">
|
||||
<list default="true" id="1a245e6a-2e43-4348-8759-dc1b63a4c9c8" name="Default" comment="Lots of changes">
|
||||
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/cbpi/controller/job_controller.py" beforeDir="false" afterPath="$PROJECT_DIR$/cbpi/controller/job_controller.py" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/cbpi/controller/log_file_controller.py" beforeDir="false" afterPath="$PROJECT_DIR$/cbpi/controller/log_file_controller.py" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/cbpi/craftbeerpi.py" beforeDir="false" afterPath="$PROJECT_DIR$/cbpi/craftbeerpi.py" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/cbpi/extension/dummysensor/__init__.py" beforeDir="false" afterPath="$PROJECT_DIR$/cbpi/extension/dummysensor/__init__.py" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/cbpi/extension/mqtt/__init__.py" beforeDir="false" afterPath="$PROJECT_DIR$/cbpi/extension/mqtt/__init__.py" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/cbpi/extension/mqtt/config.yaml" beforeDir="false" afterPath="$PROJECT_DIR$/cbpi/extension/mqtt/config.yaml" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/cbpi/utils/encoder.py" beforeDir="false" afterPath="$PROJECT_DIR$/cbpi/utils/encoder.py" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/cbpi/websocket.py" beforeDir="false" afterPath="$PROJECT_DIR$/cbpi/websocket.py" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/requirements.txt" beforeDir="false" afterPath="$PROJECT_DIR$/requirements.txt" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/tests/test_logger.py" beforeDir="false" afterPath="$PROJECT_DIR$/tests/test_logger.py" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/cbpi/http_endpoints/http_log.py" beforeDir="false" afterPath="$PROJECT_DIR$/cbpi/http_endpoints/http_log.py" afterDir="false" />
|
||||
</list>
|
||||
<ignored path="$PROJECT_DIR$/.idea/httpRequests/" />
|
||||
<option name="EXCLUDED_CONVERTED_TO_IGNORED" value="true" />
|
||||
|
@ -30,7 +21,7 @@
|
|||
<SUITE FILE_PATH="coverage/craftbeerpi4$pytest_for_tests_test_actor.coverage" NAME="pytest for tests.test_actor Coverage Results" MODIFIED="1564652352869" SOURCE_PROVIDER="com.intellij.coverage.DefaultCoverageFileProvider" RUNNER="coverage.py" COVERAGE_BY_TEST_ENABLED="true" COVERAGE_TRACING_ENABLED="false" WORKING_DIRECTORY="$PROJECT_DIR$" />
|
||||
<SUITE FILE_PATH="coverage/craftbeerpi4$pytest_in_tests.coverage" NAME="pytest in tests Coverage Results" MODIFIED="1563993867067" SOURCE_PROVIDER="com.intellij.coverage.DefaultCoverageFileProvider" RUNNER="coverage.py" COVERAGE_BY_TEST_ENABLED="true" COVERAGE_TRACING_ENABLED="false" WORKING_DIRECTORY="$PROJECT_DIR$" />
|
||||
<SUITE FILE_PATH="coverage/craftbeerpi4$test_app.coverage" NAME="test_app Coverage Results" MODIFIED="1563992336652" SOURCE_PROVIDER="com.intellij.coverage.DefaultCoverageFileProvider" RUNNER="coverage.py" COVERAGE_BY_TEST_ENABLED="true" COVERAGE_TRACING_ENABLED="false" WORKING_DIRECTORY="$PROJECT_DIR$/tests" />
|
||||
<SUITE FILE_PATH="coverage/craftbeerpi4$run.coverage" NAME="run Coverage Results" MODIFIED="1565038749493" SOURCE_PROVIDER="com.intellij.coverage.DefaultCoverageFileProvider" RUNNER="coverage.py" COVERAGE_BY_TEST_ENABLED="true" COVERAGE_TRACING_ENABLED="false" WORKING_DIRECTORY="$PROJECT_DIR$" />
|
||||
<SUITE FILE_PATH="coverage/craftbeerpi4$run.coverage" NAME="run Coverage Results" MODIFIED="1565039626875" SOURCE_PROVIDER="com.intellij.coverage.DefaultCoverageFileProvider" RUNNER="coverage.py" COVERAGE_BY_TEST_ENABLED="true" COVERAGE_TRACING_ENABLED="false" WORKING_DIRECTORY="$PROJECT_DIR$" />
|
||||
<SUITE FILE_PATH="coverage/craftbeerpi4$pytest_in_test_logger_py.coverage" NAME="pytest in test_logger.py Coverage Results" MODIFIED="1565035432152" SOURCE_PROVIDER="com.intellij.coverage.DefaultCoverageFileProvider" RUNNER="coverage.py" COVERAGE_BY_TEST_ENABLED="true" COVERAGE_TRACING_ENABLED="false" WORKING_DIRECTORY="$PROJECT_DIR$/" />
|
||||
<SUITE FILE_PATH="coverage/craftbeerpi4$py_test_in_tests.coverage" NAME="py.test in tests Coverage Results" MODIFIED="1544486432317" SOURCE_PROVIDER="com.intellij.coverage.DefaultCoverageFileProvider" RUNNER="coverage.py" COVERAGE_BY_TEST_ENABLED="true" COVERAGE_TRACING_ENABLED="false" WORKING_DIRECTORY="" />
|
||||
<SUITE FILE_PATH="coverage/craftbeerpi4$pytest_in_test_ws_py.coverage" NAME="pytest in test_ws.py Coverage Results" MODIFIED="1546518348327" SOURCE_PROVIDER="com.intellij.coverage.DefaultCoverageFileProvider" RUNNER="coverage.py" COVERAGE_BY_TEST_ENABLED="true" COVERAGE_TRACING_ENABLED="false" WORKING_DIRECTORY="$PROJECT_DIR$" />
|
||||
|
@ -111,22 +102,11 @@
|
|||
</provider>
|
||||
</entry>
|
||||
</file>
|
||||
<file pinned="false" current-in-tab="false">
|
||||
<entry file="file://$PROJECT_DIR$/cbpi/http_endpoints/http_system.py">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state relative-caret-position="-432">
|
||||
<folding>
|
||||
<element signature="e#0#23#0" expanded="true" />
|
||||
</folding>
|
||||
</state>
|
||||
</provider>
|
||||
</entry>
|
||||
</file>
|
||||
<file pinned="false" current-in-tab="true">
|
||||
<entry file="file://$PROJECT_DIR$/cbpi/http_endpoints/http_log.py">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state relative-caret-position="527">
|
||||
<caret line="62" column="39" lean-forward="true" selection-start-line="62" selection-start-column="39" selection-end-line="62" selection-end-column="39" />
|
||||
<state relative-caret-position="414">
|
||||
<caret line="74" column="47" selection-start-line="74" selection-start-column="47" selection-end-line="74" selection-end-column="47" />
|
||||
<folding>
|
||||
<element signature="e#0#23#0" expanded="true" />
|
||||
</folding>
|
||||
|
@ -137,8 +117,8 @@
|
|||
<file pinned="false" current-in-tab="false">
|
||||
<entry file="file://$PROJECT_DIR$/cbpi/controller/log_file_controller.py">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state relative-caret-position="162">
|
||||
<caret line="105" selection-start-line="105" selection-end-line="105" />
|
||||
<state relative-caret-position="1501">
|
||||
<caret line="156" column="19" selection-start-line="156" selection-start-column="19" selection-end-line="156" selection-end-column="19" />
|
||||
<folding>
|
||||
<element signature="e#0#15#0" expanded="true" />
|
||||
</folding>
|
||||
|
@ -158,8 +138,8 @@
|
|||
<file pinned="false" current-in-tab="false">
|
||||
<entry file="file://$PROJECT_DIR$/cbpi/http_endpoints/http_plugin.py">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state relative-caret-position="802">
|
||||
<caret line="74" column="37" lean-forward="true" selection-start-line="74" selection-start-column="37" selection-end-line="74" selection-end-column="37" />
|
||||
<state relative-caret-position="77">
|
||||
<caret line="13" column="8" selection-start-line="13" selection-start-column="8" selection-end-line="35" selection-end-column="11" />
|
||||
<folding>
|
||||
<element signature="e#0#23#0" expanded="true" />
|
||||
</folding>
|
||||
|
@ -170,7 +150,8 @@
|
|||
<file pinned="false" current-in-tab="false">
|
||||
<entry file="file://$PROJECT_DIR$/cbpi/http_endpoints/http_dashboard.py">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state>
|
||||
<state relative-caret-position="411">
|
||||
<caret line="42" column="25" lean-forward="true" selection-start-line="36" selection-start-column="8" selection-end-line="42" selection-end-column="25" />
|
||||
<folding>
|
||||
<element signature="e#0#23#0" expanded="true" />
|
||||
</folding>
|
||||
|
@ -380,6 +361,13 @@
|
|||
<item name="cbpi" type="462c0819:PsiDirectoryNode" />
|
||||
<item name="http_endpoints" type="462c0819:PsiDirectoryNode" />
|
||||
</path>
|
||||
<path>
|
||||
<item name="craftbeerpi4" type="b2602c69:ProjectViewProjectNode" />
|
||||
<item name="craftbeerpi4" type="462c0819:PsiDirectoryNode" />
|
||||
<item name="cbpi" type="462c0819:PsiDirectoryNode" />
|
||||
<item name="http_endpoints" type="462c0819:PsiDirectoryNode" />
|
||||
<item name="http_dashboard.py" type="8704e2dd:PyFileNode" />
|
||||
</path>
|
||||
<path>
|
||||
<item name="craftbeerpi4" type="b2602c69:ProjectViewProjectNode" />
|
||||
<item name="craftbeerpi4" type="462c0819:PsiDirectoryNode" />
|
||||
|
@ -465,6 +453,12 @@
|
|||
<item name="utils" type="462c0819:PsiDirectoryNode" />
|
||||
<item name="utils.py" type="8704e2dd:PyFileNode" />
|
||||
</path>
|
||||
<path>
|
||||
<item name="craftbeerpi4" type="b2602c69:ProjectViewProjectNode" />
|
||||
<item name="craftbeerpi4" type="462c0819:PsiDirectoryNode" />
|
||||
<item name="cbpi" type="462c0819:PsiDirectoryNode" />
|
||||
<item name="craftbeerpi.py" type="8704e2dd:PyFileNode" />
|
||||
</path>
|
||||
<path>
|
||||
<item name="craftbeerpi4" type="b2602c69:ProjectViewProjectNode" />
|
||||
<item name="craftbeerpi4" type="462c0819:PsiDirectoryNode" />
|
||||
|
@ -963,7 +957,7 @@
|
|||
<workItem from="1557865115345" duration="642000" />
|
||||
<workItem from="1558267960394" duration="706000" />
|
||||
<workItem from="1559500167254" duration="104000" />
|
||||
<workItem from="1563709285256" duration="111111000" />
|
||||
<workItem from="1563709285256" duration="111965000" />
|
||||
</task>
|
||||
<task id="LOCAL-00001" summary="Lots of changes">
|
||||
<created>1541288846149</created>
|
||||
|
@ -1015,7 +1009,7 @@
|
|||
</history-entry>
|
||||
</component>
|
||||
<component name="TimeTrackingManager">
|
||||
<option name="totallyTimeSpent" value="382989000" />
|
||||
<option name="totallyTimeSpent" value="383843000" />
|
||||
</component>
|
||||
<component name="TodoView">
|
||||
<todo-panel id="selected-file">
|
||||
|
@ -1314,22 +1308,6 @@
|
|||
</state>
|
||||
</provider>
|
||||
</entry>
|
||||
<entry file="file://$PROJECT_DIR$/cbpi/extension/mqtt/config.yaml">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state relative-caret-position="30">
|
||||
<caret line="2" column="13" selection-start-line="2" selection-start-column="13" selection-end-line="2" selection-end-column="13" />
|
||||
</state>
|
||||
</provider>
|
||||
</entry>
|
||||
<entry file="file://$PROJECT_DIR$/cbpi/http_endpoints/http_dashboard.py">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state>
|
||||
<folding>
|
||||
<element signature="e#0#23#0" expanded="true" />
|
||||
</folding>
|
||||
</state>
|
||||
</provider>
|
||||
</entry>
|
||||
<entry file="file://$PROJECT_DIR$/cbpi/http_endpoints/http_kettle.py">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state>
|
||||
|
@ -1348,13 +1326,6 @@
|
|||
</state>
|
||||
</provider>
|
||||
</entry>
|
||||
<entry file="file://$PROJECT_DIR$/cbpi/craftbeerpi.py">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state relative-caret-position="134">
|
||||
<caret line="29" column="23" selection-start-line="29" selection-start-column="23" selection-end-line="29" selection-end-column="23" />
|
||||
</state>
|
||||
</provider>
|
||||
</entry>
|
||||
<entry file="file://$USER_HOME$/cbp42/lib/python3.7/site-packages/aiohttp/web_response.py">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state relative-caret-position="229">
|
||||
|
@ -1389,19 +1360,43 @@
|
|||
</state>
|
||||
</provider>
|
||||
</entry>
|
||||
<entry file="file://$PROJECT_DIR$/cbpi/http_endpoints/http_system.py">
|
||||
<entry file="file://$PROJECT_DIR$/cbpi/http_endpoints/http_plugin.py">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state relative-caret-position="-432">
|
||||
<state relative-caret-position="77">
|
||||
<caret line="13" column="8" selection-start-line="13" selection-start-column="8" selection-end-line="35" selection-end-column="11" />
|
||||
<folding>
|
||||
<element signature="e#0#23#0" expanded="true" />
|
||||
</folding>
|
||||
</state>
|
||||
</provider>
|
||||
</entry>
|
||||
<entry file="file://$PROJECT_DIR$/cbpi/http_endpoints/http_plugin.py">
|
||||
<entry file="file://$PROJECT_DIR$/cbpi/craftbeerpi.py">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state relative-caret-position="802">
|
||||
<caret line="74" column="37" lean-forward="true" selection-start-line="74" selection-start-column="37" selection-end-line="74" selection-end-column="37" />
|
||||
<state relative-caret-position="134">
|
||||
<caret line="29" column="23" selection-start-line="29" selection-start-column="23" selection-end-line="29" selection-end-column="23" />
|
||||
</state>
|
||||
</provider>
|
||||
</entry>
|
||||
<entry file="file://$PROJECT_DIR$/cbpi/http_endpoints/http_system.py">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state relative-caret-position="-531">
|
||||
<folding>
|
||||
<element signature="e#0#23#0" expanded="true" />
|
||||
</folding>
|
||||
</state>
|
||||
</provider>
|
||||
</entry>
|
||||
<entry file="file://$PROJECT_DIR$/cbpi/extension/mqtt/config.yaml">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state relative-caret-position="30">
|
||||
<caret line="2" column="13" selection-start-line="2" selection-start-column="13" selection-end-line="2" selection-end-column="13" />
|
||||
</state>
|
||||
</provider>
|
||||
</entry>
|
||||
<entry file="file://$PROJECT_DIR$/cbpi/http_endpoints/http_dashboard.py">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state relative-caret-position="411">
|
||||
<caret line="42" column="25" lean-forward="true" selection-start-line="36" selection-start-column="8" selection-end-line="42" selection-end-column="25" />
|
||||
<folding>
|
||||
<element signature="e#0#23#0" expanded="true" />
|
||||
</folding>
|
||||
|
@ -1410,8 +1405,8 @@
|
|||
</entry>
|
||||
<entry file="file://$PROJECT_DIR$/cbpi/controller/log_file_controller.py">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state relative-caret-position="162">
|
||||
<caret line="105" selection-start-line="105" selection-end-line="105" />
|
||||
<state relative-caret-position="1501">
|
||||
<caret line="156" column="19" selection-start-line="156" selection-start-column="19" selection-end-line="156" selection-end-column="19" />
|
||||
<folding>
|
||||
<element signature="e#0#15#0" expanded="true" />
|
||||
</folding>
|
||||
|
@ -1420,8 +1415,8 @@
|
|||
</entry>
|
||||
<entry file="file://$PROJECT_DIR$/cbpi/http_endpoints/http_log.py">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state relative-caret-position="527">
|
||||
<caret line="62" column="39" lean-forward="true" selection-start-line="62" selection-start-column="39" selection-end-line="62" selection-end-column="39" />
|
||||
<state relative-caret-position="414">
|
||||
<caret line="74" column="47" selection-start-line="74" selection-start-column="47" selection-end-line="74" selection-end-column="47" />
|
||||
<folding>
|
||||
<element signature="e#0#23#0" expanded="true" />
|
||||
</folding>
|
||||
|
|
|
@ -155,7 +155,6 @@ class LogController:
|
|||
for f in all_filenames:
|
||||
zip.write(os.path.join(f))
|
||||
zip.close()
|
||||
|
||||
return file_name
|
||||
return os.path.basename(file_name)
|
||||
|
||||
|
||||
|
|
|
@ -10,19 +10,71 @@ class LogHttpEndpoints:
|
|||
|
||||
@request_mapping(path="/{name}/zip", method="POST", auth_required=False)
|
||||
async def create_zip_names(self, request):
|
||||
"""
|
||||
---
|
||||
description: Zip Log files for sensor
|
||||
tags:
|
||||
- Log
|
||||
parameters:
|
||||
- name: "name"
|
||||
in: "path"
|
||||
description: "Sensor ID"
|
||||
required: true
|
||||
type: "integer"
|
||||
format: "int64"
|
||||
produces:
|
||||
- application/json
|
||||
responses:
|
||||
"204":
|
||||
description: successful operation. Return "pong" text
|
||||
"""
|
||||
|
||||
log_name = request.match_info['name']
|
||||
data = self.cbpi.log.zip_log_data(log_name)
|
||||
print(data)
|
||||
|
||||
return web.json_response(dict(filename=data), dumps=json_dumps)
|
||||
|
||||
@request_mapping(path="/{name}/zip", method="DELETE", auth_required=False)
|
||||
async def clear_zip_names(self, request):
|
||||
"""
|
||||
---
|
||||
description: Delete all zip files for sensor
|
||||
tags:
|
||||
- Log
|
||||
parameters:
|
||||
- name: "name"
|
||||
in: "path"
|
||||
description: "Sensor ID"
|
||||
required: true
|
||||
type: "integer"
|
||||
format: "int64"
|
||||
responses:
|
||||
"204":
|
||||
description: successful operation.
|
||||
"""
|
||||
log_name = request.match_info['name']
|
||||
self.cbpi.log.clear_zip(log_name)
|
||||
return web.Response(status=204)
|
||||
|
||||
@request_mapping(path="/zip/download/{name}", method="GET", auth_required=False)
|
||||
async def download_zip(self, request):
|
||||
"""
|
||||
---
|
||||
description: Download a sensor zip file
|
||||
tags:
|
||||
- Log
|
||||
parameters:
|
||||
- name: "name"
|
||||
in: "path"
|
||||
description: "Zip File name"
|
||||
required: true
|
||||
type: "integer"
|
||||
format: "int64"
|
||||
responses:
|
||||
"204":
|
||||
description: successful operation.
|
||||
"""
|
||||
|
||||
response = web.StreamResponse(
|
||||
status=200,
|
||||
reason='OK',
|
||||
|
@ -39,12 +91,49 @@ class LogHttpEndpoints:
|
|||
|
||||
@request_mapping(path="/{name}/zip", method="GET", auth_required=False)
|
||||
async def get_zip_names(self, request):
|
||||
"""
|
||||
---
|
||||
description: Zip available zip file names for sensor
|
||||
tags:
|
||||
- Log
|
||||
parameters:
|
||||
- name: "name"
|
||||
in: "path"
|
||||
description: "Sensor ID"
|
||||
required: true
|
||||
type: "integer"
|
||||
format: "int64"
|
||||
produces:
|
||||
- application/json
|
||||
responses:
|
||||
"200":
|
||||
description: successful operation.
|
||||
"""
|
||||
log_name = request.match_info['name']
|
||||
data = self.cbpi.log.get_all_zip_file_names(log_name)
|
||||
return web.json_response(data, dumps=json_dumps)
|
||||
|
||||
@request_mapping(path="/{name}/files", method="GET", auth_required=False)
|
||||
async def get_file_names(self, request):
|
||||
"""
|
||||
---
|
||||
description: Available log file names for sensor
|
||||
tags:
|
||||
- Log
|
||||
parameters:
|
||||
|
||||
- name: "name"
|
||||
in: "path"
|
||||
description: "Sensor ID"
|
||||
required: true
|
||||
type: "integer"
|
||||
format: "int64"
|
||||
produces:
|
||||
- application/json
|
||||
responses:
|
||||
"200":
|
||||
description: successful operation.
|
||||
"""
|
||||
log_name = request.match_info['name']
|
||||
print(log_name)
|
||||
data = self.cbpi.log.get_logfile_names(log_name)
|
||||
|
@ -52,12 +141,41 @@ class LogHttpEndpoints:
|
|||
|
||||
@request_mapping(path="/{name}", method="GET", auth_required=False)
|
||||
async def delete_log(self, request):
|
||||
"""
|
||||
---
|
||||
description: Get log data for sensor
|
||||
tags:
|
||||
- Log
|
||||
parameters:
|
||||
- name: "name"
|
||||
in: "path"
|
||||
description: "Sensor ID"
|
||||
required: true
|
||||
type: "integer"
|
||||
format: "int64"
|
||||
produces:
|
||||
- application/json
|
||||
responses:
|
||||
"200":
|
||||
description: successful operation.
|
||||
"""
|
||||
log_name = request.match_info['name']
|
||||
data = await self.cbpi.log.get_data(log_name)
|
||||
return web.json_response(data, dumps=json_dumps)
|
||||
|
||||
@request_mapping(path="/{name}", method="DELETE", auth_required=False)
|
||||
async def delete_all_logs(self, request):
|
||||
"""
|
||||
---
|
||||
description: Get log data for sensor
|
||||
tags:
|
||||
- Log
|
||||
parameters:
|
||||
|
||||
responses:
|
||||
"204":
|
||||
description: successful operation.
|
||||
"""
|
||||
log_name = request.match_info['name']
|
||||
await self.cbpi.log.clear_logs(log_name)
|
||||
return web.Response(status=204)
|
Loading…
Reference in a new issue