blob: e5c6e3637466f35f2ca64b9a84f0bb11777aac09 [file] [log] [blame]
Tomáš Pecka6a2334b2022-07-12 13:57:54 +02001/*
2 * Copyright (C) 2022 CESNET, https://photonics.cesnet.cz/
3 *
4 * Written by Tomáš Pecka <tomas.pecka@fit.cvut.cz>
5 *
6 */
7#include "alarms.h"
8
9using namespace std::string_literals;
10
11namespace {
12const auto alarmRpc = "/sysrepo-ietf-alarms:create-or-update-alarm";
13}
14
15namespace velia::health {
16void createOrUpdateAlarm(sysrepo::Session session, const std::string& alarmId, const std::optional<std::string>& alarmTypeQualifier, const std::string& resource, const std::string& severity, const std::string& text)
17{
18 auto inputNode = session.getContext().newPath(alarmRpc, std::nullopt);
19
20 inputNode.newPath(alarmRpc + "/resource"s, resource);
21 inputNode.newPath(alarmRpc + "/alarm-type-id"s, alarmId);
22 inputNode.newPath(alarmRpc + "/alarm-type-qualifier"s, alarmTypeQualifier.value_or(""));
23 inputNode.newPath(alarmRpc + "/severity"s, severity);
24 inputNode.newPath(alarmRpc + "/alarm-text"s, text);
25
26 session.sendRPC(inputNode);
27}
28}