Skip to content

Commit 988bce9

Browse files
authored
feat: Ensure schemas are not duplicated (#1311)
It can happen (in Keystone it does for sure) that certain API method decorators when applied together result in certain schemas being present in multiple decorator processing iterations. This results in some schemas being multiplied. It should be safe to just use `set` instead of a `list` to deduplicate them. While we were working on this Nova "again" changed some decorators breaking us so fix that as well since generated code is broken. Also re-enable tui things we just temporarily disabled. Change-Id: I25b2506264d6027f9d605c74297e6f0cc6ab2767 Signed-off-by: Artem Goncharov <artem.goncharov@gmail.com> Changes are triggered by https://review.opendev.org/953093
1 parent 4fb3047 commit 988bce9

File tree

188 files changed

+14567
-9381
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

188 files changed

+14567
-9381
lines changed

openstack_cli/src/compute/v2/hypervisor/search/get.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -93,8 +93,8 @@ impl SearchCommand {
9393
.build()
9494
.map_err(|x| OpenStackCliError::EndpointBuild(x.to_string()))?;
9595

96-
let data = ep.query_async(client).await?;
97-
op.output_single::<SearchResponse>(data)?;
96+
let data: Vec<serde_json::Value> = ep.query_async(client).await?;
97+
op.output_list::<SearchResponse>(data)?;
9898
Ok(())
9999
}
100100
}

