Skip to main content

openstack_cli_image/v2/metadef/
namespace.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//! Glance Metadef namespace
16
17use clap::{Parser, Subcommand};
18
19use openstack_sdk::AsyncOpenStack;
20
21use openstack_cli_core::{cli::CliArgs, error::OpenStackCliError};
22
23pub mod create;
24pub mod delete;
25pub mod list;
26pub mod object;
27pub mod property;
28pub mod resource_type;
29pub mod set;
30pub mod show;
31pub mod tag;
32
33/// Metadata definition namespaces
34///
35/// Creates, lists, shows details for, updates, and deletes metadata definition namespaces. Defines
36/// namespaces that can contain property definitions, object definitions, and resource type
37/// associations.
38#[derive(Parser)]
39pub struct NamespaceCommand {
40    /// subcommand
41    #[command(subcommand)]
42    command: NamespaceCommands,
43}
44
45/// Supported subcommands
46#[allow(missing_docs)]
47#[derive(Subcommand)]
48pub enum NamespaceCommands {
49    Create(create::NamespaceCommand),
50    Delete(delete::NamespaceCommand),
51    List(list::NamespacesCommand),
52    Object(object::ObjectCommand),
53    Property(property::PropertyCommand),
54    ResourceTypeAssociation(resource_type::ResourceTypeCommand),
55    Set(set::NamespaceCommand),
56    Show(show::NamespaceCommand),
57    Tag(tag::TagCommand),
58}
59
60impl NamespaceCommand {
61    /// Perform command action
62    pub async fn take_action<C: CliArgs>(
63        &self,
64        parsed_args: &C,
65        session: &mut AsyncOpenStack,
66    ) -> Result<(), OpenStackCliError> {
67        match &self.command {
68            NamespaceCommands::Create(cmd) => cmd.take_action(parsed_args, session).await,
69            NamespaceCommands::Delete(cmd) => cmd.take_action(parsed_args, session).await,
70            NamespaceCommands::List(cmd) => cmd.take_action(parsed_args, session).await,
71            NamespaceCommands::Object(cmd) => cmd.take_action(parsed_args, session).await,
72            NamespaceCommands::Property(cmd) => cmd.take_action(parsed_args, session).await,
73            NamespaceCommands::ResourceTypeAssociation(cmd) => {
74                cmd.take_action(parsed_args, session).await
75            }
76            NamespaceCommands::Set(cmd) => cmd.take_action(parsed_args, session).await,
77            NamespaceCommands::Show(cmd) => cmd.take_action(parsed_args, session).await,
78            NamespaceCommands::Tag(cmd) => cmd.take_action(parsed_args, session).await,
79        }
80    }
81}