Mountain/RPC/CocoonService/GenericRequest/Secrets/
Get.rs1#![allow(unused_variables, dead_code, unused_imports)]
2
3use serde_json::{Value, json};
4use tonic::Response;
5use CommonLibrary::Secret::SecretProvider::SecretProvider;
6
7use crate::{Environment::MountainEnvironment::MountainEnvironment, Vine::Generated::GenericResponse};
8
9pub async fn Fn(RequestId:u64, Params:Value, Env:&MountainEnvironment) -> Response<GenericResponse> {
10 let ExtensionId = Params.get("extensionId").and_then(|V| V.as_str()).unwrap_or("").to_string();
11
12 let Key = Params.get("key").and_then(|V| V.as_str()).unwrap_or("").to_string();
13
14 match Env.GetSecret(ExtensionId, Key).await {
15 Ok(Some(V)) => super::super::FileSystem::OkResponse(RequestId, &json!({ "value": V })),
16
17 Ok(None) => super::super::FileSystem::OkResponse(RequestId, &Value::Null),
18
19 Err(Error) => super::super::FileSystem::ErrResponse(RequestId, -32000, Error.to_string()),
20 }
21}