From 2cbe2897a2e4fb061f74c39eb1e68706d6e82b9a Mon Sep 17 00:00:00 2001 From: Simon Quigley Date: Sun, 15 Dec 2024 22:54:04 -0600 Subject: [PATCH] Add support for many more optional arguments to archive::getPublishedSources --- src/archive.cpp | 36 ++++++++++++++++++++++--- src/archive.h | 12 ++++++++- src/binary_package_publishing_history.h | 2 +- 3 files changed, 44 insertions(+), 6 deletions(-) diff --git a/src/archive.cpp b/src/archive.cpp index 00f1b2d..c5d18aa 100644 --- a/src/archive.cpp +++ b/src/archive.cpp @@ -153,10 +153,38 @@ std::generator archive::getAllPermissions() const { } } -std::generator archive::getPublishedSources(const std::string& status) const { - std::map params; - params["ws.op"] = "getPublishedSources"; - params["status"] = status; +std::generator archive::getPublishedSources( + const std::string& component_name, + const std::string& created_since_date, + std::optional ds, + const bool exact_match, + const bool order_by_date, + const std::string& pocket, + const std::string& source_name, + const std::string& status, + const std::string& version +) const { + std::map params = { + {"exact_match", exact_match ? "true" : ""}, + {"order_by_date", order_by_date ? "true" : ""}, + {"distro_series", ds ? ds.value().self_link : ""}, + {"component_name", !component_name.empty() ? component_name : ""}, + {"created_since_date", !created_since_date.empty() ? created_since_date : ""}, + {"pocket", !pocket.empty() ? pocket : ""}, + {"source_name", !source_name.empty() ? source_name : ""}, + {"status", !status.empty() ? status : ""}, + {"version", !version.empty() ? version : ""} + }; + + // Remove empty entries + for (auto it = params.begin(); it != params.end(); ) { + if (it->second.empty()) { + it = params.erase(it); + } else { + ++it; + } + } + auto response = lp->api_get(self_link, params); if(!response) co_return; auto data = nlohmann::json::parse(response.value()); diff --git a/src/archive.h b/src/archive.h index cf0976a..e18d7ae 100644 --- a/src/archive.h +++ b/src/archive.h @@ -81,7 +81,17 @@ public: std::string status; std::string web_link; - std::generator getPublishedSources(const std::string& status) const; + std::generator getPublishedSources( + const std::string& component_name = "", + const std::string& created_since_date = "", + std::optional ds = std::nullopt, + const bool exact_match = false, + const bool order_by_date = false, + const std::string& pocket = "", + const std::string& source_name = "", + const std::string& status = "", + const std::string& version = "" + ) const; std::generator getAllPermissions() const; std::optional checkUpload(const std::string& component, diff --git a/src/binary_package_publishing_history.h b/src/binary_package_publishing_history.h index f4b5db2..1aebf18 100644 --- a/src/binary_package_publishing_history.h +++ b/src/binary_package_publishing_history.h @@ -55,7 +55,7 @@ public: std::string source_package_version; std::string status; - std::optional get() const; + std::optional get() const; bool patch(const nlohmann::json& data) const; bool put(const nlohmann::json& data) const;