openstack_cli_placement/v1/resource_provider/inventory/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 Inventory command
19//!
20//! Wraps invoking of the `resource_providers/{uuid}/inventories/{resource_class}` 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;
32
33/// Delete the inventory record of the {resource_class} for the resource
34/// provider identified by {uuid}.
35///
36/// See
37/// [Troubleshooting](?expanded=delete-resource-provider-inventories-detail#delete-resource-provider-inventories)
38/// section in `Delete resource provider inventories` for a description. In
39/// addition, the request returns HTTP 409 when there are allocations for the
40/// specified resource provider and resource class.
41///
42/// Normal Response Codes: 204
43///
44/// Error response codes: itemNotFound(404), conflict(409)
45#[derive(Args)]
46#[command(about = "Delete resource provider inventory")]
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 /// resource_class parameter for
65 /// /resource_providers/{uuid}/inventories/{resource_class} API
66 #[arg(
67 help_heading = "Path parameters",
68 id = "path_param_resource_class",
69 value_name = "RESOURCE_CLASS"
70 )]
71 resource_class: String,
72
73 /// uuid parameter for
74 /// /resource_providers/{uuid}/inventories/{resource_class} API
75 #[arg(
76 help_heading = "Path parameters",
77 id = "path_param_uuid",
78 value_name = "UUID"
79 )]
80 uuid: String,
81}
82
83impl InventoryCommand {
84 /// Perform command action
85 pub async fn take_action<C: CliArgs>(
86 &self,
87 parsed_args: &C,
88 client: &mut AsyncOpenStack,
89 ) -> Result<(), OpenStackCliError> {
90 info!("Delete Inventory");
91
92 let op = OutputProcessor::from_args(
93 parsed_args,
94 Some("placement.resource_provider/inventory"),
95 Some("delete"),
96 );
97 op.validate_args(parsed_args)?;
98
99 let mut ep_builder = delete::Request::builder();
100
101 ep_builder.resource_class(&self.path.resource_class);
102 ep_builder.uuid(&self.path.uuid);
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}