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
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
// Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License.
// This product includes software developed at Datadog (https://www.datadoghq.com/).
// Copyright 2019-Present Datadog, Inc.
use serde::de::{Error, MapAccess, Visitor};
use serde::{Deserialize, Deserializer, Serialize};
use serde_with::skip_serializing_none;
use std::fmt::{self, Formatter};
/// Attributes of a deployment in the v2 API response.
#[non_exhaustive]
#[skip_serializing_none]
#[derive(Clone, Debug, PartialEq, Serialize)]
pub struct FleetDeploymentV2Attributes {
/// Handle of the user who triggered the deployment.
#[serde(rename = "author")]
pub author: Option<String>,
/// Ordered list of configuration file operations applied by this deployment.
/// Absent for package deployments, which have no configuration file operations.
#[serde(rename = "config_operations")]
pub config_operations: Option<Vec<crate::datadogV2::model::FleetDeploymentOperation>>,
/// Duration of the deployment in seconds, computed as `finished_at - started_at`.
/// Zero if the deployment has not finished.
#[serde(rename = "duration_seconds")]
pub duration_seconds: Option<i64>,
/// Top-level error message for the deployment. Populated only when the deployment has failed.
#[serde(rename = "error_summary")]
pub error_summary: Option<String>,
/// Estimated completion time of the deployment as a Unix timestamp. Zero if not available.
#[serde(rename = "estimated_finished_at")]
pub estimated_finished_at: Option<i64>,
/// Time the deployment finished as a Unix timestamp. Zero if not yet finished.
#[serde(rename = "finished_at")]
pub finished_at: Option<i64>,
/// Whether this deployment was triggered by a schedule (`schedule_id` is non-empty).
#[serde(rename = "is_scheduled")]
pub is_scheduled: Option<bool>,
/// Query used to filter and select target hosts for the deployment.
#[serde(rename = "query")]
pub query: Option<String>,
/// Identifier of the schedule that triggered this deployment. Empty if triggered manually.
#[serde(rename = "schedule_id")]
pub schedule_id: Option<String>,
/// Time the deployment started as a Unix timestamp. Zero if not yet started.
#[serde(rename = "started_at")]
pub started_at: Option<i64>,
/// Current high-level status of the deployment (for example, "pending", "running",
/// "completed", "failed").
#[serde(rename = "status")]
pub status: Option<String>,
/// Package versions targeted by this deployment.
#[serde(rename = "target_versions")]
pub target_versions: Option<Vec<String>>,
/// Total number of hosts targeted by this deployment.
#[serde(rename = "total_hosts")]
pub total_hosts: Option<i64>,
/// Type of update operation performed by this deployment
/// (for example, "update_config_operations", "update_package").
#[serde(rename = "update_type")]
pub update_type: Option<String>,
#[serde(flatten)]
pub additional_properties: std::collections::BTreeMap<String, serde_json::Value>,
#[serde(skip)]
#[serde(default)]
pub(crate) _unparsed: bool,
}
impl FleetDeploymentV2Attributes {
pub fn new() -> FleetDeploymentV2Attributes {
FleetDeploymentV2Attributes {
author: None,
config_operations: None,
duration_seconds: None,
error_summary: None,
estimated_finished_at: None,
finished_at: None,
is_scheduled: None,
query: None,
schedule_id: None,
started_at: None,
status: None,
target_versions: None,
total_hosts: None,
update_type: None,
additional_properties: std::collections::BTreeMap::new(),
_unparsed: false,
}
}
pub fn author(mut self, value: String) -> Self {
self.author = Some(value);
self
}
pub fn config_operations(
mut self,
value: Vec<crate::datadogV2::model::FleetDeploymentOperation>,
) -> Self {
self.config_operations = Some(value);
self
}
pub fn duration_seconds(mut self, value: i64) -> Self {
self.duration_seconds = Some(value);
self
}
pub fn error_summary(mut self, value: String) -> Self {
self.error_summary = Some(value);
self
}
pub fn estimated_finished_at(mut self, value: i64) -> Self {
self.estimated_finished_at = Some(value);
self
}
pub fn finished_at(mut self, value: i64) -> Self {
self.finished_at = Some(value);
self
}
pub fn is_scheduled(mut self, value: bool) -> Self {
self.is_scheduled = Some(value);
self
}
pub fn query(mut self, value: String) -> Self {
self.query = Some(value);
self
}
pub fn schedule_id(mut self, value: String) -> Self {
self.schedule_id = Some(value);
self
}
pub fn started_at(mut self, value: i64) -> Self {
self.started_at = Some(value);
self
}
pub fn status(mut self, value: String) -> Self {
self.status = Some(value);
self
}
pub fn target_versions(mut self, value: Vec<String>) -> Self {
self.target_versions = Some(value);
self
}
pub fn total_hosts(mut self, value: i64) -> Self {
self.total_hosts = Some(value);
self
}
pub fn update_type(mut self, value: String) -> Self {
self.update_type = Some(value);
self
}
pub fn additional_properties(
mut self,
value: std::collections::BTreeMap<String, serde_json::Value>,
) -> Self {
self.additional_properties = value;
self
}
}
impl Default for FleetDeploymentV2Attributes {
fn default() -> Self {
Self::new()
}
}
impl<'de> Deserialize<'de> for FleetDeploymentV2Attributes {
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
where
D: Deserializer<'de>,
{
struct FleetDeploymentV2AttributesVisitor;
impl<'a> Visitor<'a> for FleetDeploymentV2AttributesVisitor {
type Value = FleetDeploymentV2Attributes;
fn expecting(&self, f: &mut Formatter<'_>) -> fmt::Result {
f.write_str("a mapping")
}
fn visit_map<M>(self, mut map: M) -> Result<Self::Value, M::Error>
where
M: MapAccess<'a>,
{
let mut author: Option<String> = None;
let mut config_operations: Option<
Vec<crate::datadogV2::model::FleetDeploymentOperation>,
> = None;
let mut duration_seconds: Option<i64> = None;
let mut error_summary: Option<String> = None;
let mut estimated_finished_at: Option<i64> = None;
let mut finished_at: Option<i64> = None;
let mut is_scheduled: Option<bool> = None;
let mut query: Option<String> = None;
let mut schedule_id: Option<String> = None;
let mut started_at: Option<i64> = None;
let mut status: Option<String> = None;
let mut target_versions: Option<Vec<String>> = None;
let mut total_hosts: Option<i64> = None;
let mut update_type: Option<String> = None;
let mut additional_properties: std::collections::BTreeMap<
String,
serde_json::Value,
> = std::collections::BTreeMap::new();
let mut _unparsed = false;
while let Some((k, v)) = map.next_entry::<String, serde_json::Value>()? {
match k.as_str() {
"author" => {
if v.is_null() {
continue;
}
author = Some(serde_json::from_value(v).map_err(M::Error::custom)?);
}
"config_operations" => {
if v.is_null() {
continue;
}
config_operations =
Some(serde_json::from_value(v).map_err(M::Error::custom)?);
}
"duration_seconds" => {
if v.is_null() {
continue;
}
duration_seconds =
Some(serde_json::from_value(v).map_err(M::Error::custom)?);
}
"error_summary" => {
if v.is_null() {
continue;
}
error_summary =
Some(serde_json::from_value(v).map_err(M::Error::custom)?);
}
"estimated_finished_at" => {
if v.is_null() {
continue;
}
estimated_finished_at =
Some(serde_json::from_value(v).map_err(M::Error::custom)?);
}
"finished_at" => {
if v.is_null() {
continue;
}
finished_at =
Some(serde_json::from_value(v).map_err(M::Error::custom)?);
}
"is_scheduled" => {
if v.is_null() {
continue;
}
is_scheduled =
Some(serde_json::from_value(v).map_err(M::Error::custom)?);
}
"query" => {
if v.is_null() {
continue;
}
query = Some(serde_json::from_value(v).map_err(M::Error::custom)?);
}
"schedule_id" => {
if v.is_null() {
continue;
}
schedule_id =
Some(serde_json::from_value(v).map_err(M::Error::custom)?);
}
"started_at" => {
if v.is_null() {
continue;
}
started_at = Some(serde_json::from_value(v).map_err(M::Error::custom)?);
}
"status" => {
if v.is_null() {
continue;
}
status = Some(serde_json::from_value(v).map_err(M::Error::custom)?);
}
"target_versions" => {
if v.is_null() {
continue;
}
target_versions =
Some(serde_json::from_value(v).map_err(M::Error::custom)?);
}
"total_hosts" => {
if v.is_null() {
continue;
}
total_hosts =
Some(serde_json::from_value(v).map_err(M::Error::custom)?);
}
"update_type" => {
if v.is_null() {
continue;
}
update_type =
Some(serde_json::from_value(v).map_err(M::Error::custom)?);
}
&_ => {
if let Ok(value) = serde_json::from_value(v.clone()) {
additional_properties.insert(k, value);
}
}
}
}
let content = FleetDeploymentV2Attributes {
author,
config_operations,
duration_seconds,
error_summary,
estimated_finished_at,
finished_at,
is_scheduled,
query,
schedule_id,
started_at,
status,
target_versions,
total_hosts,
update_type,
additional_properties,
_unparsed,
};
Ok(content)
}
}
deserializer.deserialize_any(FleetDeploymentV2AttributesVisitor)
}
}