2026-01-27 09:06:40 -05:00
|
|
|
// SPDX-FileCopyrightText: 2012 Icinga GmbH <https://icinga.com>
|
|
|
|
|
// SPDX-License-Identifier: GPL-2.0-or-later
|
2014-10-17 13:44:31 -04:00
|
|
|
|
2015-08-20 11:18:48 -04:00
|
|
|
#include "base/configobject.hpp"
|
|
|
|
|
#include "base/utility.hpp"
|
|
|
|
|
#impl_include "icinga/service.hpp"
|
|
|
|
|
|
2015-08-04 08:47:44 -04:00
|
|
|
library icinga;
|
|
|
|
|
|
2013-11-09 15:19:52 -05:00
|
|
|
namespace icinga
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
code {{{
|
|
|
|
|
/**
|
|
|
|
|
* The type of a service comment.
|
|
|
|
|
*
|
|
|
|
|
* @ingroup icinga
|
|
|
|
|
*/
|
|
|
|
|
enum CommentType
|
|
|
|
|
{
|
|
|
|
|
CommentUser = 1,
|
|
|
|
|
CommentAcknowledgement = 4
|
|
|
|
|
};
|
2015-08-20 11:18:48 -04:00
|
|
|
|
2017-12-31 01:22:16 -05:00
|
|
|
class CommentNameComposer : public NameComposer
|
2015-08-20 11:18:48 -04:00
|
|
|
{
|
|
|
|
|
public:
|
2025-05-05 03:12:41 -04:00
|
|
|
virtual String MakeName(const String& shortName, const Object::Ptr& context) const override;
|
|
|
|
|
virtual Dictionary::Ptr ParseName(const String& name) const override;
|
2015-08-20 11:18:48 -04:00
|
|
|
};
|
2013-11-09 15:19:52 -05:00
|
|
|
}}}
|
|
|
|
|
|
2015-08-20 11:18:48 -04:00
|
|
|
class Comment : ConfigObject < CommentNameComposer
|
2013-11-09 15:19:52 -05:00
|
|
|
{
|
2015-08-20 11:18:48 -04:00
|
|
|
load_after Host;
|
|
|
|
|
load_after Service;
|
|
|
|
|
|
2022-06-20 09:25:40 -04:00
|
|
|
[config, no_user_modify, protected, required, navigation(host)] name(Host) host_name {
|
2015-08-20 11:18:48 -04:00
|
|
|
navigate {{{
|
|
|
|
|
return Host::GetByName(GetHostName());
|
|
|
|
|
}}}
|
|
|
|
|
};
|
2022-06-20 09:25:40 -04:00
|
|
|
[config, no_user_modify, protected, navigation(service)] String service_name {
|
2015-08-20 11:18:48 -04:00
|
|
|
track {{{
|
|
|
|
|
if (!oldValue.IsEmpty()) {
|
|
|
|
|
Service::Ptr service = Service::GetByNamePair(GetHostName(), oldValue);
|
|
|
|
|
DependencyGraph::RemoveDependency(this, service.get());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!newValue.IsEmpty()) {
|
|
|
|
|
Service::Ptr service = Service::GetByNamePair(GetHostName(), newValue);
|
2016-05-09 07:48:30 -04:00
|
|
|
DependencyGraph::AddDependency(this, service.get());
|
2015-08-20 11:18:48 -04:00
|
|
|
}
|
|
|
|
|
}}}
|
|
|
|
|
navigate {{{
|
2026-01-16 12:14:46 -05:00
|
|
|
if (!GetServiceName().IsEmpty()) {
|
|
|
|
|
Host::Ptr host = Host::GetByName(GetHostName());
|
|
|
|
|
if (host)
|
|
|
|
|
return host->GetServiceByShortName(GetServiceName());
|
|
|
|
|
}
|
2015-08-20 11:18:48 -04:00
|
|
|
|
2026-01-16 12:14:46 -05:00
|
|
|
return nullptr;
|
2015-08-20 11:18:48 -04:00
|
|
|
}}}
|
|
|
|
|
};
|
|
|
|
|
|
2016-06-21 05:29:12 -04:00
|
|
|
[config] Timestamp entry_time {
|
2015-08-20 11:18:48 -04:00
|
|
|
default {{{ return Utility::GetTime(); }}}
|
|
|
|
|
};
|
|
|
|
|
[config, enum] CommentType entry_type {
|
|
|
|
|
default {{{ return CommentUser; }}}
|
|
|
|
|
};
|
2022-03-21 10:41:22 -04:00
|
|
|
[config, no_user_view, no_user_modify] bool sticky;
|
2015-08-20 11:18:48 -04:00
|
|
|
[config, required] String author;
|
|
|
|
|
[config, required] String text;
|
2017-01-25 15:21:22 -05:00
|
|
|
[config] bool persistent;
|
2016-06-21 05:29:12 -04:00
|
|
|
[config] Timestamp expire_time;
|
2016-03-23 09:03:44 -04:00
|
|
|
[state] int legacy_id;
|
2019-11-21 09:53:40 -05:00
|
|
|
|
|
|
|
|
[no_user_view, no_user_modify] String removed_by;
|
2021-12-13 10:37:45 -05:00
|
|
|
[no_user_view, no_user_modify] Timestamp remove_time;
|
2013-11-09 15:19:52 -05:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
}
|