launchpadlib-cpp/src/archive_permission.h

72 lines
1.9 KiB
C++

// 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_PERMISSION_H
#define ARCHIVE_PERMISSION_H
#include <string>
#include <optional>
#include <nlohmann/json.hpp>
#include <generator>
#include "distro_series.h"
#ifndef LAUNCHPAD_API
#ifdef BUILDING_LAUNCHPAD
#define LAUNCHPAD_API __attribute__((visibility("default")))
#else
#define LAUNCHPAD_API
#endif
#endif
class launchpad;
class archive_permission {
public:
archive_permission();
~archive_permission();
static std::optional<archive_permission> parse(const std::string& json_data);
void set_lp(launchpad* lp_ptr);
std::string archive_link;
std::string component_name;
std::string date_created;
std::string distro_series_name;
std::string distroseries_link;
bool explicit_;
std::string package_set_name;
std::string permission;
std::string person_link;
std::string pocket;
std::string source_package_name;
std::string http_etag;
std::string resource_type_link;
std::string self_link;
std::optional<archive_permission> get() const;
bool patch(const nlohmann::json& data) const;
bool put(const nlohmann::json& data) const;
std::generator<distro_series> getDistroSeries() const;
private:
void parse_json(const std::string& json_data);
launchpad* lp;
};
#endif