1 /* Icinga 2 | (c) 2012 Icinga GmbH | GPLv2+ */
3 #include "icinga/objectutils.hpp"
4 #include "icinga/host.hpp"
5 #include "icinga/user.hpp"
6 #include "icinga/checkcommand.hpp"
7 #include "icinga/eventcommand.hpp"
8 #include "icinga/notificationcommand.hpp"
9 #include "icinga/hostgroup.hpp"
10 #include "icinga/servicegroup.hpp"
11 #include "icinga/usergroup.hpp"
13 using namespace icinga;
15 REGISTER_FUNCTION(Icinga, get_host, &Host::GetByName, "name");
16 REGISTER_FUNCTION(Icinga, get_service, &ObjectUtils::GetService, "host:name");
17 REGISTER_FUNCTION(Icinga, get_services, &ObjectUtils::GetServices, "host");
18 REGISTER_FUNCTION(Icinga, get_user, &User::GetByName, "name");
19 REGISTER_FUNCTION(Icinga, get_check_command, &CheckCommand::GetByName, "name");
20 REGISTER_FUNCTION(Icinga, get_event_command, &EventCommand::GetByName, "name");
21 REGISTER_FUNCTION(Icinga, get_notification_command, &NotificationCommand::GetByName, "name");
22 REGISTER_FUNCTION(Icinga, get_host_group, &HostGroup::GetByName, "name");
23 REGISTER_FUNCTION(Icinga, get_service_group, &ServiceGroup::GetByName, "name");
24 REGISTER_FUNCTION(Icinga, get_user_group, &UserGroup::GetByName, "name");
25 REGISTER_FUNCTION(Icinga, get_time_period, &TimePeriod::GetByName, "name");
27 Service::Ptr ObjectUtils::GetService(const Value& host, const String& name)
31 if (host.IsObjectType<Host>())
34 hostObj = Host::GetByName(host);
39 return hostObj->GetServiceByShortName(name);
42 Array::Ptr ObjectUtils::GetServices(const Value& host)
46 if (host.IsObjectType<Host>())
49 hostObj = Host::GetByName(host);
54 return Array::FromVector(hostObj->GetServices());