KiCad PCB EDA Suite
Loading...
Searching...
No Matches
HTTP_LIB_CONNECTION Class Reference

#include <http_lib_connection.h>

Public Member Functions

 HTTP_LIB_CONNECTION (const HTTP_LIB_SOURCE &aSource, bool aTestConnectionNow)
 
 ~HTTP_LIB_CONNECTION ()
 
bool IsValidEndpoint () const
 
bool SelectOne (const std::string &aPartID, HTTP_LIB_PART &aFetchedPart)
 Retrieves a single part with full details from the HTTP library. More...
 
bool SelectAll (const HTTP_LIB_CATEGORY &aCategory, std::vector< HTTP_LIB_PART > &aParts)
 Retrieves all parts from a specific category from the HTTP library. More...
 
std::string GetLastError () const
 
std::vector< HTTP_LIB_CATEGORYgetCategories () const
 
auto getCachedParts ()
 

Static Public Attributes

static const long DEFAULT_TIMEOUT = 10
 

Private Member Functions

std::unique_ptr< KICAD_CURL_EASYcreateCurlEasyObject ()
 
bool ValidateHTTPLibraryEndpoints ()
 
bool syncCategories ()
 
bool checkServerResponse (std::unique_ptr< KICAD_CURL_EASY > &aCurl)
 
bool boolFromString (const std::any &aVal, bool aDefaultValue=false)
 
wxString httpErrorCodeDescription (uint16_t aHttpCode)
 

Private Attributes

HTTP_LIB_SOURCE m_source
 
std::map< std::string, HTTP_LIB_PARTm_cachedParts
 
std::map< std::string, std::tuple< std::string, std::string > > m_cache
 
bool m_endpointValid = false
 
std::string m_lastError
 
std::vector< HTTP_LIB_CATEGORYm_categories
 
std::map< std::string, std::string > m_parts
 
const std::string http_endpoint_categories = "categories"
 
const std::string http_endpoint_parts = "parts"
 
const std::string http_endpoint_settings = "settings"
 
const std::string http_endpoint_auth = "authentication"
 

Detailed Description

Definition at line 32 of file http_lib_connection.h.

Constructor & Destructor Documentation

◆ HTTP_LIB_CONNECTION()

HTTP_LIB_CONNECTION::HTTP_LIB_CONNECTION ( const HTTP_LIB_SOURCE aSource,
bool  aTestConnectionNow 
)

Definition at line 37 of file http_lib_connection.cpp.

References m_source, and ValidateHTTPLibraryEndpoints().

◆ ~HTTP_LIB_CONNECTION()

HTTP_LIB_CONNECTION::~HTTP_LIB_CONNECTION ( )

Definition at line 48 of file http_lib_connection.cpp.

Member Function Documentation

◆ boolFromString()

bool HTTP_LIB_CONNECTION::boolFromString ( const std::any &  aVal,
bool  aDefaultValue = false 
)
private

Definition at line 383 of file http_lib_connection.cpp.

Referenced by SelectOne().

◆ checkServerResponse()

bool HTTP_LIB_CONNECTION::checkServerResponse ( std::unique_ptr< KICAD_CURL_EASY > &  aCurl)
private

◆ createCurlEasyObject()

std::unique_ptr< KICAD_CURL_EASY > HTTP_LIB_CONNECTION::createCurlEasyObject ( )
inlineprivate

◆ getCachedParts()

auto HTTP_LIB_CONNECTION::getCachedParts ( )
inline

Definition at line 63 of file http_lib_connection.h.

References m_cache.

◆ getCategories()

std::vector< HTTP_LIB_CATEGORY > HTTP_LIB_CONNECTION::getCategories ( ) const
inline

Definition at line 61 of file http_lib_connection.h.

References m_categories.

◆ GetLastError()

std::string HTTP_LIB_CONNECTION::GetLastError ( ) const
inline

Definition at line 59 of file http_lib_connection.h.

References m_lastError.

◆ httpErrorCodeDescription()

wxString HTTP_LIB_CONNECTION::httpErrorCodeDescription ( uint16_t  aHttpCode)
private

Definition at line 424 of file http_lib_connection.cpp.

Referenced by checkServerResponse().

◆ IsValidEndpoint()

bool HTTP_LIB_CONNECTION::IsValidEndpoint ( ) const

Definition at line 109 of file http_lib_connection.cpp.

References m_endpointValid.

Referenced by SelectAll(), SelectOne(), and syncCategories().

◆ SelectAll()

