use async_trait::async_trait;
use clap::Args;
use serde::{Deserialize, Serialize};
use tracing::info;
use crate::output::OutputProcessor;
use crate::Cli;
use structable::StructTableOptions;
use crate::StructTable;
use crate::{OSCCommand, OpenStackCliError};
use openstack_sdk::AsyncOpenStack;
use bytes::Bytes;
use http::Response;
use openstack_sdk::api::compute::v2::server::os_get_vncconsole;
use openstack_sdk::api::RawQueryAsync;
#[derive(Args, Clone, Debug)]
pub struct ServerArgs {
#[command(flatten)]
query: QueryParameters,
#[command(flatten)]
path: PathParameters,
}
#[derive(Args, Clone, Debug)]
pub struct QueryParameters {}
#[derive(Args, Clone, Debug)]
pub struct PathParameters {
#[arg()]
id: String,
}
pub struct ServerCmd {
pub args: ServerArgs,
}
#[derive(Deserialize, Debug, Clone, Serialize, StructTable)]
pub struct ResponseData {}
#[async_trait]
impl OSCCommand for ServerCmd {
async fn take_action(
&self,
parsed_args: &Cli,
client: &mut AsyncOpenStack,
) -> Result<(), OpenStackCliError> {
info!("Action Server with {:?}", self.args);
let op = OutputProcessor::from_args(parsed_args);
op.validate_args(parsed_args)?;
info!("Parsed args: {:?}", self.args);
let mut ep_builder = os_get_vncconsole::Request::builder();
ep_builder.id(&self.args.path.id);
let ep = ep_builder
.build()
.map_err(|x| OpenStackCliError::EndpointBuild(x.to_string()))?;
let rsp: Response<Bytes> = ep.raw_query_async(client).await?;
let data = ResponseData {};
op.output_human::<ResponseData>(&data)?;
Ok(())
}
}