21 #include "cafNotNull.h" 22 #include "cafRpcClient.h" 23 #include "cafSession.h" 25 #include <boost/beast/core.hpp> 26 #include <boost/beast/http/status.hpp> 27 #include <boost/beast/http/verb.hpp> 42 namespace http = boost::beast::http;
54 RestClient(
const std::string& hostname,
int port = 50000 );
59 std::shared_ptr<caffa::ObjectHandle> document(
const std::string& documentId )
const override;
60 std::vector<std::shared_ptr<caffa::ObjectHandle>> documents()
const override;
61 std::string execute( caffa::not_null<const caffa::ObjectHandle*> selfObject,
62 const std::string& methodName,
63 const std::string& jsonArguments )
const override;
64 bool stopServer()
override;
65 void sendKeepAlive()
override;
66 bool isReady( caffa::Session::Type type )
const override;
68 void createSession( caffa::Session::Type type,
const std::string& username =
"",
const std::string& password =
"" )
override;
75 caffa::Session::Type checkSession()
const override;
76 void changeSession( caffa::Session::Type newType )
override;
77 void destroySession()
override;
78 const std::string& sessionUuid()
const override;
79 void startKeepAliveThread()
override;
81 std::shared_ptr<caffa::ObjectHandle> getChildObject(
const caffa::ObjectHandle* objectHandle,
82 const std::string& fieldName )
const override;
84 std::vector<std::shared_ptr<caffa::ObjectHandle>> getChildObjects(
const caffa::ObjectHandle* objectHandle,
85 const std::string& fieldName )
const override;
88 const std::string& fieldName,
91 void removeChildObject(
const caffa::ObjectHandle* objectHandle,
const std::string& fieldName,
size_t index )
override;
93 void clearChildObjects(
const caffa::ObjectHandle* objectHandle,
const std::string& fieldName )
override;
96 const std::string& fieldName,
101 void setJson(
const caffa::ObjectHandle* objectHandle,
const std::string& fieldName,
const nlohmann::json& value )
override;
102 nlohmann::json getJson(
const caffa::ObjectHandle*,
const std::string& fieldName )
const override;
104 std::pair<http::status, std::string> performRequest( http::verb verb,
105 const std::string& hostname,
107 const std::string& target,
108 const std::string& body,
109 const std::string& username =
"",
110 const std::string& password =
"" )
const;
111 std::pair<http::status, std::string> performGetRequest(
const std::string& hostname,
113 const std::string& target,
114 const std::string& username =
"",
115 const std::string& password =
"" )
const;
118 std::string m_sessionUuid;
119 std::unique_ptr<std::thread> m_keepAliveThread;
120 mutable std::mutex m_sessionMutex;
123 std::shared_ptr<boost::asio::io_context> m_ioc;
124 mutable std::shared_ptr<boost::beast::tcp_stream> m_stream;
Definition: cafRestClient.h:44
Basic Application Information.
Definition: cafApplication.h:38
Definition: cafRpcClient.h:37
Definition: cafObjectHandle.h:47
Definition: cafRestClient.h:51
Main Caffa namespace.
Definition: cafApplication.h:30
Definition: cafRestAppService.h:28