| 100 | } |
| 101 | |
| 102 | async fn update( |
| 103 | &self, |
| 104 | request: Request<api::UpdateApplicationRequest>, |
| 105 | ) -> Result<Response<()>, Status> { |
| 106 | let req_app = match &request.get_ref().application { |
| 107 | Some(v) => v, |
| 108 | None => { |
| 109 | return Err(Status::invalid_argument("application is missing")); |
| 110 | } |
| 111 | }; |
| 112 | let app_id = Uuid::from_str(&req_app.id).map_err(|e| e.status())?; |
| 113 | |
| 114 | self.validator |
| 115 | .validate( |
| 116 | request.extensions(), |
| 117 | validator::ValidateApplicationAccess::new(validator::Flag::Update, app_id), |
| 118 | ) |
| 119 | .await?; |
| 120 | |
| 121 | let _ = application::update(application::Application { |
| 122 | id: app_id.into(), |
| 123 | name: req_app.name.to_string(), |
| 124 | description: req_app.description.to_string(), |
| 125 | tags: fields::KeyValue::new(req_app.tags.clone()), |
| 126 | ..Default::default() |
| 127 | }) |
| 128 | .await |
| 129 | .map_err(|e| e.status())?; |
| 130 | |
| 131 | let mut resp = Response::new(()); |
| 132 | resp.metadata_mut() |
| 133 | .insert("x-log-application_id", req_app.id.parse().unwrap()); |
| 134 | |
| 135 | Ok(resp) |
| 136 | } |
| 137 | |
| 138 | async fn delete( |
| 139 | &self, |