openstack_cli/load_balancer/v2/l7policy/rule/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 Rule command
19//!
20//! Wraps invoking of the `v2/lbaas/l7policies/{l7policy_id}/rules/{rule_id}` with `DELETE` method
21
22use clap::Args;
23use serde::{Deserialize, Serialize};
24use tracing::info;
25
26use openstack_sdk::AsyncOpenStack;
27
28use crate::Cli;
29use crate::OpenStackCliError;
30use crate::OutputConfig;
31use crate::StructTable;
32use crate::output::OutputProcessor;
33
34use bytes::Bytes;
35use http::Response;
36use openstack_sdk::api::RawQueryAsync;
37use openstack_sdk::api::load_balancer::v2::l7policy::rule::delete;
38use structable_derive::StructTable;
39
40/// Removes a L7 rule and its associated configuration from the project.
41///
42/// The API immediately purges any and all configuration data, depending on the
43/// configuration settings. You cannot recover it.
44///
45#[derive(Args)]
46#[command(about = "Remove a L7 Rule")]
47pub struct RuleCommand {
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 /// l7policy_id parameter for
65 /// /v2/lbaas/l7policies/{l7policy_id}/rules/{rule_id} API
66 ///
67 #[arg(
68 help_heading = "Path parameters",
69 id = "path_param_l7policy_id",
70 value_name = "L7POLICY_ID"
71 )]
72 l7policy_id: String,
73
74 /// rule_id parameter for
75 /// /v2/lbaas/l7policies/{l7policy_id}/rules/{rule_id} API
76 ///
77 #[arg(
78 help_heading = "Path parameters",
79 id = "path_param_id",
80 value_name = "ID"
81 )]
82 id: String,
83}
84/// Rule response representation
85#[derive(Deserialize, Serialize, Clone, StructTable)]
86struct ResponseData {}
87
88impl RuleCommand {
89 /// Perform command action
90 pub async fn take_action(
91 &self,
92 parsed_args: &Cli,
93 client: &mut AsyncOpenStack,
94 ) -> Result<(), OpenStackCliError> {
95 info!("Delete Rule");
96
97 let op = OutputProcessor::from_args(parsed_args);
98 op.validate_args(parsed_args)?;
99
100 let mut ep_builder = delete::Request::builder();
101
102 // Set path parameters
103 ep_builder.l7policy_id(&self.path.l7policy_id);
104 ep_builder.id(&self.path.id);
105 // Set query parameters
106 // Set body parameters
107
108 let ep = ep_builder
109 .build()
110 .map_err(|x| OpenStackCliError::EndpointBuild(x.to_string()))?;
111
112 let _rsp: Response<Bytes> = ep.raw_query_async(client).await?;
113 Ok(())
114 }
115}