Skip to content

Commit

Permalink
don't replace q_origin_key underscores
Browse files Browse the repository at this point in the history
  • Loading branch information
cooperlarson committed Sep 2, 2024
1 parent fab00fa commit 342a505
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
14 changes: 14 additions & 0 deletions include/forti_api/api.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,22 @@ struct Response {
inline static nlohmann::json convert_keys_to_hyphens(const nlohmann::json& j) {
nlohmann::json result;

std::array<std::string, 10> ignore_keys{
"q_origin_key"
};

for (auto it = j.begin(); it != j.end(); ++it) {
std::string key = it.key();

bool should_process = true;
for (const auto& ignore : ignore_keys) {
if (key == ignore) {
should_process = false;
break;
}
}
if (!should_process) continue;

std::replace(key.begin(), key.end(), '_', '-');

if (it->is_object()) result[key] = convert_keys_to_hyphens(*it);
Expand Down
2 changes: 1 addition & 1 deletion include/forti_api/firewall.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ struct Service : public Module {
};

struct FirewallPolicy {
unsigned int policyid, q_origin_key, uuid_idx;
unsigned int policyid{}, q_origin_key{}, uuid_idx{};
std::vector<Interface> srcintf, dstintf;
std::vector<Address> srcaddr, dstaddr;
std::vector<Service> service;
Expand Down

0 comments on commit 342a505

Please sign in to comment.