KiCad PCB EDA Suite
|
#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) |
Retrieve a single part with full details from the HTTP library. | |
bool | SelectAll (const HTTP_LIB_CATEGORY &aCategory, std::vector< HTTP_LIB_PART > &aParts) |
Retrieve all parts from a specific category from the HTTP library. | |
std::string | GetLastError () const |
std::vector< HTTP_LIB_CATEGORY > | getCategories () const |
std::string | getCategoryDescription (const std::string &aCategoryName) const |
auto & | getCachedParts () |
Static Public Attributes | |
static const long | DEFAULT_TIMEOUT = 10 |
Private Member Functions | |
std::unique_ptr< KICAD_CURL_EASY > | createCurlEasyObject () |
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) |
HTTP response status codes indicate whether a specific HTTP request has been successfully completed. | |
Private Attributes | |
HTTP_LIB_SOURCE | m_source |
std::map< std::string, HTTP_LIB_PART > | m_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_CATEGORY > | m_categories |
std::map< std::string, std::string > | m_categoryDescriptions |
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" |
Definition at line 33 of file http_lib_connection.h.
HTTP_LIB_CONNECTION::HTTP_LIB_CONNECTION | ( | const HTTP_LIB_SOURCE & | aSource, |
bool | aTestConnectionNow | ||
) |
Definition at line 38 of file http_lib_connection.cpp.
References m_source, and ValidateHTTPLibraryEndpoints().
HTTP_LIB_CONNECTION::~HTTP_LIB_CONNECTION | ( | ) |
Definition at line 49 of file http_lib_connection.cpp.
|
private |
Definition at line 393 of file http_lib_connection.cpp.
Referenced by SelectOne().
|
private |
Definition at line 379 of file http_lib_connection.cpp.
References _, httpErrorCodeDescription(), and m_lastError.
Referenced by SelectOne(), syncCategories(), and ValidateHTTPLibraryEndpoints().
|
inlineprivate |
Definition at line 77 of file http_lib_connection.h.
References m_source, and HTTP_LIB_SOURCE::token.
Referenced by SelectAll(), SelectOne(), syncCategories(), and ValidateHTTPLibraryEndpoints().
|
inline |
Definition at line 71 of file http_lib_connection.h.
References m_cache.
|
inline |
Definition at line 64 of file http_lib_connection.h.
References m_categories.
|
inline |
Definition at line 66 of file http_lib_connection.h.
References m_categoryDescriptions.
|
inline |
Definition at line 62 of file http_lib_connection.h.
References m_lastError.
|
private |
HTTP response status codes indicate whether a specific HTTP request has been successfully completed.
Responses are grouped in five classes:
Server error responses (500 ? 599)
see: https://developer.mozilla.org/en-US/docs/Web/HTTP/Status
Definition at line 424 of file http_lib_connection.cpp.
Referenced by checkServerResponse().
bool HTTP_LIB_CONNECTION::IsValidEndpoint | ( | ) | const |
Definition at line 110 of file http_lib_connection.cpp.
References m_endpointValid.
Referenced by SelectAll(), SelectOne(), and syncCategories().
bool HTTP_LIB_CONNECTION::SelectAll | ( | const HTTP_LIB_CATEGORY & | aCategory, |
std::vector< HTTP_LIB_PART > & | aParts | ||
) |
Retrieve all parts from a specific category from the HTTP library.
aPk | is the primary key of the category |
aResults | will be filled with all parts in that category |
Definition at line 310 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.
bool HTTP_LIB_CONNECTION::SelectOne | ( | const std::string & | aPartID, |
HTTP_LIB_PART & | aFetchedPart | ||
) |
Retrieve a single part with full details from the HTTP library.
aPk | is the primary key of the part |
aResult | will contain the part if one was found |
Definition at line 178 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.
|
private |
Definition at line 116 of file http_lib_connection.cpp.
References _, checkServerResponse(), createCurlEasyObject(), HTTP_LIB_CATEGORY::description, http_endpoint_categories, HTTP_LIB_CATEGORY::id, IsValidEndpoint(), m_categories, m_categoryDescriptions, m_lastError, m_source, HTTP_LIB_CATEGORY::name, res, HTTP_LIB_SOURCE::root_url, and traceHTTPLib.
Referenced by ValidateHTTPLibraryEndpoints().
|
private |
Definition at line 55 of file http_lib_connection.cpp.
References _, checkServerResponse(), createCurlEasyObject(), http_endpoint_categories, http_endpoint_parts, m_endpointValid, m_lastError, m_source, res, HTTP_LIB_SOURCE::root_url, syncCategories(), and traceHTTPLib.
Referenced by HTTP_LIB_CONNECTION().
|
static |
Definition at line 36 of file http_lib_connection.h.
|
private |
Definition at line 131 of file http_lib_connection.h.
|
private |
Definition at line 128 of file http_lib_connection.h.
Referenced by syncCategories(), and ValidateHTTPLibraryEndpoints().
|
private |
Definition at line 129 of file http_lib_connection.h.
Referenced by SelectAll(), SelectOne(), and ValidateHTTPLibraryEndpoints().
|
private |
Definition at line 130 of file http_lib_connection.h.
|
private |
Definition at line 117 of file http_lib_connection.h.
Referenced by getCachedParts(), and SelectAll().
|
private |
Definition at line 114 of file http_lib_connection.h.
Referenced by SelectOne().
|
private |
Definition at line 123 of file http_lib_connection.h.
Referenced by getCategories(), and syncCategories().
|
private |
Definition at line 124 of file http_lib_connection.h.
Referenced by getCategoryDescription(), and syncCategories().
|
private |
Definition at line 119 of file http_lib_connection.h.
Referenced by IsValidEndpoint(), and ValidateHTTPLibraryEndpoints().
|
private |
Definition at line 121 of file http_lib_connection.h.
Referenced by checkServerResponse(), GetLastError(), SelectAll(), SelectOne(), syncCategories(), and ValidateHTTPLibraryEndpoints().
|
private |
Definition at line 126 of file http_lib_connection.h.
|
private |
Definition at line 111 of file http_lib_connection.h.
Referenced by createCurlEasyObject(), HTTP_LIB_CONNECTION(), SelectAll(), SelectOne(), syncCategories(), and ValidateHTTPLibraryEndpoints().