You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

226 lines
12 KiB

1 week ago
// Copyright (C) 2024 Simon Quigley <tsimonq2@ubuntu.com>
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <https://www.gnu.org/licenses/>.
#ifndef ARCHIVE_H
#define ARCHIVE_H
#include "source_package_publishing_history.h"
#include "archive_permission.h"
#include "binary_package_publishing_history.h"
#include "archive_dependency.h"
1 week ago
#include <generator>
#include <nlohmann/json.hpp>
#include <optional>
#include <string>
#include <vector>
#ifndef LAUNCHPAD_API
#ifdef BUILDING_LAUNCHPAD
#define LAUNCHPAD_API __attribute__((visibility("default")))
#else
#define LAUNCHPAD_API
#endif
#endif
1 week ago
class launchpad;
struct build_record {
nlohmann::json data;
};
1 week ago
class archive {
1 week ago
public:
archive();
~archive();
static std::optional<archive> parse(const std::string& json_data);
void parse_json(const std::string& json_data);
void set_lp(launchpad* lp_ptr);
int authorized_size;
bool build_debug_symbols;
std::string description;
std::string displayname;
std::string distribution_link;
std::string external_dependencies;
nlohmann::json metadata_overrides;
std::string name;
std::string owner_link;
bool permit_obsolete_series_uploads;
bool is_private;
bool publish;
bool publish_debug_symbols;
std::string publishing_method;
int relative_build_score;
std::string repository_format;
bool require_virtualized;
std::string signing_key_fingerprint;
bool suppress_subscription_notifications;
std::string owner_name;
std::string ppa_name;
std::string self_link;
std::string dependencies_collection_link;
std::string enabled_restricted_processors_collection_link;
std::string http_etag;
std::string processors_collection_link;
std::string reference;
std::string resource_type_link;
std::string status;
std::string web_link;
std::generator<source_package_publishing_history> getPublishedSources(const std::string& status) const;
std::generator<archive_permission> getAllPermissions() const;
std::optional<nlohmann::json> checkUpload(const std::string& component,
const std::string& distroseries,
const std::string& person,
const std::string& pocket,
const std::string& sourcepackagename,
bool strict_component = false) const;
std::optional<archive_dependency> getArchiveDependency(const std::string& dependency_link) const;
std::optional<nlohmann::json> getBuildCounters(bool include_needsbuild = false) const;
std::generator<build_record> getBuildRecords(const std::string& build_state = "",
const std::string& pocket = "",
const std::string& source_name = "") const;
std::optional<nlohmann::json> getBuildSummariesForSourceIds(const std::vector<std::string>& source_ids) const;
std::generator<archive_permission> getComponentsForQueueAdmin(const std::string& person_link) const;
std::optional<nlohmann::json> getNamedAuthToken(const std::string& name) const;
std::optional<nlohmann::json> getNamedAuthTokens(const std::vector<std::string>& names = {}) const;
std::generator<archive_permission> getPackagesetsForSource(const std::string& sourcepackagename,
bool direct_permissions = false) const;
std::generator<archive_permission> getPackagesetsForSourceUploader(const std::string& person_link,
const std::string& sourcepackagename) const;
std::generator<archive_permission> getPackagesetsForUploader(const std::string& person_link) const;
std::generator<archive_permission> getPermissionsForPerson(const std::string& person_link) const;
std::generator<archive_permission> getPocketsForQueueAdmin(const std::string& person_link) const;
std::generator<archive_permission> getPocketsForUploader(const std::string& person_link) const;
std::generator<binary_package_publishing_history> getPublishedBinaries(const std::string& binary_name = "",
const std::string& component_name = "",
const std::string& created_since_date = "",
const std::string& distro_arch_series = "",
bool exact_match = false,
bool order_by_date = false,
bool ordered = true,
const std::string& pocket = "",
const std::string& status = "",
const std::string& version = "") const;
std::generator<archive_permission> getQueueAdminsForComponent(const std::string& component_name) const;
std::generator<archive_permission> getQueueAdminsForPocket(const std::string& distroseries,
const std::string& pocket) const;
std::optional<std::string> getSigningKeyData() const;
std::generator<archive_permission> getUploadersForComponent(const std::string& component_name) const;
std::generator<archive_permission> getUploadersForPackage(const std::string& source_package_name) const;
std::generator<archive_permission> getUploadersForPackageset(const std::string& packageset,
bool direct_permissions = false) const;
std::generator<archive_permission> getUploadersForPocket(const std::string& pocket) const;
std::optional<bool> isSourceUploadAllowed(const std::string& distroseries,
const std::string& person,
const std::string& sourcepackagename) const;
// Custom POST methods
std::optional<archive_dependency> addArchiveDependency(const std::string& dependency_link,
const std::string& component,
const std::string& pocket) const;
bool copyPackage(const std::string& from_archive,
const std::string& from_pocket,
const std::string& from_series,
bool include_binaries,
bool move,
std::optional<int> phased_update_percentage,
bool silent,
const std::string& source_name,
const std::string& sponsored,
const std::string& to_pocket,
const std::string& to_series,
bool unembargo,
const std::string& version,
bool auto_approve = false) const;
bool copyPackages(const std::string& from_archive,
const std::string& from_series,
bool include_binaries,
bool silent,
const std::vector<std::string>& source_names,
const std::string& sponsored,
const std::string& to_pocket,
const std::string& to_series,
bool unembargo,
bool auto_approve = false) const;
bool deleteComponentUploader(const std::string& component_name,
const std::string& person) const;
bool deletePackageUploader(const std::string& person,
const std::string& source_package_name) const;
bool deletePackagesetUploader(const std::string& packageset,
const std::string& person,
bool explicit_) const;
bool deletePocketQueueAdmin(const std::string& distroseries,
const std::string& person,
const std::string& pocket) const;
bool deletePocketUploader(const std::string& person,
const std::string& pocket) const;
bool deleteQueueAdmin(const std::string& component_name,
const std::string& person) const;
bool enableRestrictedProcessor(const std::string& processor) const;
bool markSuiteDirty(const std::string& distroseries,
const std::string& pocket) const;
std::optional<archive_permission> newComponentUploader(const std::string& component_name,
const std::string& person) const;
std::optional<nlohmann::json> newNamedAuthToken(const std::string& name,
const std::optional<std::string>& token) const;
std::optional<nlohmann::json> newNamedAuthTokens(const std::vector<std::string>& names) const;
std::optional<archive_permission> newPackageUploader(const std::string& person,
const std::string& source_package_name) const;
std::optional<archive_permission> newPackagesetUploader(const std::string& packageset,
const std::string& person,
bool explicit_) const;
std::optional<archive_permission> newPocketQueueAdmin(const std::string& distroseries,
const std::string& person,
const std::string& pocket) const;
std::optional<archive_permission> newPocketUploader(const std::string& person,
const std::string& pocket) const;
std::optional<archive_permission> newQueueAdmin(const std::string& component_name,
const std::string& person) const;
std::optional<nlohmann::json> newSubscription(const std::string& subscriber,
const std::optional<std::string>& date_expires,
const std::optional<std::string>& description) const;
bool removeArchiveDependency(const std::string& dependency_link) const;
bool removeCopyNotification(const std::string& job_id) const;
bool revokeNamedAuthToken(const std::string& name) const;
bool revokeNamedAuthTokens(const std::vector<std::string>& names) const;
bool setProcessors(const std::vector<std::string>& processors) const;
bool syncSource(const std::string& from_archive,
bool include_binaries,
const std::string& source_name,
const std::string& to_pocket,
const std::string& to_series,
const std::string& version) const;
bool syncSources(const std::string& from_archive,
const std::string& from_series,
bool include_binaries,
const std::vector<std::string>& source_names,
const std::string& to_pocket,
const std::string& to_series) const;
bool uploadCIBuild(const std::string& ci_build,
const std::string& to_channel,
const std::string& to_pocket,
const std::string& to_series) const;
1 week ago
private:
std::string build_archive_endpoint() const;
launchpad* lp;
1 week ago
};
#endif // ARCHIVE_H