From 17a049be4dd791b4954f0a12fb8fea719aca4efb Mon Sep 17 00:00:00 2001 From: Artem Goncharov Date: Thu, 18 Dec 2025 12:02:18 +0100 Subject: [PATCH] chore: Prepare update of the block-storage data In cinder few schemas has been modified: - attachment completion now properly reports that it requires 3.44 mv - cluster set is replaced with dedicated enable/disable calls --- .../src/block_storage/v3/attachment.rs | 7 +- .../{os_complete.rs => os_complete_344.rs} | 16 +- openstack_cli/src/block_storage/v3/cluster.rs | 3 - .../src/block_storage/v3/cluster/set.rs | 116 ---------- .../src/block_storage/v3/service/set.rs | 106 --------- .../tests/block_storage/v3/cluster/mod.rs | 1 - .../block_storage/v3/cluster/set_autogen.rs | 32 --- .../src/api/block_storage/v3/attachment.rs | 2 +- .../{os_complete.rs => os_complete_344.rs} | 27 ++- .../src/api/block_storage/v3/cluster.rs | 1 - .../src/api/block_storage/v3/cluster/set.rs | 219 ------------------ .../src/block_storage/v3/cluster/response.rs | 1 - .../block_storage/v3/cluster/response/set.rs | 156 ------------- 13 files changed, 41 insertions(+), 646 deletions(-) rename openstack_cli/src/block_storage/v3/attachment/{os_complete.rs => os_complete_344.rs} (81%) delete mode 100644 openstack_cli/src/block_storage/v3/cluster/set.rs delete mode 100644 openstack_cli/src/block_storage/v3/service/set.rs delete mode 100644 openstack_cli/tests/block_storage/v3/cluster/set_autogen.rs rename openstack_sdk/src/api/block_storage/v3/attachment/{os_complete.rs => os_complete_344.rs} (88%) delete mode 100644 openstack_sdk/src/api/block_storage/v3/cluster/set.rs delete mode 100644 openstack_types/src/block_storage/v3/cluster/response/set.rs diff --git a/openstack_cli/src/block_storage/v3/attachment.rs b/openstack_cli/src/block_storage/v3/attachment.rs index 93eb4487f..9e0fb14ae 100644 --- a/openstack_cli/src/block_storage/v3/attachment.rs +++ b/openstack_cli/src/block_storage/v3/attachment.rs @@ -25,7 +25,7 @@ pub mod create_327; pub mod create_354; pub mod delete; pub mod list; -pub mod os_complete; +pub mod os_complete_344; pub mod set_327; pub mod show; @@ -63,7 +63,8 @@ pub struct AttachmentCommand { #[allow(missing_docs)] #[derive(Subcommand)] pub enum AttachmentCommands { - Complete(Box), + #[command(visible_alias = "complete")] + Complete344(Box), #[command(visible_alias = "create")] Create354(Box), Create327(Box), @@ -82,7 +83,7 @@ impl AttachmentCommand { session: &mut AsyncOpenStack, ) -> Result<(), OpenStackCliError> { match &self.command { - AttachmentCommands::Complete(cmd) => cmd.take_action(parsed_args, session).await, + AttachmentCommands::Complete344(cmd) => cmd.take_action(parsed_args, session).await, AttachmentCommands::Create354(cmd) => cmd.take_action(parsed_args, session).await, AttachmentCommands::Create327(cmd) => cmd.take_action(parsed_args, session).await, AttachmentCommands::Delete(cmd) => cmd.take_action(parsed_args, session).await, diff --git a/openstack_cli/src/block_storage/v3/attachment/os_complete.rs b/openstack_cli/src/block_storage/v3/attachment/os_complete_344.rs similarity index 81% rename from openstack_cli/src/block_storage/v3/attachment/os_complete.rs rename to openstack_cli/src/block_storage/v3/attachment/os_complete_344.rs index 3c528248b..45f29cea5 100644 --- a/openstack_cli/src/block_storage/v3/attachment/os_complete.rs +++ b/openstack_cli/src/block_storage/v3/attachment/os_complete_344.rs @@ -29,7 +29,8 @@ use crate::OpenStackCliError; use crate::output::OutputProcessor; use openstack_sdk::api::QueryAsync; -use openstack_sdk::api::block_storage::v3::attachment::os_complete; +use openstack_sdk::api::block_storage::v3::attachment::os_complete_344; +use serde_json::Value; /// Empty body for os-complete action #[derive(Args)] @@ -41,6 +42,9 @@ pub struct AttachmentCommand { /// Path parameters #[command(flatten)] path: PathParameters, + + #[arg(help_heading = "Body parameters", long, value_name="JSON", value_parser=crate::common::parse_json)] + os_complete: Value, } /// Query parameters @@ -75,10 +79,18 @@ impl AttachmentCommand { ); op.validate_args(parsed_args)?; - let mut ep_builder = os_complete::Request::builder(); + let mut ep_builder = os_complete_344::Request::builder(); + ep_builder.header( + http::header::HeaderName::from_static("openstack-api-version"), + http::header::HeaderValue::from_static("volume 3.44"), + ); ep_builder.id(&self.path.id); + // Set body parameters + // Set Request.os_complete data + ep_builder.os_complete(self.os_complete.clone()); + let ep = ep_builder .build() .map_err(|x| OpenStackCliError::EndpointBuild(x.to_string()))?; diff --git a/openstack_cli/src/block_storage/v3/cluster.rs b/openstack_cli/src/block_storage/v3/cluster.rs index 0fab2d911..8e066e008 100644 --- a/openstack_cli/src/block_storage/v3/cluster.rs +++ b/openstack_cli/src/block_storage/v3/cluster.rs @@ -22,7 +22,6 @@ use crate::{Cli, OpenStackCliError}; use openstack_sdk::AsyncOpenStack; pub mod list; -pub mod set; pub mod show; /// Clusters (clusters) @@ -58,7 +57,6 @@ pub struct ClusterCommand { #[derive(Subcommand)] pub enum ClusterCommands { List(Box), - Set(Box), Show(Box), } @@ -71,7 +69,6 @@ impl ClusterCommand { ) -> Result<(), OpenStackCliError> { match &self.command { ClusterCommands::List(cmd) => cmd.take_action(parsed_args, session).await, - ClusterCommands::Set(cmd) => cmd.take_action(parsed_args, session).await, ClusterCommands::Show(cmd) => cmd.take_action(parsed_args, session).await, } } diff --git a/openstack_cli/src/block_storage/v3/cluster/set.rs b/openstack_cli/src/block_storage/v3/cluster/set.rs deleted file mode 100644 index b0ec44d10..000000000 --- a/openstack_cli/src/block_storage/v3/cluster/set.rs +++ /dev/null @@ -1,116 +0,0 @@ -// 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 Cluster command -//! -//! Wraps invoking of the `v3/clusters/{id}` with `PUT` method - -use clap::Args; -use tracing::info; - -use openstack_sdk::AsyncOpenStack; - -use crate::Cli; -use crate::OpenStackCliError; -use crate::output::OutputProcessor; - -use openstack_sdk::api::QueryAsync; -use openstack_sdk::api::block_storage::v3::cluster::set; -use openstack_types::block_storage::v3::cluster::response::set::ClusterResponse; - -/// Enable/Disable scheduling for a cluster. -#[derive(Args)] -pub struct ClusterCommand { - /// Request Query parameters - #[command(flatten)] - query: QueryParameters, - - /// Path parameters - #[command(flatten)] - path: PathParameters, - - /// The binary name of the services in the cluster. - #[arg(help_heading = "Body parameters", long)] - binary: Option, - - /// The reason for disabling a resource. - #[arg(help_heading = "Body parameters", long)] - disabled_reason: Option, - - /// The name to identify the service cluster. - #[arg(help_heading = "Body parameters", long)] - name: String, -} - -/// Query parameters -#[derive(Args)] -struct QueryParameters {} - -/// Path parameters -#[derive(Args)] -struct PathParameters { - /// id parameter for /v3/clusters/{id} API - #[arg( - help_heading = "Path parameters", - id = "path_param_id", - value_name = "ID" - )] - id: String, -} - -impl ClusterCommand { - /// Perform command action - pub async fn take_action( - &self, - parsed_args: &Cli, - client: &mut AsyncOpenStack, - ) -> Result<(), OpenStackCliError> { - info!("Set Cluster"); - - let op = - OutputProcessor::from_args(parsed_args, Some("block-storage.cluster"), Some("set")); - op.validate_args(parsed_args)?; - - let mut ep_builder = set::Request::builder(); - - ep_builder.id(&self.path.id); - - // Set body parameters - // Set Request.binary data - if let Some(arg) = &self.binary { - ep_builder.binary(Some(arg.into())); - } - - // Set Request.disabled_reason data - if let Some(arg) = &self.disabled_reason { - ep_builder.disabled_reason(Some(arg.into())); - } - - // Set Request.name data - ep_builder.name(&self.name); - - let ep = ep_builder - .build() - .map_err(|x| OpenStackCliError::EndpointBuild(x.to_string()))?; - - let data = ep.query_async(client).await?; - op.output_single::(data)?; - // Show command specific hints - op.show_command_hint()?; - Ok(()) - } -} diff --git a/openstack_cli/src/block_storage/v3/service/set.rs b/openstack_cli/src/block_storage/v3/service/set.rs deleted file mode 100644 index 465801531..000000000 --- a/openstack_cli/src/block_storage/v3/service/set.rs +++ /dev/null @@ -1,106 +0,0 @@ -// 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 eyre::{OptionExt, WrapErr}; -use tracing::info; - -use openstack_sdk::AsyncOpenStack; - -use crate::Cli; -use crate::OpenStackCliError; -use crate::output::OutputProcessor; - -use crate::common::parse_key_val; -use openstack_sdk::api::QueryAsync; -use openstack_sdk::api::block_storage::v3::service::set; -use openstack_types::block_storage::v3::service::response::set::ServiceResponse; -use serde_json::Value; - -/// 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, -} - -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, Some("block-storage.service"), Some("set")); - op.validate_args(parsed_args)?; - - let mut ep_builder = set::Request::builder(); - - ep_builder.id(&self.path.id); - - // 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)?; - // Show command specific hints - op.show_command_hint()?; - Ok(()) - } -} diff --git a/openstack_cli/tests/block_storage/v3/cluster/mod.rs b/openstack_cli/tests/block_storage/v3/cluster/mod.rs index 82fd75fdc..ab237c838 100644 --- a/openstack_cli/tests/block_storage/v3/cluster/mod.rs +++ b/openstack_cli/tests/block_storage/v3/cluster/mod.rs @@ -13,7 +13,6 @@ // SPDX-License-Identifier: Apache-2.0 mod list_autogen; -mod set_autogen; mod show_autogen; use assert_cmd::prelude::*; diff --git a/openstack_cli/tests/block_storage/v3/cluster/set_autogen.rs b/openstack_cli/tests/block_storage/v3/cluster/set_autogen.rs deleted file mode 100644 index 093df382e..000000000 --- a/openstack_cli/tests/block_storage/v3/cluster/set_autogen.rs +++ /dev/null @@ -1,32 +0,0 @@ -// 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("cluster") - .arg("set") - .arg("--help"); - cmd.assert().success(); - - Ok(()) -} diff --git a/openstack_sdk/src/api/block_storage/v3/attachment.rs b/openstack_sdk/src/api/block_storage/v3/attachment.rs index 3c4ab344e..57bd30eaf 100644 --- a/openstack_sdk/src/api/block_storage/v3/attachment.rs +++ b/openstack_sdk/src/api/block_storage/v3/attachment.rs @@ -22,5 +22,5 @@ pub mod delete; pub mod get; pub mod list; pub mod list_detailed; -pub mod os_complete; +pub mod os_complete_344; pub mod set_327; diff --git a/openstack_sdk/src/api/block_storage/v3/attachment/os_complete.rs b/openstack_sdk/src/api/block_storage/v3/attachment/os_complete_344.rs similarity index 88% rename from openstack_sdk/src/api/block_storage/v3/attachment/os_complete.rs rename to openstack_sdk/src/api/block_storage/v3/attachment/os_complete_344.rs index 5304aa274..2a6e2b256 100644 --- a/openstack_sdk/src/api/block_storage/v3/attachment/os_complete.rs +++ b/openstack_sdk/src/api/block_storage/v3/attachment/os_complete_344.rs @@ -26,6 +26,9 @@ use std::borrow::Cow; #[derive(Builder, Debug, Clone)] #[builder(setter(strip_option))] pub struct Request<'a> { + #[builder(setter(into))] + pub(crate) os_complete: Value, + /// id parameter for /v3/attachments/{id}/action API #[builder(default, setter(into))] id: Cow<'a, str>, @@ -84,7 +87,7 @@ impl RestEndpoint for Request<'_> { fn body(&self) -> Result)>, BodyError> { let mut params = JsonBodyParams::default(); - params.push("os-complete", Value::Null); + params.push("os-complete", serde_json::to_value(&self.os_complete)?); params.into_body() } @@ -104,7 +107,7 @@ impl RestEndpoint for Request<'_> { /// Returns required API version fn api_version(&self) -> Option { - Some(ApiVersion::new(3, 0)) + Some(ApiVersion::new(3, 44)) } } @@ -122,14 +125,23 @@ mod tests { #[test] fn test_service_type() { assert_eq!( - Request::builder().build().unwrap().service_type(), + Request::builder() + .os_complete(json!({})) + .build() + .unwrap() + .service_type(), ServiceType::BlockStorage ); } #[test] fn test_response_key() { - assert!(Request::builder().build().unwrap().response_key().is_none()) + assert!(Request::builder() + .os_complete(json!({})) + .build() + .unwrap() + .response_key() + .is_none()) } #[cfg(feature = "sync")] @@ -146,7 +158,11 @@ mod tests { .json_body(json!({ "dummy": {} })); }); - let endpoint = Request::builder().id("id").build().unwrap(); + let endpoint = Request::builder() + .id("id") + .os_complete(json!({})) + .build() + .unwrap(); let _: serde_json::Value = endpoint.query(&client).unwrap(); mock.assert(); } @@ -168,6 +184,7 @@ mod tests { let endpoint = Request::builder() .id("id") + .os_complete(json!({})) .headers( [( Some(HeaderName::from_static("foo")), diff --git a/openstack_sdk/src/api/block_storage/v3/cluster.rs b/openstack_sdk/src/api/block_storage/v3/cluster.rs index 4f5eab6e2..cf81c0ed5 100644 --- a/openstack_sdk/src/api/block_storage/v3/cluster.rs +++ b/openstack_sdk/src/api/block_storage/v3/cluster.rs @@ -19,4 +19,3 @@ pub mod get; pub mod list; pub mod list_detailed; -pub mod set; diff --git a/openstack_sdk/src/api/block_storage/v3/cluster/set.rs b/openstack_sdk/src/api/block_storage/v3/cluster/set.rs deleted file mode 100644 index 2f150865b..000000000 --- a/openstack_sdk/src/api/block_storage/v3/cluster/set.rs +++ /dev/null @@ -1,219 +0,0 @@ -// 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 cluster. -//! -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> { - /// The binary name of the services in the cluster. - #[builder(default, setter(into))] - pub(crate) binary: Option>>, - - /// The reason for disabling a resource. - #[builder(default, setter(into))] - pub(crate) disabled_reason: Option>>, - - /// The name to identify the service cluster. - #[builder(setter(into))] - pub(crate) name: Cow<'a, str>, - - /// id parameter for /v3/clusters/{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 Cluster. - pub fn header(&mut self, header_name: K, header_value: V) -> &mut Self - where - K: Into, - V: Into, - { - self._headers - .get_or_insert(None) - .get_or_insert_with(HeaderMap::new) - .insert(header_name.into(), header_value.into()); - 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::PUT - } - - fn endpoint(&self) -> Cow<'static, str> { - format!("clusters/{id}", id = self.id.as_ref(),).into() - } - - fn parameters(&self) -> QueryParams<'_> { - QueryParams::default() - } - - fn body(&self) -> Result)>, BodyError> { - let mut params = JsonBodyParams::default(); - - if let Some(val) = &self.binary { - params.push("binary", serde_json::to_value(val)?); - } - if let Some(val) = &self.disabled_reason { - params.push("disabled_reason", serde_json::to_value(val)?); - } - params.push("name", serde_json::to_value(&self.name)?); - - params.into_body() - } - - fn service_type(&self) -> ServiceType { - ServiceType::BlockStorage - } - - fn response_key(&self) -> Option> { - Some("cluster".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 { - use super::*; - #[cfg(feature = "sync")] - use crate::api::Query; - use crate::test::client::FakeOpenStackClient; - use crate::types::ServiceType; - use http::{HeaderName, HeaderValue}; - use httpmock::MockServer; - use serde_json::json; - - #[test] - fn test_service_type() { - assert_eq!( - Request::builder() - .name("foo") - .build() - .unwrap() - .service_type(), - ServiceType::BlockStorage - ); - } - - #[test] - fn test_response_key() { - assert_eq!( - Request::builder() - .name("foo") - .build() - .unwrap() - .response_key() - .unwrap(), - "cluster" - ); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::PUT) - .path(format!("/clusters/{id}", id = "id",)); - - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "cluster": {} })); - }); - - let endpoint = Request::builder().id("id").name("foo").build().unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } - - #[cfg(feature = "sync")] - #[test] - fn endpoint_headers() { - let server = MockServer::start(); - let client = FakeOpenStackClient::new(server.base_url()); - let mock = server.mock(|when, then| { - when.method(httpmock::Method::PUT) - .path(format!("/clusters/{id}", id = "id",)) - .header("foo", "bar") - .header("not_foo", "not_bar"); - then.status(200) - .header("content-type", "application/json") - .json_body(json!({ "cluster": {} })); - }); - - let endpoint = Request::builder() - .id("id") - .name("foo") - .headers( - [( - Some(HeaderName::from_static("foo")), - HeaderValue::from_static("bar"), - )] - .into_iter(), - ) - .header( - HeaderName::from_static("not_foo"), - HeaderValue::from_static("not_bar"), - ) - .build() - .unwrap(); - let _: serde_json::Value = endpoint.query(&client).unwrap(); - mock.assert(); - } -} diff --git a/openstack_types/src/block_storage/v3/cluster/response.rs b/openstack_types/src/block_storage/v3/cluster/response.rs index 5ba9aa4ff..f1febc5ff 100644 --- a/openstack_types/src/block_storage/v3/cluster/response.rs +++ b/openstack_types/src/block_storage/v3/cluster/response.rs @@ -19,4 +19,3 @@ pub mod get; pub mod list; pub mod list_detailed; -pub mod set; diff --git a/openstack_types/src/block_storage/v3/cluster/response/set.rs b/openstack_types/src/block_storage/v3/cluster/response/set.rs deleted file mode 100644 index 186bb4f67..000000000 --- a/openstack_types/src/block_storage/v3/cluster/response/set.rs +++ /dev/null @@ -1,156 +0,0 @@ -// 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`. -//! Response type for the PUT `clusters/{id}` operation - -use serde::{Deserialize, Serialize}; -use structable::{StructTable, StructTableOptions}; - -/// Cluster response representation -#[derive(Clone, Deserialize, Serialize, StructTable)] -pub struct ClusterResponse { - /// The ID of active storage backend. Only in cinder-volume service. - #[serde(default)] - #[structable(optional)] - pub active_backend_id: Option, - - /// The binary name of the services in the cluster. - #[serde(default)] - #[structable(optional)] - pub binary: Option, - - /// The date and time when the resource was created. - #[serde(default)] - #[structable(optional)] - pub created_at: Option, - - /// The reason for disabling a resource. - #[serde(default)] - #[structable(optional)] - pub disabled_reason: Option, - - /// Whether the cluster is frozen or not. - #[serde(default)] - #[structable(optional)] - pub frozen: Option, - - /// The last periodic heartbeat received. - #[serde(default)] - #[structable(optional)] - pub last_heartbeat: Option, - - /// The name of the service cluster. - #[serde(default)] - #[structable(optional)] - pub name: Option, - - /// The number of down hosts in the cluster. - #[serde(default)] - #[structable(optional)] - pub num_down_hosts: Option, - - /// The number of hosts in the cluster. - #[serde(default)] - #[structable(optional)] - pub num_hosts: Option, - - /// The cluster replication status. Only included in responses if - /// configured. - #[serde(default)] - #[structable(optional, serialize)] - pub replication_status: Option, - - /// The state of the cluster. - #[serde(default)] - #[structable(optional, serialize)] - pub state: Option, - - /// The status of the cluster. - #[serde(default)] - #[structable(optional, serialize)] - pub status: Option, - - /// The date and time when the resource was updated. - #[serde(default)] - #[structable(optional)] - pub updated_at: Option, -} - -#[derive(Debug, Deserialize, Clone, Serialize)] -pub enum ReplicationStatus { - // Disabled - #[serde(rename = "disabled")] - Disabled, - - // Enabled - #[serde(rename = "enabled")] - Enabled, -} - -impl std::str::FromStr for ReplicationStatus { - type Err = (); - fn from_str(input: &str) -> Result { - match input { - "disabled" => Ok(Self::Disabled), - "enabled" => Ok(Self::Enabled), - _ => Err(()), - } - } -} - -#[derive(Debug, Deserialize, Clone, Serialize)] -pub enum State { - // Down - #[serde(rename = "down")] - Down, - - // Up - #[serde(rename = "up")] - Up, -} - -impl std::str::FromStr for State { - type Err = (); - fn from_str(input: &str) -> Result { - match input { - "down" => Ok(Self::Down), - "up" => Ok(Self::Up), - _ => Err(()), - } - } -} - -#[derive(Debug, Deserialize, Clone, Serialize)] -pub enum Status { - // Disabled - #[serde(rename = "disabled")] - Disabled, - - // Enabled - #[serde(rename = "enabled")] - Enabled, -} - -impl std::str::FromStr for Status { - type Err = (); - fn from_str(input: &str) -> Result { - match input { - "disabled" => Ok(Self::Disabled), - "enabled" => Ok(Self::Enabled), - _ => Err(()), - } - } -}