Skip to main content

openstack_cli_placement/v1/
allocation.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 `allocation` command with subcommands
16use clap::{Parser, Subcommand};
17
18use openstack_cli_core::{cli::CliArgs, error::OpenStackCliError};
19use openstack_sdk::AsyncOpenStack;
20
21pub mod create_113;
22pub mod create_128;
23pub mod create_134;
24pub mod create_138;
25pub mod delete;
26pub mod set_10;
27pub mod set_112;
28pub mod set_128;
29pub mod set_138;
30pub mod set_18;
31pub mod show;
32
33/// Allocations
34///
35/// Allocations are records representing resources that have been assigned and used by some
36/// consumer of that resource. They indicate the amount of a particular resource that has been
37/// allocated to a given consumer of that resource from a particular resource provider.
38#[derive(Parser)]
39pub struct AllocationCommand {
40    #[command(subcommand)]
41    command: AllocationCommands,
42}
43
44/// Supported subcommands
45#[allow(missing_docs)]
46#[derive(Subcommand)]
47pub enum AllocationCommands {
48    #[command(visible_alias = "create")]
49    Create138(create_138::AllocationCommand),
50    Create134(create_134::AllocationCommand),
51    Create128(create_128::AllocationCommand),
52    Create113(create_113::AllocationCommand),
53    Delete(delete::AllocationCommand),
54    #[command(visible_alias = "set")]
55    Set138(set_138::AllocationCommand),
56    Set128(set_128::AllocationCommand),
57    Set112(set_112::AllocationCommand),
58    Set18(set_18::AllocationCommand),
59    Set10(set_10::AllocationCommand),
60    Show(show::AllocationCommand),
61}
62
63impl AllocationCommand {
64    /// Perform command action
65    pub async fn take_action<C: CliArgs>(
66        &self,
67        parsed_args: &C,
68        session: &mut AsyncOpenStack,
69    ) -> Result<(), OpenStackCliError> {
70        match &self.command {
71            AllocationCommands::Create138(cmd) => cmd.take_action(parsed_args, session).await,
72            AllocationCommands::Create134(cmd) => cmd.take_action(parsed_args, session).await,
73            AllocationCommands::Create128(cmd) => cmd.take_action(parsed_args, session).await,
74            AllocationCommands::Create113(cmd) => cmd.take_action(parsed_args, session).await,
75            AllocationCommands::Delete(cmd) => cmd.take_action(parsed_args, session).await,
76            AllocationCommands::Set128(cmd) => cmd.take_action(parsed_args, session).await,
77            AllocationCommands::Set138(cmd) => cmd.take_action(parsed_args, session).await,
78            AllocationCommands::Set112(cmd) => cmd.take_action(parsed_args, session).await,
79            AllocationCommands::Set18(cmd) => cmd.take_action(parsed_args, session).await,
80            AllocationCommands::Set10(cmd) => cmd.take_action(parsed_args, session).await,
81            AllocationCommands::Show(cmd) => cmd.take_action(parsed_args, session).await,
82        }
83    }
84}