MQTTSuite
Loading...
Searching...
No Matches
JsonMappingReader.h
Go to the documentation of this file.
1/*
2 * MQTTSuite - A lightweight MQTT Integration System
3 * Copyright (C) Volker Christian <me@vchrist.at>
4 * 2022, 2023, 2024, 2025, 2026
5 * Tobias Pfeil
6 * 2025, 2026
7 *
8 * This program is free software: you can redistribute it and/or modify it
9 * under the terms of the GNU General Public License as published by the Free
10 * Software Foundation, either version 3 of the License, or (at your option)
11 * any later version.
12 *
13 * This program is distributed in the hope that it will be useful, but WITHOUT
14 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
15 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
16 * more details.
17 *
18 * You should have received a copy of the GNU General Public License along
19 * with this program. If not, see <https://www.gnu.org/licenses/>.
20 */
21
22/*
23 * MIT License
24 *
25 * Permission is hereby granted, free of charge, to any person obtaining a copy
26 * of this software and associated documentation files (the "Software"), to deal
27 * in the Software without restriction, including without limitation the rights
28 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
29 * copies of the Software, and to permit persons to whom the Software is
30 * furnished to do so, subject to the following conditions:
31 *
32 * The above copyright notice and this permission notice shall be included in
33 * all copies or substantial portions of the Software.
34 *
35 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
36 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
37 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
38 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
39 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
40 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
41 * THE SOFTWARE.
42 */
43
44#ifndef MQTTBROKER_LIB_JSONMAPPINGREADER_H
45#define MQTTBROKER_LIB_JSONMAPPINGREADER_H
46
47#ifndef DOXYGEN_SHOULD_SKIP_THIS
48
49#include <nlohmann/json_fwd.hpp> // IWYU pragma: export
50#include <string>
51#include <vector>
52
53#endif // DOXYGEN_SHOULD_SKIP_THIS
54
55namespace mqtt::lib {
56
58 public:
60
61 public:
62 static nlohmann::json readMappingFromFile(const std::string& mapFilePath);
63
64 // Admin / Live Reload Support
65 static void saveDraft(const std::string& mapFilePath, const nlohmann::json& content);
66 static nlohmann::json readDraftOrActive(const std::string& mapFilePath);
67 static nlohmann::json deployDraft(const std::string& mapFilePath);
68 static void discardDraft(const std::string& mapFilePath);
69 static std::string getDraftPath(const std::string& mapFilePath);
70
71 struct VersionEntry {
72 std::string id;
73 std::string filename;
74 std::string comment;
75 std::string date;
76 };
77
78 static std::vector<VersionEntry> getHistory(const std::string& mapFilePath);
79 static nlohmann::json rollbackTo(const std::string& mapFilePath, const std::string& versionId);
80
81 private:
82 static nlohmann::json getDefaultPatch(const nlohmann::json& inputJson);
83 };
84
85} // namespace mqtt::lib
86
87#endif // MQTTBROKER_LIB_JSONMAPPINGREADER_H
std::string getMappingFilename() const
const std::shared_ptr< MqttMapper > getMqttMapper() const
bool setMappingFile(const std::string &mappingFile)
ConfigApplication & setSessionStore(const std::string &sessionStore)
ConfigApplication(utils::SubCommand *parent, ConcretConfigApplicationT *concretConfigApplication)
std::shared_ptr< MqttMapper > mqttMapper
bool setMapping(const nlohmann::json &json)
std::string getSessionStore() const
ConfigMqttBroker & setHtmlRoot(const std::string &htmlRoot)
static constexpr std::string_view NAME
ConfigMqttBroker(utils::SubCommand *parent)
static constexpr std::string_view DESCRIPTION
static constexpr std::string_view DESCRIPTION
static constexpr std::string_view NAME
ConfigMqttIntegrator(utils::SubCommand *parent)
static nlohmann::json deployDraft(const std::string &mapFilePath)
static nlohmann::json rollbackTo(const std::string &mapFilePath, const std::string &versionId)
static void discardDraft(const std::string &mapFilePath)
static std::vector< VersionEntry > getHistory(const std::string &mapFilePath)
static nlohmann::json readMappingFromFile(const std::string &mapFilePath)
static nlohmann::json readDraftOrActive(const std::string &mapFilePath)
static std::string getDraftPath(const std::string &mapFilePath)
static void saveDraft(const std::string &mapFilePath, const nlohmann::json &content)
static nlohmann::json getDefaultPatch(const nlohmann::json &inputJson)
bool setMapping(nlohmann::json mappingJson)