#pragma once #include #include #include namespace DB { class AccessControl; enum class AccessEntityType; struct IAccessEntity; using AccessEntityPtr = std::shared_ptr; class AccessRightsElements; class IBackup; using BackupPtr = std::shared_ptr; class IBackupEntry; using BackupEntryPtr = std::shared_ptr; struct RestoreSettings; struct QualifiedTableName; /// Makes a backup of access entities of a specified type. std::pair makeBackupEntryForAccess( const std::vector> access_entities, const String & data_path_in_backup, size_t counter, const AccessControl & access_control); /// Restores access entities from a backup. class AccessRestorerFromBackup { public: AccessRestorerFromBackup(const BackupPtr & backup_, const RestoreSettings & restore_settings_); ~AccessRestorerFromBackup(); /// Adds a data path to loads access entities from. void addDataPath(const String & data_path, const QualifiedTableName & table_name_for_logs); /// Checks that the current user can do restoring. AccessRightsElements getRequiredAccess() const; /// Inserts all access entities loaded from all the paths added by addDataPath(). std::vector> getAccessEntities(const AccessControl & access_control) const; private: BackupPtr backup; bool allow_unresolved_access_dependencies = false; std::vector> entities; std::unordered_map> dependencies; std::unordered_set data_paths; }; }