Skip to content

Commit

Permalink
fix: http methods (#154)
Browse files Browse the repository at this point in the history
* Sync with internal rep

* update doc

* Fix typo

* Update methods

* Remove secret information *laugh*

* chore(ui): update http request methods

Closes: #154

---------

Co-authored-by: Daniel Bayerlein
  • Loading branch information
TheRealKasumi committed Mar 31, 2023
1 parent 3d61fda commit d6e81f8
Show file tree
Hide file tree
Showing 21 changed files with 570 additions and 552 deletions.
16 changes: 9 additions & 7 deletions documentation/api/OpenApi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ paths:
application/json:
schema:
$ref: "#/components/schemas/SystemConfiguration"
post:
patch:
tags:
- System Configuration
summary: Update system configuration.
Expand Down Expand Up @@ -127,7 +127,7 @@ paths:
application/json:
schema:
$ref: "#/components/schemas/LedConfiguration"
post:
patch:
tags:
- LED/Zone Configuration
summary: Update LED/zone configuration.
Expand Down Expand Up @@ -168,7 +168,7 @@ paths:
application/json:
schema:
$ref: "#/components/schemas/WiFiConfiguration"
post:
patch:
tags:
- WiFi Configuration
summary: Update WiFi configuration.
Expand All @@ -195,7 +195,8 @@ paths:
application/json:
schema:
$ref: "#/components/schemas/ApiResponse"
/config/motion:

/config/motion/calibration:
get:
tags:
- Motion Sensor Calibration Configuration
Expand All @@ -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.
Expand All @@ -236,6 +237,7 @@ paths:
application/json:
schema:
$ref: "#/components/schemas/ApiResponse"
/config/motion/calibration/auto:
patch:
tags:
- Motion Sensor Calibration Configuration
Expand Down Expand Up @@ -277,7 +279,7 @@ paths:
application/json:
schema:
$ref: "#/components/schemas/AudioUnitConfiguration"
post:
patch:
tags:
- Audio Unit Configuration
summary: Update the audio unit configuration.
Expand Down Expand Up @@ -318,7 +320,7 @@ paths:
application/json:
schema:
$ref: "#/components/schemas/UIConfiguration"
post:
patch:
tags:
- UI Configuration
summary: Update UI configuration.
Expand Down
30 changes: 17 additions & 13 deletions documentation/api/TesLight API.postman_collection.json
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@
"disabledSystemHeaders": {}
},
"request": {
"method": "POST",
"method": "PATCH",
"header": [],
"body": {
"mode": "raw",
Expand Down Expand Up @@ -114,7 +114,7 @@
"disabledSystemHeaders": {}
},
"request": {
"method": "POST",
"method": "PATCH",
"header": [],
"body": {
"mode": "raw",
Expand Down Expand Up @@ -168,7 +168,7 @@
{
"name": "Set WiFi Configuration",
"request": {
"method": "POST",
"method": "PATCH",
"header": [],
"body": {
"mode": "raw",
Expand Down Expand Up @@ -441,15 +441,16 @@
"method": "GET",
"header": [],
"url": {
"raw": "http://{{TESLIGHTIP}}/api/config/motion",
"raw": "http://{{TESLIGHTIP}}/api/config/motion/calibration",
"protocol": "http",
"host": [
"{{TESLIGHTIP}}"
],
"path": [
"api",
"config",
"motion"
"motion",
"calibration"
]
}
},
Expand All @@ -461,7 +462,7 @@
"disabledSystemHeaders": {}
},
"request": {
"method": "POST",
"method": "PATCH",
"header": [],
"body": {
"mode": "raw",
Expand All @@ -473,15 +474,16 @@
}
},
"url": {
"raw": "http://{{TESLIGHTIP}}/api/config/motion",
"raw": "http://{{TESLIGHTIP}}/api/config/motion/calibration",
"protocol": "http",
"host": [
"{{TESLIGHTIP}}"
],
"path": [
"api",
"config",
"motion"
"motion",
"calibration"
]
}
},
Expand All @@ -496,15 +498,17 @@
"method": "PATCH",
"header": [],
"url": {
"raw": "http://{{TESLIGHTIP}}/api/config/motion",
"raw": "http://{{TESLIGHTIP}}/api/config/motion/calibration/auto",
"protocol": "http",
"host": [
"{{TESLIGHTIP}}"
],
"path": [
"api",
"config",
"motion"
"motion",
"calibration",
"auto"
]
}
},
Expand Down Expand Up @@ -541,7 +545,7 @@
"disabledSystemHeaders": {}
},
"request": {
"method": "POST",
"method": "PATCH",
"header": [],
"body": {
"mode": "raw",
Expand Down Expand Up @@ -598,7 +602,7 @@
"disabledSystemHeaders": {}
},
"request": {
"method": "POST",
"method": "PATCH",
"header": [],
"body": {
"mode": "raw",
Expand Down Expand Up @@ -845,4 +849,4 @@
"type": "string"
}
]
}
}
2 changes: 1 addition & 1 deletion mcu/include/server/AudioUnitConfigurationEndpoint.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion mcu/include/server/LedConfigurationEndpoint.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion mcu/include/server/MotionSensorEndpoint.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion mcu/include/server/SystemConfigurationEndpoint.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion mcu/include/server/UIConfigurationEndpoint.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ namespace TL
UIConfigurationEndpoint();

static void getUIConfig();
static void postUIConfig();
static void patchUIConfig();

static bool validateUIConfig(const JsonObject &jsonObject);
};
Expand Down
2 changes: 1 addition & 1 deletion mcu/include/server/WiFiConfigurationEndpoint.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
6 changes: 3 additions & 3 deletions mcu/src/server/AudioUnitConfigurationEndpoint.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

/**
Expand Down Expand Up @@ -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())
Expand Down
6 changes: 3 additions & 3 deletions mcu/src/server/LedConfigurationEndpoint.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

/**
Expand Down Expand Up @@ -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())
Expand Down
10 changes: 5 additions & 5 deletions mcu/src/server/MotionSensorEndpoint.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

/**
Expand Down Expand Up @@ -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())
Expand Down
6 changes: 3 additions & 3 deletions mcu/src/server/SystemConfigurationEndpoint.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

/**
Expand Down Expand Up @@ -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())
Expand Down
6 changes: 3 additions & 3 deletions mcu/src/server/UIConfigurationEndpoint.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

/**
Expand Down Expand Up @@ -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())
Expand Down
6 changes: 3 additions & 3 deletions mcu/src/server/WiFiConfigurationEndpoint.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

/**
Expand Down Expand Up @@ -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())
Expand Down
Loading

0 comments on commit d6e81f8

Please sign in to comment.