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 apikey. 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 sucsessStatus) |
runns a get command and returns the response body as std::string 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 > sucsessStatus) |
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 > sucsessStatus) |
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 in order to resolve an uri path towards the local path gets the siteId from an variable stored in the class More... | |
std::unordered_map< std::string, std::string > | batchResolvePath (std::vector< std::string > &uriPaths) |
resolves a vector off paths against the AYON server in an async way uses auto generated batch requests More... | |
std::pair< std::string, std::string > | getAssetIdent (const nlohmann::json &uriResolverRespone) |
this function takes a ayon path uri response(resolved ayon://path) and returns a pair of assetIdentifier(ayon:// path) and the machine local file location More... | |
bool | loadEnvVars () |
this function loads all needed varible into the class this will allso be called by the constructor More... | |
std::shared_ptr< AyonLogger > | logPointer () |
get function for shared AyonLogger pointer used by this class instance More... | |
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 &sucsessStatus) |
calls the server in an serial way by sharing the AyonServer pointer More... | |
std::string | GenerativeCorePost (const std::string &endPoint, httplib::Headers headers, std::string &Payload, const int &sucsessStatus) |
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 off uris into an string to serve into CorePost funcs More... | |
Private Attributes | |
std::unique_ptr< httplib::Client > | m_AyonServer |
std::unordered_map< std::string, std::string > | m_siteRoots |
const std::string | m_authKey |
const std::string | m_serverUrl |
std::string | m_ayonProjectName |
std::string | m_siteId |
std::string | m_userName |
uint8_t | m_minGrpSizeForAsyncRequests = 10 |
uint16_t | m_regroupSizeForAsyncRequests = 200 |
uint16_t | m_maxGroupSizeForAsyncRequests = 300 |
uint16_t | m_minVecSizeForGroupSplitAsyncRequests = 50 |
uint8_t | m_maxCallRetrys = 8 |
uint16_t | m_retryWaight = 800 |
const int | m_num_threads |
maximum number off threads that the cpu can handle at the same time. More... | |
std::shared_ptr< AyonLogger > | m_Log |
std::string | m_uriResolverEndpoint = "/api/resolve" |
std::string | m_uriResolverEndpointPathOnlyVar = "?pathOnly=true" |
bool | m_pathOnlyReselution = true |
std::mutex | m_ConcurentRequestAfterffoMutex |
uint8_t | m_maxConcurentRequestAfterffo = 8 |
uint16_t | m_GenerativeCorePostMaxLoopIterations = 200 |
uint16_t | m_connectionTimeOutMax = 200 |
uint8_t | m_readTimeOutMax = 160 |
bool | m_batchResolveOptimizeVector = true |
decides if the cpp api removes duplicates from batch request vector default is true More... | |
uint16_t | m_ServerBusyCode = 503 |
uint16_t | m_RequestDelayWhenServerBusy = 10000 |
bool | m_serverBusy = false |
this bool will be set to true if a 503 is encountered More... | |
std::mutex | m_AyonServerMutex |
needed for serial resolve operations. More... | |
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 off paths against the AYON server in an async way uses auto generated batch requests
uriPaths |
|
private |
converts a vector off uris into an string to serve into CorePost funcs
uriVec | vector off str 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 > | sucsessStatus | ||
) |
http post request utilizing the creation of a new httplib client ( Generative Async )
endPoint | the AYON enpoint to hit |
headers | the http header that you want to send |
jsonPayload | the payload in json format |
sucsessStatus | defines what status code is considered a success and brakes 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 |
sucsessStatus | 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 | sucsessStatus | ||
) |
runns a get command and returns the response body as std::string
endPoint | reachable http / https endpoint |
headers | http headers |
sucsessStatus | define what http response code should be considered a success. |
std::pair< std::string, std::string > AyonApi::getAssetIdent | ( | const nlohmann::json & | uriResolverRespone | ) |
this function takes a ayon path uri response(resolved ayon://path) and returns a pair of assetIdentifier(ayon:// path) and the machine local file location
uriResolverRespone | json representation off the resolves the ayon/api/resolve endpoint returns |
std::string AyonApi::getKey | ( | ) |
returns the stored apikey.
Retrieved from the appropriate env variable. (the variable is loaded from loadEnvVars())
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.
Retrieved from the appropriate env variable. (the variable is loaded from loadEnvVars())
bool AyonApi::loadEnvVars | ( | ) |
this function loads all needed varible into the class
this will allso be called by the constructor
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 in order to resolve an uri path towards the local path
gets the siteId from an variable stored in the class
uriPath |
std::string AyonApi::rootReplace | ( | const std::string & | rootLessPath | ) |
replaces {root[var]} for ayon:// paths
rootLessPath | endpoint response for ayon://path with {root[var]} available if no root can be found the path will be returned as is |
|
private |
calls the server in an 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 |
sucsessStatus | defines what is considered a success response to break the retry loop |
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 > | sucsessStatus | ||
) |
post Request via a shared httplib client ( serial )
endPoint | the AYON enpoint to hit |
headers | the http header that you want to send |
jsonPayload | the payload in json format |
sucsessStatus | defines what status code is considered a success and brakes the retry loop. |
|
private |
|
private |
|
private |
|
private |
needed for serial resolve operations.
to lock acces to AyonServer shared pointer
|
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 |
maximum number off threads that the cpu can handle at the same time.
Will be set via constructor
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
this bool will be set to true if a 503 is encountered
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |