Skip to main content

openstack_cli_placement/v1/resource_provider/
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 ResourceProvider command
19//!
20//! Wraps invoking of the `resource_providers/{uuid}` 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::delete;
32
33/// Delete the resource provider identified by {uuid}. This will also
34/// disassociate aggregates and delete inventories.
35///
36/// Normal Response Codes: 204
37///
38/// Error response codes: itemNotFound(404), conflict(409)
39///
40/// A 409 Conflict response code will be returned if there exist allocations
41/// records for any of the inventories that would be deleted as a result of
42/// removing the resource provider.
43///
44/// This error code will be also returned if there are existing child resource
45/// providers under the parent resource provider being deleted.
46#[derive(Args)]
47#[command(about = "Delete resource provider")]
48pub struct ResourceProviderCommand {
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
62/// Path parameters
63#[derive(Args)]
64struct PathParameters {
65    /// uuid parameter for /resource_providers/{uuid} API
66    #[arg(
67        help_heading = "Path parameters",
68        id = "path_param_uuid",
69        value_name = "UUID"
70    )]
71    uuid: String,
72}
73
74impl ResourceProviderCommand {
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 ResourceProvider");
82
83        let op = OutputProcessor::from_args(
84            parsed_args,
85            Some("placement.resource_provider"),
86            Some("delete"),
87        );
88        op.validate_args(parsed_args)?;
89
90        let mut ep_builder = delete::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}