openstack_cli_placement/v1/resource_provider/inventory/delete_all.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 Inventory command
19//!
20//! Wraps invoking of the `resource_providers/{uuid}/inventories` 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::placement::v1::resource_provider::inventory::delete_all;
32
33/// Deletes all inventory records for the resource provider identified by
34/// {uuid}.
35///
36/// **Troubleshooting**
37///
38/// The request returns an HTTP 409 when there are allocations against the
39/// provider or if the provider’s inventory is updated by another thread while
40/// attempting the operation.
41///
42/// Normal Response Codes: 204
43///
44/// Error response codes: itemNotFound(404), conflict(409)
45#[derive(Args)]
46#[command(about = "Delete resource provider inventories")]
47pub struct InventoryCommand {
48 /// Request Query parameters
49 #[command(flatten)]
50 query: QueryParameters,
51
52 /// Path parameters
53 #[command(flatten)]
54 path: PathParameters,
55}
56
57/// Query parameters
58#[derive(Args)]
59struct QueryParameters {}
60
61/// Path parameters
62#[derive(Args)]
63struct PathParameters {
64 /// uuid parameter for
65 /// /resource_providers/{uuid}/inventories/{resource_class} API
66 #[arg(
67 help_heading = "Path parameters",
68 id = "path_param_uuid",
69 value_name = "UUID"
70 )]
71 uuid: String,
72}
73
74impl InventoryCommand {
75 /// Perform command action
76 pub async fn take_action<C: CliArgs>(
77 &self,
78 parsed_args: &C,
79 client: &mut AsyncOpenStack,
80 ) -> Result<(), OpenStackCliError> {
81 info!("Delete Inventory");
82
83 let op = OutputProcessor::from_args(
84 parsed_args,
85 Some("placement.resource_provider/inventory"),
86 Some("delete_all"),
87 );
88 op.validate_args(parsed_args)?;
89
90 let mut ep_builder = delete_all::Request::builder();
91
92 ep_builder.uuid(&self.path.uuid);
93
94 let ep = ep_builder
95 .build()
96 .map_err(|x| OpenStackCliError::EndpointBuild(x.to_string()))?;
97 openstack_sdk::api::ignore(ep).query_async(client).await?;
98 // Show command specific hints
99 op.show_command_hint()?;
100 Ok(())
101 }
102}