openstack_cli_placement/v1/resource_provider/set_10.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//! Set ResourceProvider command [microversion = 1.0]
19//!
20//! Wraps invoking of the `resource_providers/{uuid}` with `PUT` 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::placement::v1::resource_provider::set_10;
32
33/// Update the name of the resource provider identified by {uuid}.
34///
35/// Normal Response Codes: 200
36///
37/// Error response codes: badRequest(400), itemNotFound(404), conflict(409)
38///
39/// A 409 Conflict response code will be returned if another resource provider
40/// exists with the provided name.
41#[derive(Args)]
42#[command(about = "Update resource provider (microversion = 1.0)")]
43pub struct ResourceProviderCommand {
44 /// Request Query parameters
45 #[command(flatten)]
46 query: QueryParameters,
47
48 /// Path parameters
49 #[command(flatten)]
50 path: PathParameters,
51
52 /// The name of one resource provider.
53 #[arg(help_heading = "Body parameters", long)]
54 name: String,
55}
56
57/// Query parameters
58#[derive(Args)]
59struct QueryParameters {}
60
61/// Path parameters
62#[derive(Args)]
63struct PathParameters {
64 /// uuid parameter for /resource_providers/{uuid} API
65 #[arg(
66 help_heading = "Path parameters",
67 id = "path_param_uuid",
68 value_name = "UUID"
69 )]
70 uuid: String,
71}
72
73impl ResourceProviderCommand {
74 /// Perform command action
75 pub async fn take_action<C: CliArgs>(
76 &self,
77 parsed_args: &C,
78 client: &mut AsyncOpenStack,
79 ) -> Result<(), OpenStackCliError> {
80 info!("Set ResourceProvider");
81
82 let op = OutputProcessor::from_args(
83 parsed_args,
84 Some("placement.resource_provider"),
85 Some("set"),
86 );
87 op.validate_args(parsed_args)?;
88
89 let mut ep_builder = set_10::Request::builder();
90 ep_builder.header(
91 http::header::HeaderName::from_static("openstack-api-version"),
92 http::header::HeaderValue::from_static("placement 1.0"),
93 );
94
95 ep_builder.uuid(&self.path.uuid);
96
97 // Set body parameters
98 // Set Request.name data
99 ep_builder.name(&self.name);
100
101 let ep = ep_builder
102 .build()
103 .map_err(|x| OpenStackCliError::EndpointBuild(x.to_string()))?;
104 openstack_sdk::api::ignore(ep).query_async(client).await?;
105 // Show command specific hints
106 op.show_command_hint()?;
107 Ok(())
108 }
109}