mirror of
https://github.com/davidallendj/gdpm.git
synced 2025-12-20 03:27:02 -07:00
Small fixes
Updated CMakeLists.txt Updated README.md Updated bin/gdpm-test.sh Changed some constants defined in constants.hpp Added GDPM_TIMESTAMP_FORMAT configurable macro
This commit is contained in:
parent
1893c7c36b
commit
2b250d9a2d
11 changed files with 288 additions and 120 deletions
|
|
@ -287,6 +287,7 @@ namespace gdpm::cache{
|
|||
" download_hash='" + p.download_hash + "', " +
|
||||
" is_installed=" + fmt::to_string(p.is_installed) + ", "
|
||||
" install_path='" + p.install_path + "'"
|
||||
// " dependencies='" + p.dependencies + "'"
|
||||
" WHERE title='" + p.title + "' AND asset_id=" + fmt::to_string(p.asset_id)
|
||||
+ ";\n";
|
||||
}
|
||||
|
|
@ -387,6 +388,7 @@ namespace gdpm::cache{
|
|||
std::string to_values(const package_info& p){
|
||||
std::string p_values{};
|
||||
std::string p_title = p.title; /* need copy for utils::replace_all() */
|
||||
|
||||
p_values += fmt::to_string(p.asset_id) + ", ";
|
||||
p_values += "'" + p.type + "', ";
|
||||
p_values += "'" + utils::replace_all(p_title, "'", "''") + "', ";
|
||||
|
|
@ -413,4 +415,5 @@ namespace gdpm::cache{
|
|||
o += to_values(p);
|
||||
return o;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -34,7 +34,7 @@ namespace gdpm::package_manager{
|
|||
CURL *curl;
|
||||
CURLcode res;
|
||||
config::config_context config;
|
||||
rest_api::asset_list_context params;
|
||||
rest_api::rest_api_context params;
|
||||
command_e command;
|
||||
std::vector<std::string> packages;
|
||||
std::vector<std::string> opts;
|
||||
|
|
@ -83,7 +83,8 @@ namespace gdpm::package_manager{
|
|||
|
||||
|
||||
void install_packages(const std::vector<std::string>& package_titles){
|
||||
using namespace rapidjson;
|
||||
using namespace rapidjson;
|
||||
params.verbose = config.verbose;
|
||||
|
||||
/* Check if the package data is already stored in cache. If it is, there
|
||||
is no need to do a lookup to synchronize the local database since we
|
||||
|
|
@ -95,7 +96,6 @@ namespace gdpm::package_manager{
|
|||
cache if possible. */
|
||||
if(config.enable_sync){
|
||||
if(p_cache.empty()){
|
||||
log::info("Synchronizing database...");
|
||||
p_cache = synchronize_database(package_titles);
|
||||
p_cache = cache::get_package_info_by_title(package_titles);
|
||||
}
|
||||
|
|
@ -135,9 +135,10 @@ namespace gdpm::package_manager{
|
|||
/* Retrieve necessary asset data if it was found already in cache */
|
||||
Document doc;
|
||||
if(p.download_url.empty() || p.category.empty() || p.description.empty() || p.support_level.empty()){
|
||||
doc = rest_api::get_asset(url, p.asset_id, config.verbose);
|
||||
doc = rest_api::get_asset(url, p.asset_id, params);
|
||||
if(doc.HasParseError() || doc.IsNull()){
|
||||
log::error("Could not get a response from server. ({})", doc.GetParseError());
|
||||
log::println("");
|
||||
log::error("Error parsing HTTP response. (error code: {})", doc.GetParseError());
|
||||
return;
|
||||
}
|
||||
p.category = doc["category"].GetString();
|
||||
|
|
@ -286,36 +287,50 @@ namespace gdpm::package_manager{
|
|||
using namespace rapidjson;
|
||||
/* If no package titles provided, update everything and then exit */
|
||||
if(package_titles.empty()){
|
||||
|
||||
std::string url{constants::HostUrl};
|
||||
url += rest_api::endpoints::GET_AssetId;
|
||||
Document doc = rest_api::get_assets_list(url, params);
|
||||
if(doc.IsNull()){
|
||||
log::error("Could not get response from server. Aborting.");
|
||||
return;
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
/* Fetch remote asset data and compare to see if there are package updates */
|
||||
std::vector<package_info> p_updates = {};
|
||||
std::vector<std::string> p_updates = {};
|
||||
std::vector<package_info> p_cache = cache::get_package_info_by_title(package_titles);
|
||||
|
||||
std::string url{constants::HostUrl};
|
||||
url += rest_api::endpoints::GET_Asset;
|
||||
Document doc = rest_api::get_assets_list(url, params);
|
||||
log::println("Packages to update: ");
|
||||
for(const auto& p_title : p_updates)
|
||||
log::print(" {} ", p_title);
|
||||
log::println("");
|
||||
|
||||
if(doc.IsNull()){
|
||||
log::error("Could not get response from server. Aborting.");
|
||||
return;
|
||||
}
|
||||
|
||||
for(const auto& p : p_updates){
|
||||
for(const auto& o : doc["result"].GetArray()){
|
||||
size_t local_version = std::stoul(p.version);
|
||||
std::string remote_version_s = o[""].GetString();
|
||||
/* Check version information to see if packages need updates */
|
||||
for(const auto& p : p_cache){
|
||||
std::string url{constants::HostUrl};
|
||||
url += rest_api::endpoints::GET_AssetId;
|
||||
Document doc = rest_api::get_asset(url, p.asset_id);
|
||||
std::string remote_version = doc["version"].GetString();
|
||||
if(p.version != remote_version){
|
||||
p_updates.emplace_back(p.title);
|
||||
}
|
||||
}
|
||||
|
||||
if(!skip_prompt){
|
||||
if(!utils::prompt_user_yn("Do you want to update the following packages? (y/n)"))
|
||||
return;
|
||||
}
|
||||
|
||||
remove_packages(p_updates);
|
||||
install_packages(p_updates);
|
||||
}
|
||||
|
||||
|
||||
void search_for_packages(const std::vector<std::string> &package_titles){
|
||||
std::vector<package_info> p_cache = cache::get_package_info_by_title(package_titles);
|
||||
|
||||
if(!p_cache.empty()){
|
||||
|
||||
if(!p_cache.empty() && !config.enable_sync){
|
||||
print_package_list(p_cache);
|
||||
return;
|
||||
}
|
||||
|
|
@ -341,20 +356,25 @@ namespace gdpm::package_manager{
|
|||
}
|
||||
|
||||
|
||||
void list_installed_packages(){
|
||||
void list_information(const std::vector<std::string>& opts){
|
||||
using namespace rapidjson;
|
||||
using namespace std::filesystem;
|
||||
const path path{config.packages_dir};
|
||||
std::vector<package_info> p_installed = cache::get_installed_packages();
|
||||
if(p_installed.empty())
|
||||
using namespace std::filesystem;
|
||||
|
||||
if(opts.empty() || opts[0] == "packages"){
|
||||
const path path{config.packages_dir};
|
||||
std::vector<package_info> p_installed = cache::get_installed_packages();
|
||||
if(p_installed.empty())
|
||||
return;
|
||||
log::println("Installed packages:");
|
||||
print_package_list(p_installed);
|
||||
}
|
||||
else if(opts[0] == "remote-sources"){
|
||||
print_remote_sources();
|
||||
}
|
||||
else{
|
||||
log::error("Unrecognized subcommand. Use either 'packages' or 'remote-sources' instead.");
|
||||
return;
|
||||
log::println("Installed packages:");
|
||||
print_package_list(p_installed);
|
||||
}
|
||||
|
||||
|
||||
void read_package_contents(const std::string& package_title){
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -378,6 +398,11 @@ namespace gdpm::package_manager{
|
|||
void link_packages(const std::vector<std::string>& package_titles, const std::vector<std::string>& paths){
|
||||
using namespace std::filesystem;
|
||||
|
||||
if(paths.empty()){
|
||||
log::error("No path set. Use '--path' option to set a path.");
|
||||
return;
|
||||
}
|
||||
|
||||
std::vector<package_info> p_found = {};
|
||||
std::vector<package_info> p_cache = cache::get_package_info_by_title(package_titles);
|
||||
if(p_cache.empty()){
|
||||
|
|
@ -392,11 +417,16 @@ namespace gdpm::package_manager{
|
|||
}
|
||||
}
|
||||
|
||||
if(p_found.empty()){
|
||||
log::error("No packages found to link.");
|
||||
return;
|
||||
}
|
||||
|
||||
/* Get the storage paths for all packages to create symlinks */
|
||||
const path package_dir{config.packages_dir};
|
||||
for(const auto& p : p_found){
|
||||
for(const auto& path : paths){
|
||||
log::info("Creating symlink for \"{}\" package to {}", p.title, path + "/" + p.title);
|
||||
log::info_n("Creating symlink for \"{}\" package to '{}'...", p.title, path + "/" + p.title);
|
||||
// std::filesystem::path target{config.packages_dir + "/" + p.title};
|
||||
std::filesystem::path target = {current_path().string() + "/" + config.packages_dir + "/" + p.title};
|
||||
std::filesystem::path symlink_path{path + "/" + p.title};
|
||||
|
|
@ -407,6 +437,7 @@ namespace gdpm::package_manager{
|
|||
if(ec){
|
||||
log::error("Could not create symlink: {}", ec.message());
|
||||
}
|
||||
log::println("Done.");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -415,6 +446,11 @@ namespace gdpm::package_manager{
|
|||
void clone_packages(const std::vector<std::string>& package_titles, const std::vector<std::string>& paths){
|
||||
using namespace std::filesystem;
|
||||
|
||||
if(paths.empty()){
|
||||
log::error("No path set. Use '--path' option to set a path.");
|
||||
return;
|
||||
}
|
||||
|
||||
std::vector<package_info> p_found = {};
|
||||
std::vector<package_info> p_cache = cache::get_package_info_by_title(package_titles);
|
||||
if(p_cache.empty()){
|
||||
|
|
@ -429,6 +465,11 @@ namespace gdpm::package_manager{
|
|||
}
|
||||
}
|
||||
|
||||
if(p_found.empty()){
|
||||
log::error("No packages to clone.");
|
||||
return;
|
||||
}
|
||||
|
||||
/* Get the storage paths for all packages to create clones */
|
||||
const path package_dir{config.packages_dir};
|
||||
for(const auto& p : p_found){
|
||||
|
|
@ -463,12 +504,33 @@ namespace gdpm::package_manager{
|
|||
}
|
||||
|
||||
|
||||
/* TODO: Need to finish implementation...will do that when it's needed. */
|
||||
void delete_remote_repository(size_t index){
|
||||
auto& s = config.remote_sources;
|
||||
// std::erase(s, index);
|
||||
}
|
||||
|
||||
|
||||
std::vector<std::string> resolve_dependencies(const std::vector<std::string>& package_titles){
|
||||
std::vector<std::string> p_deps = {};
|
||||
std::vector<package_info> p_cache = cache::get_package_info_by_title(package_titles);
|
||||
|
||||
/* Build an graph of every thing to check then install in order */
|
||||
for(const auto& p : p_cache){
|
||||
if(p.dependencies.empty())
|
||||
continue;
|
||||
|
||||
/* Check if dependency has a dependency. If so, resolve those first. */
|
||||
for(const auto& d : p.dependencies){
|
||||
auto temp = resolve_dependencies({d.title});
|
||||
utils::move_if_not(temp, p_deps, [](const std::string& p){ return true; });
|
||||
}
|
||||
}
|
||||
|
||||
return p_deps;
|
||||
}
|
||||
|
||||
|
||||
cxxargs parse_arguments(int argc, char **argv){
|
||||
/* Parse command-line arguments using cxxopts */
|
||||
cxxopts::Options options(
|
||||
|
|
@ -490,7 +552,9 @@ namespace gdpm::package_manager{
|
|||
("sync", "Sync local database with remote server.")
|
||||
("add-remote", "Set a source repository.", cxxopts::value<std::string>()->default_value(constants::AssetRepo), "<url>")
|
||||
("delete-remote", "Remove a source repository from list.", cxxopts::value<std::string>(), "<url>")
|
||||
("remote", "One time remote source use. Source is not saved and override sources used in config.", cxxopts::value<std::vector<std::string>>(), "<url>")
|
||||
("h,help", "Print this message and exit.")
|
||||
("version", "Show the version and exit.")
|
||||
;
|
||||
options.parse_positional({"input"});
|
||||
options.add_options("Options")
|
||||
|
|
@ -517,9 +581,6 @@ namespace gdpm::package_manager{
|
|||
|
||||
|
||||
void handle_arguments(const cxxargs& args){
|
||||
auto _get_package_list = [](const cxxopts::ParseResult& result, const char *arg){
|
||||
return result[arg].as<std::vector<std::string>>();
|
||||
};
|
||||
const auto& result = args.result;
|
||||
const auto& options = args.options;
|
||||
|
||||
|
|
@ -538,6 +599,9 @@ namespace gdpm::package_manager{
|
|||
auto iter = std::find(config.remote_sources.begin(), config.remote_sources.end(), repo);
|
||||
if(iter != config.remote_sources.end())
|
||||
config.remote_sources.erase(iter);
|
||||
}
|
||||
if(result.count("remote")){
|
||||
|
||||
}
|
||||
if(result.count("file")){
|
||||
std::string path = result["file"].as<std::string>();
|
||||
|
|
@ -548,8 +612,8 @@ namespace gdpm::package_manager{
|
|||
opts = result["path"].as<std::vector<std::string>>();
|
||||
}
|
||||
if(result.count("sort")){
|
||||
rest_api::sort_e sort = rest_api::sort_e::none;
|
||||
std::string r = result["sort"].as<std::string>();
|
||||
rest_api::sort_e sort = rest_api::sort_e::none;
|
||||
if(r == "none") sort = rest_api::sort_e::none;
|
||||
else if(r == "rating") sort = rest_api::sort_e::rating;
|
||||
else if(r == "cost") sort = rest_api::sort_e::cost;
|
||||
|
|
@ -558,16 +622,16 @@ namespace gdpm::package_manager{
|
|||
params.sort = sort;
|
||||
}
|
||||
if(result.count("type")){
|
||||
rest_api::type_e type = rest_api::type_e::any;
|
||||
std::string r = result["type"].as<std::string>();
|
||||
rest_api::type_e type = rest_api::type_e::any;
|
||||
if(r == "any") type = rest_api::type_e::any;
|
||||
else if(r == "addon") type = rest_api::type_e::addon;
|
||||
else if(r == "project") type = rest_api::type_e::project;
|
||||
params.type = type;
|
||||
}
|
||||
if(result.count("support")){
|
||||
rest_api::support_e support = rest_api::support_e::all;
|
||||
std::string r = result["support"].as<std::string>();
|
||||
rest_api::support_e support = rest_api::support_e::all;
|
||||
if(r == "all") support = rest_api::support_e::all;
|
||||
else if(r == "official") support = rest_api::support_e::official;
|
||||
else if(r == "community") support = rest_api::support_e::community;
|
||||
|
|
@ -633,7 +697,7 @@ namespace gdpm::package_manager{
|
|||
else if(argv[0] == "update" || argv[0] == "--update") command = update;
|
||||
else if(argv[0] == "search" || argv[0] == "--search") command = search;
|
||||
else if(argv[0] == "list" || argv[0] == "-ls") command = list;
|
||||
else if (argv[0] == "link" || argv[0] == "--link") command = link;
|
||||
else if(argv[0] == "link" || argv[0] == "--link") command = link;
|
||||
else if(argv[0] == "clone" || argv[0] == "--clone") command = clone;
|
||||
else if(argv[0] == "clean" || argv[0] == "--clean") command = clean;
|
||||
else if(argv[0] == "sync" || argv[0] == "--sync") command = sync;
|
||||
|
|
@ -642,6 +706,9 @@ namespace gdpm::package_manager{
|
|||
else if(argv[0] == "help" || argv[0] == "-h" || argv[0] == "--help"){
|
||||
log::println("{}", options.help());
|
||||
}
|
||||
else{
|
||||
log::error("Unrecognized command. Try 'gdpm help' for more info.");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -652,7 +719,7 @@ namespace gdpm::package_manager{
|
|||
case remove: remove_packages(package_titles); break;
|
||||
case update: update_packages(package_titles); break;
|
||||
case search: search_for_packages(package_titles); break;
|
||||
case list: list_installed_packages(); break;
|
||||
case list: list_information(package_titles); break;
|
||||
/* ...opts are the paths here */
|
||||
case link: link_packages(package_titles, opts); break;
|
||||
case clone: clone_packages(package_titles, opts); break;
|
||||
|
|
@ -668,12 +735,12 @@ namespace gdpm::package_manager{
|
|||
|
||||
void print_package_list(const std::vector<package_info>& packages){
|
||||
for(const auto& p : packages){
|
||||
log::println("{}/{} {} id={}\n\t{}, Godot {}, {}, {}, Last Modified: {}",
|
||||
log::println("{}/{}/{} {} id={}\n\tGodot {}, {}, {}, Last Modified: {}",
|
||||
p.support_level,
|
||||
p.author,
|
||||
p.title,
|
||||
p.version,
|
||||
p.asset_id,
|
||||
p.author,
|
||||
p.godot_version,
|
||||
p.cost,
|
||||
p.category,
|
||||
|
|
@ -685,12 +752,12 @@ namespace gdpm::package_manager{
|
|||
|
||||
void print_package_list(const rapidjson::Document& json){
|
||||
for(const auto& o : json["result"].GetArray()){
|
||||
log::println("{}/{} {} id={}\n\t{}, Godot {}, {}, {}, Last Modified: {}",
|
||||
log::println("{}/{}/{} {} id={}\n\tGodot {}, {}, {}, Last Modified: {}",
|
||||
o["support_level"] .GetString(),
|
||||
o["author"] .GetString(),
|
||||
o["title"] .GetString(),
|
||||
o["version_string"] .GetString(),
|
||||
o["asset_id"] .GetString(),
|
||||
o["author"] .GetString(),
|
||||
o["godot_version"] .GetString(),
|
||||
o["cost"] .GetString(),
|
||||
o["category"] .GetString(),
|
||||
|
|
@ -699,6 +766,14 @@ namespace gdpm::package_manager{
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
void print_remote_sources(){
|
||||
log::println("Remote sources:");
|
||||
for(const auto& s : config.remote_sources){
|
||||
log::println("\t{}", s);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
std::vector<package_info> synchronize_database(const std::vector<std::string>& package_titles){
|
||||
using namespace rapidjson;
|
||||
|
|
@ -711,6 +786,7 @@ namespace gdpm::package_manager{
|
|||
int total_items = 0;
|
||||
int items_left = 0;
|
||||
|
||||
log::info_n("Sychronizing database...");
|
||||
do{
|
||||
/* Make the GET request to get page data and store it in the local
|
||||
package database. Also, check to see if we need to keep going. */
|
||||
|
|
@ -720,7 +796,7 @@ namespace gdpm::package_manager{
|
|||
params.page += 1;
|
||||
|
||||
if(doc.IsNull()){
|
||||
log::error("Could not get response from server. Aborting.");
|
||||
log::error("\nCould not get response from server. Aborting.");
|
||||
return {};
|
||||
}
|
||||
|
||||
|
|
@ -765,6 +841,8 @@ namespace gdpm::package_manager{
|
|||
|
||||
} while(items_left > 0);
|
||||
|
||||
log::println("Done.");
|
||||
|
||||
return cache::get_package_info_by_title(package_titles);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -27,8 +27,8 @@ namespace gdpm::rest_api{
|
|||
return false;
|
||||
}
|
||||
|
||||
asset_list_context make_context(type_e type, int category, support_e support, const std::string& filter, const std::string& user, const std::string& godot_version, int max_results, int page, sort_e sort, bool reverse, int verbose){
|
||||
asset_list_context params{
|
||||
rest_api_context make_context(type_e type, int category, support_e support, const std::string& filter, const std::string& user, const std::string& godot_version, int max_results, int page, sort_e sort, bool reverse, int verbose){
|
||||
rest_api_context params{
|
||||
.type = type,
|
||||
.category = category,
|
||||
.support = support,
|
||||
|
|
@ -58,7 +58,7 @@ namespace gdpm::rest_api{
|
|||
return d;
|
||||
}
|
||||
|
||||
std::string _get_type_string(type_e type){
|
||||
std::string to_string(type_e type){
|
||||
std::string _s{"type="};
|
||||
switch(type){
|
||||
case any: _s += "any"; break;
|
||||
|
|
@ -68,7 +68,7 @@ namespace gdpm::rest_api{
|
|||
return _s;
|
||||
}
|
||||
|
||||
std::string _get_support_string(support_e support){
|
||||
std::string to_string(support_e support){
|
||||
std::string _s{"support="};
|
||||
switch(support){
|
||||
case all: _s += "official+community+testing"; break;
|
||||
|
|
@ -79,7 +79,7 @@ namespace gdpm::rest_api{
|
|||
return _s;
|
||||
}
|
||||
|
||||
std::string _get_sort_string(sort_e sort){
|
||||
std::string to_string(sort_e sort){
|
||||
std::string _s{"sort="};
|
||||
switch(sort){
|
||||
case none: _s += ""; break;
|
||||
|
|
@ -91,7 +91,21 @@ namespace gdpm::rest_api{
|
|||
return _s;
|
||||
}
|
||||
|
||||
void _print_params(const asset_list_context& params){
|
||||
std::string _prepare_request(const std::string &url, const rest_api_context &c){
|
||||
std::string request_url{url};
|
||||
request_url += to_string(c.type);
|
||||
request_url += (c.category <= 0) ? "&category=" : "&category="+fmt::to_string(c.category);
|
||||
request_url += "&" + to_string(c.support);
|
||||
request_url += "&" + to_string(c.sort);
|
||||
request_url += (!c.filter.empty()) ? "&filter="+c.filter : "";
|
||||
request_url += (!c.godot_version.empty()) ? "&godot_version="+c.godot_version : "";
|
||||
request_url += "&max_results=" + fmt::to_string(c.max_results);
|
||||
request_url += "&page=" + fmt::to_string(c.page);
|
||||
request_url += (c.reverse) ? "&reverse" : "";
|
||||
return request_url;
|
||||
}
|
||||
|
||||
void _print_params(const rest_api_context& params){
|
||||
log::println("params: \n"
|
||||
"\ttype: {}\n"
|
||||
"\tcategory: {}\n"
|
||||
|
|
@ -108,10 +122,9 @@ namespace gdpm::rest_api{
|
|||
);
|
||||
}
|
||||
|
||||
|
||||
rapidjson::Document configure(const std::string& url, type_e type, int verbose){
|
||||
std::string request_url{url};
|
||||
request_url += _get_type_string(type);
|
||||
request_url += to_string(type);
|
||||
http::response r = http::request_get(url);
|
||||
if(verbose > 0)
|
||||
log::info("URL: {}", url);
|
||||
|
|
@ -119,34 +132,35 @@ namespace gdpm::rest_api{
|
|||
}
|
||||
|
||||
rapidjson::Document get_assets_list(const std::string& url, type_e type, int category, support_e support, const std::string& filter,const std::string& user, const std::string& godot_version, int max_results, int page, sort_e sort, bool reverse, int verbose){
|
||||
std::string request_url{url};
|
||||
request_url += _get_type_string(type);
|
||||
request_url += (category <= 0) ? "&category=" : "&category="+fmt::to_string(category);
|
||||
request_url += "&" + _get_support_string(support);
|
||||
request_url += "&" + _get_sort_string(sort);
|
||||
request_url += (!filter.empty()) ? "&filter="+filter : "";
|
||||
request_url += (!godot_version.empty()) ? "&godot_version="+godot_version : "";
|
||||
request_url += "&max_results=" + fmt::to_string(max_results);
|
||||
request_url += "&page=" + fmt::to_string(page);
|
||||
request_url += (reverse) ? "&reverse" : "";
|
||||
rest_api_context c{
|
||||
.type = type,
|
||||
.category = category,
|
||||
.support = support,
|
||||
.filter = filter,
|
||||
.user = user,
|
||||
.godot_version = godot_version,
|
||||
.max_results = max_results,
|
||||
.page = page,
|
||||
.sort = sort,
|
||||
.reverse = reverse,
|
||||
.verbose = verbose
|
||||
};
|
||||
return get_assets_list(url, c);
|
||||
}
|
||||
|
||||
rapidjson::Document get_assets_list(const std::string& url, const rest_api_context& c){
|
||||
std::string request_url = _prepare_request(url, c);
|
||||
http::response r = http::request_get(request_url);
|
||||
if(verbose > 0)
|
||||
if(c.verbose > 0)
|
||||
log::info("URL: {}", request_url);
|
||||
return _parse_json(r.body, verbose);
|
||||
return _parse_json(r.body, c.verbose);
|
||||
}
|
||||
|
||||
rapidjson::Document get_assets_list(const std::string& url, const asset_list_context& params){
|
||||
return get_assets_list(
|
||||
url, params.type, params.category, params.support, params.filter, params.user, params.godot_version, params.max_results, params.page, params.sort, params.reverse, params.verbose
|
||||
);
|
||||
}
|
||||
|
||||
rapidjson::Document get_asset(const std::string& url, int asset_id, int verbose){
|
||||
std::string request_url{url};
|
||||
request_url = utils::replace_all(request_url, "{id}", fmt::to_string(asset_id));
|
||||
rapidjson::Document get_asset(const std::string& url, int asset_id, const rest_api_context& params){
|
||||
std::string request_url = _prepare_request(url, params);
|
||||
utils::replace_all(request_url, "{id}", std::to_string(asset_id));
|
||||
http::response r = http::request_get(request_url.c_str());
|
||||
if(verbose > 0)
|
||||
if(params.verbose > 0)
|
||||
log::info("URL: {}", request_url);
|
||||
return _parse_json(r.body);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue