Skip to main content

dataplane_sdk/core/model/
messages.rs

1//  Copyright (c) 2026 Metaform Systems, Inc
2//
3//  This program and the accompanying materials are made available under the
4//  terms of the Apache License, Version 2.0 which is available at
5//  https://www.apache.org/licenses/LICENSE-2.0
6//
7//    SPDX-License-Identifier: Apache-2.0
8//
9//    Contributors:
10//         Metaform Systems, Inc. - initial API and implementation
11//
12
13use std::collections::HashMap;
14
15use bon::Builder;
16use serde::{Deserialize, Serialize};
17use serde_json::Value;
18
19use super::{data_address::DataAddress, data_flow::DataFlowState};
20
21#[derive(Debug, Serialize, Deserialize, Clone, Builder)]
22#[serde(rename_all = "camelCase")]
23#[builder(on(String, into))]
24pub struct DataFlowStartMessage {
25    pub message_id: String,
26    pub participant_id: String,
27    pub counter_party_id: String,
28    pub dataspace_context: String,
29    pub process_id: String,
30    pub agreement_id: String,
31    pub dataset_id: String,
32    pub profile: String,
33    pub data_address: Option<DataAddress>,
34    #[builder(default)]
35    #[serde(default)]
36    pub labels: Vec<String>,
37    #[builder(default)]
38    #[serde(default)]
39    pub metadata: HashMap<String, Value>,
40}
41
42#[derive(Debug, Serialize, Deserialize, Clone, Builder)]
43#[serde(rename_all = "camelCase")]
44#[builder(on(String, into))]
45pub struct DataFlowResumeMessage {
46    pub data_address: Option<DataAddress>,
47}
48
49#[derive(Debug, Serialize, Deserialize, Clone, Builder)]
50#[serde(rename_all = "camelCase")]
51#[builder(on(String, into))]
52pub struct DataFlowPrepareMessage {
53    pub message_id: String,
54    pub participant_id: String,
55    pub counter_party_id: String,
56    pub dataspace_context: String,
57    pub process_id: String,
58    pub agreement_id: String,
59    pub dataset_id: String,
60    pub profile: String,
61    #[builder(default)]
62    #[serde(default)]
63    pub labels: Vec<String>,
64    #[builder(default)]
65    #[serde(default)]
66    pub metadata: HashMap<String, Value>,
67}
68
69#[derive(Debug, Builder, Serialize, Deserialize, Clone)]
70#[serde(rename_all = "camelCase")]
71#[builder(on(String, into))]
72pub struct DataFlowStatusMessage {
73    #[builder(default = new_message_id())]
74    #[serde(default = "new_message_id")]
75    pub message_id: String,
76    pub data_flow_id: String,
77    #[serde(skip_serializing_if = "Option::is_none")]
78    pub data_address: Option<DataAddress>,
79    pub state: DataFlowState,
80    #[serde(skip_serializing_if = "Option::is_none")]
81    pub error: Option<String>,
82}
83
84fn new_message_id() -> String {
85    uuid::Uuid::new_v4().to_string()
86}
87
88#[derive(Debug, Builder, Serialize, Deserialize, Clone)]
89#[serde(rename_all = "camelCase")]
90pub struct DataFlowStartedNotificationMessage {
91    pub data_address: Option<DataAddress>,
92}
93
94#[derive(Builder, Debug, Serialize, Deserialize, Clone)]
95#[serde(rename_all = "camelCase")]
96#[builder(on(String, into))]
97pub struct DataFlowStatusResponseMessage {
98    pub data_flow_id: String,
99    pub state: DataFlowState,
100}
101
102#[derive(Debug, Serialize, Deserialize, Clone)]
103#[serde(rename_all = "camelCase")]
104pub struct DataFlowSuspendMessage {
105    pub reason: Option<String>,
106}
107
108#[derive(Debug, Serialize, Deserialize, Clone, Builder)]
109#[serde(rename_all = "camelCase")]
110#[builder(on(String, into))]
111pub struct DataFlowTerminateMessage {
112    pub reason: Option<String>,
113}