1 /* Icinga 2 | (c) 2012 Icinga GmbH | GPLv2+ */
3 #include "icinga/customvarobject.hpp"
4 #impl_include "icinga/notificationcommand.hpp"
5 #impl_include "icinga/service.hpp"
13 class NotificationNameComposer : public NameComposer
16 virtual String MakeName(const String& shortName, const Object::Ptr& context) const;
17 virtual Dictionary::Ptr ParseName(const String& name) const;
21 class Notification : CustomVarObject < NotificationNameComposer
26 [config, protected, required, navigation] name(NotificationCommand) command (CommandRaw) {
28 return NotificationCommand::GetByName(GetCommandRaw());
31 [config] double interval {
32 default {{{ return 1800; }}}
34 [config, navigation] name(TimePeriod) period (PeriodRaw) {
36 return TimePeriod::GetByName(GetPeriodRaw());
39 [config, protected] array(name(User)) users (UsersRaw);
40 [config, protected] array(name(UserGroup)) user_groups (UserGroupsRaw);
41 [config] Dictionary::Ptr times;
42 [config] array(Value) types;
43 [no_user_view, no_user_modify] int type_filter_real (TypeFilter);
44 [config] array(Value) states;
45 [no_user_view, no_user_modify] int state_filter_real (StateFilter);
46 [config, protected, required, navigation(host)] name(Host) host_name {
48 return Host::GetByName(GetHostName());
51 [config, protected, navigation(service)] String service_name {
53 if (!oldValue.IsEmpty()) {
54 Service::Ptr service = Service::GetByNamePair(GetHostName(), oldValue);
55 DependencyGraph::RemoveDependency(this, service.get());
58 if (!newValue.IsEmpty()) {
59 Service::Ptr service = Service::GetByNamePair(GetHostName(), newValue);
60 DependencyGraph::AddDependency(this, service.get());
64 if (GetServiceName().IsEmpty())
67 Host::Ptr host = Host::GetByName(GetHostName());
68 return host->GetServiceByShortName(GetServiceName());
72 [state, no_user_modify] Array::Ptr notified_problem_users {
73 default {{{ return new Array(); }}}
76 [state, no_user_modify] bool no_more_notifications {
77 default {{{ return false; }}}
80 [state] Timestamp last_notification;
81 [state] Timestamp next_notification;
82 [state] int notification_number;
83 [state] Timestamp last_problem_notification;
85 [config, navigation] name(Endpoint) command_endpoint (CommandEndpointRaw) {
87 return Endpoint::GetByName(GetCommandEndpointRaw());
92 validator Notification {