From 414275728408b0ad755fffba3d0e0cd1c2e3ca3f Mon Sep 17 00:00:00 2001 From: Simon Quigley Date: Sun, 15 Dec 2024 21:43:19 -0600 Subject: [PATCH] Add support for distribution::getSeries() --- src/distribution.cpp | 18 ++++++++++++++++++ src/distribution.h | 4 ++++ 2 files changed, 22 insertions(+) diff --git a/src/distribution.cpp b/src/distribution.cpp index feabb77..be3be9a 100644 --- a/src/distribution.cpp +++ b/src/distribution.cpp @@ -68,6 +68,24 @@ void distribution::parse_json(const std::string& json_data) { } } +std::optional distribution::getSeries(const std::string& name_or_version) { + std::map params = { + {"name_or_version", name_or_version}, + {"ws.op", "getSeries"} + }; + auto response = lp->api_get(self_link, params); + if (!response.has_value()) { + return std::nullopt; + } + + std::optional ds_opt = distro_series::parse(response.value()); + if (!ds_opt.has_value()) return std::nullopt; + + // Set lp in the returned archive + ds_opt->set_lp(lp); + return ds_opt; +} + void distribution::set_lp(launchpad* lp_ptr) { lp = lp_ptr; } diff --git a/src/distribution.h b/src/distribution.h index 9272564..9e66b5a 100644 --- a/src/distribution.h +++ b/src/distribution.h @@ -19,6 +19,7 @@ #include #include #include +#include "distro_series.h" #ifndef LAUNCHPAD_API #ifdef BUILDING_LAUNCHPAD @@ -38,6 +39,9 @@ public: // Static method to parse JSON data static std::optional parse(const std::string& json_data); + // Public functions + std::optional distribution::getSeries(const std::string& name_or_version); + // Public member variables std::string name; std::string description;