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 (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...
 

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 ( 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

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

◆ 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

◆ m_authKey

const std::string AyonApi::m_authKey
private

◆ m_ayonProjectName

std::string AyonApi::m_ayonProjectName
private

◆ m_AyonServer

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

◆ m_AyonServerMutex

std::mutex AyonApi::m_AyonServerMutex
private

needed for serial resolve operations.

to lock acces to AyonServer shared pointer

◆ m_batchResolveOptimizeVector

bool AyonApi::m_batchResolveOptimizeVector = true
private

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

◆ m_ConcurentRequestAfterffoMutex

std::mutex AyonApi::m_ConcurentRequestAfterffoMutex
private

◆ m_connectionTimeOutMax

uint16_t AyonApi::m_connectionTimeOutMax = 200
private

◆ m_GenerativeCorePostMaxLoopIterations

uint16_t AyonApi::m_GenerativeCorePostMaxLoopIterations = 200
private

◆ m_Log

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

◆ m_maxCallRetrys

uint8_t AyonApi::m_maxCallRetrys = 8
private

◆ m_maxConcurentRequestAfterffo

uint8_t AyonApi::m_maxConcurentRequestAfterffo = 8
private

◆ m_maxGroupSizeForAsyncRequests

uint16_t AyonApi::m_maxGroupSizeForAsyncRequests = 300
private

◆ m_minGrpSizeForAsyncRequests

uint8_t AyonApi::m_minGrpSizeForAsyncRequests = 10
private

◆ m_minVecSizeForGroupSplitAsyncRequests

uint16_t AyonApi::m_minVecSizeForGroupSplitAsyncRequests = 50
private

◆ m_num_threads

const int AyonApi::m_num_threads
private

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

Will be set via constructor

◆ m_pathOnlyReselution

bool AyonApi::m_pathOnlyReselution = true
private

◆ m_readTimeOutMax

uint8_t AyonApi::m_readTimeOutMax = 160
private

◆ m_regroupSizeForAsyncRequests

uint16_t AyonApi::m_regroupSizeForAsyncRequests = 200
private

◆ m_RequestDelayWhenServerBusy

uint16_t AyonApi::m_RequestDelayWhenServerBusy = 10000
private

◆ m_retryWaight

uint16_t AyonApi::m_retryWaight = 800
private

◆ m_serverBusy

bool AyonApi::m_serverBusy = false
private

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

◆ m_ServerBusyCode

uint16_t AyonApi::m_ServerBusyCode = 503
private

◆ m_serverUrl

const std::string AyonApi::m_serverUrl
private

◆ m_siteId

std::string AyonApi::m_siteId
private

◆ m_siteRoots

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

◆ m_uriResolverEndpoint

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

◆ m_uriResolverEndpointPathOnlyVar

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

◆ m_userName

std::string AyonApi::m_userName
private

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