openstack_cli_load_balancer/v2/loadbalancer/status.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//! Get Loadbalancer command
19//!
20//! Wraps invoking of the `v2/lbaas/loadbalancers/{loadbalancer_id}/status` 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::load_balancer::v2::loadbalancer::status;
32use openstack_types::load_balancer::v2::loadbalancer::response;
33
34/// Shows the status tree for a load balancer.
35///
36/// This operation returns a status tree for a load balancer object, by load
37/// balancer ID.
38///
39/// `provisioning_status` is the status associated with lifecycle of the
40/// resource. See [Provisioning Status Codes](#prov-status) for descriptions of
41/// the status codes.
42///
43/// `operating_status` is the observed status of the resource. See
44/// [Operating Status Codes](#op-status) for descriptions of the status codes.
45///
46/// If you are not an administrative user and the load balancer object does not
47/// belong to your project, the service returns the HTTP `Forbidden (403)`
48/// response code.
49///
50/// If the operation succeeds, the returned element is a status tree that
51/// contains the load balancer and all provisioning and operating statuses for
52/// its children.
53#[derive(Args)]
54#[command(about = "Get the Load Balancer status tree")]
55pub struct LoadbalancerCommand {
56 /// Request Query parameters
57 #[command(flatten)]
58 query: QueryParameters,
59
60 /// Path parameters
61 #[command(flatten)]
62 path: PathParameters,
63}
64
65/// Query parameters
66#[derive(Args)]
67struct QueryParameters {}
68
69/// Path parameters
70#[derive(Args)]
71struct PathParameters {
72 /// loadbalancer_id parameter for
73 /// /v2/lbaas/loadbalancers/{loadbalancer_id}/status API
74 #[arg(
75 help_heading = "Path parameters",
76 id = "path_param_id",
77 value_name = "ID"
78 )]
79 id: String,
80}
81
82impl LoadbalancerCommand {
83 /// Perform command action
84 pub async fn take_action<C: CliArgs>(
85 &self,
86 parsed_args: &C,
87 client: &mut AsyncOpenStack,
88 ) -> Result<(), OpenStackCliError> {
89 info!("Get Loadbalancer");
90
91 let op = OutputProcessor::from_args(
92 parsed_args,
93 Some("load-balancer.loadbalancer"),
94 Some("status"),
95 );
96 op.validate_args(parsed_args)?;
97
98 let mut ep_builder = status::Request::builder();
99
100 ep_builder.id(&self.path.id);
101
102 let ep = ep_builder
103 .build()
104 .map_err(|x| OpenStackCliError::EndpointBuild(x.to_string()))?;
105
106 let data: serde_json::Value = ep.query_async(client).await?;
107
108 op.output_single::<response::status::LoadbalancerResponse>(data.clone())?;
109 // Show command specific hints
110 op.show_command_hint()?;
111 Ok(())
112 }
113}