ORE Studio 0.0.4
Loading...
Searching...
No Matches
data_organization_protocol.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_DQ_MESSAGING_DATA_ORGANIZATION_PROTOCOL_HPP
21#define ORES_DQ_MESSAGING_DATA_ORGANIZATION_PROTOCOL_HPP
22
23#include <span>
24#include <iosfwd>
25#include <vector>
26#include <expected>
27#include "ores.comms/messaging/message_types.hpp"
28#include "ores.comms/messaging/message_traits.hpp"
29#include "ores.dq/domain/catalog.hpp"
30#include "ores.dq/domain/data_domain.hpp"
31#include "ores.dq/domain/subject_area.hpp"
32
33namespace ores::dq::messaging {
34
35// ============================================================================
36// Catalog Messages
37// ============================================================================
38
43 std::vector<std::byte> serialize() const;
44 static std::expected<get_catalogs_request,
45 ores::utility::serialization::error_code>
46 deserialize(std::span<const std::byte> data);
47};
48
49std::ostream& operator<<(std::ostream& s, const get_catalogs_request& v);
50
55 std::vector<domain::catalog> catalogs;
56
57 std::vector<std::byte> serialize() const;
58 static std::expected<get_catalogs_response,
59 ores::utility::serialization::error_code>
60 deserialize(std::span<const std::byte> data);
61};
62
63std::ostream& operator<<(std::ostream& s, const get_catalogs_response& v);
64
69 domain::catalog catalog;
70
71 std::vector<std::byte> serialize() const;
72 static std::expected<save_catalog_request,
73 ores::utility::serialization::error_code>
74 deserialize(std::span<const std::byte> data);
75};
76
77std::ostream& operator<<(std::ostream& s, const save_catalog_request& v);
78
83 bool success;
84 std::string message;
85
86 std::vector<std::byte> serialize() const;
87 static std::expected<save_catalog_response,
88 ores::utility::serialization::error_code>
89 deserialize(std::span<const std::byte> data);
90};
91
92std::ostream& operator<<(std::ostream& s, const save_catalog_response& v);
93
98 std::string name;
99 bool success;
100 std::string message;
101};
102
103std::ostream& operator<<(std::ostream& s, const delete_catalog_result& v);
104
109 std::vector<std::string> names;
110
111 std::vector<std::byte> serialize() const;
112 static std::expected<delete_catalog_request,
113 ores::utility::serialization::error_code>
114 deserialize(std::span<const std::byte> data);
115};
116
117std::ostream& operator<<(std::ostream& s, const delete_catalog_request& v);
118
123 std::vector<delete_catalog_result> results;
124
125 std::vector<std::byte> serialize() const;
126 static std::expected<delete_catalog_response,
127 ores::utility::serialization::error_code>
128 deserialize(std::span<const std::byte> data);
129};
130
131std::ostream& operator<<(std::ostream& s, const delete_catalog_response& v);
132
137 std::string name;
138
139 std::vector<std::byte> serialize() const;
140 static std::expected<get_catalog_history_request,
141 ores::utility::serialization::error_code>
142 deserialize(std::span<const std::byte> data);
143};
144
145std::ostream& operator<<(std::ostream& s, const get_catalog_history_request& v);
146
151 bool success;
152 std::string message;
153 std::vector<domain::catalog> versions;
154
155 std::vector<std::byte> serialize() const;
156 static std::expected<get_catalog_history_response,
157 ores::utility::serialization::error_code>
158 deserialize(std::span<const std::byte> data);
159};
160
161std::ostream& operator<<(std::ostream& s, const get_catalog_history_response& v);
162
163// ============================================================================
164// Data Domain Messages
165// ============================================================================
166
171 std::vector<std::byte> serialize() const;
172 static std::expected<get_data_domains_request,
173 ores::utility::serialization::error_code>
174 deserialize(std::span<const std::byte> data);
175};
176
177std::ostream& operator<<(std::ostream& s, const get_data_domains_request& v);
178
183 std::vector<domain::data_domain> domains;
184
185 std::vector<std::byte> serialize() const;
186 static std::expected<get_data_domains_response,
187 ores::utility::serialization::error_code>
188 deserialize(std::span<const std::byte> data);
189};
190
191std::ostream& operator<<(std::ostream& s, const get_data_domains_response& v);
192
197 domain::data_domain domain;
198
199 std::vector<std::byte> serialize() const;
200 static std::expected<save_data_domain_request,
201 ores::utility::serialization::error_code>
202 deserialize(std::span<const std::byte> data);
203};
204
205std::ostream& operator<<(std::ostream& s, const save_data_domain_request& v);
206
211 bool success;
212 std::string message;
213
214 std::vector<std::byte> serialize() const;
215 static std::expected<save_data_domain_response,
216 ores::utility::serialization::error_code>
217 deserialize(std::span<const std::byte> data);
218};
219
220std::ostream& operator<<(std::ostream& s, const save_data_domain_response& v);
221
226 std::string name;
227 bool success;
228 std::string message;
229};
230
231std::ostream& operator<<(std::ostream& s, const delete_data_domain_result& v);
232
237 std::vector<std::string> names;
238
239 std::vector<std::byte> serialize() const;
240 static std::expected<delete_data_domain_request,
241 ores::utility::serialization::error_code>
242 deserialize(std::span<const std::byte> data);
243};
244
245std::ostream& operator<<(std::ostream& s, const delete_data_domain_request& v);
246
251 std::vector<delete_data_domain_result> results;
252
253 std::vector<std::byte> serialize() const;
254 static std::expected<delete_data_domain_response,
255 ores::utility::serialization::error_code>
256 deserialize(std::span<const std::byte> data);
257};
258
259std::ostream& operator<<(std::ostream& s, const delete_data_domain_response& v);
260
265 std::string name;
266
267 std::vector<std::byte> serialize() const;
268 static std::expected<get_data_domain_history_request,
269 ores::utility::serialization::error_code>
270 deserialize(std::span<const std::byte> data);
271};
272
273std::ostream& operator<<(std::ostream& s, const get_data_domain_history_request& v);
274
279 bool success;
280 std::string message;
281 std::vector<domain::data_domain> versions;
282
283 std::vector<std::byte> serialize() const;
284 static std::expected<get_data_domain_history_response,
285 ores::utility::serialization::error_code>
286 deserialize(std::span<const std::byte> data);
287};
288
289std::ostream& operator<<(std::ostream& s, const get_data_domain_history_response& v);
290
291// ============================================================================
292// Subject Area Messages
293// ============================================================================
294
299 std::vector<std::byte> serialize() const;
300 static std::expected<get_subject_areas_request,
301 ores::utility::serialization::error_code>
302 deserialize(std::span<const std::byte> data);
303};
304
305std::ostream& operator<<(std::ostream& s, const get_subject_areas_request& v);
306
311 std::vector<domain::subject_area> subject_areas;
312
313 std::vector<std::byte> serialize() const;
314 static std::expected<get_subject_areas_response,
315 ores::utility::serialization::error_code>
316 deserialize(std::span<const std::byte> data);
317};
318
319std::ostream& operator<<(std::ostream& s, const get_subject_areas_response& v);
320
325 std::string domain_name;
326
327 std::vector<std::byte> serialize() const;
328 static std::expected<get_subject_areas_by_domain_request,
329 ores::utility::serialization::error_code>
330 deserialize(std::span<const std::byte> data);
331};
332
333std::ostream& operator<<(std::ostream& s, const get_subject_areas_by_domain_request& v);
334
339 std::vector<domain::subject_area> subject_areas;
340
341 std::vector<std::byte> serialize() const;
342 static std::expected<get_subject_areas_by_domain_response,
343 ores::utility::serialization::error_code>
344 deserialize(std::span<const std::byte> data);
345};
346
347std::ostream& operator<<(std::ostream& s, const get_subject_areas_by_domain_response& v);
348
353 domain::subject_area subject_area;
354
355 std::vector<std::byte> serialize() const;
356 static std::expected<save_subject_area_request,
357 ores::utility::serialization::error_code>
358 deserialize(std::span<const std::byte> data);
359};
360
361std::ostream& operator<<(std::ostream& s, const save_subject_area_request& v);
362
367 bool success;
368 std::string message;
369
370 std::vector<std::byte> serialize() const;
371 static std::expected<save_subject_area_response,
372 ores::utility::serialization::error_code>
373 deserialize(std::span<const std::byte> data);
374};
375
376std::ostream& operator<<(std::ostream& s, const save_subject_area_response& v);
377
381struct subject_area_key final {
382 std::string name;
383 std::string domain_name;
384};
385
386std::ostream& operator<<(std::ostream& s, const subject_area_key& v);
387
393 bool success;
394 std::string message;
395};
396
397std::ostream& operator<<(std::ostream& s, const delete_subject_area_result& v);
398
403 std::vector<subject_area_key> keys;
404
405 std::vector<std::byte> serialize() const;
406 static std::expected<delete_subject_area_request,
407 ores::utility::serialization::error_code>
408 deserialize(std::span<const std::byte> data);
409};
410
411std::ostream& operator<<(std::ostream& s, const delete_subject_area_request& v);
412
417 std::vector<delete_subject_area_result> results;
418
419 std::vector<std::byte> serialize() const;
420 static std::expected<delete_subject_area_response,
421 ores::utility::serialization::error_code>
422 deserialize(std::span<const std::byte> data);
423};
424
425std::ostream& operator<<(std::ostream& s, const delete_subject_area_response& v);
426
432
433 std::vector<std::byte> serialize() const;
434 static std::expected<get_subject_area_history_request,
435 ores::utility::serialization::error_code>
436 deserialize(std::span<const std::byte> data);
437};
438
439std::ostream& operator<<(std::ostream& s, const get_subject_area_history_request& v);
440
445 bool success;
446 std::string message;
447 std::vector<domain::subject_area> versions;
448
449 std::vector<std::byte> serialize() const;
450 static std::expected<get_subject_area_history_response,
451 ores::utility::serialization::error_code>
452 deserialize(std::span<const std::byte> data);
453};
454
455std::ostream& operator<<(std::ostream& s, const get_subject_area_history_response& v);
456
457}
458
459namespace ores::comms::messaging {
460
461// Catalog traits
462template<>
463struct message_traits<dq::messaging::get_catalogs_request> {
464 using request_type = dq::messaging::get_catalogs_request;
465 using response_type = dq::messaging::get_catalogs_response;
466 static constexpr message_type request_message_type =
467 message_type::get_catalogs_request;
468};
469
470template<>
471struct message_traits<dq::messaging::save_catalog_request> {
472 using request_type = dq::messaging::save_catalog_request;
473 using response_type = dq::messaging::save_catalog_response;
474 static constexpr message_type request_message_type =
475 message_type::save_catalog_request;
476};
477
478template<>
479struct message_traits<dq::messaging::delete_catalog_request> {
480 using request_type = dq::messaging::delete_catalog_request;
481 using response_type = dq::messaging::delete_catalog_response;
482 static constexpr message_type request_message_type =
483 message_type::delete_catalog_request;
484};
485
486template<>
487struct message_traits<dq::messaging::get_catalog_history_request> {
488 using request_type = dq::messaging::get_catalog_history_request;
489 using response_type = dq::messaging::get_catalog_history_response;
490 static constexpr message_type request_message_type =
491 message_type::get_catalog_history_request;
492};
493
494// Data Domain traits
495template<>
496struct message_traits<dq::messaging::get_data_domains_request> {
497 using request_type = dq::messaging::get_data_domains_request;
498 using response_type = dq::messaging::get_data_domains_response;
499 static constexpr message_type request_message_type =
500 message_type::get_data_domains_request;
501};
502
503template<>
504struct message_traits<dq::messaging::save_data_domain_request> {
505 using request_type = dq::messaging::save_data_domain_request;
506 using response_type = dq::messaging::save_data_domain_response;
507 static constexpr message_type request_message_type =
508 message_type::save_data_domain_request;
509};
510
511template<>
512struct message_traits<dq::messaging::delete_data_domain_request> {
513 using request_type = dq::messaging::delete_data_domain_request;
514 using response_type = dq::messaging::delete_data_domain_response;
515 static constexpr message_type request_message_type =
516 message_type::delete_data_domain_request;
517};
518
519template<>
520struct message_traits<dq::messaging::get_data_domain_history_request> {
521 using request_type = dq::messaging::get_data_domain_history_request;
522 using response_type = dq::messaging::get_data_domain_history_response;
523 static constexpr message_type request_message_type =
524 message_type::get_data_domain_history_request;
525};
526
527// Subject Area traits
528template<>
529struct message_traits<dq::messaging::get_subject_areas_request> {
530 using request_type = dq::messaging::get_subject_areas_request;
531 using response_type = dq::messaging::get_subject_areas_response;
532 static constexpr message_type request_message_type =
533 message_type::get_subject_areas_request;
534};
535
536template<>
537struct message_traits<dq::messaging::get_subject_areas_by_domain_request> {
538 using request_type = dq::messaging::get_subject_areas_by_domain_request;
539 using response_type = dq::messaging::get_subject_areas_by_domain_response;
540 static constexpr message_type request_message_type =
541 message_type::get_subject_areas_by_domain_request;
542};
543
544template<>
545struct message_traits<dq::messaging::save_subject_area_request> {
546 using request_type = dq::messaging::save_subject_area_request;
547 using response_type = dq::messaging::save_subject_area_response;
548 static constexpr message_type request_message_type =
549 message_type::save_subject_area_request;
550};
551
552template<>
553struct message_traits<dq::messaging::delete_subject_area_request> {
554 using request_type = dq::messaging::delete_subject_area_request;
555 using response_type = dq::messaging::delete_subject_area_response;
556 static constexpr message_type request_message_type =
557 message_type::delete_subject_area_request;
558};
559
560template<>
561struct message_traits<dq::messaging::get_subject_area_history_request> {
562 using request_type = dq::messaging::get_subject_area_history_request;
563 using response_type = dq::messaging::get_subject_area_history_response;
564 static constexpr message_type request_message_type =
565 message_type::get_subject_area_history_request;
566};
567
568}
569
570#endif
Contains messaging related infrastructure in the comms library.
Definition assets_protocol.hpp:122
Represents a logical grouping of related datasets.
Definition catalog.hpp:39
Represents a high-level classification of data within the system.
Definition data_domain.hpp:40
Represents a subdivision within a data domain.
Definition subject_area.hpp:38
Request to retrieve all catalogs.
Definition data_organization_protocol.hpp:42
Response containing all catalogs.
Definition data_organization_protocol.hpp:54
Request to save a catalog (create or update).
Definition data_organization_protocol.hpp:68
Response confirming catalog save operation.
Definition data_organization_protocol.hpp:82
Result for a single catalog deletion.
Definition data_organization_protocol.hpp:97
Request to delete one or more catalogs.
Definition data_organization_protocol.hpp:108
Response confirming catalog deletion(s).
Definition data_organization_protocol.hpp:122
Request to retrieve version history for a catalog.
Definition data_organization_protocol.hpp:136
Response containing catalog version history.
Definition data_organization_protocol.hpp:150
Request to retrieve all data domains.
Definition data_organization_protocol.hpp:170
Response containing all data domains.
Definition data_organization_protocol.hpp:182
Request to save a data domain (create or update).
Definition data_organization_protocol.hpp:196
Response confirming data domain save operation.
Definition data_organization_protocol.hpp:210
Result for a single data domain deletion.
Definition data_organization_protocol.hpp:225
Request to delete one or more data domains.
Definition data_organization_protocol.hpp:236
Response confirming data domain deletion(s).
Definition data_organization_protocol.hpp:250
Request to retrieve version history for a data domain.
Definition data_organization_protocol.hpp:264
Response containing data domain version history.
Definition data_organization_protocol.hpp:278
Request to retrieve all subject areas.
Definition data_organization_protocol.hpp:298
Response containing all subject areas.
Definition data_organization_protocol.hpp:310
Request to retrieve subject areas for a specific domain.
Definition data_organization_protocol.hpp:324
Response containing subject areas for a domain.
Definition data_organization_protocol.hpp:338
Request to save a subject area (create or update).
Definition data_organization_protocol.hpp:352
Response confirming subject area save operation.
Definition data_organization_protocol.hpp:366
Key for a subject area (composite key: name + domain_name).
Definition data_organization_protocol.hpp:381
Result for a single subject area deletion.
Definition data_organization_protocol.hpp:391
Request to delete one or more subject areas.
Definition data_organization_protocol.hpp:402
Response confirming subject area deletion(s).
Definition data_organization_protocol.hpp:416
Request to retrieve version history for a subject area.
Definition data_organization_protocol.hpp:430
Response containing subject area version history.
Definition data_organization_protocol.hpp:444