Skip to content

Commit

Permalink
wip update-model implementation
Browse files Browse the repository at this point in the history
  • Loading branch information
sabotack committed Nov 28, 2023
1 parent 3110aea commit 5d93cf7
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 3 deletions.
2 changes: 1 addition & 1 deletion Ecdar-ProtoBuf
37 changes: 35 additions & 2 deletions src/api/ecdar_api.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ use crate::database::{
session_context::SessionContextTrait, user_context::UserContextTrait,
};

use super::server::server::UpdateModelRequest;
use super::server::server::{
ecdar_api_auth_server::EcdarApiAuth,
ecdar_api_server::EcdarApi,
Expand Down Expand Up @@ -157,8 +158,40 @@ impl EcdarApi for ConcreteEcdarApi {
}
}

Check warning on line 159 in src/api/ecdar_api.rs

View workflow job for this annotation

GitHub Actions / cargo fmt

Diff in /home/runner/work/Ecdar-API/Ecdar-API/src/api/ecdar_api.rs

async fn update_model(&self, _request: Request<()>) -> Result<Response<()>, Status> {
todo!()
async fn update_model(
&self,
request: Request<UpdateModelRequest>
)-> Result<Response<()>, Status> {
let message = request.get_ref().clone();
let uid = request

Check warning on line 166 in src/api/ecdar_api.rs

View workflow job for this annotation

GitHub Actions / Clippy lint and check

unused variable: `uid`

warning: unused variable: `uid` --> src/api/ecdar_api.rs:166:13 | 166 | let uid = request | ^^^ help: if this is intentional, prefix it with an underscore: `_uid` | = note: `#[warn(unused_variables)]` on by default

Check warning on line 166 in src/api/ecdar_api.rs

View workflow job for this annotation

GitHub Actions / Clippy lint and check

unused variable: `uid`

warning: unused variable: `uid` --> src/api/ecdar_api.rs:166:13 | 166 | let uid = request | ^^^ help: if this is intentional, prefix it with an underscore: `_uid` | = note: `#[warn(unused_variables)]` on by default
.uid()
.ok_or(Status::internal("Could not get uid from request metadata"))?;

// Check if the model exists
let model = match self.model_context.get_by_id(message.id).await {
Ok(Some(model)) => model,
Ok(None) => return Err(Status::not_found("No model found with given id")),
Err(error) => return Err(Status::internal(error.to_string())),
};

// // Check if the user has access to the model
// let access = match self.access_context.get_by_id(message.id, uid).await {
// Ok(Some(access)) => access,
// Ok(None) => return Err(Status::permission_denied("No access to model")),
// Err(error) => return Err(Status::internal(error.to_string())),
// };

// let model = model::Model {
// id: message.id,
// name: message.name,
// components_info: serde_json::to_value(message.components_info).unwrap(),
// owner_id: Default::default(),
// };

match self.model_context.update(model).await {
Ok(_) => Ok(Response::new(())),
Err(error) => Err(Status::new(Code::Internal, error.to_string())),
}
}

async fn delete_model(
Expand Down

0 comments on commit 5d93cf7

Please sign in to comment.