Compare commits
2 Commits
745c394940
...
39b73caea2
Author | SHA1 | Date | |
---|---|---|---|
39b73caea2 | |||
65fe1e54f5 |
@ -110,6 +110,8 @@ void archive::parse_json(const std::string& json_data) {
|
||||
}
|
||||
}
|
||||
|
||||
std::cout << "!!!!!! " << self_link << std::endl;
|
||||
|
||||
std::string link = owner_link;
|
||||
size_t pos = link.find("~");
|
||||
if (pos != std::string::npos) {
|
||||
@ -187,6 +189,7 @@ std::generator<source_package_publishing_history> archive::getPublishedSources(
|
||||
}
|
||||
}
|
||||
|
||||
std::cout << "Running a getPublishedSources() operation with " << self_link << "..." << std::endl;
|
||||
auto response = lp->api_get(self_link, params);
|
||||
if(!response) co_return;
|
||||
auto data = nlohmann::json::parse(response.value());
|
||||
|
@ -51,14 +51,7 @@ void build::parse_json(const std::string& json_data) {
|
||||
{"can_be_cancelled", [this](const nlohmann::json& val) { can_be_cancelled = val.get<bool>(); }},
|
||||
{"can_be_retried", [this](const nlohmann::json& val) { can_be_retried = val.get<bool>(); }},
|
||||
{"title", [this](const nlohmann::json& val) { title = val.get<std::string>(); }},
|
||||
{"self_link", [this](const nlohmann::json& val) {
|
||||
self_link = val.get<std::string>();
|
||||
std::regex rgx("/builds/(\\d+)");
|
||||
std::smatch match;
|
||||
if (std::regex_search(self_link, match, rgx)) {
|
||||
id = std::stol(match[1]);
|
||||
}
|
||||
}},
|
||||
{"self_link", [this](const nlohmann::json& val) { self_link = val.get<std::string>(); }},
|
||||
{"build_log_url", [this](const nlohmann::json& val) { build_log_url = val.get<std::string>(); }},
|
||||
{"upload_log_url", [this](const nlohmann::json& val) { upload_log_url = val.get<std::string>(); }},
|
||||
{"duration", [this](const nlohmann::json& val) { duration = val.get<std::string>(); }},
|
||||
@ -132,6 +125,7 @@ bool build::cancel() {
|
||||
if (self_link.empty()) return false;
|
||||
std::map<std::string, std::string> params;
|
||||
params["ws.op"] = "cancel";
|
||||
std::cout << "Running a cancel operation..." << std::endl;
|
||||
auto response = lp->api_post(self_link, params);
|
||||
return response.has_value();
|
||||
}
|
||||
|
@ -209,20 +209,22 @@ bool launchpad::is_authenticated() const {
|
||||
}
|
||||
|
||||
std::string launchpad::build_full_url(const std::string& endpoint) const {
|
||||
std::cout << "....!!!!!!!!!!!!! " << endpoint << std::endl;
|
||||
if (endpoint.rfind("http", 0) == 0) {
|
||||
return endpoint;
|
||||
} else if (endpoint != "") {
|
||||
} else if (!endpoint.empty()) {
|
||||
return service_root + "/" + api_version + "/" + endpoint;
|
||||
}
|
||||
std::cerr << "Internal error: endpoint is empty" << std::endl;
|
||||
return "";
|
||||
}
|
||||
|
||||
std::optional<std::string> launchpad::api_get(const std::string& endpoint, const std::map<std::string, std::string>& params) const {
|
||||
std::optional<std::string> launchpad::api_get(const std::string endpoint, const std::map<std::string, std::string> params) const {
|
||||
std::cout << "!!!!!!!!!!!!! " << endpoint << std::endl;
|
||||
std::string url = build_full_url(endpoint);
|
||||
if (url.empty()) {
|
||||
std::cerr << "Internal error: please include the following info in a bug report:" << std::endl;
|
||||
if (!params.empty()) {
|
||||
std::cerr << "Internal error: please include the following info in a bug report:" << std::endl;
|
||||
for (const auto& [key, value] : params) {
|
||||
std::cerr << url_encode(key) + "=" + url_encode(value) + "&";
|
||||
}
|
||||
@ -296,14 +298,14 @@ std::optional<std::string> launchpad::api_get(const std::string& endpoint, const
|
||||
}
|
||||
|
||||
std::optional<std::string> launchpad::api_post(
|
||||
const std::string& endpoint,
|
||||
const std::map<std::string, std::string>& params,
|
||||
const std::string endpoint,
|
||||
const std::map<std::string, std::string> params,
|
||||
bool build_endpoint,
|
||||
const std::string& token_secret_override
|
||||
const std::string token_secret_override
|
||||
) {
|
||||
if (endpoint.empty()) {
|
||||
std::cerr << "Internal error: please include the following info in a bug report:" << std::endl;
|
||||
if (!params.empty()) {
|
||||
std::cerr << "Internal error: please include the following info in a bug report:" << std::endl;
|
||||
for (const auto& [key, value] : params) {
|
||||
std::cerr << url_encode(key) + "=" + url_encode(value) + "&";
|
||||
}
|
||||
|
@ -69,11 +69,11 @@ public:
|
||||
// API Methods
|
||||
std::optional<archive> get_archive(const std::string& distribution_name);
|
||||
|
||||
std::optional<std::string> api_get(const std::string& endpoint = "", const std::map<std::string, std::string>& params = {}) const;
|
||||
std::optional<std::string> api_post(const std::string& endpoint = "",
|
||||
const std::map<std::string, std::string>& params = {},
|
||||
std::optional<std::string> api_get(const std::string endpoint = "", const std::map<std::string, std::string> params = {}) const;
|
||||
std::optional<std::string> api_post(const std::string endpoint = "",
|
||||
const std::map<std::string, std::string> params = {},
|
||||
bool build_endpoint = true,
|
||||
const std::string& token_secret_override = "");
|
||||
const std::string token_secret_override = "");
|
||||
std::optional<std::string> api_patch(const std::string& endpoint = "", const nlohmann::json& data = nlohmann::json{});
|
||||
std::optional<std::string> api_delete(const std::string& endpoint = "");
|
||||
|
||||
|
@ -59,6 +59,7 @@ std::generator<build> source_package_publishing_history::getBuilds() const {
|
||||
if (self_link.empty()) { co_return; }
|
||||
|
||||
std::map<std::string, std::string> params = {{"ws.op", "getBuilds"}};
|
||||
std::cout << "Running a getBuilds() operation..." << std::endl;
|
||||
auto response = lp->api_get(self_link, params);
|
||||
if (!response.has_value()) { co_return; }
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user