| 267 | } |
| 268 | |
| 269 | async fn create_http_integration( |
| 270 | &self, |
| 271 | request: Request<api::CreateHttpIntegrationRequest>, |
| 272 | ) -> Result<Response<()>, Status> { |
| 273 | let req_int = match &request.get_ref().integration { |
| 274 | Some(v) => v, |
| 275 | None => { |
| 276 | return Err(Status::invalid_argument("integration is missing")); |
| 277 | } |
| 278 | }; |
| 279 | let app_id = Uuid::from_str(&req_int.application_id).map_err(|e| e.status())?; |
| 280 | |
| 281 | self.validator |
| 282 | .validate( |
| 283 | request.extensions(), |
| 284 | validator::ValidateApplicationAccess::new(validator::Flag::Update, app_id), |
| 285 | ) |
| 286 | .await?; |
| 287 | |
| 288 | let i = application::Integration { |
| 289 | application_id: app_id.into(), |
| 290 | kind: application::IntegrationKind::Http, |
| 291 | configuration: application::IntegrationConfiguration::Http( |
| 292 | application::HttpConfiguration { |
| 293 | headers: req_int.headers.clone(), |
| 294 | json: match req_int.encoding() { |
| 295 | api::Encoding::Protobuf => false, |
| 296 | api::Encoding::Json => true, |
| 297 | }, |
| 298 | event_endpoint_url: req_int.event_endpoint_url.clone(), |
| 299 | }, |
| 300 | ), |
| 301 | ..Default::default() |
| 302 | }; |
| 303 | |
| 304 | let _ = application::create_integration(i) |
| 305 | .await |
| 306 | .map_err(|e| e.status())?; |
| 307 | |
| 308 | let mut resp = Response::new(()); |
| 309 | resp.metadata_mut().insert( |
| 310 | "x-log-application_id", |
| 311 | req_int.application_id.parse().unwrap(), |
| 312 | ); |
| 313 | |
| 314 | Ok(resp) |
| 315 | } |
| 316 | |
| 317 | async fn get_http_integration( |
| 318 | &self, |