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