Skip to main content

openstack_cli_network/v2/floatingip/
port_forwarding.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//! FloatingIP Port Forwarding
16
17use clap::{Parser, Subcommand};
18
19use openstack_sdk::AsyncOpenStack;
20
21use openstack_cli_core::{cli::CliArgs, error::OpenStackCliError};
22
23pub mod create;
24pub mod delete;
25pub mod list;
26pub mod set;
27pub mod show;
28
29/// Floating IPs port forwarding
30///
31/// Lists, creates, shows details for, updates, and deletes floating IPs port forwardings.
32///
33/// ## Port forwarding with port ranges
34///
35/// The floating-ip-port-forwarding-port-ranges extension adds the new attributes
36/// internal_port_range and external_port_range to the floating IP port forwardings. The value of
37/// these new attributes should be a string that represents a colon separated port range. You can
38/// not use the attributes internal_port_range and external_port_range with the attributes
39/// internal_port and external_port in the same request.
40///
41/// ## Port forwarding rule description
42///
43/// The floating-ip-port-forwarding-description extension adds the description attribute to the
44/// floating IP port forwardings. The value of the description attribute contains a text describing
45/// the rule, which helps users to manage/find easily theirs rules.
46#[derive(Parser)]
47pub struct PortForwardingCommand {
48    /// subcommand
49    #[command(subcommand)]
50    command: PortForwardingCommands,
51}
52
53/// Supported subcommands
54#[allow(missing_docs)]
55#[derive(Subcommand)]
56pub enum PortForwardingCommands {
57    Create(create::PortForwardingCommand),
58    Delete(delete::PortForwardingCommand),
59    List(list::PortForwardingsCommand),
60    Set(set::PortForwardingCommand),
61    Show(show::PortForwardingCommand),
62}
63
64impl PortForwardingCommand {
65    /// Perform command action
66    pub async fn take_action<C: CliArgs>(
67        &self,
68        parsed_args: &C,
69        session: &mut AsyncOpenStack,
70    ) -> Result<(), OpenStackCliError> {
71        match &self.command {
72            PortForwardingCommands::Create(cmd) => cmd.take_action(parsed_args, session).await,
73            PortForwardingCommands::Delete(cmd) => cmd.take_action(parsed_args, session).await,
74            PortForwardingCommands::List(cmd) => cmd.take_action(parsed_args, session).await,
75            PortForwardingCommands::Set(cmd) => cmd.take_action(parsed_args, session).await,
76            PortForwardingCommands::Show(cmd) => cmd.take_action(parsed_args, session).await,
77        }
78    }
79}