Skip to main content

openstack_cli_network/v2/port/binding/
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 Binding command
19//!
20//! Wraps invoking of the `v2.0/ports/{port_id}/bindings/{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::network::v2::port::binding::delete;
32
33/// Normal response codes: 204
34///
35/// Error response codes: 401, 403, 404, 412
36#[derive(Args)]
37#[command(about = "Delete Port Binding")]
38pub struct BindingCommand {
39    /// Request Query parameters
40    #[command(flatten)]
41    query: QueryParameters,
42
43    /// Path parameters
44    #[command(flatten)]
45    path: PathParameters,
46}
47
48/// Query parameters
49#[derive(Args)]
50struct QueryParameters {}
51
52/// Path parameters
53#[derive(Args)]
54struct PathParameters {
55    /// id parameter for /v2.0/ports/{port_id}/bindings/{id} API
56    #[arg(
57        help_heading = "Path parameters",
58        id = "path_param_id",
59        value_name = "ID"
60    )]
61    id: String,
62
63    /// port_id parameter for /v2.0/ports/{port_id}/bindings/{id} API
64    #[arg(
65        help_heading = "Path parameters",
66        id = "path_param_port_id",
67        value_name = "PORT_ID"
68    )]
69    port_id: String,
70}
71
72impl BindingCommand {
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 Binding");
80
81        let op =
82            OutputProcessor::from_args(parsed_args, Some("network.port/binding"), Some("delete"));
83        op.validate_args(parsed_args)?;
84
85        let mut ep_builder = delete::Request::builder();
86
87        ep_builder.id(&self.path.id);
88        ep_builder.port_id(&self.path.port_id);
89
90        let ep = ep_builder
91            .build()
92            .map_err(|x| OpenStackCliError::EndpointBuild(x.to_string()))?;
93        openstack_sdk::api::ignore(ep).query_async(client).await?;
94        // Show command specific hints
95        op.show_command_hint()?;
96        Ok(())
97    }
98}