diff --git a/documentation/api/OpenApi.yaml b/documentation/api/OpenApi.yaml index 143e0d2..e9b0766 100644 --- a/documentation/api/OpenApi.yaml +++ b/documentation/api/OpenApi.yaml @@ -86,7 +86,7 @@ paths: application/json: schema: $ref: "#/components/schemas/SystemConfiguration" - post: + patch: tags: - System Configuration summary: Update system configuration. @@ -127,7 +127,7 @@ paths: application/json: schema: $ref: "#/components/schemas/LedConfiguration" - post: + patch: tags: - LED/Zone Configuration summary: Update LED/zone configuration. @@ -168,7 +168,7 @@ paths: application/json: schema: $ref: "#/components/schemas/WiFiConfiguration" - post: + patch: tags: - WiFi Configuration summary: Update WiFi configuration. @@ -195,7 +195,8 @@ paths: application/json: schema: $ref: "#/components/schemas/ApiResponse" - /config/motion: + + /config/motion/calibration: get: tags: - Motion Sensor Calibration Configuration @@ -209,7 +210,7 @@ paths: application/json: schema: $ref: "#/components/schemas/MotionSensorCalibration" - post: + patch: tags: - Motion Sensor Calibration Configuration summary: Update the motion sensor calibration. @@ -236,6 +237,7 @@ paths: application/json: schema: $ref: "#/components/schemas/ApiResponse" + /config/motion/calibration/auto: patch: tags: - Motion Sensor Calibration Configuration @@ -277,7 +279,7 @@ paths: application/json: schema: $ref: "#/components/schemas/AudioUnitConfiguration" - post: + patch: tags: - Audio Unit Configuration summary: Update the audio unit configuration. @@ -318,7 +320,7 @@ paths: application/json: schema: $ref: "#/components/schemas/UIConfiguration" - post: + patch: tags: - UI Configuration summary: Update UI configuration. diff --git a/documentation/api/TesLight API.postman_collection.json b/documentation/api/TesLight API.postman_collection.json index b812042..541952b 100644 --- a/documentation/api/TesLight API.postman_collection.json +++ b/documentation/api/TesLight API.postman_collection.json @@ -57,7 +57,7 @@ "disabledSystemHeaders": {} }, "request": { - "method": "POST", + "method": "PATCH", "header": [], "body": { "mode": "raw", @@ -114,7 +114,7 @@ "disabledSystemHeaders": {} }, "request": { - "method": "POST", + "method": "PATCH", "header": [], "body": { "mode": "raw", @@ -168,7 +168,7 @@ { "name": "Set WiFi Configuration", "request": { - "method": "POST", + "method": "PATCH", "header": [], "body": { "mode": "raw", @@ -441,7 +441,7 @@ "method": "GET", "header": [], "url": { - "raw": "http://{{TESLIGHTIP}}/api/config/motion", + "raw": "http://{{TESLIGHTIP}}/api/config/motion/calibration", "protocol": "http", "host": [ "{{TESLIGHTIP}}" @@ -449,7 +449,8 @@ "path": [ "api", "config", - "motion" + "motion", + "calibration" ] } }, @@ -461,7 +462,7 @@ "disabledSystemHeaders": {} }, "request": { - "method": "POST", + "method": "PATCH", "header": [], "body": { "mode": "raw", @@ -473,7 +474,7 @@ } }, "url": { - "raw": "http://{{TESLIGHTIP}}/api/config/motion", + "raw": "http://{{TESLIGHTIP}}/api/config/motion/calibration", "protocol": "http", "host": [ "{{TESLIGHTIP}}" @@ -481,7 +482,8 @@ "path": [ "api", "config", - "motion" + "motion", + "calibration" ] } }, @@ -496,7 +498,7 @@ "method": "PATCH", "header": [], "url": { - "raw": "http://{{TESLIGHTIP}}/api/config/motion", + "raw": "http://{{TESLIGHTIP}}/api/config/motion/calibration/auto", "protocol": "http", "host": [ "{{TESLIGHTIP}}" @@ -504,7 +506,9 @@ "path": [ "api", "config", - "motion" + "motion", + "calibration", + "auto" ] } }, @@ -541,7 +545,7 @@ "disabledSystemHeaders": {} }, "request": { - "method": "POST", + "method": "PATCH", "header": [], "body": { "mode": "raw", @@ -598,7 +602,7 @@ "disabledSystemHeaders": {} }, "request": { - "method": "POST", + "method": "PATCH", "header": [], "body": { "mode": "raw", @@ -845,4 +849,4 @@ "type": "string" } ] -} \ No newline at end of file +} diff --git a/mcu/include/server/AudioUnitConfigurationEndpoint.h b/mcu/include/server/AudioUnitConfigurationEndpoint.h index fbfb8ee..49fd176 100644 --- a/mcu/include/server/AudioUnitConfigurationEndpoint.h +++ b/mcu/include/server/AudioUnitConfigurationEndpoint.h @@ -39,7 +39,7 @@ namespace TL AudioUnitConfigurationEndpoint(); static void getAudioUnitConfig(); - static void postAudioUnitConfig(); + static void patchAudioUnitConfig(); static bool validateConfiguration(const JsonObject &jsonObject); static bool isInRange(const long value, const long min, const long max); diff --git a/mcu/include/server/LedConfigurationEndpoint.h b/mcu/include/server/LedConfigurationEndpoint.h index 81ff8fa..d4971dc 100644 --- a/mcu/include/server/LedConfigurationEndpoint.h +++ b/mcu/include/server/LedConfigurationEndpoint.h @@ -41,7 +41,7 @@ namespace TL LedConfigurationEndpoint(); static void getLedConfig(); - static void postLedConfig(); + static void patchLedConfig(); static bool validateLedZone(const JsonObject &jsonObject, const uint8_t index); static bool validateAnimationSettings(const uint8_t type, const JsonArray &jsonArray); diff --git a/mcu/include/server/MotionSensorEndpoint.h b/mcu/include/server/MotionSensorEndpoint.h index 735a9f5..3622251 100644 --- a/mcu/include/server/MotionSensorEndpoint.h +++ b/mcu/include/server/MotionSensorEndpoint.h @@ -39,7 +39,7 @@ namespace TL MotionSensorEndpoint(); static void getCalibrationData(); - static void postCalibrationData(); + static void patchCalibrationData(); static void runCalibration(); static bool validateConfiguration(const JsonObject &jsonObject); diff --git a/mcu/include/server/SystemConfigurationEndpoint.h b/mcu/include/server/SystemConfigurationEndpoint.h index db29940..707485f 100644 --- a/mcu/include/server/SystemConfigurationEndpoint.h +++ b/mcu/include/server/SystemConfigurationEndpoint.h @@ -41,7 +41,7 @@ namespace TL SystemConfigurationEndpoint(); static void getSystemConfig(); - static void postSystemConfig(); + static void patchSystemConfig(); static bool validateConfiguration(const JsonObject &jsonObject); static bool isInRange(const long value, const long min, const long max); diff --git a/mcu/include/server/UIConfigurationEndpoint.h b/mcu/include/server/UIConfigurationEndpoint.h index b3036b1..0916879 100644 --- a/mcu/include/server/UIConfigurationEndpoint.h +++ b/mcu/include/server/UIConfigurationEndpoint.h @@ -24,7 +24,7 @@ namespace TL UIConfigurationEndpoint(); static void getUIConfig(); - static void postUIConfig(); + static void patchUIConfig(); static bool validateUIConfig(const JsonObject &jsonObject); }; diff --git a/mcu/include/server/WiFiConfigurationEndpoint.h b/mcu/include/server/WiFiConfigurationEndpoint.h index 37b537a..e4757fc 100644 --- a/mcu/include/server/WiFiConfigurationEndpoint.h +++ b/mcu/include/server/WiFiConfigurationEndpoint.h @@ -39,7 +39,7 @@ namespace TL WiFiConfigurationEndpoint(); static void getWiFiConfig(); - static void postWiFiConfig(); + static void patchWiFiConfig(); static bool validateConfiguration(const JsonObject &jsonObject); static bool isInRange(const long value, const long min, const long max); diff --git a/mcu/src/server/AudioUnitConfigurationEndpoint.cpp b/mcu/src/server/AudioUnitConfigurationEndpoint.cpp index 62cb2d7..8407fb6 100644 --- a/mcu/src/server/AudioUnitConfigurationEndpoint.cpp +++ b/mcu/src/server/AudioUnitConfigurationEndpoint.cpp @@ -27,7 +27,7 @@ void TL::AudioUnitConfigurationEndpoint::begin() { TL::WebServerManager::addRequestHandler((getBaseUri() + F("config/audio")).c_str(), http_method::HTTP_GET, TL::AudioUnitConfigurationEndpoint::getAudioUnitConfig); - TL::WebServerManager::addRequestHandler((getBaseUri() + F("config/audio")).c_str(), http_method::HTTP_POST, TL::AudioUnitConfigurationEndpoint::postAudioUnitConfig); + TL::WebServerManager::addRequestHandler((getBaseUri() + F("config/audio")).c_str(), http_method::HTTP_PATCH, TL::AudioUnitConfigurationEndpoint::patchAudioUnitConfig); } /** @@ -70,9 +70,9 @@ void TL::AudioUnitConfigurationEndpoint::getAudioUnitConfig() } /** - * @brief Receive the audio unit configuration sent by the client. + * @brief Update the audio unit configuration. */ -void TL::AudioUnitConfigurationEndpoint::postAudioUnitConfig() +void TL::AudioUnitConfigurationEndpoint::patchAudioUnitConfig() { TL::Logger::log(TL::Logger::LogLevel::INFO, SOURCE_LOCATION, F("Received request to update the audio unit configuration.")); if (!TL::Configuration::isInitialized()) diff --git a/mcu/src/server/LedConfigurationEndpoint.cpp b/mcu/src/server/LedConfigurationEndpoint.cpp index 5356b8b..8d39bc0 100644 --- a/mcu/src/server/LedConfigurationEndpoint.cpp +++ b/mcu/src/server/LedConfigurationEndpoint.cpp @@ -27,7 +27,7 @@ void TL::LedConfigurationEndpoint::begin() { TL::WebServerManager::addRequestHandler((getBaseUri() + F("config/led")).c_str(), http_method::HTTP_GET, TL::LedConfigurationEndpoint::getLedConfig); - TL::WebServerManager::addRequestHandler((getBaseUri() + F("config/led")).c_str(), http_method::HTTP_POST, TL::LedConfigurationEndpoint::postLedConfig); + TL::WebServerManager::addRequestHandler((getBaseUri() + F("config/led")).c_str(), http_method::HTTP_PATCH, TL::LedConfigurationEndpoint::patchLedConfig); } /** @@ -80,9 +80,9 @@ void TL::LedConfigurationEndpoint::getLedConfig() } /** - * @brief Receive the LED configuration sent by the client. + * @brief Update the LED configuration. */ -void TL::LedConfigurationEndpoint::postLedConfig() +void TL::LedConfigurationEndpoint::patchLedConfig() { TL::Logger::log(TL::Logger::LogLevel::INFO, SOURCE_LOCATION, F("Received request to update the LED configuration.")); if (!TL::Configuration::isInitialized()) diff --git a/mcu/src/server/MotionSensorEndpoint.cpp b/mcu/src/server/MotionSensorEndpoint.cpp index 15b1125..ef1319b 100644 --- a/mcu/src/server/MotionSensorEndpoint.cpp +++ b/mcu/src/server/MotionSensorEndpoint.cpp @@ -26,9 +26,9 @@ */ void TL::MotionSensorEndpoint::begin() { - TL::WebServerManager::addRequestHandler((getBaseUri() + F("config/motion")).c_str(), http_method::HTTP_GET, TL::MotionSensorEndpoint::getCalibrationData); - TL::WebServerManager::addRequestHandler((getBaseUri() + F("config/motion")).c_str(), http_method::HTTP_POST, TL::MotionSensorEndpoint::postCalibrationData); - TL::WebServerManager::addRequestHandler((getBaseUri() + F("config/motion")).c_str(), http_method::HTTP_PATCH, TL::MotionSensorEndpoint::runCalibration); + TL::WebServerManager::addRequestHandler((getBaseUri() + F("config/motion/calibration")).c_str(), http_method::HTTP_GET, TL::MotionSensorEndpoint::getCalibrationData); + TL::WebServerManager::addRequestHandler((getBaseUri() + F("config/motion/calibration")).c_str(), http_method::HTTP_PATCH, TL::MotionSensorEndpoint::patchCalibrationData); + TL::WebServerManager::addRequestHandler((getBaseUri() + F("config/motion/calibration/auto")).c_str(), http_method::HTTP_PATCH, TL::MotionSensorEndpoint::runCalibration); } /** @@ -64,9 +64,9 @@ void TL::MotionSensorEndpoint::getCalibrationData() } /** - * @brief Receive the motion sensor calibration sent by the client. + * @brief Update the motion sensor calibration manually. */ -void TL::MotionSensorEndpoint::postCalibrationData() +void TL::MotionSensorEndpoint::patchCalibrationData() { TL::Logger::log(TL::Logger::LogLevel::INFO, SOURCE_LOCATION, F("Received request to update the motion sensor calibration data.")); if (!TL::Configuration::isInitialized()) diff --git a/mcu/src/server/SystemConfigurationEndpoint.cpp b/mcu/src/server/SystemConfigurationEndpoint.cpp index f3e5a97..44272ba 100644 --- a/mcu/src/server/SystemConfigurationEndpoint.cpp +++ b/mcu/src/server/SystemConfigurationEndpoint.cpp @@ -27,7 +27,7 @@ void TL::SystemConfigurationEndpoint::begin() { TL::WebServerManager::addRequestHandler((getBaseUri() + F("config/system")).c_str(), http_method::HTTP_GET, TL::SystemConfigurationEndpoint::getSystemConfig); - TL::WebServerManager::addRequestHandler((getBaseUri() + F("config/system")).c_str(), http_method::HTTP_POST, TL::SystemConfigurationEndpoint::postSystemConfig); + TL::WebServerManager::addRequestHandler((getBaseUri() + F("config/system")).c_str(), http_method::HTTP_PATCH, TL::SystemConfigurationEndpoint::patchSystemConfig); } /** @@ -67,9 +67,9 @@ void TL::SystemConfigurationEndpoint::getSystemConfig() } /** - * @brief Receive the system configuration sent by the client. + * @brief Update the system configuration. */ -void TL::SystemConfigurationEndpoint::postSystemConfig() +void TL::SystemConfigurationEndpoint::patchSystemConfig() { TL::Logger::log(TL::Logger::LogLevel::INFO, SOURCE_LOCATION, F("Received request to update the system configuration.")); if (!TL::Configuration::isInitialized()) diff --git a/mcu/src/server/UIConfigurationEndpoint.cpp b/mcu/src/server/UIConfigurationEndpoint.cpp index 7b921d1..a6610da 100644 --- a/mcu/src/server/UIConfigurationEndpoint.cpp +++ b/mcu/src/server/UIConfigurationEndpoint.cpp @@ -14,7 +14,7 @@ void TL::UIConfigurationEndpoint::begin() { TL::WebServerManager::addRequestHandler((getBaseUri() + F("config/ui")).c_str(), http_method::HTTP_GET, TL::UIConfigurationEndpoint::getUIConfig); - TL::WebServerManager::addRequestHandler((getBaseUri() + F("config/ui")).c_str(), http_method::HTTP_POST, TL::UIConfigurationEndpoint::postUIConfig); + TL::WebServerManager::addRequestHandler((getBaseUri() + F("config/ui")).c_str(), http_method::HTTP_PATCH, TL::UIConfigurationEndpoint::patchUIConfig); } /** @@ -42,9 +42,9 @@ void TL::UIConfigurationEndpoint::getUIConfig() } /** - * @brief Receive the UI configuration sent by the client. + * @brief Update the UI configuration. */ -void TL::UIConfigurationEndpoint::postUIConfig() +void TL::UIConfigurationEndpoint::patchUIConfig() { TL::Logger::log(TL::Logger::LogLevel::INFO, SOURCE_LOCATION, F("Received request to update the UI configuration.")); if (!TL::Configuration::isInitialized()) diff --git a/mcu/src/server/WiFiConfigurationEndpoint.cpp b/mcu/src/server/WiFiConfigurationEndpoint.cpp index 18f4e49..29055b9 100644 --- a/mcu/src/server/WiFiConfigurationEndpoint.cpp +++ b/mcu/src/server/WiFiConfigurationEndpoint.cpp @@ -27,7 +27,7 @@ void TL::WiFiConfigurationEndpoint::begin() { TL::WebServerManager::addRequestHandler((getBaseUri() + F("config/wifi")).c_str(), http_method::HTTP_GET, TL::WiFiConfigurationEndpoint::getWiFiConfig); - TL::WebServerManager::addRequestHandler((getBaseUri() + F("config/wifi")).c_str(), http_method::HTTP_POST, TL::WiFiConfigurationEndpoint::postWiFiConfig); + TL::WebServerManager::addRequestHandler((getBaseUri() + F("config/wifi")).c_str(), http_method::HTTP_PATCH, TL::WiFiConfigurationEndpoint::patchWiFiConfig); } /** @@ -58,9 +58,9 @@ void TL::WiFiConfigurationEndpoint::getWiFiConfig() } /** - * @brief Receive the WiFi configuration sent by the client. + * @brief Update the WiFi configuration. */ -void TL::WiFiConfigurationEndpoint::postWiFiConfig() +void TL::WiFiConfigurationEndpoint::patchWiFiConfig() { TL::Logger::log(TL::Logger::LogLevel::INFO, SOURCE_LOCATION, F("Received request to update the WiFi configuration.")); if (!TL::Configuration::isInitialized()) diff --git a/ui/src/mocks/handlers.ts b/ui/src/mocks/handlers.ts index ce247c8..057261b 100644 --- a/ui/src/mocks/handlers.ts +++ b/ui/src/mocks/handlers.ts @@ -190,7 +190,7 @@ export const handlers = [ // ------------------ rest.get('/api/info/system', (_req, res, ctx) => { - console.debug(`Get system information: ${mock.info.system}`); + console.debug(`System information: ${mock.info.system}`); return res( ctx.status(200), ctx.json({ status: 200, message: 'ok', ...mock.info.system }), @@ -202,16 +202,16 @@ export const handlers = [ // -------------------- rest.get('/api/config/system', (_req, res, ctx) => { - console.debug(`Get system configuration: ${mock.system}`); + console.debug(`System configuration: ${mock.system}`); return res( ctx.status(200), ctx.json({ status: 200, message: 'ok', ...mock.system }), ); }), - rest.post('/api/config/system', async (req, res, ctx) => { + rest.patch('/api/config/system', async (req, res, ctx) => { mock.system = await req.json(); - console.debug(`Post new system configuration: ${mock.system}`); + console.debug(`Update system configuration: ${mock.system}`); return res(ctx.status(200), ctx.json({ status: 200, message: 'ok' })); }), @@ -220,7 +220,7 @@ export const handlers = [ // ------------------ rest.get('/api/config/profile/active', (_req, res, ctx) => { - console.debug(`Get active profile: ${mock.profile}`); + console.debug(`Active profile: ${mock.profile}`); return res( ctx.status(200), ctx.json({ status: 200, message: 'ok', ...mock.profile }), @@ -234,7 +234,7 @@ export const handlers = [ }), rest.get('/api/config/profile', (_req, res, ctx) => { - console.debug(`Get profiles: ${mock.profiles}`); + console.debug(`Profiles: ${mock.profiles}`); return res( ctx.status(200), ctx.json({ status: 200, message: 'ok', ...mock.profiles }), @@ -244,7 +244,7 @@ export const handlers = [ rest.post('/api/config/profile', async (req, res, ctx) => { const data = await req.json(); mock.profiles.profile.names.push(data.profile.name); - console.debug(`Post new profile: ${mock.profile}`); + console.debug(`Create new profile: ${mock.profile}`); return res(ctx.status(200), ctx.json({ status: 200, message: 'ok' })); }), @@ -254,7 +254,7 @@ export const handlers = [ ...mock.profiles.profile.names, data.profile.name, ]; - console.debug(`Clone profile: ${mock.profiles}`); + console.debug(`Clone existing profile: ${mock.profiles}`); return res(ctx.status(200), ctx.json({ status: 200, message: 'ok' })); }), @@ -272,16 +272,16 @@ export const handlers = [ // ---------------------- rest.get('/api/config/led', (_req, res, ctx) => { - console.debug(`Get LED configuration: ${mock.led}`); + console.debug(`LED configuration: ${mock.led}`); return res( ctx.status(200), ctx.json({ status: 200, message: 'ok', ...mock.led }), ); }), - rest.post('/api/config/led', async (req, res, ctx) => { + rest.patch('/api/config/led', async (req, res, ctx) => { mock.led = await req.json(); - console.debug(`Post new LED configuration: ${mock.led}`); + console.debug(`Update LED configuration: ${mock.led}`); return res(ctx.status(200), ctx.json({ status: 200, message: 'ok' })); }), @@ -290,16 +290,16 @@ export const handlers = [ // ------------------ rest.get('/api/config/wifi', (_req, res, ctx) => { - console.debug(`Get wifi configuration: ${mock.wifi}`); + console.debug(`Wifi configuration: ${mock.wifi}`); return res( ctx.status(200), ctx.json({ status: 200, message: 'ok', ...mock.wifi }), ); }), - rest.post('/api/config/wifi', async (req, res, ctx) => { + rest.patch('/api/config/wifi', async (req, res, ctx) => { mock.wifi = await req.json(); - console.debug(`Post new wifi configuration: ${mock.wifi}`); + console.debug(`Update wifi configuration: ${mock.wifi}`); return res(ctx.status(200), ctx.json({ status: 200, message: 'ok' })); }), @@ -308,16 +308,16 @@ export const handlers = [ // ---------------- rest.get('/api/config/ui', (_req, res, ctx) => { - console.debug(`Get UI configuration: ${mock.ui}`); + console.debug(`UI configuration: ${mock.ui}`); return res( ctx.status(200), ctx.json({ status: 200, message: 'ok', ...mock.ui }), ); }), - rest.post('/api/config/ui', async (req, res, ctx) => { + rest.patch('/api/config/ui', async (req, res, ctx) => { mock.ui = await req.json(); - console.debug(`Post new UI configuration: ${mock.ui}`); + console.debug(`Update UI configuration: ${mock.ui}`); return res(ctx.status(200), ctx.json({ status: 200, message: 'ok' })); }), @@ -325,8 +325,8 @@ export const handlers = [ // Motion Sensor Calibration Configuration // --------------------------------------- - rest.get('/api/config/motion', (_req, res, ctx) => { - console.debug(`Get motion configuration: ${mock.motion}`); + rest.get('/api/config/motion/calibration', (_req, res, ctx) => { + console.debug(`Motion calibration configuration: ${mock.motion}`); return res( ctx.status(200), ctx.json({ @@ -337,14 +337,14 @@ export const handlers = [ ); }), - rest.post('/api/config/motion', async (req, res, ctx) => { + rest.patch('/api/config/motion/calibration', async (req, res, ctx) => { mock.motion = await req.json(); - console.debug(`Post new motion configuration: ${mock.motion}`); + console.debug(`Update motion calibration configuration: ${mock.motion}`); return res(ctx.status(200), ctx.json({ status: 200, message: 'ok' })); }), - rest.patch('/api/config/motion', async (_req, res, ctx) => { - console.debug(`Patch motion configuration: ${mock.motion}`); + rest.patch('/api/config/motion/calibration/auto', async (_req, res, ctx) => { + console.debug('Run the motion sensor calibration'); return throttledRes( ctx.status(200), ctx.json({ status: 200, message: 'ok' }), @@ -356,7 +356,7 @@ export const handlers = [ // --------------- rest.get('/api/fseq', async (_req, res, ctx) => { - console.debug(`Get motion configuration: ${mock.motion}`); + console.debug(`FSEQ files: ${mock.fseq}`); return res( ctx.status(200), ctx.json({ @@ -376,7 +376,7 @@ export const handlers = [ fileSize: arrayBuffer.byteLength, fileName, }); - console.debug(`Post new fseq: ${fileName}`); + console.debug(`New FSEQ file: ${fileName}`); return throttledRes( ctx.status(200), ctx.json({ status: 200, message: 'ok' }), @@ -388,7 +388,7 @@ export const handlers = [ mock.fseq.fileList = mock.fseq.fileList.filter( (file) => file.fileName !== fileName, ); - console.debug(`Delete fseq: ${mock.fseq}`); + console.debug(`Delete FSEQ file: ${mock.fseq}`); return res(ctx.status(200), ctx.json({ status: 200, message: 'ok' })); }), @@ -397,7 +397,7 @@ export const handlers = [ // ------ rest.post('/api/update', async (_req, _res, ctx) => { - console.debug('Post update'); + console.debug('Update firmware'); return throttledRes( ctx.status(200), ctx.json({ status: 200, message: 'ok' }), @@ -410,7 +410,7 @@ export const handlers = [ rest.get('/api/log/size', (_req, res, ctx) => { const logSize = mock.log.text.length * 5000; - console.debug(`Get log size: ${logSize}`); + console.debug(`Log size: ${logSize}`); return res( ctx.status(200), ctx.json({ @@ -454,12 +454,12 @@ export const handlers = [ // ----- rest.post('/api/reset/soft', async (_req, res, ctx) => { - console.debug('Post reset soft'); + console.debug('Restart controller'); return res(ctx.status(200), ctx.json({ status: 200, message: 'ok' })); }), rest.post('/api/reset/hard', async (_req, res, ctx) => { - console.debug('Post reset hard'); + console.debug('Restart controller an reset the configuration'); return res(ctx.status(200), ctx.json({ status: 200, message: 'ok' })); }), ]; diff --git a/ui/src/pages/api/led.ts b/ui/src/pages/api/led.ts index c9adade..e9da19a 100644 --- a/ui/src/pages/api/led.ts +++ b/ui/src/pages/api/led.ts @@ -49,7 +49,7 @@ export const useUpdateLed = () => { return useMutation({ mutationFn: async (data) => await ky - .post(LED_API_URL, { + .patch(LED_API_URL, { json: { ledConfig: data }, throwHttpErrors: false, hooks: { diff --git a/ui/src/pages/api/motionSensorCalibration.ts b/ui/src/pages/api/motionSensorCalibration.ts index bc0a6bb..a762810 100644 --- a/ui/src/pages/api/motionSensorCalibration.ts +++ b/ui/src/pages/api/motionSensorCalibration.ts @@ -1,7 +1,8 @@ import { useMutation } from '@tanstack/react-query'; import ky from 'ky'; -export const MOTION_SENSOR_CALIBRATION_API_URL = '/api/config/motion'; +export const MOTION_SENSOR_CALIBRATION_API_URL = + '/api/config/motion/calibration'; export type MotionSensorCalibration = { accXRaw: number; @@ -26,5 +27,5 @@ type Response = { export const useAutoMotionSensorCalibration = () => useMutation({ mutationFn: async () => - await ky.patch(`${MOTION_SENSOR_CALIBRATION_API_URL}`).json(), + await ky.patch(`${MOTION_SENSOR_CALIBRATION_API_URL}/auto`).json(), }); diff --git a/ui/src/pages/api/openapi.json b/ui/src/pages/api/openapi.json index 9f5ddeb..56d9c7d 100644 --- a/ui/src/pages/api/openapi.json +++ b/ui/src/pages/api/openapi.json @@ -23,10 +23,6 @@ "name": "System Information", "description": "Read the system information from the TesLight controller" }, - { - "name": "Profile Management", - "description": "Manage user profiles" - }, { "name": "System Configuration", "description": "Read and update the system configuration" @@ -66,6 +62,10 @@ { "name": "Reset", "description": "Restart or \\\"factory reset\\\" the controller" + }, + { + "name": "Profile Management", + "description": "Manage user profiles" } ], "paths": { @@ -109,19 +109,19 @@ } } }, - "/config/profile/active": { + "/config/system": { "get": { - "tags": ["Profile Management"], - "summary": "Get the currently active user profile.", - "description": "Get the currently active user profile.", - "operationId": "getActiveProfile", + "tags": ["System Configuration"], + "summary": "Get system configuration.", + "description": "Get the current system configuration from the controller.", + "operationId": "getSystemConfig", "responses": { "200": { - "description": "Response contains the name of the active user profile.", + "description": "Response contains the current system configuration.", "content": { "application/json": { "schema": { - "$ref": "#/components/schemas/Profile" + "$ref": "#/components/schemas/SystemConfiguration" } } } @@ -129,16 +129,16 @@ } }, "patch": { - "tags": ["Profile Management"], - "summary": "Update the active user profile.", - "description": "Update the active user profile.", - "operationId": "updateActiveUserProfile", + "tags": ["System Configuration"], + "summary": "Update system configuration.", + "description": "Update the current system configuration on the controller.", + "operationId": "setSystemConfig", "requestBody": { - "$ref": "#/components/requestBodies/Profile" + "$ref": "#/components/requestBodies/SystemConfiguration" }, "responses": { "200": { - "description": "The active profile was updated.", + "description": "The configuration was updated.", "content": { "application/json": { "schema": { @@ -157,16 +157,6 @@ } } }, - "404": { - "description": "The profile was not found.", - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/ApiResponse" - } - } - } - }, "500": { "description": "Failed to process the request.", "content": { @@ -180,36 +170,36 @@ } } }, - "/config/profile": { + "/config/led": { "get": { - "tags": ["Profile Management"], - "summary": "Get a list of all user profile.", - "description": "Get a list of all user profile.", - "operationId": "getProfileList", + "tags": ["LED/Zone Configuration"], + "summary": "Get LED/zone configuration.", + "description": "Get the current LED/zone configuration from the controller.", + "operationId": "getLedConfig", "responses": { "200": { - "description": "Response contains the names of all user profiles.", + "description": "Response contains the current LED/zone configuration.", "content": { "application/json": { "schema": { - "$ref": "#/components/schemas/ProfileList" + "$ref": "#/components/schemas/LedConfiguration" } } } } } }, - "post": { - "tags": ["Profile Management"], - "summary": "Create a new user profile.", - "description": "Create a new user profile.", - "operationId": "createUserProfile", + "patch": { + "tags": ["LED/Zone Configuration"], + "summary": "Update LED/zone configuration.", + "description": "Update the current LED/zone configuration on the controller.", + "operationId": "setLedConfig", "requestBody": { - "$ref": "#/components/requestBodies/Profile" + "$ref": "#/components/requestBodies/LedConfiguration" }, "responses": { "200": { - "description": "The profile was created.", + "description": "The configuration was updated.", "content": { "application/json": { "schema": { @@ -239,29 +229,38 @@ } } } - }, - "put": { - "tags": ["Profile Management"], - "summary": "Clone an existing user profile.", - "description": "Clone an existing user profile.", - "operationId": "cloneUserProfile", - "parameters": [ - { - "name": "name", - "in": "query", - "description": "Name of the source profile.", - "schema": { - "type": "string" - }, - "required": true + } + }, + "/config/wifi": { + "get": { + "tags": ["WiFi Configuration"], + "summary": "WiFi configuration.", + "description": "Get the current WiFi configuration from the controller.", + "operationId": "getWifiConfig", + "responses": { + "200": { + "description": "Response contains the current WiFi configuration.", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/WiFiConfiguration" + } + } + } } - ], + } + }, + "patch": { + "tags": ["WiFi Configuration"], + "summary": "Update WiFi configuration.", + "description": "Update the current WiFi configuration on the controller.", + "operationId": "setWiFiConfig", "requestBody": { - "$ref": "#/components/requestBodies/Profile" + "$ref": "#/components/requestBodies/WiFiConfiguration" }, "responses": { "200": { - "description": "The profile was cloned.", + "description": "The configuration was updated.", "content": { "application/json": { "schema": { @@ -280,8 +279,8 @@ } } }, - "404": { - "description": "The source profile was not found.", + "500": { + "description": "Failed to process the request.", "content": { "application/json": { "schema": { @@ -289,38 +288,40 @@ } } } - }, - "500": { - "description": "Failed to process the request.", + } + } + } + }, + "/config/motion/calibration": { + "get": { + "tags": ["Motion Sensor Calibration Configuration"], + "summary": "Read the motion sensor calibration.", + "description": "Read the motion sensor calibration.", + "operationId": "getMotionSensorCalibration", + "responses": { + "200": { + "description": "Response contains the current motion sensor calibration.", "content": { "application/json": { "schema": { - "$ref": "#/components/schemas/ApiResponse" + "$ref": "#/components/schemas/MotionSensorCalibration" } } } } } }, - "delete": { - "tags": ["Profile Management"], - "summary": "Delete an existing user profile.", - "description": "Delete an existing user profile.", - "operationId": "deleteUserProfile", - "parameters": [ - { - "name": "name", - "in": "query", - "description": "Name of the profile to delete.", - "schema": { - "type": "string" - }, - "required": true - } - ], + "patch": { + "tags": ["Motion Sensor Calibration Configuration"], + "summary": "Update the motion sensor calibration.", + "description": "Update the current motion sensor calibration on the controller.", + "operationId": "setMotionSensorCalibration", + "requestBody": { + "$ref": "#/components/requestBodies/MotionSensorCalibration" + }, "responses": { "200": { - "description": "The profile was delete.", + "description": "The calibration data was updated.", "content": { "application/json": { "schema": { @@ -339,8 +340,38 @@ } } }, - "404": { - "description": "The profile was not found.", + "500": { + "description": "Failed to process the request.", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ApiResponse" + } + } + } + } + } + } + }, + "/config/motion/calibration/auto": { + "patch": { + "tags": ["Motion Sensor Calibration Configuration"], + "summary": "Automatically run the motion sensor calibration.", + "description": "Automatically run the current motion sensor calibration on the controller.", + "operationId": "calibrateMotionSensor", + "responses": { + "200": { + "description": "The calibration data was updated.", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ApiResponse" + } + } + } + }, + "412": { + "description": "The motion sensor is not ready to be calibrated.", "content": { "application/json": { "schema": { @@ -362,32 +393,32 @@ } } }, - "/config/system": { + "/config/audio": { "get": { - "tags": ["System Configuration"], - "summary": "Get system configuration.", - "description": "Get the current system configuration from the controller.", - "operationId": "getSystemConfig", + "tags": ["Audio Unit Configuration"], + "summary": "Read the audio unit configuration.", + "description": "Read the audio unit configuration.", + "operationId": "getAudioUnitConfiguration", "responses": { "200": { - "description": "Response contains the current system configuration.", + "description": "Response contains the current audio unit configuration.", "content": { "application/json": { "schema": { - "$ref": "#/components/schemas/SystemConfiguration" + "$ref": "#/components/schemas/AudioUnitConfiguration" } } } } } }, - "post": { - "tags": ["System Configuration"], - "summary": "Update system configuration.", - "description": "Update the current system configuration on the controller.", - "operationId": "setSystemConfig", + "patch": { + "tags": ["Audio Unit Configuration"], + "summary": "Update the audio unit configuration.", + "description": "Update the current audio unit configuration on the controller.", + "operationId": "setAudioUnitConfiguration", "requestBody": { - "$ref": "#/components/requestBodies/SystemConfiguration" + "$ref": "#/components/requestBodies/AudioUnitConfiguration" }, "responses": { "200": { @@ -423,32 +454,32 @@ } } }, - "/config/led": { + "/config/ui": { "get": { - "tags": ["LED/Zone Configuration"], - "summary": "Get LED/zone configuration.", - "description": "Get the current LED/zone configuration from the controller.", - "operationId": "getLedConfig", + "tags": ["UI Configuration"], + "summary": "Get UI configuration.", + "description": "Get the current UI configuration from the controller.", + "operationId": "getUIConfig", "responses": { "200": { - "description": "Response contains the current LED/zone configuration.", + "description": "Response contains the current UI configuration.", "content": { "application/json": { "schema": { - "$ref": "#/components/schemas/LedConfiguration" + "$ref": "#/components/schemas/UIConfiguration" } } } } } }, - "post": { - "tags": ["LED/Zone Configuration"], - "summary": "Update LED/zone configuration.", - "description": "Update the current LED/zone configuration on the controller.", - "operationId": "setLedConfig", + "patch": { + "tags": ["UI Configuration"], + "summary": "Update UI configuration.", + "description": "Update the current UI configuration on the controller.", + "operationId": "setUIConfig", "requestBody": { - "$ref": "#/components/requestBodies/LedConfiguration" + "$ref": "#/components/requestBodies/UIConfiguration" }, "responses": { "200": { @@ -484,19 +515,29 @@ } } }, - "/config/wifi": { + "/fseq": { "get": { - "tags": ["WiFi Configuration"], - "summary": "WiFi configuration.", - "description": "Get the current WiFi configuration from the controller.", - "operationId": "getWifiConfig", - "responses": { + "tags": ["FSEQ Management"], + "summary": "List all FSEQ files on the controller.", + "description": "List all FSEQ files currently stored on the controller and get their file size.", + "operationId": "getFSEQList", + "responses": { "200": { - "description": "Response contains the current WiFi configuration.", + "description": "Response contains a list of all FSEQ files stored on the controller.", "content": { "application/json": { "schema": { - "$ref": "#/components/schemas/WiFiConfiguration" + "$ref": "#/components/schemas/FSEQList" + } + } + } + }, + "500": { + "description": "Failed to process the request.", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ApiResponse" } } } @@ -504,16 +545,39 @@ } }, "post": { - "tags": ["WiFi Configuration"], - "summary": "Update WiFi configuration.", - "description": "Update the current WiFi configuration on the controller.", - "operationId": "setWiFiConfig", + "tags": ["FSEQ Management"], + "summary": "Upload a new FSEQ file to the controller.", + "description": "Upload a new FSEQ file to the controller and validate it.", + "operationId": "uploadFSEQFile", + "parameters": [ + { + "name": "fileName", + "in": "query", + "description": "File name of the FSEQ file under which it should be stored on the controller.", + "schema": { + "type": "string" + }, + "required": true + } + ], "requestBody": { - "$ref": "#/components/requestBodies/WiFiConfiguration" + "content": { + "multipart/form-data": { + "schema": { + "type": "object", + "properties": { + "file": { + "type": "string", + "format": "binary" + } + } + } + } + } }, "responses": { "200": { - "description": "The configuration was updated.", + "description": "The calibration data was updated.", "content": { "application/json": { "schema": { @@ -523,7 +587,7 @@ } }, "400": { - "description": "The request is invalid.", + "description": "The request or the file is invalid.", "content": { "application/json": { "schema": { @@ -543,38 +607,36 @@ } } } - } - }, - "/config/motion": { - "get": { - "tags": ["Motion Sensor Calibration Configuration"], - "summary": "Read the motion sensor calibration.", - "description": "Read the motion sensor calibration.", - "operationId": "getMotionSensorCalibration", + }, + "delete": { + "tags": ["FSEQ Management"], + "summary": "Delete an FSEQ file from the controller.", + "description": "Delete an FSEQ file from the controller.", + "operationId": "deleteFSEQFile", + "parameters": [ + { + "name": "fileName", + "in": "query", + "description": "File name of the FSEQ file which should be deleted from the controller.", + "schema": { + "type": "string" + }, + "required": true + } + ], "responses": { "200": { - "description": "Response contains the current motion sensor calibration.", + "description": "The calibration data was updated.", "content": { "application/json": { "schema": { - "$ref": "#/components/schemas/MotionSensorCalibration" + "$ref": "#/components/schemas/ApiResponse" } } } - } - } - }, - "post": { - "tags": ["Motion Sensor Calibration Configuration"], - "summary": "Update the motion sensor calibration.", - "description": "Update the current motion sensor calibration on the controller.", - "operationId": "setMotionSensorCalibration", - "requestBody": { - "$ref": "#/components/requestBodies/MotionSensorCalibration" - }, - "responses": { - "200": { - "description": "The calibration data was updated.", + }, + "400": { + "description": "The request is not valid.", "content": { "application/json": { "schema": { @@ -583,8 +645,8 @@ } } }, - "400": { - "description": "The request is invalid.", + "404": { + "description": "The file was not found.", "content": { "application/json": { "schema": { @@ -604,25 +666,42 @@ } } } - }, - "patch": { - "tags": ["Motion Sensor Calibration Configuration"], - "summary": "Automatically run the motion sensor calibration.", - "description": "Automatically run the current motion sensor calibration on the controller.", - "operationId": "calibrateMotionSensor", + } + }, + "/update": { + "post": { + "tags": ["Update"], + "summary": "Update the TesLight controller with a new firmware.", + "description": "Upload a TesLight update package and update the controller with a new firmware.", + "operationId": "uploadTUP", + "requestBody": { + "content": { + "multipart/form-data": { + "schema": { + "type": "object", + "properties": { + "file": { + "type": "string", + "format": "binary" + } + } + } + } + } + }, "responses": { "200": { - "description": "The calibration data was updated.", + "description": "The upload and validation was successful. Update will be installed after a reboot.", "content": { "application/json": { "schema": { - "$ref": "#/components/schemas/ApiResponse" + "$ref": "#/components/schemas/FSEQList" } } } }, - "412": { - "description": "The motion sensor is not ready to be calibrated.", + "400": { + "description": "The request is not valid. Probably the update package is corrupted.", "content": { "application/json": { "schema": { @@ -644,50 +723,19 @@ } } }, - "/config/audio": { + "/log/size": { "get": { - "tags": ["Audio Unit Configuration"], - "summary": "Read the audio unit configuration.", - "description": "Read the audio unit configuration.", - "operationId": "getAudioUnitConfiguration", - "responses": { - "200": { - "description": "Response contains the current audio unit configuration.", - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/AudioUnitConfiguration" - } - } - } - } - } - }, - "post": { - "tags": ["Audio Unit Configuration"], - "summary": "Update the audio unit configuration.", - "description": "Update the current audio unit configuration on the controller.", - "operationId": "setAudioUnitConfiguration", - "requestBody": { - "$ref": "#/components/requestBodies/AudioUnitConfiguration" - }, + "tags": ["Log"], + "summary": "Get the size of the log file.", + "description": "Get the current size of the log file stored on the controller.", + "operationId": "getLogSize", "responses": { "200": { - "description": "The configuration was updated.", - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/ApiResponse" - } - } - } - }, - "400": { - "description": "The request is invalid.", + "description": "Response contains the size of the log in bytes.", "content": { "application/json": { "schema": { - "$ref": "#/components/schemas/ApiResponse" + "$ref": "#/components/schemas/LogSize" } } } @@ -705,36 +753,63 @@ } } }, - "/config/ui": { + "/log": { "get": { - "tags": ["UI Configuration"], - "summary": "Get UI configuration.", - "description": "Get the current UI configuration from the controller.", - "operationId": "getUIConfig", + "tags": ["Log"], + "summary": "Get a part of the log file.", + "description": "Get a part of the log file. Note that this can be slow when a hug part of the file is read.", + "operationId": "getLog", + "parameters": [ + { + "name": "start", + "in": "query", + "description": "Start position from where to start to read the log.", + "schema": { + "type": "integer", + "format": "uint32" + }, + "required": true + }, + { + "name": "count", + "in": "query", + "description": "Number of bytes to read from the log.", + "schema": { + "type": "integer", + "format": "uint32" + }, + "required": true + } + ], "responses": { "200": { - "description": "Response contains the current UI configuration.", + "description": "Response directly contains a segement of the log.", + "content": { + "text/plain": { + "example": "Some log data" + } + } + }, + "500": { + "description": "Failed to process the request.", "content": { "application/json": { "schema": { - "$ref": "#/components/schemas/UIConfiguration" + "$ref": "#/components/schemas/ApiResponse" } } } } } }, - "post": { - "tags": ["UI Configuration"], - "summary": "Update UI configuration.", - "description": "Update the current UI configuration on the controller.", - "operationId": "setUIConfig", - "requestBody": { - "$ref": "#/components/requestBodies/UIConfiguration" - }, + "delete": { + "tags": ["Log"], + "summary": "Clear the log.", + "description": "Clear the log file on the controller.", + "operationId": "deleteLog", "responses": { "200": { - "description": "The configuration was updated.", + "description": "Positive response.", "content": { "application/json": { "schema": { @@ -743,8 +818,8 @@ } } }, - "400": { - "description": "The request is invalid.", + "500": { + "description": "Failed to process the request.", "content": { "application/json": { "schema": { @@ -752,9 +827,19 @@ } } } - }, - "500": { - "description": "Failed to process the request.", + } + } + } + }, + "/reset/soft": { + "post": { + "tags": ["Reset"], + "summary": "Restart the controller.", + "description": "Restart the controller while keeping the configuration.", + "operationId": "restartSoft", + "responses": { + "200": { + "description": "Positive response.", "content": { "application/json": { "schema": { @@ -766,69 +851,56 @@ } } }, - "/fseq": { - "get": { - "tags": ["FSEQ Management"], - "summary": "List all FSEQ files on the controller.", - "description": "List all FSEQ files currently stored on the controller and get their file size.", - "operationId": "getFSEQList", + "/reset/hard": { + "post": { + "tags": ["Reset"], + "summary": "Restart the controller and reset the configuration.", + "description": "Restart the controller and reset the configuration to defaults.", + "operationId": "restartHard", "responses": { "200": { - "description": "Response contains a list of all FSEQ files stored on the controller.", + "description": "Positive response.", "content": { "application/json": { "schema": { - "$ref": "#/components/schemas/FSEQList" + "$ref": "#/components/schemas/ApiResponse" } } } - }, - "500": { - "description": "Failed to process the request.", + } + } + } + }, + "/config/profile/active": { + "get": { + "tags": ["Profile Management"], + "summary": "Get the currently active user profile.", + "description": "Get the currently active user profile.", + "operationId": "getActiveProfile", + "responses": { + "200": { + "description": "Response contains the name of the active user profile.", "content": { "application/json": { "schema": { - "$ref": "#/components/schemas/ApiResponse" + "$ref": "#/components/schemas/Profile" } } } } } }, - "post": { - "tags": ["FSEQ Management"], - "summary": "Upload a new FSEQ file to the controller.", - "description": "Upload a new FSEQ file to the controller and validate it.", - "operationId": "uploadFSEQFile", - "parameters": [ - { - "name": "fileName", - "in": "query", - "description": "File name of the FSEQ file under which it should be stored on the controller.", - "schema": { - "type": "string" - }, - "required": true - } - ], + "patch": { + "tags": ["Profile Management"], + "summary": "Update the active user profile.", + "description": "Update the active user profile.", + "operationId": "updateActiveUserProfile", "requestBody": { - "content": { - "multipart/form-data": { - "schema": { - "type": "object", - "properties": { - "file": { - "type": "string", - "format": "binary" - } - } - } - } - } + "$ref": "#/components/requestBodies/Profile" }, "responses": { "200": { - "description": "The calibration data was updated.", + "description": "The active profile was updated.", "content": { "application/json": { "schema": { @@ -838,7 +910,17 @@ } }, "400": { - "description": "The request or the file is invalid.", + "description": "The request is invalid.", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ApiResponse" + } + } + } + }, + "404": { + "description": "The profile was not found.", "content": { "application/json": { "schema": { @@ -858,36 +940,38 @@ } } } - }, - "delete": { - "tags": ["FSEQ Management"], - "summary": "Delete an FSEQ file from the controller.", - "description": "Delete an FSEQ file from the controller.", - "operationId": "deleteFSEQFile", - "parameters": [ - { - "name": "fileName", - "in": "query", - "description": "File name of the FSEQ file which should be deleted from the controller.", - "schema": { - "type": "string" - }, - "required": true - } - ], + } + }, + "/config/profile": { + "get": { + "tags": ["Profile Management"], + "summary": "Get a list of all user profile.", + "description": "Get a list of all user profile.", + "operationId": "getProfileList", "responses": { "200": { - "description": "The calibration data was updated.", + "description": "Response contains the names of all user profiles.", "content": { "application/json": { "schema": { - "$ref": "#/components/schemas/ApiResponse" + "$ref": "#/components/schemas/ProfileList" } } } - }, - "400": { - "description": "The request is not valid.", + } + } + }, + "post": { + "tags": ["Profile Management"], + "summary": "Create a new user profile.", + "description": "Create a new user profile.", + "operationId": "createUserProfile", + "requestBody": { + "$ref": "#/components/requestBodies/Profile" + }, + "responses": { + "200": { + "description": "The profile was created.", "content": { "application/json": { "schema": { @@ -896,8 +980,8 @@ } } }, - "404": { - "description": "The file was not found.", + "400": { + "description": "The request is invalid.", "content": { "application/json": { "schema": { @@ -917,42 +1001,39 @@ } } } - } - }, - "/update": { - "post": { - "tags": ["Update"], - "summary": "Update the TesLight controller with a new firmware.", - "description": "Upload a TesLight update package and update the controller with a new firmware.", - "operationId": "uploadTUP", - "requestBody": { - "content": { - "multipart/form-data": { - "schema": { - "type": "object", - "properties": { - "file": { - "type": "string", - "format": "binary" - } - } - } - } + }, + "put": { + "tags": ["Profile Management"], + "summary": "Clone an existing user profile.", + "description": "Clone an existing user profile.", + "operationId": "cloneUserProfile", + "parameters": [ + { + "name": "name", + "in": "query", + "description": "Name of the source profile.", + "schema": { + "type": "string" + }, + "required": true } + ], + "requestBody": { + "$ref": "#/components/requestBodies/Profile" }, "responses": { "200": { - "description": "The upload and validation was successful. Update will be installed after a reboot.", + "description": "The profile was cloned.", "content": { "application/json": { "schema": { - "$ref": "#/components/schemas/FSEQList" + "$ref": "#/components/schemas/ApiResponse" } } } }, "400": { - "description": "The request is not valid. Probably the update package is corrupted.", + "description": "The request is invalid.", "content": { "application/json": { "schema": { @@ -961,8 +1042,8 @@ } } }, - "500": { - "description": "Failed to process the request.", + "404": { + "description": "The source profile was not found.", "content": { "application/json": { "schema": { @@ -970,26 +1051,6 @@ } } } - } - } - } - }, - "/log/size": { - "get": { - "tags": ["Log"], - "summary": "Get the size of the log file.", - "description": "Get the current size of the log file stored on the controller.", - "operationId": "getLogSize", - "responses": { - "200": { - "description": "Response contains the size of the log in bytes.", - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/LogSize" - } - } - } }, "500": { "description": "Failed to process the request.", @@ -1002,65 +1063,26 @@ } } } - } - }, - "/log": { - "get": { - "tags": ["Log"], - "summary": "Get a part of the log file.", - "description": "Get a part of the log file. Note that this can be slow when a hug part of the file is read.", - "operationId": "getLog", + }, + "delete": { + "tags": ["Profile Management"], + "summary": "Delete an existing user profile.", + "description": "Delete an existing user profile.", + "operationId": "deleteUserProfile", "parameters": [ { - "name": "start", - "in": "query", - "description": "Start position from where to start to read the log.", - "schema": { - "type": "integer", - "format": "uint32" - }, - "required": true - }, - { - "name": "count", + "name": "name", "in": "query", - "description": "Number of bytes to read from the log.", + "description": "Name of the profile to delete.", "schema": { - "type": "integer", - "format": "uint32" + "type": "string" }, "required": true } ], "responses": { "200": { - "description": "Response directly contains a segement of the log.", - "content": { - "text/plain": { - "example": "Some log data" - } - } - }, - "500": { - "description": "Failed to process the request.", - "content": { - "application/json": { - "schema": { - "$ref": "#/components/schemas/ApiResponse" - } - } - } - } - } - }, - "delete": { - "tags": ["Log"], - "summary": "Clear the log.", - "description": "Clear the log file on the controller.", - "operationId": "deleteLog", - "responses": { - "200": { - "description": "Positive response.", + "description": "The profile was delete.", "content": { "application/json": { "schema": { @@ -1069,8 +1091,8 @@ } } }, - "500": { - "description": "Failed to process the request.", + "400": { + "description": "The request is invalid.", "content": { "application/json": { "schema": { @@ -1078,19 +1100,9 @@ } } } - } - } - } - }, - "/reset/soft": { - "post": { - "tags": ["Reset"], - "summary": "Restart the controller.", - "description": "Restart the controller while keeping the configuration.", - "operationId": "restartSoft", - "responses": { - "200": { - "description": "Positive response.", + }, + "404": { + "description": "The profile was not found.", "content": { "application/json": { "schema": { @@ -1098,19 +1110,9 @@ } } } - } - } - } - }, - "/reset/hard": { - "post": { - "tags": ["Reset"], - "summary": "Restart the controller and reset the configuration.", - "description": "Restart the controller and reset the configuration to defaults.", - "operationId": "restartHard", - "responses": { - "200": { - "description": "Positive response.", + }, + "500": { + "description": "Failed to process the request.", "content": { "application/json": { "schema": { @@ -1287,45 +1289,6 @@ } } }, - "Profile": { - "properties": { - "profile": { - "type": "object", - "properties": { - "name": { - "type": "string", - "example": "New Profile" - } - } - } - } - }, - "ProfileList": { - "type": "object", - "properties": { - "status": { - "type": "integer", - "format": "int32", - "example": 200 - }, - "message": { - "type": "string", - "example": "Message" - }, - "profile": { - "type": "object", - "properties": { - "names": { - "type": "array", - "items": { - "type": "string", - "example": "Profile" - } - } - } - } - } - }, "SystemConfiguration": { "type": "object", "properties": { @@ -1805,6 +1768,54 @@ } } } + }, + "Profile": { + "properties": { + "status": { + "type": "integer", + "format": "int32", + "example": 200 + }, + "message": { + "type": "string", + "example": "Message" + }, + "profile": { + "type": "object", + "properties": { + "name": { + "type": "string", + "example": "New Profile" + } + } + } + } + }, + "ProfileList": { + "type": "object", + "properties": { + "status": { + "type": "integer", + "format": "int32", + "example": 200 + }, + "message": { + "type": "string", + "example": "Message" + }, + "profile": { + "type": "object", + "properties": { + "names": { + "type": "array", + "items": { + "type": "string", + "example": "Profile" + } + } + } + } + } } }, "requestBodies": { @@ -1905,27 +1916,6 @@ } } }, - "Profile": { - "description": "Contains the name of a profile.", - "content": { - "application/json": { - "schema": { - "type": "object", - "properties": { - "profile": { - "type": "object", - "properties": { - "name": { - "type": "string", - "example": "New Profile" - } - } - } - } - } - } - } - }, "LedConfiguration": { "description": "Update the current LED/zone configuration on the controller.", "content": { @@ -2241,6 +2231,27 @@ } } } + }, + "Profile": { + "description": "Contains the name of a profile.", + "content": { + "application/json": { + "schema": { + "type": "object", + "properties": { + "profile": { + "type": "object", + "properties": { + "name": { + "type": "string", + "example": "New Profile" + } + } + } + } + } + } + } } } } diff --git a/ui/src/pages/api/system.ts b/ui/src/pages/api/system.ts index aedae6a..188a562 100644 --- a/ui/src/pages/api/system.ts +++ b/ui/src/pages/api/system.ts @@ -54,7 +54,7 @@ export const useUpdateSystem = () => { const queryClient = useQueryClient(); return useMutation({ mutationFn: async (data) => - await ky.post(SYSTEM_API_URL, { json: { systemConfig: data } }).json(), + await ky.patch(SYSTEM_API_URL, { json: { systemConfig: data } }).json(), onMutate: async (systemConfig) => { await queryClient.cancelQueries({ queryKey: [SYSTEM_API_URL] }); const cache = queryClient.getQueryData([SYSTEM_API_URL]); diff --git a/ui/src/pages/api/ui.ts b/ui/src/pages/api/ui.ts index 47683f0..9ad3eba 100644 --- a/ui/src/pages/api/ui.ts +++ b/ui/src/pages/api/ui.ts @@ -40,7 +40,7 @@ export const useUpdateUi = () => { const queryClient = useQueryClient(); return useMutation({ mutationFn: async (data) => - await ky.post(UI_API_URL, { json: { uiConfig: data } }).json(), + await ky.patch(UI_API_URL, { json: { uiConfig: data } }).json(), onMutate: async (uiConfig) => { await queryClient.cancelQueries({ queryKey: [UI_API_URL] }); const cache = queryClient.getQueryData([UI_API_URL]); diff --git a/ui/src/pages/api/wifi.ts b/ui/src/pages/api/wifi.ts index 06dfa85..dcbfa8d 100644 --- a/ui/src/pages/api/wifi.ts +++ b/ui/src/pages/api/wifi.ts @@ -41,7 +41,7 @@ export const useUpdateWifi = () => { const queryClient = useQueryClient(); return useMutation({ mutationFn: async (data) => - await ky.post(WIFI_API_URL, { json: { wifiConfig: data } }).json(), + await ky.patch(WIFI_API_URL, { json: { wifiConfig: data } }).json(), onMutate: async (wifiConfig) => { await queryClient.cancelQueries({ queryKey: [WIFI_API_URL] }); const cache = queryClient.getQueryData([WIFI_API_URL]);