Skip to main content

openstack_cli_image/v2/schema/images/
get.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//! Json Images command
19//!
20//! Wraps invoking of the `v2/schemas/images` 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::image::v2::schema::images::get;
32
33/// *(Since Images v2.0)*
34///
35/// Shows a JSON schema document that represents an *images* entity.
36///
37/// An images entity is a container of image entities.
38///
39/// The following schema is solely an example. Consider only the response to
40/// the API call as authoritative.
41///
42/// Normal response codes: 200
43///
44/// Error response codes: 400, 401
45#[derive(Args)]
46#[command(about = "Show images schema")]
47pub struct ImagesCommand {
48    /// Request Query parameters
49    #[command(flatten)]
50    query: QueryParameters,
51
52    /// Path parameters
53    #[command(flatten)]
54    path: PathParameters,
55}
56
57/// Query parameters
58#[derive(Args)]
59struct QueryParameters {}
60
61/// Path parameters
62#[derive(Args)]
63struct PathParameters {}
64
65impl ImagesCommand {
66    /// Perform command action
67    pub async fn take_action<C: CliArgs>(
68        &self,
69        parsed_args: &C,
70        client: &mut AsyncOpenStack,
71    ) -> Result<(), OpenStackCliError> {
72        info!("Json Images");
73
74        let op = OutputProcessor::from_args(parsed_args, Some("image.schema/images"), Some("get"));
75        op.validate_args(parsed_args)?;
76
77        let ep_builder = get::Request::builder();
78
79        let ep = ep_builder
80            .build()
81            .map_err(|x| OpenStackCliError::EndpointBuild(x.to_string()))?;
82
83        let data: serde_json::Value = ep.query_async(client).await?;
84        op.output_machine(data)?;
85        // Show command specific hints
86        op.show_command_hint()?;
87        Ok(())
88    }
89}