bool HTTP_LIB_CONNECTION::SelectAll ( const HTTP_LIB_CATEGORY aCategory,
std::vector< HTTP_LIB_PART > &  aParts 
)

Retrieves all parts from a specific category from the HTTP library.

Parameters
aPkis the primary key of the category
aResultswill be filled with all parts in that category
Returns
true if the query succeeded and at least one part was found, false otherwise

Definition at line 300 of file http_lib_connection.cpp.

References _, createCurlEasyObject(), HTTP_LIB_PART::fields, http_endpoint_parts, HTTP_LIB_PART::id, HTTP_LIB_CATEGORY::id, IsValidEndpoint(), m_cache, m_lastError, m_source, HTTP_LIB_PART::name, res, HTTP_LIB_SOURCE::root_url, and traceHTTPLib.

◆ SelectOne()

bool HTTP_LIB_CONNECTION::SelectOne ( const std::string &  aPartID,
HTTP_LIB_PART aFetchedPart 
)

Retrieves a single part with full details from the HTTP library.

Parameters
aPkis the primary key of the part
aResultwill conatain the part if one was found
Returns
true if aResult was filled; false otherwise

Definition at line 170 of file http_lib_connection.cpp.

References _, boolFromString(), checkServerResponse(), createCurlEasyObject(), HTTP_LIB_PART::exclude_from_board, HTTP_LIB_PART::exclude_from_bom, HTTP_LIB_PART::exclude_from_sim, HTTP_LIB_PART::fields, http_endpoint_parts, HTTP_LIB_PART::id, IsValidEndpoint(), HTTP_LIB_PART::lastCached, m_cachedParts, m_lastError, m_source, HTTP_LIB_PART::name, res, HTTP_LIB_SOURCE::root_url, HTTP_LIB_PART::symbolIdStr, HTTP_LIB_SOURCE::timeout_parts, and traceHTTPLib.

◆ syncCategories()

◆ ValidateHTTPLibraryEndpoints()

bool HTTP_LIB_CONNECTION::ValidateHTTPLibraryEndpoints ( )
private

Member Data Documentation

◆ DEFAULT_TIMEOUT

const long HTTP_LIB_CONNECTION::DEFAULT_TIMEOUT = 10
static

Definition at line 35 of file http_lib_connection.h.

◆ http_endpoint_auth

const std::string HTTP_LIB_CONNECTION::http_endpoint_auth = "authentication"
private

Definition at line 110 of file http_lib_connection.h.

◆ http_endpoint_categories

const std::string HTTP_LIB_CONNECTION::http_endpoint_categories = "categories"
private

Definition at line 107 of file http_lib_connection.h.

Referenced by syncCategories(), and ValidateHTTPLibraryEndpoints().

◆ http_endpoint_parts

const std::string HTTP_LIB_CONNECTION::http_endpoint_parts = "parts"
private

Definition at line 108 of file http_lib_connection.h.

Referenced by SelectAll(), SelectOne(), and ValidateHTTPLibraryEndpoints().

◆ http_endpoint_settings

const std::string HTTP_LIB_CONNECTION::http_endpoint_settings = "settings"
private

Definition at line 109 of file http_lib_connection.h.

◆ m_cache

std::map<std::string, std::tuple<std::string, std::string> > HTTP_LIB_CONNECTION::m_cache
private

Definition at line 97 of file http_lib_connection.h.

Referenced by getCachedParts(), and SelectAll().

◆ m_cachedParts

std::map<std::string, HTTP_LIB_PART> HTTP_LIB_CONNECTION::m_cachedParts
private

Definition at line 94 of file http_lib_connection.h.

Referenced by SelectOne().

◆ m_categories

std::vector<HTTP_LIB_CATEGORY> HTTP_LIB_CONNECTION::m_categories
private

Definition at line 103 of file http_lib_connection.h.

Referenced by getCategories(), and syncCategories().

◆ m_endpointValid

bool HTTP_LIB_CONNECTION::m_endpointValid = false
private

Definition at line 99 of file http_lib_connection.h.

Referenced by IsValidEndpoint(), and ValidateHTTPLibraryEndpoints().

◆ m_lastError

std::string HTTP_LIB_CONNECTION::m_lastError
private

◆ m_parts

std::map<std::string, std::string> HTTP_LIB_CONNECTION::m_parts
private

Definition at line 105 of file http_lib_connection.h.

◆ m_source

HTTP_LIB_SOURCE HTTP_LIB_CONNECTION::m_source
private

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