Skip to content

Commit b4859c7

Browse files
authored
Merge pull request #124 from gtema/loadbalancer
feat: Add LoadBalancer
2 parents 702d60f + c7c7c1b commit b4859c7

File tree

294 files changed

+42110
-0
lines changed

Some content is hidden

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

294 files changed

+42110
-0
lines changed

doc/src/osc.md

Lines changed: 1949 additions & 0 deletions
Large diffs are not rendered by default.

openstack_cli/src/cli.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ use crate::catalog;
3030
use crate::compute::v2 as compute;
3131
use crate::identity::v3 as identity;
3232
use crate::image::v2 as image;
33+
use crate::load_balancer::v2 as load_balancer;
3334
use crate::network::v2 as network;
3435
use crate::object_store::v1 as object_store;
3536

@@ -101,6 +102,7 @@ pub enum TopLevelCommands {
101102
Compute(compute::ComputeCommand),
102103
Identity(identity::IdentityCommand),
103104
Image(image::ImageCommand),
105+
LoadBalancer(load_balancer::LoadBalancerCommand),
104106
Network(network::NetworkCommand),
105107
ObjectStore(object_store::ObjectStoreCommand),
106108
}
@@ -116,6 +118,7 @@ impl Cli {
116118
TopLevelCommands::Compute(args) => args.take_action(self, client).await,
117119
TopLevelCommands::Identity(args) => args.take_action(self, client).await,
118120
TopLevelCommands::Image(args) => args.take_action(self, client).await,
121+
TopLevelCommands::LoadBalancer(args) => args.take_action(self, client).await,
119122
TopLevelCommands::Network(args) => args.take_action(self, client).await,
120123
TopLevelCommands::ObjectStore(args) => args.take_action(self, client).await,
121124
}

