ORE Studio 0.0.4
Loading...
Searching...
No Matches
accounts_commands.hpp
1/* -*- mode: c++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
2 *
3 * Copyright (C) 2025 Marco Craveiro <marco.craveiro@gmail.com>
4 *
5 * This program is free software; you can redistribute it and/or modify it under
6 * the terms of the GNU General Public License as published by the Free Software
7 * Foundation; either version 3 of the License, or (at your option) any later
8 * version.
9 *
10 * This program is distributed in the hope that it will be useful, but WITHOUT
11 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
12 * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
13 * details.
14 *
15 * You should have received a copy of the GNU General Public License along with
16 * this program; if not, write to the Free Software Foundation, Inc., 51
17 * Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
18 *
19 */
20#ifndef ORES_SHELL_APP_COMMANDS_ACCOUNTS_COMMANDS_HPP
21#define ORES_SHELL_APP_COMMANDS_ACCOUNTS_COMMANDS_HPP
22
23#include <string>
24#include "ores.logging/make_logger.hpp"
25#include "ores.nats/service/nats_client.hpp"
26#include "ores.shell/app/pagination_context.hpp"
27
28namespace cli {
29
30class Menu;
31
32}
33
34namespace ores::shell::app::commands {
35
40private:
41 inline static std::string_view logger_name =
42 "ores.shell.app.commands.accounts_commands";
43
44 static auto& lg() {
45 using namespace ores::logging;
46 static auto instance = make_logger(logger_name);
47 return instance;
48 }
49
50public:
56 static void register_commands(cli::Menu& root_menu,
58 pagination_context& pagination);
59
73 static void process_create_account(std::ostream& out,
75 std::string principal, std::string password, std::string totp_secret,
76 std::string email);
77
87 static void process_list_accounts(std::ostream& out,
89 pagination_context& pagination);
90
102 static void process_login(std::ostream& out,
104 std::string principal, std::string password);
105
115 static void process_lock_account(std::ostream& out,
117 std::string account_id);
118
128 static void process_unlock_account(std::ostream& out,
130 std::string account_id);
131
140 static void process_list_login_info(std::ostream& out,
142
151 static void process_logout(std::ostream& out,
153
167 static void process_bootstrap(std::ostream& out,
169 std::string principal, std::string password, std::string email);
170
180 static void process_list_sessions(std::ostream& out,
182 std::string account_id = "");
183
192 static void process_active_sessions(std::ostream& out,
194
204 static void process_session_stats(std::ostream& out,
206 int days = 30);
207
217 static void process_get_account_history(std::ostream& out,
219 std::string username);
220
233 static void process_account_info(std::ostream& out,
235 std::string username);
236};
237
238}
239
240#endif
Implements logging infrastructure for ORE Studio.
Definition boost_severity.hpp:28
Authenticated NATS client for both interactive and service-to-service use.
Definition nats_client.hpp:71
Manages commands related to accounts.
Definition accounts_commands.hpp:39
static void process_list_login_info(std::ostream &out, ores::nats::service::nats_client &session)
Process a list login info request.
Definition accounts_commands.cpp:421
static void process_logout(std::ostream &out, ores::nats::service::nats_client &session)
Process a logout request.
Definition accounts_commands.cpp:435
static void process_session_stats(std::ostream &out, ores::nats::service::nats_client &session, int days=30)
Process a session statistics request.
Definition accounts_commands.cpp:594
static void register_commands(cli::Menu &root_menu, ores::nats::service::nats_client &session, pagination_context &pagination)
Register account-related commands.
Definition accounts_commands.cpp:119
static void process_active_sessions(std::ostream &out, ores::nats::service::nats_client &session)
Process an active sessions request.
Definition accounts_commands.cpp:554
static void process_create_account(std::ostream &out, ores::nats::service::nats_client &session, std::string principal, std::string password, std::string totp_secret, std::string email)
Process a create account request.
Definition accounts_commands.cpp:393
static void process_list_sessions(std::ostream &out, ores::nats::service::nats_client &session, std::string account_id="")
Process a list sessions request.
Definition accounts_commands.cpp:490
static void process_login(std::ostream &out, ores::nats::service::nats_client &session, std::string principal, std::string password)
Process a login request.
Definition accounts_commands.cpp:289
static void process_list_accounts(std::ostream &out, ores::nats::service::nats_client &session, pagination_context &pagination)
Process a list accounts request.
Definition accounts_commands.cpp:252
static void process_lock_account(std::ostream &out, ores::nats::service::nats_client &session, std::string account_id)
Process a lock account request.
Definition accounts_commands.cpp:318
static void process_get_account_history(std::ostream &out, ores::nats::service::nats_client &session, std::string username)
Process a get account history request.
Definition accounts_commands.cpp:662
static void process_unlock_account(std::ostream &out, ores::nats::service::nats_client &session, std::string account_id)
Process an unlock account request.
Definition accounts_commands.cpp:356
static void process_bootstrap(std::ostream &out, ores::nats::service::nats_client &session, std::string principal, std::string password, std::string email)
Process a bootstrap request.
Definition accounts_commands.cpp:459
static void process_account_info(std::ostream &out, ores::nats::service::nats_client &session, std::string username)
Process an account info request.
Definition accounts_commands.cpp:698
Manages pagination state across shell commands.
Definition pagination_context.hpp:51