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);
120 std::pair<std::string, std::string>
getAssetIdent(
const nlohmann::json &uriResolverResponse);
131 const std::unordered_map<std::string, std::string>&
getSiteRoots();
139 std::string
rootReplace(
const std::string &rootLessPath);
151 httplib::Headers headers,
152 std::string &payload,
153 const int &successStatus);
163 httplib::Headers headers,
164 std::string &payload,
165 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:214
std::string getUrl()
Returns the stored AYON server URL.
Definition: AyonCppApi.cpp:584
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:592
std::string m_uriResolverEndpoint
Definition: AyonCppApi.h:205
const int m_numThreads
Definition: AyonCppApi.h:196
httplib::Headers m_headers
Definition: AyonCppApi.h:200
std::string rootReplace(const std::string &rootLessPath)
Replaces {root[var]} for ayon:// paths.
Definition: AyonCppApi.cpp:246
uint8_t m_maxConcurrentRequestsAfterServerBusy
Definition: AyonCppApi.h:231
bool m_serverBusy
Definition: AyonCppApi.h:202
std::unordered_map< std::string, std::string > m_siteRoots
Definition: AyonCppApi.h:199
uint8_t m_minGroupSizeForAsyncRequests
Definition: AyonCppApi.h:213
std::shared_ptr< AyonLogger > m_log
Definition: AyonCppApi.h:189
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:406
uint8_t m_readTimeoutMax
Definition: AyonCppApi.h:224
const std::unordered_map< std::string, std::string > & getSiteRoots()
Gets the site root overwrites for the current project.
Definition: AyonCppApi.cpp:215
std::mutex m_concurrentRequestAfterServerBusyMutex
Definition: AyonCppApi.h:229
std::string m_userName
Definition: AyonCppApi.h:201
uint8_t m_maxCallRetries
Definition: AyonCppApi.h:219
uint16_t m_connectionTimeoutMax
Definition: AyonCppApi.h:223
uint16_t m_serverBusyCode
Definition: AyonCppApi.h:221
std::unique_ptr< httplib::Client > m_ayonServer
Definition: AyonCppApi.h:188
std::mutex m_ayonServerMutex
Definition: AyonCppApi.h:228
bool m_pathOnlyResolution
Definition: AyonCppApi.h:207
std::condition_variable m_serverBusyCondVar
Definition: AyonCppApi.h:230
uint16_t m_generativeCorePostMaxLoopIterations
Definition: AyonCppApi.h:225
std::string m_ayonProjectName
Definition: AyonCppApi.h:194
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:636
uint16_t m_minVecSizeForGroupSplitAsyncRequests
Definition: AyonCppApi.h:216
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:554
const std::string m_authKey
Definition: AyonCppApi.h:192
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:746
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:427
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:328
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:280
void setSSL()
Sets the SSL cert path for the m_ayonServer httplib client.
Definition: AyonCppApi.cpp:772
std::string getKey()
Returns the stored API key.
Definition: AyonCppApi.cpp:577
bool m_batchResolveOptimizeVector
Decides if the cpp API removes duplicates from batch request vector.
Definition: AyonCppApi.h:212
bool isSSL() const
Checks if the m_ayonServer is running on SSL based on m_serverUrl Simple implementation - httplib's b...
Definition: AyonCppApi.cpp:766
~AyonApi()
Destructor.
Definition: AyonCppApi.cpp:210
std::string m_uriResolverEndpointPathOnlyVar
Definition: AyonCppApi.h:206
uint16_t m_maxGroupSizeForAsyncRequests
Definition: AyonCppApi.h:215
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:373
const std::string m_serverUrl
Definition: AyonCppApi.h:193
std::string m_siteId
Definition: AyonCppApi.h:195
uint16_t m_retryWait
Definition: AyonCppApi.h:220
std::shared_ptr< AyonLogger > logPointer()
Get function for shared AyonLogger pointer used by this class instance.
Definition: AyonCppApi.cpp:760
uint16_t m_requestDelayWhenServerBusy
Definition: AyonCppApi.h:222