Skip to main content

openstack_cli_network/v2/
router.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//! Router commands
16
17use clap::{Parser, Subcommand};
18
19use openstack_cli_core::{cli::CliArgs, error::OpenStackCliError};
20use openstack_sdk::AsyncOpenStack;
21
22pub mod add_external_gateways;
23pub mod add_extraroutes;
24pub mod add_router_interface;
25pub mod conntrack_helper;
26pub mod create;
27pub mod delete;
28pub mod l3_agent;
29pub mod list;
30pub mod remove_external_gateways;
31pub mod remove_extraroutes;
32pub mod remove_router_interface;
33pub mod set;
34pub mod show;
35pub mod tag;
36
37/// Router commands
38#[derive(Parser)]
39pub struct RouterCommand {
40    /// subcommand
41    #[command(subcommand)]
42    command: RouterCommands,
43}
44
45/// Supported subcommands
46#[allow(missing_docs)]
47#[derive(Subcommand)]
48pub enum RouterCommands {
49    AddExternalGateway(Box<add_external_gateways::RouterCommand>),
50    AddExtraroute(Box<add_extraroutes::RouterCommand>),
51    AddRouterInterface(Box<add_router_interface::RouterCommand>),
52    ConntrackHelper(Box<conntrack_helper::ConntrackHelperCommand>),
53    Create(create::RouterCommand),
54    Delete(delete::RouterCommand),
55    L3Agent(l3_agent::L3AgentCommand),
56    List(list::RoutersCommand),
57    RemoveExternalGateway(Box<remove_external_gateways::RouterCommand>),
58    RemoveExtraroute(Box<remove_extraroutes::RouterCommand>),
59    RemoveRouterInterface(Box<remove_router_interface::RouterCommand>),
60    Set(set::RouterCommand),
61    Show(show::RouterCommand),
62    Tag(tag::TagCommand),
63}
64
65impl RouterCommand {
66    /// Perform command action
67    pub async fn take_action<C: CliArgs>(
68        &self,
69        parsed_args: &C,
70        session: &mut AsyncOpenStack,
71    ) -> Result<(), OpenStackCliError> {
72        match &self.command {
73            RouterCommands::AddExternalGateway(cmd) => cmd.take_action(parsed_args, session).await,
74            RouterCommands::AddExtraroute(cmd) => cmd.take_action(parsed_args, session).await,
75            RouterCommands::AddRouterInterface(cmd) => cmd.take_action(parsed_args, session).await,
76            RouterCommands::ConntrackHelper(cmd) => cmd.take_action(parsed_args, session).await,
77            RouterCommands::Create(cmd) => cmd.take_action(parsed_args, session).await,
78            RouterCommands::Delete(cmd) => cmd.take_action(parsed_args, session).await,
79            RouterCommands::L3Agent(cmd) => cmd.take_action(parsed_args, session).await,
80            RouterCommands::List(cmd) => cmd.take_action(parsed_args, session).await,
81            RouterCommands::RemoveExternalGateway(cmd) => {
82                cmd.take_action(parsed_args, session).await
83            }
84            RouterCommands::RemoveExtraroute(cmd) => cmd.take_action(parsed_args, session).await,
85            RouterCommands::RemoveRouterInterface(cmd) => {
86                cmd.take_action(parsed_args, session).await
87            }
88            RouterCommands::Set(cmd) => cmd.take_action(parsed_args, session).await,
89            RouterCommands::Show(cmd) => cmd.take_action(parsed_args, session).await,
90            RouterCommands::Tag(cmd) => cmd.take_action(parsed_args, session).await,
91        }
92    }
93}