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
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
//! Insight model for Appwrite SDK
use serde::{Deserialize, Serialize};
/// Insight
#[derive(Debug, Clone, Serialize, Deserialize)]
#[cfg_attr(test, derive(Default))]
pub struct Insight {
/// Insight ID.
#[serde(rename = "$id")]
pub id: String,
/// Insight creation date in ISO 8601 format.
#[serde(rename = "$createdAt")]
pub created_at: String,
/// Insight update date in ISO 8601 format.
#[serde(rename = "$updatedAt")]
pub updated_at: String,
/// Parent report ID. Insights always belong to a report.
#[serde(rename = "reportId")]
pub report_id: String,
/// Insight type. One of databaseIndex (legacy), tablesDBIndex,
/// documentsDBIndex, vectorsDBIndex, databasePerformance, sitePerformance,
/// siteAccessibility, siteSeo, functionPerformance. The index types are
/// engine-specific so each CTA can pair the right service+method
/// (databases.createIndex, tablesDB.createIndex, documentsDB.createIndex, or
/// vectorsDB.createIndex).
#[serde(rename = "type")]
pub r#type: String,
/// Insight severity. One of info, warning, critical.
#[serde(rename = "severity")]
pub severity: String,
/// Insight status. One of active, dismissed.
#[serde(rename = "status")]
pub status: String,
/// Type of the resource the insight is about. Plural noun, e.g. databases,
/// sites, functions.
#[serde(rename = "resourceType")]
pub resource_type: String,
/// ID of the resource the insight is about.
#[serde(rename = "resourceId")]
pub resource_id: String,
/// Plural noun for the parent resource that contains the insight's resource,
/// e.g. an insight about a column index on a table → resourceType=indexes,
/// parentResourceType=tables. Empty when the resource has no parent.
#[serde(rename = "parentResourceType")]
pub parent_resource_type: String,
/// ID of the parent resource. Empty when the resource has no parent.
#[serde(rename = "parentResourceId")]
pub parent_resource_id: String,
/// Insight title.
#[serde(rename = "title")]
pub title: String,
/// Short markdown summary describing the insight.
#[serde(rename = "summary")]
pub summary: String,
/// List of call-to-action buttons attached to this insight.
#[serde(rename = "ctas")]
pub ctas: Vec<crate::models::InsightCTA>,
/// Time the insight was analyzed in ISO 8601 format.
#[serde(rename = "analyzedAt")]
#[serde(skip_serializing_if = "Option::is_none")]
pub analyzed_at: Option<String>,
/// Time the insight was dismissed in ISO 8601 format. Empty when not
/// dismissed.
#[serde(rename = "dismissedAt")]
#[serde(skip_serializing_if = "Option::is_none")]
pub dismissed_at: Option<String>,
/// User ID that dismissed the insight. Empty when not dismissed.
#[serde(rename = "dismissedBy")]
#[serde(skip_serializing_if = "Option::is_none")]
pub dismissed_by: Option<String>,
}
impl Insight {
/// Get id
pub fn id(&self) -> &String {
&self.id
}
/// Get created_at
pub fn created_at(&self) -> &String {
&self.created_at
}
/// Get updated_at
pub fn updated_at(&self) -> &String {
&self.updated_at
}
/// Get report_id
pub fn report_id(&self) -> &String {
&self.report_id
}
/// Get r#type
pub fn r#type(&self) -> &String {
&self.r#type
}
/// Get severity
pub fn severity(&self) -> &String {
&self.severity
}
/// Get status
pub fn status(&self) -> &String {
&self.status
}
/// Get resource_type
pub fn resource_type(&self) -> &String {
&self.resource_type
}
/// Get resource_id
pub fn resource_id(&self) -> &String {
&self.resource_id
}
/// Get parent_resource_type
pub fn parent_resource_type(&self) -> &String {
&self.parent_resource_type
}
/// Get parent_resource_id
pub fn parent_resource_id(&self) -> &String {
&self.parent_resource_id
}
/// Get title
pub fn title(&self) -> &String {
&self.title
}
/// Get summary
pub fn summary(&self) -> &String {
&self.summary
}
/// Get ctas
pub fn ctas(&self) -> &Vec<crate::models::InsightCTA> {
&self.ctas
}
/// Set analyzed_at
pub fn set_analyzed_at(mut self, analyzed_at: String) -> Self {
self.analyzed_at = Some(analyzed_at);
self
}
/// Get analyzed_at
pub fn analyzed_at(&self) -> Option<&String> {
self.analyzed_at.as_ref()
}
/// Set dismissed_at
pub fn set_dismissed_at(mut self, dismissed_at: String) -> Self {
self.dismissed_at = Some(dismissed_at);
self
}
/// Get dismissed_at
pub fn dismissed_at(&self) -> Option<&String> {
self.dismissed_at.as_ref()
}
/// Set dismissed_by
pub fn set_dismissed_by(mut self, dismissed_by: String) -> Self {
self.dismissed_by = Some(dismissed_by);
self
}
/// Get dismissed_by
pub fn dismissed_by(&self) -> Option<&String> {
self.dismissed_by.as_ref()
}
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn test_insight_creation() {
let _model = <Insight as Default>::default();
let _ = _model.id();
let _ = _model.created_at();
let _ = _model.updated_at();
let _ = _model.report_id();
let _ = _model.r#type();
let _ = _model.severity();
let _ = _model.status();
let _ = _model.resource_type();
let _ = _model.resource_id();
let _ = _model.parent_resource_type();
let _ = _model.parent_resource_id();
let _ = _model.title();
let _ = _model.summary();
let _ = _model.ctas();
}
#[test]
fn test_insight_serialization() {
let model = <Insight as Default>::default();
let json = serde_json::to_string(&model);
assert!(json.is_ok());
let deserialized: Result<Insight, _> = serde_json::from_str(&json.unwrap());
assert!(deserialized.is_ok());
}
}