openstack_cli_compute/v2/assisted_volume_snapshot/delete.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//! Delete AssistedVolumeSnapshot command
19//!
20//! Wraps invoking of the `v2.1/os-assisted-volume-snapshots/{id}` with `DELETE` method
21
22use clap::Args;
23use tracing::info;
24
25use openstack_cli_core::cli::CliArgs;
26use openstack_cli_core::error::OpenStackCliError;
27use openstack_cli_core::output::OutputProcessor;
28use openstack_sdk::AsyncOpenStack;
29
30use openstack_sdk::api::QueryAsync;
31use openstack_sdk::api::compute::v2::assisted_volume_snapshot::delete;
32
33/// Deletes an assisted volume snapshot.
34///
35/// To make this request, add the `delete_info` query parameter to the URI, as
36/// follows:
37///
38/// DELETE
39/// /os-assisted-volume-snapshots/421752a6-acf6-4b2d-bc7a-119f9148cd8c?delete_info=’{“volume_id”:
40/// “521752a6-acf6-4b2d-bc7a-119f9148cd8c”}’
41///
42/// Normal response codes: 204
43///
44/// Error response codes: badRequest(400), unauthorized(401), forbidden(403),
45/// itemNotFound(404)
46#[derive(Args)]
47#[command(about = "Delete Assisted Volume Snapshot")]
48pub struct AssistedVolumeSnapshotCommand {
49 /// Request Query parameters
50 #[command(flatten)]
51 query: QueryParameters,
52
53 /// Path parameters
54 #[command(flatten)]
55 path: PathParameters,
56}
57
58/// Query parameters
59#[derive(Args)]
60struct QueryParameters {
61 #[arg(help_heading = "Query parameters", long)]
62 delete_info: Option<String>,
63}
64
65/// Path parameters
66#[derive(Args)]
67struct PathParameters {
68 /// id parameter for /v2.1/os-assisted-volume-snapshots/{id} API
69 #[arg(
70 help_heading = "Path parameters",
71 id = "path_param_id",
72 value_name = "ID"
73 )]
74 id: String,
75}
76
77impl AssistedVolumeSnapshotCommand {
78 /// Perform command action
79 pub async fn take_action<C: CliArgs>(
80 &self,
81 parsed_args: &C,
82 client: &mut AsyncOpenStack,
83 ) -> Result<(), OpenStackCliError> {
84 info!("Delete AssistedVolumeSnapshot");
85
86 let op = OutputProcessor::from_args(
87 parsed_args,
88 Some("compute.assisted_volume_snapshot"),
89 Some("delete"),
90 );
91 op.validate_args(parsed_args)?;
92
93 let mut ep_builder = delete::Request::builder();
94
95 ep_builder.id(&self.path.id);
96 // Set query parameters
97 if let Some(val) = &self.query.delete_info {
98 ep_builder.delete_info(val);
99 }
100
101 let ep = ep_builder
102 .build()
103 .map_err(|x| OpenStackCliError::EndpointBuild(x.to_string()))?;
104 openstack_sdk::api::ignore(ep).query_async(client).await?;
105 // Show command specific hints
106 op.show_command_hint()?;
107 Ok(())
108 }
109}