Mountain/RPC/CocoonService/Extension/
GetExtension.rs1use tonic::{Response, Status};
5use CommonLibrary::ExtensionManagement::ExtensionManagementService::ExtensionManagementService;
6use ::Vine::Generated::{ExtensionInfo, GetExtensionRequest, GetExtensionResponse};
7
8use crate::{RPC::CocoonService::CocoonServiceImpl, dev_log};
9
10pub async fn Fn(
11 Service:&CocoonServiceImpl,
12
13 Request:GetExtensionRequest,
14) -> Result<Response<GetExtensionResponse>, Status> {
15 dev_log!("cocoon", "[CocoonService] get_extension: {}", Request.extension_id);
16
17 let Found = Service
18 .environment
19 .GetExtension(Request.extension_id.clone())
20 .await
21 .ok()
22 .flatten();
23
24 let Info = Found.map(|Value| {
25 ExtensionInfo {
26 id:Request.extension_id,
27 display_name:Value.get("Name").and_then(|V| V.as_str()).unwrap_or("").to_string(),
28 version:Value.get("Version").and_then(|V| V.as_str()).unwrap_or("").to_string(),
29 is_active:true,
30 extension_path:Value
31 .get("ExtensionLocation")
32 .and_then(|V| V.as_str())
33 .unwrap_or("")
34 .to_string(),
35 }
36 });
37
38 Ok(Response::new(GetExtensionResponse { extension:Info }))
39}