diff --git a/icinga/hostgroup.cpp b/icinga/hostgroup.cpp new file mode 100644 index 000000000..903dfdd4e --- /dev/null +++ b/icinga/hostgroup.cpp @@ -0,0 +1,43 @@ +#include "i2-icinga.h" + +using namespace icinga; + +string HostGroup::GetAlias(void) const +{ + string value; + + if (GetConfigObject()->GetProperty("alias", &value)) + return value; + + return GetName(); +} + +string HostGroup::GetNotesUrl(void) const +{ + string value; + GetConfigObject()->GetProperty("notes_url", &value); + return value; +} + +string HostGroup::GetActionUrl(void) const +{ + string value; + GetConfigObject()->GetProperty("action_url", &value); + return value; +} + +bool HostGroup::Exists(const string& name) +{ + return (ConfigObject::GetObject("hostgroup", name)); +} + +HostGroup HostGroup::GetByName(const string& name) +{ + ConfigObject::Ptr configObject = ConfigObject::GetObject("hostgroup", name); + + if (!configObject) + throw invalid_argument("HostGroup '" + name + "' does not exist."); + + return HostGroup(configObject); +} + diff --git a/icinga/hostgroup.h b/icinga/hostgroup.h new file mode 100644 index 000000000..8c98626c6 --- /dev/null +++ b/icinga/hostgroup.h @@ -0,0 +1,24 @@ +#ifndef HOSTGROUP_H +#define HOSTGROUP_H + +namespace icinga +{ + +class I2_ICINGA_API HostGroup : public ConfigObjectAdapter +{ +public: + HostGroup(const ConfigObject::Ptr& configObject) + : ConfigObjectAdapter(configObject) + { } + + static bool Exists(const string& name); + static HostGroup GetByName(const string& name); + + string GetAlias(void) const; + string GetNotesUrl(void) const; + string GetActionUrl(void) const; +}; + +} + +#endif /* HOSTGROUP_H */ diff --git a/icinga/servicegroup.cpp b/icinga/servicegroup.cpp new file mode 100644 index 000000000..24496af4b --- /dev/null +++ b/icinga/servicegroup.cpp @@ -0,0 +1,43 @@ +#include "i2-icinga.h" + +using namespace icinga; + +string ServiceGroup::GetAlias(void) const +{ + string value; + + if (GetConfigObject()->GetProperty("alias", &value)) + return value; + + return GetName(); +} + +string ServiceGroup::GetNotesUrl(void) const +{ + string value; + GetConfigObject()->GetProperty("notes_url", &value); + return value; +} + +string ServiceGroup::GetActionUrl(void) const +{ + string value; + GetConfigObject()->GetProperty("action_url", &value); + return value; +} + +bool ServiceGroup::Exists(const string& name) +{ + return (ConfigObject::GetObject("hostgroup", name)); +} + +ServiceGroup ServiceGroup::GetByName(const string& name) +{ + ConfigObject::Ptr configObject = ConfigObject::GetObject("hostgroup", name); + + if (!configObject) + throw invalid_argument("ServiceGroup '" + name + "' does not exist."); + + return ServiceGroup(configObject); +} + diff --git a/icinga/servicegroup.h b/icinga/servicegroup.h new file mode 100644 index 000000000..7c3edf850 --- /dev/null +++ b/icinga/servicegroup.h @@ -0,0 +1,24 @@ +#ifndef SERVICEGROUP_H +#define SERVICEGROUP_H + +namespace icinga +{ + +class I2_ICINGA_API ServiceGroup : public ConfigObjectAdapter +{ +public: + ServiceGroup(const ConfigObject::Ptr& configObject) + : ConfigObjectAdapter(configObject) + { } + + static bool Exists(const string& name); + static ServiceGroup GetByName(const string& name); + + string GetAlias(void) const; + string GetNotesUrl(void) const; + string GetActionUrl(void) const; +}; + +} + +#endif /* SERVICEGROUP_H */