Skip to main content

openstack_cli_block_storage/v3/
snapshot.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 Snapshot commands
16//!
17
18use clap::{Parser, Subcommand};
19
20use openstack_cli_core::{cli::CliArgs, error::OpenStackCliError};
21use openstack_sdk::AsyncOpenStack;
22
23pub mod create;
24pub mod delete;
25pub mod list;
26pub mod os_force_delete;
27pub mod os_reset_status;
28pub mod os_unmanage;
29pub mod os_update_snapshot_status;
30pub mod set;
31pub mod show;
32
33/// Volume snapshots (snapshots)
34///
35/// A snapshot is a point-in-time copy of the data that a volume contains.
36///
37/// When you create, list, or delete snapshots, these status values are possible:
38///
39///   - creating: The snapshot is being created.
40///
41///   - available: The snapshot is ready to use.
42///
43///   - backing-up: The snapshot is being backed up.
44///
45///   - deleting: The snapshot is being deleted.
46///
47///   - error: A snapshot creation error occurred.
48///
49///   - deleted: The snapshot has been deleted.
50///
51///   - unmanaging: The snapshot is being unmanaged.
52///
53///   - restoring: The snapshot is being restored to a volume.
54///
55///   - error_deleting: A snapshot deletion error occurred.
56#[derive(Parser)]
57pub struct SnapshotCommand {
58    /// subcommand
59    #[command(subcommand)]
60    command: SnapshotCommands,
61}
62
63/// Supported subcommands
64#[allow(missing_docs)]
65#[derive(Subcommand)]
66pub enum SnapshotCommands {
67    Create(Box<create::SnapshotCommand>),
68    Delete(Box<delete::SnapshotCommand>),
69    ForceDelete(Box<os_force_delete::SnapshotCommand>),
70    List(Box<list::SnapshotsCommand>),
71    ResetStatus(Box<os_reset_status::SnapshotCommand>),
72    Set(Box<set::SnapshotCommand>),
73    Show(Box<show::SnapshotCommand>),
74    Unmanage(Box<os_unmanage::SnapshotCommand>),
75    UpdateStatus(Box<os_update_snapshot_status::SnapshotCommand>),
76}
77
78impl SnapshotCommand {
79    /// Perform command action
80    pub async fn take_action<C: CliArgs>(
81        &self,
82        parsed_args: &C,
83        session: &mut AsyncOpenStack,
84    ) -> Result<(), OpenStackCliError> {
85        match &self.command {
86            SnapshotCommands::Create(cmd) => cmd.take_action(parsed_args, session).await,
87            SnapshotCommands::Delete(cmd) => cmd.take_action(parsed_args, session).await,
88            SnapshotCommands::ForceDelete(cmd) => cmd.take_action(parsed_args, session).await,
89            SnapshotCommands::List(cmd) => cmd.take_action(parsed_args, session).await,
90            SnapshotCommands::ResetStatus(cmd) => cmd.take_action(parsed_args, session).await,
91            SnapshotCommands::Set(cmd) => cmd.take_action(parsed_args, session).await,
92            SnapshotCommands::Show(cmd) => cmd.take_action(parsed_args, session).await,
93            SnapshotCommands::Unmanage(cmd) => cmd.take_action(parsed_args, session).await,
94            SnapshotCommands::UpdateStatus(cmd) => cmd.take_action(parsed_args, session).await,
95        }
96    }
97}