1 /* Icinga 2 | (c) 2012 Icinga GmbH | GPLv2+ */
3 #include "icinga/customvarobject.hpp"
4 #include "icinga/notificationresult.hpp"
5 #include "base/array.hpp"
6 #impl_include "icinga/notificationcommand.hpp"
7 #impl_include "icinga/service.hpp"
15 class NotificationNameComposer : public NameComposer
18 virtual String MakeName(const String& shortName, const Object::Ptr& context) const;
19 virtual Dictionary::Ptr ParseName(const String& name) const;
24 class Notification : CustomVarObject < NotificationNameComposer
29 [config, protected, required, navigation] name(NotificationCommand) command (CommandRaw) {
31 return NotificationCommand::GetByName(GetCommandRaw());
34 [config] double interval {
35 default {{{ return 1800; }}}
37 [config, navigation] name(TimePeriod) period (PeriodRaw) {
39 return TimePeriod::GetByName(GetPeriodRaw());
42 [config, protected] array(name(User)) users (UsersRaw);
43 [config, protected] array(name(UserGroup)) user_groups (UserGroupsRaw);
44 [config] Dictionary::Ptr times;
45 [config] array(Value) types;
46 [no_user_view, no_user_modify] int type_filter_real (TypeFilter);
47 [config] array(Value) states;
48 [no_user_view, no_user_modify] int state_filter_real (StateFilter);
49 [config, protected, required, navigation(host)] name(Host) host_name {
51 return Host::GetByName(GetHostName());
54 [config, protected, navigation(service)] String service_name {
56 if (!oldValue.IsEmpty()) {
57 Service::Ptr service = Service::GetByNamePair(GetHostName(), oldValue);
58 DependencyGraph::RemoveDependency(this, service.get());
61 if (!newValue.IsEmpty()) {
62 Service::Ptr service = Service::GetByNamePair(GetHostName(), newValue);
63 DependencyGraph::AddDependency(this, service.get());
67 if (GetServiceName().IsEmpty())
70 Host::Ptr host = Host::GetByName(GetHostName());
71 return host->GetServiceByShortName(GetServiceName());
75 [state, no_user_modify] Array::Ptr notified_problem_users {
76 default {{{ return new Array(); }}}
79 [state, no_user_modify] bool no_more_notifications {
80 default {{{ return false; }}}
83 [state] Timestamp last_notification;
84 [state] Timestamp next_notification;
85 [state] int notification_number;
86 [state] Timestamp last_problem_notification;
87 [state] NotificationResult::Ptr last_notification_result;
89 [config, navigation] name(Endpoint) command_endpoint (CommandEndpointRaw) {
91 return Endpoint::GetByName(GetCommandEndpointRaw());
96 validator Notification {