]> granicus.if.org Git - icinga2/blob - lib/icinga/servicegroup.cpp
Refactored the libraries.
[icinga2] / lib / icinga / servicegroup.cpp
1 /******************************************************************************
2  * Icinga 2                                                                   *
3  * Copyright (C) 2012 Icinga Development Team (http://www.icinga.org/)        *
4  *                                                                            *
5  * This program is free software; you can redistribute it and/or              *
6  * modify it under the terms of the GNU General Public License                *
7  * as published by the Free Software Foundation; either version 2             *
8  * of the License, or (at your option) any later version.                     *
9  *                                                                            *
10  * This program is distributed in the hope that it will be useful,            *
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of             *
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the              *
13  * GNU General Public License for more details.                               *
14  *                                                                            *
15  * You should have received a copy of the GNU General Public License          *
16  * along with this program; if not, write to the Free Software Foundation     *
17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.             *
18  ******************************************************************************/
19
20 #include "i2-icinga.h"
21
22 using namespace icinga;
23
24 REGISTER_CLASS(ServiceGroup);
25
26 String ServiceGroup::GetAlias(void) const
27 {
28         String value = Get("alias");
29
30         if (!value.IsEmpty())
31                 return value;
32         else
33                 return GetName();
34 }
35
36 String ServiceGroup::GetNotesUrl(void) const
37 {
38         return Get("notes_url");
39 }
40
41 String ServiceGroup::GetActionUrl(void) const
42 {
43         return Get("action_url");
44 }
45
46 bool ServiceGroup::Exists(const String& name)
47 {
48         return (DynamicObject::GetObject("ServiceGroup", name));
49 }
50
51 ServiceGroup::Ptr ServiceGroup::GetByName(const String& name)
52 {
53         DynamicObject::Ptr configObject = DynamicObject::GetObject("ServiceGroup", name);
54
55         if (!configObject)
56                 throw_exception(invalid_argument("ServiceGroup '" + name + "' does not exist."));
57
58         return dynamic_pointer_cast<ServiceGroup>(configObject);
59 }
60