1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
//! DatabaseStatus model for Appwrite SDK
use serde::{Deserialize, Serialize};
/// Status
#[derive(Debug, Clone, Serialize, Deserialize)]
#[cfg_attr(test, derive(Default))]
pub struct DatabaseStatus {
/// Overall health status: healthy, degraded, unhealthy, or unknown when
/// nothing could be measured.
#[serde(rename = "health")]
pub health: String,
/// Whether the database is ready to accept connections.
#[serde(rename = "ready")]
pub ready: bool,
/// Database engine: postgresql, mysql, or mongodb.
#[serde(rename = "engine")]
pub engine: String,
/// Database engine version.
#[serde(rename = "version")]
pub version: String,
/// Database uptime in seconds.
#[serde(rename = "uptime")]
pub uptime: i64,
/// Connection statistics.
#[serde(rename = "connections")]
pub connections: crate::models::DatabaseStatusConnections,
/// Requested replication sync mode. Possible values: async, sync, quorum.
/// Compare with effectiveSyncMode for what the primary is enforcing.
#[serde(rename = "syncMode")]
pub sync_mode: String,
/// Replication sync mode the primary is actually enforcing. Null when high
/// availability is disabled or the state could not be read.
#[serde(rename = "effectiveSyncMode")]
#[serde(skip_serializing_if = "Option::is_none")]
pub effective_sync_mode: Option<String>,
/// Whether the enforced replication is weaker than the requested syncMode.
#[serde(rename = "syncDegraded")]
pub sync_degraded: bool,
/// Number of standby acknowledgements the primary waits for before a write is
/// committed.
#[serde(rename = "syncAcknowledgements")]
pub sync_acknowledgements: i64,
/// Number of standbys registered with the primary for synchronous replication.
#[serde(rename = "syncStandbyCount")]
pub sync_standby_count: i64,
/// Whether the other sync fields are an engine reading rather than a recorded
/// estimate. True when the primary answered what it is enforcing, including
/// when that answer contradicted the record, in which case the contradicted
/// values are replaced by the ones the engine reports. False when the reading
/// could not be taken: the probe did not answer, there was no engine to ask,
/// or the values describe a configuration change just applied rather than
/// anything measured. Absent when no engine was asked at all, so an unprobed
/// database is distinguishable from an unconfirmed one. False never means a
/// standby was found lagging, because it is the absence of a reading rather
/// than a negative one, so draw no conclusion about replication health from it
/// or from a response that omits it.
#[serde(rename = "syncStateConfirmed")]
#[serde(skip_serializing_if = "Option::is_none")]
pub sync_state_confirmed: Option<bool>,
/// List of database replicas and their status. Every configured member
/// appears, including one the backend has not brought up, which is reported as
/// not healthy.
#[serde(rename = "replicas")]
pub replicas: Vec<crate::models::DatabaseStatusReplica>,
/// Storage volume information.
#[serde(rename = "volumes")]
pub volumes: Vec<crate::models::DatabaseStatusVolume>,
}
impl DatabaseStatus {
/// Get health
pub fn health(&self) -> &String {
&self.health
}
/// Get ready
pub fn ready(&self) -> &bool {
&self.ready
}
/// Get engine
pub fn engine(&self) -> &String {
&self.engine
}
/// Get version
pub fn version(&self) -> &String {
&self.version
}
/// Get uptime
pub fn uptime(&self) -> &i64 {
&self.uptime
}
/// Get connections
pub fn connections(&self) -> &crate::models::DatabaseStatusConnections {
&self.connections
}
/// Get sync_mode
pub fn sync_mode(&self) -> &String {
&self.sync_mode
}
/// Set effective_sync_mode
pub fn set_effective_sync_mode(mut self, effective_sync_mode: String) -> Self {
self.effective_sync_mode = Some(effective_sync_mode);
self
}
/// Get effective_sync_mode
pub fn effective_sync_mode(&self) -> Option<&String> {
self.effective_sync_mode.as_ref()
}
/// Get sync_degraded
pub fn sync_degraded(&self) -> &bool {
&self.sync_degraded
}
/// Get sync_acknowledgements
pub fn sync_acknowledgements(&self) -> &i64 {
&self.sync_acknowledgements
}
/// Get sync_standby_count
pub fn sync_standby_count(&self) -> &i64 {
&self.sync_standby_count
}
/// Set sync_state_confirmed
pub fn set_sync_state_confirmed(mut self, sync_state_confirmed: bool) -> Self {
self.sync_state_confirmed = Some(sync_state_confirmed);
self
}
/// Get sync_state_confirmed
pub fn sync_state_confirmed(&self) -> Option<&bool> {
self.sync_state_confirmed.as_ref()
}
/// Get replicas
pub fn replicas(&self) -> &Vec<crate::models::DatabaseStatusReplica> {
&self.replicas
}
/// Get volumes
pub fn volumes(&self) -> &Vec<crate::models::DatabaseStatusVolume> {
&self.volumes
}
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn test_database_status_creation() {
let _model = <DatabaseStatus as Default>::default();
let _ = _model.health();
let _ = _model.ready();
let _ = _model.engine();
let _ = _model.version();
let _ = _model.uptime();
let _ = _model.connections();
let _ = _model.sync_mode();
let _ = _model.sync_degraded();
let _ = _model.sync_acknowledgements();
let _ = _model.sync_standby_count();
let _ = _model.replicas();
let _ = _model.volumes();
}
#[test]
fn test_database_status_serialization() {
let model = <DatabaseStatus as Default>::default();
let json = serde_json::to_string(&model);
assert!(json.is_ok());
let deserialized: Result<DatabaseStatus, _> = serde_json::from_str(&json.unwrap());
assert!(deserialized.is_ok());
}
}