openstack_cli/identity/v3/
region.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//! Identity Region commands
16
17use clap::{Parser, Subcommand};
18
19use openstack_sdk::AsyncOpenStack;
20
21use crate::{Cli, OpenStackCliError};
22
23pub mod create;
24pub mod delete;
25pub mod list;
26pub mod set;
27pub mod show;
28
29/// Region commands
30///
31/// A region is a general division of an OpenStack deployment. You can associate zero or more
32/// sub-regions with a region to create a tree- like structured hierarchy.
33///
34/// Although a region does not have a geographical connotation, a deployment can use a geographical
35/// name for a region ID, such as us- east.
36///
37/// You can list, create, update, show details for, and delete regions.
38#[derive(Parser)]
39pub struct RegionCommand {
40    #[command(subcommand)]
41    command: RegionCommands,
42}
43
44/// Supported subcommands
45#[allow(missing_docs)]
46#[derive(Subcommand)]
47pub enum RegionCommands {
48    Create(create::RegionCommand),
49    Delete(delete::RegionCommand),
50    List(list::RegionsCommand),
51    Set(set::RegionCommand),
52    Show(show::RegionCommand),
53}
54
55impl RegionCommand {
56    /// Perform command action
57    pub async fn take_action(
58        &self,
59        parsed_args: &Cli,
60        session: &mut AsyncOpenStack,
61    ) -> Result<(), OpenStackCliError> {
62        match &self.command {
63            RegionCommands::Create(cmd) => cmd.take_action(parsed_args, session).await,
64            RegionCommands::Delete(cmd) => cmd.take_action(parsed_args, session).await,
65            RegionCommands::List(cmd) => cmd.take_action(parsed_args, session).await,
66            RegionCommands::Set(cmd) => cmd.take_action(parsed_args, session).await,
67            RegionCommands::Show(cmd) => cmd.take_action(parsed_args, session).await,
68        }
69    }
70}