openstack_cli_network/v2/extension/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 Extension command
19//!
20//! Wraps invoking of the `v2.0/extensions/{id}` 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::extension::get;
32use openstack_types::network::v2::extension::response;
33
34/// Shows details for an extension, by alias. The response shows the extension
35/// name and its alias. To show details for an extension, you specify the
36/// alias.
37///
38/// Use the `fields` query parameter to control which fields are returned in
39/// the response body. For more information, see [Fields](#fields).
40///
41/// Normal response codes: 200
42///
43/// Error response codes: 401, 404
44#[derive(Args)]
45#[command(about = "Show extension details")]
46pub struct ExtensionCommand {
47 /// Request Query parameters
48 #[command(flatten)]
49 query: QueryParameters,
50
51 /// Path parameters
52 #[command(flatten)]
53 path: PathParameters,
54}
55
56/// Query parameters
57#[derive(Args)]
58struct QueryParameters {}
59
60/// Path parameters
61#[derive(Args)]
62struct PathParameters {
63 /// id parameter for /v2.0/extensions/{id} API
64 #[arg(
65 help_heading = "Path parameters",
66 id = "path_param_id",
67 value_name = "ID"
68 )]
69 id: String,
70}
71
72impl ExtensionCommand {
73 /// Perform command action
74 pub async fn take_action<C: CliArgs>(
75 &self,
76 parsed_args: &C,
77 client: &mut AsyncOpenStack,
78 ) -> Result<(), OpenStackCliError> {
79 info!("Show Extension");
80
81 let op = OutputProcessor::from_args(parsed_args, Some("network.extension"), Some("show"));
82 op.validate_args(parsed_args)?;
83
84 let mut ep_builder = get::Request::builder();
85
86 ep_builder.id(&self.path.id);
87
88 let ep = ep_builder
89 .build()
90 .map_err(|x| OpenStackCliError::EndpointBuild(x.to_string()))?;
91
92 let data: serde_json::Value = ep.query_async(client).await?;
93
94 op.output_single::<response::get::ExtensionResponse>(data.clone())?;
95 // Show command specific hints
96 op.show_command_hint()?;
97 Ok(())
98 }
99}