openstack_cli_compute/v2/availability_zone/list_detail.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 AvailabilityZones command
19//!
20//! Wraps invoking of the `v2.1/os-availability-zone/detail` 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::compute::v2::availability_zone::list_detail;
32use openstack_types::compute::v2::availability_zone::response;
33
34/// Gets detailed availability zone information. Policy defaults enable only
35/// users with the administrative role to perform this operation. Cloud
36/// providers can change these permissions through the `policy.yaml` file.
37///
38/// Normal response codes: 200
39///
40/// Error response codes: unauthorized(401), forbidden(403)
41#[derive(Args)]
42#[command(about = "Get Detailed Availability Zone Information")]
43pub struct AvailabilityZonesCommand {
44 /// Request Query parameters
45 #[command(flatten)]
46 query: QueryParameters,
47
48 /// Path parameters
49 #[command(flatten)]
50 path: PathParameters,
51}
52
53/// Query parameters
54#[derive(Args)]
55struct QueryParameters {}
56
57/// Path parameters
58#[derive(Args)]
59struct PathParameters {}
60
61impl AvailabilityZonesCommand {
62 /// Perform command action
63 pub async fn take_action<C: CliArgs>(
64 &self,
65 parsed_args: &C,
66 client: &mut AsyncOpenStack,
67 ) -> Result<(), OpenStackCliError> {
68 info!("List AvailabilityZones");
69
70 let op = OutputProcessor::from_args(
71 parsed_args,
72 Some("compute.availability_zone"),
73 Some("list"),
74 );
75 op.validate_args(parsed_args)?;
76
77 let ep_builder = list_detail::Request::builder();
78
79 let ep = ep_builder
80 .build()
81 .map_err(|x| OpenStackCliError::EndpointBuild(x.to_string()))?;
82
83 let data: Vec<serde_json::Value> = ep.query_async(client).await?;
84
85 op.output_list::<response::list_detail::AvailabilityZoneResponse>(data.clone())?;
86 // Show command specific hints
87 op.show_command_hint()?;
88 Ok(())
89 }
90}