Skip to main content

openstack_cli_block_storage/v3/volume/
metadata.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 metadata commands
16use clap::{Parser, Subcommand};
17
18use openstack_cli_core::{cli::CliArgs, error::OpenStackCliError};
19use openstack_sdk::AsyncOpenStack;
20
21mod create;
22mod delete;
23mod list;
24mod replace;
25mod set;
26mod show;
27
28/// Volume metadata
29///
30/// Lists metadata, creates or replaces one or more metadata items, and updates
31/// one or more metadata items for a volume.
32#[derive(Parser)]
33#[command(about = "Volume metadata")]
34pub struct MetadataCommand {
35    /// subcommand
36    #[command(subcommand)]
37    command: MetadataCommands,
38}
39
40/// Supported subcommands
41#[allow(missing_docs)]
42#[derive(Subcommand)]
43pub enum MetadataCommands {
44    Create(Box<create::MetadataCommand>),
45    Delete(Box<delete::MetadataCommand>),
46    List(Box<list::MetadatasCommand>),
47    Replace(Box<replace::MetadataCommand>),
48    Set(Box<set::MetadataCommand>),
49    Show(Box<show::MetadataCommand>),
50}
51
52impl MetadataCommand {
53    /// Perform command action
54    pub async fn take_action<C: CliArgs>(
55        &self,
56        parsed_args: &C,
57        session: &mut AsyncOpenStack,
58    ) -> Result<(), OpenStackCliError> {
59        match &self.command {
60            MetadataCommands::Create(cmd) => cmd.take_action(parsed_args, session).await,
61            MetadataCommands::Delete(cmd) => cmd.take_action(parsed_args, session).await,
62            MetadataCommands::List(cmd) => cmd.take_action(parsed_args, session).await,
63            MetadataCommands::Replace(cmd) => cmd.take_action(parsed_args, session).await,
64            MetadataCommands::Set(cmd) => cmd.take_action(parsed_args, session).await,
65            MetadataCommands::Show(cmd) => cmd.take_action(parsed_args, session).await,
66        }
67    }
68}