openstack_types/block_storage/v3/cluster/response/
get.rs

1// Licensed under the Apache License, Version 2.0 (the "License");
2// you may not use this file except in compliance with the License.
3// You may obtain a copy of the License at
4//
5//     http://www.apache.org/licenses/LICENSE-2.0
6//
7// Unless required by applicable law or agreed to in writing, software
8// distributed under the License is distributed on an "AS IS" BASIS,
9// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
10// See the License for the specific language governing permissions and
11// limitations under the License.
12//
13// SPDX-License-Identifier: Apache-2.0
14//
15// WARNING: This file is automatically generated from OpenAPI schema using
16// `openstack-codegenerator`.
17//! Response type for the GET `clusters/{id}` operation
18
19use serde::{Deserialize, Serialize};
20use structable::{StructTable, StructTableOptions};
21
22/// Cluster response representation
23#[derive(Clone, Deserialize, Serialize, StructTable)]
24pub struct ClusterResponse {
25    /// The ID of active storage backend. Only in cinder-volume service.
26    #[serde(default)]
27    #[structable(optional)]
28    pub active_backend_id: Option<String>,
29
30    /// The binary name of the services in the cluster.
31    #[serde(default)]
32    #[structable(optional)]
33    pub binary: Option<String>,
34
35    /// The date and time when the resource was created.
36    #[serde(default)]
37    #[structable(optional)]
38    pub created_at: Option<String>,
39
40    /// The reason for disabling a resource.
41    #[serde(default)]
42    #[structable(optional)]
43    pub disabled_reason: Option<String>,
44
45    /// Whether the cluster is frozen or not.
46    #[serde(default)]
47    #[structable(optional)]
48    pub frozen: Option<bool>,
49
50    /// The last periodic heartbeat received.
51    #[serde(default)]
52    #[structable(optional)]
53    pub last_heartbeat: Option<String>,
54
55    /// The name of the service cluster.
56    #[serde(default)]
57    #[structable(optional)]
58    pub name: Option<String>,
59
60    /// The number of down hosts in the cluster.
61    #[serde(default)]
62    #[structable(optional)]
63    pub num_down_hosts: Option<i32>,
64
65    /// The number of hosts in the cluster.
66    #[serde(default)]
67    #[structable(optional)]
68    pub num_hosts: Option<i32>,
69
70    /// The cluster replication status. Only included in responses if
71    /// configured.
72    #[serde(default)]
73    #[structable(optional, serialize)]
74    pub replication_status: Option<ReplicationStatus>,
75
76    /// The state of the cluster.
77    #[serde(default)]
78    #[structable(optional, serialize)]
79    pub state: Option<State>,
80
81    /// The status of the cluster.
82    #[serde(default)]
83    #[structable(optional, serialize)]
84    pub status: Option<Status>,
85
86    /// The date and time when the resource was updated.
87    #[serde(default)]
88    #[structable(optional)]
89    pub updated_at: Option<String>,
90}
91
92#[derive(Debug, Deserialize, Clone, Serialize)]
93pub enum ReplicationStatus {
94    // Disabled
95    #[serde(rename = "disabled")]
96    Disabled,
97
98    // Enabled
99    #[serde(rename = "enabled")]
100    Enabled,
101}
102
103impl std::str::FromStr for ReplicationStatus {
104    type Err = ();
105    fn from_str(input: &str) -> Result<Self, Self::Err> {
106        match input {
107            "disabled" => Ok(Self::Disabled),
108            "enabled" => Ok(Self::Enabled),
109            _ => Err(()),
110        }
111    }
112}
113
114#[derive(Debug, Deserialize, Clone, Serialize)]
115pub enum State {
116    // Down
117    #[serde(rename = "down")]
118    Down,
119
120    // Up
121    #[serde(rename = "up")]
122    Up,
123}
124
125impl std::str::FromStr for State {
126    type Err = ();
127    fn from_str(input: &str) -> Result<Self, Self::Err> {
128        match input {
129            "down" => Ok(Self::Down),
130            "up" => Ok(Self::Up),
131            _ => Err(()),
132        }
133    }
134}
135
136#[derive(Debug, Deserialize, Clone, Serialize)]
137pub enum Status {
138    // Disabled
139    #[serde(rename = "disabled")]
140    Disabled,
141
142    // Enabled
143    #[serde(rename = "enabled")]
144    Enabled,
145}
146
147impl std::str::FromStr for Status {
148    type Err = ();
149    fn from_str(input: &str) -> Result<Self, Self::Err> {
150        match input {
151            "disabled" => Ok(Self::Disabled),
152            "enabled" => Ok(Self::Enabled),
153            _ => Err(()),
154        }
155    }
156}