Matthew Barth | 3174e72 | 2020-09-15 15:13:40 -0500 | [diff] [blame] | 1 | /** |
| 2 | * Copyright © 2020 IBM Corporation |
| 3 | * |
| 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | * you may not use this file except in compliance with the License. |
| 6 | * You may obtain a copy of the License at |
| 7 | * |
| 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | * |
| 10 | * Unless required by applicable law or agreed to in writing, software |
| 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | * See the License for the specific language governing permissions and |
| 14 | * limitations under the License. |
| 15 | */ |
| 16 | #include "event.hpp" |
| 17 | |
Matthew Barth | 776ca56 | 2021-03-31 09:50:58 -0500 | [diff] [blame] | 18 | #include "action.hpp" |
Matthew Barth | e557860 | 2021-03-30 12:53:24 -0500 | [diff] [blame] | 19 | #include "config_base.hpp" |
Matthew Barth | 391ade0 | 2021-01-15 14:33:21 -0600 | [diff] [blame] | 20 | #include "group.hpp" |
Matthew Barth | e557860 | 2021-03-30 12:53:24 -0500 | [diff] [blame] | 21 | #include "manager.hpp" |
Matthew Barth | 9403a21 | 2021-05-17 09:31:50 -0500 | [diff] [blame] | 22 | #include "sdbusplus.hpp" |
Matthew Barth | 54b5a24 | 2021-05-21 11:02:52 -0500 | [diff] [blame] | 23 | #include "trigger.hpp" |
Matthew Barth | e557860 | 2021-03-30 12:53:24 -0500 | [diff] [blame] | 24 | |
Matthew Barth | 3174e72 | 2020-09-15 15:13:40 -0500 | [diff] [blame] | 25 | #include <nlohmann/json.hpp> |
| 26 | #include <phosphor-logging/log.hpp> |
| 27 | #include <sdbusplus/bus.hpp> |
| 28 | |
Matthew Barth | e557860 | 2021-03-30 12:53:24 -0500 | [diff] [blame] | 29 | #include <algorithm> |
Patrick Williams | fbf4703 | 2023-07-17 12:27:34 -0500 | [diff] [blame] | 30 | #include <format> |
Matthew Barth | 12bae96 | 2021-01-15 16:18:11 -0600 | [diff] [blame] | 31 | #include <optional> |
Matthew Barth | 12bae96 | 2021-01-15 16:18:11 -0600 | [diff] [blame] | 32 | |
Matthew Barth | 3174e72 | 2020-09-15 15:13:40 -0500 | [diff] [blame] | 33 | namespace phosphor::fan::control::json |
| 34 | { |
| 35 | |
| 36 | using json = nlohmann::json; |
| 37 | using namespace phosphor::logging; |
| 38 | |
Matthew Barth | 3695ac3 | 2021-10-06 14:55:30 -0500 | [diff] [blame] | 39 | std::map<configKey, std::unique_ptr<Group>> Event::allGroups; |
| 40 | |
Matthew Barth | 9403a21 | 2021-05-17 09:31:50 -0500 | [diff] [blame] | 41 | Event::Event(const json& jsonObj, Manager* mgr, |
Matthew Barth | 9f1632e | 2021-03-31 15:51:50 -0500 | [diff] [blame] | 42 | std::map<configKey, std::unique_ptr<Zone>>& zones) : |
Matthew Barth | 44ab769 | 2021-03-26 11:40:10 -0500 | [diff] [blame] | 43 | ConfigBase(jsonObj), |
Matthew Barth | 9403a21 | 2021-05-17 09:31:50 -0500 | [diff] [blame] | 44 | _bus(util::SDBusPlus::getBus()), _manager(mgr), _zones(zones) |
Matthew Barth | 3174e72 | 2020-09-15 15:13:40 -0500 | [diff] [blame] | 45 | { |
Matthew Barth | 619dc0f | 2021-05-20 09:27:02 -0500 | [diff] [blame] | 46 | // Event groups are optional |
| 47 | if (jsonObj.contains("groups")) |
Matthew Barth | 3174e72 | 2020-09-15 15:13:40 -0500 | [diff] [blame] | 48 | { |
Matthew Barth | e386fbb | 2021-06-30 14:33:55 -0500 | [diff] [blame] | 49 | setGroups(jsonObj, _profiles, _groups); |
Matthew Barth | 3174e72 | 2020-09-15 15:13:40 -0500 | [diff] [blame] | 50 | } |
Matthew Barth | 619dc0f | 2021-05-20 09:27:02 -0500 | [diff] [blame] | 51 | // Event actions are optional |
| 52 | if (jsonObj.contains("actions")) |
Matthew Barth | 3174e72 | 2020-09-15 15:13:40 -0500 | [diff] [blame] | 53 | { |
Matthew Barth | 619dc0f | 2021-05-20 09:27:02 -0500 | [diff] [blame] | 54 | setActions(jsonObj); |
Matthew Barth | 3174e72 | 2020-09-15 15:13:40 -0500 | [diff] [blame] | 55 | } |
Matthew Barth | 619dc0f | 2021-05-20 09:27:02 -0500 | [diff] [blame] | 56 | setTriggers(jsonObj); |
Matthew Barth | 3174e72 | 2020-09-15 15:13:40 -0500 | [diff] [blame] | 57 | } |
| 58 | |
Matthew Barth | 54b5a24 | 2021-05-21 11:02:52 -0500 | [diff] [blame] | 59 | void Event::enable() |
| 60 | { |
Matt Spinler | d1f97f4 | 2021-10-29 16:19:24 -0500 | [diff] [blame] | 61 | for (const auto& [type, trigger] : _triggers) |
Matthew Barth | 54b5a24 | 2021-05-21 11:02:52 -0500 | [diff] [blame] | 62 | { |
Matt Spinler | d1f97f4 | 2021-10-29 16:19:24 -0500 | [diff] [blame] | 63 | // Don't call the powerOn or powerOff triggers |
| 64 | if (type.find("power") == std::string::npos) |
| 65 | { |
| 66 | trigger(getName(), _manager, _groups, _actions); |
| 67 | } |
| 68 | } |
| 69 | } |
| 70 | |
| 71 | void Event::powerOn() |
| 72 | { |
| 73 | for (const auto& [type, trigger] : _triggers) |
| 74 | { |
| 75 | if (type == "poweron") |
| 76 | { |
| 77 | trigger(getName(), _manager, _groups, _actions); |
| 78 | } |
| 79 | } |
| 80 | } |
| 81 | |
| 82 | void Event::powerOff() |
| 83 | { |
| 84 | for (const auto& [type, trigger] : _triggers) |
| 85 | { |
| 86 | if (type == "poweroff") |
| 87 | { |
| 88 | trigger(getName(), _manager, _groups, _actions); |
| 89 | } |
Matthew Barth | 54b5a24 | 2021-05-21 11:02:52 -0500 | [diff] [blame] | 90 | } |
| 91 | } |
| 92 | |
Matthew Barth | 3695ac3 | 2021-10-06 14:55:30 -0500 | [diff] [blame] | 93 | std::map<configKey, std::unique_ptr<Group>>& |
| 94 | Event::getAllGroups(bool loadGroups) |
Matthew Barth | c8bde4a | 2021-05-19 15:34:49 -0500 | [diff] [blame] | 95 | { |
Matthew Barth | 3695ac3 | 2021-10-06 14:55:30 -0500 | [diff] [blame] | 96 | if (allGroups.empty() && loadGroups) |
| 97 | { |
| 98 | allGroups = Manager::getConfig<Group>(true); |
| 99 | } |
| 100 | |
| 101 | return allGroups; |
Matthew Barth | c8bde4a | 2021-05-19 15:34:49 -0500 | [diff] [blame] | 102 | } |
| 103 | |
Matthew Barth | 46b3448 | 2021-04-06 11:27:23 -0500 | [diff] [blame] | 104 | void Event::configGroup(Group& group, const json& jsonObj) |
| 105 | { |
| 106 | if (!jsonObj.contains("interface") || !jsonObj.contains("property") || |
| 107 | !jsonObj["property"].contains("name")) |
| 108 | { |
| 109 | log<level::ERR>("Missing required group attribute", |
| 110 | entry("JSON=%s", jsonObj.dump().c_str())); |
| 111 | throw std::runtime_error("Missing required group attribute"); |
| 112 | } |
| 113 | |
| 114 | // Get the group members' interface |
| 115 | auto intf = jsonObj["interface"].get<std::string>(); |
| 116 | group.setInterface(intf); |
| 117 | |
| 118 | // Get the group members' property name |
| 119 | auto prop = jsonObj["property"]["name"].get<std::string>(); |
| 120 | group.setProperty(prop); |
| 121 | |
| 122 | // Get the group members' data type |
| 123 | if (jsonObj["property"].contains("type")) |
| 124 | { |
| 125 | std::optional<std::string> type = |
| 126 | jsonObj["property"]["type"].get<std::string>(); |
| 127 | group.setType(type); |
| 128 | } |
| 129 | |
| 130 | // Get the group members' expected value |
| 131 | if (jsonObj["property"].contains("value")) |
| 132 | { |
| 133 | std::optional<PropertyVariantType> value = |
| 134 | getJsonValue(jsonObj["property"]["value"]); |
| 135 | group.setValue(value); |
| 136 | } |
| 137 | } |
| 138 | |
Matthew Barth | e386fbb | 2021-06-30 14:33:55 -0500 | [diff] [blame] | 139 | void Event::setGroups(const json& jsonObj, |
| 140 | const std::vector<std::string>& profiles, |
| 141 | std::vector<Group>& groups) |
Matthew Barth | 3174e72 | 2020-09-15 15:13:40 -0500 | [diff] [blame] | 142 | { |
Matthew Barth | e386fbb | 2021-06-30 14:33:55 -0500 | [diff] [blame] | 143 | if (jsonObj.contains("groups")) |
Matthew Barth | 3174e72 | 2020-09-15 15:13:40 -0500 | [diff] [blame] | 144 | { |
Matthew Barth | 3695ac3 | 2021-10-06 14:55:30 -0500 | [diff] [blame] | 145 | auto& availGroups = getAllGroups(); |
Matthew Barth | e386fbb | 2021-06-30 14:33:55 -0500 | [diff] [blame] | 146 | for (const auto& jsonGrp : jsonObj["groups"]) |
Matthew Barth | 3174e72 | 2020-09-15 15:13:40 -0500 | [diff] [blame] | 147 | { |
Matthew Barth | e386fbb | 2021-06-30 14:33:55 -0500 | [diff] [blame] | 148 | if (!jsonGrp.contains("name")) |
| 149 | { |
Patrick Williams | fbf4703 | 2023-07-17 12:27:34 -0500 | [diff] [blame] | 150 | auto msg = std::format("Missing required group name attribute"); |
Matthew Barth | e386fbb | 2021-06-30 14:33:55 -0500 | [diff] [blame] | 151 | log<level::ERR>(msg.c_str(), |
| 152 | entry("JSON=%s", jsonGrp.dump().c_str())); |
| 153 | throw std::runtime_error(msg.c_str()); |
| 154 | } |
Matthew Barth | 12bae96 | 2021-01-15 16:18:11 -0600 | [diff] [blame] | 155 | |
Matthew Barth | e386fbb | 2021-06-30 14:33:55 -0500 | [diff] [blame] | 156 | configKey eventProfile = |
| 157 | std::make_pair(jsonGrp["name"].get<std::string>(), profiles); |
| 158 | auto grpEntry = std::find_if(availGroups.begin(), availGroups.end(), |
| 159 | [&eventProfile](const auto& grp) { |
Patrick Williams | 61b7329 | 2023-05-10 07:50:12 -0500 | [diff] [blame] | 160 | return Manager::inConfig(grp.first, eventProfile); |
| 161 | }); |
Matthew Barth | e386fbb | 2021-06-30 14:33:55 -0500 | [diff] [blame] | 162 | if (grpEntry != availGroups.end()) |
| 163 | { |
| 164 | auto group = Group(*grpEntry->second); |
| 165 | configGroup(group, jsonGrp); |
| 166 | groups.emplace_back(group); |
| 167 | } |
Matthew Barth | 12bae96 | 2021-01-15 16:18:11 -0600 | [diff] [blame] | 168 | } |
Matthew Barth | e557860 | 2021-03-30 12:53:24 -0500 | [diff] [blame] | 169 | } |
Matthew Barth | 3174e72 | 2020-09-15 15:13:40 -0500 | [diff] [blame] | 170 | } |
| 171 | |
Matthew Barth | c8bde4a | 2021-05-19 15:34:49 -0500 | [diff] [blame] | 172 | void Event::setActions(const json& jsonObj) |
Matthew Barth | 3174e72 | 2020-09-15 15:13:40 -0500 | [diff] [blame] | 173 | { |
Matthew Barth | 46b3448 | 2021-04-06 11:27:23 -0500 | [diff] [blame] | 174 | for (const auto& jsonAct : jsonObj["actions"]) |
Matthew Barth | 3174e72 | 2020-09-15 15:13:40 -0500 | [diff] [blame] | 175 | { |
Matthew Barth | 46b3448 | 2021-04-06 11:27:23 -0500 | [diff] [blame] | 176 | if (!jsonAct.contains("name")) |
Matthew Barth | 3174e72 | 2020-09-15 15:13:40 -0500 | [diff] [blame] | 177 | { |
| 178 | log<level::ERR>("Missing required event action name", |
Matthew Barth | 46b3448 | 2021-04-06 11:27:23 -0500 | [diff] [blame] | 179 | entry("JSON=%s", jsonAct.dump().c_str())); |
Matthew Barth | 3174e72 | 2020-09-15 15:13:40 -0500 | [diff] [blame] | 180 | throw std::runtime_error("Missing required event action name"); |
| 181 | } |
Matthew Barth | 46b3448 | 2021-04-06 11:27:23 -0500 | [diff] [blame] | 182 | |
Matthew Barth | 46b3448 | 2021-04-06 11:27:23 -0500 | [diff] [blame] | 183 | // Determine list of zones action should be run against |
| 184 | std::vector<std::reference_wrapper<Zone>> actionZones; |
Matthew Barth | a8ea091 | 2021-05-03 14:33:52 -0500 | [diff] [blame] | 185 | if (!jsonAct.contains("zones")) |
Matthew Barth | 46b3448 | 2021-04-06 11:27:23 -0500 | [diff] [blame] | 186 | { |
| 187 | // No zones configured on the action results in the action running |
| 188 | // against all zones matching the event's active profiles |
| 189 | for (const auto& zone : _zones) |
| 190 | { |
Patrick Williams | 61b7329 | 2023-05-10 07:50:12 -0500 | [diff] [blame] | 191 | configKey eventProfile = std::make_pair(zone.second->getName(), |
| 192 | _profiles); |
Matthew Barth | 46b3448 | 2021-04-06 11:27:23 -0500 | [diff] [blame] | 193 | auto zoneEntry = std::find_if(_zones.begin(), _zones.end(), |
| 194 | [&eventProfile](const auto& z) { |
Patrick Williams | 61b7329 | 2023-05-10 07:50:12 -0500 | [diff] [blame] | 195 | return Manager::inConfig(z.first, eventProfile); |
| 196 | }); |
Matthew Barth | 46b3448 | 2021-04-06 11:27:23 -0500 | [diff] [blame] | 197 | if (zoneEntry != _zones.end()) |
| 198 | { |
| 199 | actionZones.emplace_back(*zoneEntry->second); |
| 200 | } |
| 201 | } |
| 202 | } |
| 203 | else |
| 204 | { |
| 205 | // Zones configured on the action result in the action only running |
| 206 | // against those zones if they match the event's active profiles |
Matthew Barth | a8ea091 | 2021-05-03 14:33:52 -0500 | [diff] [blame] | 207 | for (const auto& jsonZone : jsonAct["zones"]) |
Matthew Barth | 46b3448 | 2021-04-06 11:27:23 -0500 | [diff] [blame] | 208 | { |
| 209 | configKey eventProfile = |
| 210 | std::make_pair(jsonZone.get<std::string>(), _profiles); |
| 211 | auto zoneEntry = std::find_if(_zones.begin(), _zones.end(), |
| 212 | [&eventProfile](const auto& z) { |
Patrick Williams | 61b7329 | 2023-05-10 07:50:12 -0500 | [diff] [blame] | 213 | return Manager::inConfig(z.first, eventProfile); |
| 214 | }); |
Matthew Barth | 46b3448 | 2021-04-06 11:27:23 -0500 | [diff] [blame] | 215 | if (zoneEntry != _zones.end()) |
| 216 | { |
| 217 | actionZones.emplace_back(*zoneEntry->second); |
| 218 | } |
| 219 | } |
| 220 | } |
| 221 | if (actionZones.empty()) |
| 222 | { |
| 223 | log<level::DEBUG>( |
Patrick Williams | fbf4703 | 2023-07-17 12:27:34 -0500 | [diff] [blame] | 224 | std::format("No zones configured for event {}'s action {} " |
Matthew Barth | 46b3448 | 2021-04-06 11:27:23 -0500 | [diff] [blame] | 225 | "based on the active profile(s)", |
| 226 | getName(), jsonAct["name"].get<std::string>()) |
| 227 | .c_str()); |
| 228 | } |
| 229 | |
Matthew Barth | 5fb5268 | 2021-09-29 13:57:02 -0500 | [diff] [blame] | 230 | // Action specific groups, if any given, will override the use of event |
| 231 | // groups in the action(s) |
| 232 | std::vector<Group> actionGroups; |
| 233 | setGroups(jsonAct, _profiles, actionGroups); |
| 234 | if (!actionGroups.empty()) |
Matthew Barth | 776ca56 | 2021-03-31 09:50:58 -0500 | [diff] [blame] | 235 | { |
Matthew Barth | 5fb5268 | 2021-09-29 13:57:02 -0500 | [diff] [blame] | 236 | // Create the action for the event using the action's groups |
| 237 | auto actObj = ActionFactory::getAction( |
| 238 | jsonAct["name"].get<std::string>(), jsonAct, |
| 239 | std::move(actionGroups), std::move(actionZones)); |
| 240 | if (actObj) |
| 241 | { |
Matt Spinler | e6fc210 | 2022-04-07 14:31:29 -0500 | [diff] [blame] | 242 | actObj->setEventName(_name); |
Matthew Barth | 5fb5268 | 2021-09-29 13:57:02 -0500 | [diff] [blame] | 243 | _actions.emplace_back(std::move(actObj)); |
| 244 | } |
| 245 | } |
| 246 | else |
| 247 | { |
| 248 | // Create the action for the event using the event's groups |
| 249 | auto actObj = ActionFactory::getAction( |
| 250 | jsonAct["name"].get<std::string>(), jsonAct, _groups, |
| 251 | std::move(actionZones)); |
| 252 | if (actObj) |
| 253 | { |
Matt Spinler | e6fc210 | 2022-04-07 14:31:29 -0500 | [diff] [blame] | 254 | actObj->setEventName(_name); |
Matthew Barth | 5fb5268 | 2021-09-29 13:57:02 -0500 | [diff] [blame] | 255 | _actions.emplace_back(std::move(actObj)); |
| 256 | } |
| 257 | } |
| 258 | |
| 259 | if (actionGroups.empty() && _groups.empty()) |
| 260 | { |
| 261 | log<level::DEBUG>( |
Patrick Williams | fbf4703 | 2023-07-17 12:27:34 -0500 | [diff] [blame] | 262 | std::format("No groups configured for event {}'s action {} " |
Matthew Barth | 5fb5268 | 2021-09-29 13:57:02 -0500 | [diff] [blame] | 263 | "based on the active profile(s)", |
| 264 | getName(), jsonAct["name"].get<std::string>()) |
| 265 | .c_str()); |
Matthew Barth | 776ca56 | 2021-03-31 09:50:58 -0500 | [diff] [blame] | 266 | } |
Matthew Barth | 3174e72 | 2020-09-15 15:13:40 -0500 | [diff] [blame] | 267 | } |
| 268 | } |
| 269 | |
Matthew Barth | 9f1632e | 2021-03-31 15:51:50 -0500 | [diff] [blame] | 270 | void Event::setTriggers(const json& jsonObj) |
| 271 | { |
| 272 | if (!jsonObj.contains("triggers")) |
| 273 | { |
| 274 | log<level::ERR>("Missing required event triggers list", |
| 275 | entry("JSON=%s", jsonObj.dump().c_str())); |
| 276 | throw std::runtime_error("Missing required event triggers list"); |
| 277 | } |
Matthew Barth | 0620be7 | 2021-04-14 13:31:12 -0500 | [diff] [blame] | 278 | for (const auto& jsonTrig : jsonObj["triggers"]) |
| 279 | { |
| 280 | if (!jsonTrig.contains("class")) |
| 281 | { |
| 282 | log<level::ERR>("Missing required event trigger class", |
| 283 | entry("JSON=%s", jsonTrig.dump().c_str())); |
| 284 | throw std::runtime_error("Missing required event trigger class"); |
| 285 | } |
| 286 | // The class of trigger used to run the event actions |
| 287 | auto tClass = jsonTrig["class"].get<std::string>(); |
| 288 | std::transform(tClass.begin(), tClass.end(), tClass.begin(), tolower); |
| 289 | auto trigFunc = trigger::triggers.find(tClass); |
| 290 | if (trigFunc != trigger::triggers.end()) |
| 291 | { |
Matthew Barth | 54b5a24 | 2021-05-21 11:02:52 -0500 | [diff] [blame] | 292 | _triggers.emplace_back( |
Matt Spinler | d1f97f4 | 2021-10-29 16:19:24 -0500 | [diff] [blame] | 293 | trigFunc->first, |
Matthew Barth | b6ebac8 | 2021-05-21 11:15:33 -0500 | [diff] [blame] | 294 | trigFunc->second(jsonTrig, getName(), _actions)); |
Matthew Barth | 0620be7 | 2021-04-14 13:31:12 -0500 | [diff] [blame] | 295 | } |
| 296 | else |
| 297 | { |
| 298 | // Construct list of available triggers |
| 299 | auto availTrigs = std::accumulate( |
| 300 | std::next(trigger::triggers.begin()), trigger::triggers.end(), |
| 301 | trigger::triggers.begin()->first, [](auto list, auto trig) { |
Patrick Williams | 5e15c3b | 2023-10-20 11:18:11 -0500 | [diff] [blame] | 302 | return std::move(list) + ", " + trig.first; |
| 303 | }); |
Matthew Barth | 0620be7 | 2021-04-14 13:31:12 -0500 | [diff] [blame] | 304 | log<level::ERR>( |
Patrick Williams | fbf4703 | 2023-07-17 12:27:34 -0500 | [diff] [blame] | 305 | std::format("Trigger '{}' is not recognized", tClass).c_str(), |
Matthew Barth | 0620be7 | 2021-04-14 13:31:12 -0500 | [diff] [blame] | 306 | entry("AVAILABLE_TRIGGERS=%s", availTrigs.c_str())); |
| 307 | throw std::runtime_error("Unsupported trigger class name given"); |
| 308 | } |
| 309 | } |
Matthew Barth | 9f1632e | 2021-03-31 15:51:50 -0500 | [diff] [blame] | 310 | } |
| 311 | |
Matt Spinler | c3eb7b3 | 2022-04-25 15:44:16 -0500 | [diff] [blame] | 312 | json Event::dump() const |
| 313 | { |
| 314 | json actionData; |
| 315 | std::for_each(_actions.begin(), _actions.end(), |
| 316 | [&actionData](const auto& action) { |
Patrick Williams | 61b7329 | 2023-05-10 07:50:12 -0500 | [diff] [blame] | 317 | actionData[action->getUniqueName()] = action->dump(); |
| 318 | }); |
Matt Spinler | c3eb7b3 | 2022-04-25 15:44:16 -0500 | [diff] [blame] | 319 | |
| 320 | std::vector<std::string> groupData; |
| 321 | std::for_each(_groups.begin(), _groups.end(), |
| 322 | [&groupData](const auto& group) { |
Patrick Williams | 61b7329 | 2023-05-10 07:50:12 -0500 | [diff] [blame] | 323 | groupData.push_back(group.getName()); |
| 324 | }); |
Matt Spinler | c3eb7b3 | 2022-04-25 15:44:16 -0500 | [diff] [blame] | 325 | |
| 326 | json eventData; |
| 327 | eventData["groups"] = groupData; |
| 328 | eventData["actions"] = actionData; |
| 329 | |
| 330 | return eventData; |
| 331 | } |
| 332 | |
Matthew Barth | 3174e72 | 2020-09-15 15:13:40 -0500 | [diff] [blame] | 333 | } // namespace phosphor::fan::control::json |