openstack_cli/src/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ mod common;
3030
mod compute;
3131
mod identity;
3232
mod image;
33+
mod load_balancer;
3334
mod network;
3435
mod object_store;
3536

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
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+
//! Load Balancer (Octavia) commands
16+
pub(super) mod v2;
Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
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+
//! Octavia `Amphorae` resource commands
16+
17+
use clap::{Parser, Subcommand};
18+
19+
use openstack_sdk::AsyncOpenStack;
20+
21+
use crate::{Cli, OpenStackCliError};
22+
23+
mod config;
24+
mod delete;
25+
mod failover;
26+
mod list;
27+
mod show;
28+
mod stats;
29+
30+
/// Amphorae (Octavia) commands
31+
#[derive(Parser)]
32+
pub struct AmphoraeCommand {
33+
/// subcommand
34+
#[command(subcommand)]
35+
command: AmphoraeCommands,
36+
}
37+
38+
/// Supported subcommands
39+
#[allow(missing_docs)]
40+
#[derive(Subcommand)]
41+
pub enum AmphoraeCommands {
42+
Config(config::AmphoraeCommand),
43+
Delete(delete::AmphoraeCommand),
44+
Failover(failover::AmphoraeCommand),
45+
List(list::AmphoraesCommand),
46+
Show(show::AmphoraeCommand),
47+
Stats(stats::AmphoraeCommand),
48+
}
49+
50+
impl AmphoraeCommand {
51+
/// Perform command action
52+
pub async fn take_action(
53+
&self,
54+
parsed_args: &Cli,
55+
session: &mut AsyncOpenStack,
56+
) -> Result<(), OpenStackCliError> {
57+
match &self.command {
58+
AmphoraeCommands::Config(cmd) => cmd.take_action(parsed_args, session).await,
59+
AmphoraeCommands::Delete(cmd) => cmd.take_action(parsed_args, session).await,
60+
AmphoraeCommands::Failover(cmd) => cmd.take_action(parsed_args, session).await,
61+
AmphoraeCommands::List(cmd) => cmd.take_action(parsed_args, session).await,
62+
AmphoraeCommands::Show(cmd) => cmd.take_action(parsed_args, session).await,
63+
AmphoraeCommands::Stats(cmd) => cmd.take_action(parsed_args, session).await,
64+
}
65+
}
66+
}
Lines changed: 114 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,114 @@
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+
//! Action Amphorae command
19+
//!
20+
//! Wraps invoking of the `v2/octavia/amphorae/{amphora_id}/config` with `PUT` method
21+
22+
use clap::Args;
23+
use serde::{Deserialize, Serialize};
24+
use tracing::info;
25+
26+
use anyhow::Result;
27+
28+
use openstack_sdk::AsyncOpenStack;
29+
30+
use crate::output::OutputProcessor;
31+
use crate::Cli;
32+
use crate::OpenStackCliError;
33+
use crate::OutputConfig;
34+
use crate::StructTable;
35+
36+
use crate::common::parse_key_val;
37+
use bytes::Bytes;
38+
use http::Response;
39+
use openstack_sdk::api::load_balancer::v2::amphorae::config;
40+
use openstack_sdk::api::RawQueryAsync;
41+
use serde_json::Value;
42+
use structable_derive::StructTable;
43+
44+
/// Request of the octavia/amphorae/amphora_id/config:put operation
45+
///
46+
#[derive(Args)]
47+
#[command(about = "Configure Amphora")]
48+
pub struct AmphoraeCommand {
49+
/// Request Query parameters
50+
#[command(flatten)]
51+
query: QueryParameters,
52+
53+
/// Path parameters
54+
#[command(flatten)]
55+
path: PathParameters,
56+
57+
#[arg(long="property", value_name="key=value", value_parser=parse_key_val::<String, Value>)]
58+
#[arg(help_heading = "Body parameters")]
59+
properties: Option<Vec<(String, Value)>>,
60+
}
61+
62+
/// Query parameters
63+
#[derive(Args)]
64+
struct QueryParameters {}
65+
66+
/// Path parameters
67+
#[derive(Args)]
68+
struct PathParameters {
69+
/// amphora_id parameter for /v2/octavia/amphorae/{amphora_id}/config API
70+
///
71+
#[arg(
72+
help_heading = "Path parameters",
73+
id = "path_param_amphora_id",
74+
value_name = "AMPHORA_ID"
75+
)]
76+
amphora_id: String,
77+
}
78+
/// Amphorae response representation
79+
#[derive(Deserialize, Serialize, Clone, StructTable)]
80+
struct ResponseData {}
81+
82+
impl AmphoraeCommand {
83+
/// Perform command action
84+
pub async fn take_action(
85+
&self,
86+
parsed_args: &Cli,
87+
client: &mut AsyncOpenStack,
88+
) -> Result<(), OpenStackCliError> {
89+
info!("Action Amphorae");
90+
91+
let op = OutputProcessor::from_args(parsed_args);
92+
op.validate_args(parsed_args)?;
93+
94+
let mut ep_builder = config::Request::builder();
95+
96+
// Set path parameters
97+
ep_builder.amphora_id(&self.path.amphora_id);
98+
// Set query parameters
99+
// Set body parameters
100+
if let Some(properties) = &self.properties {
101+
ep_builder.properties(properties.iter().cloned());
102+
}
103+
104+
let ep = ep_builder
105+
.build()
106+
.map_err(|x| OpenStackCliError::EndpointBuild(x.to_string()))?;
107+
108+
let _rsp: Response<Bytes> = ep.raw_query_async(client).await?;
109+
let data = ResponseData {};
110+
// Maybe output some headers metadata
111+
op.output_human::<ResponseData>(&data)?;
112+
Ok(())
113+
}
114+
}
Lines changed: 107 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,107 @@
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 Amphorae command
19+
//!
20+
//! Wraps invoking of the `v2/octavia/amphorae/{amphora_id}` with `DELETE` method
21+
22+
use clap::Args;
23+
use serde::{Deserialize, Serialize};
24+
use tracing::info;
25+
26+
use anyhow::Result;
27+
28+
use openstack_sdk::AsyncOpenStack;
29+
30+
use crate::output::OutputProcessor;
31+
use crate::Cli;
32+
use crate::OpenStackCliError;
33+
use crate::OutputConfig;
34+
use crate::StructTable;
35+
36+
use bytes::Bytes;
37+
use http::Response;
38+
use openstack_sdk::api::load_balancer::v2::amphorae::delete;
39+
use openstack_sdk::api::RawQueryAsync;
40+
use structable_derive::StructTable;
41+
42+
/// Removes an amphora and its associated configuration.
43+
///
44+
/// The API immediately purges any and all configuration data, depending on the
45+
/// configuration settings. You cannot recover it.
46+
///
47+
/// **New in version 2.20**
48+
///
49+
#[derive(Args)]
50+
#[command(about = "Remove an Amphora")]
51+
pub struct AmphoraeCommand {
52+
/// Request Query parameters
53+
#[command(flatten)]
54+
query: QueryParameters,
55+
56+
/// Path parameters
57+
#[command(flatten)]
58+
path: PathParameters,
59+
}
60+
61+
/// Query parameters
62+
#[derive(Args)]
63+
struct QueryParameters {}
64+
65+
/// Path parameters
66+
#[derive(Args)]
67+
struct PathParameters {
68+
/// amphora_id parameter for /v2/octavia/amphorae/{amphora_id} API
69+
///
70+
#[arg(
71+
help_heading = "Path parameters",
72+
id = "path_param_amphora_id",
73+
value_name = "AMPHORA_ID"
74+
)]
75+
amphora_id: String,
76+
}
77+
/// Amphorae response representation
78+
#[derive(Deserialize, Serialize, Clone, StructTable)]
79+
struct ResponseData {}
80+
81+
impl AmphoraeCommand {
82+
/// Perform command action
83+
pub async fn take_action(
84+
&self,
85+
parsed_args: &Cli,
86+
client: &mut AsyncOpenStack,
87+
) -> Result<(), OpenStackCliError> {
88+
info!("Delete Amphorae");
89+
90+
let op = OutputProcessor::from_args(parsed_args);
91+
op.validate_args(parsed_args)?;
92+
93+
let mut ep_builder = delete::Request::builder();
94+
95+
// Set path parameters
96+
ep_builder.amphora_id(&self.path.amphora_id);
97+
// Set query parameters
98+
// Set body parameters
99+
100+
let ep = ep_builder
101+
.build()
102+
.map_err(|x| OpenStackCliError::EndpointBuild(x.to_string()))?;
103+
104+
let _rsp: Response<Bytes> = ep.raw_query_async(client).await?;
105+
Ok(())
106+
}
107+
}

0 commit comments

Comments
 (0)