Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ CREATE TABLE IF NOT EXISTS data_flows (
suspension_reason TEXT,
termination_reason TEXT,
metadata JSONB NOT NULL DEFAULT '{}',
claims JSONB NOT NULL DEFAULT '{}',
labels JSONB NOT NULL DEFAULT '[]',
created_at TIMESTAMPTZ NOT NULL DEFAULT CURRENT_TIMESTAMP,
updated_at TIMESTAMPTZ NOT NULL DEFAULT CURRENT_TIMESTAMP
Expand Down
3 changes: 3 additions & 0 deletions crates/sdk-postgres/src/data_flow/model.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@ pub struct DataFlow {
pub termination_reason: Option<String>,
#[builder(default)]
pub metadata: Json<HashMap<String, Value>>,
#[builder(default)]
pub claims: Json<HashMap<String, Value>>,
#[builder(into)]
pub data_address: Option<Json<DataAddress>>,
#[builder(into)]
Expand Down Expand Up @@ -78,6 +80,7 @@ impl From<DataFlow> for dataplane_sdk::core::model::data_flow::DataFlow {
.labels(flow.labels.0)
.agreement_id(flow.agreement_id)
.metadata(flow.metadata.0)
.claims(flow.claims.0)
.dataset_id(flow.dataset_id)
.dataspace_context(flow.dataspace_context)
.participant_id(flow.participant_id)
Expand Down
5 changes: 3 additions & 2 deletions crates/sdk-postgres/src/data_flow/repo.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@ impl DataFlowRepo for PgDataFlowRepo {
async fn create(&self, tx: &mut Self::Transaction, flow: &DataFlow) -> DbResult<()> {
let result = sqlx::query(
r#"
INSERT INTO data_flows (id, participant_id, dataspace_context, participant_context_id, counter_party_id, dataset_id, agreement_id, state, profile, type, data_address, control_plane_id, labels, metadata, created_at, updated_at)
VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, $12, $13, $14, $15, $16)
INSERT INTO data_flows (id, participant_id, dataspace_context, participant_context_id, counter_party_id, dataset_id, agreement_id, state, profile, type, data_address, control_plane_id, labels, metadata, claims, created_at, updated_at)
VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, $12, $13, $14, $15, $16, $17)
"#,
)
.bind(&flow.id)
Expand All @@ -51,6 +51,7 @@ impl DataFlowRepo for PgDataFlowRepo {
.bind(&flow.control_plane_id)
.bind(Json(flow.labels.clone()))
.bind(Json(flow.metadata.clone()))
.bind(Json(flow.claims.clone()))
.bind(flow.created_at)
.bind(flow.updated_at)
.execute(&mut *tx.0)
Expand Down
5 changes: 5 additions & 0 deletions crates/sdk/src/core/db/test_suite.rs
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,11 @@ pub fn create_data_flow(id: &str) -> DataFlow {
.into_iter()
.collect(),
)
.claims(
vec![("claim".to_string(), "value".into())]
.into_iter()
.collect(),
)
.dataset_id("dataset_id")
.dataspace_context("dataspace_context")
.participant_id("participant_id")
Expand Down
2 changes: 2 additions & 0 deletions crates/sdk/src/core/model/data_flow.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@ pub struct DataFlow {
pub labels: Vec<String>,
#[builder(default)]
pub metadata: HashMap<String, Value>,
#[builder(default)]
pub claims: HashMap<String, Value>,
#[builder(into)]
pub data_address: Option<DataAddress>,
#[builder(default = Utc::now())]
Expand Down
6 changes: 6 additions & 0 deletions crates/sdk/src/core/model/messages.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,9 @@ pub struct DataFlowStartMessage {
#[builder(default)]
#[serde(default)]
pub metadata: HashMap<String, Value>,
#[builder(default)]
#[serde(default)]
pub claims: HashMap<String, Value>,
}

#[derive(Debug, Serialize, Deserialize, Clone, Builder)]
Expand Down Expand Up @@ -64,6 +67,9 @@ pub struct DataFlowPrepareMessage {
#[builder(default)]
#[serde(default)]
pub metadata: HashMap<String, Value>,
#[builder(default)]
#[serde(default)]
pub claims: HashMap<String, Value>,
}

#[derive(Debug, Builder, Serialize, Deserialize, Clone)]
Expand Down
2 changes: 2 additions & 0 deletions crates/sdk/src/sdk/internal.rs
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ where
.participant_context_id(participant_context_id)
.state(DataFlowState::Initiating)
.metadata(req.metadata)
.claims(req.claims)
.participant_id(req.participant_id)
.dataspace_context(req.dataspace_context)
.dataset_id(req.dataset_id)
Expand Down Expand Up @@ -107,6 +108,7 @@ where
.participant_context_id(participant_context_id)
.state(DataFlowState::Initiating)
.metadata(req.metadata)
.claims(req.claims)
.participant_id(req.participant_id)
.dataspace_context(req.dataspace_context)
.dataset_id(req.dataset_id)
Expand Down