Skip to content

Commit 5300fd7

Browse files
committed
feat: Start generating keystone-ng code
Start generating the code from the new keystone with improved federation support, passkeys, etc. Change-Id: I84ecfbd26bcfdaf010181ee04a9c2c2e2974a58c Signed-off-by: Artem Goncharov <artem.goncharov@gmail.com> Changes are triggered by https://review.opendev.org/959986
1 parent 0608bb9 commit 5300fd7

111 files changed

Lines changed: 7037 additions & 72 deletions

File tree

Some content is hidden

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

openstack_cli/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ load_balancer = ["openstack_sdk/load_balancer"]
4545
network = ["openstack_sdk/network"]
4646
object_store = ["openstack_sdk/object_store"]
4747
placement = ["openstack_sdk/placement"]
48+
keystone_ng = ["openstack_sdk/keystone_ng", "openstack_types/keystone_ng"]
4849
_test_admin = []
4950
_test_net_auto-allocated-topology = []
5051
_test_net_dhcp_agent_scheduler = []
Lines changed: 209 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,209 @@
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+
//! Create IdentityProvider command
19+
//!
20+
//! Wraps invoking of the `v4/federation/identity_providers` with `POST` 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 crate::common::parse_key_val;
32+
use openstack_sdk::api::QueryAsync;
33+
use openstack_sdk::api::identity::v4::federation::identity_provider::create;
34+
use openstack_types::identity::v4::federation::identity_provider::response::create::IdentityProviderResponse;
35+
use serde_json::Value;
36+
37+
/// Create the identity provider with the specified properties.
38+
///
39+
/// It is expected that only admin user is able to create global identity
40+
/// providers.
41+
#[derive(Args)]
42+
#[command(about = "Create the identity provider.")]
43+
pub struct IdentityProviderCommand {
44+
/// Request Query parameters
45+
#[command(flatten)]
46+
query: QueryParameters,
47+
48+
/// Path parameters
49+
#[command(flatten)]
50+
path: PathParameters,
51+
52+
/// Identity provider data.
53+
#[command(flatten)]
54+
identity_provider: IdentityProvider,
55+
}
56+
57+
/// Query parameters
58+
#[derive(Args)]
59+
struct QueryParameters {}
60+
61+
/// Path parameters
62+
#[derive(Args)]
63+
struct PathParameters {}
64+
/// IdentityProvider Body data
65+
#[derive(Args, Clone)]
66+
struct IdentityProvider {
67+
/// The bound issuer that is verified when using the identity provider.
68+
#[arg(help_heading = "Body parameters", long)]
69+
bound_issuer: Option<String>,
70+
71+
/// Default attribute mapping name which is automatically used when no
72+
/// mapping is explicitly requested. The referred attribute mapping must
73+
/// exist.
74+
#[arg(help_heading = "Body parameters", long)]
75+
default_mapping_name: Option<String>,
76+
77+
/// The ID of the domain this identity provider belongs to. Empty value
78+
/// identifies that the identity provider can be used by other domains as
79+
/// well.
80+
#[arg(help_heading = "Body parameters", long)]
81+
domain_id: Option<String>,
82+
83+
/// Optional URL to fetch JsonWebKeySet. Must be specified for JWT
84+
/// authentication when discovery for the provider is not available or not
85+
/// standard compliant.
86+
#[arg(help_heading = "Body parameters", long)]
87+
jwks_url: Option<String>,
88+
89+
/// List of the jwt validation public keys.
90+
///
91+
/// Parameter is an array, may be provided multiple times.
92+
#[arg(action=clap::ArgAction::Append, help_heading = "Body parameters", long)]
93+
jwt_validation_pubkeys: Option<Vec<String>>,
94+
95+
/// Identity provider name.
96+
#[arg(help_heading = "Body parameters", long)]
97+
name: String,
98+
99+
/// The oidc `client_id` to use for the private client.
100+
#[arg(help_heading = "Body parameters", long)]
101+
oidc_client_id: Option<String>,
102+
103+
/// The oidc `client_secret` to use for the private client. It is never
104+
/// returned back.
105+
#[arg(help_heading = "Body parameters", long)]
106+
oidc_client_secret: Option<String>,
107+
108+
/// OIDC discovery endpoint for the identity provider.
109+
#[arg(help_heading = "Body parameters", long)]
110+
oidc_discovery_url: Option<String>,
111+
112+
/// The oidc response mode.
113+
#[arg(help_heading = "Body parameters", long)]
114+
oidc_response_mode: Option<String>,
115+
116+
/// List of supported response types.
117+
///
118+
/// Parameter is an array, may be provided multiple times.
119+
#[arg(action=clap::ArgAction::Append, help_heading = "Body parameters", long)]
120+
oidc_response_types: Option<Vec<String>>,
121+
122+
/// Additional special provider specific configuration
123+
#[arg(help_heading = "Body parameters", long, value_name="key=value", value_parser=parse_key_val::<String, Value>)]
124+
provider_config: Option<Vec<(String, Value)>>,
125+
}
126+
127+
impl IdentityProviderCommand {
128+
/// Perform command action
129+
pub async fn take_action(
130+
&self,
131+
parsed_args: &Cli,
132+
client: &mut AsyncOpenStack,
133+
) -> Result<(), OpenStackCliError> {
134+
info!("Create IdentityProvider");
135+
136+
let op = OutputProcessor::from_args(
137+
parsed_args,
138+
Some("identity.federation/identity_provider"),
139+
Some("create"),
140+
);
141+
op.validate_args(parsed_args)?;
142+
143+
let mut ep_builder = create::Request::builder();
144+
145+
// Set body parameters
146+
// Set Request.identity_provider data
147+
let args = &self.identity_provider;
148+
let mut identity_provider_builder = create::IdentityProviderBuilder::default();
149+
if let Some(val) = &args.bound_issuer {
150+
identity_provider_builder.bound_issuer(val);
151+
}
152+
153+
if let Some(val) = &args.default_mapping_name {
154+
identity_provider_builder.default_mapping_name(val);
155+
}
156+
157+
if let Some(val) = &args.domain_id {
158+
identity_provider_builder.domain_id(val);
159+
}
160+
161+
if let Some(val) = &args.jwks_url {
162+
identity_provider_builder.jwks_url(val);
163+
}
164+
165+
if let Some(val) = &args.jwt_validation_pubkeys {
166+
identity_provider_builder
167+
.jwt_validation_pubkeys(val.iter().map(Into::into).collect::<Vec<_>>());
168+
}
169+
170+
identity_provider_builder.name(&args.name);
171+
172+
if let Some(val) = &args.oidc_client_id {
173+
identity_provider_builder.oidc_client_id(val);
174+
}
175+
176+
if let Some(val) = &args.oidc_client_secret {
177+
identity_provider_builder.oidc_client_secret(val);
178+
}
179+
180+
if let Some(val) = &args.oidc_discovery_url {
181+
identity_provider_builder.oidc_discovery_url(val);
182+
}
183+
184+
if let Some(val) = &args.oidc_response_mode {
185+
identity_provider_builder.oidc_response_mode(val);
186+
}
187+
188+
if let Some(val) = &args.oidc_response_types {
189+
identity_provider_builder
190+
.oidc_response_types(val.iter().map(Into::into).collect::<Vec<_>>());
191+
}
192+
193+
if let Some(val) = &args.provider_config {
194+
identity_provider_builder.provider_config(val.iter().cloned());
195+
}
196+
197+
ep_builder.identity_provider(identity_provider_builder.build().unwrap());
198+
199+
let ep = ep_builder
200+
.build()
201+
.map_err(|x| OpenStackCliError::EndpointBuild(x.to_string()))?;
202+
203+
let data = ep.query_async(client).await?;
204+
op.output_single::<IdentityProviderResponse>(data)?;
205+
// Show command specific hints
206+
op.show_command_hint()?;
207+
Ok(())
208+
}
209+
}
Lines changed: 94 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,94 @@
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+
//! Delete IdentityProvider command
19+
//!
20+
//! Wraps invoking of the `v4/federation/identity_providers/{idp_id}` with `DELETE` 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::identity::v4::federation::identity_provider::delete;
33+
34+
/// Deletes the existing identity provider.
35+
///
36+
/// It is expected that only admin user is allowed to delete the global
37+
/// identity provider
38+
#[derive(Args)]
39+
#[command(about = "Delete Identity provider.")]
40+
pub struct IdentityProviderCommand {
41+
/// Request Query parameters
42+
#[command(flatten)]
43+
query: QueryParameters,
44+
45+
/// Path parameters
46+
#[command(flatten)]
47+
path: PathParameters,
48+
}
49+
50+
/// Query parameters
51+
#[derive(Args)]
52+
struct QueryParameters {}
53+
54+
/// Path parameters
55+
#[derive(Args)]
56+
struct PathParameters {
57+
/// The ID of the identity provider
58+
#[arg(
59+
help_heading = "Path parameters",
60+
id = "path_param_idp_id",
61+
value_name = "IDP_ID"
62+
)]
63+
idp_id: String,
64+
}
65+
66+
impl IdentityProviderCommand {
67+
/// Perform command action
68+
pub async fn take_action(
69+
&self,
70+
parsed_args: &Cli,
71+
client: &mut AsyncOpenStack,
72+
) -> Result<(), OpenStackCliError> {
73+
info!("Delete IdentityProvider");
74+
75+
let op = OutputProcessor::from_args(
76+
parsed_args,
77+
Some("identity.federation/identity_provider"),
78+
Some("delete"),
79+
);
80+
op.validate_args(parsed_args)?;
81+
82+
let mut ep_builder = delete::Request::builder();
83+
84+
ep_builder.idp_id(&self.path.idp_id);
85+
86+
let ep = ep_builder
87+
.build()
88+
.map_err(|x| OpenStackCliError::EndpointBuild(x.to_string()))?;
89+
openstack_sdk::api::ignore(ep).query_async(client).await?;
90+
// Show command specific hints
91+
op.show_command_hint()?;
92+
Ok(())
93+
}
94+
}

0 commit comments

Comments
 (0)