Simplify self_link for build
This commit is contained in:
parent
32a4d23784
commit
65fe1e54f5
@ -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_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>(); }},
|
{"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>(); }},
|
{"title", [this](const nlohmann::json& val) { title = val.get<std::string>(); }},
|
||||||
{"self_link", [this](const nlohmann::json& val) {
|
{"self_link", [this](const nlohmann::json& val) { self_link = val.get<std::string>(); }},
|
||||||
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]);
|
|
||||||
}
|
|
||||||
}},
|
|
||||||
{"build_log_url", [this](const nlohmann::json& val) { build_log_url = 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>(); }},
|
{"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>(); }},
|
{"duration", [this](const nlohmann::json& val) { duration = val.get<std::string>(); }},
|
||||||
|
@ -221,8 +221,8 @@ std::string launchpad::build_full_url(const std::string& endpoint) const {
|
|||||||
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::string url = build_full_url(endpoint);
|
std::string url = build_full_url(endpoint);
|
||||||
if (url.empty()) {
|
if (url.empty()) {
|
||||||
std::cerr << "Internal error: please include the following info in a bug report:" << std::endl;
|
|
||||||
if (!params.empty()) {
|
if (!params.empty()) {
|
||||||
|
std::cerr << "Internal error: please include the following info in a bug report:" << std::endl;
|
||||||
for (const auto& [key, value] : params) {
|
for (const auto& [key, value] : params) {
|
||||||
std::cerr << url_encode(key) + "=" + url_encode(value) + "&";
|
std::cerr << url_encode(key) + "=" + url_encode(value) + "&";
|
||||||
}
|
}
|
||||||
@ -302,8 +302,8 @@ std::optional<std::string> launchpad::api_post(
|
|||||||
const std::string& token_secret_override
|
const std::string& token_secret_override
|
||||||
) {
|
) {
|
||||||
if (endpoint.empty()) {
|
if (endpoint.empty()) {
|
||||||
std::cerr << "Internal error: please include the following info in a bug report:" << std::endl;
|
|
||||||
if (!params.empty()) {
|
if (!params.empty()) {
|
||||||
|
std::cerr << "Internal error: please include the following info in a bug report:" << std::endl;
|
||||||
for (const auto& [key, value] : params) {
|
for (const auto& [key, value] : params) {
|
||||||
std::cerr << url_encode(key) + "=" + url_encode(value) + "&";
|
std::cerr << url_encode(key) + "=" + url_encode(value) + "&";
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user