use serde::Deserialize;
use serde_json::json;

use super::{common, ToolResult};

#[derive(Debug, Deserialize)]
#[serde(deny_unknown_fields)]
pub struct RotateParams {
    pub name: String,
}

pub async fn execute(params: RotateParams) -> ToolResult {
    common::validate_secret_name(&params.name, "name")?;
    envseal::ops::rotate_secret(&params.name).map_err(|e| e.to_string())?;

    Ok(json!({
        "rotated": true,
        "name": params.name
    }))
}
