Skip to content

Commit

Permalink
feat: boostrap tui
Browse files Browse the repository at this point in the history
  • Loading branch information
wolf4ood committed Sep 9, 2024
1 parent ea141f4 commit 4cfb285
Show file tree
Hide file tree
Showing 57 changed files with 3,336 additions and 236 deletions.
1,043 changes: 1,031 additions & 12 deletions Cargo.lock

Large diffs are not rendered by default.

3 changes: 2 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
[workspace]
resolver="2"
members = [
"edc-connector-client"
"edc-connector-client",
"edc-connector-tui"
]

[workspace.dependencies]
Expand Down
4 changes: 2 additions & 2 deletions edc-connector-client/src/api/catalog.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,15 @@ impl<'a> CatalogApi<'a> {
}

pub async fn request(&self, request: &CatalogRequest) -> EdcResult<Catalog> {
let url = format!("{}/v2/catalog/request", self.0.management_url);
let url = format!("{}/v3/catalog/request", self.0.management_url);
self.0
.post::<_, WithContext<Catalog>>(url, &WithContextRef::default_context(request))
.await
.map(|ctx| ctx.inner)
}

pub async fn dataset(&self, request: &DatasetRequest) -> EdcResult<Dataset> {
let url = format!("{}/v2/catalog/dataset/request", self.0.management_url);
let url = format!("{}/v3/catalog/dataset/request", self.0.management_url);
self.0
.post::<_, WithContext<Dataset>>(url, &WithContextRef::default_context(request))
.await
Expand Down
4 changes: 2 additions & 2 deletions edc-connector-client/src/api/contract_agreement.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,15 @@ impl<'a> ContractAgreementApi<'a> {
}

pub async fn get(&self, id: &str) -> EdcResult<ContractAgreement> {
let url = format!("{}/v2/contractagreements/{}", self.0.management_url, id);
let url = format!("{}/v3/contractagreements/{}", self.0.management_url, id);
self.0
.get::<WithContext<ContractAgreement>>(url)
.await
.map(|ctx| ctx.inner)
}

pub async fn query(&self, query: Query) -> EdcResult<Vec<ContractAgreement>> {
let url = format!("{}/v2/contractagreements/request", self.0.management_url);
let url = format!("{}/v3/contractagreements/request", self.0.management_url);
self.0
.post::<_, Vec<WithContext<ContractAgreement>>>(
url,
Expand Down
10 changes: 5 additions & 5 deletions edc-connector-client/src/api/contract_definitions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ impl<'a> ContractDefinitionApi<'a> {
&self,
contract_definition: &NewContractDefinition,
) -> EdcResult<IdResponse<String>> {
let url = format!("{}/v2/contractdefinitions", self.0.management_url);
let url = format!("{}/v3/contractdefinitions", self.0.management_url);
self.0
.post::<_, WithContext<IdResponse<String>>>(
url,
Expand All @@ -31,22 +31,22 @@ impl<'a> ContractDefinitionApi<'a> {
}

pub async fn get(&self, id: &str) -> EdcResult<ContractDefinition> {
let url = format!("{}/v2/contractdefinitions/{}", self.0.management_url, id);
let url = format!("{}/v3/contractdefinitions/{}", self.0.management_url, id);
self.0
.get::<WithContext<ContractDefinition>>(url)
.await
.map(|ctx| ctx.inner)
}

pub async fn update(&self, contract_definition: &ContractDefinition) -> EdcResult<()> {
let url = format!("{}/v2/contractdefinitions", self.0.management_url);
let url = format!("{}/v3/contractdefinitions", self.0.management_url);
self.0
.put(url, &WithContextRef::default_context(contract_definition))
.await
}

pub async fn query(&self, query: Query) -> EdcResult<Vec<ContractDefinition>> {
let url = format!("{}/v2/contractdefinitions/request", self.0.management_url);
let url = format!("{}/v3/contractdefinitions/request", self.0.management_url);
self.0
.post::<_, Vec<WithContext<ContractDefinition>>>(
url,
Expand All @@ -57,7 +57,7 @@ impl<'a> ContractDefinitionApi<'a> {
}

pub async fn delete(&self, id: &str) -> EdcResult<()> {
let url = format!("{}/v2/contractdefinitions/{}", self.0.management_url, id);
let url = format!("{}/v3/contractdefinitions/{}", self.0.management_url, id);
self.0.del(url).await
}
}
10 changes: 5 additions & 5 deletions edc-connector-client/src/api/contract_negotiations.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ impl<'a> ContractNegotiationApi<'a> {
&self,
contract_request: &ContractRequest,
) -> EdcResult<IdResponse<String>> {
let url = format!("{}/v2/contractnegotiations", self.0.management_url);
let url = format!("{}/v3/contractnegotiations", self.0.management_url);
self.0
.post::<_, WithContext<IdResponse<String>>>(
url,
Expand All @@ -34,15 +34,15 @@ impl<'a> ContractNegotiationApi<'a> {
}

pub async fn get(&self, id: &str) -> EdcResult<ContractNegotiation> {
let url = format!("{}/v2/contractnegotiations/{}", self.0.management_url, id);
let url = format!("{}/v3/contractnegotiations/{}", self.0.management_url, id);
self.0
.get::<WithContext<ContractNegotiation>>(url)
.await
.map(|ctx| ctx.inner)
}

pub async fn get_state(&self, id: &str) -> EdcResult<ContractNegotiationState> {
let url = format!("{}/v2/contractnegotiations/{}", self.0.management_url, id);
let url = format!("{}/v3/contractnegotiations/{}", self.0.management_url, id);
self.0
.get::<WithContext<NegotiationState>>(url)
.await
Expand All @@ -51,7 +51,7 @@ impl<'a> ContractNegotiationApi<'a> {

pub async fn terminate(&self, id: &str, reason: &str) -> EdcResult<()> {
let url = format!(
"{}/v2/contractnegotiations/{}/terminate",
"{}/v3/contractnegotiations/{}/terminate",
self.0.management_url, id
);

Expand All @@ -66,7 +66,7 @@ impl<'a> ContractNegotiationApi<'a> {
}

pub async fn query(&self, query: Query) -> EdcResult<Vec<ContractNegotiation>> {
let url = format!("{}/v2/contractnegotiations/request", self.0.management_url);
let url = format!("{}/v3/contractnegotiations/request", self.0.management_url);
self.0
.post::<_, Vec<WithContext<ContractNegotiation>>>(
url,
Expand Down
14 changes: 5 additions & 9 deletions edc-connector-client/src/api/dataplanes.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
use crate::{
client::EdcConnectorClientInternal,
types::{
context::{WithContext, WithContextRef},
context::WithContext,
dataplane::DataPlaneInstance,
response::IdResponse,
},
EdcResult,
};
Expand All @@ -15,14 +14,11 @@ impl<'a> DataPlaneApi<'a> {
DataPlaneApi(client)
}

pub async fn register(&self, data_plane: &DataPlaneInstance) -> EdcResult<IdResponse<String>> {
let url = format!("{}/v2/dataplanes", self.0.management_url);
pub async fn list(&self) -> EdcResult<Vec<DataPlaneInstance>> {
let url = format!("{}/v3/dataplanes", self.0.management_url);
self.0
.post::<_, WithContext<IdResponse<String>>>(
url,
&WithContextRef::default_context(data_plane),
)
.get::<Vec<WithContext<DataPlaneInstance>>>(url)
.await
.map(|ctx| ctx.inner)
.map(|results| results.into_iter().map(|ctx| ctx.inner).collect())
}
}
6 changes: 3 additions & 3 deletions edc-connector-client/src/api/edrs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,15 +37,15 @@ impl<'a> EdrApi<'a> {
}

pub async fn get_data_address(&self, id: &str) -> EdcResult<DataAddress> {
let url = format!("{}/v2/edrs/{}/dataaddress", self.0.management_url, id);
let url = format!("{}/v3/edrs/{}/dataaddress", self.0.management_url, id);
self.0
.get::<WithContext<DataAddress>>(url)
.await
.map(|ctx| ctx.inner)
}

pub async fn query(&self, query: Query) -> EdcResult<Vec<EndpointDataReferenceEntry>> {
let url = format!("{}/v1/edrs/request", self.0.management_url);
let url = format!("{}/v3/edrs/request", self.0.management_url);
self.0
.post::<_, Vec<WithContext<EndpointDataReferenceEntry>>>(
url,
Expand All @@ -56,7 +56,7 @@ impl<'a> EdrApi<'a> {
}

pub async fn delete(&self, id: &str) -> EdcResult<()> {
let url = format!("{}/v1/edrs/{}", self.0.management_url, id);
let url = format!("{}/v3/edrs/{}", self.0.management_url, id);
self.0.del(url).await
}
}
8 changes: 4 additions & 4 deletions edc-connector-client/src/api/policies.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ impl<'a> PolicyApi<'a> {
&self,
policy_definition: &NewPolicyDefinition,
) -> EdcResult<IdResponse<String>> {
let url = format!("{}/v2/policydefinitions", self.0.management_url);
let url = format!("{}/v3/policydefinitions", self.0.management_url);
self.0
.post::<_, WithContext<IdResponse<String>>>(
url,
Expand All @@ -31,7 +31,7 @@ impl<'a> PolicyApi<'a> {
}

pub async fn get(&self, id: &str) -> EdcResult<PolicyDefinition> {
let url = format!("{}/v2/policydefinitions/{}", self.0.management_url, id);
let url = format!("{}/v3/policydefinitions/{}", self.0.management_url, id);
self.0
.get::<WithContext<PolicyDefinition>>(url)
.await
Expand All @@ -50,7 +50,7 @@ impl<'a> PolicyApi<'a> {
}

pub async fn query(&self, query: Query) -> EdcResult<Vec<PolicyDefinition>> {
let url = format!("{}/v2/policydefinitions/request", self.0.management_url);
let url = format!("{}/v3/policydefinitions/request", self.0.management_url);
self.0
.post::<_, Vec<WithContext<PolicyDefinition>>>(
url,
Expand All @@ -61,7 +61,7 @@ impl<'a> PolicyApi<'a> {
}

pub async fn delete(&self, id: &str) -> EdcResult<()> {
let url = format!("{}/v2/policydefinitions/{}", self.0.management_url, id);
let url = format!("{}/v3/policydefinitions/{}", self.0.management_url, id);
self.0.del(url).await
}
}
14 changes: 7 additions & 7 deletions edc-connector-client/src/api/transfer_process.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ impl<'a> TransferProcessApi<'a> {
&self,
transfer_request: &TransferRequest,
) -> EdcResult<IdResponse<String>> {
let url = format!("{}/v2/transferprocesses", self.0.management_url);
let url = format!("{}/v3/transferprocesses", self.0.management_url);
self.0
.post::<_, WithContext<IdResponse<String>>>(
url,
Expand All @@ -34,23 +34,23 @@ impl<'a> TransferProcessApi<'a> {
}

pub async fn get(&self, id: &str) -> EdcResult<TransferProcess> {
let url = format!("{}/v2/transferprocesses/{}", self.0.management_url, id);
let url = format!("{}/v3/transferprocesses/{}", self.0.management_url, id);
self.0
.get::<WithContext<TransferProcess>>(url)
.await
.map(|ctx| ctx.inner)
}

pub async fn get_state(&self, id: &str) -> EdcResult<TransferProcessState> {
let url = format!("{}/v2/transferprocesses/{}", self.0.management_url, id);
let url = format!("{}/v3/transferprocesses/{}", self.0.management_url, id);
self.0
.get::<WithContext<TransferState>>(url)
.await
.map(|ctx| ctx.inner.state().clone())
}

pub async fn query(&self, query: Query) -> EdcResult<Vec<TransferProcess>> {
let url = format!("{}/v2/transferprocesses/request", self.0.management_url);
let url = format!("{}/v3/transferprocesses/request", self.0.management_url);
self.0
.post::<_, Vec<WithContext<TransferProcess>>>(
url,
Expand All @@ -62,7 +62,7 @@ impl<'a> TransferProcessApi<'a> {

pub async fn terminate(&self, id: &str, reason: &str) -> EdcResult<()> {
let url = format!(
"{}/v2/transferprocesses/{}/terminate",
"{}/v3/transferprocesses/{}/terminate",
self.0.management_url, id
);

Expand All @@ -78,7 +78,7 @@ impl<'a> TransferProcessApi<'a> {

pub async fn suspend(&self, id: &str, reason: &str) -> EdcResult<()> {
let url = format!(
"{}/v2/transferprocesses/{}/suspend",
"{}/v3/transferprocesses/{}/suspend",
self.0.management_url, id
);

Expand All @@ -94,7 +94,7 @@ impl<'a> TransferProcessApi<'a> {

pub async fn resume(&self, id: &str) -> EdcResult<()> {
let url = format!(
"{}/v2/transferprocesses/{}/resume",
"{}/v3/transferprocesses/{}/resume",
self.0.management_url, id
);

Expand Down
14 changes: 13 additions & 1 deletion edc-connector-client/src/types/asset.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ use super::{
properties::{FromValue, Properties, PropertyValue, ToValue},
};

#[derive(Debug, Serialize, Deserialize)]
#[derive(Debug, Serialize, Deserialize, Clone)]
#[serde(rename_all = "camelCase")]
pub struct Asset {
#[serde(rename = "@id")]
Expand Down Expand Up @@ -55,6 +55,18 @@ where {
pub fn id(&self) -> &str {
&self.id
}

pub fn properties(&self) -> &Properties {
&self.properties
}

pub fn private_properties(&self) -> &Properties {
&self.private_properties
}

pub fn data_address(&self) -> &DataAddress {
&self.data_address
}
}

#[derive(Default)]
Expand Down
8 changes: 5 additions & 3 deletions edc-connector-client/src/types/contract_definition.rs
Original file line number Diff line number Diff line change
@@ -1,19 +1,21 @@
use serde::{Deserialize, Serialize};

use crate::{BuilderError, ConversionError};
use serde::{Deserialize, Serialize};
use serde_with::{formats::PreferMany, serde_as, OneOrMany};

use super::{
properties::{FromValue, Properties, ToValue},
query::Criterion,
};

#[derive(Debug, Serialize, Deserialize)]
#[serde_as]
#[derive(Debug, Serialize, Deserialize, Clone)]
#[serde(rename_all = "camelCase")]
pub struct ContractDefinition {
#[serde(rename = "@id")]
id: String,
access_policy_id: String,
contract_policy_id: String,
#[serde_as(deserialize_as = "OneOrMany<_, PreferMany>")]
#[serde(default)]
assets_selector: Vec<Criterion>,
#[serde(default)]
Expand Down
2 changes: 1 addition & 1 deletion edc-connector-client/src/types/data_address.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use crate::{error::BuilderError, ConversionError};

use super::properties::{FromValue, Properties, ToValue};

#[derive(Debug, Deserialize, Serialize)]
#[derive(Debug, Deserialize, Serialize, Clone)]
pub struct DataAddress(Properties);

impl DataAddress {
Expand Down
Loading

0 comments on commit 4cfb285

Please sign in to comment.