Skip to main content

openstack_cli_dns/
v2.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//! DNS API v2 command
16
17use clap::{Parser, Subcommand};
18
19use openstack_cli_core::{cli::CliArgs, error::OpenStackCliError};
20use openstack_sdk::{AsyncOpenStack, types::ServiceType};
21
22pub mod limit;
23pub mod quota;
24pub mod recordset;
25pub mod reverse;
26pub mod zone;
27
28/// DNS service (Designate) operations
29#[derive(Parser)]
30pub struct DnsCommand {
31    /// Dns service resource
32    #[command(subcommand)]
33    command: DnsCommands,
34}
35
36/// Dns resources commands
37#[allow(missing_docs)]
38#[derive(Subcommand)]
39pub enum DnsCommands {
40    Limit(Box<limit::LimitCommand>),
41    Quota(Box<quota::QuotaCommand>),
42    Recordset(Box<recordset::RecordsetCommand>),
43    Reverse(Box<reverse::ReverseCommand>),
44    Zone(Box<zone::ZoneCommand>),
45}
46
47impl DnsCommand {
48    /// Perform command action
49    pub async fn take_action<C: CliArgs>(
50        &self,
51        parsed_args: &C,
52        session: &mut AsyncOpenStack,
53    ) -> Result<(), OpenStackCliError> {
54        session.discover_service_endpoint(&ServiceType::Dns).await?;
55
56        match &self.command {
57            DnsCommands::Limit(cmd) => cmd.take_action(parsed_args, session).await,
58            DnsCommands::Quota(cmd) => cmd.take_action(parsed_args, session).await,
59            DnsCommands::Recordset(cmd) => cmd.take_action(parsed_args, session).await,
60            DnsCommands::Reverse(cmd) => cmd.take_action(parsed_args, session).await,
61            DnsCommands::Zone(cmd) => cmd.take_action(parsed_args, session).await,
62        }
63    }
64}