openstack_cli/src/compute/v2/hypervisor/server/get.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -94,8 +94,8 @@ impl ServerCommand {
9494
.build()
9595
.map_err(|x| OpenStackCliError::EndpointBuild(x.to_string()))?;
9696

97-
let data = ep.query_async(client).await?;
98-
op.output_single::<ServerResponse>(data)?;
97+
let data: Vec<serde_json::Value> = ep.query_async(client).await?;
98+
op.output_list::<ServerResponse>(data)?;
9999
Ok(())
100100
}
101101
}
Lines changed: 212 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,212 @@
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 QuotaClassSet command [microversion = 2.50]
19+
//!
20+
//! Wraps invoking of the `v2.1/os-quota-class-sets/{id}` with `PUT` method
21+
22+
use clap::Args;
23+
use tracing::info;
24+
25+
use openstack_sdk::AsyncOpenStack;
26+
27+
use crate::Cli;
28+
use crate::OpenStackCliError;
29+
use crate::output::OutputProcessor;
30+
31+
use openstack_sdk::api::QueryAsync;
32+
use openstack_sdk::api::compute::v2::quota_class_set::set_250;
33+
use openstack_types::compute::v2::quota_class_set::response::set::QuotaClassSetResponse;
34+
35+
/// Update the quotas for the Quota Class.
36+
///
37+
/// If the requested Quota Class is not found in the DB, then the API will
38+
/// create the one. Only ‘default’ quota class is valid and used to set the
39+
/// default quotas, all other quota class would not be used anywhere.
40+
///
41+
/// Normal response codes: 200
42+
///
43+
/// Error response codes: badRequest(400), unauthorized(401), forbidden(403)
44+
#[derive(Args)]
45+
#[command(about = "Create or Update Quotas for Quota Class (microversion = 2.50)")]
46+
pub struct QuotaClassSetCommand {
47+
/// Request Query parameters
48+
#[command(flatten)]
49+
query: QueryParameters,
50+
51+
/// Path parameters
52+
#[command(flatten)]
53+
path: PathParameters,
54+
55+
/// A `quota_class_set` object.
56+
#[command(flatten)]
57+
quota_class_set: QuotaClassSet,
58+
}
59+
60+
/// Query parameters
61+
#[derive(Args)]
62+
struct QueryParameters {}
63+
64+
/// Path parameters
65+
#[derive(Args)]
66+
struct PathParameters {
67+
/// id parameter for /v2.1/os-quota-class-sets/{id} API
68+
#[arg(
69+
help_heading = "Path parameters",
70+
id = "path_param_id",
71+
value_name = "ID"
72+
)]
73+
id: String,
74+
}
75+
/// QuotaClassSet Body data
76+
#[derive(Args, Clone)]
77+
struct QuotaClassSet {
78+
/// The number of allowed injected files for the quota class.
79+
///
80+
/// **Available until version 2.56**
81+
#[arg(help_heading = "Body parameters", long)]
82+
cores: Option<i32>,
83+
84+
/// The number of allowed injected files for the quota class.
85+
///
86+
/// **Available until version 2.56**
87+
#[arg(help_heading = "Body parameters", long)]
88+
injected_file_content_bytes: Option<i32>,
89+
90+
/// The number of allowed injected files for the quota class.
91+
///
92+
/// **Available until version 2.56**
93+
#[arg(help_heading = "Body parameters", long)]
94+
injected_file_path_bytes: Option<i32>,
95+
96+
/// The number of allowed injected files for the quota class.
97+
///
98+
/// **Available until version 2.56**
99+
#[arg(help_heading = "Body parameters", long)]
100+
injected_files: Option<i32>,
101+
102+
/// The number of allowed injected files for the quota class.
103+
///
104+
/// **Available until version 2.56**
105+
#[arg(help_heading = "Body parameters", long)]
106+
instances: Option<i32>,
107+
108+
/// The number of allowed injected files for the quota class.
109+
///
110+
/// **Available until version 2.56**
111+
#[arg(help_heading = "Body parameters", long)]
112+
key_pairs: Option<i32>,
113+
114+
/// The number of allowed injected files for the quota class.
115+
///
116+
/// **Available until version 2.56**
117+
#[arg(help_heading = "Body parameters", long)]
118+
metadata_items: Option<i32>,
119+
120+
/// The number of allowed injected files for the quota class.
121+
///
122+
/// **Available until version 2.56**
123+
#[arg(help_heading = "Body parameters", long)]
124+
ram: Option<i32>,
125+
126+
/// The number of allowed injected files for the quota class.
127+
///
128+
/// **Available until version 2.56**
129+
#[arg(help_heading = "Body parameters", long)]
130+
server_group_members: Option<i32>,
131+
132+
/// The number of allowed injected files for the quota class.
133+
///
134+
/// **Available until version 2.56**
135+
#[arg(help_heading = "Body parameters", long)]
136+
server_groups: Option<i32>,
137+
}
138+
139+
impl QuotaClassSetCommand {
140+
/// Perform command action
141+
pub async fn take_action(
142+
&self,
143+
parsed_args: &Cli,
144+
client: &mut AsyncOpenStack,
145+
) -> Result<(), OpenStackCliError> {
146+
info!("Set QuotaClassSet");
147+
148+
let op =
149+
OutputProcessor::from_args(parsed_args, Some("compute.quota_class_set"), Some("set"));
150+
op.validate_args(parsed_args)?;
151+
152+
let mut ep_builder = set_250::Request::builder();
153+
ep_builder.header("OpenStack-API-Version", "compute 2.50");
154+
155+
// Set path parameters
156+
ep_builder.id(&self.path.id);
157+
// Set query parameters
158+
// Set body parameters
159+
// Set Request.quota_class_set data
160+
let args = &self.quota_class_set;
161+
let mut quota_class_set_builder = set_250::QuotaClassSetBuilder::default();
162+
if let Some(val) = &args.cores {
163+
quota_class_set_builder.cores(*val);
164+
}
165+
166+
if let Some(val) = &args.injected_file_content_bytes {
167+
quota_class_set_builder.injected_file_content_bytes(*val);
168+
}
169+
170+
if let Some(val) = &args.injected_file_path_bytes {
171+
quota_class_set_builder.injected_file_path_bytes(*val);
172+
}
173+
174+
if let Some(val) = &args.injected_files {
175+
quota_class_set_builder.injected_files(*val);
176+
}
177+
178+
if let Some(val) = &args.instances {
179+
quota_class_set_builder.instances(*val);
180+
}
181+
182+
if let Some(val) = &args.key_pairs {
183+
quota_class_set_builder.key_pairs(*val);
184+
}
185+
186+
if let Some(val) = &args.metadata_items {
187+
quota_class_set_builder.metadata_items(*val);
188+
}
189+
190+
if let Some(val) = &args.ram {
191+
quota_class_set_builder.ram(*val);
192+
}
193+
194+
if let Some(val) = &args.server_group_members {
195+
quota_class_set_builder.server_group_members(*val);
196+
}
197+
198+
if let Some(val) = &args.server_groups {
199+
quota_class_set_builder.server_groups(*val);
200+
}
201+
202+
ep_builder.quota_class_set(quota_class_set_builder.build().unwrap());
203+
204+
let ep = ep_builder
205+
.build()
206+
.map_err(|x| OpenStackCliError::EndpointBuild(x.to_string()))?;
207+
208+
let data = ep.query_async(client).await?;
209+
op.output_single::<QuotaClassSetResponse>(data)?;
210+
Ok(())
211+
}
212+
}

0 commit comments

Comments
 (0)