Skip to main content

openstack_cli_dns/v2/reverse/floatingip/
show.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// WARNING: This file is automatically generated from OpenAPI schema using
16// `openstack-codegenerator`.
17
18//! Show Floatingip command
19//!
20//! Wraps invoking of the `v2/reverse/floatingips/{fip_key}` with `GET` method
21
22use clap::Args;
23use tracing::info;
24
25use openstack_cli_core::cli::CliArgs;
26use openstack_cli_core::error::OpenStackCliError;
27use openstack_cli_core::output::OutputProcessor;
28use openstack_sdk::AsyncOpenStack;
29
30use openstack_sdk::api::QueryAsync;
31use openstack_sdk::api::dns::v2::reverse::floatingip::get;
32use openstack_types::dns::v2::reverse::floatingip::response;
33
34/// Shows a particular FloatingIP PTR
35#[derive(Args)]
36#[command(about = "Show FloatingIP’s PTR record")]
37pub struct FloatingipCommand {
38    /// Request Query parameters
39    #[command(flatten)]
40    query: QueryParameters,
41
42    /// Request Headers parameters
43    #[command(flatten)]
44    headers: HeaderParameters,
45
46    /// Path parameters
47    #[command(flatten)]
48    path: PathParameters,
49}
50
51/// Query parameters
52#[derive(Args)]
53struct QueryParameters {}
54
55/// Header parameters
56#[derive(Args)]
57struct HeaderParameters {
58    /// If enabled this will show results from all projects in Designate
59    #[arg(long)]
60    x_auth_all_projects: Option<bool>,
61
62    /// This allows a user to impersonate another project
63    #[arg(long)]
64    x_auth_sudo_project_id: Option<String>,
65}
66
67/// Path parameters
68#[derive(Args)]
69struct PathParameters {
70    /// fip_key parameter for /v2/reverse/floatingips/{fip_key} API
71    #[arg(
72        help_heading = "Path parameters",
73        id = "path_param_fip_key",
74        value_name = "FIP_KEY"
75    )]
76    fip_key: String,
77}
78
79impl FloatingipCommand {
80    /// Perform command action
81    pub async fn take_action<C: CliArgs>(
82        &self,
83        parsed_args: &C,
84        client: &mut AsyncOpenStack,
85    ) -> Result<(), OpenStackCliError> {
86        info!("Show Floatingip");
87
88        let op =
89            OutputProcessor::from_args(parsed_args, Some("dns.reverse/floatingip"), Some("show"));
90        op.validate_args(parsed_args)?;
91
92        let mut ep_builder = get::Request::builder();
93        // Set path parameters
94        ep_builder.fip_key(&self.path.fip_key);
95
96        // Set header parameters
97        if let Some(val) = &self.headers.x_auth_all_projects {
98            ep_builder.header(
99                http::header::HeaderName::from_static("x-auth-all-projects"),
100                http::header::HeaderValue::from_static(if *val { "true" } else { "false" }),
101            );
102        }
103        if let Some(val) = &self.headers.x_auth_sudo_project_id {
104            ep_builder.header(
105                http::header::HeaderName::from_static("x-auth-sudo-project-id"),
106                http::header::HeaderValue::from_str(val)?,
107            );
108        }
109
110        let ep = ep_builder
111            .build()
112            .map_err(|x| OpenStackCliError::EndpointBuild(x.to_string()))?;
113
114        let data: serde_json::Value = ep.query_async(client).await?;
115
116        op.output_single::<response::get::FloatingipResponse>(data.clone())?;
117        // Show command specific hints
118        op.show_command_hint()?;
119        Ok(())
120    }
121}