Skip to main content

openstack_cli_network/v2/
flavor.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//! Flavor commands
16
17use clap::{Parser, Subcommand};
18
19use openstack_cli_core::{cli::CliArgs, error::OpenStackCliError};
20use openstack_sdk::AsyncOpenStack;
21
22pub mod create;
23pub mod delete;
24pub mod list;
25pub mod set;
26pub mod show;
27
28/// Networking Flavors Framework
29///
30/// Extension that allows user selection of operator-curated flavors during resource creation.
31///
32/// Users can check if flavor available by performing a GET on the /v2.0/extensions/flavors. If it
33/// is unavailable,there is an 404 error response (itemNotFound). Refer Show extension details for
34/// more details.
35#[derive(Parser)]
36pub struct FlavorCommand {
37    /// subcommand
38    #[command(subcommand)]
39    command: FlavorCommands,
40}
41
42/// Supported subcommands
43#[allow(missing_docs)]
44#[derive(Subcommand)]
45pub enum FlavorCommands {
46    Create(create::FlavorCommand),
47    Delete(delete::FlavorCommand),
48    List(list::FlavorsCommand),
49    Set(set::FlavorCommand),
50    Show(show::FlavorCommand),
51}
52
53impl FlavorCommand {
54    /// Perform command action
55    pub async fn take_action<C: CliArgs>(
56        &self,
57        parsed_args: &C,
58        session: &mut AsyncOpenStack,
59    ) -> Result<(), OpenStackCliError> {
60        match &self.command {
61            FlavorCommands::Create(cmd) => cmd.take_action(parsed_args, session).await,
62            FlavorCommands::Delete(cmd) => cmd.take_action(parsed_args, session).await,
63            FlavorCommands::List(cmd) => cmd.take_action(parsed_args, session).await,
64            FlavorCommands::Set(cmd) => cmd.take_action(parsed_args, session).await,
65            FlavorCommands::Show(cmd) => cmd.take_action(parsed_args, session).await,
66        }
67    }
68}