1 /******************************************************************************
3 * Copyright (C) 2012-2017 Icinga Development Team (https://www.icinga.com/) *
5 * This program is free software; you can redistribute it and/or *
6 * modify it under the terms of the GNU General Public License *
7 * as published by the Free Software Foundation; either version 2 *
8 * of the License, or (at your option) any later version. *
10 * This program is distributed in the hope that it will be useful, *
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
13 * GNU General Public License for more details. *
15 * You should have received a copy of the GNU General Public License *
16 * along with this program; if not, write to the Free Software Foundation *
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA. *
18 ******************************************************************************/
20 #include "icinga/customvarobject.hpp"
21 #impl_include "icinga/notificationcommand.hpp"
22 #impl_include "icinga/service.hpp"
30 class I2_ICINGA_API NotificationNameComposer : public NameComposer
33 virtual String MakeName(const String& shortName, const Object::Ptr& context) const;
34 virtual Dictionary::Ptr ParseName(const String& name) const;
38 class Notification : CustomVarObject < NotificationNameComposer
43 [config, protected, required, navigation] name(NotificationCommand) command (CommandRaw) {
45 return NotificationCommand::GetByName(GetCommandRaw());
48 [config] double interval {
49 default {{{ return 1800; }}}
51 [config, navigation] name(TimePeriod) period (PeriodRaw) {
53 return TimePeriod::GetByName(GetPeriodRaw());
56 [config, protected] array(name(User)) users (UsersRaw);
57 [config, protected] array(name(UserGroup)) user_groups (UserGroupsRaw);
58 [config] Dictionary::Ptr times;
59 [config] array(Value) types;
60 [no_user_view, no_user_modify] int type_filter_real (TypeFilter);
61 [config] array(Value) states;
62 [no_user_view, no_user_modify] int state_filter_real (StateFilter);
63 [config, protected, required, navigation(host)] name(Host) host_name {
65 return Host::GetByName(GetHostName());
68 [config, protected, navigation(service)] String service_name {
70 if (!oldValue.IsEmpty()) {
71 Service::Ptr service = Service::GetByNamePair(GetHostName(), oldValue);
72 DependencyGraph::RemoveDependency(this, service.get());
75 if (!newValue.IsEmpty()) {
76 Service::Ptr service = Service::GetByNamePair(GetHostName(), newValue);
77 DependencyGraph::AddDependency(this, service.get());
81 if (GetServiceName().IsEmpty())
84 Host::Ptr host = Host::GetByName(GetHostName());
85 return host->GetServiceByShortName(GetServiceName());
89 [state, no_user_modify] Array::Ptr notified_problem_users {
90 default {{{ return new Array(); }}}
93 [state, no_user_modify] bool no_more_notifications {
94 default {{{ return false; }}}
97 [state] Timestamp last_notification;
98 [state] Timestamp next_notification;
99 [state] int notification_number;
100 [state] Timestamp last_problem_notification;
102 [config, navigation] name(Endpoint) command_endpoint (CommandEndpointRaw) {
104 return Endpoint::GetByName(GetCommandEndpointRaw());
109 validator Notification {