Skip to main content

openstack_cli_network/v2/qos/
policy.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//! QoS policy commands
16
17use clap::{Parser, Subcommand};
18
19use openstack_sdk::AsyncOpenStack;
20
21use openstack_cli_core::{cli::CliArgs, error::OpenStackCliError};
22
23pub mod bandwidth_limit_rule;
24pub mod create;
25pub mod delete;
26pub mod dscp_marking_rule;
27pub mod list;
28pub mod minimum_bandwidth_rule;
29pub mod minimum_packet_rate_rule;
30pub mod set;
31pub mod show;
32
33/// QoS minimum packet rate rules
34///
35/// Lists, creates, deletes, shows information for, and updates QoS minimum packet rate rules.
36#[derive(Parser)]
37pub struct PolicyCommand {
38    /// subcommand
39    #[command(subcommand)]
40    command: PolicyCommands,
41}
42
43/// Supported subcommands
44#[allow(missing_docs)]
45#[derive(Subcommand)]
46pub enum PolicyCommands {
47    BandwidthLimitRule(Box<bandwidth_limit_rule::BandwidthLimitRuleCommand>),
48    Create(Box<create::PolicyCommand>),
49    Delete(delete::PolicyCommand),
50    DscpMarkingRule(dscp_marking_rule::DscpMarkingRuleCommand),
51    List(Box<list::PoliciesCommand>),
52    MinimumBandwidthRule(Box<minimum_bandwidth_rule::MinimumBandwidthRuleCommand>),
53    MinimumPacketRateRule(Box<minimum_packet_rate_rule::MinimumPacketRateRuleCommand>),
54    Set(Box<set::PolicyCommand>),
55    Show(Box<show::PolicyCommand>),
56}
57
58impl PolicyCommand {
59    /// Perform command action
60    pub async fn take_action<C: CliArgs>(
61        &self,
62        parsed_args: &C,
63        session: &mut AsyncOpenStack,
64    ) -> Result<(), OpenStackCliError> {
65        match &self.command {
66            PolicyCommands::BandwidthLimitRule(cmd) => cmd.take_action(parsed_args, session).await,
67            PolicyCommands::Create(cmd) => cmd.take_action(parsed_args, session).await,
68            PolicyCommands::Delete(cmd) => cmd.take_action(parsed_args, session).await,
69            PolicyCommands::DscpMarkingRule(cmd) => cmd.take_action(parsed_args, session).await,
70            PolicyCommands::List(cmd) => cmd.take_action(parsed_args, session).await,
71            PolicyCommands::MinimumBandwidthRule(cmd) => {
72                cmd.take_action(parsed_args, session).await
73            }
74            PolicyCommands::MinimumPacketRateRule(cmd) => {
75                cmd.take_action(parsed_args, session).await
76            }
77            PolicyCommands::Set(cmd) => cmd.take_action(parsed_args, session).await,
78            PolicyCommands::Show(cmd) => cmd.take_action(parsed_args, session).await,
79        }
80    }
81}