ORE Studio 0.0.4
Loading...
Searching...
No Matches
session_entity.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_IAM_REPOSITORY_SESSION_ENTITY_HPP
21#define ORES_IAM_REPOSITORY_SESSION_ENTITY_HPP
22
23#include <string>
24#include <cstdint>
25#include <optional>
26#include "sqlgen/Timestamp.hpp"
27#include "sqlgen/PrimaryKey.hpp"
28
29namespace ores::iam::repository {
30
38 constexpr static const char* schema = "public";
39 constexpr static const char* tablename = "ores_iam_sessions_tbl";
40
44 sqlgen::PrimaryKey<std::string> id;
45
49 std::string tenant_id;
50
54 std::string account_id;
55
61 sqlgen::PrimaryKey<sqlgen::Timestamp<"%Y-%m-%d %H:%M:%S">> start_time;
62
70 std::string end_time;
71
75 std::string client_ip;
76
80 std::string client_identifier;
81
86
91
95 std::int64_t bytes_sent = 0;
96
100 std::int64_t bytes_received = 0;
101
105 std::string country_code;
106
110 std::string protocol = "binary";
111};
112
113std::ostream& operator<<(std::ostream& s, const session_entity& v);
114
119 constexpr static const char* schema = "public";
120 constexpr static const char* tablename = "ores_iam_session_stats_tbl";
121
122 std::string day;
123 std::string account_id;
124 std::int64_t session_count = 0;
125 double avg_duration_seconds = 0.0;
126 std::int64_t total_bytes_sent = 0;
127 std::int64_t total_bytes_received = 0;
128};
129
130std::ostream& operator<<(std::ostream& s, const session_statistics_entity& v);
131
136 constexpr static const char* schema = "public";
137 constexpr static const char* tablename = "ores_iam_session_samples_tbl";
138
142 sqlgen::PrimaryKey<std::string> session_id;
143
147 std::string tenant_id;
148
152 sqlgen::PrimaryKey<sqlgen::Timestamp<"%Y-%m-%d %H:%M:%S">> sample_time;
153
157 std::int64_t bytes_sent = 0;
158
162 std::int64_t bytes_received = 0;
163
167 std::int64_t latency_ms = 0;
168};
169
170std::ostream& operator<<(std::ostream& s, const session_sample_entity& v);
171
179 constexpr static const char* schema = "public";
180 constexpr static const char* tablename = "ores_iam_auth_events_tbl";
181
185 sqlgen::PrimaryKey<std::string> id;
186
190 sqlgen::PrimaryKey<sqlgen::Timestamp<"%Y-%m-%d %H:%M:%S">> event_time;
191
196 std::string tenant_id;
197
201 std::string account_id;
202
207 std::string event_type;
208
213 std::string username;
214
218 std::string session_id;
219
223 std::string party_id;
224
228 std::string error_detail;
229};
230
231std::ostream& operator<<(std::ostream& s, const auth_event_entity& v);
232
233}
234
235#endif
Database persistence layer for IAM domain types.
Definition account_entity.hpp:28
Represents a session record in the database.
Definition session_entity.hpp:37
std::string client_identifier
Client application identifier from handshake.
Definition session_entity.hpp:80
std::string client_ip
Client IP address (IPv4 or IPv6).
Definition session_entity.hpp:75
sqlgen::PrimaryKey< std::string > id
Session UUID - part of composite primary key.
Definition session_entity.hpp:44
sqlgen::PrimaryKey< sqlgen::Timestamp<"%Y-%m-%d %H:%M:%S"> > start_time
Session start timestamp - part of composite primary key.
Definition session_entity.hpp:61
std::int64_t bytes_sent
Total bytes sent to client.
Definition session_entity.hpp:95
std::string account_id
Foreign key to accounts table.
Definition session_entity.hpp:54
std::int64_t bytes_received
Total bytes received from client.
Definition session_entity.hpp:100
int client_version_major
Client protocol version major number.
Definition session_entity.hpp:85
std::string protocol
Protocol used for this session (binary or http).
Definition session_entity.hpp:110
std::string country_code
ISO 3166-1 alpha-2 country code.
Definition session_entity.hpp:105
int client_version_minor
Client protocol version minor number.
Definition session_entity.hpp:90
std::string end_time
Session end timestamp. Empty string if session is active.
Definition session_entity.hpp:70
std::string tenant_id
Tenant identifier for multi-tenancy isolation.
Definition session_entity.hpp:49
Entity for session statistics from continuous aggregates.
Definition session_entity.hpp:118
Entity for a single time-series sample in the session samples hypertable.
Definition session_entity.hpp:135
std::int64_t bytes_sent
Cumulative bytes sent at sample time.
Definition session_entity.hpp:157
sqlgen::PrimaryKey< sqlgen::Timestamp<"%Y-%m-%d %H:%M:%S"> > sample_time
Sample timestamp — part of composite primary key and partition column.
Definition session_entity.hpp:152
std::int64_t latency_ms
Round-trip time reported by the client in this ping, in milliseconds.
Definition session_entity.hpp:167
sqlgen::PrimaryKey< std::string > session_id
Session UUID — part of composite primary key.
Definition session_entity.hpp:142
std::int64_t bytes_received
Cumulative bytes received at sample time.
Definition session_entity.hpp:162
std::string tenant_id
Tenant identifier for multi-tenancy isolation (RLS).
Definition session_entity.hpp:147
Entity for a single authentication event in the auth events hypertable.
Definition session_entity.hpp:178
std::string session_id
Session UUID. Empty string if no session was established.
Definition session_entity.hpp:218
sqlgen::PrimaryKey< sqlgen::Timestamp<"%Y-%m-%d %H:%M:%S"> > event_time
Event timestamp — part of composite primary key and partition column.
Definition session_entity.hpp:190
sqlgen::PrimaryKey< std::string > id
UUID for this event — part of composite primary key.
Definition session_entity.hpp:185
std::string error_detail
Error detail for failure events. Empty string for success events.
Definition session_entity.hpp:228
std::string party_id
Party UUID. Empty string if no party was selected.
Definition session_entity.hpp:223
std::string event_type
Event type: login_success, login_failure, logout, token_refresh, max_session_exceeded,...
Definition session_entity.hpp:207
std::string username
Username associated with the event. May be empty for events without a resolved account.
Definition session_entity.hpp:213
std::string account_id
Account identifier. Empty string if unknown.
Definition session_entity.hpp:201
std::string tenant_id
Tenant identifier. Empty string if unknown (e.g. failed login before tenant resolution).
Definition session_entity.hpp:196