use clap::Args;
use tracing::info;
use openstack_sdk::AsyncOpenStack;
use crate::Cli;
use crate::OpenStackCliError;
use crate::output::OutputProcessor;
use openstack_sdk::api::QueryAsync;
use openstack_sdk::api::block_storage::v3::qos_spec::find;
use openstack_sdk::api::find;
use openstack_types::block_storage::v3::qos_spec::response::get::QosSpecResponse;
#[derive(Args)]
pub struct QosSpecCommand {
#[command(flatten)]
query: QueryParameters,
#[command(flatten)]
path: PathParameters,
}
#[derive(Args)]
struct QueryParameters {}
#[derive(Args)]
struct PathParameters {
#[arg(
help_heading = "Path parameters",
id = "path_param_id",
value_name = "ID"
)]
id: String,
}
impl QosSpecCommand {
pub async fn take_action(
&self,
parsed_args: &Cli,
client: &mut AsyncOpenStack,
) -> Result<(), OpenStackCliError> {
info!("Show QosSpec");
let op =
OutputProcessor::from_args(parsed_args, Some("block-storage.qos_spec"), Some("show"));
op.validate_args(parsed_args)?;
let mut find_builder = find::Request::builder();
find_builder.id(&self.path.id);
let find_ep = find_builder
.build()
.map_err(|x| OpenStackCliError::EndpointBuild(x.to_string()))?;
let find_data: serde_json::Value = find(find_ep).query_async(client).await?;
op.output_single::<QosSpecResponse>(find_data)?;
op.show_command_hint()?;
Ok(())
}
}