Skip to main content

openstack_cli_block_storage/v3/
volume.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//! Block storage Volume commands
16//!
17
18use clap::{Parser, Subcommand};
19
20use openstack_cli_core::{cli::CliArgs, error::OpenStackCliError};
21use openstack_sdk::AsyncOpenStack;
22
23pub mod create_30;
24pub mod create_313;
25pub mod create_347;
26pub mod create_353;
27pub mod delete;
28pub mod list;
29pub mod metadata;
30pub mod os_extend;
31pub mod set_30;
32pub mod set_353;
33pub mod show;
34
35/// Block Storage Volume commands
36#[derive(Parser)]
37pub struct VolumeCommand {
38    /// subcommand
39    #[command(subcommand)]
40    command: VolumeCommands,
41}
42
43/// Supported subcommands
44#[allow(missing_docs)]
45#[derive(Subcommand)]
46pub enum VolumeCommands {
47    #[command(visible_alias = "create")]
48    Create353(Box<create_353::VolumeCommand>),
49    Create347(Box<create_347::VolumeCommand>),
50    Create313(Box<create_313::VolumeCommand>),
51    Create30(Box<create_30::VolumeCommand>),
52    Delete(Box<delete::VolumeCommand>),
53    Extend(Box<os_extend::VolumeCommand>),
54    List(Box<list::VolumesCommand>),
55    Metadata(Box<metadata::MetadataCommand>),
56    #[command(visible_alias = "set")]
57    Set353(Box<set_353::VolumeCommand>),
58    Set30(Box<set_30::VolumeCommand>),
59    Show(Box<show::VolumeCommand>),
60}
61
62impl VolumeCommand {
63    /// Perform command action
64    pub async fn take_action<C: CliArgs>(
65        &self,
66        parsed_args: &C,
67        session: &mut AsyncOpenStack,
68    ) -> Result<(), OpenStackCliError> {
69        match &self.command {
70            VolumeCommands::Create353(cmd) => cmd.take_action(parsed_args, session).await,
71            VolumeCommands::Create347(cmd) => cmd.take_action(parsed_args, session).await,
72            VolumeCommands::Create313(cmd) => cmd.take_action(parsed_args, session).await,
73            VolumeCommands::Create30(cmd) => cmd.take_action(parsed_args, session).await,
74            VolumeCommands::Delete(cmd) => cmd.take_action(parsed_args, session).await,
75            VolumeCommands::Extend(cmd) => cmd.take_action(parsed_args, session).await,
76            VolumeCommands::List(cmd) => cmd.take_action(parsed_args, session).await,
77            VolumeCommands::Metadata(cmd) => cmd.take_action(parsed_args, session).await,
78            VolumeCommands::Set353(cmd) => cmd.take_action(parsed_args, session).await,
79            VolumeCommands::Set30(cmd) => cmd.take_action(parsed_args, session).await,
80            VolumeCommands::Show(cmd) => cmd.take_action(parsed_args, session).await,
81        }
82    }
83}