Skip to content

Commit

Permalink
feat: Add volume.az resource (#194)
Browse files Browse the repository at this point in the history
add volume.az and fix compute.az to not to require "-o wide".
  • Loading branch information
gtema authored May 6, 2024
1 parent 51ad58b commit a52061b
Show file tree
Hide file tree
Showing 11 changed files with 431 additions and 4 deletions.
25 changes: 25 additions & 0 deletions doc/src/osc.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ This document contains the help content for the `osc` command-line program.
* [`osc block-storage attachment list`↴](#osc-block-storage-attachment-list)
* [`osc block-storage attachment set327`↴](#osc-block-storage-attachment-set327)
* [`osc block-storage attachment show`↴](#osc-block-storage-attachment-show)
* [`osc block-storage availability-zone`↴](#osc-block-storage-availability-zone)
* [`osc block-storage availability-zone list`↴](#osc-block-storage-availability-zone-list)
* [`osc block-storage backup`↴](#osc-block-storage-backup)
* [`osc block-storage backup create351`↴](#osc-block-storage-backup-create351)
* [`osc block-storage backup create343`↴](#osc-block-storage-backup-create343)
Expand Down Expand Up @@ -840,6 +842,7 @@ Block Storage (Volume) service (Cinder) commands
###### **Subcommands:**

* `attachment` — Attachments (attachments)
* `availability-zone` — Availability zones
* `backup` — Backups
* `cluster` — Clusters (clusters)
* `default-type` — Default Volume Types (default-types)
Expand Down Expand Up @@ -1066,6 +1069,28 @@ Return data about the given attachment



## `osc block-storage availability-zone`

Availability zones

Lists and gets detailed availability zone information.

**Usage:** `osc block-storage availability-zone <COMMAND>`

###### **Subcommands:**

* `list` — Describe all known availability zones



## `osc block-storage availability-zone list`

Describe all known availability zones

**Usage:** `osc block-storage availability-zone list`



## `osc block-storage backup`

Backups
Expand Down
5 changes: 5 additions & 0 deletions openstack_cli/src/block_storage/v3.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ use openstack_sdk::{types::ServiceType, AsyncOpenStack};
use crate::{Cli, OpenStackCliError};

mod attachment;
mod availability_zone;
mod backup;
mod cluster;
mod default_type;
Expand Down Expand Up @@ -52,6 +53,7 @@ pub struct BlockStorageCommand {
#[derive(Subcommand)]
pub enum BlockStorageCommands {
Attachment(attachment::AttachmentCommand),
AvailabilityZone(availability_zone::AvailabilityZoneCommand),
Backup(backup::BackupCommand),
Cluster(cluster::ClusterCommand),
DefaultType(default_type::DefaultTypeCommand),
Expand Down Expand Up @@ -85,6 +87,9 @@ impl BlockStorageCommand {

match &self.command {
BlockStorageCommands::Attachment(cmd) => cmd.take_action(parsed_args, session).await,
BlockStorageCommands::AvailabilityZone(cmd) => {
cmd.take_action(parsed_args, session).await
}
BlockStorageCommands::Backup(cmd) => cmd.take_action(parsed_args, session).await,
BlockStorageCommands::Cluster(cmd) => cmd.take_action(parsed_args, session).await,
BlockStorageCommands::DefaultType(cmd) => cmd.take_action(parsed_args, session).await,
Expand Down
53 changes: 53 additions & 0 deletions openstack_cli/src/block_storage/v3/availability_zone.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
// SPDX-License-Identifier: Apache-2.0

//! Availability zone management
use clap::{Parser, Subcommand};

use openstack_sdk::AsyncOpenStack;

use crate::{Cli, OpenStackCliError};

mod list;

/// Availability zones
///
/// Lists and gets detailed availability zone information.
#[derive(Parser)]
pub struct AvailabilityZoneCommand {
/// subcommand
#[command(subcommand)]
command: AvailabilityZoneCommands,
}

/// Supported subcommands
#[allow(missing_docs)]
#[derive(Subcommand)]
pub enum AvailabilityZoneCommands {
List(list::AvailabilityZonesCommand),
}

impl AvailabilityZoneCommand {
/// Perform command action
pub async fn take_action(
&self,
parsed_args: &Cli,
session: &mut AsyncOpenStack,
) -> Result<(), OpenStackCliError> {
match &self.command {
AvailabilityZoneCommands::List(cmd) => cmd.take_action(parsed_args, session).await,
}
}
}
102 changes: 102 additions & 0 deletions openstack_cli/src/block_storage/v3/availability_zone/list.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
// SPDX-License-Identifier: Apache-2.0
//
// WARNING: This file is automatically generated from OpenAPI schema using
// `openstack-codegenerator`.

//! List AvailabilityZones command
//!
//! Wraps invoking of the `v3/os-availability-zone` with `GET` method
use clap::Args;
use serde::{Deserialize, Serialize};
use tracing::info;

use anyhow::Result;

use openstack_sdk::AsyncOpenStack;

use crate::output::OutputProcessor;
use crate::Cli;
use crate::OpenStackCliError;
use crate::OutputConfig;
use crate::StructTable;

use openstack_sdk::api::block_storage::v3::availability_zone::list;
use openstack_sdk::api::QueryAsync;
use serde_json::Value;
use structable_derive::StructTable;

/// Describe all known availability zones.
///
#[derive(Args)]
pub struct AvailabilityZonesCommand {
/// Request Query parameters
#[command(flatten)]
query: QueryParameters,

/// Path parameters
#[command(flatten)]
path: PathParameters,
}

/// Query parameters
#[derive(Args)]
struct QueryParameters {}

/// Path parameters
#[derive(Args)]
struct PathParameters {}
/// AvailabilityZones response representation
#[derive(Deserialize, Serialize, Clone, StructTable)]
struct ResponseData {
/// The availability zone name.
///
#[serde(rename = "zoneName")]
#[structable(optional, title = "zoneName")]
zone_name: Option<String>,

#[serde(rename = "zoneState")]
#[structable(optional, pretty, title = "zoneState")]
zone_state: Option<Value>,
}

impl AvailabilityZonesCommand {
/// Perform command action
pub async fn take_action(
&self,
parsed_args: &Cli,
client: &mut AsyncOpenStack,
) -> Result<(), OpenStackCliError> {
info!("List AvailabilityZones");

let op = OutputProcessor::from_args(parsed_args);
op.validate_args(parsed_args)?;

let ep_builder = list::Request::builder();

// Set path parameters
// Set query parameters
// Set body parameters

let ep = ep_builder
.build()
.map_err(|x| OpenStackCliError::EndpointBuild(x.to_string()))?;

let data: Vec<serde_json::Value> = ep.query_async(client).await?;

op.output_list::<ResponseData>(data)?;
Ok(())
}
}
4 changes: 2 additions & 2 deletions openstack_cli/src/compute/v2/availability_zone/list.rs
Original file line number Diff line number Diff line change
Expand Up @@ -75,13 +75,13 @@ struct ResponseData {
/// The availability zone name.
///
#[serde(rename = "zoneName")]
#[structable(optional, title = "zoneName", wide)]
#[structable(optional, title = "zoneName")]
zone_name: Option<String>,

/// The current state of the availability zone.
///
#[serde(rename = "zoneState")]
#[structable(optional, pretty, title = "zoneState", wide)]
#[structable(optional, pretty, title = "zoneState")]
zone_state: Option<Value>,
}

Expand Down
4 changes: 2 additions & 2 deletions openstack_cli/src/compute/v2/availability_zone/list_detail.rs
Original file line number Diff line number Diff line change
Expand Up @@ -80,13 +80,13 @@ struct ResponseData {
/// The availability zone name.
///
#[serde(rename = "zoneName")]
#[structable(optional, title = "zoneName", wide)]
#[structable(optional, title = "zoneName")]
zone_name: Option<String>,

/// The current state of the availability zone.
///
#[serde(rename = "zoneState")]
#[structable(optional, pretty, title = "zoneState", wide)]
#[structable(optional, pretty, title = "zoneState")]
zone_state: Option<Value>,
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
// SPDX-License-Identifier: Apache-2.0
//
// WARNING: This file is automatically generated from OpenAPI schema using
// `openstack-codegenerator`.

use assert_cmd::prelude::*;
use std::process::Command;

#[test]
fn help() -> Result<(), Box<dyn std::error::Error>> {
let mut cmd = Command::cargo_bin("osc")?;

cmd.arg("block-storage")
.arg("availability-zone")
.arg("list")
.arg("--help");
cmd.assert().success();

Ok(())
}
30 changes: 30 additions & 0 deletions openstack_cli/tests/block_storage/v3/availability_zone/mod.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
// SPDX-License-Identifier: Apache-2.0

mod list_autogen;

use assert_cmd::prelude::*;
use std::process::Command;

#[test]
fn help() -> Result<(), Box<dyn std::error::Error>> {
let mut cmd = Command::cargo_bin("osc")?;

cmd.arg("block-storage")
.arg("availability-zone")
.arg("--help");
cmd.assert().success();

Ok(())
}
1 change: 1 addition & 0 deletions openstack_sdk/src/api/block_storage/v3.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@

//! `Block_storage` Service bindings
pub mod attachment;
pub mod availability_zone;
pub mod backup;
pub mod cluster;
pub mod default_type;
Expand Down
19 changes: 19 additions & 0 deletions openstack_sdk/src/api/block_storage/v3/availability_zone.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
// SPDX-License-Identifier: Apache-2.0
//
// WARNING: This file is automatically generated from OpenAPI schema using
// `openstack-codegenerator`.

//! `/v3/os-availability-zone` REST operations of block_storage
pub mod list;
Loading

0 comments on commit a52061b

Please sign in to comment.