Skip to main content

openstack_cli_dns/v2/reverse/floatingip/
list.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//! List Floatingips command
19//!
20//! Wraps invoking of the `v2/reverse/floatingips` 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::list;
32use openstack_types::dns::v2::reverse::floatingip::response;
33
34/// List FloatingIP PTR records
35#[derive(Args)]
36#[command(about = "List FloatingIP’s PTR record")]
37pub struct FloatingipsCommand {
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
71impl FloatingipsCommand {
72    /// Perform command action
73    pub async fn take_action<C: CliArgs>(
74        &self,
75        parsed_args: &C,
76        client: &mut AsyncOpenStack,
77    ) -> Result<(), OpenStackCliError> {
78        info!("List Floatingips");
79
80        let op =
81            OutputProcessor::from_args(parsed_args, Some("dns.reverse/floatingip"), Some("list"));
82        op.validate_args(parsed_args)?;
83
84        let mut ep_builder = list::Request::builder();
85        // Set path parameters
86
87        // Set header parameters
88        if let Some(val) = &self.headers.x_auth_all_projects {
89            ep_builder.header(
90                http::header::HeaderName::from_static("x-auth-all-projects"),
91                http::header::HeaderValue::from_static(if *val { "true" } else { "false" }),
92            );
93        }
94        if let Some(val) = &self.headers.x_auth_sudo_project_id {
95            ep_builder.header(
96                http::header::HeaderName::from_static("x-auth-sudo-project-id"),
97                http::header::HeaderValue::from_str(val)?,
98            );
99        }
100
101        let ep = ep_builder
102            .build()
103            .map_err(|x| OpenStackCliError::EndpointBuild(x.to_string()))?;
104
105        let data: Vec<serde_json::Value> = ep.query_async(client).await?;
106
107        op.output_list::<response::list::FloatingipResponse>(data.clone())?;
108        // Show command specific hints
109        op.show_command_hint()?;
110        Ok(())
111    }
112}