21 #include "cafNotNull.h"
22 #include "cafRpcClient.h"
23 #include "cafSession.h"
25 #include <boost/beast/http/status.hpp>
26 #include <boost/beast/http/verb.hpp>
40 namespace http = boost::beast::http;
48 const std::string& hostname,
50 const std::string& username =
"",
51 const std::string& password =
"" );
55 std::shared_ptr<caffa::ObjectHandle>
document(
const std::string& documentId )
const override;
56 std::vector<std::shared_ptr<caffa::ObjectHandle>>
documents()
const;
57 std::string
execute( caffa::not_null<const caffa::ObjectHandle*> selfObject,
58 const std::string& methodName,
59 const std::string& jsonArguments )
const override;
61 void sendKeepAlive()
override;
69 void changeSession( caffa::Session::Type newType )
override;
70 void destroySession()
override;
71 const std::string& sessionUuid()
const override;
72 void startKeepAliveThread()
override;
74 std::shared_ptr<caffa::ObjectHandle> getShallowCopyOfChildObject(
const caffa::ObjectHandle* objectHandle,
75 const std::string& fieldName )
const override;
77 std::shared_ptr<caffa::ObjectHandle> getDeepCopyOfChildObject(
const caffa::ObjectHandle* objectHandle,
78 const std::string& fieldName )
const override;
81 const std::string& fieldName,
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 createSession( caffa::Session::Type type );
103 void setJson(
const caffa::ObjectHandle* objectHandle,
const std::string& fieldName,
const nlohmann::json& value )
override;
104 nlohmann::json getJson(
const caffa::ObjectHandle*,
const std::string& fieldName )
const override;
106 std::pair<http::status, std::string> performRequest( http::verb verb,
107 const std::string& hostname,
109 const std::string& target,
110 const std::string& body )
const;
111 std::pair<http::status, std::string>
112 performGetRequest(
const std::string& hostname,
int port,
const std::string& target )
const;
115 std::string m_sessionUuid;
116 std::unique_ptr<std::thread> m_keepAliveThread;
117 mutable std::mutex m_sessionMutex;
119 std::string m_username;
120 std::string m_password;
Definition: cafObjectHandle.h:55
Definition: cafRpcClient.h:38
Definition: cafRestClient.h:45
caffa::AppInfo appInfo() const override
Retrieve Application information.
Definition: cafRestClient.cpp:258
bool stopServer() override
Tell the server to stop operation. Returns a simple boolean status where true is ok.
Definition: cafRestClient.cpp:356
std::string execute(caffa::not_null< const caffa::ObjectHandle * > selfObject, const std::string &methodName, const std::string &jsonArguments) const override
Execute a general non-streaming method.
Definition: cafRestClient.cpp:333
std::vector< std::shared_ptr< caffa::ObjectHandle > > documents() const
Retrieve all top level documents.
Definition: cafRestClient.cpp:300
void setChildObject(const caffa::ObjectHandle *objectHandle, const std::string &fieldName, const caffa::ObjectHandle *childObject) override
TODO: add support for index and replace.
Definition: cafRestClient.cpp:681
std::shared_ptr< caffa::ObjectHandle > document(const std::string &documentId) const override
Retrieve a top level document (project)
Definition: cafRestClient.cpp:274
caffa::Session::Type checkSession() const override
Check the session. Will return a session type (including possibly INVALID) if the session exists....
Definition: cafRestClient.cpp:467
Main Caffa namespace.
Definition: __init__.py:1
Basic Application Information.
Definition: cafApplication.h:39