Skip to main content

openstack_cli_placement/v1/resource_class/
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 ResourceClass command
19//!
20//! Wraps invoking of the `resource_classes/{name}` 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_class::delete;
32
33/// Delete the resource class identified by {name}.
34///
35/// Normal Response Codes: 204
36///
37/// Error response codes: badRequest(400), itemNotFound(404), conflict(409)
38///
39/// A 400 BadRequest response code will be returned if trying to delete a
40/// standard resource class.
41///
42/// A 409 Conflict response code will be returned if there exist inventories
43/// for the resource class.
44#[derive(Args)]
45#[command(about = "Delete resource class")]
46pub struct ResourceClassCommand {
47    /// Request Query parameters
48    #[command(flatten)]
49    query: QueryParameters,
50
51    /// Path parameters
52    #[command(flatten)]
53    path: PathParameters,
54}
55
56/// Query parameters
57#[derive(Args)]
58struct QueryParameters {}
59
60/// Path parameters
61#[derive(Args)]
62struct PathParameters {
63    /// name parameter for /resource_classes/{name} API
64    #[arg(
65        help_heading = "Path parameters",
66        id = "path_param_name",
67        value_name = "NAME"
68    )]
69    name: String,
70}
71
72impl ResourceClassCommand {
73    /// Perform command action
74    pub async fn take_action<C: CliArgs>(
75        &self,
76        parsed_args: &C,
77        client: &mut AsyncOpenStack,
78    ) -> Result<(), OpenStackCliError> {
79        info!("Delete ResourceClass");
80
81        let op = OutputProcessor::from_args(
82            parsed_args,
83            Some("placement.resource_class"),
84            Some("delete"),
85        );
86        op.validate_args(parsed_args)?;
87
88        let mut ep_builder = delete::Request::builder();
89
90        ep_builder.name(&self.path.name);
91
92        let ep = ep_builder
93            .build()
94            .map_err(|x| OpenStackCliError::EndpointBuild(x.to_string()))?;
95        openstack_sdk::api::ignore(ep).query_async(client).await?;
96        // Show command specific hints
97        op.show_command_hint()?;
98        Ok(())
99    }
100}