Skip to main content

openstack_cli_compute/v2/
keypair.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//! Keypairs (keypairs)
16//!
17//! Generates, imports, and deletes SSH keys.
18
19use clap::{Parser, Subcommand};
20
21use openstack_sdk::AsyncOpenStack;
22
23use openstack_cli_core::{cli::CliArgs, error::OpenStackCliError};
24
25pub mod create_20;
26pub mod create_21;
27pub mod create_210;
28pub mod create_22;
29pub mod create_292;
30pub mod delete;
31pub mod list;
32pub mod show;
33
34/// Keypairs commands
35///
36/// Generates, imports, and deletes SSH keys.
37#[derive(Parser)]
38pub struct KeypairCommand {
39    /// subcommand
40    #[command(subcommand)]
41    command: KeypairCommands,
42}
43
44/// Supported subcommands
45#[allow(missing_docs)]
46#[derive(Subcommand)]
47pub enum KeypairCommands {
48    #[command(visible_alias = "create")]
49    Create292(create_292::KeypairCommand),
50    Create210(create_210::KeypairCommand),
51    Create22(create_22::KeypairCommand),
52    Create21(create_21::KeypairCommand),
53    Create20(create_20::KeypairCommand),
54    Delete(delete::KeypairCommand),
55    List(list::KeypairsCommand),
56    Show(show::KeypairCommand),
57}
58
59impl KeypairCommand {
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            KeypairCommands::Create292(cmd) => cmd.take_action(parsed_args, session).await,
68            KeypairCommands::Create210(cmd) => cmd.take_action(parsed_args, session).await,
69            KeypairCommands::Create22(cmd) => cmd.take_action(parsed_args, session).await,
70            KeypairCommands::Create21(cmd) => cmd.take_action(parsed_args, session).await,
71            KeypairCommands::Create20(cmd) => cmd.take_action(parsed_args, session).await,
72            KeypairCommands::Delete(cmd) => cmd.take_action(parsed_args, session).await,
73            KeypairCommands::List(cmd) => cmd.take_action(parsed_args, session).await,
74            KeypairCommands::Show(cmd) => cmd.take_action(parsed_args, session).await,
75        }
76    }
77}