ORE Studio 0.0.4
Loading...
Searching...
No Matches
publish_bundle_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_DQ_API_MESSAGING_PUBLISH_BUNDLE_PROTOCOL_HPP
21#define ORES_DQ_API_MESSAGING_PUBLISH_BUNDLE_PROTOCOL_HPP
22
23#include <string>
24#include <vector>
25#include <optional>
26#include <rfl/json.hpp>
27#include "ores.dq.api/domain/publication_mode.hpp"
28
29namespace ores::dq::messaging {
30
31struct lei_parties_params {
32 std::string root_lei;
33};
34
35struct publish_bundle_params {
36 std::vector<std::string> opted_in_datasets;
37 std::optional<lei_parties_params> lei_parties;
38};
39
40inline std::string build_params_json(const publish_bundle_params& params) {
41 return rfl::json::write(params);
42}
43
44struct bundle_dataset_result {
45 std::string dataset_code;
46 bool success = false;
47 std::string error_message;
48 int records_inserted = 0;
49 int records_updated = 0;
50 int records_skipped = 0;
51 int records_deleted = 0;
52};
53
54struct publish_bundle_request {
55 using response_type = struct publish_bundle_response;
56 static constexpr std::string_view nats_subject = "dq.v1.bundles.publish";
57 std::string bundle_code;
58 ores::dq::domain::publication_mode mode =
59 ores::dq::domain::publication_mode::upsert;
60 std::string published_by;
61 bool atomic = false;
62 std::string params_json;
63};
64
65struct publish_bundle_response {
66 bool success = false;
67 std::string error_message;
68 int datasets_succeeded = 0;
69 int total_records_inserted = 0;
70 int total_records_updated = 0;
71 std::vector<bundle_dataset_result> dataset_results;
72};
73
74}
75
76#endif