1 /******************************************************************************
3 * Copyright (C) 2012-2015 Icinga Development Team (http://www.icinga.org) *
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. *
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. *
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 ******************************************************************************/
23 #include "remote/httpclientconnection.hpp"
24 #include "base/value.hpp"
30 struct ApiFieldAttributes
47 ApiFieldAttributes FieldAttributes;
49 intrusive_ptr<ApiType> Type;
52 class ApiType : public Object
55 DECLARE_PTR_TYPEDEFS(ApiType);
62 std::map<String, ApiField> Fields;
63 std::vector<String> PrototypeKeys;
66 struct ApiObjectReference
73 struct ApiObject : public Object
76 DECLARE_PTR_TYPEDEFS(ApiObject);
78 std::map<String, Value> Attrs;
79 std::vector<ApiObjectReference> UsedBy;
82 class ApiClient : public Object
85 DECLARE_PTR_TYPEDEFS(ApiClient);
87 ApiClient(const String& host, const String& port,
88 const String& user, const String& password);
90 typedef boost::function<void(const std::vector<ApiType::Ptr>&)> TypesCompletionCallback;
91 void GetTypes(const TypesCompletionCallback& callback) const;
93 typedef boost::function<void(const std::vector<ApiObject::Ptr>&)> ObjectsCompletionCallback;
94 void GetObjects(const String& pluralType, const ObjectsCompletionCallback& callback,
95 const std::vector<String>& names = std::vector<String>(),
96 const std::vector<String>& attrs = std::vector<String>()) const;
99 HttpClientConnection::Ptr m_Connection;
103 static void TypesHttpCompletionCallback(HttpRequest& request,
104 HttpResponse& response, const TypesCompletionCallback& callback);
105 static void ObjectsHttpCompletionCallback(HttpRequest& request,
106 HttpResponse& response, const ObjectsCompletionCallback& callback);