| 886 | } |
| 887 | |
| 888 | async fn create_gcp_pub_sub_integration( |
| 889 | &self, |
| 890 | request: Request<api::CreateGcpPubSubIntegrationRequest>, |
| 891 | ) -> Result<Response<()>, Status> { |
| 892 | let req_int = match &request.get_ref().integration { |
| 893 | Some(v) => v, |
| 894 | None => { |
| 895 | return Err(Status::invalid_argument("integration is missing")); |
| 896 | } |
| 897 | }; |
| 898 | let app_id = Uuid::from_str(&req_int.application_id).map_err(|e| e.status())?; |
| 899 | |
| 900 | self.validator |
| 901 | .validate( |
| 902 | request.extensions(), |
| 903 | validator::ValidateApplicationAccess::new(validator::Flag::Update, app_id), |
| 904 | ) |
| 905 | .await?; |
| 906 | |
| 907 | let _ = application::create_integration(application::Integration { |
| 908 | application_id: app_id.into(), |
| 909 | kind: application::IntegrationKind::GcpPubSub, |
| 910 | configuration: application::IntegrationConfiguration::GcpPubSub( |
| 911 | application::GcpPubSubConfiguration { |
| 912 | encoding: req_int.encoding, |
| 913 | credentials_file: req_int.credentials_file.clone(), |
| 914 | project_id: req_int.project_id.clone(), |
| 915 | topic_name: req_int.topic_name.clone(), |
| 916 | }, |
| 917 | ), |
| 918 | ..Default::default() |
| 919 | }) |
| 920 | .await |
| 921 | .map_err(|e| e.status())?; |
| 922 | |
| 923 | let mut resp = Response::new(()); |
| 924 | resp.metadata_mut().insert( |
| 925 | "x-log-application_id", |
| 926 | req_int.application_id.parse().unwrap(), |
| 927 | ); |
| 928 | |
| 929 | Ok(resp) |
| 930 | } |
| 931 | |
| 932 | async fn get_gcp_pub_sub_integration( |
| 933 | &self, |