]> granicus.if.org Git - icinga2/blob - lib/icinga/compatutility.h
compatutility: Add contact(group) getters.
[icinga2] / lib / icinga / compatutility.h
1 /******************************************************************************
2  * Icinga 2                                                                   *
3  * Copyright (C) 2012-2013 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 #ifndef COMPATUTILITY_H
21 #define COMPATUTILITY_H
22
23 #include "icinga/i2-icinga.h"
24 #include "icinga/service.h"
25 #include "icinga/checkcommand.h"
26 #include "base/dictionary.h"
27 #include "base/dynamicobject.h"
28 #include <vector>
29
30 namespace icinga
31 {
32
33 /**
34  * @ingroup icinga
35  */
36 enum CompatObjectType
37 {
38         CompatTypeService,
39         CompatTypeHost
40 };
41
42 /**
43  * Compatibility utility functions.
44  *
45  * @ingroup icinga
46  */
47 class I2_ICINGA_API CompatUtility
48 {
49 public:
50         static Dictionary::Ptr GetHostConfigAttributes(const Host::Ptr& host);
51
52         static Dictionary::Ptr GetServiceStatusAttributes(const Service::Ptr& service, CompatObjectType type);
53         static Dictionary::Ptr GetServiceConfigAttributes(const Service::Ptr& service);
54
55         static Dictionary::Ptr GetCommandConfigAttributes(const Command::Ptr& command);
56
57         static Dictionary::Ptr GetCustomVariableConfig(const DynamicObject::Ptr& object);
58
59         static Value GetServiceNotificationUsers(const Service::Ptr& service);
60         static Value GetServiceNotificationUserGroups(const Service::Ptr& service);
61
62         static Dictionary::Ptr GetCheckResultOutput(const Dictionary::Ptr& cr);
63         static String GetCheckResultPerfdata(const Dictionary::Ptr& cr);
64
65         static int MapNotificationReasonType(NotificationType type);
66         static int MapExternalCommandType(const String& name);
67
68         static String EscapeString(const String& str);
69
70 private:
71         CompatUtility(void);
72 };
73
74 }
75
76 #endif /* COMPATUTILITY_H */