openstack_cli_image/v2/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//! Glance Metadefs
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 resource_type;
25
26/// Metadefs
27///
28/// The Metadata Definitions Service (“metadefs”, for short) provides a common API for vendors,
29/// operators, administrators, services, and users to meaningfully define available key:value pairs
30/// that can be used on different types of cloud resources (for example, images, artifacts,
31/// volumes, flavors, aggregates, and other resources).
32///
33/// To get you started, Glance contains a default catalog of metadefs that may be installed at your
34/// site; see the README in the code repository for details.
35///
36/// Once a common catalog of metadata definitions has been created, the catalog is available for
37/// querying through the API. Note that this service stores only the catalog, because metadefs are
38/// meta-metadata. Metadefs provide information about resource metadata, but do not themselves
39/// serve as actual metadata.
40///
41/// Actual key:value pairs are stored on the resources to which they apply using the metadata
42/// facilities provided by the appropriate API. (For example, the Images API would be used to put
43/// specific key:value pairs on a virtual machine image.)
44///
45/// A metadefs definition includes a property’s key, its description, its constraints, and the
46/// resource types to which it can be associated. See [Metadata Definition
47/// Concepts](https://docs.openstack.org/glance/latest/user/metadefs-concepts.html) in the Glance
48/// Developer documentation for more information.
49///
50/// **Note**: By default, only admins can manipulate the data exposed by this API, but all users
51/// may list and show public resources. This changed from a default of “open to all” in the Wallaby
52/// release.
53#[derive(Parser)]
54pub struct MetadefCommand {
55 /// subcommand
56 #[command(subcommand)]
57 command: MetadefCommands,
58}
59
60/// Supported subcommands
61#[allow(missing_docs)]
62#[derive(Subcommand)]
63pub enum MetadefCommands {
64 Namespace(Box<namespace::NamespaceCommand>),
65 ResourceType(Box<resource_type::ResourceTypeCommand>),
66}
67
68impl MetadefCommand {
69 /// Perform command action
70 pub async fn take_action<C: CliArgs>(
71 &self,
72 parsed_args: &C,
73 session: &mut AsyncOpenStack,
74 ) -> Result<(), OpenStackCliError> {
75 match &self.command {
76 MetadefCommands::Namespace(cmd) => cmd.take_action(parsed_args, session).await,
77 MetadefCommands::ResourceType(cmd) => cmd.take_action(parsed_args, session).await,
78 }
79 }
80}