Skip to main content

openstack_cli_block_storage/v3/backup/
os_reset_status.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 Backup command
19//!
20//! Wraps invoking of the `v3/backups/{id}/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::backup::os_reset_status;
33
34/// Command without description in OpenAPI
35#[derive(Args)]
36pub struct BackupCommand {
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    os_reset_status: OsResetStatus,
47}
48
49/// Query parameters
50#[derive(Args)]
51struct QueryParameters {}
52
53/// Path parameters
54#[derive(Args)]
55struct PathParameters {
56    /// id parameter for /v3/backups/{id}/action API
57    #[arg(
58        help_heading = "Path parameters",
59        id = "path_param_id",
60        value_name = "ID"
61    )]
62    id: String,
63}
64/// OsResetStatus Body data
65#[derive(Args, Clone)]
66struct OsResetStatus {
67    #[arg(help_heading = "Body parameters", long)]
68    status: String,
69}
70
71impl BackupCommand {
72    /// Perform command action
73    pub async fn take_action<C: CliArgs>(
74        &self,
75        parsed_args: &C,
76        client: &mut AsyncOpenStack,
77    ) -> Result<(), OpenStackCliError> {
78        info!("Action Backup");
79
80        let op = OutputProcessor::from_args(
81            parsed_args,
82            Some("block-storage.backup"),
83            Some("os_reset_status"),
84        );
85        op.validate_args(parsed_args)?;
86
87        let mut ep_builder = os_reset_status::Request::builder();
88
89        ep_builder.id(&self.path.id);
90
91        // Set body parameters
92        // Set Request.os_reset_status data
93        let args = &self.os_reset_status;
94        let mut os_reset_status_builder = os_reset_status::OsResetStatusBuilder::default();
95
96        os_reset_status_builder.status(&args.status);
97
98        ep_builder.os_reset_status(
99            os_reset_status_builder
100                .build()
101                .wrap_err("error preparing the request data")?,
102        );
103
104        let ep = ep_builder
105            .build()
106            .map_err(|x| OpenStackCliError::EndpointBuild(x.to_string()))?;
107        openstack_sdk::api::ignore(ep).query_async(client).await?;
108        // Show command specific hints
109        op.show_command_hint()?;
110        Ok(())
111    }
112}