20#ifndef ORES_ACCOUNTS_REPOSITORY_ACCOUNT_ROLE_REPOSITORY_HPP
21#define ORES_ACCOUNTS_REPOSITORY_ACCOUNT_ROLE_REPOSITORY_HPP
25#include <boost/uuid/uuid.hpp>
26#include <sqlgen/postgres.hpp>
27#include "ores.utility/log/make_logger.hpp"
28#include "ores.database/domain/context.hpp"
29#include "ores.accounts/domain/account_role.hpp"
30#include "ores.accounts/domain/role.hpp"
32namespace ores::accounts::repository {
39 inline static std::string_view logger_name =
40 "ores.accounts.repository.account_role_repository";
42 [[nodiscard]]
static auto& lg() {
44 static auto instance = make_logger(logger_name);
63 void write(
const std::vector<domain::account_role>& account_roles);
74 std::vector<domain::account_role>
80 std::vector<domain::account_role>
88 bool exists(
const boost::uuids::uuid& account_id,
89 const boost::uuids::uuid& role_id);
94 void remove(
const boost::uuids::uuid& account_id,
95 const boost::uuids::uuid& role_id);
108 std::vector<std::string>
117 std::vector<domain::role>
Implements logging for ORE Studio.
Definition lifecycle_manager.hpp:30
Represents the assignment of a role to an account.
Definition account_role.hpp:36
Reads and writes account-role assignments to data storage.
Definition account_role_repository.hpp:37
void remove(const boost::uuids::uuid &account_id, const boost::uuids::uuid &role_id)
Removes a specific account-role assignment.
Definition account_role_repository.cpp:125
void write(const domain::account_role &account_role)
Writes account-role assignments to database.
Definition account_role_repository.cpp:45
std::vector< domain::account_role > read_latest_by_role(const boost::uuids::uuid &role_id)
Reads all accounts assigned to a specific role.
Definition account_role_repository.cpp:88
std::vector< std::string > read_effective_permissions(const boost::uuids::uuid &account_id)
Gets all effective permission codes for an account in a single query.
Definition account_role_repository.cpp:157
bool exists(const boost::uuids::uuid &account_id, const boost::uuids::uuid &role_id)
Checks if a specific account-role assignment exists.
Definition account_role_repository.cpp:102
std::vector< domain::account_role > read_latest_by_account(const boost::uuids::uuid &account_id)
Reads all roles assigned to a specific account.
Definition account_role_repository.cpp:73
std::string sql()
Returns the SQL created by sqlgen to construct the table.
Definition account_role_repository.cpp:38
std::vector< domain::role > read_roles_with_permissions(const boost::uuids::uuid &account_id)
Gets all roles assigned to an account with their permissions.
Definition account_role_repository.cpp:174
std::vector< domain::account_role > read_latest()
Reads all active account-role assignments.
Definition account_role_repository.cpp:61
void remove_all_for_account(const boost::uuids::uuid &account_id)
Removes all role assignments for an account.
Definition account_role_repository.cpp:142
Context for the operations on a postgres database.
Definition context.hpp:30