Skip to main content

openstack_cli_placement/v1/resource_provider/
inventory.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//! Placement `ResourceProviderInventory` command with subcommands
16use clap::{Parser, Subcommand};
17
18use openstack_cli_core::{cli::CliArgs, error::OpenStackCliError};
19use openstack_sdk::AsyncOpenStack;
20
21pub mod create;
22pub mod delete;
23pub mod delete_all;
24pub mod list;
25pub mod replace;
26pub mod set;
27pub mod show;
28
29/// Resource provider inventories
30///
31/// Each resource provider has inventory records for one or more classes of resources. An inventory
32/// record contains information about the total and reserved amounts of the resource and any
33/// consumption constraints for that resource against the provider.
34#[derive(Parser)]
35pub struct InventoryCommand {
36    #[command(subcommand)]
37    command: InventoryCommands,
38}
39
40/// Supported subcommands
41#[allow(missing_docs)]
42#[derive(Subcommand)]
43pub enum InventoryCommands {
44    Create(create::InventoryCommand),
45    Delete(delete::InventoryCommand),
46    Purge(delete_all::InventoryCommand),
47    List(list::InventoriesCommand),
48    Replace(replace::InventoryCommand),
49    Set(set::InventoryCommand),
50    Show(show::InventoryCommand),
51}
52
53impl InventoryCommand {
54    /// Perform command action
55    pub async fn take_action<C: CliArgs>(
56        &self,
57        parsed_args: &C,
58        session: &mut AsyncOpenStack,
59    ) -> Result<(), OpenStackCliError> {
60        match &self.command {
61            InventoryCommands::Create(cmd) => cmd.take_action(parsed_args, session).await,
62            InventoryCommands::Delete(cmd) => cmd.take_action(parsed_args, session).await,
63            InventoryCommands::Purge(cmd) => cmd.take_action(parsed_args, session).await,
64            InventoryCommands::List(cmd) => cmd.take_action(parsed_args, session).await,
65            InventoryCommands::Replace(cmd) => cmd.take_action(parsed_args, session).await,
66            InventoryCommands::Set(cmd) => cmd.take_action(parsed_args, session).await,
67            InventoryCommands::Show(cmd) => cmd.take_action(parsed_args, session).await,
68        }
69    }
70}