Skip to main content

openstack_cli_network/v2/
qos.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//! Quality of service commands
16
17use clap::{Parser, Subcommand};
18
19use openstack_cli_core::{cli::CliArgs, error::OpenStackCliError};
20use openstack_sdk::AsyncOpenStack;
21
22pub mod alias_bandwidth_limit_rule;
23pub mod alias_dscp_marking_rule;
24pub mod alias_minimum_bandwidth_rule;
25pub mod alias_minimum_packet_rate_rule;
26pub mod policy;
27pub mod rule_type;
28
29/// Quality of Service
30#[derive(Parser)]
31pub struct QosCommand {
32    /// subcommand
33    #[command(subcommand)]
34    command: QosCommands,
35}
36
37/// Supported subcommands
38#[allow(missing_docs)]
39#[derive(Subcommand)]
40pub enum QosCommands {
41    AliasBandwidthLimitRule(Box<alias_bandwidth_limit_rule::AliasBandwidthLimitRuleCommand>),
42    AliasDscpMarkingRule(Box<alias_dscp_marking_rule::AliasDscpMarkingRuleCommand>),
43    AliasMinimumBandwidthRule(Box<alias_minimum_bandwidth_rule::AliasMinimumBandwidthRuleCommand>),
44    AliasMinimumPacketRateRule(
45        Box<alias_minimum_packet_rate_rule::AliasMinimumPacketRateRuleCommand>,
46    ),
47    Policy(Box<policy::PolicyCommand>),
48    RuleType(Box<rule_type::RuleTypeCommand>),
49}
50
51impl QosCommand {
52    /// Perform command action
53    pub async fn take_action<C: CliArgs>(
54        &self,
55        parsed_args: &C,
56        session: &mut AsyncOpenStack,
57    ) -> Result<(), OpenStackCliError> {
58        match &self.command {
59            QosCommands::AliasBandwidthLimitRule(cmd) => {
60                cmd.take_action(parsed_args, session).await
61            }
62            QosCommands::AliasDscpMarkingRule(cmd) => cmd.take_action(parsed_args, session).await,
63            QosCommands::AliasMinimumBandwidthRule(cmd) => {
64                cmd.take_action(parsed_args, session).await
65            }
66            QosCommands::AliasMinimumPacketRateRule(cmd) => {
67                cmd.take_action(parsed_args, session).await
68            }
69            QosCommands::Policy(cmd) => cmd.take_action(parsed_args, session).await,
70            QosCommands::RuleType(cmd) => cmd.take_action(parsed_args, session).await,
71        }
72    }
73}