AYON Cpp Api  0.1.0
Loading...
Searching...
No Matches
AyonApi Class Reference

Central Ayon api class
Class for exposing Ayon server functions to C++ users. More...

#include <AyonCppApi.h>

Collaboration diagram for AyonApi:

Public Member Functions

 AyonApi ()
 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< AyonLoggerlogPointer ()
 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 > AyonServer
 
std::unordered_map< std::string, std::string > siteRoots
 
const char * authKey
 
const char * serverUrl
 
std::string ayonProjectName
 
std::string ayonAppData = getAppDataDir() + "/AYON"
 
std::string siteId
 
std::string userName
 
u_int8_t minGrpSizeForAsyncRequests = 10
 
u_int16_t regroupSizeForAsyncRequests = 200
 
u_int16_t maxGroupSizeForAsyncRequests = 300
 
u_int16_t minVecSizeForGroupSplitAsyncRequests = 50
 
u_int8_t maxCallRetrys = 8
 
u_int16_t retryWaight = 800
 
const int num_threads
 maximum number off threads that the cpu can handle at the same time. More...
 
std::shared_ptr< AyonLoggerLog
 
std::string uriResolverEndpoint = "/api/resolve"
 
std::string uriResolverEndpointPathOnlyVar = "?pathOnly=true"
 
bool pathOnlyReselution = true
 
std::mutex ConcurentRequestAfterffoMutex
 
uint8_t maxConcurentRequestAfterffo = 8
 
uint16_t GenerativeCorePostMaxLoopIterations = 200
 
u_int16_t connectionTimeOutMax = 200
 
u_int8_t readTimeOutMax = 160
 
bool batchResolveOptimizeVector = true
 decides if the cpp api removes duplicates from batch request vector default is true More...
 
uint16_t ServerBusyCode = 503
 
uint16_t RequestDelayWhenServerBusy = 10000
 
bool serverBusy = false
 this bool will be set to true if a 503 is encountered More...
 
std::mutex AyonServerMutex
 needed for serial resolve operations. More...
 

Detailed Description

Central Ayon api class
Class for exposing Ayon server functions to C++ users.

Uses httplib internally for communication with the server

Constructor & Destructor Documentation

◆ AyonApi()

AyonApi::AyonApi ( )

constructor

Here is the call graph for this function:

◆ ~AyonApi()

AyonApi::~AyonApi ( )

destructor

Member Function Documentation

◆ batchResolvePath()

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

Parameters
uriPaths
Here is the call graph for this function:

◆ convertUriVecToString()

std::string AyonApi::convertUriVecToString ( const std::vector< std::string > &  uriVec)
private

converts a vector off uris into an string to serve into CorePost funcs

Parameters
uriVecvector off str uris

◆ CPOST()

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 )

Parameters
endPointthe AYON enpoint to hit
headersthe http header that you want to send
jsonPayloadthe payload in json format
sucsessStatusdefines what status code is considered a success and brakes the retry loop.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ GenerativeCorePost()

std::string AyonApi::GenerativeCorePost ( const std::string &  endPoint,
httplib::Headers  headers,
std::string &  Payload,
const int &  sucsessStatus 
)
private

calls the server while creating a new client instance to stay async

Parameters
endPointendpoint that ayon resolve is loaded on
headershttp headers
Payloadjson payload to be resolved by endpoint
sucsessStatusdefines what is considered a success response to break the retry loop
Here is the caller graph for this function:

◆ GET()

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

Parameters
endPointreachable http / https endpoint
headershttp headers
sucsessStatusdefine what http response code should be considered a success.
Here is the caller graph for this function:

◆ getAssetIdent()

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

Parameters
uriResolverResponejson representation off the resolves the ayon/api/resolve endpoint returns
Here is the call graph for this function:
Here is the caller graph for this function:

◆ getKey()

std::string AyonApi::getKey ( )

returns the stored apikey.

Retrieved from the appropriate env variable. (the variable is loaded from loadEnvVars())

◆ getSiteRoots()

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

Here is the call graph for this function:
Here is the caller graph for this function:

◆ getUrl()

std::string AyonApi::getUrl ( )

returns the stored AYON server url.

Retrieved from the appropriate env variable. (the variable is loaded from loadEnvVars())

◆ loadEnvVars()

bool AyonApi::loadEnvVars ( )

this function loads all needed varible into the class
this will allso be called by the constructor

Returns
Here is the caller graph for this function:

◆ logPointer()

