|
AYON Cpp Api
0.1.0
|
Central Ayon api class Class for exposing Ayon server functions to C++ users. More...
#include <AyonCppApi.h>
Public Member Functions | |
| AyonApi (const std::optional< std::string > &logFilePos, const std::string &authKey, const std::string &serverUrl, const std::string &ayonProjectName, const std::string &siteId, std::optional< int > concurrency=std::nullopt) | |
| Constructor. More... | |
| ~AyonApi () | |
| Destructor. More... | |
| std::string | getKey () |
| Returns the stored API key. More... | |
| std::string | getUrl () |
| Returns the stored AYON server URL. More... | |
| nlohmann::json | GET (const std::shared_ptr< std::string > endPoint, const std::shared_ptr< httplib::Headers > headers, uint8_t successStatus) |
| Runs a GET command. More... | |
| 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) More... | |
| 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) More... | |
| 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. More... | |
| 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. More... | |
| 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:// path) and the machine local file location. More... | |
| std::shared_ptr< AyonLogger > | logPointer () |
| Get function for shared AyonLogger pointer used by this class instance. More... | |
| const std::unordered_map< std::string, std::string > & | getSiteRoots () |
| Gets the site root overwrites for the current project. More... | |
| std::string | rootReplace (const std::string &rootLessPath) |
| Replaces {root[var]} for ayon:// paths. More... | |
Private Member Functions | |
| 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. More... | |
| 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. More... | |
| std::string | convertUriVecToString (const std::vector< std::string > &uriVec) |
| Converts a vector of URIs into a string to serve into CorePost functions. More... | |
| bool | isSSL () const |
| Checks if the m_ayonServer is running on SSL based on m_serverUrl Simple implementation - httplib's built-in check is not working. More... | |
| void | setSSL () |
| Sets the SSL cert path for the m_ayonServer httplib client. More... | |
Private Attributes | |
| std::unique_ptr< httplib::Client > | m_ayonServer |
| std::shared_ptr< AyonLogger > | m_log |
| const std::string | m_authKey |
| const std::string | m_serverUrl |
| std::string | m_ayonProjectName |
| std::string | m_siteId |
| const int | m_numThreads |
| std::unordered_map< std::string, std::string > | m_siteRoots |
| httplib::Headers | m_headers |
| std::string | m_userName |
| bool | m_serverBusy = false |
| std::string | m_uriResolverEndpoint = "/api/resolve" |
| std::string | m_uriResolverEndpointPathOnlyVar = "?pathOnly=true" |
| bool | m_pathOnlyResolution = true |
| bool | m_batchResolveOptimizeVector = true |
| Decides if the cpp API removes duplicates from batch request vector. More... | |
| uint8_t | m_minGroupSizeForAsyncRequests = 10 |
| uint16_t | m_regroupSizeForAsyncRequests = 200 |
| uint16_t | m_maxGroupSizeForAsyncRequests = 300 |
| uint16_t | m_minVecSizeForGroupSplitAsyncRequests = 50 |
| uint8_t | m_maxCallRetries = 8 |
| uint16_t | m_retryWait = 800 |
| uint16_t | m_serverBusyCode = 503 |
| uint16_t | m_requestDelayWhenServerBusy = 10000 |
| uint16_t | m_connectionTimeoutMax = 200 |
| uint8_t | m_readTimeoutMax = 160 |
| uint16_t | m_generativeCorePostMaxLoopIterations = 200 |
| std::mutex | m_ayonServerMutex |
| std::mutex | m_concurrentRequestAfterServerBusyMutex |
| std::condition_variable | m_serverBusyCondVar |
| uint8_t | m_maxConcurrentRequestsAfterServerBusy = 8 |
Central Ayon api class Class for exposing Ayon server functions to C++ users.
Uses httplib internally for communication with the server
| AyonApi::AyonApi | ( | const std::optional< std::string > & | logFilePos, |
| const std::string & | authKey, | ||
| const std::string & | serverUrl, | ||
| const std::string & | ayonProjectName, | ||
| const std::string & | siteId, | ||
| std::optional< int > | concurrency = std::nullopt |
||
| ) |
Constructor.
| AyonApi::~AyonApi | ( | ) |
Destructor.
| std::unordered_map< std::string, std::string > AyonApi::batchResolvePath | ( | std::vector< std::string > & | uriPaths | ) |
Resolves a vector of paths against the AYON server asynchronously using auto-generated batch requests.
| uriPaths | The vector of URI paths to resolve. |
|
private |
Converts a vector of URIs into a string to serve into CorePost functions.
| uriVec | Vector of string URIs. |
| nlohmann::json AyonApi::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)
| endPoint | The AYON endpoint to hit |
| headers | The HTTP headers to send |
| jsonPayload | The payload in JSON format |
| successStatus | Defines what status code is considered a success and breaks the retry loop. |
|
private |
Calls the server while creating a new client instance to stay async.
| endPoint | Endpoint that AYON resolve is loaded on. |
| headers | HTTP headers. |
| payload | JSON payload to be resolved by endpoint. |
| successStatus | Defines what is considered a success response to break the retry loop. |
| nlohmann::json AyonApi::GET | ( | const std::shared_ptr< std::string > | endPoint, |
| const std::shared_ptr< httplib::Headers > | headers, | ||
| uint8_t | successStatus | ||
| ) |
Runs a GET command.
| endPoint | Reachable HTTP/HTTPS endpoint |
| headers | HTTP headers |
| successStatus | Defines what HTTP response code should be considered a success. |
| std::pair< std::string, std::string > AyonApi::getAssetIdent | ( | const nlohmann::json & | uriResolverResponse | ) |
Takes an AYON path URI response (resolved ayon://path) and returns a pair of asset identifier (ayon:// path) and the machine local file location.
| uriResolverResponse | JSON representation of the response from the AYON API resolve endpoint. |
| std::string AyonApi::getKey | ( | ) |
Returns the stored API key.
Passed in the constructor.
| const std::unordered_map< std::string, std::string > & AyonApi::getSiteRoots | ( | ) |
Gets the site root overwrites for the current project.
Current project is defined via an env variable for now
| std::string AyonApi::getUrl | ( | ) |
Returns the stored AYON server URL.
Passed in the constructor.
|
private |
Checks if the m_ayonServer is running on SSL based on m_serverUrl Simple implementation - httplib's built-in check is not working.
| std::shared_ptr< AyonLogger > AyonApi::logPointer | ( | ) |
Get function for shared AyonLogger pointer used by this class instance.
| std::pair< std::string, std::string > AyonApi::resolvePath | ( | const std::string & | uriPath | ) |
Uses the URI resolve endpoint on the AYON server to resolve a URI path to the local path.
Gets the siteId from a variable stored in the class.
| uriPath | The URI path to resolve. |
| std::string AyonApi::rootReplace | ( | const std::string & | rootLessPath | ) |
Replaces {root[var]} for ayon:// paths.
| rootLessPath | Endpoint response for ayon://path with {root[var]}. If no root can be found, the path will be returned as is. |
|
private |
Calls the server in a serial way by sharing the AyonServer pointer.
| endPoint | Endpoint that AYON resolve is loaded on. |
| headers | HTTP headers. |
| payload | JSON payload to be resolved by endpoint. |
| successStatus | Defines what is considered a success response to break the retry loop. |
|
private |
Sets the SSL cert path for the m_ayonServer httplib client.
| nlohmann::json AyonApi::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)
| endPoint | The AYON endpoint to hit |
| headers | The HTTP headers to send |
| jsonPayload | The payload in JSON format |
| successStatus | Defines what status code is considered a success and breaks the retry loop |
|
private |
|
private |
|
private |
|
private |
|
private |
Decides if the cpp API removes duplicates from batch request vector.
Default is true
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |