use clap::Parser;
use cosmian_kms_client::KmsClientConfig;
use super::KEY_PAIRS_ENDPOINT;
use crate::{actions::kms::google::gmail_client::GmailClient, error::result::KmsCliResult};
#[derive(Parser)]
#[clap(verbatim_doc_comment)]
pub struct EnableKeyPairsAction {
#[clap(required = true)]
key_pairs_id: String,
#[clap(long, short = 'u', required = true)]
user_id: String,
}
impl EnableKeyPairsAction {
pub async fn run(&self, config: KmsClientConfig) -> KmsCliResult<()> {
let endpoint = [KEY_PAIRS_ENDPOINT, &self.key_pairs_id, ":enable"].concat();
let gmail_client = GmailClient::new(config, &self.user_id);
let response = gmail_client.await?.post(&endpoint, String::new()).await?;
GmailClient::handle_response(response).await
}
}