]> granicus.if.org Git - icinga2/commitdiff
Added missing files.
authorGunnar Beutner <gunnar@beutner.name>
Sun, 1 Jul 2012 11:08:07 +0000 (13:08 +0200)
committerGunnar Beutner <gunnar@beutner.name>
Sun, 1 Jul 2012 11:08:07 +0000 (13:08 +0200)
icinga/hostgroup.cpp [new file with mode: 0644]
icinga/hostgroup.h [new file with mode: 0644]
icinga/servicegroup.cpp [new file with mode: 0644]
icinga/servicegroup.h [new file with mode: 0644]

diff --git a/icinga/hostgroup.cpp b/icinga/hostgroup.cpp
new file mode 100644 (file)
index 0000000..903dfdd
--- /dev/null
@@ -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 (file)
index 0000000..8c98626
--- /dev/null
@@ -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 (file)
index 0000000..24496af
--- /dev/null
@@ -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 (file)
index 0000000..7c3edf8
--- /dev/null
@@ -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 */