ORE Studio 0.0.4
Loading...
Searching...
No Matches
account_protocol.hpp
1/* -*- mode: c++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
2 *
3 * Copyright (C) 2026 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_IAM_MESSAGING_ACCOUNT_PROTOCOL_HPP
21#define ORES_IAM_MESSAGING_ACCOUNT_PROTOCOL_HPP
22
23#include <string>
24#include <vector>
25#include "ores.iam.api/domain/account.hpp"
26#include "ores.iam.api/domain/login_info.hpp"
27
28namespace ores::iam::messaging {
29
30struct get_accounts_request {
31 int offset = 0;
32 int limit = 100;
33};
34
35struct get_accounts_response {
36 std::vector<ores::iam::domain::account> accounts;
37 int total_available_count = 0;
38};
39
40struct save_account_request {
41 using response_type = struct save_account_response;
42 static constexpr std::string_view nats_subject = "iam.v1.accounts.save";
43 std::string principal;
44 std::string password;
45 std::string totp_secret;
46 std::string email;
47 std::string account_type;
48};
49
50struct update_account_request {
51 using response_type = struct update_account_response;
52 static constexpr std::string_view nats_subject = "iam.v1.accounts.update";
53 std::string account_id;
54 std::string email;
55 std::string change_reason_code;
56 std::string change_commentary;
57};
58
59struct update_account_response {
60 bool success = false;
61 std::string message;
62};
63
64struct save_account_response {
65 bool success = false;
66 std::string message;
67 std::string account_id;
68};
69
70struct delete_account_request {
71 using response_type = struct delete_account_response;
72 static constexpr std::string_view nats_subject = "iam.v1.accounts.delete";
73 std::string account_id;
74};
75
76struct delete_account_response {
77 bool success = false;
78 std::string message;
79};
80
81struct account_operation_result {
82 bool success = false;
83 std::string message;
84};
85
86struct lock_account_request {
87 using response_type = struct lock_account_response;
88 static constexpr std::string_view nats_subject = "iam.v1.accounts.lock";
89 std::vector<std::string> account_ids;
90};
91
92struct lock_account_response {
93 std::vector<account_operation_result> results;
94};
95
96struct unlock_account_request {
97 using response_type = struct unlock_account_response;
98 static constexpr std::string_view nats_subject = "iam.v1.accounts.unlock";
99 std::vector<std::string> account_ids;
100};
101
102struct unlock_account_response {
103 std::vector<account_operation_result> results;
104};
105
106struct list_login_info_request {
107 using response_type = struct list_login_info_response;
108 static constexpr std::string_view nats_subject = "iam.v1.accounts.login-info";
109};
110
111struct list_login_info_response {
112 std::vector<ores::iam::domain::login_info> login_infos;
113};
114
115struct reset_password_request {
116 using response_type = struct reset_password_response;
117 static constexpr std::string_view nats_subject = "iam.v1.accounts.reset-password";
118 std::vector<std::string> account_ids;
119 std::string new_password;
120};
121
122struct reset_password_response {
123 bool success = false;
124 std::string message;
125 std::vector<account_operation_result> results;
126};
127
128struct change_password_request {
129 std::string current_password;
130 std::string new_password;
131};
132
133struct change_password_response {
134 bool success = false;
135 std::string message;
136};
137
138struct update_my_email_request {
139 using response_type = struct update_my_email_response;
140 static constexpr std::string_view nats_subject = "iam.v1.accounts.update-email";
141 std::string email;
142};
143
144struct update_my_email_response {
145 bool success = false;
146 std::string message;
147};
148
149struct select_party_request {
150 using response_type = struct select_party_response;
151 static constexpr std::string_view nats_subject = "iam.v1.accounts.select-party";
152 std::string party_id;
153};
154
155struct select_party_response {
156 bool success = false;
157 std::string message;
158 std::string token;
159 std::string username;
160 std::string tenant_name;
161 std::string party_name;
167 int access_lifetime_s = 1800;
168};
169
170struct get_accounts_request_typed {
171 using response_type = struct get_accounts_response;
172 static constexpr std::string_view nats_subject = "iam.v1.accounts.list";
173 int offset = 0;
174 int limit = 100;
175};
176
177struct change_password_request_typed {
178 using response_type = struct change_password_response;
179 static constexpr std::string_view nats_subject = "iam.v1.accounts.change-password";
180 std::string current_password;
181 std::string new_password;
182};
183
184}
185
186#endif