Skip to main content

openstack_cli_block_storage/v3/
attachment.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//! Block storage Volume Attachment commands
16//!
17
18use clap::{Parser, Subcommand};
19
20use openstack_cli_core::{cli::CliArgs, error::OpenStackCliError};
21use openstack_sdk::AsyncOpenStack;
22
23pub mod create_327;
24pub mod create_354;
25pub mod delete;
26pub mod list;
27pub mod os_complete_344;
28pub mod set_327;
29pub mod show;
30
31/// Attachments (attachments)
32///
33/// Lists all, lists all with details, shows details for, creates, and deletes attachment.
34///
35/// Note
36///
37/// Everything except for Complete attachment is new as of the 3.27 microversion. Complete attachment is new as of the 3.44 microversion.
38///
39/// When you create, list, update, or delete attachment, the possible status values are:
40///
41///   - attached: A volume is attached for the attachment.
42///
43///   - attaching: A volume is attaching for the attachment.
44///
45///   - detached: A volume is detached for the attachment.
46///
47///   - reserved: A volume is reserved for the attachment.
48///
49///   - error_attaching: A volume is error attaching for the attachment.
50///
51///   - error_detaching: A volume is error detaching for the attachment.
52///
53///   - deleted: The attachment is deleted.
54#[derive(Parser)]
55pub struct AttachmentCommand {
56    /// subcommand
57    #[command(subcommand)]
58    command: AttachmentCommands,
59}
60
61/// Supported subcommands
62#[allow(missing_docs)]
63#[derive(Subcommand)]
64pub enum AttachmentCommands {
65    #[command(visible_alias = "complete")]
66    Complete344(Box<os_complete_344::AttachmentCommand>),
67    #[command(visible_alias = "create")]
68    Create354(Box<create_354::AttachmentCommand>),
69    Create327(Box<create_327::AttachmentCommand>),
70    Delete(Box<delete::AttachmentCommand>),
71    List(Box<list::AttachmentsCommand>),
72    #[command(visible_alias = "set")]
73    Set327(Box<set_327::AttachmentCommand>),
74    Show(Box<show::AttachmentCommand>),
75}
76
77impl AttachmentCommand {
78    /// Perform command action
79    pub async fn take_action<C: CliArgs>(
80        &self,
81        parsed_args: &C,
82        session: &mut AsyncOpenStack,
83    ) -> Result<(), OpenStackCliError> {
84        match &self.command {
85            AttachmentCommands::Complete344(cmd) => cmd.take_action(parsed_args, session).await,
86            AttachmentCommands::Create354(cmd) => cmd.take_action(parsed_args, session).await,
87            AttachmentCommands::Create327(cmd) => cmd.take_action(parsed_args, session).await,
88            AttachmentCommands::Delete(cmd) => cmd.take_action(parsed_args, session).await,
89            AttachmentCommands::List(cmd) => cmd.take_action(parsed_args, session).await,
90            AttachmentCommands::Set327(cmd) => cmd.take_action(parsed_args, session).await,
91            AttachmentCommands::Show(cmd) => cmd.take_action(parsed_args, session).await,
92        }
93    }
94}