2022-06-15 18:25:13 +00:00
|
|
|
#pragma once
|
|
|
|
|
2022-06-29 20:44:05 +00:00
|
|
|
#include <Core/UUID.h>
|
2022-06-15 18:25:13 +00:00
|
|
|
#include <unordered_map>
|
2022-06-18 22:01:08 +00:00
|
|
|
#include <unordered_set>
|
2022-06-15 18:25:13 +00:00
|
|
|
|
|
|
|
|
|
|
|
namespace DB
|
|
|
|
{
|
|
|
|
class AccessControl;
|
|
|
|
enum class AccessEntityType;
|
|
|
|
struct IAccessEntity;
|
|
|
|
using AccessEntityPtr = std::shared_ptr<const IAccessEntity>;
|
2022-06-18 22:01:08 +00:00
|
|
|
class AccessRightsElements;
|
2022-06-29 20:44:05 +00:00
|
|
|
class IBackup;
|
|
|
|
using BackupPtr = std::shared_ptr<const IBackup>;
|
|
|
|
class IBackupEntry;
|
|
|
|
using BackupEntryPtr = std::shared_ptr<const IBackupEntry>;
|
|
|
|
struct RestoreSettings;
|
2022-06-15 18:25:13 +00:00
|
|
|
|
|
|
|
|
|
|
|
/// Makes a backup of access entities of a specified type.
|
2022-06-29 20:44:05 +00:00
|
|
|
std::pair<String, BackupEntryPtr> makeBackupEntryForAccess(
|
|
|
|
const std::vector<std::pair<UUID, AccessEntityPtr>> access_entities,
|
2022-06-15 18:25:13 +00:00
|
|
|
const String & data_path_in_backup,
|
2022-06-29 20:44:05 +00:00
|
|
|
size_t counter,
|
|
|
|
const AccessControl & access_control);
|
|
|
|
|
2022-06-15 18:25:13 +00:00
|
|
|
|
|
|
|
/// Restores access entities from a backup.
|
2022-06-29 20:44:05 +00:00
|
|
|
class AccessRestorerFromBackup
|
2022-06-15 18:25:13 +00:00
|
|
|
{
|
|
|
|
public:
|
2022-06-29 20:44:05 +00:00
|
|
|
AccessRestorerFromBackup(const BackupPtr & backup_, const RestoreSettings & restore_settings_);
|
|
|
|
~AccessRestorerFromBackup();
|
2022-06-15 18:25:13 +00:00
|
|
|
|
|
|
|
/// Adds a data path to loads access entities from.
|
2022-07-02 16:26:08 +00:00
|
|
|
void addDataPath(const String & data_path);
|
2022-06-18 22:01:08 +00:00
|
|
|
|
|
|
|
/// Checks that the current user can do restoring.
|
|
|
|
AccessRightsElements getRequiredAccess() const;
|
2022-06-15 18:25:13 +00:00
|
|
|
|
|
|
|
/// Inserts all access entities loaded from all the paths added by addDataPath().
|
2022-06-29 20:44:05 +00:00
|
|
|
std::vector<std::pair<UUID, AccessEntityPtr>> getAccessEntities(const AccessControl & access_control) const;
|
2022-06-15 18:25:13 +00:00
|
|
|
|
|
|
|
private:
|
|
|
|
BackupPtr backup;
|
2022-06-29 20:44:05 +00:00
|
|
|
bool allow_unresolved_access_dependencies = false;
|
|
|
|
std::vector<std::pair<UUID, AccessEntityPtr>> entities;
|
2022-06-15 18:25:13 +00:00
|
|
|
std::unordered_map<UUID, std::pair<String, AccessEntityType>> dependencies;
|
2022-06-18 22:01:08 +00:00
|
|
|
std::unordered_set<String> data_paths;
|
2022-06-15 18:25:13 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
}
|