From e802aa35912b1c64093a99cc3c368e232e25e2ef Mon Sep 17 00:00:00 2001 From: Artem Goncharov Date: Thu, 1 Aug 2024 13:50:19 +0200 Subject: [PATCH] chore: Regenerate block-storage resources (#397) Signed-off-by: Artem Goncharov --- .../src/block_storage/v3/capability/show.rs | 113 +++++ .../src/block_storage/v3/cgsnapshot/create.rs | 112 +++++ .../src/block_storage/v3/cgsnapshot/delete.rs | 99 ++++ .../src/block_storage/v3/cgsnapshot/list.rs | 103 ++++ .../src/block_storage/v3/cgsnapshot/show.rs | 113 +++++ .../v3/consistencygroup/create.rs | 112 +++++ .../create_from_src/create.rs | 115 +++++ .../v3/consistencygroup/delete.rs | 99 ++++ .../v3/consistencygroup/delete/create.rs | 122 +++++ .../block_storage/v3/consistencygroup/list.rs | 103 ++++ .../block_storage/v3/consistencygroup/set.rs | 138 ++++++ .../block_storage/v3/consistencygroup/show.rs | 113 +++++ .../v3/manageable_snapshot/create.rs | 313 ++++++++++++ .../v3/manageable_snapshot/get.rs | 156 ++++++ .../v3/manageable_snapshot/list.rs | 164 +++++++ .../v3/manageable_volume/create.rs | 458 ++++++++++++++++++ .../block_storage/v3/manageable_volume/get.rs | 156 ++++++ .../v3/manageable_volume/list.rs | 164 +++++++ .../block_storage/v3/quota_class_set/set.rs | 120 +++++ .../block_storage/v3/quota_class_set/show.rs | 113 +++++ .../block_storage/v3/quota_set/default/get.rs | 113 +++++ .../src/block_storage/v3/quota_set/delete.rs | 102 ++++ .../src/block_storage/v3/quota_set/set.rs | 125 +++++ .../src/block_storage/v3/quota_set/show.rs | 116 +++++ .../v3/scheduler_stat/get_pool/get.rs | 103 ++++ .../src/block_storage/v3/service/list.rs | 105 ++++ .../src/block_storage/v3/service/set.rs | 126 +++++ .../src/block_storage/v3/version/get.rs | 104 ++++ .../v3/worker/cleanup/create_324.rs | 179 +++++++ .../v3/capability/show_autogen.rs | 32 ++ .../v3/cgsnapshot/create_autogen.rs | 32 ++ .../v3/cgsnapshot/delete_autogen.rs | 32 ++ .../v3/cgsnapshot/list_autogen.rs | 32 ++ .../v3/cgsnapshot/show_autogen.rs | 32 ++ .../v3/consistencygroup/create_autogen.rs | 32 ++ .../create_from_src/create_autogen.rs | 33 ++ .../consistencygroup/delete/create_autogen.rs | 33 ++ .../v3/consistencygroup/delete_autogen.rs | 32 ++ .../v3/consistencygroup/list_autogen.rs | 32 ++ .../v3/consistencygroup/set_autogen.rs | 32 ++ .../v3/consistencygroup/show_autogen.rs | 32 ++ .../v3/manageable_snapshot/create_autogen.rs | 32 ++ .../v3/manageable_snapshot/get_autogen.rs | 32 ++ .../v3/manageable_snapshot/list_autogen.rs | 32 ++ .../v3/manageable_volume/create_autogen.rs | 32 ++ .../v3/manageable_volume/get_autogen.rs | 32 ++ .../v3/manageable_volume/list_autogen.rs | 32 ++ .../v3/quota_class_set/set_autogen.rs | 32 ++ .../v3/quota_class_set/show_autogen.rs | 32 ++ .../v3/quota_set/default/get_autogen.rs | 33 ++ .../v3/quota_set/delete_autogen.rs | 32 ++ .../block_storage/v3/quota_set/set_autogen.rs | 32 ++ .../v3/quota_set/show_autogen.rs | 32 ++ .../v3/scheduler_stat/get_pool/get_autogen.rs | 33 ++ .../block_storage/v3/service/list_autogen.rs | 32 ++ .../block_storage/v3/service/set_autogen.rs | 32 ++ .../block_storage/v3/version/get_autogen.rs | 32 ++ .../v3/worker/cleanup/create_324_autogen.rs | 33 ++ openstack_sdk/src/api/block_storage/v3.rs | 14 + .../src/api/block_storage/v3/capability.rs | 19 + .../api/block_storage/v3/capability/get.rs | 174 +++++++ .../src/api/block_storage/v3/cgsnapshot.rs | 23 + .../api/block_storage/v3/cgsnapshot/create.rs | 194 ++++++++ .../api/block_storage/v3/cgsnapshot/delete.rs | 174 +++++++ .../api/block_storage/v3/cgsnapshot/get.rs | 174 +++++++ .../api/block_storage/v3/cgsnapshot/list.rs | 166 +++++++ .../v3/cgsnapshot/list_detailed.rs | 166 +++++++ .../api/block_storage/v3/consistencygroup.rs | 25 + .../v3/consistencygroup/create.rs | 194 ++++++++ .../v3/consistencygroup/create_from_src.rs | 19 + .../create_from_src/create.rs | 197 ++++++++ .../v3/consistencygroup/delete.rs | 19 + .../v3/consistencygroup/delete/create.rs | 201 ++++++++ .../block_storage/v3/consistencygroup/get.rs | 174 +++++++ .../block_storage/v3/consistencygroup/list.rs | 166 +++++++ .../v3/consistencygroup/list_detailed.rs | 166 +++++++ .../block_storage/v3/consistencygroup/set.rs | 217 +++++++++ .../block_storage/v3/manageable_snapshot.rs | 21 + .../v3/manageable_snapshot/create.rs | 326 +++++++++++++ .../v3/manageable_snapshot/get.rs | 221 +++++++++ .../v3/manageable_snapshot/list_detailed.rs | 221 +++++++++ .../api/block_storage/v3/manageable_volume.rs | 21 + .../v3/manageable_volume/create.rs | 332 +++++++++++++ .../block_storage/v3/manageable_volume/get.rs | 221 +++++++++ .../v3/manageable_volume/list_detailed.rs | 221 +++++++++ .../api/block_storage/v3/quota_class_set.rs | 20 + .../block_storage/v3/quota_class_set/get.rs | 172 +++++++ .../block_storage/v3/quota_class_set/set.rs | 213 ++++++++ .../src/api/block_storage/v3/quota_set.rs | 22 + .../api/block_storage/v3/quota_set/default.rs | 19 + .../block_storage/v3/quota_set/default/get.rs | 172 +++++++ .../api/block_storage/v3/quota_set/delete.rs | 177 +++++++ .../src/api/block_storage/v3/quota_set/get.rs | 177 +++++++ .../src/api/block_storage/v3/quota_set/set.rs | 217 +++++++++ .../api/block_storage/v3/scheduler_stat.rs | 19 + .../v3/scheduler_stat/get_pool.rs | 19 + .../v3/scheduler_stat/get_pool/get.rs | 166 +++++++ .../src/api/block_storage/v3/service.rs | 20 + .../src/api/block_storage/v3/service/list.rs | 168 +++++++ .../src/api/block_storage/v3/service/set.rs | 205 ++++++++ .../src/api/block_storage/v3/version.rs | 19 + .../src/api/block_storage/v3/version/get.rs | 165 +++++++ .../src/api/block_storage/v3/worker.rs | 19 + .../api/block_storage/v3/worker/cleanup.rs | 19 + .../v3/worker/cleanup/create_324.rs | 233 +++++++++ 105 files changed, 11299 insertions(+) create mode 100644 openstack_cli/src/block_storage/v3/capability/show.rs create mode 100644 openstack_cli/src/block_storage/v3/cgsnapshot/create.rs create mode 100644 openstack_cli/src/block_storage/v3/cgsnapshot/delete.rs create mode 100644 openstack_cli/src/block_storage/v3/cgsnapshot/list.rs create mode 100644 openstack_cli/src/block_storage/v3/cgsnapshot/show.rs create mode 100644 openstack_cli/src/block_storage/v3/consistencygroup/create.rs create mode 100644 openstack_cli/src/block_storage/v3/consistencygroup/create_from_src/create.rs create mode 100644 openstack_cli/src/block_storage/v3/consistencygroup/delete.rs create mode 100644 openstack_cli/src/block_storage/v3/consistencygroup/delete/create.rs create mode 100644 openstack_cli/src/block_storage/v3/consistencygroup/list.rs create mode 100644 openstack_cli/src/block_storage/v3/consistencygroup/set.rs create mode 100644 openstack_cli/src/block_storage/v3/consistencygroup/show.rs create mode 100644 openstack_cli/src/block_storage/v3/manageable_snapshot/create.rs create mode 100644 openstack_cli/src/block_storage/v3/manageable_snapshot/get.rs create mode 100644 openstack_cli/src/block_storage/v3/manageable_snapshot/list.rs create mode 100644 openstack_cli/src/block_storage/v3/manageable_volume/create.rs create mode 100644 openstack_cli/src/block_storage/v3/manageable_volume/get.rs create mode 100644 openstack_cli/src/block_storage/v3/manageable_volume/list.rs create mode 100644 openstack_cli/src/block_storage/v3/quota_class_set/set.rs create mode 100644 openstack_cli/src/block_storage/v3/quota_class_set/show.rs create mode 100644 openstack_cli/src/block_storage/v3/quota_set/default/get.rs create mode 100644 openstack_cli/src/block_storage/v3/quota_set/delete.rs create mode 100644 openstack_cli/src/block_storage/v3/quota_set/set.rs create mode 100644 openstack_cli/src/block_storage/v3/quota_set/show.rs create mode 100644 openstack_cli/src/block_storage/v3/scheduler_stat/get_pool/get.rs create mode 100644 openstack_cli/src/block_storage/v3/service/list.rs create mode 100644 openstack_cli/src/block_storage/v3/service/set.rs create mode 100644 openstack_cli/src/block_storage/v3/version/get.rs create mode 100644 openstack_cli/src/block_storage/v3/worker/cleanup/create_324.rs create mode 100644 openstack_cli/tests/block_storage/v3/capability/show_autogen.rs create mode 100644 openstack_cli/tests/block_storage/v3/cgsnapshot/create_autogen.rs create mode 100644 openstack_cli/tests/block_storage/v3/cgsnapshot/delete_autogen.rs create mode 100644 openstack_cli/tests/block_storage/v3/cgsnapshot/list_autogen.rs create mode 100644 openstack_cli/tests/block_storage/v3/cgsnapshot/show_autogen.rs create mode 100644 openstack_cli/tests/block_storage/v3/consistencygroup/create_autogen.rs create mode 100644 openstack_cli/tests/block_storage/v3/consistencygroup/create_from_src/create_autogen.rs create mode 100644 openstack_cli/tests/block_storage/v3/consistencygroup/delete/create_autogen.rs create mode 100644 openstack_cli/tests/block_storage/v3/consistencygroup/delete_autogen.rs create mode 100644 openstack_cli/tests/block_storage/v3/consistencygroup/list_autogen.rs create mode 100644 openstack_cli/tests/block_storage/v3/consistencygroup/set_autogen.rs create mode 100644 openstack_cli/tests/block_storage/v3/consistencygroup/show_autogen.rs create mode 100644 openstack_cli/tests/block_storage/v3/manageable_snapshot/create_autogen.rs create mode 100644 openstack_cli/tests/block_storage/v3/manageable_snapshot/get_autogen.rs create mode 100644 openstack_cli/tests/block_storage/v3/manageable_snapshot/list_autogen.rs create mode 100644 openstack_cli/tests/block_storage/v3/manageable_volume/create_autogen.rs create mode 100644 openstack_cli/tests/block_storage/v3/manageable_volume/get_autogen.rs create mode 100644 openstack_cli/tests/block_storage/v3/manageable_volume/list_autogen.rs create mode 100644 openstack_cli/tests/block_storage/v3/quota_class_set/set_autogen.rs create mode 100644 openstack_cli/tests/block_storage/v3/quota_class_set/show_autogen.rs create mode 100644 openstack_cli/tests/block_storage/v3/quota_set/default/get_autogen.rs create mode 100644 openstack_cli/tests/block_storage/v3/quota_set/delete_autogen.rs create mode 100644 openstack_cli/tests/block_storage/v3/quota_set/set_autogen.rs create mode 100644 openstack_cli/tests/block_storage/v3/quota_set/show_autogen.rs create mode 100644 openstack_cli/tests/block_storage/v3/scheduler_stat/get_pool/get_autogen.rs create mode 100644 openstack_cli/tests/block_storage/v3/service/list_autogen.rs create mode 100644 openstack_cli/tests/block_storage/v3/service/set_autogen.rs create mode 100644 openstack_cli/tests/block_storage/v3/version/get_autogen.rs create mode 100644 openstack_cli/tests/block_storage/v3/worker/cleanup/create_324_autogen.rs create mode 100644 openstack_sdk/src/api/block_storage/v3/capability.rs create mode 100644 openstack_sdk/src/api/block_storage/v3/capability/get.rs create mode 100644 openstack_sdk/src/api/block_storage/v3/cgsnapshot.rs create mode 100644 openstack_sdk/src/api/block_storage/v3/cgsnapshot/create.rs create mode 100644 openstack_sdk/src/api/block_storage/v3/cgsnapshot/delete.rs create mode 100644 openstack_sdk/src/api/block_storage/v3/cgsnapshot/get.rs create mode 100644 openstack_sdk/src/api/block_storage/v3/cgsnapshot/list.rs create mode 100644 openstack_sdk/src/api/block_storage/v3/cgsnapshot/list_detailed.rs create mode 100644 openstack_sdk/src/api/block_storage/v3/consistencygroup.rs create mode 100644 openstack_sdk/src/api/block_storage/v3/consistencygroup/create.rs create mode 100644 openstack_sdk/src/api/block_storage/v3/consistencygroup/create_from_src.rs create mode 100644 openstack_sdk/src/api/block_storage/v3/consistencygroup/create_from_src/create.rs create mode 100644 openstack_sdk/src/api/block_storage/v3/consistencygroup/delete.rs create mode 100644 openstack_sdk/src/api/block_storage/v3/consistencygroup/delete/create.rs create mode 100644 openstack_sdk/src/api/block_storage/v3/consistencygroup/get.rs create mode 100644 openstack_sdk/src/api/block_storage/v3/consistencygroup/list.rs create mode 100644 openstack_sdk/src/api/block_storage/v3/consistencygroup/list_detailed.rs create mode 100644 openstack_sdk/src/api/block_storage/v3/consistencygroup/set.rs create mode 100644 openstack_sdk/src/api/block_storage/v3/manageable_snapshot.rs create mode 100644 openstack_sdk/src/api/block_storage/v3/manageable_snapshot/create.rs create mode 100644 openstack_sdk/src/api/block_storage/v3/manageable_snapshot/get.rs create mode 100644 openstack_sdk/src/api/block_storage/v3/manageable_snapshot/list_detailed.rs create mode 100644 openstack_sdk/src/api/block_storage/v3/manageable_volume.rs create mode 100644 openstack_sdk/src/api/block_storage/v3/manageable_volume/create.rs create mode 100644 openstack_sdk/src/api/block_storage/v3/manageable_volume/get.rs create mode 100644 openstack_sdk/src/api/block_storage/v3/manageable_volume/list_detailed.rs create mode 100644 openstack_sdk/src/api/block_storage/v3/quota_class_set.rs create mode 100644 openstack_sdk/src/api/block_storage/v3/quota_class_set/get.rs create mode 100644 openstack_sdk/src/api/block_storage/v3/quota_class_set/set.rs create mode 100644 openstack_sdk/src/api/block_storage/v3/quota_set.rs create mode 100644 openstack_sdk/src/api/block_storage/v3/quota_set/default.rs create mode 100644 openstack_sdk/src/api/block_storage/v3/quota_set/default/get.rs create mode 100644 openstack_sdk/src/api/block_storage/v3/quota_set/delete.rs create mode 100644 openstack_sdk/src/api/block_storage/v3/quota_set/get.rs create mode 100644 openstack_sdk/src/api/block_storage/v3/quota_set/set.rs create mode 100644 openstack_sdk/src/api/block_storage/v3/scheduler_stat.rs create mode 100644 openstack_sdk/src/api/block_storage/v3/scheduler_stat/get_pool.rs create mode 100644 openstack_sdk/src/api/block_storage/v3/scheduler_stat/get_pool/get.rs create mode 100644 openstack_sdk/src/api/block_storage/v3/service.rs create mode 100644 openstack_sdk/src/api/block_storage/v3/service/list.rs create mode 100644 openstack_sdk/src/api/block_storage/v3/service/set.rs create mode 100644 openstack_sdk/src/api/block_storage/v3/version.rs create mode 100644 openstack_sdk/src/api/block_storage/v3/version/get.rs create mode 100644 openstack_sdk/src/api/block_storage/v3/worker.rs create mode 100644 openstack_sdk/src/api/block_storage/v3/worker/cleanup.rs create mode 100644 openstack_sdk/src/api/block_storage/v3/worker/cleanup/create_324.rs diff --git a/openstack_cli/src/block_storage/v3/capability/show.rs b/openstack_cli/src/block_storage/v3/capability/show.rs new file mode 100644 index 000000000..b80c77750 --- /dev/null +++ b/openstack_cli/src/block_storage/v3/capability/show.rs @@ -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); + +impl StructTable for ResponseData { + fn build(&self, _options: &OutputConfig) -> (Vec, Vec>) { + let headers: Vec = Vec::from(["Name".to_string(), "Value".to_string()]); + let mut rows: Vec> = 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::(data)?; + Ok(()) + } +} diff --git a/openstack_cli/src/block_storage/v3/cgsnapshot/create.rs b/openstack_cli/src/block_storage/v3/cgsnapshot/create.rs new file mode 100644 index 000000000..561637238 --- /dev/null +++ b/openstack_cli/src/block_storage/v3/cgsnapshot/create.rs @@ -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::)] + #[arg(help_heading = "Body parameters")] + properties: Option>, +} + +/// Query parameters +#[derive(Args)] +struct QueryParameters {} + +/// Path parameters +#[derive(Args)] +struct PathParameters {} +/// Response data as HashMap type +#[derive(Deserialize, Serialize)] +struct ResponseData(HashMap); + +impl StructTable for ResponseData { + fn build(&self, _options: &OutputConfig) -> (Vec, Vec>) { + let headers: Vec = Vec::from(["Name".to_string(), "Value".to_string()]); + let mut rows: Vec> = 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::(data)?; + Ok(()) + } +} diff --git a/openstack_cli/src/block_storage/v3/cgsnapshot/delete.rs b/openstack_cli/src/block_storage/v3/cgsnapshot/delete.rs new file mode 100644 index 000000000..e79607b01 --- /dev/null +++ b/openstack_cli/src/block_storage/v3/cgsnapshot/delete.rs @@ -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 = ep.raw_query_async(client).await?; + Ok(()) + } +} diff --git a/openstack_cli/src/block_storage/v3/cgsnapshot/list.rs b/openstack_cli/src/block_storage/v3/cgsnapshot/list.rs new file mode 100644 index 000000000..83a4a5882 --- /dev/null +++ b/openstack_cli/src/block_storage/v3/cgsnapshot/list.rs @@ -0,0 +1,103 @@ +// 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 Cgsnapshots command +//! +//! Wraps invoking of the `v3/cgsnapshots/detail` 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::cgsnapshot::list_detailed; +use openstack_sdk::api::QueryAsync; +use serde_json::Value; +use std::collections::HashMap; + +/// Returns a detailed list of cgsnapshots. +/// +#[derive(Args)] +pub struct CgsnapshotsCommand { + /// 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 {} +/// Response data as HashMap type +#[derive(Deserialize, Serialize)] +struct ResponseData(HashMap); + +impl StructTable for ResponseData { + fn build(&self, _options: &OutputConfig) -> (Vec, Vec>) { + let headers: Vec = Vec::from(["Name".to_string(), "Value".to_string()]); + let mut rows: Vec> = 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 CgsnapshotsCommand { + /// Perform command action + pub async fn take_action( + &self, + parsed_args: &Cli, + client: &mut AsyncOpenStack, + ) -> Result<(), OpenStackCliError> { + info!("List Cgsnapshots"); + + let op = OutputProcessor::from_args(parsed_args); + op.validate_args(parsed_args)?; + + let ep_builder = list_detailed::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 = ep.query_async(client).await?; + op.output_single::(data)?; + Ok(()) + } +} diff --git a/openstack_cli/src/block_storage/v3/cgsnapshot/show.rs b/openstack_cli/src/block_storage/v3/cgsnapshot/show.rs new file mode 100644 index 000000000..29aeb08f1 --- /dev/null +++ b/openstack_cli/src/block_storage/v3/cgsnapshot/show.rs @@ -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 Cgsnapshot command +//! +//! Wraps invoking of the `v3/cgsnapshots/{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::cgsnapshot::get; +use openstack_sdk::api::QueryAsync; +use serde_json::Value; +use std::collections::HashMap; + +/// Return data about the given 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, +} +/// Response data as HashMap type +#[derive(Deserialize, Serialize)] +struct ResponseData(HashMap); + +impl StructTable for ResponseData { + fn build(&self, _options: &OutputConfig) -> (Vec, Vec>) { + let headers: Vec = Vec::from(["Name".to_string(), "Value".to_string()]); + let mut rows: Vec> = 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!("Show Cgsnapshot"); + + 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::(data)?; + Ok(()) + } +} diff --git a/openstack_cli/src/block_storage/v3/consistencygroup/create.rs b/openstack_cli/src/block_storage/v3/consistencygroup/create.rs new file mode 100644 index 000000000..05afc2ceb --- /dev/null +++ b/openstack_cli/src/block_storage/v3/consistencygroup/create.rs @@ -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 Consistencygroup command +//! +//! Wraps invoking of the `v3/consistencygroups` 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::consistencygroup::create; +use openstack_sdk::api::QueryAsync; +use serde_json::Value; +use std::collections::HashMap; + +/// Create a new consistency group. +/// +#[derive(Args)] +pub struct ConsistencygroupCommand { + /// 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::)] + #[arg(help_heading = "Body parameters")] + properties: Option>, +} + +/// Query parameters +#[derive(Args)] +struct QueryParameters {} + +/// Path parameters +#[derive(Args)] +struct PathParameters {} +/// Response data as HashMap type +#[derive(Deserialize, Serialize)] +struct ResponseData(HashMap); + +impl StructTable for ResponseData { + fn build(&self, _options: &OutputConfig) -> (Vec, Vec>) { + let headers: Vec = Vec::from(["Name".to_string(), "Value".to_string()]); + let mut rows: Vec> = 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 ConsistencygroupCommand { + /// Perform command action + pub async fn take_action( + &self, + parsed_args: &Cli, + client: &mut AsyncOpenStack, + ) -> Result<(), OpenStackCliError> { + info!("Create Consistencygroup"); + + 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::(data)?; + Ok(()) + } +} diff --git a/openstack_cli/src/block_storage/v3/consistencygroup/create_from_src/create.rs b/openstack_cli/src/block_storage/v3/consistencygroup/create_from_src/create.rs new file mode 100644 index 000000000..e036a9fa8 --- /dev/null +++ b/openstack_cli/src/block_storage/v3/consistencygroup/create_from_src/create.rs @@ -0,0 +1,115 @@ +// 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 CreateFromSrc command +//! +//! Wraps invoking of the `v3/consistencygroups/create_from_src` 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::consistencygroup::create_from_src::create; +use openstack_sdk::api::QueryAsync; +use serde_json::Value; +use std::collections::HashMap; + +/// Create a new consistency group from a source. +/// +/// The source can be a CG snapshot or a CG. Note that this does not require +/// volume_types as the "create" API above. +/// +#[derive(Args)] +pub struct CreateFromSrcCommand { + /// 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::)] + #[arg(help_heading = "Body parameters")] + properties: Option>, +} + +/// Query parameters +#[derive(Args)] +struct QueryParameters {} + +/// Path parameters +#[derive(Args)] +struct PathParameters {} +/// Response data as HashMap type +#[derive(Deserialize, Serialize)] +struct ResponseData(HashMap); + +impl StructTable for ResponseData { + fn build(&self, _options: &OutputConfig) -> (Vec, Vec>) { + let headers: Vec = Vec::from(["Name".to_string(), "Value".to_string()]); + let mut rows: Vec> = 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 CreateFromSrcCommand { + /// Perform command action + pub async fn take_action( + &self, + parsed_args: &Cli, + client: &mut AsyncOpenStack, + ) -> Result<(), OpenStackCliError> { + info!("Create CreateFromSrc"); + + 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::(data)?; + Ok(()) + } +} diff --git a/openstack_cli/src/block_storage/v3/consistencygroup/delete.rs b/openstack_cli/src/block_storage/v3/consistencygroup/delete.rs new file mode 100644 index 000000000..aa8fd5c6f --- /dev/null +++ b/openstack_cli/src/block_storage/v3/consistencygroup/delete.rs @@ -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 Consistencygroup command +//! +//! Wraps invoking of the `v3/consistencygroups/{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::consistencygroup::delete; +use openstack_sdk::api::RawQueryAsync; +use structable_derive::StructTable; + +/// Delete a consistency group. +/// +#[derive(Args)] +pub struct ConsistencygroupCommand { + /// 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/consistencygroups/{id} API + /// + #[arg( + help_heading = "Path parameters", + id = "path_param_id", + value_name = "ID" + )] + id: String, +} +/// Consistencygroup response representation +#[derive(Deserialize, Serialize, Clone, StructTable)] +struct ResponseData {} + +impl ConsistencygroupCommand { + /// Perform command action + pub async fn take_action( + &self, + parsed_args: &Cli, + client: &mut AsyncOpenStack, + ) -> Result<(), OpenStackCliError> { + info!("Delete Consistencygroup"); + + 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 = ep.raw_query_async(client).await?; + Ok(()) + } +} diff --git a/openstack_cli/src/block_storage/v3/consistencygroup/delete/create.rs b/openstack_cli/src/block_storage/v3/consistencygroup/delete/create.rs new file mode 100644 index 000000000..8b1c80fd5 --- /dev/null +++ b/openstack_cli/src/block_storage/v3/consistencygroup/delete/create.rs @@ -0,0 +1,122 @@ +// 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 Delete command +//! +//! Wraps invoking of the `v3/consistencygroups/{id}/delete` 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::consistencygroup::delete::create; +use openstack_sdk::api::QueryAsync; +use serde_json::Value; +use std::collections::HashMap; + +/// Delete a consistency group. +/// +#[derive(Args)] +pub struct DeleteCommand { + /// 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::)] + #[arg(help_heading = "Body parameters")] + properties: Option>, +} + +/// Query parameters +#[derive(Args)] +struct QueryParameters {} + +/// Path parameters +#[derive(Args)] +struct PathParameters { + /// id parameter for /v3/consistencygroups/{id}/delete 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); + +impl StructTable for ResponseData { + fn build(&self, _options: &OutputConfig) -> (Vec, Vec>) { + let headers: Vec = Vec::from(["Name".to_string(), "Value".to_string()]); + let mut rows: Vec> = 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 DeleteCommand { + /// Perform command action + pub async fn take_action( + &self, + parsed_args: &Cli, + client: &mut AsyncOpenStack, + ) -> Result<(), OpenStackCliError> { + info!("Create Delete"); + + let op = OutputProcessor::from_args(parsed_args); + op.validate_args(parsed_args)?; + + let mut ep_builder = create::Request::builder(); + + // Set path parameters + ep_builder.id(&self.path.id); + // 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::(data)?; + Ok(()) + } +} diff --git a/openstack_cli/src/block_storage/v3/consistencygroup/list.rs b/openstack_cli/src/block_storage/v3/consistencygroup/list.rs new file mode 100644 index 000000000..53cfd37a7 --- /dev/null +++ b/openstack_cli/src/block_storage/v3/consistencygroup/list.rs @@ -0,0 +1,103 @@ +// 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 Consistencygroups command +//! +//! Wraps invoking of the `v3/consistencygroups/detail` 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::consistencygroup::list_detailed; +use openstack_sdk::api::QueryAsync; +use serde_json::Value; +use std::collections::HashMap; + +/// Returns a detailed list of consistency groups. +/// +#[derive(Args)] +pub struct ConsistencygroupsCommand { + /// 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 {} +/// Response data as HashMap type +#[derive(Deserialize, Serialize)] +struct ResponseData(HashMap); + +impl StructTable for ResponseData { + fn build(&self, _options: &OutputConfig) -> (Vec, Vec>) { + let headers: Vec = Vec::from(["Name".to_string(), "Value".to_string()]); + let mut rows: Vec> = 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 ConsistencygroupsCommand { + /// Perform command action + pub async fn take_action( + &self, + parsed_args: &Cli, + client: &mut AsyncOpenStack, + ) -> Result<(), OpenStackCliError> { + info!("List Consistencygroups"); + + let op = OutputProcessor::from_args(parsed_args); + op.validate_args(parsed_args)?; + + let ep_builder = list_detailed::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 = ep.query_async(client).await?; + op.output_single::(data)?; + Ok(()) + } +} diff --git a/openstack_cli/src/block_storage/v3/consistencygroup/set.rs b/openstack_cli/src/block_storage/v3/consistencygroup/set.rs new file mode 100644 index 000000000..22cca15e7 --- /dev/null +++ b/openstack_cli/src/block_storage/v3/consistencygroup/set.rs @@ -0,0 +1,138 @@ +// 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`. + +//! Set Consistencygroup command +//! +//! Wraps invoking of the `v3/consistencygroups/{id}/update` with `PUT` 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::consistencygroup::set; +use openstack_sdk::api::QueryAsync; +use serde_json::Value; +use std::collections::HashMap; + +/// Update the consistency group. +/// +/// Expected format of the input parameter 'body': +/// +/// ```text +/// +/// { +/// "consistencygroup": +/// { +/// "name": "my_cg", +/// "description": "My consistency group", +/// "add_volumes": "volume-uuid-1,volume-uuid-2,...", +/// "remove_volumes": "volume-uuid-8,volume-uuid-9,..." +/// } +/// } +/// +/// ``` +/// +#[derive(Args)] +pub struct ConsistencygroupCommand { + /// 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::)] + #[arg(help_heading = "Body parameters")] + properties: Option>, +} + +/// Query parameters +#[derive(Args)] +struct QueryParameters {} + +/// Path parameters +#[derive(Args)] +struct PathParameters { + /// id parameter for /v3/consistencygroups/{id}/update 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); + +impl StructTable for ResponseData { + fn build(&self, _options: &OutputConfig) -> (Vec, Vec>) { + let headers: Vec = Vec::from(["Name".to_string(), "Value".to_string()]); + let mut rows: Vec> = 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 ConsistencygroupCommand { + /// Perform command action + pub async fn take_action( + &self, + parsed_args: &Cli, + client: &mut AsyncOpenStack, + ) -> Result<(), OpenStackCliError> { + info!("Set Consistencygroup"); + + let op = OutputProcessor::from_args(parsed_args); + op.validate_args(parsed_args)?; + + let mut ep_builder = set::Request::builder(); + + // Set path parameters + ep_builder.id(&self.path.id); + // 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::(data)?; + Ok(()) + } +} diff --git a/openstack_cli/src/block_storage/v3/consistencygroup/show.rs b/openstack_cli/src/block_storage/v3/consistencygroup/show.rs new file mode 100644 index 000000000..16d8e1816 --- /dev/null +++ b/openstack_cli/src/block_storage/v3/consistencygroup/show.rs @@ -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 Consistencygroup command +//! +//! Wraps invoking of the `v3/consistencygroups/{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::consistencygroup::get; +use openstack_sdk::api::QueryAsync; +use serde_json::Value; +use std::collections::HashMap; + +/// Return data about the given consistency group. +/// +#[derive(Args)] +pub struct ConsistencygroupCommand { + /// 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/consistencygroups/{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); + +impl StructTable for ResponseData { + fn build(&self, _options: &OutputConfig) -> (Vec, Vec>) { + let headers: Vec = Vec::from(["Name".to_string(), "Value".to_string()]); + let mut rows: Vec> = 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 ConsistencygroupCommand { + /// Perform command action + pub async fn take_action( + &self, + parsed_args: &Cli, + client: &mut AsyncOpenStack, + ) -> Result<(), OpenStackCliError> { + info!("Show Consistencygroup"); + + 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::(data)?; + Ok(()) + } +} diff --git a/openstack_cli/src/block_storage/v3/manageable_snapshot/create.rs b/openstack_cli/src/block_storage/v3/manageable_snapshot/create.rs new file mode 100644 index 000000000..90dd39460 --- /dev/null +++ b/openstack_cli/src/block_storage/v3/manageable_snapshot/create.rs @@ -0,0 +1,313 @@ +// 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 ManageableSnapshot command +//! +//! Wraps invoking of the `v3/manageable_snapshots` 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::manageable_snapshot::create; +use openstack_sdk::api::QueryAsync; +use serde_json::Value; +use structable_derive::StructTable; + +/// Instruct Cinder to manage a storage snapshot object. +/// +/// Manages an existing backend storage snapshot object (e.g. a Linux logical +/// volume or a SAN disk) by creating the Cinder objects required to manage it, +/// and possibly renaming the backend storage snapshot object (driver +/// dependent). +/// +/// From an API perspective, this operation behaves very much like a snapshot +/// creation operation. +/// +/// Required HTTP Body: +/// +/// ```text +/// +/// { +/// "snapshot": +/// { +/// "volume_id": "", +/// "ref": +/// "" +/// } +/// } +/// +/// ``` +/// +/// See the appropriate Cinder drivers' implementations of the manage_snapshot +/// method to find out the accepted format of 'ref'. For example,in LVM driver, +/// it will be the logic volume name of snapshot which you want to manage. +/// +/// This API call will return with an error if any of the above elements are +/// missing from the request, or if the 'volume_id' element refers to a cinder +/// volume that could not be found. +/// +/// The snapshot will later enter the error state if it is discovered that +/// 'ref' is bad. +/// +/// Optional elements to 'snapshot' are: +/// +/// ```text +/// +/// name A name for the new snapshot. +/// description A description for the new snapshot. +/// metadata Key/value pairs to be associated with the new snapshot. +/// +/// ``` +/// +#[derive(Args)] +pub struct ManageableSnapshotCommand { + /// Request Query parameters + #[command(flatten)] + query: QueryParameters, + + /// Path parameters + #[command(flatten)] + path: PathParameters, + + /// A `snapshot` object. + /// + #[command(flatten)] + snapshot: Snapshot, +} + +/// Query parameters +#[derive(Args)] +struct QueryParameters {} + +/// Path parameters +#[derive(Args)] +struct PathParameters {} +/// Snapshot Body data +#[derive(Args, Clone)] +struct Snapshot { + /// A description for the snapshot. Default is `None`. + /// + #[arg(help_heading = "Body parameters", long)] + description: Option, + + /// One or more metadata key and value pairs for the snapshot. + /// + #[arg(help_heading = "Body parameters", long, value_name="key=value", value_parser=parse_key_val::)] + metadata: Option>, + + /// The name of the snapshot. Default is `None`. + /// + #[arg(help_heading = "Body parameters", long)] + name: Option, + + /// A reference to the existing volume. The internal structure of this + /// reference depends on the volume driver implementation. For details + /// about the required elements in the structure, see the documentation for + /// the volume driver. + /// + #[arg(help_heading = "Body parameters", long, value_name="JSON", value_parser=parse_json)] + _ref: Option, + + /// The UUID of the volume. + /// + #[arg(help_heading = "Body parameters", long)] + volume_id: String, +} + +/// ManageableSnapshot response representation +#[derive(Deserialize, Serialize, Clone, StructTable)] +struct ResponseData { + /// Whether this resource consumes quota or not. Resources that not counted + /// for quota usage are usually temporary internal resources created to + /// perform an operation. + /// + /// **New in version 3.65** + /// + #[serde()] + #[structable(optional)] + consumes_quota: Option, + + /// The total count of requested resource before pagination is applied. + /// + #[serde()] + #[structable(optional)] + count: Option, + + /// The date and time when the resource was created. + /// + /// The date and time stamp format is + /// [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601): + /// + /// ```text + /// CCYY-MM-DDThh:mm:ss±hh:mm + /// + /// ``` + /// + /// For example, `2015-08-27T09:49:58-05:00`. + /// + /// The `±hh:mm` value, if included, is the time zone as an offset from + /// UTC. + /// + #[serde()] + #[structable(optional)] + created_at: Option, + + /// A description for the snapshot. + /// + #[serde()] + #[structable(optional)] + description: Option, + + /// The ID of the group snapshot. + /// + /// **New in version 3.14** + /// + #[serde()] + #[structable(optional)] + group_snapshot_id: Option, + + /// The UUID of the object. + /// + #[serde()] + #[structable(optional)] + id: Option, + + /// One or more metadata key and value pairs for the snapshot. + /// + #[serde()] + #[structable(optional, pretty)] + metadata: Option, + + /// The name of the snapshot. Default is `None`. + /// + #[serde()] + #[structable(optional)] + name: Option, + + /// A percentage value for the build progress. + /// + #[serde(rename = "os-extended-snapshot-attributes:progress")] + #[structable(optional, title = "os-extended-snapshot-attributes:progress")] + os_extended_snapshot_attributes_progress: Option, + + /// The UUID of the owning project. + /// + #[serde(rename = "os-extended-snapshot-attributes:project_id")] + #[structable(optional, title = "os-extended-snapshot-attributes:project_id")] + os_extended_snapshot_attributes_project_id: Option, + + /// The size of the volume, in gibibytes (GiB). + /// + #[serde()] + #[structable(optional)] + size: Option, + + /// The status for the snapshot. + /// + #[serde()] + #[structable(optional)] + status: Option, + + /// The date and time when the resource was updated. + /// + /// The date and time stamp format is + /// [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601): + /// + /// ```text + /// CCYY-MM-DDThh:mm:ss±hh:mm + /// + /// ``` + /// + /// For example, `2015-08-27T09:49:58-05:00`. + /// + /// The `±hh:mm` value, if included, is the time zone as an offset from + /// UTC. In the previous example, the offset value is `-05:00`. + /// + /// If the `updated_at` date and time stamp is not set, its value is + /// `null`. + /// + #[serde()] + #[structable(optional)] + updated_at: Option, + + /// The UUID of the volume. + /// + #[serde()] + #[structable(optional)] + volume_id: Option, +} + +impl ManageableSnapshotCommand { + /// Perform command action + pub async fn take_action( + &self, + parsed_args: &Cli, + client: &mut AsyncOpenStack, + ) -> Result<(), OpenStackCliError> { + info!("Create ManageableSnapshot"); + + 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 + // Set Request.snapshot data + let args = &self.snapshot; + let mut snapshot_builder = create::SnapshotBuilder::default(); + if let Some(val) = &args.description { + snapshot_builder.description(Some(val.into())); + } + + if let Some(val) = &args.metadata { + snapshot_builder.metadata(val.iter().cloned()); + } + + if let Some(val) = &args.name { + snapshot_builder.name(Some(val.into())); + } + + snapshot_builder.volume_id(&args.volume_id); + + if let Some(val) = &args._ref { + snapshot_builder._ref(val.clone()); + } + + ep_builder.snapshot(snapshot_builder.build().unwrap()); + + let ep = ep_builder + .build() + .map_err(|x| OpenStackCliError::EndpointBuild(x.to_string()))?; + + let data = ep.query_async(client).await?; + op.output_single::(data)?; + Ok(()) + } +} diff --git a/openstack_cli/src/block_storage/v3/manageable_snapshot/get.rs b/openstack_cli/src/block_storage/v3/manageable_snapshot/get.rs new file mode 100644 index 000000000..a5195b57c --- /dev/null +++ b/openstack_cli/src/block_storage/v3/manageable_snapshot/get.rs @@ -0,0 +1,156 @@ +// 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`. + +//! Get ManageableSnapshot command +//! +//! Wraps invoking of the `v3/manageable_snapshots` 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::manageable_snapshot::get; +use openstack_sdk::api::QueryAsync; +use serde_json::Value; +use structable_derive::StructTable; + +/// Returns a summary list of volumes available to manage. +/// +#[derive(Args)] +pub struct ManageableSnapshotCommand { + /// Request Query parameters + #[command(flatten)] + query: QueryParameters, + + /// Path parameters + #[command(flatten)] + path: PathParameters, +} + +/// Query parameters +#[derive(Args)] +struct QueryParameters { + /// Requests a page size of items. Returns a number of items up to a limit + /// value. Use the limit parameter to make an initial limited request and + /// use the ID of the last-seen item from the response as the marker + /// parameter value in a subsequent limited request. + /// + #[arg(help_heading = "Query parameters", long)] + limit: Option, + + /// The ID of the last-seen item. Use the limit parameter to make an + /// initial limited request and use the ID of the last-seen item from the + /// response as the marker parameter value in a subsequent limited request. + /// + #[arg(help_heading = "Query parameters", long)] + marker: Option, + + /// Used in conjunction with limit to return a slice of items. offset is + /// where to start in the list. + /// + #[arg(help_heading = "Query parameters", long)] + offset: Option, + + /// Comma-separated list of sort keys and optional sort directions in the + /// form of \< key > \[: \< direction > \]. A valid direction is asc + /// (ascending) or desc (descending). + /// + #[arg(help_heading = "Query parameters", long)] + sort: Option, + + /// Sorts by one or more sets of attribute and sort direction combinations. + /// If you omit the sort direction in a set, default is desc. Deprecated in + /// favour of the combined sort parameter. + /// + #[arg(help_heading = "Query parameters", long, value_parser = ["asc","desc"])] + sort_dir: Option, + + /// Sorts by an attribute. A valid value is name, status, container_format, + /// disk_format, size, id, created_at, or updated_at. Default is + /// created_at. The API uses the natural sorting direction of the sort_key + /// attribute value. Deprecated in favour of the combined sort parameter. + /// + #[arg(help_heading = "Query parameters", long)] + sort_key: Option, +} + +/// Path parameters +#[derive(Args)] +struct PathParameters {} +/// ManageableSnapshot response representation +#[derive(Deserialize, Serialize, Clone, StructTable)] +struct ResponseData { + /// A list of manageable snapshots. + /// + #[serde(rename = "manageable-snapshots")] + #[structable(pretty, title = "manageable-snapshots")] + manageable_snapshots: Value, +} + +impl ManageableSnapshotCommand { + /// Perform command action + pub async fn take_action( + &self, + parsed_args: &Cli, + client: &mut AsyncOpenStack, + ) -> Result<(), OpenStackCliError> { + info!("Get ManageableSnapshot"); + + let op = OutputProcessor::from_args(parsed_args); + op.validate_args(parsed_args)?; + + let mut ep_builder = get::Request::builder(); + + // Set path parameters + // Set query parameters + if let Some(val) = &self.query.sort { + ep_builder.sort(val); + } + if let Some(val) = &self.query.sort_key { + ep_builder.sort_key(val); + } + if let Some(val) = &self.query.sort_dir { + ep_builder.sort_dir(val); + } + if let Some(val) = &self.query.limit { + ep_builder.limit(*val); + } + if let Some(val) = &self.query.offset { + ep_builder.offset(*val); + } + if let Some(val) = &self.query.marker { + ep_builder.marker(val); + } + // Set body parameters + + let ep = ep_builder + .build() + .map_err(|x| OpenStackCliError::EndpointBuild(x.to_string()))?; + + let data: Vec = ep.query_async(client).await?; + op.output_list::(data)?; + Ok(()) + } +} diff --git a/openstack_cli/src/block_storage/v3/manageable_snapshot/list.rs b/openstack_cli/src/block_storage/v3/manageable_snapshot/list.rs new file mode 100644 index 000000000..a18126550 --- /dev/null +++ b/openstack_cli/src/block_storage/v3/manageable_snapshot/list.rs @@ -0,0 +1,164 @@ +// 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 ManageableSnapshots command +//! +//! Wraps invoking of the `v3/manageable_snapshots/detail` 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::manageable_snapshot::list_detailed; +use openstack_sdk::api::QueryAsync; +use openstack_sdk::api::{paged, Pagination}; +use serde_json::Value; +use structable_derive::StructTable; + +/// Returns a detailed list of volumes available to manage. +/// +#[derive(Args)] +pub struct ManageableSnapshotsCommand { + /// Request Query parameters + #[command(flatten)] + query: QueryParameters, + + /// Path parameters + #[command(flatten)] + path: PathParameters, + + /// Total limit of entities count to return. Use this when there are too many entries. + #[arg(long, default_value_t = 10000)] + max_items: usize, +} + +/// Query parameters +#[derive(Args)] +struct QueryParameters { + /// Requests a page size of items. Returns a number of items up to a limit + /// value. Use the limit parameter to make an initial limited request and + /// use the ID of the last-seen item from the response as the marker + /// parameter value in a subsequent limited request. + /// + #[arg(help_heading = "Query parameters", long)] + limit: Option, + + /// The ID of the last-seen item. Use the limit parameter to make an + /// initial limited request and use the ID of the last-seen item from the + /// response as the marker parameter value in a subsequent limited request. + /// + #[arg(help_heading = "Query parameters", long)] + marker: Option, + + /// Used in conjunction with limit to return a slice of items. offset is + /// where to start in the list. + /// + #[arg(help_heading = "Query parameters", long)] + offset: Option, + + /// Comma-separated list of sort keys and optional sort directions in the + /// form of \< key > \[: \< direction > \]. A valid direction is asc + /// (ascending) or desc (descending). + /// + #[arg(help_heading = "Query parameters", long)] + sort: Option, + + /// Sorts by one or more sets of attribute and sort direction combinations. + /// If you omit the sort direction in a set, default is desc. Deprecated in + /// favour of the combined sort parameter. + /// + #[arg(help_heading = "Query parameters", long, value_parser = ["asc","desc"])] + sort_dir: Option, + + /// Sorts by an attribute. A valid value is name, status, container_format, + /// disk_format, size, id, created_at, or updated_at. Default is + /// created_at. The API uses the natural sorting direction of the sort_key + /// attribute value. Deprecated in favour of the combined sort parameter. + /// + #[arg(help_heading = "Query parameters", long)] + sort_key: Option, +} + +/// Path parameters +#[derive(Args)] +struct PathParameters {} +/// ManageableSnapshots response representation +#[derive(Deserialize, Serialize, Clone, StructTable)] +struct ResponseData { + /// A list of manageable snapshots. + /// + #[serde(rename = "manageable-snapshots")] + #[structable(pretty, title = "manageable-snapshots", wide)] + manageable_snapshots: Value, +} + +impl ManageableSnapshotsCommand { + /// Perform command action + pub async fn take_action( + &self, + parsed_args: &Cli, + client: &mut AsyncOpenStack, + ) -> Result<(), OpenStackCliError> { + info!("List ManageableSnapshots"); + + let op = OutputProcessor::from_args(parsed_args); + op.validate_args(parsed_args)?; + + let mut ep_builder = list_detailed::Request::builder(); + + // Set path parameters + // Set query parameters + if let Some(val) = &self.query.sort { + ep_builder.sort(val); + } + if let Some(val) = &self.query.sort_key { + ep_builder.sort_key(val); + } + if let Some(val) = &self.query.sort_dir { + ep_builder.sort_dir(val); + } + if let Some(val) = &self.query.limit { + ep_builder.limit(*val); + } + if let Some(val) = &self.query.offset { + ep_builder.offset(*val); + } + if let Some(val) = &self.query.marker { + ep_builder.marker(val); + } + // Set body parameters + + let ep = ep_builder + .build() + .map_err(|x| OpenStackCliError::EndpointBuild(x.to_string()))?; + + let data: Vec = paged(ep, Pagination::Limit(self.max_items)) + .query_async(client) + .await?; + + op.output_list::(data)?; + Ok(()) + } +} diff --git a/openstack_cli/src/block_storage/v3/manageable_volume/create.rs b/openstack_cli/src/block_storage/v3/manageable_volume/create.rs new file mode 100644 index 000000000..743ef368c --- /dev/null +++ b/openstack_cli/src/block_storage/v3/manageable_volume/create.rs @@ -0,0 +1,458 @@ +// 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 ManageableVolume command +//! +//! Wraps invoking of the `v3/manageable_volumes` 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::manageable_volume::create; +use openstack_sdk::api::QueryAsync; +use serde_json::Value; +use structable_derive::StructTable; + +/// Instruct Cinder to manage a storage object. +/// +/// Manages an existing backend storage object (e.g. a Linux logical volume or +/// a SAN disk) by creating the Cinder objects required to manage it, and +/// possibly renaming the backend storage object (driver dependent) +/// +/// From an API perspective, this operation behaves very much like a volume +/// creation operation, except that properties such as image, snapshot and +/// volume references don't make sense, because we are taking an existing +/// storage object into Cinder management. +/// +/// Required HTTP Body: +/// +/// ```text +/// +/// { +/// "volume": { +/// "host": "", +/// "cluster": "", +/// "ref": "" +/// } +/// } +/// +/// ``` +/// +/// See the appropriate Cinder drivers' implementations of the manage_volume +/// method to find out the accepted format of 'ref'. +/// +/// This API call will return with an error if any of the above elements are +/// missing from the request, or if the 'host' element refers to a cinder host +/// that is not registered. +/// +/// The volume will later enter the error state if it is discovered that 'ref' +/// is bad. +/// +/// Optional elements to 'volume' are: +/// +/// ```text +/// +/// name A name for the new volume. +/// description A description for the new volume. +/// volume_type ID or name of a volume type to associate with +/// the new Cinder volume. Does not necessarily +/// guarantee that the managed volume will have the +/// properties described in the volume_type. The +/// driver may choose to fail if it identifies that +/// the specified volume_type is not compatible with +/// the backend storage object. +/// metadata Key/value pairs to be associated with the new +/// volume. +/// availability_zone The availability zone to associate with the new +/// volume. +/// bootable If set to True, marks the volume as bootable. +/// +/// ``` +/// +#[derive(Args)] +pub struct ManageableVolumeCommand { + /// Request Query parameters + #[command(flatten)] + query: QueryParameters, + + /// Path parameters + #[command(flatten)] + path: PathParameters, + + /// A `volume` object. + /// + #[command(flatten)] + volume: Volume, +} + +/// Query parameters +#[derive(Args)] +struct QueryParameters {} + +/// Path parameters +#[derive(Args)] +struct PathParameters {} +/// Volume Body data +#[derive(Args, Clone)] +struct Volume { + /// The volume name. + /// + #[arg(help_heading = "Body parameters", long)] + availability_zone: Option, + + /// Enables or disables the bootable attribute. You can boot an instance + /// from a bootable volume. See + /// [valid boolean values](#valid-boolean-values) + /// + #[arg(action=clap::ArgAction::Set, help_heading = "Body parameters", long)] + bootable: Option, + + /// The volume description. + /// + #[arg(help_heading = "Body parameters", long)] + description: Option, + + /// The OpenStack Block Storage host where the existing resource resides. + /// Optional only if cluster field is provided. + /// + #[arg(help_heading = "Body parameters", long)] + host: Option, + + /// One or more metadata key and value pairs to be associated with the new + /// volume. + /// + #[arg(help_heading = "Body parameters", long, value_name="key=value", value_parser=parse_key_val::)] + metadata: Option>, + + /// The volume name. + /// + #[arg(help_heading = "Body parameters", long)] + name: Option, + + /// A reference to the existing volume. The internal structure of this + /// reference depends on the volume driver implementation. For details + /// about the required elements in the structure, see the documentation for + /// the volume driver. + /// + #[arg(help_heading = "Body parameters", long, value_name="JSON", value_parser=parse_json)] + _ref: Value, + + /// The volume name. + /// + #[arg(help_heading = "Body parameters", long)] + volume_type: Option, +} + +/// ManageableVolume response representation +#[derive(Deserialize, Serialize, Clone, StructTable)] +struct ResponseData { + /// Instance attachment information. If this volume is attached to a server + /// instance, the attachments list includes the UUID of the attached + /// server, an attachment UUID, the name of the attached host, if any, the + /// volume UUID, the device, and the device UUID. Otherwise, this list is + /// empty. For example: + /// + /// ```text + /// [ + /// { + /// 'server_id': '6c8cf6e0-4c8f-442f-9196-9679737feec6', + /// 'attachment_id': '3dafcac4-1cb9-4b60-a227-d729baa10cf6', + /// 'attached_at': '2019-09-30T19:30:34.000000', + /// 'host_name': null, + /// 'volume_id': '5d95d5ee-4bdd-4452-b9d7-d44ca10d3d53', + /// 'device': '/dev/vda', + /// 'id': '5d95d5ee-4bdd-4452-b9d7-d44ca10d3d53' + /// } + /// ] + /// + /// ``` + /// + #[serde()] + #[structable(optional, pretty)] + attachments: Option, + + /// The name of the availability zone. + /// + #[serde()] + #[structable(optional)] + availability_zone: Option, + + /// The cluster name of volume backend. + /// + #[serde()] + #[structable(optional)] + cluster_name: Option, + + /// The UUID of the consistency group. + /// + #[serde()] + #[structable(optional)] + consistencygroup_id: Option, + + /// Whether this resource consumes quota or not. Resources that not counted + /// for quota usage are usually temporary internal resources created to + /// perform an operation. + /// + #[serde()] + #[structable(optional)] + consumes_quota: Option, + + /// The date and time when the resource was created. + /// + /// The date and time stamp format is + /// [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601): + /// + /// ```text + /// CCYY-MM-DDThh:mm:ss±hh:mm + /// + /// ``` + /// + /// For example, `2015-08-27T09:49:58-05:00`. + /// + /// The `±hh:mm` value, if included, is the time zone as an offset from + /// UTC. + /// + #[serde()] + #[structable(optional)] + created_at: Option, + + /// The volume description. + /// + #[serde()] + #[structable(optional)] + description: Option, + + /// If true, this volume is encrypted. + /// + #[serde()] + #[structable(optional)] + encrypted: Option, + + /// The ID of the group. + /// + #[serde()] + #[structable(optional)] + group_id: Option, + + /// The UUID of the volume. + /// + #[serde()] + #[structable(optional)] + id: Option, + + /// The volume links. + /// + #[serde()] + #[structable(optional, pretty)] + links: Option, + + /// A `metadata` object. Contains one or more metadata key and value pairs + /// that are associated with the volume. + /// + #[serde()] + #[structable(optional, pretty)] + metadata: Option, + + /// The volume migration status. Admin only. + /// + #[serde()] + #[structable(optional)] + migration_status: Option, + + /// If true, this volume can attach to more than one instance. + /// + #[serde()] + #[structable(optional)] + multiattach: Option, + + /// The volume name. + /// + #[serde()] + #[structable(optional)] + name: Option, + + /// The provider ID for the volume. The value is either a string set by the + /// driver or null if the driver doesn’t use the field or if it hasn’t + /// created it yet. Only returned for administrators. + /// + #[serde()] + #[structable(optional)] + provider_id: Option, + + /// The volume replication status. + /// + #[serde()] + #[structable(optional)] + replication_status: Option, + + /// A unique identifier that’s used to indicate what node the + /// volume-service for a particular volume is being serviced by. + /// + #[serde()] + #[structable(optional)] + service_uuid: Option, + + /// An indicator whether the host connecting the volume should lock for the + /// whole attach/detach process or not. true means only is iSCSI initiator + /// running on host doesn’t support manual scans, false means never use + /// locks, and null means to always use locks. Look at os-brick’s + /// guard_connection context manager. Default=True. + /// + #[serde()] + #[structable(optional)] + shared_targets: Option, + + /// The size of the volume, in gibibytes (GiB). + /// + #[serde()] + #[structable(optional)] + size: Option, + + /// To create a volume from an existing snapshot, specify the UUID of the + /// volume snapshot. The volume is created in same availability zone and + /// with same size as the snapshot. + /// + #[serde()] + #[structable(optional)] + snapshot_id: Option, + + /// The UUID of the source volume. The API creates a new volume with the + /// same size as the source volume unless a larger size is requested. + /// + #[serde()] + #[structable(optional)] + source_volid: Option, + + /// The volume status. + /// + #[serde()] + #[structable(optional)] + status: Option, + + /// The date and time when the resource was updated. + /// + /// The date and time stamp format is + /// [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601): + /// + /// ```text + /// CCYY-MM-DDThh:mm:ss±hh:mm + /// + /// ``` + /// + /// For example, `2015-08-27T09:49:58-05:00`. + /// + /// The `±hh:mm` value, if included, is the time zone as an offset from + /// UTC. In the previous example, the offset value is `-05:00`. + /// + /// If the `updated_at` date and time stamp is not set, its value is + /// `null`. + /// + #[serde()] + #[structable(optional)] + updated_at: Option, + + /// The UUID of the user. + /// + #[serde()] + #[structable(optional)] + user_id: Option, + + /// A `volume_type` object. + /// + #[serde()] + #[structable(optional)] + volume_type: Option, + + /// The associated volume type ID for the volume. + /// + #[serde()] + #[structable(optional)] + volume_type_id: Option, +} + +impl ManageableVolumeCommand { + /// Perform command action + pub async fn take_action( + &self, + parsed_args: &Cli, + client: &mut AsyncOpenStack, + ) -> Result<(), OpenStackCliError> { + info!("Create ManageableVolume"); + + 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 + // Set Request.volume data + let args = &self.volume; + let mut volume_builder = create::VolumeBuilder::default(); + if let Some(val) = &args.description { + volume_builder.description(Some(val.into())); + } + + if let Some(val) = &args.availability_zone { + volume_builder.availability_zone(Some(val.into())); + } + + if let Some(val) = &args.bootable { + volume_builder.bootable(*val); + } + + if let Some(val) = &args.volume_type { + volume_builder.volume_type(Some(val.into())); + } + + if let Some(val) = &args.name { + volume_builder.name(Some(val.into())); + } + + if let Some(val) = &args.host { + volume_builder.host(Some(val.into())); + } + + volume_builder._ref(args._ref.clone()); + + if let Some(val) = &args.metadata { + volume_builder.metadata(val.iter().cloned()); + } + + ep_builder.volume(volume_builder.build().unwrap()); + + let ep = ep_builder + .build() + .map_err(|x| OpenStackCliError::EndpointBuild(x.to_string()))?; + + let data = ep.query_async(client).await?; + op.output_single::(data)?; + Ok(()) + } +} diff --git a/openstack_cli/src/block_storage/v3/manageable_volume/get.rs b/openstack_cli/src/block_storage/v3/manageable_volume/get.rs new file mode 100644 index 000000000..3276d7dad --- /dev/null +++ b/openstack_cli/src/block_storage/v3/manageable_volume/get.rs @@ -0,0 +1,156 @@ +// 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`. + +//! Get ManageableVolume command +//! +//! Wraps invoking of the `v3/manageable_volumes` 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::manageable_volume::get; +use openstack_sdk::api::QueryAsync; +use serde_json::Value; +use structable_derive::StructTable; + +/// Returns a summary list of volumes available to manage. +/// +#[derive(Args)] +pub struct ManageableVolumeCommand { + /// Request Query parameters + #[command(flatten)] + query: QueryParameters, + + /// Path parameters + #[command(flatten)] + path: PathParameters, +} + +/// Query parameters +#[derive(Args)] +struct QueryParameters { + /// Requests a page size of items. Returns a number of items up to a limit + /// value. Use the limit parameter to make an initial limited request and + /// use the ID of the last-seen item from the response as the marker + /// parameter value in a subsequent limited request. + /// + #[arg(help_heading = "Query parameters", long)] + limit: Option, + + /// The ID of the last-seen item. Use the limit parameter to make an + /// initial limited request and use the ID of the last-seen item from the + /// response as the marker parameter value in a subsequent limited request. + /// + #[arg(help_heading = "Query parameters", long)] + marker: Option, + + /// Used in conjunction with limit to return a slice of items. offset is + /// where to start in the list. + /// + #[arg(help_heading = "Query parameters", long)] + offset: Option, + + /// Comma-separated list of sort keys and optional sort directions in the + /// form of \< key > \[: \< direction > \]. A valid direction is asc + /// (ascending) or desc (descending). + /// + #[arg(help_heading = "Query parameters", long)] + sort: Option, + + /// Sorts by one or more sets of attribute and sort direction combinations. + /// If you omit the sort direction in a set, default is desc. Deprecated in + /// favour of the combined sort parameter. + /// + #[arg(help_heading = "Query parameters", long, value_parser = ["asc","desc"])] + sort_dir: Option, + + /// Sorts by an attribute. A valid value is name, status, container_format, + /// disk_format, size, id, created_at, or updated_at. Default is + /// created_at. The API uses the natural sorting direction of the sort_key + /// attribute value. Deprecated in favour of the combined sort parameter. + /// + #[arg(help_heading = "Query parameters", long)] + sort_key: Option, +} + +/// Path parameters +#[derive(Args)] +struct PathParameters {} +/// ManageableVolume response representation +#[derive(Deserialize, Serialize, Clone, StructTable)] +struct ResponseData { + /// A list of manageable volumes. + /// + #[serde(rename = "manageable-volumes")] + #[structable(pretty, title = "manageable-volumes")] + manageable_volumes: Value, +} + +impl ManageableVolumeCommand { + /// Perform command action + pub async fn take_action( + &self, + parsed_args: &Cli, + client: &mut AsyncOpenStack, + ) -> Result<(), OpenStackCliError> { + info!("Get ManageableVolume"); + + let op = OutputProcessor::from_args(parsed_args); + op.validate_args(parsed_args)?; + + let mut ep_builder = get::Request::builder(); + + // Set path parameters + // Set query parameters + if let Some(val) = &self.query.sort { + ep_builder.sort(val); + } + if let Some(val) = &self.query.sort_key { + ep_builder.sort_key(val); + } + if let Some(val) = &self.query.sort_dir { + ep_builder.sort_dir(val); + } + if let Some(val) = &self.query.limit { + ep_builder.limit(*val); + } + if let Some(val) = &self.query.offset { + ep_builder.offset(*val); + } + if let Some(val) = &self.query.marker { + ep_builder.marker(val); + } + // Set body parameters + + let ep = ep_builder + .build() + .map_err(|x| OpenStackCliError::EndpointBuild(x.to_string()))?; + + let data: Vec = ep.query_async(client).await?; + op.output_list::(data)?; + Ok(()) + } +} diff --git a/openstack_cli/src/block_storage/v3/manageable_volume/list.rs b/openstack_cli/src/block_storage/v3/manageable_volume/list.rs new file mode 100644 index 000000000..73c01d4c7 --- /dev/null +++ b/openstack_cli/src/block_storage/v3/manageable_volume/list.rs @@ -0,0 +1,164 @@ +// 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 ManageableVolumes command +//! +//! Wraps invoking of the `v3/manageable_volumes/detail` 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::manageable_volume::list_detailed; +use openstack_sdk::api::QueryAsync; +use openstack_sdk::api::{paged, Pagination}; +use serde_json::Value; +use structable_derive::StructTable; + +/// Returns a detailed list of volumes available to manage. +/// +#[derive(Args)] +pub struct ManageableVolumesCommand { + /// Request Query parameters + #[command(flatten)] + query: QueryParameters, + + /// Path parameters + #[command(flatten)] + path: PathParameters, + + /// Total limit of entities count to return. Use this when there are too many entries. + #[arg(long, default_value_t = 10000)] + max_items: usize, +} + +/// Query parameters +#[derive(Args)] +struct QueryParameters { + /// Requests a page size of items. Returns a number of items up to a limit + /// value. Use the limit parameter to make an initial limited request and + /// use the ID of the last-seen item from the response as the marker + /// parameter value in a subsequent limited request. + /// + #[arg(help_heading = "Query parameters", long)] + limit: Option, + + /// The ID of the last-seen item. Use the limit parameter to make an + /// initial limited request and use the ID of the last-seen item from the + /// response as the marker parameter value in a subsequent limited request. + /// + #[arg(help_heading = "Query parameters", long)] + marker: Option, + + /// Used in conjunction with limit to return a slice of items. offset is + /// where to start in the list. + /// + #[arg(help_heading = "Query parameters", long)] + offset: Option, + + /// Comma-separated list of sort keys and optional sort directions in the + /// form of \< key > \[: \< direction > \]. A valid direction is asc + /// (ascending) or desc (descending). + /// + #[arg(help_heading = "Query parameters", long)] + sort: Option, + + /// Sorts by one or more sets of attribute and sort direction combinations. + /// If you omit the sort direction in a set, default is desc. Deprecated in + /// favour of the combined sort parameter. + /// + #[arg(help_heading = "Query parameters", long, value_parser = ["asc","desc"])] + sort_dir: Option, + + /// Sorts by an attribute. A valid value is name, status, container_format, + /// disk_format, size, id, created_at, or updated_at. Default is + /// created_at. The API uses the natural sorting direction of the sort_key + /// attribute value. Deprecated in favour of the combined sort parameter. + /// + #[arg(help_heading = "Query parameters", long)] + sort_key: Option, +} + +/// Path parameters +#[derive(Args)] +struct PathParameters {} +/// ManageableVolumes response representation +#[derive(Deserialize, Serialize, Clone, StructTable)] +struct ResponseData { + /// A list of manageable volumes. + /// + #[serde(rename = "manageable-volumes")] + #[structable(pretty, title = "manageable-volumes", wide)] + manageable_volumes: Value, +} + +impl ManageableVolumesCommand { + /// Perform command action + pub async fn take_action( + &self, + parsed_args: &Cli, + client: &mut AsyncOpenStack, + ) -> Result<(), OpenStackCliError> { + info!("List ManageableVolumes"); + + let op = OutputProcessor::from_args(parsed_args); + op.validate_args(parsed_args)?; + + let mut ep_builder = list_detailed::Request::builder(); + + // Set path parameters + // Set query parameters + if let Some(val) = &self.query.sort { + ep_builder.sort(val); + } + if let Some(val) = &self.query.sort_key { + ep_builder.sort_key(val); + } + if let Some(val) = &self.query.sort_dir { + ep_builder.sort_dir(val); + } + if let Some(val) = &self.query.limit { + ep_builder.limit(*val); + } + if let Some(val) = &self.query.offset { + ep_builder.offset(*val); + } + if let Some(val) = &self.query.marker { + ep_builder.marker(val); + } + // Set body parameters + + let ep = ep_builder + .build() + .map_err(|x| OpenStackCliError::EndpointBuild(x.to_string()))?; + + let data: Vec = paged(ep, Pagination::Limit(self.max_items)) + .query_async(client) + .await?; + + op.output_list::(data)?; + Ok(()) + } +} diff --git a/openstack_cli/src/block_storage/v3/quota_class_set/set.rs b/openstack_cli/src/block_storage/v3/quota_class_set/set.rs new file mode 100644 index 000000000..89a469877 --- /dev/null +++ b/openstack_cli/src/block_storage/v3/quota_class_set/set.rs @@ -0,0 +1,120 @@ +// 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`. + +//! Set QuotaClassSet command +//! +//! Wraps invoking of the `v3/os-quota-class-sets/{id}` with `PUT` 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_key_val; +use openstack_sdk::api::block_storage::v3::quota_class_set::set; +use openstack_sdk::api::QueryAsync; +use serde_json::Value; +use std::collections::HashMap; + +/// Command without description in OpenAPI +/// +#[derive(Args)] +pub struct QuotaClassSetCommand { + /// Request Query parameters + #[command(flatten)] + query: QueryParameters, + + /// Path parameters + #[command(flatten)] + path: PathParameters, + + #[arg(help_heading = "Body parameters", long, value_name="key=value", value_parser=parse_key_val::)] + quota_class_set: Vec<(String, String)>, +} + +/// Query parameters +#[derive(Args)] +struct QueryParameters {} + +/// Path parameters +#[derive(Args)] +struct PathParameters { + /// id parameter for /v3/os-quota-class-sets/{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); + +impl StructTable for ResponseData { + fn build(&self, _options: &OutputConfig) -> (Vec, Vec>) { + let headers: Vec = Vec::from(["Name".to_string(), "Value".to_string()]); + let mut rows: Vec> = 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 QuotaClassSetCommand { + /// Perform command action + pub async fn take_action( + &self, + parsed_args: &Cli, + client: &mut AsyncOpenStack, + ) -> Result<(), OpenStackCliError> { + info!("Set QuotaClassSet"); + + let op = OutputProcessor::from_args(parsed_args); + op.validate_args(parsed_args)?; + + let mut ep_builder = set::Request::builder(); + + // Set path parameters + ep_builder.id(&self.path.id); + // Set query parameters + // Set body parameters + // Set Request.quota_class_set data + + ep_builder.quota_class_set(self.quota_class_set.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::(data)?; + Ok(()) + } +} diff --git a/openstack_cli/src/block_storage/v3/quota_class_set/show.rs b/openstack_cli/src/block_storage/v3/quota_class_set/show.rs new file mode 100644 index 000000000..3f382b832 --- /dev/null +++ b/openstack_cli/src/block_storage/v3/quota_class_set/show.rs @@ -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 QuotaClassSet command +//! +//! Wraps invoking of the `v3/os-quota-class-sets/{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::quota_class_set::get; +use openstack_sdk::api::QueryAsync; +use serde_json::Value; +use std::collections::HashMap; + +/// Command without description in OpenAPI +/// +#[derive(Args)] +pub struct QuotaClassSetCommand { + /// 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/os-quota-class-sets/{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); + +impl StructTable for ResponseData { + fn build(&self, _options: &OutputConfig) -> (Vec, Vec>) { + let headers: Vec = Vec::from(["Name".to_string(), "Value".to_string()]); + let mut rows: Vec> = 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 QuotaClassSetCommand { + /// Perform command action + pub async fn take_action( + &self, + parsed_args: &Cli, + client: &mut AsyncOpenStack, + ) -> Result<(), OpenStackCliError> { + info!("Show QuotaClassSet"); + + 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::(data)?; + Ok(()) + } +} diff --git a/openstack_cli/src/block_storage/v3/quota_set/default/get.rs b/openstack_cli/src/block_storage/v3/quota_set/default/get.rs new file mode 100644 index 000000000..032d4bbc8 --- /dev/null +++ b/openstack_cli/src/block_storage/v3/quota_set/default/get.rs @@ -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`. + +//! Get Default command +//! +//! Wraps invoking of the `v3/os-quota-sets/{id}/defaults` 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::quota_set::default::get; +use openstack_sdk::api::QueryAsync; +use serde_json::Value; +use std::collections::HashMap; + +/// Command without description in OpenAPI +/// +#[derive(Args)] +pub struct DefaultCommand { + /// 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/os-quota-sets/{id}/defaults 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); + +impl StructTable for ResponseData { + fn build(&self, _options: &OutputConfig) -> (Vec, Vec>) { + let headers: Vec = Vec::from(["Name".to_string(), "Value".to_string()]); + let mut rows: Vec> = 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 DefaultCommand { + /// Perform command action + pub async fn take_action( + &self, + parsed_args: &Cli, + client: &mut AsyncOpenStack, + ) -> Result<(), OpenStackCliError> { + info!("Get Default"); + + 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::(data)?; + Ok(()) + } +} diff --git a/openstack_cli/src/block_storage/v3/quota_set/delete.rs b/openstack_cli/src/block_storage/v3/quota_set/delete.rs new file mode 100644 index 000000000..f97b44320 --- /dev/null +++ b/openstack_cli/src/block_storage/v3/quota_set/delete.rs @@ -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`. + +//! Delete QuotaSet command +//! +//! Wraps invoking of the `v3/os-quota-sets/{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::quota_set::delete; +use openstack_sdk::api::RawQueryAsync; +use structable_derive::StructTable; + +/// Delete Quota for a particular tenant. +/// +/// | param req: | request | | --- | --- | | param id: | target project id that +/// needs to be deleted | +/// +#[derive(Args)] +pub struct QuotaSetCommand { + /// 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/os-quota-sets/{id} API + /// + #[arg( + help_heading = "Path parameters", + id = "path_param_id", + value_name = "ID" + )] + id: String, +} +/// QuotaSet response representation +#[derive(Deserialize, Serialize, Clone, StructTable)] +struct ResponseData {} + +impl QuotaSetCommand { + /// Perform command action + pub async fn take_action( + &self, + parsed_args: &Cli, + client: &mut AsyncOpenStack, + ) -> Result<(), OpenStackCliError> { + info!("Delete QuotaSet"); + + 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 = ep.raw_query_async(client).await?; + Ok(()) + } +} diff --git a/openstack_cli/src/block_storage/v3/quota_set/set.rs b/openstack_cli/src/block_storage/v3/quota_set/set.rs new file mode 100644 index 000000000..b5d7c8338 --- /dev/null +++ b/openstack_cli/src/block_storage/v3/quota_set/set.rs @@ -0,0 +1,125 @@ +// 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`. + +//! Set QuotaSet command +//! +//! Wraps invoking of the `v3/os-quota-sets/{id}` with `PUT` 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::quota_set::set; +use openstack_sdk::api::QueryAsync; +use serde_json::Value; +use std::collections::HashMap; + +/// Update Quota for a particular tenant +/// +/// | param req: | request | | --- | --- | | param id: | target project id that +/// needs to be updated | | param body: | key, value pair that will be applied +/// to the resources if the update succeeds | +/// +#[derive(Args)] +pub struct QuotaSetCommand { + /// Request Query parameters + #[command(flatten)] + query: QueryParameters, + + /// Path parameters + #[command(flatten)] + path: PathParameters, + + #[arg(help_heading = "Body parameters", long, value_name="key=value", value_parser=parse_key_val::)] + quota_set: Vec<(String, Value)>, +} + +/// Query parameters +#[derive(Args)] +struct QueryParameters {} + +/// Path parameters +#[derive(Args)] +struct PathParameters { + /// id parameter for /v3/os-quota-sets/{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); + +impl StructTable for ResponseData { + fn build(&self, _options: &OutputConfig) -> (Vec, Vec>) { + let headers: Vec = Vec::from(["Name".to_string(), "Value".to_string()]); + let mut rows: Vec> = 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 QuotaSetCommand { + /// Perform command action + pub async fn take_action( + &self, + parsed_args: &Cli, + client: &mut AsyncOpenStack, + ) -> Result<(), OpenStackCliError> { + info!("Set QuotaSet"); + + let op = OutputProcessor::from_args(parsed_args); + op.validate_args(parsed_args)?; + + let mut ep_builder = set::Request::builder(); + + // Set path parameters + ep_builder.id(&self.path.id); + // Set query parameters + // Set body parameters + // Set Request.quota_set data + + ep_builder.quota_set(self.quota_set.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::(data)?; + Ok(()) + } +} diff --git a/openstack_cli/src/block_storage/v3/quota_set/show.rs b/openstack_cli/src/block_storage/v3/quota_set/show.rs new file mode 100644 index 000000000..2d59010a1 --- /dev/null +++ b/openstack_cli/src/block_storage/v3/quota_set/show.rs @@ -0,0 +1,116 @@ +// 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 QuotaSet command +//! +//! Wraps invoking of the `v3/os-quota-sets/{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::quota_set::get; +use openstack_sdk::api::QueryAsync; +use serde_json::Value; +use std::collections::HashMap; + +/// Show quota for a particular tenant +/// +/// | param req: | request | | --- | --- | | param id: | target project id that +/// needs to be shown | +/// +#[derive(Args)] +pub struct QuotaSetCommand { + /// 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/os-quota-sets/{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); + +impl StructTable for ResponseData { + fn build(&self, _options: &OutputConfig) -> (Vec, Vec>) { + let headers: Vec = Vec::from(["Name".to_string(), "Value".to_string()]); + let mut rows: Vec> = 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 QuotaSetCommand { + /// Perform command action + pub async fn take_action( + &self, + parsed_args: &Cli, + client: &mut AsyncOpenStack, + ) -> Result<(), OpenStackCliError> { + info!("Show QuotaSet"); + + 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::(data)?; + Ok(()) + } +} diff --git a/openstack_cli/src/block_storage/v3/scheduler_stat/get_pool/get.rs b/openstack_cli/src/block_storage/v3/scheduler_stat/get_pool/get.rs new file mode 100644 index 000000000..316cd0f7a --- /dev/null +++ b/openstack_cli/src/block_storage/v3/scheduler_stat/get_pool/get.rs @@ -0,0 +1,103 @@ +// 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`. + +//! Get GetPool command +//! +//! Wraps invoking of the `v3/scheduler-stats/get_pools` 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::scheduler_stat::get_pool::get; +use openstack_sdk::api::QueryAsync; +use serde_json::Value; +use std::collections::HashMap; + +/// List all active pools in scheduler. +/// +#[derive(Args)] +pub struct GetPoolCommand { + /// 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 {} +/// Response data as HashMap type +#[derive(Deserialize, Serialize)] +struct ResponseData(HashMap); + +impl StructTable for ResponseData { + fn build(&self, _options: &OutputConfig) -> (Vec, Vec>) { + let headers: Vec = Vec::from(["Name".to_string(), "Value".to_string()]); + let mut rows: Vec> = 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 GetPoolCommand { + /// Perform command action + pub async fn take_action( + &self, + parsed_args: &Cli, + client: &mut AsyncOpenStack, + ) -> Result<(), OpenStackCliError> { + info!("Get GetPool"); + + let op = OutputProcessor::from_args(parsed_args); + op.validate_args(parsed_args)?; + + let ep_builder = get::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 = ep.query_async(client).await?; + op.output_single::(data)?; + Ok(()) + } +} diff --git a/openstack_cli/src/block_storage/v3/service/list.rs b/openstack_cli/src/block_storage/v3/service/list.rs new file mode 100644 index 000000000..efb27a5b8 --- /dev/null +++ b/openstack_cli/src/block_storage/v3/service/list.rs @@ -0,0 +1,105 @@ +// 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 Services command +//! +//! Wraps invoking of the `v3/os-services` 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::service::list; +use openstack_sdk::api::QueryAsync; +use serde_json::Value; +use std::collections::HashMap; + +/// Return a list of all running services. +/// +/// Filter by host & service name. +/// +#[derive(Args)] +pub struct ServicesCommand { + /// 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 {} +/// Response data as HashMap type +#[derive(Deserialize, Serialize)] +struct ResponseData(HashMap); + +impl StructTable for ResponseData { + fn build(&self, _options: &OutputConfig) -> (Vec, Vec>) { + let headers: Vec = Vec::from(["Name".to_string(), "Value".to_string()]); + let mut rows: Vec> = 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 ServicesCommand { + /// Perform command action + pub async fn take_action( + &self, + parsed_args: &Cli, + client: &mut AsyncOpenStack, + ) -> Result<(), OpenStackCliError> { + info!("List Services"); + + 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 = ep.query_async(client).await?; + op.output_single::(data)?; + Ok(()) + } +} diff --git a/openstack_cli/src/block_storage/v3/service/set.rs b/openstack_cli/src/block_storage/v3/service/set.rs new file mode 100644 index 000000000..c440c546c --- /dev/null +++ b/openstack_cli/src/block_storage/v3/service/set.rs @@ -0,0 +1,126 @@ +// 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`. + +//! Set Service command +//! +//! Wraps invoking of the `v3/os-services/{id}` with `PUT` 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::service::set; +use openstack_sdk::api::QueryAsync; +use serde_json::Value; +use std::collections::HashMap; + +/// Enable/Disable scheduling for a service. +/// +/// Includes Freeze/Thaw which sends call down to drivers and allows +/// volume.manager for the specified host to disable the service rather than +/// accessing the service directly in this API layer. +/// +#[derive(Args)] +pub struct ServiceCommand { + /// 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::)] + #[arg(help_heading = "Body parameters")] + properties: Option>, +} + +/// Query parameters +#[derive(Args)] +struct QueryParameters {} + +/// Path parameters +#[derive(Args)] +struct PathParameters { + /// id parameter for /v3/os-services/{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); + +impl StructTable for ResponseData { + fn build(&self, _options: &OutputConfig) -> (Vec, Vec>) { + let headers: Vec = Vec::from(["Name".to_string(), "Value".to_string()]); + let mut rows: Vec> = 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 ServiceCommand { + /// Perform command action + pub async fn take_action( + &self, + parsed_args: &Cli, + client: &mut AsyncOpenStack, + ) -> Result<(), OpenStackCliError> { + info!("Set Service"); + + let op = OutputProcessor::from_args(parsed_args); + op.validate_args(parsed_args)?; + + let mut ep_builder = set::Request::builder(); + + // Set path parameters + ep_builder.id(&self.path.id); + // 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::(data)?; + Ok(()) + } +} diff --git a/openstack_cli/src/block_storage/v3/version/get.rs b/openstack_cli/src/block_storage/v3/version/get.rs new file mode 100644 index 000000000..8f578f36f --- /dev/null +++ b/openstack_cli/src/block_storage/v3/version/get.rs @@ -0,0 +1,104 @@ +// 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`. + +//! Get Version command +//! +//! Wraps invoking of the `v3/` 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::version::get; +use openstack_sdk::api::QueryAsync; +use serde_json::Value; +use std::collections::HashMap; + +/// Shows details for Block Storage API v3. +/// +#[derive(Args)] +#[command(about = "Show API v3 details")] +pub struct VersionCommand { + /// 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 {} +/// Response data as HashMap type +#[derive(Deserialize, Serialize)] +struct ResponseData(HashMap); + +impl StructTable for ResponseData { + fn build(&self, _options: &OutputConfig) -> (Vec, Vec>) { + let headers: Vec = Vec::from(["Name".to_string(), "Value".to_string()]); + let mut rows: Vec> = 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 VersionCommand { + /// Perform command action + pub async fn take_action( + &self, + parsed_args: &Cli, + client: &mut AsyncOpenStack, + ) -> Result<(), OpenStackCliError> { + info!("Get Version"); + + let op = OutputProcessor::from_args(parsed_args); + op.validate_args(parsed_args)?; + + let ep_builder = get::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 = ep.query_async(client).await?; + op.output_single::(data)?; + Ok(()) + } +} diff --git a/openstack_cli/src/block_storage/v3/worker/cleanup/create_324.rs b/openstack_cli/src/block_storage/v3/worker/cleanup/create_324.rs new file mode 100644 index 000000000..7c38fcd45 --- /dev/null +++ b/openstack_cli/src/block_storage/v3/worker/cleanup/create_324.rs @@ -0,0 +1,179 @@ +// 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 Cleanup command [microversion = 3.24] +//! +//! Wraps invoking of the `v3/workers/cleanup` 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 clap::ValueEnum; +use openstack_sdk::api::block_storage::v3::worker::cleanup::create_324; +use openstack_sdk::api::QueryAsync; +use serde_json::Value; +use std::collections::HashMap; + +/// Do the cleanup on resources from a specific service/host/node. +/// +#[derive(Args)] +pub struct CleanupCommand { + /// Request Query parameters + #[command(flatten)] + query: QueryParameters, + + /// Path parameters + #[command(flatten)] + path: PathParameters, + + #[arg(help_heading = "Body parameters", long)] + binary: Option, + + #[arg(help_heading = "Body parameters", long)] + cluster_name: Option, + + #[arg(action=clap::ArgAction::Set, help_heading = "Body parameters", long)] + disabled: Option, + + #[arg(help_heading = "Body parameters", long)] + host: Option, + + #[arg(action=clap::ArgAction::Set, help_heading = "Body parameters", long)] + is_up: Option, + + #[arg(help_heading = "Body parameters", long)] + resource_id: Option, + + #[arg(help_heading = "Body parameters", long)] + resource_type: Option, + + #[arg(help_heading = "Body parameters", long)] + service_id: Option, +} + +/// Query parameters +#[derive(Args)] +struct QueryParameters {} + +/// Path parameters +#[derive(Args)] +struct PathParameters {} + +#[derive(Clone, Eq, Ord, PartialEq, PartialOrd, ValueEnum)] +enum Binary { + CinderScheduler, + CinderVolume, +} + +/// Response data as HashMap type +#[derive(Deserialize, Serialize)] +struct ResponseData(HashMap); + +impl StructTable for ResponseData { + fn build(&self, _options: &OutputConfig) -> (Vec, Vec>) { + let headers: Vec = Vec::from(["Name".to_string(), "Value".to_string()]); + let mut rows: Vec> = 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 CleanupCommand { + /// Perform command action + pub async fn take_action( + &self, + parsed_args: &Cli, + client: &mut AsyncOpenStack, + ) -> Result<(), OpenStackCliError> { + info!("Create Cleanup"); + + let op = OutputProcessor::from_args(parsed_args); + op.validate_args(parsed_args)?; + + let mut ep_builder = create_324::Request::builder(); + ep_builder.header("OpenStack-API-Version", "volume 3.24"); + + // Set path parameters + // Set query parameters + // Set body parameters + // Set Request.binary data + if let Some(arg) = &self.binary { + let tmp = match arg { + Binary::CinderScheduler => create_324::Binary::CinderScheduler, + Binary::CinderVolume => create_324::Binary::CinderVolume, + }; + ep_builder.binary(tmp); + } + + // Set Request.cluster_name data + if let Some(arg) = &self.cluster_name { + ep_builder.cluster_name(Some(arg.into())); + } + + // Set Request.disabled data + if let Some(arg) = &self.disabled { + ep_builder.disabled(*arg); + } + + // Set Request.host data + if let Some(arg) = &self.host { + ep_builder.host(Some(arg.into())); + } + + // Set Request.is_up data + if let Some(arg) = &self.is_up { + ep_builder.is_up(*arg); + } + + // Set Request.resource_id data + if let Some(arg) = &self.resource_id { + ep_builder.resource_id(Some(arg.into())); + } + + // Set Request.resource_type data + if let Some(arg) = &self.resource_type { + ep_builder.resource_type(Some(arg.into())); + } + + // Set Request.service_id data + if let Some(arg) = &self.service_id { + ep_builder.service_id(Some(arg.into())); + } + + let ep = ep_builder + .build() + .map_err(|x| OpenStackCliError::EndpointBuild(x.to_string()))?; + + let data = ep.query_async(client).await?; + op.output_single::(data)?; + Ok(()) + } +} diff --git a/openstack_cli/tests/block_storage/v3/capability/show_autogen.rs b/openstack_cli/tests/block_storage/v3/capability/show_autogen.rs new file mode 100644 index 000000000..1576d396e --- /dev/null +++ b/openstack_cli/tests/block_storage/v3/capability/show_autogen.rs @@ -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> { + let mut cmd = Command::cargo_bin("osc")?; + + cmd.arg("block-storage") + .arg("capability") + .arg("show") + .arg("--help"); + cmd.assert().success(); + + Ok(()) +} diff --git a/openstack_cli/tests/block_storage/v3/cgsnapshot/create_autogen.rs b/openstack_cli/tests/block_storage/v3/cgsnapshot/create_autogen.rs new file mode 100644 index 000000000..db34849ed --- /dev/null +++ b/openstack_cli/tests/block_storage/v3/cgsnapshot/create_autogen.rs @@ -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> { + let mut cmd = Command::cargo_bin("osc")?; + + cmd.arg("block-storage") + .arg("cgsnapshot") + .arg("create") + .arg("--help"); + cmd.assert().success(); + + Ok(()) +} diff --git a/openstack_cli/tests/block_storage/v3/cgsnapshot/delete_autogen.rs b/openstack_cli/tests/block_storage/v3/cgsnapshot/delete_autogen.rs new file mode 100644 index 000000000..f51bad1dd --- /dev/null +++ b/openstack_cli/tests/block_storage/v3/cgsnapshot/delete_autogen.rs @@ -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> { + let mut cmd = Command::cargo_bin("osc")?; + + cmd.arg("block-storage") + .arg("cgsnapshot") + .arg("delete") + .arg("--help"); + cmd.assert().success(); + + Ok(()) +} diff --git a/openstack_cli/tests/block_storage/v3/cgsnapshot/list_autogen.rs b/openstack_cli/tests/block_storage/v3/cgsnapshot/list_autogen.rs new file mode 100644 index 000000000..836ca8448 --- /dev/null +++ b/openstack_cli/tests/block_storage/v3/cgsnapshot/list_autogen.rs @@ -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> { + let mut cmd = Command::cargo_bin("osc")?; + + cmd.arg("block-storage") + .arg("cgsnapshot") + .arg("list") + .arg("--help"); + cmd.assert().success(); + + Ok(()) +} diff --git a/openstack_cli/tests/block_storage/v3/cgsnapshot/show_autogen.rs b/openstack_cli/tests/block_storage/v3/cgsnapshot/show_autogen.rs new file mode 100644 index 000000000..aef7f3bb5 --- /dev/null +++ b/openstack_cli/tests/block_storage/v3/cgsnapshot/show_autogen.rs @@ -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> { + let mut cmd = Command::cargo_bin("osc")?; + + cmd.arg("block-storage") + .arg("cgsnapshot") + .arg("show") + .arg("--help"); + cmd.assert().success(); + + Ok(()) +} diff --git a/openstack_cli/tests/block_storage/v3/consistencygroup/create_autogen.rs b/openstack_cli/tests/block_storage/v3/consistencygroup/create_autogen.rs new file mode 100644 index 000000000..459d5c96f --- /dev/null +++ b/openstack_cli/tests/block_storage/v3/consistencygroup/create_autogen.rs @@ -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> { + let mut cmd = Command::cargo_bin("osc")?; + + cmd.arg("block-storage") + .arg("consistencygroup") + .arg("create") + .arg("--help"); + cmd.assert().success(); + + Ok(()) +} diff --git a/openstack_cli/tests/block_storage/v3/consistencygroup/create_from_src/create_autogen.rs b/openstack_cli/tests/block_storage/v3/consistencygroup/create_from_src/create_autogen.rs new file mode 100644 index 000000000..916f22978 --- /dev/null +++ b/openstack_cli/tests/block_storage/v3/consistencygroup/create_from_src/create_autogen.rs @@ -0,0 +1,33 @@ +// 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> { + let mut cmd = Command::cargo_bin("osc")?; + + cmd.arg("block-storage") + .arg("consistencygroup") + .arg("create-from-src") + .arg("create") + .arg("--help"); + cmd.assert().success(); + + Ok(()) +} diff --git a/openstack_cli/tests/block_storage/v3/consistencygroup/delete/create_autogen.rs b/openstack_cli/tests/block_storage/v3/consistencygroup/delete/create_autogen.rs new file mode 100644 index 000000000..4cad941da --- /dev/null +++ b/openstack_cli/tests/block_storage/v3/consistencygroup/delete/create_autogen.rs @@ -0,0 +1,33 @@ +// 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> { + let mut cmd = Command::cargo_bin("osc")?; + + cmd.arg("block-storage") + .arg("consistencygroup") + .arg("delete") + .arg("create") + .arg("--help"); + cmd.assert().success(); + + Ok(()) +} diff --git a/openstack_cli/tests/block_storage/v3/consistencygroup/delete_autogen.rs b/openstack_cli/tests/block_storage/v3/consistencygroup/delete_autogen.rs new file mode 100644 index 000000000..ca4518906 --- /dev/null +++ b/openstack_cli/tests/block_storage/v3/consistencygroup/delete_autogen.rs @@ -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> { + let mut cmd = Command::cargo_bin("osc")?; + + cmd.arg("block-storage") + .arg("consistencygroup") + .arg("delete") + .arg("--help"); + cmd.assert().success(); + + Ok(()) +} diff --git a/openstack_cli/tests/block_storage/v3/consistencygroup/list_autogen.rs b/openstack_cli/tests/block_storage/v3/consistencygroup/list_autogen.rs new file mode 100644 index 000000000..90b5206bb --- /dev/null +++ b/openstack_cli/tests/block_storage/v3/consistencygroup/list_autogen.rs @@ -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> { + let mut cmd = Command::cargo_bin("osc")?; + + cmd.arg("block-storage") + .arg("consistencygroup") + .arg("list") + .arg("--help"); + cmd.assert().success(); + + Ok(()) +} diff --git a/openstack_cli/tests/block_storage/v3/consistencygroup/set_autogen.rs b/openstack_cli/tests/block_storage/v3/consistencygroup/set_autogen.rs new file mode 100644 index 000000000..ec6fef8ae --- /dev/null +++ b/openstack_cli/tests/block_storage/v3/consistencygroup/set_autogen.rs @@ -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> { + let mut cmd = Command::cargo_bin("osc")?; + + cmd.arg("block-storage") + .arg("consistencygroup") + .arg("set") + .arg("--help"); + cmd.assert().success(); + + Ok(()) +} diff --git a/openstack_cli/tests/block_storage/v3/consistencygroup/show_autogen.rs b/openstack_cli/tests/block_storage/v3/consistencygroup/show_autogen.rs new file mode 100644 index 000000000..addbf6847 --- /dev/null +++ b/openstack_cli/tests/block_storage/v3/consistencygroup/show_autogen.rs @@ -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> { + let mut cmd = Command::cargo_bin("osc")?; + + cmd.arg("block-storage") + .arg("consistencygroup") + .arg("show") + .arg("--help"); + cmd.assert().success(); + + Ok(()) +} diff --git a/openstack_cli/tests/block_storage/v3/manageable_snapshot/create_autogen.rs b/openstack_cli/tests/block_storage/v3/manageable_snapshot/create_autogen.rs new file mode 100644 index 000000000..72e776e2f --- /dev/null +++ b/openstack_cli/tests/block_storage/v3/manageable_snapshot/create_autogen.rs @@ -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> { + let mut cmd = Command::cargo_bin("osc")?; + + cmd.arg("block-storage") + .arg("manageable-snapshot") + .arg("create") + .arg("--help"); + cmd.assert().success(); + + Ok(()) +} diff --git a/openstack_cli/tests/block_storage/v3/manageable_snapshot/get_autogen.rs b/openstack_cli/tests/block_storage/v3/manageable_snapshot/get_autogen.rs new file mode 100644 index 000000000..6570849f4 --- /dev/null +++ b/openstack_cli/tests/block_storage/v3/manageable_snapshot/get_autogen.rs @@ -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> { + let mut cmd = Command::cargo_bin("osc")?; + + cmd.arg("block-storage") + .arg("manageable-snapshot") + .arg("get") + .arg("--help"); + cmd.assert().success(); + + Ok(()) +} diff --git a/openstack_cli/tests/block_storage/v3/manageable_snapshot/list_autogen.rs b/openstack_cli/tests/block_storage/v3/manageable_snapshot/list_autogen.rs new file mode 100644 index 000000000..50a522e5d --- /dev/null +++ b/openstack_cli/tests/block_storage/v3/manageable_snapshot/list_autogen.rs @@ -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> { + let mut cmd = Command::cargo_bin("osc")?; + + cmd.arg("block-storage") + .arg("manageable-snapshot") + .arg("list") + .arg("--help"); + cmd.assert().success(); + + Ok(()) +} diff --git a/openstack_cli/tests/block_storage/v3/manageable_volume/create_autogen.rs b/openstack_cli/tests/block_storage/v3/manageable_volume/create_autogen.rs new file mode 100644 index 000000000..818d02119 --- /dev/null +++ b/openstack_cli/tests/block_storage/v3/manageable_volume/create_autogen.rs @@ -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> { + let mut cmd = Command::cargo_bin("osc")?; + + cmd.arg("block-storage") + .arg("manageable-volume") + .arg("create") + .arg("--help"); + cmd.assert().success(); + + Ok(()) +} diff --git a/openstack_cli/tests/block_storage/v3/manageable_volume/get_autogen.rs b/openstack_cli/tests/block_storage/v3/manageable_volume/get_autogen.rs new file mode 100644 index 000000000..6dd1370e4 --- /dev/null +++ b/openstack_cli/tests/block_storage/v3/manageable_volume/get_autogen.rs @@ -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> { + let mut cmd = Command::cargo_bin("osc")?; + + cmd.arg("block-storage") + .arg("manageable-volume") + .arg("get") + .arg("--help"); + cmd.assert().success(); + + Ok(()) +} diff --git a/openstack_cli/tests/block_storage/v3/manageable_volume/list_autogen.rs b/openstack_cli/tests/block_storage/v3/manageable_volume/list_autogen.rs new file mode 100644 index 000000000..e16359ae4 --- /dev/null +++ b/openstack_cli/tests/block_storage/v3/manageable_volume/list_autogen.rs @@ -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> { + let mut cmd = Command::cargo_bin("osc")?; + + cmd.arg("block-storage") + .arg("manageable-volume") + .arg("list") + .arg("--help"); + cmd.assert().success(); + + Ok(()) +} diff --git a/openstack_cli/tests/block_storage/v3/quota_class_set/set_autogen.rs b/openstack_cli/tests/block_storage/v3/quota_class_set/set_autogen.rs new file mode 100644 index 000000000..38d383ed6 --- /dev/null +++ b/openstack_cli/tests/block_storage/v3/quota_class_set/set_autogen.rs @@ -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> { + let mut cmd = Command::cargo_bin("osc")?; + + cmd.arg("block-storage") + .arg("quota-class-set") + .arg("set") + .arg("--help"); + cmd.assert().success(); + + Ok(()) +} diff --git a/openstack_cli/tests/block_storage/v3/quota_class_set/show_autogen.rs b/openstack_cli/tests/block_storage/v3/quota_class_set/show_autogen.rs new file mode 100644 index 000000000..9a8ba5f67 --- /dev/null +++ b/openstack_cli/tests/block_storage/v3/quota_class_set/show_autogen.rs @@ -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> { + let mut cmd = Command::cargo_bin("osc")?; + + cmd.arg("block-storage") + .arg("quota-class-set") + .arg("show") + .arg("--help"); + cmd.assert().success(); + + Ok(()) +} diff --git a/openstack_cli/tests/block_storage/v3/quota_set/default/get_autogen.rs b/openstack_cli/tests/block_storage/v3/quota_set/default/get_autogen.rs new file mode 100644 index 000000000..a53843a9c --- /dev/null +++ b/openstack_cli/tests/block_storage/v3/quota_set/default/get_autogen.rs @@ -0,0 +1,33 @@ +// 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> { + let mut cmd = Command::cargo_bin("osc")?; + + cmd.arg("block-storage") + .arg("quota-set") + .arg("default") + .arg("get") + .arg("--help"); + cmd.assert().success(); + + Ok(()) +} diff --git a/openstack_cli/tests/block_storage/v3/quota_set/delete_autogen.rs b/openstack_cli/tests/block_storage/v3/quota_set/delete_autogen.rs new file mode 100644 index 000000000..ac7c28a07 --- /dev/null +++ b/openstack_cli/tests/block_storage/v3/quota_set/delete_autogen.rs @@ -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> { + let mut cmd = Command::cargo_bin("osc")?; + + cmd.arg("block-storage") + .arg("quota-set") + .arg("delete") + .arg("--help"); + cmd.assert().success(); + + Ok(()) +} diff --git a/openstack_cli/tests/block_storage/v3/quota_set/set_autogen.rs b/openstack_cli/tests/block_storage/v3/quota_set/set_autogen.rs new file mode 100644 index 000000000..fa3816745 --- /dev/null +++ b/openstack_cli/tests/block_storage/v3/quota_set/set_autogen.rs @@ -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> { + let mut cmd = Command::cargo_bin("osc")?; + + cmd.arg("block-storage") + .arg("quota-set") + .arg("set") + .arg("--help"); + cmd.assert().success(); + + Ok(()) +} diff --git a/openstack_cli/tests/block_storage/v3/quota_set/show_autogen.rs b/openstack_cli/tests/block_storage/v3/quota_set/show_autogen.rs new file mode 100644 index 000000000..1eb6116dd --- /dev/null +++ b/openstack_cli/tests/block_storage/v3/quota_set/show_autogen.rs @@ -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> { + let mut cmd = Command::cargo_bin("osc")?; + + cmd.arg("block-storage") + .arg("quota-set") + .arg("show") + .arg("--help"); + cmd.assert().success(); + + Ok(()) +} diff --git a/openstack_cli/tests/block_storage/v3/scheduler_stat/get_pool/get_autogen.rs b/openstack_cli/tests/block_storage/v3/scheduler_stat/get_pool/get_autogen.rs new file mode 100644 index 000000000..b0ee63ad7 --- /dev/null +++ b/openstack_cli/tests/block_storage/v3/scheduler_stat/get_pool/get_autogen.rs @@ -0,0 +1,33 @@ +// 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> { + let mut cmd = Command::cargo_bin("osc")?; + + cmd.arg("block-storage") + .arg("scheduler-stat") + .arg("get-pool") + .arg("get") + .arg("--help"); + cmd.assert().success(); + + Ok(()) +} diff --git a/openstack_cli/tests/block_storage/v3/service/list_autogen.rs b/openstack_cli/tests/block_storage/v3/service/list_autogen.rs new file mode 100644 index 000000000..91e41a2fb --- /dev/null +++ b/openstack_cli/tests/block_storage/v3/service/list_autogen.rs @@ -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> { + let mut cmd = Command::cargo_bin("osc")?; + + cmd.arg("block-storage") + .arg("service") + .arg("list") + .arg("--help"); + cmd.assert().success(); + + Ok(()) +} diff --git a/openstack_cli/tests/block_storage/v3/service/set_autogen.rs b/openstack_cli/tests/block_storage/v3/service/set_autogen.rs new file mode 100644 index 000000000..d35379353 --- /dev/null +++ b/openstack_cli/tests/block_storage/v3/service/set_autogen.rs @@ -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> { + let mut cmd = Command::cargo_bin("osc")?; + + cmd.arg("block-storage") + .arg("service") + .arg("set") + .arg("--help"); + cmd.assert().success(); + + Ok(()) +} diff --git a/openstack_cli/tests/block_storage/v3/version/get_autogen.rs b/openstack_cli/tests/block_storage/v3/version/get_autogen.rs new file mode 100644 index 000000000..8443370ed --- /dev/null +++ b/openstack_cli/tests/block_storage/v3/version/get_autogen.rs @@ -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> { + let mut cmd = Command::cargo_bin("osc")?; + + cmd.arg("block-storage") + .arg("version") + .arg("get") + .arg("--help"); + cmd.assert().success(); + + Ok(()) +} diff --git a/openstack_cli/tests/block_storage/v3/worker/cleanup/create_324_autogen.rs b/openstack_cli/tests/block_storage/v3/worker/cleanup/create_324_autogen.rs new file mode 100644 index 000000000..0f5e63f87 --- /dev/null +++ b/openstack_cli/tests/block_storage/v3/worker/cleanup/create_324_autogen.rs @@ -0,0 +1,33 @@ +// 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> { + let mut cmd = Command::cargo_bin("osc")?; + + cmd.arg("block-storage") + .arg("worker") + .arg("cleanup") + .arg("create324") + .arg("--help"); + cmd.assert().success(); + + Ok(()) +} diff --git a/openstack_sdk/src/api/block_storage/v3.rs b/openstack_sdk/src/api/block_storage/v3.rs index a067616d4..f96f9e1a2 100644 --- a/openstack_sdk/src/api/block_storage/v3.rs +++ b/openstack_sdk/src/api/block_storage/v3.rs @@ -11,12 +11,18 @@ // limitations under the License. // // SPDX-License-Identifier: Apache-2.0 +// +// WARNING: This file is automatically generated from OpenAPI schema using +// `openstack-codegenerator`. //! `Block_storage` Service bindings pub mod attachment; pub mod availability_zone; pub mod backup; +pub mod capability; +pub mod cgsnapshot; pub mod cluster; +pub mod consistencygroup; pub mod default_type; pub mod extension; pub mod group; @@ -24,13 +30,21 @@ pub mod group_snapshot; pub mod group_type; pub mod host; pub mod limit; +pub mod manageable_snapshot; +pub mod manageable_volume; pub mod message; pub mod os_volume_transfer; pub mod qos_spec; +pub mod quota_class_set; +pub mod quota_set; pub mod resource_filter; +pub mod scheduler_stat; +pub mod service; pub mod snapshot; pub mod snapshot_manage; pub mod r#type; +pub mod version; pub mod volume; pub mod volume_manage; pub mod volume_transfer; +pub mod worker; diff --git a/openstack_sdk/src/api/block_storage/v3/capability.rs b/openstack_sdk/src/api/block_storage/v3/capability.rs new file mode 100644 index 000000000..6aae6d0c5 --- /dev/null +++ b/openstack_sdk/src/api/block_storage/v3/capability.rs @@ -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/capabilities/{id}` REST operations of block_storage +pub mod get; diff --git a/openstack_sdk/src/api/block_storage/v3/capability/get.rs b/openstack_sdk/src/api/block_storage/v3/capability/get.rs new file mode 100644 index 000000000..68e9bc18f --- /dev/null +++ b/openstack_sdk/src/api/block_storage/v3/capability/get.rs @@ -0,0 +1,174 @@ +// 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`. + +//! Return capabilities list of given backend. +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use crate::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// id parameter for /v3/capabilities/{id} API + /// + #[builder(default, setter(into))] + id: Cow<'a, str>, + + #[builder(setter(name = "_headers"), default, private)] + _headers: Option, +} +impl<'a> Request<'a> { + /// Create a builder for the endpoint. + pub fn builder() -> RequestBuilder<'a> { + RequestBuilder::default() + } +} + +impl<'a> RequestBuilder<'a> { + /// Add a single header to the Capability. + pub fn header(&mut self, header_name: &'static str, header_value: &'static str) -> &mut Self +where { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name, HeaderValue::from_static(header_value)); + self + } + + /// Add multiple headers. + pub fn headers(&mut self, iter: I) -> &mut Self + where + I: Iterator, + T: Into<(Option, HeaderValue)>, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .extend(iter.map(Into::into)); + self + } +} + +impl<'a> RestEndpoint for Request<'a> { + fn method(&self) -> http::Method { + http::Method::GET + } + + fn endpoint(&self) -> Cow<'static, str> { + format!("capabilities/{id}", id = self.id.as_ref(),).into() + } + + fn parameters(&self) -> QueryParams { + QueryParams::default() + } + + fn service_type(&self) -> ServiceType { + ServiceType::BlockStorage + } + + fn response_key(&self) -> Option> { + None + } + + /// Returns headers to be set into the request + fn request_headers(&self) -> Option<&HeaderMap> { + self._headers.as_ref() + } + + /// Returns required API version + fn api_version(&self) -> Option { + Some(ApiVersion::new(3, 0)) + } +} + +#[cfg(test)] +mod tests { + #![allow(unused_imports)] + use super::*; + #[cfg(feature = "sync")] + use crate::api::Query; + #[cfg(feature = "sync")] + use crate::test::client::MockServerClient; + use crate::types::ServiceType; + use http::{HeaderName, HeaderValue}; + use serde_json::json; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::BlockStorage + ); + } + + #[test] + fn test_response_key() { + assert!(Request::builder().build().unwrap().response_key().is_none()) + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let client = MockServerClient::new(); + let mock = client.server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path(format!("/capabilities/{id}", id = "id",)); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "dummy": {} })); + }); + + let endpoint = Request::builder().id("id").build().unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let client = MockServerClient::new(); + let mock = client.server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path(format!("/capabilities/{id}", id = "id",)) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "dummy": {} })); + }); + + let endpoint = Request::builder() + .id("id") + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header("not_foo", "not_bar") + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/openstack_sdk/src/api/block_storage/v3/cgsnapshot.rs b/openstack_sdk/src/api/block_storage/v3/cgsnapshot.rs new file mode 100644 index 000000000..fcc707c3e --- /dev/null +++ b/openstack_sdk/src/api/block_storage/v3/cgsnapshot.rs @@ -0,0 +1,23 @@ +// 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/cgsnapshots/detail` REST operations of block_storage +pub mod create; +pub mod delete; +pub mod get; +pub mod list; +pub mod list_detailed; diff --git a/openstack_sdk/src/api/block_storage/v3/cgsnapshot/create.rs b/openstack_sdk/src/api/block_storage/v3/cgsnapshot/create.rs new file mode 100644 index 000000000..31143b645 --- /dev/null +++ b/openstack_sdk/src/api/block_storage/v3/cgsnapshot/create.rs @@ -0,0 +1,194 @@ +// 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 a new cgsnapshot. +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use crate::api::rest_endpoint_prelude::*; + +use serde_json::Value; +use std::collections::BTreeMap; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + #[builder(setter(name = "_headers"), default, private)] + _headers: Option, + + #[builder(setter(name = "_properties"), default, private)] + _properties: BTreeMap, Value>, +} +impl<'a> Request<'a> { + /// Create a builder for the endpoint. + pub fn builder() -> RequestBuilder<'a> { + RequestBuilder::default() + } +} + +impl<'a> RequestBuilder<'a> { + /// Add a single header to the Cgsnapshot. + pub fn header(&mut self, header_name: &'static str, header_value: &'static str) -> &mut Self +where { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name, HeaderValue::from_static(header_value)); + self + } + + /// Add multiple headers. + pub fn headers(&mut self, iter: I) -> &mut Self + where + I: Iterator, + T: Into<(Option, HeaderValue)>, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .extend(iter.map(Into::into)); + self + } + + pub fn properties(&mut self, iter: I) -> &mut Self + where + I: Iterator, + K: Into>, + V: Into, + { + self._properties + .get_or_insert_with(BTreeMap::new) + .extend(iter.map(|(k, v)| (k.into(), v.into()))); + self + } +} + +impl<'a> RestEndpoint for Request<'a> { + fn method(&self) -> http::Method { + http::Method::POST + } + + fn endpoint(&self) -> Cow<'static, str> { + "cgsnapshots".to_string().into() + } + + fn parameters(&self) -> QueryParams { + QueryParams::default() + } + + fn body(&self) -> Result)>, BodyError> { + let mut params = JsonBodyParams::default(); + + for (key, val) in &self._properties { + params.push(key.clone(), val.clone()); + } + + params.into_body() + } + + fn service_type(&self) -> ServiceType { + ServiceType::BlockStorage + } + + fn response_key(&self) -> Option> { + None + } + + /// Returns headers to be set into the request + fn request_headers(&self) -> Option<&HeaderMap> { + self._headers.as_ref() + } + + /// Returns required API version + fn api_version(&self) -> Option { + Some(ApiVersion::new(3, 0)) + } +} + +#[cfg(test)] +mod tests { + #![allow(unused_imports)] + use super::*; + #[cfg(feature = "sync")] + use crate::api::Query; + #[cfg(feature = "sync")] + use crate::test::client::MockServerClient; + use crate::types::ServiceType; + use http::{HeaderName, HeaderValue}; + use serde_json::json; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::BlockStorage + ); + } + + #[test] + fn test_response_key() { + assert!(Request::builder().build().unwrap().response_key().is_none()) + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let client = MockServerClient::new(); + let mock = client.server.mock(|when, then| { + when.method(httpmock::Method::POST) + .path("/cgsnapshots".to_string()); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "dummy": {} })); + }); + + let endpoint = Request::builder().build().unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let client = MockServerClient::new(); + let mock = client.server.mock(|when, then| { + when.method(httpmock::Method::POST) + .path("/cgsnapshots".to_string()) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "dummy": {} })); + }); + + let endpoint = Request::builder() + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header("not_foo", "not_bar") + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/openstack_sdk/src/api/block_storage/v3/cgsnapshot/delete.rs b/openstack_sdk/src/api/block_storage/v3/cgsnapshot/delete.rs new file mode 100644 index 000000000..c546b7bf1 --- /dev/null +++ b/openstack_sdk/src/api/block_storage/v3/cgsnapshot/delete.rs @@ -0,0 +1,174 @@ +// 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 a cgsnapshot. +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use crate::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// id parameter for /v3/cgsnapshots/{id} API + /// + #[builder(default, setter(into))] + id: Cow<'a, str>, + + #[builder(setter(name = "_headers"), default, private)] + _headers: Option, +} +impl<'a> Request<'a> { + /// Create a builder for the endpoint. + pub fn builder() -> RequestBuilder<'a> { + RequestBuilder::default() + } +} + +impl<'a> RequestBuilder<'a> { + /// Add a single header to the Cgsnapshot. + pub fn header(&mut self, header_name: &'static str, header_value: &'static str) -> &mut Self +where { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name, HeaderValue::from_static(header_value)); + self + } + + /// Add multiple headers. + pub fn headers(&mut self, iter: I) -> &mut Self + where + I: Iterator, + T: Into<(Option, HeaderValue)>, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .extend(iter.map(Into::into)); + self + } +} + +impl<'a> RestEndpoint for Request<'a> { + fn method(&self) -> http::Method { + http::Method::DELETE + } + + fn endpoint(&self) -> Cow<'static, str> { + format!("cgsnapshots/{id}", id = self.id.as_ref(),).into() + } + + fn parameters(&self) -> QueryParams { + QueryParams::default() + } + + fn service_type(&self) -> ServiceType { + ServiceType::BlockStorage + } + + fn response_key(&self) -> Option> { + None + } + + /// Returns headers to be set into the request + fn request_headers(&self) -> Option<&HeaderMap> { + self._headers.as_ref() + } + + /// Returns required API version + fn api_version(&self) -> Option { + Some(ApiVersion::new(3, 0)) + } +} + +#[cfg(test)] +mod tests { + #![allow(unused_imports)] + use super::*; + #[cfg(feature = "sync")] + use crate::api::Query; + #[cfg(feature = "sync")] + use crate::test::client::MockServerClient; + use crate::types::ServiceType; + use http::{HeaderName, HeaderValue}; + use serde_json::json; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::BlockStorage + ); + } + + #[test] + fn test_response_key() { + assert!(Request::builder().build().unwrap().response_key().is_none()) + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let client = MockServerClient::new(); + let mock = client.server.mock(|when, then| { + when.method(httpmock::Method::DELETE) + .path(format!("/cgsnapshots/{id}", id = "id",)); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "dummy": {} })); + }); + + let endpoint = Request::builder().id("id").build().unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let client = MockServerClient::new(); + let mock = client.server.mock(|when, then| { + when.method(httpmock::Method::DELETE) + .path(format!("/cgsnapshots/{id}", id = "id",)) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "dummy": {} })); + }); + + let endpoint = Request::builder() + .id("id") + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header("not_foo", "not_bar") + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/openstack_sdk/src/api/block_storage/v3/cgsnapshot/get.rs b/openstack_sdk/src/api/block_storage/v3/cgsnapshot/get.rs new file mode 100644 index 000000000..9d3548746 --- /dev/null +++ b/openstack_sdk/src/api/block_storage/v3/cgsnapshot/get.rs @@ -0,0 +1,174 @@ +// 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`. + +//! Return data about the given cgsnapshot. +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use crate::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// id parameter for /v3/cgsnapshots/{id} API + /// + #[builder(default, setter(into))] + id: Cow<'a, str>, + + #[builder(setter(name = "_headers"), default, private)] + _headers: Option, +} +impl<'a> Request<'a> { + /// Create a builder for the endpoint. + pub fn builder() -> RequestBuilder<'a> { + RequestBuilder::default() + } +} + +impl<'a> RequestBuilder<'a> { + /// Add a single header to the Cgsnapshot. + pub fn header(&mut self, header_name: &'static str, header_value: &'static str) -> &mut Self +where { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name, HeaderValue::from_static(header_value)); + self + } + + /// Add multiple headers. + pub fn headers(&mut self, iter: I) -> &mut Self + where + I: Iterator, + T: Into<(Option, HeaderValue)>, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .extend(iter.map(Into::into)); + self + } +} + +impl<'a> RestEndpoint for Request<'a> { + fn method(&self) -> http::Method { + http::Method::GET + } + + fn endpoint(&self) -> Cow<'static, str> { + format!("cgsnapshots/{id}", id = self.id.as_ref(),).into() + } + + fn parameters(&self) -> QueryParams { + QueryParams::default() + } + + fn service_type(&self) -> ServiceType { + ServiceType::BlockStorage + } + + fn response_key(&self) -> Option> { + None + } + + /// Returns headers to be set into the request + fn request_headers(&self) -> Option<&HeaderMap> { + self._headers.as_ref() + } + + /// Returns required API version + fn api_version(&self) -> Option { + Some(ApiVersion::new(3, 0)) + } +} + +#[cfg(test)] +mod tests { + #![allow(unused_imports)] + use super::*; + #[cfg(feature = "sync")] + use crate::api::Query; + #[cfg(feature = "sync")] + use crate::test::client::MockServerClient; + use crate::types::ServiceType; + use http::{HeaderName, HeaderValue}; + use serde_json::json; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::BlockStorage + ); + } + + #[test] + fn test_response_key() { + assert!(Request::builder().build().unwrap().response_key().is_none()) + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let client = MockServerClient::new(); + let mock = client.server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path(format!("/cgsnapshots/{id}", id = "id",)); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "dummy": {} })); + }); + + let endpoint = Request::builder().id("id").build().unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let client = MockServerClient::new(); + let mock = client.server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path(format!("/cgsnapshots/{id}", id = "id",)) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "dummy": {} })); + }); + + let endpoint = Request::builder() + .id("id") + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header("not_foo", "not_bar") + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/openstack_sdk/src/api/block_storage/v3/cgsnapshot/list.rs b/openstack_sdk/src/api/block_storage/v3/cgsnapshot/list.rs new file mode 100644 index 000000000..83b9903b9 --- /dev/null +++ b/openstack_sdk/src/api/block_storage/v3/cgsnapshot/list.rs @@ -0,0 +1,166 @@ +// 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`. + +//! Returns a summary list of cgsnapshots. +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use crate::api::rest_endpoint_prelude::*; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request { + #[builder(setter(name = "_headers"), default, private)] + _headers: Option, +} +impl Request { + /// Create a builder for the endpoint. + pub fn builder() -> RequestBuilder { + RequestBuilder::default() + } +} + +impl RequestBuilder { + /// Add a single header to the Cgsnapshot. + pub fn header(&mut self, header_name: &'static str, header_value: &'static str) -> &mut Self +where { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name, HeaderValue::from_static(header_value)); + self + } + + /// Add multiple headers. + pub fn headers(&mut self, iter: I) -> &mut Self + where + I: Iterator, + T: Into<(Option, HeaderValue)>, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .extend(iter.map(Into::into)); + self + } +} + +impl RestEndpoint for Request { + fn method(&self) -> http::Method { + http::Method::GET + } + + fn endpoint(&self) -> Cow<'static, str> { + "cgsnapshots".to_string().into() + } + + fn parameters(&self) -> QueryParams { + QueryParams::default() + } + + fn service_type(&self) -> ServiceType { + ServiceType::BlockStorage + } + + fn response_key(&self) -> Option> { + None + } + + /// Returns headers to be set into the request + fn request_headers(&self) -> Option<&HeaderMap> { + self._headers.as_ref() + } + + /// Returns required API version + fn api_version(&self) -> Option { + Some(ApiVersion::new(3, 0)) + } +} + +#[cfg(test)] +mod tests { + #![allow(unused_imports)] + use super::*; + #[cfg(feature = "sync")] + use crate::api::Query; + #[cfg(feature = "sync")] + use crate::test::client::MockServerClient; + use crate::types::ServiceType; + use http::{HeaderName, HeaderValue}; + use serde_json::json; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::BlockStorage + ); + } + + #[test] + fn test_response_key() { + assert!(Request::builder().build().unwrap().response_key().is_none()) + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let client = MockServerClient::new(); + let mock = client.server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path("/cgsnapshots".to_string()); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "dummy": {} })); + }); + + let endpoint = Request::builder().build().unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let client = MockServerClient::new(); + let mock = client.server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path("/cgsnapshots".to_string()) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "dummy": {} })); + }); + + let endpoint = Request::builder() + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header("not_foo", "not_bar") + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/openstack_sdk/src/api/block_storage/v3/cgsnapshot/list_detailed.rs b/openstack_sdk/src/api/block_storage/v3/cgsnapshot/list_detailed.rs new file mode 100644 index 000000000..ff30d7530 --- /dev/null +++ b/openstack_sdk/src/api/block_storage/v3/cgsnapshot/list_detailed.rs @@ -0,0 +1,166 @@ +// 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`. + +//! Returns a detailed list of cgsnapshots. +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use crate::api::rest_endpoint_prelude::*; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request { + #[builder(setter(name = "_headers"), default, private)] + _headers: Option, +} +impl Request { + /// Create a builder for the endpoint. + pub fn builder() -> RequestBuilder { + RequestBuilder::default() + } +} + +impl RequestBuilder { + /// Add a single header to the Cgsnapshot. + pub fn header(&mut self, header_name: &'static str, header_value: &'static str) -> &mut Self +where { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name, HeaderValue::from_static(header_value)); + self + } + + /// Add multiple headers. + pub fn headers(&mut self, iter: I) -> &mut Self + where + I: Iterator, + T: Into<(Option, HeaderValue)>, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .extend(iter.map(Into::into)); + self + } +} + +impl RestEndpoint for Request { + fn method(&self) -> http::Method { + http::Method::GET + } + + fn endpoint(&self) -> Cow<'static, str> { + "cgsnapshots/detail".to_string().into() + } + + fn parameters(&self) -> QueryParams { + QueryParams::default() + } + + fn service_type(&self) -> ServiceType { + ServiceType::BlockStorage + } + + fn response_key(&self) -> Option> { + None + } + + /// Returns headers to be set into the request + fn request_headers(&self) -> Option<&HeaderMap> { + self._headers.as_ref() + } + + /// Returns required API version + fn api_version(&self) -> Option { + Some(ApiVersion::new(3, 0)) + } +} + +#[cfg(test)] +mod tests { + #![allow(unused_imports)] + use super::*; + #[cfg(feature = "sync")] + use crate::api::Query; + #[cfg(feature = "sync")] + use crate::test::client::MockServerClient; + use crate::types::ServiceType; + use http::{HeaderName, HeaderValue}; + use serde_json::json; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::BlockStorage + ); + } + + #[test] + fn test_response_key() { + assert!(Request::builder().build().unwrap().response_key().is_none()) + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let client = MockServerClient::new(); + let mock = client.server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path("/cgsnapshots/detail".to_string()); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "dummy": {} })); + }); + + let endpoint = Request::builder().build().unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let client = MockServerClient::new(); + let mock = client.server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path("/cgsnapshots/detail".to_string()) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "dummy": {} })); + }); + + let endpoint = Request::builder() + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header("not_foo", "not_bar") + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/openstack_sdk/src/api/block_storage/v3/consistencygroup.rs b/openstack_sdk/src/api/block_storage/v3/consistencygroup.rs new file mode 100644 index 000000000..2e9cbca8c --- /dev/null +++ b/openstack_sdk/src/api/block_storage/v3/consistencygroup.rs @@ -0,0 +1,25 @@ +// 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/consistencygroups/detail` REST operations of block_storage +pub mod create; +pub mod create_from_src; +pub mod delete; +pub mod get; +pub mod list; +pub mod list_detailed; +pub mod set; diff --git a/openstack_sdk/src/api/block_storage/v3/consistencygroup/create.rs b/openstack_sdk/src/api/block_storage/v3/consistencygroup/create.rs new file mode 100644 index 000000000..92eae5f93 --- /dev/null +++ b/openstack_sdk/src/api/block_storage/v3/consistencygroup/create.rs @@ -0,0 +1,194 @@ +// 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 a new consistency group. +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use crate::api::rest_endpoint_prelude::*; + +use serde_json::Value; +use std::collections::BTreeMap; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + #[builder(setter(name = "_headers"), default, private)] + _headers: Option, + + #[builder(setter(name = "_properties"), default, private)] + _properties: BTreeMap, Value>, +} +impl<'a> Request<'a> { + /// Create a builder for the endpoint. + pub fn builder() -> RequestBuilder<'a> { + RequestBuilder::default() + } +} + +impl<'a> RequestBuilder<'a> { + /// Add a single header to the Consistencygroup. + pub fn header(&mut self, header_name: &'static str, header_value: &'static str) -> &mut Self +where { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name, HeaderValue::from_static(header_value)); + self + } + + /// Add multiple headers. + pub fn headers(&mut self, iter: I) -> &mut Self + where + I: Iterator, + T: Into<(Option, HeaderValue)>, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .extend(iter.map(Into::into)); + self + } + + pub fn properties(&mut self, iter: I) -> &mut Self + where + I: Iterator, + K: Into>, + V: Into, + { + self._properties + .get_or_insert_with(BTreeMap::new) + .extend(iter.map(|(k, v)| (k.into(), v.into()))); + self + } +} + +impl<'a> RestEndpoint for Request<'a> { + fn method(&self) -> http::Method { + http::Method::POST + } + + fn endpoint(&self) -> Cow<'static, str> { + "consistencygroups".to_string().into() + } + + fn parameters(&self) -> QueryParams { + QueryParams::default() + } + + fn body(&self) -> Result)>, BodyError> { + let mut params = JsonBodyParams::default(); + + for (key, val) in &self._properties { + params.push(key.clone(), val.clone()); + } + + params.into_body() + } + + fn service_type(&self) -> ServiceType { + ServiceType::BlockStorage + } + + fn response_key(&self) -> Option> { + None + } + + /// Returns headers to be set into the request + fn request_headers(&self) -> Option<&HeaderMap> { + self._headers.as_ref() + } + + /// Returns required API version + fn api_version(&self) -> Option { + Some(ApiVersion::new(3, 0)) + } +} + +#[cfg(test)] +mod tests { + #![allow(unused_imports)] + use super::*; + #[cfg(feature = "sync")] + use crate::api::Query; + #[cfg(feature = "sync")] + use crate::test::client::MockServerClient; + use crate::types::ServiceType; + use http::{HeaderName, HeaderValue}; + use serde_json::json; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::BlockStorage + ); + } + + #[test] + fn test_response_key() { + assert!(Request::builder().build().unwrap().response_key().is_none()) + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let client = MockServerClient::new(); + let mock = client.server.mock(|when, then| { + when.method(httpmock::Method::POST) + .path("/consistencygroups".to_string()); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "dummy": {} })); + }); + + let endpoint = Request::builder().build().unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let client = MockServerClient::new(); + let mock = client.server.mock(|when, then| { + when.method(httpmock::Method::POST) + .path("/consistencygroups".to_string()) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "dummy": {} })); + }); + + let endpoint = Request::builder() + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header("not_foo", "not_bar") + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/openstack_sdk/src/api/block_storage/v3/consistencygroup/create_from_src.rs b/openstack_sdk/src/api/block_storage/v3/consistencygroup/create_from_src.rs new file mode 100644 index 000000000..d13ff605d --- /dev/null +++ b/openstack_sdk/src/api/block_storage/v3/consistencygroup/create_from_src.rs @@ -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/consistencygroups/create_from_src` REST operations of block_storage +pub mod create; diff --git a/openstack_sdk/src/api/block_storage/v3/consistencygroup/create_from_src/create.rs b/openstack_sdk/src/api/block_storage/v3/consistencygroup/create_from_src/create.rs new file mode 100644 index 000000000..0e417d5fe --- /dev/null +++ b/openstack_sdk/src/api/block_storage/v3/consistencygroup/create_from_src/create.rs @@ -0,0 +1,197 @@ +// 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 a new consistency group from a source. +//! +//! The source can be a CG snapshot or a CG. Note that this does not require +//! volume_types as the "create" API above. +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use crate::api::rest_endpoint_prelude::*; + +use serde_json::Value; +use std::collections::BTreeMap; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + #[builder(setter(name = "_headers"), default, private)] + _headers: Option, + + #[builder(setter(name = "_properties"), default, private)] + _properties: BTreeMap, Value>, +} +impl<'a> Request<'a> { + /// Create a builder for the endpoint. + pub fn builder() -> RequestBuilder<'a> { + RequestBuilder::default() + } +} + +impl<'a> RequestBuilder<'a> { + /// Add a single header to the Create_From_Src. + pub fn header(&mut self, header_name: &'static str, header_value: &'static str) -> &mut Self +where { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name, HeaderValue::from_static(header_value)); + self + } + + /// Add multiple headers. + pub fn headers(&mut self, iter: I) -> &mut Self + where + I: Iterator, + T: Into<(Option, HeaderValue)>, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .extend(iter.map(Into::into)); + self + } + + pub fn properties(&mut self, iter: I) -> &mut Self + where + I: Iterator, + K: Into>, + V: Into, + { + self._properties + .get_or_insert_with(BTreeMap::new) + .extend(iter.map(|(k, v)| (k.into(), v.into()))); + self + } +} + +impl<'a> RestEndpoint for Request<'a> { + fn method(&self) -> http::Method { + http::Method::POST + } + + fn endpoint(&self) -> Cow<'static, str> { + "consistencygroups/create_from_src".to_string().into() + } + + fn parameters(&self) -> QueryParams { + QueryParams::default() + } + + fn body(&self) -> Result)>, BodyError> { + let mut params = JsonBodyParams::default(); + + for (key, val) in &self._properties { + params.push(key.clone(), val.clone()); + } + + params.into_body() + } + + fn service_type(&self) -> ServiceType { + ServiceType::BlockStorage + } + + fn response_key(&self) -> Option> { + None + } + + /// Returns headers to be set into the request + fn request_headers(&self) -> Option<&HeaderMap> { + self._headers.as_ref() + } + + /// Returns required API version + fn api_version(&self) -> Option { + Some(ApiVersion::new(3, 0)) + } +} + +#[cfg(test)] +mod tests { + #![allow(unused_imports)] + use super::*; + #[cfg(feature = "sync")] + use crate::api::Query; + #[cfg(feature = "sync")] + use crate::test::client::MockServerClient; + use crate::types::ServiceType; + use http::{HeaderName, HeaderValue}; + use serde_json::json; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::BlockStorage + ); + } + + #[test] + fn test_response_key() { + assert!(Request::builder().build().unwrap().response_key().is_none()) + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let client = MockServerClient::new(); + let mock = client.server.mock(|when, then| { + when.method(httpmock::Method::POST) + .path("/consistencygroups/create_from_src".to_string()); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "dummy": {} })); + }); + + let endpoint = Request::builder().build().unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let client = MockServerClient::new(); + let mock = client.server.mock(|when, then| { + when.method(httpmock::Method::POST) + .path("/consistencygroups/create_from_src".to_string()) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "dummy": {} })); + }); + + let endpoint = Request::builder() + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header("not_foo", "not_bar") + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/openstack_sdk/src/api/block_storage/v3/consistencygroup/delete.rs b/openstack_sdk/src/api/block_storage/v3/consistencygroup/delete.rs new file mode 100644 index 000000000..a1e31206c --- /dev/null +++ b/openstack_sdk/src/api/block_storage/v3/consistencygroup/delete.rs @@ -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/consistencygroups/{id}/delete` REST operations of block_storage +pub mod create; diff --git a/openstack_sdk/src/api/block_storage/v3/consistencygroup/delete/create.rs b/openstack_sdk/src/api/block_storage/v3/consistencygroup/delete/create.rs new file mode 100644 index 000000000..b53b4ee75 --- /dev/null +++ b/openstack_sdk/src/api/block_storage/v3/consistencygroup/delete/create.rs @@ -0,0 +1,201 @@ +// 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 a consistency group. +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use crate::api::rest_endpoint_prelude::*; + +use serde_json::Value; +use std::borrow::Cow; +use std::collections::BTreeMap; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// id parameter for /v3/consistencygroups/{id}/delete API + /// + #[builder(default, setter(into))] + id: Cow<'a, str>, + + #[builder(setter(name = "_headers"), default, private)] + _headers: Option, + + #[builder(setter(name = "_properties"), default, private)] + _properties: BTreeMap, Value>, +} +impl<'a> Request<'a> { + /// Create a builder for the endpoint. + pub fn builder() -> RequestBuilder<'a> { + RequestBuilder::default() + } +} + +impl<'a> RequestBuilder<'a> { + /// Add a single header to the Delete. + pub fn header(&mut self, header_name: &'static str, header_value: &'static str) -> &mut Self +where { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name, HeaderValue::from_static(header_value)); + self + } + + /// Add multiple headers. + pub fn headers(&mut self, iter: I) -> &mut Self + where + I: Iterator, + T: Into<(Option, HeaderValue)>, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .extend(iter.map(Into::into)); + self + } + + pub fn properties(&mut self, iter: I) -> &mut Self + where + I: Iterator, + K: Into>, + V: Into, + { + self._properties + .get_or_insert_with(BTreeMap::new) + .extend(iter.map(|(k, v)| (k.into(), v.into()))); + self + } +} + +impl<'a> RestEndpoint for Request<'a> { + fn method(&self) -> http::Method { + http::Method::POST + } + + fn endpoint(&self) -> Cow<'static, str> { + format!("consistencygroups/{id}/delete", id = self.id.as_ref(),).into() + } + + fn parameters(&self) -> QueryParams { + QueryParams::default() + } + + fn body(&self) -> Result)>, BodyError> { + let mut params = JsonBodyParams::default(); + + for (key, val) in &self._properties { + params.push(key.clone(), val.clone()); + } + + params.into_body() + } + + fn service_type(&self) -> ServiceType { + ServiceType::BlockStorage + } + + fn response_key(&self) -> Option> { + None + } + + /// Returns headers to be set into the request + fn request_headers(&self) -> Option<&HeaderMap> { + self._headers.as_ref() + } + + /// Returns required API version + fn api_version(&self) -> Option { + Some(ApiVersion::new(3, 0)) + } +} + +#[cfg(test)] +mod tests { + #![allow(unused_imports)] + use super::*; + #[cfg(feature = "sync")] + use crate::api::Query; + #[cfg(feature = "sync")] + use crate::test::client::MockServerClient; + use crate::types::ServiceType; + use http::{HeaderName, HeaderValue}; + use serde_json::json; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::BlockStorage + ); + } + + #[test] + fn test_response_key() { + assert!(Request::builder().build().unwrap().response_key().is_none()) + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let client = MockServerClient::new(); + let mock = client.server.mock(|when, then| { + when.method(httpmock::Method::POST) + .path(format!("/consistencygroups/{id}/delete", id = "id",)); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "dummy": {} })); + }); + + let endpoint = Request::builder().id("id").build().unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let client = MockServerClient::new(); + let mock = client.server.mock(|when, then| { + when.method(httpmock::Method::POST) + .path(format!("/consistencygroups/{id}/delete", id = "id",)) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "dummy": {} })); + }); + + let endpoint = Request::builder() + .id("id") + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header("not_foo", "not_bar") + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/openstack_sdk/src/api/block_storage/v3/consistencygroup/get.rs b/openstack_sdk/src/api/block_storage/v3/consistencygroup/get.rs new file mode 100644 index 000000000..65ab3a409 --- /dev/null +++ b/openstack_sdk/src/api/block_storage/v3/consistencygroup/get.rs @@ -0,0 +1,174 @@ +// 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`. + +//! Return data about the given consistency group. +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use crate::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// id parameter for /v3/consistencygroups/{id} API + /// + #[builder(default, setter(into))] + id: Cow<'a, str>, + + #[builder(setter(name = "_headers"), default, private)] + _headers: Option, +} +impl<'a> Request<'a> { + /// Create a builder for the endpoint. + pub fn builder() -> RequestBuilder<'a> { + RequestBuilder::default() + } +} + +impl<'a> RequestBuilder<'a> { + /// Add a single header to the Consistencygroup. + pub fn header(&mut self, header_name: &'static str, header_value: &'static str) -> &mut Self +where { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name, HeaderValue::from_static(header_value)); + self + } + + /// Add multiple headers. + pub fn headers(&mut self, iter: I) -> &mut Self + where + I: Iterator, + T: Into<(Option, HeaderValue)>, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .extend(iter.map(Into::into)); + self + } +} + +impl<'a> RestEndpoint for Request<'a> { + fn method(&self) -> http::Method { + http::Method::GET + } + + fn endpoint(&self) -> Cow<'static, str> { + format!("consistencygroups/{id}", id = self.id.as_ref(),).into() + } + + fn parameters(&self) -> QueryParams { + QueryParams::default() + } + + fn service_type(&self) -> ServiceType { + ServiceType::BlockStorage + } + + fn response_key(&self) -> Option> { + None + } + + /// Returns headers to be set into the request + fn request_headers(&self) -> Option<&HeaderMap> { + self._headers.as_ref() + } + + /// Returns required API version + fn api_version(&self) -> Option { + Some(ApiVersion::new(3, 0)) + } +} + +#[cfg(test)] +mod tests { + #![allow(unused_imports)] + use super::*; + #[cfg(feature = "sync")] + use crate::api::Query; + #[cfg(feature = "sync")] + use crate::test::client::MockServerClient; + use crate::types::ServiceType; + use http::{HeaderName, HeaderValue}; + use serde_json::json; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::BlockStorage + ); + } + + #[test] + fn test_response_key() { + assert!(Request::builder().build().unwrap().response_key().is_none()) + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let client = MockServerClient::new(); + let mock = client.server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path(format!("/consistencygroups/{id}", id = "id",)); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "dummy": {} })); + }); + + let endpoint = Request::builder().id("id").build().unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let client = MockServerClient::new(); + let mock = client.server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path(format!("/consistencygroups/{id}", id = "id",)) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "dummy": {} })); + }); + + let endpoint = Request::builder() + .id("id") + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header("not_foo", "not_bar") + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/openstack_sdk/src/api/block_storage/v3/consistencygroup/list.rs b/openstack_sdk/src/api/block_storage/v3/consistencygroup/list.rs new file mode 100644 index 000000000..789d42cd8 --- /dev/null +++ b/openstack_sdk/src/api/block_storage/v3/consistencygroup/list.rs @@ -0,0 +1,166 @@ +// 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`. + +//! Returns a summary list of consistency groups. +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use crate::api::rest_endpoint_prelude::*; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request { + #[builder(setter(name = "_headers"), default, private)] + _headers: Option, +} +impl Request { + /// Create a builder for the endpoint. + pub fn builder() -> RequestBuilder { + RequestBuilder::default() + } +} + +impl RequestBuilder { + /// Add a single header to the Consistencygroup. + pub fn header(&mut self, header_name: &'static str, header_value: &'static str) -> &mut Self +where { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name, HeaderValue::from_static(header_value)); + self + } + + /// Add multiple headers. + pub fn headers(&mut self, iter: I) -> &mut Self + where + I: Iterator, + T: Into<(Option, HeaderValue)>, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .extend(iter.map(Into::into)); + self + } +} + +impl RestEndpoint for Request { + fn method(&self) -> http::Method { + http::Method::GET + } + + fn endpoint(&self) -> Cow<'static, str> { + "consistencygroups".to_string().into() + } + + fn parameters(&self) -> QueryParams { + QueryParams::default() + } + + fn service_type(&self) -> ServiceType { + ServiceType::BlockStorage + } + + fn response_key(&self) -> Option> { + None + } + + /// Returns headers to be set into the request + fn request_headers(&self) -> Option<&HeaderMap> { + self._headers.as_ref() + } + + /// Returns required API version + fn api_version(&self) -> Option { + Some(ApiVersion::new(3, 0)) + } +} + +#[cfg(test)] +mod tests { + #![allow(unused_imports)] + use super::*; + #[cfg(feature = "sync")] + use crate::api::Query; + #[cfg(feature = "sync")] + use crate::test::client::MockServerClient; + use crate::types::ServiceType; + use http::{HeaderName, HeaderValue}; + use serde_json::json; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::BlockStorage + ); + } + + #[test] + fn test_response_key() { + assert!(Request::builder().build().unwrap().response_key().is_none()) + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let client = MockServerClient::new(); + let mock = client.server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path("/consistencygroups".to_string()); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "dummy": {} })); + }); + + let endpoint = Request::builder().build().unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let client = MockServerClient::new(); + let mock = client.server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path("/consistencygroups".to_string()) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "dummy": {} })); + }); + + let endpoint = Request::builder() + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header("not_foo", "not_bar") + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/openstack_sdk/src/api/block_storage/v3/consistencygroup/list_detailed.rs b/openstack_sdk/src/api/block_storage/v3/consistencygroup/list_detailed.rs new file mode 100644 index 000000000..094c98beb --- /dev/null +++ b/openstack_sdk/src/api/block_storage/v3/consistencygroup/list_detailed.rs @@ -0,0 +1,166 @@ +// 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`. + +//! Returns a detailed list of consistency groups. +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use crate::api::rest_endpoint_prelude::*; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request { + #[builder(setter(name = "_headers"), default, private)] + _headers: Option, +} +impl Request { + /// Create a builder for the endpoint. + pub fn builder() -> RequestBuilder { + RequestBuilder::default() + } +} + +impl RequestBuilder { + /// Add a single header to the Consistencygroup. + pub fn header(&mut self, header_name: &'static str, header_value: &'static str) -> &mut Self +where { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name, HeaderValue::from_static(header_value)); + self + } + + /// Add multiple headers. + pub fn headers(&mut self, iter: I) -> &mut Self + where + I: Iterator, + T: Into<(Option, HeaderValue)>, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .extend(iter.map(Into::into)); + self + } +} + +impl RestEndpoint for Request { + fn method(&self) -> http::Method { + http::Method::GET + } + + fn endpoint(&self) -> Cow<'static, str> { + "consistencygroups/detail".to_string().into() + } + + fn parameters(&self) -> QueryParams { + QueryParams::default() + } + + fn service_type(&self) -> ServiceType { + ServiceType::BlockStorage + } + + fn response_key(&self) -> Option> { + None + } + + /// Returns headers to be set into the request + fn request_headers(&self) -> Option<&HeaderMap> { + self._headers.as_ref() + } + + /// Returns required API version + fn api_version(&self) -> Option { + Some(ApiVersion::new(3, 0)) + } +} + +#[cfg(test)] +mod tests { + #![allow(unused_imports)] + use super::*; + #[cfg(feature = "sync")] + use crate::api::Query; + #[cfg(feature = "sync")] + use crate::test::client::MockServerClient; + use crate::types::ServiceType; + use http::{HeaderName, HeaderValue}; + use serde_json::json; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::BlockStorage + ); + } + + #[test] + fn test_response_key() { + assert!(Request::builder().build().unwrap().response_key().is_none()) + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let client = MockServerClient::new(); + let mock = client.server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path("/consistencygroups/detail".to_string()); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "dummy": {} })); + }); + + let endpoint = Request::builder().build().unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let client = MockServerClient::new(); + let mock = client.server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path("/consistencygroups/detail".to_string()) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "dummy": {} })); + }); + + let endpoint = Request::builder() + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header("not_foo", "not_bar") + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/openstack_sdk/src/api/block_storage/v3/consistencygroup/set.rs b/openstack_sdk/src/api/block_storage/v3/consistencygroup/set.rs new file mode 100644 index 000000000..7cae508b1 --- /dev/null +++ b/openstack_sdk/src/api/block_storage/v3/consistencygroup/set.rs @@ -0,0 +1,217 @@ +// 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`. + +//! Update the consistency group. +//! +//! Expected format of the input parameter 'body': +//! +//! ```text +//! +//! { +//! "consistencygroup": +//! { +//! "name": "my_cg", +//! "description": "My consistency group", +//! "add_volumes": "volume-uuid-1,volume-uuid-2,...", +//! "remove_volumes": "volume-uuid-8,volume-uuid-9,..." +//! } +//! } +//! +//! ``` +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use crate::api::rest_endpoint_prelude::*; + +use serde_json::Value; +use std::borrow::Cow; +use std::collections::BTreeMap; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// id parameter for /v3/consistencygroups/{id}/update API + /// + #[builder(default, setter(into))] + id: Cow<'a, str>, + + #[builder(setter(name = "_headers"), default, private)] + _headers: Option, + + #[builder(setter(name = "_properties"), default, private)] + _properties: BTreeMap, Value>, +} +impl<'a> Request<'a> { + /// Create a builder for the endpoint. + pub fn builder() -> RequestBuilder<'a> { + RequestBuilder::default() + } +} + +impl<'a> RequestBuilder<'a> { + /// Add a single header to the Consistencygroup. + pub fn header(&mut self, header_name: &'static str, header_value: &'static str) -> &mut Self +where { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name, HeaderValue::from_static(header_value)); + self + } + + /// Add multiple headers. + pub fn headers(&mut self, iter: I) -> &mut Self + where + I: Iterator, + T: Into<(Option, HeaderValue)>, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .extend(iter.map(Into::into)); + self + } + + pub fn properties(&mut self, iter: I) -> &mut Self + where + I: Iterator, + K: Into>, + V: Into, + { + self._properties + .get_or_insert_with(BTreeMap::new) + .extend(iter.map(|(k, v)| (k.into(), v.into()))); + self + } +} + +impl<'a> RestEndpoint for Request<'a> { + fn method(&self) -> http::Method { + http::Method::PUT + } + + fn endpoint(&self) -> Cow<'static, str> { + format!("consistencygroups/{id}/update", id = self.id.as_ref(),).into() + } + + fn parameters(&self) -> QueryParams { + QueryParams::default() + } + + fn body(&self) -> Result)>, BodyError> { + let mut params = JsonBodyParams::default(); + + for (key, val) in &self._properties { + params.push(key.clone(), val.clone()); + } + + params.into_body() + } + + fn service_type(&self) -> ServiceType { + ServiceType::BlockStorage + } + + fn response_key(&self) -> Option> { + None + } + + /// Returns headers to be set into the request + fn request_headers(&self) -> Option<&HeaderMap> { + self._headers.as_ref() + } + + /// Returns required API version + fn api_version(&self) -> Option { + Some(ApiVersion::new(3, 0)) + } +} + +#[cfg(test)] +mod tests { + #![allow(unused_imports)] + use super::*; + #[cfg(feature = "sync")] + use crate::api::Query; + #[cfg(feature = "sync")] + use crate::test::client::MockServerClient; + use crate::types::ServiceType; + use http::{HeaderName, HeaderValue}; + use serde_json::json; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::BlockStorage + ); + } + + #[test] + fn test_response_key() { + assert!(Request::builder().build().unwrap().response_key().is_none()) + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let client = MockServerClient::new(); + let mock = client.server.mock(|when, then| { + when.method(httpmock::Method::PUT) + .path(format!("/consistencygroups/{id}/update", id = "id",)); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "dummy": {} })); + }); + + let endpoint = Request::builder().id("id").build().unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let client = MockServerClient::new(); + let mock = client.server.mock(|when, then| { + when.method(httpmock::Method::PUT) + .path(format!("/consistencygroups/{id}/update", id = "id",)) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "dummy": {} })); + }); + + let endpoint = Request::builder() + .id("id") + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header("not_foo", "not_bar") + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/openstack_sdk/src/api/block_storage/v3/manageable_snapshot.rs b/openstack_sdk/src/api/block_storage/v3/manageable_snapshot.rs new file mode 100644 index 000000000..66382ffe9 --- /dev/null +++ b/openstack_sdk/src/api/block_storage/v3/manageable_snapshot.rs @@ -0,0 +1,21 @@ +// 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/manageable_snapshots/detail` REST operations of block_storage +pub mod create; +pub mod get; +pub mod list_detailed; diff --git a/openstack_sdk/src/api/block_storage/v3/manageable_snapshot/create.rs b/openstack_sdk/src/api/block_storage/v3/manageable_snapshot/create.rs new file mode 100644 index 000000000..b9c85cb90 --- /dev/null +++ b/openstack_sdk/src/api/block_storage/v3/manageable_snapshot/create.rs @@ -0,0 +1,326 @@ +// 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`. + +//! Instruct Cinder to manage a storage snapshot object. +//! +//! Manages an existing backend storage snapshot object (e.g. a Linux logical +//! volume or a SAN disk) by creating the Cinder objects required to manage it, +//! and possibly renaming the backend storage snapshot object (driver +//! dependent). +//! +//! From an API perspective, this operation behaves very much like a snapshot +//! creation operation. +//! +//! Required HTTP Body: +//! +//! ```text +//! +//! { +//! "snapshot": +//! { +//! "volume_id": "", +//! "ref": +//! "" +//! } +//! } +//! +//! ``` +//! +//! See the appropriate Cinder drivers' implementations of the manage_snapshot +//! method to find out the accepted format of 'ref'. For example,in LVM driver, +//! it will be the logic volume name of snapshot which you want to manage. +//! +//! This API call will return with an error if any of the above elements are +//! missing from the request, or if the 'volume_id' element refers to a cinder +//! volume that could not be found. +//! +//! The snapshot will later enter the error state if it is discovered that +//! 'ref' is bad. +//! +//! Optional elements to 'snapshot' are: +//! +//! ```text +//! +//! name A name for the new snapshot. +//! description A description for the new snapshot. +//! metadata Key/value pairs to be associated with the new snapshot. +//! +//! ``` +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use crate::api::rest_endpoint_prelude::*; + +use serde::Deserialize; +use serde::Serialize; +use serde_json::Value; +use std::borrow::Cow; +use std::collections::BTreeMap; + +/// A `snapshot` object. +/// +#[derive(Builder, Debug, Deserialize, Clone, Serialize)] +#[builder(setter(strip_option))] +pub struct Snapshot<'a> { + /// A description for the snapshot. Default is `None`. + /// + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) description: Option>>, + + /// One or more metadata key and value pairs for the snapshot. + /// + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, private, setter(name = "_metadata"))] + pub(crate) metadata: Option, Cow<'a, str>>>>, + + /// The name of the snapshot. Default is `None`. + /// + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) name: Option>>, + + /// A reference to the existing volume. The internal structure of this + /// reference depends on the volume driver implementation. For details + /// about the required elements in the structure, see the documentation for + /// the volume driver. + /// + #[serde(rename = "ref")] + #[builder(setter(into))] + pub(crate) _ref: Option, + + /// The UUID of the volume. + /// + #[serde()] + #[builder(setter(into))] + pub(crate) volume_id: Cow<'a, str>, +} + +impl<'a> SnapshotBuilder<'a> { + /// One or more metadata key and value pairs for the snapshot. + /// + pub fn metadata(&mut self, iter: I) -> &mut Self + where + I: Iterator, + K: Into>, + V: Into>, + { + self.metadata + .get_or_insert(None) + .get_or_insert(None) + .get_or_insert_with(BTreeMap::new) + .extend(iter.map(|(k, v)| (k.into(), v.into()))); + self + } +} + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// A `snapshot` object. + /// + #[builder(setter(into))] + pub(crate) snapshot: Snapshot<'a>, + + #[builder(setter(name = "_headers"), default, private)] + _headers: Option, +} +impl<'a> Request<'a> { + /// Create a builder for the endpoint. + pub fn builder() -> RequestBuilder<'a> { + RequestBuilder::default() + } +} + +impl<'a> RequestBuilder<'a> { + /// Add a single header to the Manageable_Snapshot. + pub fn header(&mut self, header_name: &'static str, header_value: &'static str) -> &mut Self +where { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name, HeaderValue::from_static(header_value)); + self + } + + /// Add multiple headers. + pub fn headers(&mut self, iter: I) -> &mut Self + where + I: Iterator, + T: Into<(Option, HeaderValue)>, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .extend(iter.map(Into::into)); + self + } +} + +impl<'a> RestEndpoint for Request<'a> { + fn method(&self) -> http::Method { + http::Method::POST + } + + fn endpoint(&self) -> Cow<'static, str> { + "manageable_snapshots".to_string().into() + } + + fn parameters(&self) -> QueryParams { + QueryParams::default() + } + + fn body(&self) -> Result)>, BodyError> { + let mut params = JsonBodyParams::default(); + + params.push("snapshot", serde_json::to_value(&self.snapshot)?); + + params.into_body() + } + + fn service_type(&self) -> ServiceType { + ServiceType::BlockStorage + } + + fn response_key(&self) -> Option> { + Some("snapshot".into()) + } + + /// Returns headers to be set into the request + fn request_headers(&self) -> Option<&HeaderMap> { + self._headers.as_ref() + } + + /// Returns required API version + fn api_version(&self) -> Option { + Some(ApiVersion::new(3, 0)) + } +} + +#[cfg(test)] +mod tests { + #![allow(unused_imports)] + use super::*; + #[cfg(feature = "sync")] + use crate::api::Query; + #[cfg(feature = "sync")] + use crate::test::client::MockServerClient; + use crate::types::ServiceType; + use http::{HeaderName, HeaderValue}; + use serde_json::json; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder() + .snapshot( + SnapshotBuilder::default() + ._ref(json!({})) + .volume_id("foo") + .build() + .unwrap() + ) + .build() + .unwrap() + .service_type(), + ServiceType::BlockStorage + ); + } + + #[test] + fn test_response_key() { + assert_eq!( + Request::builder() + .snapshot( + SnapshotBuilder::default() + ._ref(json!({})) + .volume_id("foo") + .build() + .unwrap() + ) + .build() + .unwrap() + .response_key() + .unwrap(), + "snapshot" + ); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let client = MockServerClient::new(); + let mock = client.server.mock(|when, then| { + when.method(httpmock::Method::POST) + .path("/manageable_snapshots".to_string()); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "snapshot": {} })); + }); + + let endpoint = Request::builder() + .snapshot( + SnapshotBuilder::default() + ._ref(json!({})) + .volume_id("foo") + .build() + .unwrap(), + ) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let client = MockServerClient::new(); + let mock = client.server.mock(|when, then| { + when.method(httpmock::Method::POST) + .path("/manageable_snapshots".to_string()) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "snapshot": {} })); + }); + + let endpoint = Request::builder() + .snapshot( + SnapshotBuilder::default() + ._ref(json!({})) + .volume_id("foo") + .build() + .unwrap(), + ) + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header("not_foo", "not_bar") + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/openstack_sdk/src/api/block_storage/v3/manageable_snapshot/get.rs b/openstack_sdk/src/api/block_storage/v3/manageable_snapshot/get.rs new file mode 100644 index 000000000..4e0a45e78 --- /dev/null +++ b/openstack_sdk/src/api/block_storage/v3/manageable_snapshot/get.rs @@ -0,0 +1,221 @@ +// 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`. + +//! Returns a summary list of volumes available to manage. +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use crate::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +use crate::api::Pageable; +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// Requests a page size of items. Returns a number of items up to a limit + /// value. Use the limit parameter to make an initial limited request and + /// use the ID of the last-seen item from the response as the marker + /// parameter value in a subsequent limited request. + /// + #[builder(default)] + limit: Option, + + /// The ID of the last-seen item. Use the limit parameter to make an + /// initial limited request and use the ID of the last-seen item from the + /// response as the marker parameter value in a subsequent limited request. + /// + #[builder(default, setter(into))] + marker: Option>, + + /// Used in conjunction with limit to return a slice of items. offset is + /// where to start in the list. + /// + #[builder(default)] + offset: Option, + + /// Comma-separated list of sort keys and optional sort directions in the + /// form of \< key > \[: \< direction > \]. A valid direction is asc + /// (ascending) or desc (descending). + /// + #[builder(default, setter(into))] + sort: Option>, + + /// Sorts by one or more sets of attribute and sort direction combinations. + /// If you omit the sort direction in a set, default is desc. Deprecated in + /// favour of the combined sort parameter. + /// + #[builder(default, setter(into))] + sort_dir: Option>, + + /// Sorts by an attribute. A valid value is name, status, container_format, + /// disk_format, size, id, created_at, or updated_at. Default is + /// created_at. The API uses the natural sorting direction of the sort_key + /// attribute value. Deprecated in favour of the combined sort parameter. + /// + #[builder(default, setter(into))] + sort_key: Option>, + + #[builder(setter(name = "_headers"), default, private)] + _headers: Option, +} +impl<'a> Request<'a> { + /// Create a builder for the endpoint. + pub fn builder() -> RequestBuilder<'a> { + RequestBuilder::default() + } +} + +impl<'a> RequestBuilder<'a> { + /// Add a single header to the Manageable_Snapshot. + pub fn header(&mut self, header_name: &'static str, header_value: &'static str) -> &mut Self +where { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name, HeaderValue::from_static(header_value)); + self + } + + /// Add multiple headers. + pub fn headers(&mut self, iter: I) -> &mut Self + where + I: Iterator, + T: Into<(Option, HeaderValue)>, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .extend(iter.map(Into::into)); + self + } +} + +impl<'a> RestEndpoint for Request<'a> { + fn method(&self) -> http::Method { + http::Method::GET + } + + fn endpoint(&self) -> Cow<'static, str> { + "manageable_snapshots".to_string().into() + } + + fn parameters(&self) -> QueryParams { + let mut params = QueryParams::default(); + params.push_opt("sort", self.sort.as_ref()); + params.push_opt("sort_key", self.sort_key.as_ref()); + params.push_opt("sort_dir", self.sort_dir.as_ref()); + params.push_opt("limit", self.limit); + params.push_opt("offset", self.offset); + params.push_opt("marker", self.marker.as_ref()); + + params + } + + fn service_type(&self) -> ServiceType { + ServiceType::BlockStorage + } + + fn response_key(&self) -> Option> { + None + } + + /// Returns headers to be set into the request + fn request_headers(&self) -> Option<&HeaderMap> { + self._headers.as_ref() + } + + /// Returns required API version + fn api_version(&self) -> Option { + Some(ApiVersion::new(3, 0)) + } +} +impl<'a> Pageable for Request<'a> {} + +#[cfg(test)] +mod tests { + #![allow(unused_imports)] + use super::*; + #[cfg(feature = "sync")] + use crate::api::Query; + #[cfg(feature = "sync")] + use crate::test::client::MockServerClient; + use crate::types::ServiceType; + use http::{HeaderName, HeaderValue}; + use serde_json::json; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::BlockStorage + ); + } + + #[test] + fn test_response_key() { + assert!(Request::builder().build().unwrap().response_key().is_none()) + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let client = MockServerClient::new(); + let mock = client.server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path("/manageable_snapshots".to_string()); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "dummy": {} })); + }); + + let endpoint = Request::builder().build().unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let client = MockServerClient::new(); + let mock = client.server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path("/manageable_snapshots".to_string()) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "dummy": {} })); + }); + + let endpoint = Request::builder() + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header("not_foo", "not_bar") + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/openstack_sdk/src/api/block_storage/v3/manageable_snapshot/list_detailed.rs b/openstack_sdk/src/api/block_storage/v3/manageable_snapshot/list_detailed.rs new file mode 100644 index 000000000..fd04f54de --- /dev/null +++ b/openstack_sdk/src/api/block_storage/v3/manageable_snapshot/list_detailed.rs @@ -0,0 +1,221 @@ +// 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`. + +//! Returns a detailed list of volumes available to manage. +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use crate::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +use crate::api::Pageable; +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// Requests a page size of items. Returns a number of items up to a limit + /// value. Use the limit parameter to make an initial limited request and + /// use the ID of the last-seen item from the response as the marker + /// parameter value in a subsequent limited request. + /// + #[builder(default)] + limit: Option, + + /// The ID of the last-seen item. Use the limit parameter to make an + /// initial limited request and use the ID of the last-seen item from the + /// response as the marker parameter value in a subsequent limited request. + /// + #[builder(default, setter(into))] + marker: Option>, + + /// Used in conjunction with limit to return a slice of items. offset is + /// where to start in the list. + /// + #[builder(default)] + offset: Option, + + /// Comma-separated list of sort keys and optional sort directions in the + /// form of \< key > \[: \< direction > \]. A valid direction is asc + /// (ascending) or desc (descending). + /// + #[builder(default, setter(into))] + sort: Option>, + + /// Sorts by one or more sets of attribute and sort direction combinations. + /// If you omit the sort direction in a set, default is desc. Deprecated in + /// favour of the combined sort parameter. + /// + #[builder(default, setter(into))] + sort_dir: Option>, + + /// Sorts by an attribute. A valid value is name, status, container_format, + /// disk_format, size, id, created_at, or updated_at. Default is + /// created_at. The API uses the natural sorting direction of the sort_key + /// attribute value. Deprecated in favour of the combined sort parameter. + /// + #[builder(default, setter(into))] + sort_key: Option>, + + #[builder(setter(name = "_headers"), default, private)] + _headers: Option, +} +impl<'a> Request<'a> { + /// Create a builder for the endpoint. + pub fn builder() -> RequestBuilder<'a> { + RequestBuilder::default() + } +} + +impl<'a> RequestBuilder<'a> { + /// Add a single header to the Manageable_Snapshot. + pub fn header(&mut self, header_name: &'static str, header_value: &'static str) -> &mut Self +where { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name, HeaderValue::from_static(header_value)); + self + } + + /// Add multiple headers. + pub fn headers(&mut self, iter: I) -> &mut Self + where + I: Iterator, + T: Into<(Option, HeaderValue)>, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .extend(iter.map(Into::into)); + self + } +} + +impl<'a> RestEndpoint for Request<'a> { + fn method(&self) -> http::Method { + http::Method::GET + } + + fn endpoint(&self) -> Cow<'static, str> { + "manageable_snapshots/detail".to_string().into() + } + + fn parameters(&self) -> QueryParams { + let mut params = QueryParams::default(); + params.push_opt("sort", self.sort.as_ref()); + params.push_opt("sort_key", self.sort_key.as_ref()); + params.push_opt("sort_dir", self.sort_dir.as_ref()); + params.push_opt("limit", self.limit); + params.push_opt("offset", self.offset); + params.push_opt("marker", self.marker.as_ref()); + + params + } + + fn service_type(&self) -> ServiceType { + ServiceType::BlockStorage + } + + fn response_key(&self) -> Option> { + None + } + + /// Returns headers to be set into the request + fn request_headers(&self) -> Option<&HeaderMap> { + self._headers.as_ref() + } + + /// Returns required API version + fn api_version(&self) -> Option { + Some(ApiVersion::new(3, 0)) + } +} +impl<'a> Pageable for Request<'a> {} + +#[cfg(test)] +mod tests { + #![allow(unused_imports)] + use super::*; + #[cfg(feature = "sync")] + use crate::api::Query; + #[cfg(feature = "sync")] + use crate::test::client::MockServerClient; + use crate::types::ServiceType; + use http::{HeaderName, HeaderValue}; + use serde_json::json; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::BlockStorage + ); + } + + #[test] + fn test_response_key() { + assert!(Request::builder().build().unwrap().response_key().is_none()) + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let client = MockServerClient::new(); + let mock = client.server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path("/manageable_snapshots/detail".to_string()); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "dummy": {} })); + }); + + let endpoint = Request::builder().build().unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let client = MockServerClient::new(); + let mock = client.server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path("/manageable_snapshots/detail".to_string()) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "dummy": {} })); + }); + + let endpoint = Request::builder() + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header("not_foo", "not_bar") + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/openstack_sdk/src/api/block_storage/v3/manageable_volume.rs b/openstack_sdk/src/api/block_storage/v3/manageable_volume.rs new file mode 100644 index 000000000..9ce6e3b6c --- /dev/null +++ b/openstack_sdk/src/api/block_storage/v3/manageable_volume.rs @@ -0,0 +1,21 @@ +// 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/manageable_volumes/detail` REST operations of block_storage +pub mod create; +pub mod get; +pub mod list_detailed; diff --git a/openstack_sdk/src/api/block_storage/v3/manageable_volume/create.rs b/openstack_sdk/src/api/block_storage/v3/manageable_volume/create.rs new file mode 100644 index 000000000..a0a666f3f --- /dev/null +++ b/openstack_sdk/src/api/block_storage/v3/manageable_volume/create.rs @@ -0,0 +1,332 @@ +// 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`. + +//! Instruct Cinder to manage a storage object. +//! +//! Manages an existing backend storage object (e.g. a Linux logical volume or +//! a SAN disk) by creating the Cinder objects required to manage it, and +//! possibly renaming the backend storage object (driver dependent) +//! +//! From an API perspective, this operation behaves very much like a volume +//! creation operation, except that properties such as image, snapshot and +//! volume references don't make sense, because we are taking an existing +//! storage object into Cinder management. +//! +//! Required HTTP Body: +//! +//! ```text +//! +//! { +//! "volume": { +//! "host": "", +//! "cluster": "", +//! "ref": "" +//! } +//! } +//! +//! ``` +//! +//! See the appropriate Cinder drivers' implementations of the manage_volume +//! method to find out the accepted format of 'ref'. +//! +//! This API call will return with an error if any of the above elements are +//! missing from the request, or if the 'host' element refers to a cinder host +//! that is not registered. +//! +//! The volume will later enter the error state if it is discovered that 'ref' +//! is bad. +//! +//! Optional elements to 'volume' are: +//! +//! ```text +//! +//! name A name for the new volume. +//! description A description for the new volume. +//! volume_type ID or name of a volume type to associate with +//! the new Cinder volume. Does not necessarily +//! guarantee that the managed volume will have the +//! properties described in the volume_type. The +//! driver may choose to fail if it identifies that +//! the specified volume_type is not compatible with +//! the backend storage object. +//! metadata Key/value pairs to be associated with the new +//! volume. +//! availability_zone The availability zone to associate with the new +//! volume. +//! bootable If set to True, marks the volume as bootable. +//! +//! ``` +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use crate::api::rest_endpoint_prelude::*; + +use serde::Deserialize; +use serde::Serialize; +use serde_json::Value; +use std::borrow::Cow; +use std::collections::BTreeMap; + +/// A `volume` object. +/// +#[derive(Builder, Debug, Deserialize, Clone, Serialize)] +#[builder(setter(strip_option))] +pub struct Volume<'a> { + /// The volume name. + /// + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) availability_zone: Option>>, + + /// Enables or disables the bootable attribute. You can boot an instance + /// from a bootable volume. See + /// [valid boolean values](#valid-boolean-values) + /// + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default)] + pub(crate) bootable: Option, + + /// The volume description. + /// + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) description: Option>>, + + /// The OpenStack Block Storage host where the existing resource resides. + /// Optional only if cluster field is provided. + /// + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) host: Option>>, + + /// One or more metadata key and value pairs to be associated with the new + /// volume. + /// + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, private, setter(name = "_metadata"))] + pub(crate) metadata: Option, Cow<'a, str>>>>, + + /// The volume name. + /// + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) name: Option>>, + + /// A reference to the existing volume. The internal structure of this + /// reference depends on the volume driver implementation. For details + /// about the required elements in the structure, see the documentation for + /// the volume driver. + /// + #[serde(rename = "ref")] + #[builder(setter(into))] + pub(crate) _ref: Value, + + /// The volume name. + /// + #[serde(skip_serializing_if = "Option::is_none")] + #[builder(default, setter(into))] + pub(crate) volume_type: Option>>, +} + +impl<'a> VolumeBuilder<'a> { + /// One or more metadata key and value pairs to be associated with the new + /// volume. + /// + pub fn metadata(&mut self, iter: I) -> &mut Self + where + I: Iterator, + K: Into>, + V: Into>, + { + self.metadata + .get_or_insert(None) + .get_or_insert(None) + .get_or_insert_with(BTreeMap::new) + .extend(iter.map(|(k, v)| (k.into(), v.into()))); + self + } +} + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// A `volume` object. + /// + #[builder(setter(into))] + pub(crate) volume: Volume<'a>, + + #[builder(setter(name = "_headers"), default, private)] + _headers: Option, +} +impl<'a> Request<'a> { + /// Create a builder for the endpoint. + pub fn builder() -> RequestBuilder<'a> { + RequestBuilder::default() + } +} + +impl<'a> RequestBuilder<'a> { + /// Add a single header to the Manageable_Volume. + pub fn header(&mut self, header_name: &'static str, header_value: &'static str) -> &mut Self +where { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name, HeaderValue::from_static(header_value)); + self + } + + /// Add multiple headers. + pub fn headers(&mut self, iter: I) -> &mut Self + where + I: Iterator, + T: Into<(Option, HeaderValue)>, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .extend(iter.map(Into::into)); + self + } +} + +impl<'a> RestEndpoint for Request<'a> { + fn method(&self) -> http::Method { + http::Method::POST + } + + fn endpoint(&self) -> Cow<'static, str> { + "manageable_volumes".to_string().into() + } + + fn parameters(&self) -> QueryParams { + QueryParams::default() + } + + fn body(&self) -> Result)>, BodyError> { + let mut params = JsonBodyParams::default(); + + params.push("volume", serde_json::to_value(&self.volume)?); + + params.into_body() + } + + fn service_type(&self) -> ServiceType { + ServiceType::BlockStorage + } + + fn response_key(&self) -> Option> { + None + } + + /// Returns headers to be set into the request + fn request_headers(&self) -> Option<&HeaderMap> { + self._headers.as_ref() + } + + /// Returns required API version + fn api_version(&self) -> Option { + Some(ApiVersion::new(3, 0)) + } +} + +#[cfg(test)] +mod tests { + #![allow(unused_imports)] + use super::*; + #[cfg(feature = "sync")] + use crate::api::Query; + #[cfg(feature = "sync")] + use crate::test::client::MockServerClient; + use crate::types::ServiceType; + use http::{HeaderName, HeaderValue}; + use serde_json::json; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder() + .volume(VolumeBuilder::default()._ref(json!({})).build().unwrap()) + .build() + .unwrap() + .service_type(), + ServiceType::BlockStorage + ); + } + + #[test] + fn test_response_key() { + assert!(Request::builder() + .volume(VolumeBuilder::default()._ref(json!({})).build().unwrap()) + .build() + .unwrap() + .response_key() + .is_none()) + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let client = MockServerClient::new(); + let mock = client.server.mock(|when, then| { + when.method(httpmock::Method::POST) + .path("/manageable_volumes".to_string()); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "dummy": {} })); + }); + + let endpoint = Request::builder() + .volume(VolumeBuilder::default()._ref(json!({})).build().unwrap()) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let client = MockServerClient::new(); + let mock = client.server.mock(|when, then| { + when.method(httpmock::Method::POST) + .path("/manageable_volumes".to_string()) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "dummy": {} })); + }); + + let endpoint = Request::builder() + .volume(VolumeBuilder::default()._ref(json!({})).build().unwrap()) + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header("not_foo", "not_bar") + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/openstack_sdk/src/api/block_storage/v3/manageable_volume/get.rs b/openstack_sdk/src/api/block_storage/v3/manageable_volume/get.rs new file mode 100644 index 000000000..69839db87 --- /dev/null +++ b/openstack_sdk/src/api/block_storage/v3/manageable_volume/get.rs @@ -0,0 +1,221 @@ +// 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`. + +//! Returns a summary list of volumes available to manage. +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use crate::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +use crate::api::Pageable; +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// Requests a page size of items. Returns a number of items up to a limit + /// value. Use the limit parameter to make an initial limited request and + /// use the ID of the last-seen item from the response as the marker + /// parameter value in a subsequent limited request. + /// + #[builder(default)] + limit: Option, + + /// The ID of the last-seen item. Use the limit parameter to make an + /// initial limited request and use the ID of the last-seen item from the + /// response as the marker parameter value in a subsequent limited request. + /// + #[builder(default, setter(into))] + marker: Option>, + + /// Used in conjunction with limit to return a slice of items. offset is + /// where to start in the list. + /// + #[builder(default)] + offset: Option, + + /// Comma-separated list of sort keys and optional sort directions in the + /// form of \< key > \[: \< direction > \]. A valid direction is asc + /// (ascending) or desc (descending). + /// + #[builder(default, setter(into))] + sort: Option>, + + /// Sorts by one or more sets of attribute and sort direction combinations. + /// If you omit the sort direction in a set, default is desc. Deprecated in + /// favour of the combined sort parameter. + /// + #[builder(default, setter(into))] + sort_dir: Option>, + + /// Sorts by an attribute. A valid value is name, status, container_format, + /// disk_format, size, id, created_at, or updated_at. Default is + /// created_at. The API uses the natural sorting direction of the sort_key + /// attribute value. Deprecated in favour of the combined sort parameter. + /// + #[builder(default, setter(into))] + sort_key: Option>, + + #[builder(setter(name = "_headers"), default, private)] + _headers: Option, +} +impl<'a> Request<'a> { + /// Create a builder for the endpoint. + pub fn builder() -> RequestBuilder<'a> { + RequestBuilder::default() + } +} + +impl<'a> RequestBuilder<'a> { + /// Add a single header to the Manageable_Volume. + pub fn header(&mut self, header_name: &'static str, header_value: &'static str) -> &mut Self +where { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name, HeaderValue::from_static(header_value)); + self + } + + /// Add multiple headers. + pub fn headers(&mut self, iter: I) -> &mut Self + where + I: Iterator, + T: Into<(Option, HeaderValue)>, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .extend(iter.map(Into::into)); + self + } +} + +impl<'a> RestEndpoint for Request<'a> { + fn method(&self) -> http::Method { + http::Method::GET + } + + fn endpoint(&self) -> Cow<'static, str> { + "manageable_volumes".to_string().into() + } + + fn parameters(&self) -> QueryParams { + let mut params = QueryParams::default(); + params.push_opt("sort", self.sort.as_ref()); + params.push_opt("sort_key", self.sort_key.as_ref()); + params.push_opt("sort_dir", self.sort_dir.as_ref()); + params.push_opt("limit", self.limit); + params.push_opt("offset", self.offset); + params.push_opt("marker", self.marker.as_ref()); + + params + } + + fn service_type(&self) -> ServiceType { + ServiceType::BlockStorage + } + + fn response_key(&self) -> Option> { + None + } + + /// Returns headers to be set into the request + fn request_headers(&self) -> Option<&HeaderMap> { + self._headers.as_ref() + } + + /// Returns required API version + fn api_version(&self) -> Option { + Some(ApiVersion::new(3, 0)) + } +} +impl<'a> Pageable for Request<'a> {} + +#[cfg(test)] +mod tests { + #![allow(unused_imports)] + use super::*; + #[cfg(feature = "sync")] + use crate::api::Query; + #[cfg(feature = "sync")] + use crate::test::client::MockServerClient; + use crate::types::ServiceType; + use http::{HeaderName, HeaderValue}; + use serde_json::json; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::BlockStorage + ); + } + + #[test] + fn test_response_key() { + assert!(Request::builder().build().unwrap().response_key().is_none()) + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let client = MockServerClient::new(); + let mock = client.server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path("/manageable_volumes".to_string()); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "dummy": {} })); + }); + + let endpoint = Request::builder().build().unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let client = MockServerClient::new(); + let mock = client.server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path("/manageable_volumes".to_string()) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "dummy": {} })); + }); + + let endpoint = Request::builder() + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header("not_foo", "not_bar") + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/openstack_sdk/src/api/block_storage/v3/manageable_volume/list_detailed.rs b/openstack_sdk/src/api/block_storage/v3/manageable_volume/list_detailed.rs new file mode 100644 index 000000000..ddad5fceb --- /dev/null +++ b/openstack_sdk/src/api/block_storage/v3/manageable_volume/list_detailed.rs @@ -0,0 +1,221 @@ +// 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`. + +//! Returns a detailed list of volumes available to manage. +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use crate::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +use crate::api::Pageable; +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// Requests a page size of items. Returns a number of items up to a limit + /// value. Use the limit parameter to make an initial limited request and + /// use the ID of the last-seen item from the response as the marker + /// parameter value in a subsequent limited request. + /// + #[builder(default)] + limit: Option, + + /// The ID of the last-seen item. Use the limit parameter to make an + /// initial limited request and use the ID of the last-seen item from the + /// response as the marker parameter value in a subsequent limited request. + /// + #[builder(default, setter(into))] + marker: Option>, + + /// Used in conjunction with limit to return a slice of items. offset is + /// where to start in the list. + /// + #[builder(default)] + offset: Option, + + /// Comma-separated list of sort keys and optional sort directions in the + /// form of \< key > \[: \< direction > \]. A valid direction is asc + /// (ascending) or desc (descending). + /// + #[builder(default, setter(into))] + sort: Option>, + + /// Sorts by one or more sets of attribute and sort direction combinations. + /// If you omit the sort direction in a set, default is desc. Deprecated in + /// favour of the combined sort parameter. + /// + #[builder(default, setter(into))] + sort_dir: Option>, + + /// Sorts by an attribute. A valid value is name, status, container_format, + /// disk_format, size, id, created_at, or updated_at. Default is + /// created_at. The API uses the natural sorting direction of the sort_key + /// attribute value. Deprecated in favour of the combined sort parameter. + /// + #[builder(default, setter(into))] + sort_key: Option>, + + #[builder(setter(name = "_headers"), default, private)] + _headers: Option, +} +impl<'a> Request<'a> { + /// Create a builder for the endpoint. + pub fn builder() -> RequestBuilder<'a> { + RequestBuilder::default() + } +} + +impl<'a> RequestBuilder<'a> { + /// Add a single header to the Manageable_Volume. + pub fn header(&mut self, header_name: &'static str, header_value: &'static str) -> &mut Self +where { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name, HeaderValue::from_static(header_value)); + self + } + + /// Add multiple headers. + pub fn headers(&mut self, iter: I) -> &mut Self + where + I: Iterator, + T: Into<(Option, HeaderValue)>, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .extend(iter.map(Into::into)); + self + } +} + +impl<'a> RestEndpoint for Request<'a> { + fn method(&self) -> http::Method { + http::Method::GET + } + + fn endpoint(&self) -> Cow<'static, str> { + "manageable_volumes/detail".to_string().into() + } + + fn parameters(&self) -> QueryParams { + let mut params = QueryParams::default(); + params.push_opt("sort", self.sort.as_ref()); + params.push_opt("sort_key", self.sort_key.as_ref()); + params.push_opt("sort_dir", self.sort_dir.as_ref()); + params.push_opt("limit", self.limit); + params.push_opt("offset", self.offset); + params.push_opt("marker", self.marker.as_ref()); + + params + } + + fn service_type(&self) -> ServiceType { + ServiceType::BlockStorage + } + + fn response_key(&self) -> Option> { + None + } + + /// Returns headers to be set into the request + fn request_headers(&self) -> Option<&HeaderMap> { + self._headers.as_ref() + } + + /// Returns required API version + fn api_version(&self) -> Option { + Some(ApiVersion::new(3, 0)) + } +} +impl<'a> Pageable for Request<'a> {} + +#[cfg(test)] +mod tests { + #![allow(unused_imports)] + use super::*; + #[cfg(feature = "sync")] + use crate::api::Query; + #[cfg(feature = "sync")] + use crate::test::client::MockServerClient; + use crate::types::ServiceType; + use http::{HeaderName, HeaderValue}; + use serde_json::json; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::BlockStorage + ); + } + + #[test] + fn test_response_key() { + assert!(Request::builder().build().unwrap().response_key().is_none()) + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let client = MockServerClient::new(); + let mock = client.server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path("/manageable_volumes/detail".to_string()); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "dummy": {} })); + }); + + let endpoint = Request::builder().build().unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let client = MockServerClient::new(); + let mock = client.server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path("/manageable_volumes/detail".to_string()) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "dummy": {} })); + }); + + let endpoint = Request::builder() + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header("not_foo", "not_bar") + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/openstack_sdk/src/api/block_storage/v3/quota_class_set.rs b/openstack_sdk/src/api/block_storage/v3/quota_class_set.rs new file mode 100644 index 000000000..50056775b --- /dev/null +++ b/openstack_sdk/src/api/block_storage/v3/quota_class_set.rs @@ -0,0 +1,20 @@ +// 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-quota-class-sets/{id}` REST operations of block_storage +pub mod get; +pub mod set; diff --git a/openstack_sdk/src/api/block_storage/v3/quota_class_set/get.rs b/openstack_sdk/src/api/block_storage/v3/quota_class_set/get.rs new file mode 100644 index 000000000..c694e7918 --- /dev/null +++ b/openstack_sdk/src/api/block_storage/v3/quota_class_set/get.rs @@ -0,0 +1,172 @@ +// 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 derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use crate::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// id parameter for /v3/os-quota-class-sets/{id} API + /// + #[builder(default, setter(into))] + id: Cow<'a, str>, + + #[builder(setter(name = "_headers"), default, private)] + _headers: Option, +} +impl<'a> Request<'a> { + /// Create a builder for the endpoint. + pub fn builder() -> RequestBuilder<'a> { + RequestBuilder::default() + } +} + +impl<'a> RequestBuilder<'a> { + /// Add a single header to the Quota_Class_Set. + pub fn header(&mut self, header_name: &'static str, header_value: &'static str) -> &mut Self +where { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name, HeaderValue::from_static(header_value)); + self + } + + /// Add multiple headers. + pub fn headers(&mut self, iter: I) -> &mut Self + where + I: Iterator, + T: Into<(Option, HeaderValue)>, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .extend(iter.map(Into::into)); + self + } +} + +impl<'a> RestEndpoint for Request<'a> { + fn method(&self) -> http::Method { + http::Method::GET + } + + fn endpoint(&self) -> Cow<'static, str> { + format!("os-quota-class-sets/{id}", id = self.id.as_ref(),).into() + } + + fn parameters(&self) -> QueryParams { + QueryParams::default() + } + + fn service_type(&self) -> ServiceType { + ServiceType::BlockStorage + } + + fn response_key(&self) -> Option> { + None + } + + /// Returns headers to be set into the request + fn request_headers(&self) -> Option<&HeaderMap> { + self._headers.as_ref() + } + + /// Returns required API version + fn api_version(&self) -> Option { + Some(ApiVersion::new(3, 0)) + } +} + +#[cfg(test)] +mod tests { + #![allow(unused_imports)] + use super::*; + #[cfg(feature = "sync")] + use crate::api::Query; + #[cfg(feature = "sync")] + use crate::test::client::MockServerClient; + use crate::types::ServiceType; + use http::{HeaderName, HeaderValue}; + use serde_json::json; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::BlockStorage + ); + } + + #[test] + fn test_response_key() { + assert!(Request::builder().build().unwrap().response_key().is_none()) + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let client = MockServerClient::new(); + let mock = client.server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path(format!("/os-quota-class-sets/{id}", id = "id",)); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "dummy": {} })); + }); + + let endpoint = Request::builder().id("id").build().unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let client = MockServerClient::new(); + let mock = client.server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path(format!("/os-quota-class-sets/{id}", id = "id",)) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "dummy": {} })); + }); + + let endpoint = Request::builder() + .id("id") + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header("not_foo", "not_bar") + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/openstack_sdk/src/api/block_storage/v3/quota_class_set/set.rs b/openstack_sdk/src/api/block_storage/v3/quota_class_set/set.rs new file mode 100644 index 000000000..42da006e2 --- /dev/null +++ b/openstack_sdk/src/api/block_storage/v3/quota_class_set/set.rs @@ -0,0 +1,213 @@ +// 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 derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use crate::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; +use std::collections::BTreeMap; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + #[builder(private, setter(name = "_quota_class_set"))] + pub(crate) quota_class_set: BTreeMap, Cow<'a, str>>, + + /// id parameter for /v3/os-quota-class-sets/{id} API + /// + #[builder(default, setter(into))] + id: Cow<'a, str>, + + #[builder(setter(name = "_headers"), default, private)] + _headers: Option, +} +impl<'a> Request<'a> { + /// Create a builder for the endpoint. + pub fn builder() -> RequestBuilder<'a> { + RequestBuilder::default() + } +} + +impl<'a> RequestBuilder<'a> { + pub fn quota_class_set(&mut self, iter: I) -> &mut Self + where + I: Iterator, + K: Into>, + V: Into>, + { + self.quota_class_set + .get_or_insert_with(BTreeMap::new) + .extend(iter.map(|(k, v)| (k.into(), v.into()))); + self + } + + /// Add a single header to the Quota_Class_Set. + pub fn header(&mut self, header_name: &'static str, header_value: &'static str) -> &mut Self +where { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name, HeaderValue::from_static(header_value)); + self + } + + /// Add multiple headers. + pub fn headers(&mut self, iter: I) -> &mut Self + where + I: Iterator, + T: Into<(Option, HeaderValue)>, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .extend(iter.map(Into::into)); + self + } +} + +impl<'a> RestEndpoint for Request<'a> { + fn method(&self) -> http::Method { + http::Method::PUT + } + + fn endpoint(&self) -> Cow<'static, str> { + format!("os-quota-class-sets/{id}", id = self.id.as_ref(),).into() + } + + fn parameters(&self) -> QueryParams { + QueryParams::default() + } + + fn body(&self) -> Result)>, BodyError> { + let mut params = JsonBodyParams::default(); + + params.push( + "quota_class_set", + serde_json::to_value(&self.quota_class_set)?, + ); + + params.into_body() + } + + fn service_type(&self) -> ServiceType { + ServiceType::BlockStorage + } + + fn response_key(&self) -> Option> { + None + } + + /// Returns headers to be set into the request + fn request_headers(&self) -> Option<&HeaderMap> { + self._headers.as_ref() + } + + /// Returns required API version + fn api_version(&self) -> Option { + Some(ApiVersion::new(3, 0)) + } +} + +#[cfg(test)] +mod tests { + #![allow(unused_imports)] + use super::*; + #[cfg(feature = "sync")] + use crate::api::Query; + #[cfg(feature = "sync")] + use crate::test::client::MockServerClient; + use crate::types::ServiceType; + use http::{HeaderName, HeaderValue}; + use serde_json::json; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder() + .quota_class_set(BTreeMap::::new().into_iter()) + .build() + .unwrap() + .service_type(), + ServiceType::BlockStorage + ); + } + + #[test] + fn test_response_key() { + assert!(Request::builder() + .quota_class_set(BTreeMap::::new().into_iter()) + .build() + .unwrap() + .response_key() + .is_none()) + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let client = MockServerClient::new(); + let mock = client.server.mock(|when, then| { + when.method(httpmock::Method::PUT) + .path(format!("/os-quota-class-sets/{id}", id = "id",)); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "dummy": {} })); + }); + + let endpoint = Request::builder() + .id("id") + .quota_class_set(BTreeMap::::new().into_iter()) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let client = MockServerClient::new(); + let mock = client.server.mock(|when, then| { + when.method(httpmock::Method::PUT) + .path(format!("/os-quota-class-sets/{id}", id = "id",)) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "dummy": {} })); + }); + + let endpoint = Request::builder() + .id("id") + .quota_class_set(BTreeMap::::new().into_iter()) + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header("not_foo", "not_bar") + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/openstack_sdk/src/api/block_storage/v3/quota_set.rs b/openstack_sdk/src/api/block_storage/v3/quota_set.rs new file mode 100644 index 000000000..652d95c71 --- /dev/null +++ b/openstack_sdk/src/api/block_storage/v3/quota_set.rs @@ -0,0 +1,22 @@ +// 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-quota-sets/{id}` REST operations of block_storage +pub mod default; +pub mod delete; +pub mod get; +pub mod set; diff --git a/openstack_sdk/src/api/block_storage/v3/quota_set/default.rs b/openstack_sdk/src/api/block_storage/v3/quota_set/default.rs new file mode 100644 index 000000000..4455c8dc9 --- /dev/null +++ b/openstack_sdk/src/api/block_storage/v3/quota_set/default.rs @@ -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-quota-sets/{id}/defaults` REST operations of block_storage +pub mod get; diff --git a/openstack_sdk/src/api/block_storage/v3/quota_set/default/get.rs b/openstack_sdk/src/api/block_storage/v3/quota_set/default/get.rs new file mode 100644 index 000000000..51e74cb42 --- /dev/null +++ b/openstack_sdk/src/api/block_storage/v3/quota_set/default/get.rs @@ -0,0 +1,172 @@ +// 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 derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use crate::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// id parameter for /v3/os-quota-sets/{id}/defaults API + /// + #[builder(default, setter(into))] + id: Cow<'a, str>, + + #[builder(setter(name = "_headers"), default, private)] + _headers: Option, +} +impl<'a> Request<'a> { + /// Create a builder for the endpoint. + pub fn builder() -> RequestBuilder<'a> { + RequestBuilder::default() + } +} + +impl<'a> RequestBuilder<'a> { + /// Add a single header to the Default. + pub fn header(&mut self, header_name: &'static str, header_value: &'static str) -> &mut Self +where { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name, HeaderValue::from_static(header_value)); + self + } + + /// Add multiple headers. + pub fn headers(&mut self, iter: I) -> &mut Self + where + I: Iterator, + T: Into<(Option, HeaderValue)>, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .extend(iter.map(Into::into)); + self + } +} + +impl<'a> RestEndpoint for Request<'a> { + fn method(&self) -> http::Method { + http::Method::GET + } + + fn endpoint(&self) -> Cow<'static, str> { + format!("os-quota-sets/{id}/defaults", id = self.id.as_ref(),).into() + } + + fn parameters(&self) -> QueryParams { + QueryParams::default() + } + + fn service_type(&self) -> ServiceType { + ServiceType::BlockStorage + } + + fn response_key(&self) -> Option> { + None + } + + /// Returns headers to be set into the request + fn request_headers(&self) -> Option<&HeaderMap> { + self._headers.as_ref() + } + + /// Returns required API version + fn api_version(&self) -> Option { + Some(ApiVersion::new(3, 0)) + } +} + +#[cfg(test)] +mod tests { + #![allow(unused_imports)] + use super::*; + #[cfg(feature = "sync")] + use crate::api::Query; + #[cfg(feature = "sync")] + use crate::test::client::MockServerClient; + use crate::types::ServiceType; + use http::{HeaderName, HeaderValue}; + use serde_json::json; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::BlockStorage + ); + } + + #[test] + fn test_response_key() { + assert!(Request::builder().build().unwrap().response_key().is_none()) + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let client = MockServerClient::new(); + let mock = client.server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path(format!("/os-quota-sets/{id}/defaults", id = "id",)); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "dummy": {} })); + }); + + let endpoint = Request::builder().id("id").build().unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let client = MockServerClient::new(); + let mock = client.server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path(format!("/os-quota-sets/{id}/defaults", id = "id",)) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "dummy": {} })); + }); + + let endpoint = Request::builder() + .id("id") + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header("not_foo", "not_bar") + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/openstack_sdk/src/api/block_storage/v3/quota_set/delete.rs b/openstack_sdk/src/api/block_storage/v3/quota_set/delete.rs new file mode 100644 index 000000000..88898dcac --- /dev/null +++ b/openstack_sdk/src/api/block_storage/v3/quota_set/delete.rs @@ -0,0 +1,177 @@ +// 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 Quota for a particular tenant. +//! +//! | param req: | request | | --- | --- | | param id: | target project id that +//! needs to be deleted | +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use crate::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// id parameter for /v3/os-quota-sets/{id} API + /// + #[builder(default, setter(into))] + id: Cow<'a, str>, + + #[builder(setter(name = "_headers"), default, private)] + _headers: Option, +} +impl<'a> Request<'a> { + /// Create a builder for the endpoint. + pub fn builder() -> RequestBuilder<'a> { + RequestBuilder::default() + } +} + +impl<'a> RequestBuilder<'a> { + /// Add a single header to the Quota_Set. + pub fn header(&mut self, header_name: &'static str, header_value: &'static str) -> &mut Self +where { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name, HeaderValue::from_static(header_value)); + self + } + + /// Add multiple headers. + pub fn headers(&mut self, iter: I) -> &mut Self + where + I: Iterator, + T: Into<(Option, HeaderValue)>, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .extend(iter.map(Into::into)); + self + } +} + +impl<'a> RestEndpoint for Request<'a> { + fn method(&self) -> http::Method { + http::Method::DELETE + } + + fn endpoint(&self) -> Cow<'static, str> { + format!("os-quota-sets/{id}", id = self.id.as_ref(),).into() + } + + fn parameters(&self) -> QueryParams { + QueryParams::default() + } + + fn service_type(&self) -> ServiceType { + ServiceType::BlockStorage + } + + fn response_key(&self) -> Option> { + None + } + + /// Returns headers to be set into the request + fn request_headers(&self) -> Option<&HeaderMap> { + self._headers.as_ref() + } + + /// Returns required API version + fn api_version(&self) -> Option { + Some(ApiVersion::new(3, 0)) + } +} + +#[cfg(test)] +mod tests { + #![allow(unused_imports)] + use super::*; + #[cfg(feature = "sync")] + use crate::api::Query; + #[cfg(feature = "sync")] + use crate::test::client::MockServerClient; + use crate::types::ServiceType; + use http::{HeaderName, HeaderValue}; + use serde_json::json; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::BlockStorage + ); + } + + #[test] + fn test_response_key() { + assert!(Request::builder().build().unwrap().response_key().is_none()) + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let client = MockServerClient::new(); + let mock = client.server.mock(|when, then| { + when.method(httpmock::Method::DELETE) + .path(format!("/os-quota-sets/{id}", id = "id",)); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "dummy": {} })); + }); + + let endpoint = Request::builder().id("id").build().unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let client = MockServerClient::new(); + let mock = client.server.mock(|when, then| { + when.method(httpmock::Method::DELETE) + .path(format!("/os-quota-sets/{id}", id = "id",)) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "dummy": {} })); + }); + + let endpoint = Request::builder() + .id("id") + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header("not_foo", "not_bar") + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/openstack_sdk/src/api/block_storage/v3/quota_set/get.rs b/openstack_sdk/src/api/block_storage/v3/quota_set/get.rs new file mode 100644 index 000000000..bcffb7f47 --- /dev/null +++ b/openstack_sdk/src/api/block_storage/v3/quota_set/get.rs @@ -0,0 +1,177 @@ +// 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 quota for a particular tenant +//! +//! | param req: | request | | --- | --- | | param id: | target project id that +//! needs to be shown | +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use crate::api::rest_endpoint_prelude::*; + +use std::borrow::Cow; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// id parameter for /v3/os-quota-sets/{id} API + /// + #[builder(default, setter(into))] + id: Cow<'a, str>, + + #[builder(setter(name = "_headers"), default, private)] + _headers: Option, +} +impl<'a> Request<'a> { + /// Create a builder for the endpoint. + pub fn builder() -> RequestBuilder<'a> { + RequestBuilder::default() + } +} + +impl<'a> RequestBuilder<'a> { + /// Add a single header to the Quota_Set. + pub fn header(&mut self, header_name: &'static str, header_value: &'static str) -> &mut Self +where { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name, HeaderValue::from_static(header_value)); + self + } + + /// Add multiple headers. + pub fn headers(&mut self, iter: I) -> &mut Self + where + I: Iterator, + T: Into<(Option, HeaderValue)>, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .extend(iter.map(Into::into)); + self + } +} + +impl<'a> RestEndpoint for Request<'a> { + fn method(&self) -> http::Method { + http::Method::GET + } + + fn endpoint(&self) -> Cow<'static, str> { + format!("os-quota-sets/{id}", id = self.id.as_ref(),).into() + } + + fn parameters(&self) -> QueryParams { + QueryParams::default() + } + + fn service_type(&self) -> ServiceType { + ServiceType::BlockStorage + } + + fn response_key(&self) -> Option> { + None + } + + /// Returns headers to be set into the request + fn request_headers(&self) -> Option<&HeaderMap> { + self._headers.as_ref() + } + + /// Returns required API version + fn api_version(&self) -> Option { + Some(ApiVersion::new(3, 0)) + } +} + +#[cfg(test)] +mod tests { + #![allow(unused_imports)] + use super::*; + #[cfg(feature = "sync")] + use crate::api::Query; + #[cfg(feature = "sync")] + use crate::test::client::MockServerClient; + use crate::types::ServiceType; + use http::{HeaderName, HeaderValue}; + use serde_json::json; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::BlockStorage + ); + } + + #[test] + fn test_response_key() { + assert!(Request::builder().build().unwrap().response_key().is_none()) + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let client = MockServerClient::new(); + let mock = client.server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path(format!("/os-quota-sets/{id}", id = "id",)); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "dummy": {} })); + }); + + let endpoint = Request::builder().id("id").build().unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let client = MockServerClient::new(); + let mock = client.server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path(format!("/os-quota-sets/{id}", id = "id",)) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "dummy": {} })); + }); + + let endpoint = Request::builder() + .id("id") + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header("not_foo", "not_bar") + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/openstack_sdk/src/api/block_storage/v3/quota_set/set.rs b/openstack_sdk/src/api/block_storage/v3/quota_set/set.rs new file mode 100644 index 000000000..3b46362b3 --- /dev/null +++ b/openstack_sdk/src/api/block_storage/v3/quota_set/set.rs @@ -0,0 +1,217 @@ +// 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`. + +//! Update Quota for a particular tenant +//! +//! | param req: | request | | --- | --- | | param id: | target project id that +//! needs to be updated | | param body: | key, value pair that will be applied +//! to the resources if the update succeeds | +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use crate::api::rest_endpoint_prelude::*; + +use serde_json::Value; +use std::borrow::Cow; +use std::collections::BTreeMap; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + #[builder(private, setter(name = "_quota_set"))] + pub(crate) quota_set: BTreeMap, Value>, + + /// id parameter for /v3/os-quota-sets/{id} API + /// + #[builder(default, setter(into))] + id: Cow<'a, str>, + + #[builder(setter(name = "_headers"), default, private)] + _headers: Option, +} +impl<'a> Request<'a> { + /// Create a builder for the endpoint. + pub fn builder() -> RequestBuilder<'a> { + RequestBuilder::default() + } +} + +impl<'a> RequestBuilder<'a> { + pub fn quota_set(&mut self, iter: I) -> &mut Self + where + I: Iterator, + K: Into>, + V: Into, + { + self.quota_set + .get_or_insert_with(BTreeMap::new) + .extend(iter.map(|(k, v)| (k.into(), v.into()))); + self + } + + /// Add a single header to the Quota_Set. + pub fn header(&mut self, header_name: &'static str, header_value: &'static str) -> &mut Self +where { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name, HeaderValue::from_static(header_value)); + self + } + + /// Add multiple headers. + pub fn headers(&mut self, iter: I) -> &mut Self + where + I: Iterator, + T: Into<(Option, HeaderValue)>, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .extend(iter.map(Into::into)); + self + } +} + +impl<'a> RestEndpoint for Request<'a> { + fn method(&self) -> http::Method { + http::Method::PUT + } + + fn endpoint(&self) -> Cow<'static, str> { + format!("os-quota-sets/{id}", id = self.id.as_ref(),).into() + } + + fn parameters(&self) -> QueryParams { + QueryParams::default() + } + + fn body(&self) -> Result)>, BodyError> { + let mut params = JsonBodyParams::default(); + + params.push("quota_set", serde_json::to_value(&self.quota_set)?); + + params.into_body() + } + + fn service_type(&self) -> ServiceType { + ServiceType::BlockStorage + } + + fn response_key(&self) -> Option> { + None + } + + /// Returns headers to be set into the request + fn request_headers(&self) -> Option<&HeaderMap> { + self._headers.as_ref() + } + + /// Returns required API version + fn api_version(&self) -> Option { + Some(ApiVersion::new(3, 0)) + } +} + +#[cfg(test)] +mod tests { + #![allow(unused_imports)] + use super::*; + #[cfg(feature = "sync")] + use crate::api::Query; + #[cfg(feature = "sync")] + use crate::test::client::MockServerClient; + use crate::types::ServiceType; + use http::{HeaderName, HeaderValue}; + use serde_json::json; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder() + .quota_set(BTreeMap::::new().into_iter()) + .build() + .unwrap() + .service_type(), + ServiceType::BlockStorage + ); + } + + #[test] + fn test_response_key() { + assert!(Request::builder() + .quota_set(BTreeMap::::new().into_iter()) + .build() + .unwrap() + .response_key() + .is_none()) + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let client = MockServerClient::new(); + let mock = client.server.mock(|when, then| { + when.method(httpmock::Method::PUT) + .path(format!("/os-quota-sets/{id}", id = "id",)); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "dummy": {} })); + }); + + let endpoint = Request::builder() + .id("id") + .quota_set(BTreeMap::::new().into_iter()) + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let client = MockServerClient::new(); + let mock = client.server.mock(|when, then| { + when.method(httpmock::Method::PUT) + .path(format!("/os-quota-sets/{id}", id = "id",)) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "dummy": {} })); + }); + + let endpoint = Request::builder() + .id("id") + .quota_set(BTreeMap::::new().into_iter()) + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header("not_foo", "not_bar") + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/openstack_sdk/src/api/block_storage/v3/scheduler_stat.rs b/openstack_sdk/src/api/block_storage/v3/scheduler_stat.rs new file mode 100644 index 000000000..d4c164449 --- /dev/null +++ b/openstack_sdk/src/api/block_storage/v3/scheduler_stat.rs @@ -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-quota-sets/{id}` REST operations of block_storage +pub mod get_pool; diff --git a/openstack_sdk/src/api/block_storage/v3/scheduler_stat/get_pool.rs b/openstack_sdk/src/api/block_storage/v3/scheduler_stat/get_pool.rs new file mode 100644 index 000000000..63b3efaa6 --- /dev/null +++ b/openstack_sdk/src/api/block_storage/v3/scheduler_stat/get_pool.rs @@ -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/scheduler-stats/get_pools` REST operations of block_storage +pub mod get; diff --git a/openstack_sdk/src/api/block_storage/v3/scheduler_stat/get_pool/get.rs b/openstack_sdk/src/api/block_storage/v3/scheduler_stat/get_pool/get.rs new file mode 100644 index 000000000..9403e338f --- /dev/null +++ b/openstack_sdk/src/api/block_storage/v3/scheduler_stat/get_pool/get.rs @@ -0,0 +1,166 @@ +// 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 all active pools in scheduler. +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use crate::api::rest_endpoint_prelude::*; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request { + #[builder(setter(name = "_headers"), default, private)] + _headers: Option, +} +impl Request { + /// Create a builder for the endpoint. + pub fn builder() -> RequestBuilder { + RequestBuilder::default() + } +} + +impl RequestBuilder { + /// Add a single header to the Get_Pool. + pub fn header(&mut self, header_name: &'static str, header_value: &'static str) -> &mut Self +where { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name, HeaderValue::from_static(header_value)); + self + } + + /// Add multiple headers. + pub fn headers(&mut self, iter: I) -> &mut Self + where + I: Iterator, + T: Into<(Option, HeaderValue)>, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .extend(iter.map(Into::into)); + self + } +} + +impl RestEndpoint for Request { + fn method(&self) -> http::Method { + http::Method::GET + } + + fn endpoint(&self) -> Cow<'static, str> { + "scheduler-stats/get_pools".to_string().into() + } + + fn parameters(&self) -> QueryParams { + QueryParams::default() + } + + fn service_type(&self) -> ServiceType { + ServiceType::BlockStorage + } + + fn response_key(&self) -> Option> { + None + } + + /// Returns headers to be set into the request + fn request_headers(&self) -> Option<&HeaderMap> { + self._headers.as_ref() + } + + /// Returns required API version + fn api_version(&self) -> Option { + Some(ApiVersion::new(3, 0)) + } +} + +#[cfg(test)] +mod tests { + #![allow(unused_imports)] + use super::*; + #[cfg(feature = "sync")] + use crate::api::Query; + #[cfg(feature = "sync")] + use crate::test::client::MockServerClient; + use crate::types::ServiceType; + use http::{HeaderName, HeaderValue}; + use serde_json::json; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::BlockStorage + ); + } + + #[test] + fn test_response_key() { + assert!(Request::builder().build().unwrap().response_key().is_none()) + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let client = MockServerClient::new(); + let mock = client.server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path("/scheduler-stats/get_pools".to_string()); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "dummy": {} })); + }); + + let endpoint = Request::builder().build().unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let client = MockServerClient::new(); + let mock = client.server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path("/scheduler-stats/get_pools".to_string()) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "dummy": {} })); + }); + + let endpoint = Request::builder() + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header("not_foo", "not_bar") + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/openstack_sdk/src/api/block_storage/v3/service.rs b/openstack_sdk/src/api/block_storage/v3/service.rs new file mode 100644 index 000000000..43adfa8f7 --- /dev/null +++ b/openstack_sdk/src/api/block_storage/v3/service.rs @@ -0,0 +1,20 @@ +// 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-services` REST operations of block_storage +pub mod list; +pub mod set; diff --git a/openstack_sdk/src/api/block_storage/v3/service/list.rs b/openstack_sdk/src/api/block_storage/v3/service/list.rs new file mode 100644 index 000000000..171bba6e5 --- /dev/null +++ b/openstack_sdk/src/api/block_storage/v3/service/list.rs @@ -0,0 +1,168 @@ +// 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`. + +//! Return a list of all running services. +//! +//! Filter by host & service name. +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use crate::api::rest_endpoint_prelude::*; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request { + #[builder(setter(name = "_headers"), default, private)] + _headers: Option, +} +impl Request { + /// Create a builder for the endpoint. + pub fn builder() -> RequestBuilder { + RequestBuilder::default() + } +} + +impl RequestBuilder { + /// Add a single header to the Service. + pub fn header(&mut self, header_name: &'static str, header_value: &'static str) -> &mut Self +where { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name, HeaderValue::from_static(header_value)); + self + } + + /// Add multiple headers. + pub fn headers(&mut self, iter: I) -> &mut Self + where + I: Iterator, + T: Into<(Option, HeaderValue)>, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .extend(iter.map(Into::into)); + self + } +} + +impl RestEndpoint for Request { + fn method(&self) -> http::Method { + http::Method::GET + } + + fn endpoint(&self) -> Cow<'static, str> { + "os-services".to_string().into() + } + + fn parameters(&self) -> QueryParams { + QueryParams::default() + } + + fn service_type(&self) -> ServiceType { + ServiceType::BlockStorage + } + + fn response_key(&self) -> Option> { + None + } + + /// Returns headers to be set into the request + fn request_headers(&self) -> Option<&HeaderMap> { + self._headers.as_ref() + } + + /// Returns required API version + fn api_version(&self) -> Option { + Some(ApiVersion::new(3, 0)) + } +} + +#[cfg(test)] +mod tests { + #![allow(unused_imports)] + use super::*; + #[cfg(feature = "sync")] + use crate::api::Query; + #[cfg(feature = "sync")] + use crate::test::client::MockServerClient; + use crate::types::ServiceType; + use http::{HeaderName, HeaderValue}; + use serde_json::json; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::BlockStorage + ); + } + + #[test] + fn test_response_key() { + assert!(Request::builder().build().unwrap().response_key().is_none()) + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let client = MockServerClient::new(); + let mock = client.server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path("/os-services".to_string()); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "dummy": {} })); + }); + + let endpoint = Request::builder().build().unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let client = MockServerClient::new(); + let mock = client.server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path("/os-services".to_string()) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "dummy": {} })); + }); + + let endpoint = Request::builder() + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header("not_foo", "not_bar") + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/openstack_sdk/src/api/block_storage/v3/service/set.rs b/openstack_sdk/src/api/block_storage/v3/service/set.rs new file mode 100644 index 000000000..a383adb1c --- /dev/null +++ b/openstack_sdk/src/api/block_storage/v3/service/set.rs @@ -0,0 +1,205 @@ +// 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`. + +//! Enable/Disable scheduling for a service. +//! +//! Includes Freeze/Thaw which sends call down to drivers and allows +//! volume.manager for the specified host to disable the service rather than +//! accessing the service directly in this API layer. +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use crate::api::rest_endpoint_prelude::*; + +use serde_json::Value; +use std::borrow::Cow; +use std::collections::BTreeMap; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + /// id parameter for /v3/os-services/{id} API + /// + #[builder(default, setter(into))] + id: Cow<'a, str>, + + #[builder(setter(name = "_headers"), default, private)] + _headers: Option, + + #[builder(setter(name = "_properties"), default, private)] + _properties: BTreeMap, Value>, +} +impl<'a> Request<'a> { + /// Create a builder for the endpoint. + pub fn builder() -> RequestBuilder<'a> { + RequestBuilder::default() + } +} + +impl<'a> RequestBuilder<'a> { + /// Add a single header to the Service. + pub fn header(&mut self, header_name: &'static str, header_value: &'static str) -> &mut Self +where { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name, HeaderValue::from_static(header_value)); + self + } + + /// Add multiple headers. + pub fn headers(&mut self, iter: I) -> &mut Self + where + I: Iterator, + T: Into<(Option, HeaderValue)>, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .extend(iter.map(Into::into)); + self + } + + pub fn properties(&mut self, iter: I) -> &mut Self + where + I: Iterator, + K: Into>, + V: Into, + { + self._properties + .get_or_insert_with(BTreeMap::new) + .extend(iter.map(|(k, v)| (k.into(), v.into()))); + self + } +} + +impl<'a> RestEndpoint for Request<'a> { + fn method(&self) -> http::Method { + http::Method::PUT + } + + fn endpoint(&self) -> Cow<'static, str> { + format!("os-services/{id}", id = self.id.as_ref(),).into() + } + + fn parameters(&self) -> QueryParams { + QueryParams::default() + } + + fn body(&self) -> Result)>, BodyError> { + let mut params = JsonBodyParams::default(); + + for (key, val) in &self._properties { + params.push(key.clone(), val.clone()); + } + + params.into_body() + } + + fn service_type(&self) -> ServiceType { + ServiceType::BlockStorage + } + + fn response_key(&self) -> Option> { + None + } + + /// Returns headers to be set into the request + fn request_headers(&self) -> Option<&HeaderMap> { + self._headers.as_ref() + } + + /// Returns required API version + fn api_version(&self) -> Option { + Some(ApiVersion::new(3, 0)) + } +} + +#[cfg(test)] +mod tests { + #![allow(unused_imports)] + use super::*; + #[cfg(feature = "sync")] + use crate::api::Query; + #[cfg(feature = "sync")] + use crate::test::client::MockServerClient; + use crate::types::ServiceType; + use http::{HeaderName, HeaderValue}; + use serde_json::json; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::BlockStorage + ); + } + + #[test] + fn test_response_key() { + assert!(Request::builder().build().unwrap().response_key().is_none()) + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let client = MockServerClient::new(); + let mock = client.server.mock(|when, then| { + when.method(httpmock::Method::PUT) + .path(format!("/os-services/{id}", id = "id",)); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "dummy": {} })); + }); + + let endpoint = Request::builder().id("id").build().unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let client = MockServerClient::new(); + let mock = client.server.mock(|when, then| { + when.method(httpmock::Method::PUT) + .path(format!("/os-services/{id}", id = "id",)) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "dummy": {} })); + }); + + let endpoint = Request::builder() + .id("id") + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header("not_foo", "not_bar") + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/openstack_sdk/src/api/block_storage/v3/version.rs b/openstack_sdk/src/api/block_storage/v3/version.rs new file mode 100644 index 000000000..7de5fa0b8 --- /dev/null +++ b/openstack_sdk/src/api/block_storage/v3/version.rs @@ -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/` REST operations of block_storage +pub mod get; diff --git a/openstack_sdk/src/api/block_storage/v3/version/get.rs b/openstack_sdk/src/api/block_storage/v3/version/get.rs new file mode 100644 index 000000000..e3a47bd73 --- /dev/null +++ b/openstack_sdk/src/api/block_storage/v3/version/get.rs @@ -0,0 +1,165 @@ +// 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`. + +//! Shows details for Block Storage API v3. +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use crate::api::rest_endpoint_prelude::*; + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request { + #[builder(setter(name = "_headers"), default, private)] + _headers: Option, +} +impl Request { + /// Create a builder for the endpoint. + pub fn builder() -> RequestBuilder { + RequestBuilder::default() + } +} + +impl RequestBuilder { + /// Add a single header to the Version. + pub fn header(&mut self, header_name: &'static str, header_value: &'static str) -> &mut Self +where { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name, HeaderValue::from_static(header_value)); + self + } + + /// Add multiple headers. + pub fn headers(&mut self, iter: I) -> &mut Self + where + I: Iterator, + T: Into<(Option, HeaderValue)>, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .extend(iter.map(Into::into)); + self + } +} + +impl RestEndpoint for Request { + fn method(&self) -> http::Method { + http::Method::GET + } + + fn endpoint(&self) -> Cow<'static, str> { + "".to_string().into() + } + + fn parameters(&self) -> QueryParams { + QueryParams::default() + } + + fn service_type(&self) -> ServiceType { + ServiceType::BlockStorage + } + + fn response_key(&self) -> Option> { + None + } + + /// Returns headers to be set into the request + fn request_headers(&self) -> Option<&HeaderMap> { + self._headers.as_ref() + } + + /// Returns required API version + fn api_version(&self) -> Option { + Some(ApiVersion::new(3, 0)) + } +} + +#[cfg(test)] +mod tests { + #![allow(unused_imports)] + use super::*; + #[cfg(feature = "sync")] + use crate::api::Query; + #[cfg(feature = "sync")] + use crate::test::client::MockServerClient; + use crate::types::ServiceType; + use http::{HeaderName, HeaderValue}; + use serde_json::json; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::BlockStorage + ); + } + + #[test] + fn test_response_key() { + assert!(Request::builder().build().unwrap().response_key().is_none()) + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let client = MockServerClient::new(); + let mock = client.server.mock(|when, then| { + when.method(httpmock::Method::GET).path("/".to_string()); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "dummy": {} })); + }); + + let endpoint = Request::builder().build().unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let client = MockServerClient::new(); + let mock = client.server.mock(|when, then| { + when.method(httpmock::Method::GET) + .path("/".to_string()) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "dummy": {} })); + }); + + let endpoint = Request::builder() + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header("not_foo", "not_bar") + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +} diff --git a/openstack_sdk/src/api/block_storage/v3/worker.rs b/openstack_sdk/src/api/block_storage/v3/worker.rs new file mode 100644 index 000000000..786083b8e --- /dev/null +++ b/openstack_sdk/src/api/block_storage/v3/worker.rs @@ -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-quota-sets/{id}` REST operations of block_storage +pub mod cleanup; diff --git a/openstack_sdk/src/api/block_storage/v3/worker/cleanup.rs b/openstack_sdk/src/api/block_storage/v3/worker/cleanup.rs new file mode 100644 index 000000000..f77de969d --- /dev/null +++ b/openstack_sdk/src/api/block_storage/v3/worker/cleanup.rs @@ -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/workers/cleanup` REST operations of block_storage +pub mod create_324; diff --git a/openstack_sdk/src/api/block_storage/v3/worker/cleanup/create_324.rs b/openstack_sdk/src/api/block_storage/v3/worker/cleanup/create_324.rs new file mode 100644 index 000000000..4ffbe7f56 --- /dev/null +++ b/openstack_sdk/src/api/block_storage/v3/worker/cleanup/create_324.rs @@ -0,0 +1,233 @@ +// 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`. + +//! Do the cleanup on resources from a specific service/host/node. +//! +use derive_builder::Builder; +use http::{HeaderMap, HeaderName, HeaderValue}; + +use crate::api::rest_endpoint_prelude::*; + +use serde::Deserialize; +use serde::Serialize; +use std::borrow::Cow; + +#[derive(Debug, Deserialize, Clone, Serialize)] +pub enum Binary { + #[serde(rename = "cinder-scheduler")] + CinderScheduler, + #[serde(rename = "cinder-volume")] + CinderVolume, +} + +#[derive(Builder, Debug, Clone)] +#[builder(setter(strip_option))] +pub struct Request<'a> { + #[builder(default)] + pub(crate) binary: Option, + + #[builder(default, setter(into))] + pub(crate) cluster_name: Option>>, + + #[builder(default)] + pub(crate) disabled: Option, + + #[builder(default, setter(into))] + pub(crate) host: Option>>, + + #[builder(default)] + pub(crate) is_up: Option, + + #[builder(default, setter(into))] + pub(crate) resource_id: Option>>, + + #[builder(default, setter(into))] + pub(crate) resource_type: Option>>, + + #[builder(default, setter(into))] + pub(crate) service_id: Option>>, + + #[builder(setter(name = "_headers"), default, private)] + _headers: Option, +} +impl<'a> Request<'a> { + /// Create a builder for the endpoint. + pub fn builder() -> RequestBuilder<'a> { + RequestBuilder::default() + } +} + +impl<'a> RequestBuilder<'a> { + /// Add a single header to the Cleanup. + pub fn header(&mut self, header_name: &'static str, header_value: &'static str) -> &mut Self +where { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .insert(header_name, HeaderValue::from_static(header_value)); + self + } + + /// Add multiple headers. + pub fn headers(&mut self, iter: I) -> &mut Self + where + I: Iterator, + T: Into<(Option, HeaderValue)>, + { + self._headers + .get_or_insert(None) + .get_or_insert_with(HeaderMap::new) + .extend(iter.map(Into::into)); + self + } +} + +impl<'a> RestEndpoint for Request<'a> { + fn method(&self) -> http::Method { + http::Method::POST + } + + fn endpoint(&self) -> Cow<'static, str> { + "workers/cleanup".to_string().into() + } + + fn parameters(&self) -> QueryParams { + QueryParams::default() + } + + fn body(&self) -> Result)>, BodyError> { + let mut params = JsonBodyParams::default(); + + if let Some(val) = &self.cluster_name { + params.push("cluster_name", serde_json::to_value(val)?); + } + if let Some(val) = &self.disabled { + params.push("disabled", serde_json::to_value(val)?); + } + if let Some(val) = &self.host { + params.push("host", serde_json::to_value(val)?); + } + if let Some(val) = &self.is_up { + params.push("is_up", serde_json::to_value(val)?); + } + if let Some(val) = &self.binary { + params.push("binary", serde_json::to_value(val)?); + } + if let Some(val) = &self.resource_id { + params.push("resource_id", serde_json::to_value(val)?); + } + if let Some(val) = &self.resource_type { + params.push("resource_type", serde_json::to_value(val)?); + } + if let Some(val) = &self.service_id { + params.push("service_id", serde_json::to_value(val)?); + } + + params.into_body() + } + + fn service_type(&self) -> ServiceType { + ServiceType::BlockStorage + } + + fn response_key(&self) -> Option> { + None + } + + /// Returns headers to be set into the request + fn request_headers(&self) -> Option<&HeaderMap> { + self._headers.as_ref() + } + + /// Returns required API version + fn api_version(&self) -> Option { + Some(ApiVersion::new(3, 24)) + } +} + +#[cfg(test)] +mod tests { + #![allow(unused_imports)] + use super::*; + #[cfg(feature = "sync")] + use crate::api::Query; + #[cfg(feature = "sync")] + use crate::test::client::MockServerClient; + use crate::types::ServiceType; + use http::{HeaderName, HeaderValue}; + use serde_json::json; + + #[test] + fn test_service_type() { + assert_eq!( + Request::builder().build().unwrap().service_type(), + ServiceType::BlockStorage + ); + } + + #[test] + fn test_response_key() { + assert!(Request::builder().build().unwrap().response_key().is_none()) + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint() { + let client = MockServerClient::new(); + let mock = client.server.mock(|when, then| { + when.method(httpmock::Method::POST) + .path("/workers/cleanup".to_string()); + + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "dummy": {} })); + }); + + let endpoint = Request::builder().build().unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } + + #[cfg(feature = "sync")] + #[test] + fn endpoint_headers() { + let client = MockServerClient::new(); + let mock = client.server.mock(|when, then| { + when.method(httpmock::Method::POST) + .path("/workers/cleanup".to_string()) + .header("foo", "bar") + .header("not_foo", "not_bar"); + then.status(200) + .header("content-type", "application/json") + .json_body(json!({ "dummy": {} })); + }); + + let endpoint = Request::builder() + .headers( + [( + Some(HeaderName::from_static("foo")), + HeaderValue::from_static("bar"), + )] + .into_iter(), + ) + .header("not_foo", "not_bar") + .build() + .unwrap(); + let _: serde_json::Value = endpoint.query(&client).unwrap(); + mock.assert(); + } +}