openstack_cli_network/v2/quota/defaults.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 Quota command
19//!
20//! Wraps invoking of the `v2.0/quotas/{id}/default` 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::network::v2::quota::defaults;
32use openstack_types::network::v2::quota::response;
33
34/// Lists default quotas for a project.
35///
36/// Standard query parameters are supported on the URI. For more information,
37/// see [Filtering and Column Selection](#filtering).
38///
39/// Use the `fields` query parameter to control which fields are returned in
40/// the response body. For more information, see [Fields](#fields).
41///
42/// Pagination query parameters are supported if Neutron configuration supports
43/// it by overriding `allow_pagination=false`. For more information, see
44/// [Pagination](#pagination).
45///
46/// Sorting query parameters are supported if Neutron configuration supports it
47/// with `allow_sorting=true`. For more information, see [Sorting](#sorting).
48///
49/// Normal response codes: 200
50///
51/// Error response codes: 401, 403
52#[derive(Args)]
53#[command(about = "List default quotas for a project")]
54pub struct QuotaCommand {
55 /// Request Query parameters
56 #[command(flatten)]
57 query: QueryParameters,
58
59 /// Path parameters
60 #[command(flatten)]
61 path: PathParameters,
62}
63
64/// Query parameters
65#[derive(Args)]
66struct QueryParameters {}
67
68/// Path parameters
69#[derive(Args)]
70struct PathParameters {
71 /// id parameter for /v2.0/quotas/{id}/default API
72 #[arg(
73 help_heading = "Path parameters",
74 id = "path_param_id",
75 value_name = "ID"
76 )]
77 id: String,
78}
79
80impl QuotaCommand {
81 /// Perform command action
82 pub async fn take_action<C: CliArgs>(
83 &self,
84 parsed_args: &C,
85 client: &mut AsyncOpenStack,
86 ) -> Result<(), OpenStackCliError> {
87 info!("Show Quota");
88
89 let op = OutputProcessor::from_args(parsed_args, Some("network.quota"), Some("defaults"));
90 op.validate_args(parsed_args)?;
91
92 let mut ep_builder = defaults::Request::builder();
93
94 ep_builder.id(&self.path.id);
95
96 let ep = ep_builder
97 .build()
98 .map_err(|x| OpenStackCliError::EndpointBuild(x.to_string()))?;
99
100 let data: serde_json::Value = ep.query_async(client).await?;
101
102 op.output_single::<response::defaults::QuotaResponse>(data.clone())?;
103 // Show command specific hints
104 op.show_command_hint()?;
105 Ok(())
106 }
107}