std::shared_ptr< AyonLogger > AyonApi::logPointer ( )

get function for shared AyonLogger pointer used by this class instance

◆ resolvePath()

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

Parameters
uriPath
Here is the call graph for this function:

◆ rootReplace()

std::string AyonApi::rootReplace ( const std::string &  rootLessPath)

replaces {root[var]} for ayon:// paths

Parameters
rootLessPathendpoint response for ayon://path with {root[var]} available if no root can be found the path will be returned as is
Here is the caller graph for this function:

◆ serialCorePost()

std::string AyonApi::serialCorePost ( const std::string &  endPoint,
httplib::Headers  headers,
std::string &  Payload,
const int &  sucsessStatus 
)
private

calls the server in an serial way by sharing the AyonServer pointer

Parameters
endPointendpoint that ayon resolve is loaded on
headershttp headers
Payloadjson payload to be resolved by endpoint
sucsessStatusdefines what is considered a success response to break the retry loop
Here is the caller graph for this function:

◆ SPOST()

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 )

Parameters
endPointthe AYON enpoint to hit
headersthe http header that you want to send
jsonPayloadthe payload in json format
sucsessStatusdefines what status code is considered a success and brakes the retry loop.
Here is the call graph for this function:
Here is the caller graph for this function:

Member Data Documentation

◆ authKey

const char* AyonApi::authKey
private

◆ ayonAppData

std::string AyonApi::ayonAppData = getAppDataDir() + "/AYON"
private

◆ ayonProjectName

std::string AyonApi::ayonProjectName
private

◆ AyonServer

std::unique_ptr<httplib::Client> AyonApi::AyonServer
private

◆ AyonServerMutex

std::mutex AyonApi::AyonServerMutex
private

needed for serial resolve operations.

to lock acces to AyonServer shared pointer

◆ batchResolveOptimizeVector

bool AyonApi::batchResolveOptimizeVector = true
private

decides if the cpp api removes duplicates from batch request vector default is true

◆ ConcurentRequestAfterffoMutex

std::mutex AyonApi::ConcurentRequestAfterffoMutex
private

◆ connectionTimeOutMax

u_int16_t AyonApi::connectionTimeOutMax = 200
private

◆ GenerativeCorePostMaxLoopIterations

uint16_t AyonApi::GenerativeCorePostMaxLoopIterations = 200
private

◆ Log

std::shared_ptr<AyonLogger> AyonApi::Log
private

◆ maxCallRetrys

u_int8_t AyonApi::maxCallRetrys = 8
private

◆ maxConcurentRequestAfterffo

uint8_t AyonApi::maxConcurentRequestAfterffo = 8
private

◆ maxGroupSizeForAsyncRequests

u_int16_t AyonApi::maxGroupSizeForAsyncRequests = 300
private

◆ minGrpSizeForAsyncRequests

u_int8_t AyonApi::minGrpSizeForAsyncRequests = 10
private

◆ minVecSizeForGroupSplitAsyncRequests

u_int16_t AyonApi::minVecSizeForGroupSplitAsyncRequests = 50
private

◆ num_threads

const int AyonApi::num_threads
private

maximum number off threads that the cpu can handle at the same time.

Will be set via constructor

◆ pathOnlyReselution

bool AyonApi::pathOnlyReselution = true
private

◆ readTimeOutMax

u_int8_t AyonApi::readTimeOutMax = 160
private

◆ regroupSizeForAsyncRequests

u_int16_t AyonApi::regroupSizeForAsyncRequests = 200
private

◆ RequestDelayWhenServerBusy

uint16_t AyonApi::RequestDelayWhenServerBusy = 10000
private

◆ retryWaight

u_int16_t AyonApi::retryWaight = 800
private

◆ serverBusy

bool AyonApi::serverBusy = false
private

this bool will be set to true if a 503 is encountered

◆ ServerBusyCode

uint16_t AyonApi::ServerBusyCode = 503
private

◆ serverUrl

const char* AyonApi::serverUrl
private

◆ siteId

std::string AyonApi::siteId
private

◆ siteRoots

std::unordered_map<std::string, std::string> AyonApi::siteRoots
private

◆ uriResolverEndpoint

std::string AyonApi::uriResolverEndpoint = "/api/resolve"
private

◆ uriResolverEndpointPathOnlyVar

std::string AyonApi::uriResolverEndpointPathOnlyVar = "?pathOnly=true"
private

◆ userName

std::string AyonApi::userName
private

The documentation for this class was generated from the following files: