Remove many getter functions

main
Simon Quigley 1 week ago
parent d7b755c248
commit e547684f45

@ -127,234 +127,10 @@ void archive::parse_json(const std::string& json_data) {
}
}
std::optional<int> archive::getAuthorizedSize() const {
return authorized_size;
}
std::optional<bool> archive::getBuildDebugSymbols() const {
return build_debug_symbols;
}
std::optional<std::string> archive::getDescription() const {
return description.empty()?std::nullopt:std::optional<std::string>(description);
}
std::optional<std::string> archive::getDisplayName() const {
return displayname.empty()?std::nullopt:std::optional<std::string>(displayname);
}
std::optional<std::string> archive::getDistributionLink() const {
return distribution_link.empty()?std::nullopt:std::optional<std::string>(distribution_link);
}
std::optional<std::string> archive::getExternalDependencies() const {
return external_dependencies.empty()?std::nullopt:std::optional<std::string>(external_dependencies);
}
std::optional<nlohmann::json> archive::getMetadataOverrides() const {
return metadata_overrides.empty()?std::nullopt:std::optional<nlohmann::json>(metadata_overrides);
}
std::optional<std::string> archive::getName() const {
return name.empty()?std::nullopt:std::optional<std::string>(name);
}
std::optional<std::string> archive::getOwnerLink() const {
return owner_link.empty()?std::nullopt:std::optional<std::string>(owner_link);
}
std::optional<bool> archive::getPermitObsoleteSeriesUploads() const {
return permit_obsolete_series_uploads;
}
std::optional<bool> archive::getPrivate() const {
return is_private;
}
std::optional<bool> archive::getPublish() const {
return publish;
}
std::optional<bool> archive::getPublishDebugSymbols() const {
return publish_debug_symbols;
}
std::optional<std::string> archive::getPublishingMethod() const {
return publishing_method.empty()?std::nullopt:std::optional<std::string>(publishing_method);
}
std::optional<int> archive::getRelativeBuildScore() const {
return relative_build_score;
}
std::optional<std::string> archive::getRepositoryFormat() const {
return repository_format.empty()?std::nullopt:std::optional<std::string>(repository_format);
}
std::optional<bool> archive::getRequireVirtualized() const {
return require_virtualized;
}
std::optional<std::string> archive::getSigningKeyFingerprint() const {
return signing_key_fingerprint.empty()?std::nullopt:std::optional<std::string>(signing_key_fingerprint);
}
std::optional<bool> archive::getSuppressSubscriptionNotifications() const {
return suppress_subscription_notifications;
}
std::optional<std::string> archive::getArchiveInfo() const {
return std::nullopt;
}
bool archive::setAuthorizedSize(int size) {
nlohmann::json update;
update["authorized_size"] = size;
return patchArchive(update);
}
bool archive::setBuildDebugSymbols(bool build) {
nlohmann::json update;
update["build_debug_symbols"] = build;
return patchArchive(update);
}
bool archive::setDescription(const std::string& desc) {
nlohmann::json update;
update["description"] = desc;
return patchArchive(update);
}
bool archive::setDisplayName(const std::string& name_) {
nlohmann::json update;
update["displayname"] = name_;
return patchArchive(update);
}
bool archive::setDistributionLink(const std::string& link) {
nlohmann::json update;
update["distribution_link"] = link;
return patchArchive(update);
}
bool archive::setExternalDependencies(const std::string& deps) {
nlohmann::json update;
update["external_dependencies"] = deps;
return patchArchive(update);
}
bool archive::setMetadataOverrides(const nlohmann::json& overrides) {
nlohmann::json update;
update["metadata_overrides"] = overrides;
return patchArchive(update);
}
bool archive::setName(const std::string& name_) {
nlohmann::json update;
update["name"] = name_;
return patchArchive(update);
}
bool archive::setOwnerLink(const std::string& link) {
nlohmann::json update;
update["owner_link"] = link;
return patchArchive(update);
}
bool archive::setPermitObsoleteSeriesUploads(bool permit) {
nlohmann::json update;
update["permit_obsolete_series_uploads"] = permit;
return patchArchive(update);
}
bool archive::setPrivate(bool is_private_) {
nlohmann::json update;
update["private"] = is_private_;
return patchArchive(update);
}
bool archive::setPublish(bool publish_) {
nlohmann::json update;
update["publish"] = publish_;
return patchArchive(update);
}
bool archive::setPublishDebugSymbols(bool publish_debug_) {
nlohmann::json update;
update["publish_debug_symbols"] = publish_debug_;
return patchArchive(update);
}
bool archive::setPublishingMethod(const std::string& method) {
nlohmann::json update;
update["publishing_method"] = method;
return patchArchive(update);
}
bool archive::setRelativeBuildScore(int score) {
nlohmann::json update;
update["relative_build_score"] = score;
return patchArchive(update);
}
bool archive::setRepositoryFormat(const std::string& format) {
nlohmann::json update;
update["repository_format"] = format;
return patchArchive(update);
}
bool archive::setRequireVirtualized(bool require_) {
nlohmann::json update;
update["require_virtualized"] = require_;
return patchArchive(update);
}
bool archive::setSigningKeyFingerprint(const std::string& fingerprint) {
nlohmann::json update;
update["signing_key_fingerprint"] = fingerprint;
return patchArchive(update);
}
bool archive::setSuppressSubscriptionNotifications(bool suppress) {
nlohmann::json update;
update["suppress_subscription_notifications"] = suppress;
return patchArchive(update);
}
std::string archive::build_archive_endpoint() const {
return "~" + url_encode(owner_name) + "/" + url_encode(ppa_name);
}
bool archive::patchArchive(const nlohmann::json& update_fields) {
if (!lp) {
std::cerr << "LP not set in archive::patchArchive.\n";
return false;
}
std::string endpoint = build_archive_endpoint();
auto response = lp->api_patch(endpoint, update_fields);
return response.has_value();
}
bool archive::putArchive(const nlohmann::json& new_representation) {
if (!lp) {
std::cerr << "LP not set in archive::putArchive.\n";
return false;
}
std::string endpoint = build_archive_endpoint();
auto response = lp->api_patch(endpoint, new_representation);
return response.has_value();
}
bool archive::deleteArchive() {
if (!lp) {
std::cerr << "LP not set in archive::deleteArchive.\n";
return false;
}
std::string endpoint = build_archive_endpoint();
auto response = lp->api_delete(endpoint);
return response.has_value();
}
std::generator<source> archive::getPublishedSources(const std::string& status) const {
std::map<std::string, std::string> params;
params["ws.op"] = "getPublishedSources";

@ -40,53 +40,6 @@ public:
static std::optional<archive> parse(const std::string& json_data);
void parse_json(const std::string& json_data);
std::optional<int> getAuthorizedSize() const;
std::optional<bool> getBuildDebugSymbols() const;
std::optional<std::string> getDescription() const;
std::optional<std::string> getDisplayName() const;
std::optional<std::string> getDistributionLink() const;
std::optional<std::string> getExternalDependencies() const;
std::optional<nlohmann::json> getMetadataOverrides() const;
std::optional<std::string> getName() const;
std::optional<std::string> getOwnerLink() const;
std::optional<bool> getPermitObsoleteSeriesUploads() const;
std::optional<bool> getPrivate() const;
std::optional<bool> getPublish() const;
std::optional<bool> getPublishDebugSymbols() const;
std::optional<std::string> getPublishingMethod() const;
std::optional<int> getRelativeBuildScore() const;
std::optional<std::string> getRepositoryFormat() const;
std::optional<bool> getRequireVirtualized() const;
std::optional<std::string> getSigningKeyFingerprint() const;
std::optional<bool> getSuppressSubscriptionNotifications() const;
std::optional<std::string> getArchiveInfo() const;
std::generator<source> getPublishedSources(const std::string& status) const;
bool setAuthorizedSize(int size);
bool setBuildDebugSymbols(bool build);
bool setDescription(const std::string& desc);
bool setDisplayName(const std::string& name_);
bool setDistributionLink(const std::string& link);
bool setExternalDependencies(const std::string& deps);
bool setMetadataOverrides(const nlohmann::json& overrides);
bool setName(const std::string& name_);
bool setOwnerLink(const std::string& link);
bool setPermitObsoleteSeriesUploads(bool permit);
bool setPrivate(bool is_private_);
bool setPublish(bool publish_);
bool setPublishDebugSymbols(bool publish_debug_);
bool setPublishingMethod(const std::string& method);
bool setRelativeBuildScore(int score);
bool setRepositoryFormat(const std::string& format);
bool setRequireVirtualized(bool require_);
bool setSigningKeyFingerprint(const std::string& fingerprint);
bool setSuppressSubscriptionNotifications(bool suppress);
bool patchArchive(const nlohmann::json& update_fields);
bool putArchive(const nlohmann::json& new_representation);
bool deleteArchive();
void set_lp(launchpad* lp_ptr);
// New public member variables
@ -123,6 +76,9 @@ public:
std::string status;
std::string web_link;
// Public functions
std::generator<source> getPublishedSources(const std::string& status) const;
launchpad* lp;
private:

@ -64,18 +64,6 @@ void distribution::parse_json(const std::string& json_data) {
}
}
std::optional<std::string> distribution::getName() const {
return name.empty() ? std::nullopt : std::optional<std::string>(name);
}
std::optional<std::string> distribution::getDescription() const {
return description.empty() ? std::nullopt : std::optional<std::string>(description);
}
std::optional<std::string> distribution::getDisplayName() const {
return displayname.empty() ? std::nullopt : std::optional<std::string>(displayname);
}
void distribution::set_lp(launchpad* lp_ptr) {
lp = lp_ptr;
}

@ -38,11 +38,6 @@ public:
// Static method to parse JSON data
static std::optional<distribution> parse(const std::string& json_data);
// Getter methods for optional fields
std::optional<std::string> getName() const;
std::optional<std::string> getDescription() const;
std::optional<std::string> getDisplayName() const;
// Public member variables
std::string name;
std::string description;

@ -67,24 +67,8 @@ void person::parse_json(const std::string& json_data) {
}
}
std::optional<std::string> person::getName() const {
return name.empty() ? std::nullopt : std::optional<std::string>(name);
}
std::optional<std::string> person::getRealName() const {
return realname.empty() ? std::nullopt : std::optional<std::string>(realname);
}
std::optional<std::string> person::getWebLink() const {
return web_link.empty() ? std::nullopt : std::optional<std::string>(web_link);
}
std::optional<std::string> person::getEmail() const {
return email.empty() ? std::nullopt : std::optional<std::string>(email);
}
std::optional<archive> person::getPPAByName(distribution& distro, const std::string& name) {
std::string owner = getName().value();
std::string owner = name;
std::string endpoint = "~" + lp->url_encode(owner);
std::map<std::string, std::string> params = {
{"distribution", distro.self_link},

@ -40,12 +40,6 @@ public:
// Static parse method
static std::optional<person> parse(const std::string& json_data);
// Getter methods for optional fields
std::optional<std::string> getName() const;
std::optional<std::string> getRealName() const;
std::optional<std::string> getWebLink() const;
std::optional<std::string> getEmail() const;
// Get a PPA by name
std::optional<archive> getPPAByName(distribution& distribution, const std::string& name);

Loading…
Cancel
Save