Skip to main content

openstack_cli_placement/v1/
resource_provider.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 `resource_provider` command with subcommands
16use clap::{Parser, Subcommand};
17
18use openstack_cli_core::{cli::CliArgs, error::OpenStackCliError};
19use openstack_sdk::AsyncOpenStack;
20
21pub mod aggregate;
22pub mod allocation;
23pub mod create_10;
24pub mod create_114;
25pub mod delete;
26pub mod inventory;
27pub mod list;
28pub mod set_10;
29pub mod set_114;
30pub mod show;
31pub mod r#trait;
32pub mod usage;
33
34/// Resource Providers
35///
36/// Resource providers are entities which provide consumable inventory of one or more classes of
37/// resource (such as disk or memory). They can be listed (with filters), created, updated and
38/// deleted.
39#[derive(Parser)]
40pub struct ResourceProviderCommand {
41    #[command(subcommand)]
42    command: ResourceProviderCommands,
43}
44
45/// Supported subcommands
46#[allow(missing_docs)]
47#[derive(Subcommand)]
48pub enum ResourceProviderCommands {
49    Aggregate(aggregate::AggregateCommand),
50    Allocation(allocation::AllocationCommand),
51    #[command(visible_alias = "create")]
52    Create114(create_114::ResourceProviderCommand),
53    Create10(create_10::ResourceProviderCommand),
54    Delete(delete::ResourceProviderCommand),
55    Inventory(inventory::InventoryCommand),
56    List(list::ResourceProvidersCommand),
57    #[command(visible_alias = "set")]
58    Set114(set_114::ResourceProviderCommand),
59    Set10(set_10::ResourceProviderCommand),
60    Show(show::ResourceProviderCommand),
61    Trait(r#trait::TraitCommand),
62    Usage(usage::UsageCommand),
63}
64
65impl ResourceProviderCommand {
66    /// Perform command action
67    pub async fn take_action<C: CliArgs>(
68        &self,
69        parsed_args: &C,
70        session: &mut AsyncOpenStack,
71    ) -> Result<(), OpenStackCliError> {
72        match &self.command {
73            ResourceProviderCommands::Aggregate(cmd) => cmd.take_action(parsed_args, session).await,
74            ResourceProviderCommands::Allocation(cmd) => {
75                cmd.take_action(parsed_args, session).await
76            }
77            ResourceProviderCommands::Create114(cmd) => cmd.take_action(parsed_args, session).await,
78            ResourceProviderCommands::Create10(cmd) => cmd.take_action(parsed_args, session).await,
79            ResourceProviderCommands::Delete(cmd) => cmd.take_action(parsed_args, session).await,
80            ResourceProviderCommands::Inventory(cmd) => cmd.take_action(parsed_args, session).await,
81            ResourceProviderCommands::List(cmd) => cmd.take_action(parsed_args, session).await,
82            ResourceProviderCommands::Set114(cmd) => cmd.take_action(parsed_args, session).await,
83            ResourceProviderCommands::Set10(cmd) => cmd.take_action(parsed_args, session).await,
84            ResourceProviderCommands::Show(cmd) => cmd.take_action(parsed_args, session).await,
85            ResourceProviderCommands::Trait(cmd) => cmd.take_action(parsed_args, session).await,
86            ResourceProviderCommands::Usage(cmd) => cmd.take_action(parsed_args, session).await,
87        }
88    }
89}