| 5144 | } |
| 5145 | |
| 5146 | pub async fn provider_profile_update( |
| 5147 | server: &str, |
| 5148 | id: &str, |
| 5149 | file: &Path, |
| 5150 | tls: &TlsOptions, |
| 5151 | ) -> Result<()> { |
| 5152 | let (mut items, mut diagnostics) = load_profile_import_items(Some(file), None)?; |
| 5153 | if items.is_empty() && diagnostics.is_empty() { |
| 5154 | return Err(miette!("no provider profile files found")); |
| 5155 | } |
| 5156 | if profile_diagnostics_have_errors(&diagnostics) { |
| 5157 | print_profile_diagnostics(&diagnostics); |
| 5158 | return Err(miette!("provider profile update failed")); |
| 5159 | } |
| 5160 | |
| 5161 | let mut client = grpc_client(server, tls).await?; |
| 5162 | if let Some(item) = items.pop() { |
| 5163 | let expected_resource_version = item |
| 5164 | .profile |
| 5165 | .as_ref() |
| 5166 | .map_or(0, |profile| profile.resource_version); |
| 5167 | let response = client |
| 5168 | .update_provider_profiles(UpdateProviderProfilesRequest { |
| 5169 | profile: Some(item), |
| 5170 | expected_resource_version, |
| 5171 | id: id.to_string(), |
| 5172 | }) |
| 5173 | .await |
| 5174 | .into_diagnostic()? |
| 5175 | .into_inner(); |
| 5176 | diagnostics.extend(response.diagnostics); |
| 5177 | if response.updated { |
| 5178 | println!("Updated provider profile."); |
| 5179 | return Ok(()); |
| 5180 | } |
| 5181 | } |
| 5182 | |
| 5183 | print_profile_diagnostics(&diagnostics); |
| 5184 | Err(miette!("provider profile update failed")) |
| 5185 | } |
| 5186 | |
| 5187 | pub async fn provider_profile_lint( |
| 5188 | server: &str, |