Skip to main content

Mountain/RPC/CocoonService/GenericRequest/Secrets/
Store.rs

1use serde_json::{Value, json};
2use tonic::Response;
3use CommonLibrary::Secret::SecretProvider::SecretProvider;
4use ::Vine::Generated::GenericResponse;
5
6use crate::Environment::MountainEnvironment::MountainEnvironment;
7
8pub async fn Fn(RequestId:u64, Params:Value, Env:&MountainEnvironment) -> Response<GenericResponse> {
9	let ExtensionId = Params.get("extensionId").and_then(|V| V.as_str()).unwrap_or("").to_string();
10
11	let Key = Params.get("key").and_then(|V| V.as_str()).unwrap_or("").to_string();
12
13	let V = Params.get("value").and_then(|V| V.as_str()).unwrap_or("").to_string();
14
15	match Env.StoreSecret(ExtensionId, Key, V).await {
16		Ok(()) => super::super::FileSystem::OkResponse(RequestId, &json!({ "success": true })),
17
18		Err(Error) => super::super::FileSystem::ErrResponse(RequestId, -32000, Error.to_string()),
19	}
20}