Skip to content

Commit

Permalink
chore: Regenerate block-storage resources (#397)
Browse files Browse the repository at this point in the history
Signed-off-by: Artem Goncharov <[email protected]>
  • Loading branch information
gtema authored Aug 1, 2024
1 parent e1e213b commit e802aa3
Show file tree
Hide file tree
Showing 105 changed files with 11,299 additions and 0 deletions.
113 changes: 113 additions & 0 deletions openstack_cli/src/block_storage/v3/capability/show.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,113 @@
// 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`.

//! Show Capability command
//!
//! Wraps invoking of the `v3/capabilities/{id}` with `GET` method
use clap::Args;
use serde::{Deserialize, Serialize};
use tracing::info;

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::capability::get;
use openstack_sdk::api::QueryAsync;
use serde_json::Value;
use std::collections::HashMap;

/// Return capabilities list of given backend.
///
#[derive(Args)]
pub struct CapabilityCommand {
/// 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 {
/// id parameter for /v3/capabilities/{id} API
///
#[arg(
help_heading = "Path parameters",
id = "path_param_id",
value_name = "ID"
)]
id: String,
}
/// Response data as HashMap type
#[derive(Deserialize, Serialize)]
struct ResponseData(HashMap<String, Value>);

impl StructTable for ResponseData {
fn build(&self, _options: &OutputConfig) -> (Vec<String>, Vec<Vec<String>>) {
let headers: Vec<String> = Vec::from(["Name".to_string(), "Value".to_string()]);
let mut rows: Vec<Vec<String>> = Vec::new();
rows.extend(self.0.iter().map(|(k, v)| {
Vec::from([
k.clone(),
serde_json::to_string(&v).expect("Is a valid data"),
])
}));
(headers, rows)
}
}

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

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

let mut ep_builder = get::Request::builder();

// Set path parameters
ep_builder.id(&self.path.id);
// Set query parameters
// Set body parameters

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

let data = ep.query_async(client).await?;
op.output_single::<ResponseData>(data)?;
Ok(())
}
}
112 changes: 112 additions & 0 deletions openstack_cli/src/block_storage/v3/cgsnapshot/create.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,112 @@
// 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`.

//! Create Cgsnapshot command
//!
//! Wraps invoking of the `v3/cgsnapshots` with `POST` method
use clap::Args;
use serde::{Deserialize, Serialize};
use tracing::info;

use openstack_sdk::AsyncOpenStack;

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

use crate::common::parse_json;
use crate::common::parse_key_val;
use openstack_sdk::api::block_storage::v3::cgsnapshot::create;
use openstack_sdk::api::QueryAsync;
use serde_json::Value;
use std::collections::HashMap;

/// Create a new cgsnapshot.
///
#[derive(Args)]
pub struct CgsnapshotCommand {
/// Request Query parameters
#[command(flatten)]
query: QueryParameters,

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

#[arg(long="property", value_name="key=value", value_parser=parse_key_val::<String, Value>)]
#[arg(help_heading = "Body parameters")]
properties: Option<Vec<(String, Value)>>,
}

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

/// Path parameters
#[derive(Args)]
struct PathParameters {}
/// Response data as HashMap type
#[derive(Deserialize, Serialize)]
struct ResponseData(HashMap<String, Value>);

impl StructTable for ResponseData {
fn build(&self, _options: &OutputConfig) -> (Vec<String>, Vec<Vec<String>>) {
let headers: Vec<String> = Vec::from(["Name".to_string(), "Value".to_string()]);
let mut rows: Vec<Vec<String>> = Vec::new();
rows.extend(self.0.iter().map(|(k, v)| {
Vec::from([
k.clone(),
serde_json::to_string(&v).expect("Is a valid data"),
])
}));
(headers, rows)
}
}

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

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

let mut ep_builder = create::Request::builder();

// Set path parameters
// Set query parameters
// Set body parameters
if let Some(properties) = &self.properties {
ep_builder.properties(properties.iter().cloned());
}

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

let data = ep.query_async(client).await?;
op.output_single::<ResponseData>(data)?;
Ok(())
}
}
99 changes: 99 additions & 0 deletions openstack_cli/src/block_storage/v3/cgsnapshot/delete.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
// 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`.

//! Delete Cgsnapshot command
//!
//! Wraps invoking of the `v3/cgsnapshots/{id}` with `DELETE` method
use clap::Args;
use serde::{Deserialize, Serialize};
use tracing::info;

use openstack_sdk::AsyncOpenStack;

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

use bytes::Bytes;
use http::Response;
use openstack_sdk::api::block_storage::v3::cgsnapshot::delete;
use openstack_sdk::api::RawQueryAsync;
use structable_derive::StructTable;

/// Delete a cgsnapshot.
///
#[derive(Args)]
pub struct CgsnapshotCommand {
/// 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 {
/// id parameter for /v3/cgsnapshots/{id} API
///
#[arg(
help_heading = "Path parameters",
id = "path_param_id",
value_name = "ID"
)]
id: String,
}
/// Cgsnapshot response representation
#[derive(Deserialize, Serialize, Clone, StructTable)]
struct ResponseData {}

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

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

let mut ep_builder = delete::Request::builder();

// Set path parameters
ep_builder.id(&self.path.id);
// Set query parameters
// Set body parameters

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

let _rsp: Response<Bytes> = ep.raw_query_async(client).await?;
Ok(())
}
}
Loading

0 comments on commit e802aa3

Please sign in to comment.