Skip to main content

openstack_cli_block_storage/v3/group/
delete_313.rs

1// Licensed under the Apache License, Version 2.0 (the "License");
2// you may not use this file except in compliance with the License.
3// You may obtain a copy of the License at
4//
5//     http://www.apache.org/licenses/LICENSE-2.0
6//
7// Unless required by applicable law or agreed to in writing, software
8// distributed under the License is distributed on an "AS IS" BASIS,
9// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
10// See the License for the specific language governing permissions and
11// limitations under the License.
12//
13// SPDX-License-Identifier: Apache-2.0
14//
15// WARNING: This file is automatically generated from OpenAPI schema using
16// `openstack-codegenerator`.
17
18//! Action Group command [microversion = 3.13]
19//!
20//! Wraps invoking of the `v3/groups/action` with `POST` method
21
22use clap::Args;
23use eyre::WrapErr;
24use tracing::info;
25
26use openstack_cli_core::cli::CliArgs;
27use openstack_cli_core::error::OpenStackCliError;
28use openstack_cli_core::output::OutputProcessor;
29use openstack_sdk::AsyncOpenStack;
30
31use openstack_sdk::api::QueryAsync;
32use openstack_sdk::api::block_storage::v3::group::delete_313;
33
34/// Command without description in OpenAPI
35#[derive(Args)]
36pub struct GroupCommand {
37    /// Request Query parameters
38    #[command(flatten)]
39    query: QueryParameters,
40
41    /// Path parameters
42    #[command(flatten)]
43    path: PathParameters,
44
45    #[command(flatten)]
46    delete: Delete,
47}
48
49/// Query parameters
50#[derive(Args)]
51struct QueryParameters {}
52
53/// Path parameters
54#[derive(Args)]
55struct PathParameters {}
56/// Delete Body data
57#[derive(Args, Clone)]
58struct Delete {
59    #[arg(action=clap::ArgAction::Set, help_heading = "Body parameters", long)]
60    delete_volumes: Option<bool>,
61}
62
63impl GroupCommand {
64    /// Perform command action
65    pub async fn take_action<C: CliArgs>(
66        &self,
67        parsed_args: &C,
68        client: &mut AsyncOpenStack,
69    ) -> Result<(), OpenStackCliError> {
70        info!("Action Group");
71
72        let op =
73            OutputProcessor::from_args(parsed_args, Some("block-storage.group"), Some("delete"));
74        op.validate_args(parsed_args)?;
75
76        let mut ep_builder = delete_313::Request::builder();
77        ep_builder.header(
78            http::header::HeaderName::from_static("openstack-api-version"),
79            http::header::HeaderValue::from_static("volume 3.13"),
80        );
81
82        // Set body parameters
83        // Set Request.delete data
84        let args = &self.delete;
85        let mut delete_builder = delete_313::DeleteBuilder::default();
86        if let Some(val) = &args.delete_volumes {
87            delete_builder.delete_volumes(*val);
88        }
89
90        ep_builder.delete(
91            delete_builder
92                .build()
93                .wrap_err("error preparing the request data")?,
94        );
95
96        let ep = ep_builder
97            .build()
98            .map_err(|x| OpenStackCliError::EndpointBuild(x.to_string()))?;
99        openstack_sdk::api::ignore(ep).query_async(client).await?;
100        // Show command specific hints
101        op.show_command_hint()?;
102        Ok(())
103    }
104}