Skip to main content

openstack_cli_block_storage/v3/group/
reset_status_320.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.20]
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::reset_status_320;
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    reset_status: ResetStatus,
47}
48
49/// Query parameters
50#[derive(Args)]
51struct QueryParameters {}
52
53/// Path parameters
54#[derive(Args)]
55struct PathParameters {}
56/// ResetStatus Body data
57#[derive(Args, Clone)]
58struct ResetStatus {
59    #[arg(help_heading = "Body parameters", long)]
60    status: String,
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 = OutputProcessor::from_args(
73            parsed_args,
74            Some("block-storage.group"),
75            Some("reset_status"),
76        );
77        op.validate_args(parsed_args)?;
78
79        let mut ep_builder = reset_status_320::Request::builder();
80        ep_builder.header(
81            http::header::HeaderName::from_static("openstack-api-version"),
82            http::header::HeaderValue::from_static("volume 3.20"),
83        );
84
85        // Set body parameters
86        // Set Request.reset_status data
87        let args = &self.reset_status;
88        let mut reset_status_builder = reset_status_320::ResetStatusBuilder::default();
89
90        reset_status_builder.status(&args.status);
91
92        ep_builder.reset_status(
93            reset_status_builder
94                .build()
95                .wrap_err("error preparing the request data")?,
96        );
97
98        let ep = ep_builder
99            .build()
100            .map_err(|x| OpenStackCliError::EndpointBuild(x.to_string()))?;
101        openstack_sdk::api::ignore(ep).query_async(client).await?;
102        // Show command specific hints
103        op.show_command_hint()?;
104        Ok(())
105    }
106}