6#include <condition_variable>
11#include <unordered_map>
22#include "nlohmann/json_fwd.hpp"
25#include "lib/ynput/lib/logging/AyonLogger.hpp"
37 AyonApi(
const std::optional<std::string> &logFilePos,
38 const std::string &authKey,
39 const std::string &serverUrl,
40 const std::string &ayonProjectName,
41 const std::string &siteId,
42 std::optional<int> concurrency = std::nullopt);
65 nlohmann::json
GET(
const std::shared_ptr<std::string> endPoint,
66 const std::shared_ptr<httplib::Headers> headers,
67 uint8_t successStatus);
78 nlohmann::json
SPOST(
const std::shared_ptr<std::string> endPoint,
79 const std::shared_ptr<httplib::Headers> headers,
80 nlohmann::json jsonPayload,
81 const std::shared_ptr<uint8_t> successStatus);
91 nlohmann::json
CPOST(
const std::shared_ptr<std::string> endPoint,
92 const std::shared_ptr<httplib::Headers> headers,
93 nlohmann::json jsonPayload,
94 const std::shared_ptr<uint8_t> successStatus);
103 std::pair<std::string, std::string>
resolvePath(
const std::string &uriPath);
111 std::unordered_map<std::string, std::string>
batchResolvePath(std::vector<std::string> &uriPaths);
126 std::unordered_map<std::string, std::string>
batchResolvePathSerial(
const std::vector<std::string> &uriPaths);
135 std::pair<std::string, std::string>
getAssetIdent(
const nlohmann::json &uriResolverResponse);
146 const std::unordered_map<std::string, std::string>&
getSiteRoots();
154 std::string
rootReplace(
const std::string &rootLessPath);
166 httplib::Headers headers,
167 std::string &payload,
168 const int &successStatus);
178 httplib::Headers headers,
179 std::string &payload,
180 const int &successStatus);
Central Ayon api class Class for exposing Ayon server functions to C++ users.
Definition: AyonCppApi.h:32
uint16_t m_regroupSizeForAsyncRequests
Definition: AyonCppApi.h:229
std::string getUrl()
Returns the stored AYON server URL.
Definition: AyonCppApi.cpp:662
std::string serialCorePost(const std::string &endPoint, httplib::Headers headers, std::string &payload, const int &successStatus)
Calls the server in a serial way by sharing the AyonServer pointer.
Definition: AyonCppApi.cpp:670
std::string m_uriResolverEndpoint
Definition: AyonCppApi.h:220
const int m_numThreads
Definition: AyonCppApi.h:211
httplib::Headers m_headers
Definition: AyonCppApi.h:215
std::string rootReplace(const std::string &rootLessPath)
Replaces {root[var]} for ayon:// paths.
Definition: AyonCppApi.cpp:260
std::unordered_map< std::string, std::string > batchResolvePathSerial(const std::vector< std::string > &uriPaths)
Resolves a vector of paths in a SINGLE batched request over the persistent keep-alive client.
Definition: AyonCppApi.cpp:567
uint8_t m_maxConcurrentRequestsAfterServerBusy
Definition: AyonCppApi.h:252
bool m_serverBusy
Definition: AyonCppApi.h:217
std::unordered_map< std::string, std::string > m_siteRoots
Definition: AyonCppApi.h:214
uint8_t m_minGroupSizeForAsyncRequests
Definition: AyonCppApi.h:228
std::shared_ptr< AyonLogger > m_log
Definition: AyonCppApi.h:204
std::pair< std::string, std::string > resolvePath(const std::string &uriPath)
Uses the URI resolve endpoint on the AYON server to resolve a URI path to the local path.
Definition: AyonCppApi.cpp:420
uint8_t m_readTimeoutMax
Definition: AyonCppApi.h:245
const std::unordered_map< std::string, std::string > & getSiteRoots()
Gets the site root overwrites for the current project.
Definition: AyonCppApi.cpp:229
std::mutex m_concurrentRequestAfterServerBusyMutex
Definition: AyonCppApi.h:250
std::string m_userName
Definition: AyonCppApi.h:216
uint8_t m_maxCallRetries
Definition: AyonCppApi.h:240
uint16_t m_connectionTimeoutMax
Definition: AyonCppApi.h:244
uint16_t m_serverBusyCode
Definition: AyonCppApi.h:242
std::unique_ptr< httplib::Client > m_ayonServer
Definition: AyonCppApi.h:203
std::mutex m_ayonServerMutex
Definition: AyonCppApi.h:249
bool m_pathOnlyResolution
Definition: AyonCppApi.h:222
std::condition_variable m_serverBusyCondVar
Definition: AyonCppApi.h:251
uint16_t m_generativeCorePostMaxLoopIterations
Definition: AyonCppApi.h:246
std::string m_ayonProjectName
Definition: AyonCppApi.h:209
std::string generativeCorePost(const std::string &endPoint, httplib::Headers headers, std::string &payload, const int &successStatus)
Calls the server while creating a new client instance to stay async.
Definition: AyonCppApi.cpp:714
uint16_t m_minVecSizeForGroupSplitAsyncRequests
Definition: AyonCppApi.h:231
std::pair< std::string, std::string > getAssetIdent(const nlohmann::json &uriResolverResponse)
Takes an AYON path URI response (resolved ayon://path) and returns a pair of asset identifier (ayon:/...
Definition: AyonCppApi.cpp:632
const std::string m_authKey
Definition: AyonCppApi.h:207
std::string convertUriVecToString(const std::vector< std::string > &uriVec)
Converts a vector of URIs into a string to serve into CorePost functions.
Definition: AyonCppApi.cpp:824
std::unordered_map< std::string, std::string > batchResolvePath(std::vector< std::string > &uriPaths)
Resolves a vector of paths against the AYON server asynchronously using auto-generated batch requests...
Definition: AyonCppApi.cpp:441
nlohmann::json SPOST(const std::shared_ptr< std::string > endPoint, const std::shared_ptr< httplib::Headers > headers, nlohmann::json jsonPayload, const std::shared_ptr< uint8_t > successStatus)
POST request via a shared httplib client (serial)
Definition: AyonCppApi.cpp:342
nlohmann::json GET(const std::shared_ptr< std::string > endPoint, const std::shared_ptr< httplib::Headers > headers, uint8_t successStatus)
Runs a GET command.
Definition: AyonCppApi.cpp:294
void setSSL()
Sets the SSL cert path for the m_ayonServer httplib client.
Definition: AyonCppApi.cpp:850
std::string getKey()
Returns the stored API key.
Definition: AyonCppApi.cpp:655
bool m_batchResolveOptimizeVector
Decides if the cpp API removes duplicates from batch request vector.
Definition: AyonCppApi.h:227
bool isSSL() const
Checks if the m_ayonServer is running on SSL based on m_serverUrl Simple implementation - httplib's b...
Definition: AyonCppApi.cpp:844
~AyonApi()
Destructor.
Definition: AyonCppApi.cpp:224
std::string m_uriResolverEndpointPathOnlyVar
Definition: AyonCppApi.h:221
uint16_t m_maxGroupSizeForAsyncRequests
Definition: AyonCppApi.h:230
uint16_t m_maxSerialBatchSize
Definition: AyonCppApi.h:237
nlohmann::json CPOST(const std::shared_ptr< std::string > endPoint, const std::shared_ptr< httplib::Headers > headers, nlohmann::json jsonPayload, const std::shared_ptr< uint8_t > successStatus)
HTTP POST request utilizing the creation of a new httplib client (Generative Async)
Definition: AyonCppApi.cpp:387
const std::string m_serverUrl
Definition: AyonCppApi.h:208
std::string m_siteId
Definition: AyonCppApi.h:210
uint16_t m_retryWait
Definition: AyonCppApi.h:241
std::shared_ptr< AyonLogger > logPointer()
Get function for shared AyonLogger pointer used by this class instance.
Definition: AyonCppApi.cpp:838
uint16_t m_requestDelayWhenServerBusy
Definition: AyonCppApi.h:243