Skip to main content

openstack_cli_image/v2/schema/
metadef.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//! Image members schema
16
17use clap::{Parser, Subcommand};
18
19use openstack_sdk::AsyncOpenStack;
20
21use openstack_cli_core::{cli::CliArgs, error::OpenStackCliError};
22
23pub mod namespace;
24pub mod namespaces;
25pub mod object;
26pub mod objects;
27pub mod properties;
28pub mod property;
29pub mod resource_type;
30pub mod resource_types;
31pub mod tag;
32pub mod tags;
33
34/// Metadata definition schemas
35///
36/// Gets a JSON-schema document that represents a metadata definition entity.
37#[derive(Parser)]
38pub struct MetadefCommand {
39    #[command(subcommand)]
40    command: MetadefCommands,
41}
42
43/// Supported subcommands
44#[allow(missing_docs)]
45#[derive(Subcommand)]
46pub enum MetadefCommands {
47    Namespace(namespace::NamespaceCommand),
48    Namespaces(namespaces::NamespacesCommand),
49    Object(object::ObjectCommand),
50    Objects(objects::ObjectsCommand),
51    Properties(properties::PropertiesCommand),
52    Property(property::PropertyCommand),
53    ResourceType(resource_type::ResourceTypeCommand),
54    ResourceTypes(resource_types::ResourceTypesCommand),
55    Tag(tag::TagCommand),
56    Tags(tags::TagsCommand),
57}
58
59impl MetadefCommand {
60    /// Perform command action
61    pub async fn take_action<C: CliArgs>(
62        &self,
63        parsed_args: &C,
64        session: &mut AsyncOpenStack,
65    ) -> Result<(), OpenStackCliError> {
66        match &self.command {
67            MetadefCommands::Namespace(cmd) => cmd.take_action(parsed_args, session).await,
68            MetadefCommands::Namespaces(cmd) => cmd.take_action(parsed_args, session).await,
69            MetadefCommands::Object(cmd) => cmd.take_action(parsed_args, session).await,
70            MetadefCommands::Objects(cmd) => cmd.take_action(parsed_args, session).await,
71            MetadefCommands::Properties(cmd) => cmd.take_action(parsed_args, session).await,
72            MetadefCommands::Property(cmd) => cmd.take_action(parsed_args, session).await,
73            MetadefCommands::ResourceType(cmd) => cmd.take_action(parsed_args, session).await,
74            MetadefCommands::ResourceTypes(cmd) => cmd.take_action(parsed_args, session).await,
75            MetadefCommands::Tag(cmd) => cmd.take_action(parsed_args, session).await,
76            MetadefCommands::Tags(cmd) => cmd.take_action(parsed_args, session).await,
77        }
78    }
79}