From 862288a354d3310b4fac01d685d2adb0b8bd5ce7 Mon Sep 17 00:00:00 2001 From: David Trattnig <david.trattnig@o94.at> Date: Fri, 20 Nov 2020 19:39:06 +0100 Subject: [PATCH] Omit /store API suffix for storing playlogs. #15 --- README.md | 2 +- .../sample/sample-development.engine-api.ini | 2 +- .../sample/sample-production.engine-api.ini | 2 +- src/rest/controllers/internal_controller.py | 2 +- src/rest/swagger/swagger.yaml | 49 +++++++++---------- src/rest/test/test_internal_controller.py | 2 +- tests/config/engine-0-api.ini | 2 +- tests/config/engine-1-api.ini | 2 +- tests/config/engine-2-api.ini | 2 +- 9 files changed, 32 insertions(+), 33 deletions(-) diff --git a/README.md b/README.md index dd0dd0c..92d895d 100644 --- a/README.md +++ b/README.md @@ -335,7 +335,7 @@ You can find details on the available API endpoints here: https://app.swaggerhub Adding some entry to the playlog: ```bash -curl -d '{ "track_start": "2020-06-27 19:14:00", "track_artist": "Mazzie Star", "track_title": "Fade Into You", "log_source": 1 }' -H "Content-Type: application/json" -X POST http://localhost:8008/api/v1/playlog/store +curl -d '{ "track_start": "2020-06-27 19:14:00", "track_artist": "Mazzie Star", "track_title": "Fade Into You", "log_source": 1 }' -H "Content-Type: application/json" -X POST http://localhost:8008/api/v1/playlog ``` This newly added entry can be queried using your browser in one of the following ways: diff --git a/config/sample/sample-development.engine-api.ini b/config/sample/sample-development.engine-api.ini index cb9ce5e..faebbb6 100644 --- a/config/sample/sample-development.engine-api.ini +++ b/config/sample/sample-development.engine-api.ini @@ -58,6 +58,6 @@ sync_host="http://localhost:8010" # API endpoints to sync data from main to child nodes sync_api_get_playlog="/api/v1/playlog" -sync_api_store_playlog="/api/v1/playlog/store" +sync_api_store_playlog="/api/v1/playlog" sync_api_store_healthlog="/api/v1/source/health" sync_api_store_clockinfo="/api/v1/clock" \ No newline at end of file diff --git a/config/sample/sample-production.engine-api.ini b/config/sample/sample-production.engine-api.ini index 084980e..919c2fe 100644 --- a/config/sample/sample-production.engine-api.ini +++ b/config/sample/sample-production.engine-api.ini @@ -58,6 +58,6 @@ enable_federation="false" # API endpoints to sync data from main to child nodes sync_api_get_playlog="/api/v1/playlog" -sync_api_store_playlog="/api/v1/playlog/store" +sync_api_store_playlog="/api/v1/playlog" sync_api_store_healthlog="/api/v1/source/health" sync_api_store_clockinfo="/api/v1/clock" \ No newline at end of file diff --git a/src/rest/controllers/internal_controller.py b/src/rest/controllers/internal_controller.py index 3d43110..93817db 100644 --- a/src/rest/controllers/internal_controller.py +++ b/src/rest/controllers/internal_controller.py @@ -144,7 +144,7 @@ def set_active_source(number): # noqa: E501 def set_clock_info(body): # noqa: E501 """Set current studio clock information such as timeslot info and track-list for engine 1 or 2 - Set current studio clock information (source, timeslot and track-list) and the next timeslot of the given play-out source (engine1, engine2). Please note, the `current_track` information is ignored in the PUT request. It's only populated in the GET request. To store current track information use `/playlog/store` instead. # noqa: E501 + Set current studio clock information (source, timeslot and track-list) and the next timeslot of the given play-out source (engine1, engine2). Please note, the `current_track` information is ignored in the PUT request. It's only populated in the GET request. To store current track information use `/playlog` instead. # noqa: E501 :param body: :type body: dict | bytes diff --git a/src/rest/swagger/swagger.yaml b/src/rest/swagger/swagger.yaml index 26e5fef..880aefe 100644 --- a/src/rest/swagger/swagger.yaml +++ b/src/rest/swagger/swagger.yaml @@ -139,7 +139,7 @@ paths: summary: Set current studio clock information such as timeslot info and track-list for engine 1 or 2 within the Engine API database. description: | - Set current studio clock information (source, timeslot and track-list) and the next timeslot of the given play-out source (engine1, engine2). Please note, the `current_track` information is ignored in the PUT request. It's only dynamically populated in the GET request by reading the most recent playlog. To store current track information use `/playlog/store` instead. Also note, similar to the `PlayLog` storage endpoint, this information is only stored to the database if a) it is a main node or b) if it's a sync node, and the `engine_source` is the currently active engine. + Set current studio clock information (source, timeslot and track-list) and the next timeslot of the given play-out source (engine1, engine2). Please note, the `current_track` information is ignored in the PUT request. It's only dynamically populated in the GET request by reading the most recent playlog. To store current track information use `/playlog` instead. Also note, similar to the `PlayLog` storage endpoint, this information is only stored to the database if a) it is a main node or b) if it's a sync node, and the `engine_source` is the currently active engine. operationId: set_clock_info requestBody: content: @@ -153,30 +153,6 @@ paths: "400": description: bad input parameter x-openapi-router-controller: src.rest.controllers.internal_controller - /playlog/store: - post: - tags: - - internal - summary: Adds an entry to the playlog - description: | - Stores the passed playlog entry in the local database. Also note, similar to the `ClockInfo` storage endpoint, this information is only stored to the database if a) it is a main node or b) if it's a sync node, and the `log_source` is the currently active engine. - operationId: add_playlog - requestBody: - content: - application/json: - schema: - $ref: '#/components/schemas/PlayLog' - required: true - responses: - "200": - description: Successfully created a new playlog - "400": - description: Invalid request - content: - application/json: - schema: - $ref: '#/components/schemas/inline_response_400' - x-openapi-router-controller: src.rest.controllers.internal_controller /playlog: get: tags: @@ -248,6 +224,29 @@ paths: "400": description: bad input parameter x-openapi-router-controller: src.rest.controllers.internal_controller + post: + tags: + - internal + summary: Adds an entry to the playlog + description: | + Stores the passed playlog entry in the local database. Also note, similar to the `ClockInfo` storage endpoint, this information is only stored to the database if a) it is a main node or b) if it's a sync node, and the `log_source` is the currently active engine. + operationId: add_playlog + requestBody: + content: + application/json: + schema: + $ref: '#/components/schemas/PlayLog' + required: true + responses: + "200": + description: Successfully created a new playlog + "400": + description: Invalid request + content: + application/json: + schema: + $ref: '#/components/schemas/inline_response_400' + x-openapi-router-controller: src.rest.controllers.internal_controller /playlog/report/{year_month}: get: tags: diff --git a/src/rest/test/test_internal_controller.py b/src/rest/test/test_internal_controller.py index 4f34752..5c5c129 100644 --- a/src/rest/test/test_internal_controller.py +++ b/src/rest/test/test_internal_controller.py @@ -40,7 +40,7 @@ class TestInternalController(BaseTestCase): """ body = PlayLog() response = self.client.open( - '/api/v1/playlog/store', + '/api/v1/playlog', method='POST', data=json.dumps(body), content_type='application/json') diff --git a/tests/config/engine-0-api.ini b/tests/config/engine-0-api.ini index 37ce8a5..aa5a3a0 100644 --- a/tests/config/engine-0-api.ini +++ b/tests/config/engine-0-api.ini @@ -55,6 +55,6 @@ sync_step_sleep=3 # API endpoints to sync data from main to child nodes sync_api_get_playlog="/api/v1/playlog" -sync_api_store_playlog="/api/v1/playlog/store" +sync_api_store_playlog="/api/v1/playlog" sync_api_store_healthlog="/api/v1/source/health" sync_api_store_clockinfo="/api/v1/clock" \ No newline at end of file diff --git a/tests/config/engine-1-api.ini b/tests/config/engine-1-api.ini index 69abc05..bc6bacc 100644 --- a/tests/config/engine-1-api.ini +++ b/tests/config/engine-1-api.ini @@ -55,6 +55,6 @@ sync_host="http://localhost:8010" # API endpoints to sync data from main to child nodes sync_api_get_playlog="/api/v1/playlog" -sync_api_store_playlog="/api/v1/playlog/store" +sync_api_store_playlog="/api/v1/playlog" sync_api_store_healthlog="/api/v1/source/health" sync_api_store_clockinfo="/api/v1/clock" \ No newline at end of file diff --git a/tests/config/engine-2-api.ini b/tests/config/engine-2-api.ini index 78e534a..d413aff 100644 --- a/tests/config/engine-2-api.ini +++ b/tests/config/engine-2-api.ini @@ -55,6 +55,6 @@ sync_host="http://localhost:8010" # API endpoints to sync data from main to child nodes sync_api_get_playlog="/api/v1/playlog" -sync_api_store_playlog="/api/v1/playlog/store" +sync_api_store_playlog="/api/v1/playlog" sync_api_store_healthlog="/api/v1/source/health" sync_api_store_clockinfo="/api/v1/clock" \ No newline at end of file -- GitLab