AirLibrary/Client/AirClient/
UpdateConfiguration.rs1use std::collections::HashMap;
6
7use tonic::Request;
8
9use crate::{AirError, Client::AirClient::AirClient, Vine::Generated::air::UpdateConfigurationRequest, dev_log};
10
11impl AirClient {
12 pub async fn UpdateConfiguration(
14 &self,
15
16 request_id:String,
17
18 section:String,
19
20 updates:HashMap<String, String>,
21 ) -> Result<(), AirError> {
22 let SectionDisplay = section.clone();
23
24 dev_log!(
25 "grpc",
26 "[AirClient] Updating configuration for section: {} ({} keys)",
27 SectionDisplay,
28 updates.len()
29 );
30
31 let RequestPayload = UpdateConfigurationRequest { request_id, section, updates };
32
33 let Client = self
34 .Client()
35 .ok_or_else(|| AirError::Network("Air client not initialized".to_string()))?;
36
37 let mut ClientGuard = Client.lock().await;
38
39 match ClientGuard.update_configuration(Request::new(RequestPayload)).await {
40 Ok(Response) => {
41 let Response = Response.into_inner();
42
43 if Response.success {
44 dev_log!(
45 "grpc",
46 "[AirClient] Configuration updated successfully for section: {}",
47 SectionDisplay
48 );
49
50 Ok(())
51 } else {
52 dev_log!("grpc", "error: [AirClient] Failed to update configuration: {}", Response.error);
53
54 Err(AirError::Configuration(Response.error))
55 }
56 },
57
58 Err(Status) => {
59 dev_log!("grpc", "error: [AirClient] Update configuration RPC error: {}", Status);
60
61 Err(AirError::Network(format!("Update configuration RPC error: {}", Status)))
62 },
63 }
64 }
65}