Skip to main content

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