azure-lite-rs 0.1.1

Lightweight HTTP client for Azure APIs
Documentation
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
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
//! Types for the Azure Defender for Cloud API (v1).
//!
//! Auto-generated from the Azure ARM REST Specification.
//! **Do not edit manually** — modify the manifest and re-run codegen.

use serde::{Deserialize, Serialize};

/// Describes the properties of a security alert.
///
/// **Azure API**: `security.v1.AlertProperties`
/// **Reference**: <https://learn.microsoft.com/en-us/rest/api/defenderforcloud//AlertProperties>
#[derive(Debug, Clone, Default, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct AlertProperties {
    /// The display name of the alert
    #[serde(skip_serializing_if = "Option::is_none")]
    pub alert_display_name: Option<String>,

    /// Unique identifier for the detection logic
    #[serde(skip_serializing_if = "Option::is_none")]
    pub alert_type: Option<String>,

    /// The display name of the resource most related to the alert
    #[serde(skip_serializing_if = "Option::is_none")]
    pub compromised_entity: Option<String>,

    /// Description of the suspected vulnerability and what it means
    #[serde(skip_serializing_if = "Option::is_none")]
    pub description: Option<String>,

    /// The risk level of the threat detected (High, Medium, Low, Informational)
    #[serde(skip_serializing_if = "Option::is_none")]
    pub severity: Option<String>,

    /// The lifecycle status of the alert (Active, Resolved, Dismissed)
    #[serde(skip_serializing_if = "Option::is_none")]
    pub status: Option<String>,

    /// The UTC time of the first event or activity included in the alert
    #[serde(skip_serializing_if = "Option::is_none")]
    pub start_time_utc: Option<String>,

    /// The UTC time the alert was generated
    #[serde(skip_serializing_if = "Option::is_none")]
    pub time_generated_utc: Option<String>,

    /// The name of the vendor that raises the alert
    #[serde(skip_serializing_if = "Option::is_none")]
    pub vendor_name: Option<String>,

    /// Manual action items to take to remediate the alert
    #[serde(default)]
    #[serde(skip_serializing_if = "Vec::is_empty")]
    pub remediation_steps: Vec<String>,

    /// The kill chain related intent behind the alert (e.g. Initial Access, Defense Evasion)
    #[serde(skip_serializing_if = "Option::is_none")]
    pub system_source: Option<String>,

    /// The kill chain related intent behind the alert
    #[serde(skip_serializing_if = "Option::is_none")]
    pub intent: Option<String>,
}

impl AlertProperties {
    #[cfg(any(test, feature = "test-support"))]
    /// Create a fixture instance for testing.
    pub fn fixture() -> Self {
        Self {
            alert_display_name: Some("test-alert_display_name".into()),
            alert_type: Some("test-alert_type".into()),
            compromised_entity: Some("test-compromised_entity".into()),
            description: Some("test-description".into()),
            severity: Some("test-severity".into()),
            status: Some("test-status".into()),
            start_time_utc: Some("test-start_time_utc".into()),
            time_generated_utc: Some("test-time_generated_utc".into()),
            vendor_name: Some("test-vendor_name".into()),
            remediation_steps: vec![],
            system_source: Some("test-system_source".into()),
            intent: Some("test-intent".into()),
        }
    }
}

/// Security alert.
///
/// **Azure API**: `security.v1.Alert`
/// **Reference**: <https://learn.microsoft.com/en-us/rest/api/defenderforcloud//Alert>
#[derive(Debug, Clone, Default, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct Alert {
    /// Fully qualified resource ID
    #[serde(skip_serializing_if = "Option::is_none")]
    pub id: Option<String>,

    /// The name of the resource
    #[serde(skip_serializing_if = "Option::is_none")]
    pub name: Option<String>,

    /// The type of the resource
    #[serde(rename = "type")]
    #[serde(skip_serializing_if = "Option::is_none")]
    pub r#type: Option<String>,

    /// Alert properties
    #[serde(skip_serializing_if = "Option::is_none")]
    pub properties: Option<AlertProperties>,
}

impl Alert {
    #[cfg(any(test, feature = "test-support"))]
    /// Create a fixture instance for testing.
    pub fn fixture() -> Self {
        Self {
            id: Some("test-id".into()),
            name: Some("test-alert".into()),
            r#type: Some("test-type".into()),
            properties: Some(AlertProperties::fixture()),
        }
    }
}

/// List of security alerts.
///
/// **Azure API**: `security.v1.AlertListResult`
/// **Reference**: <https://learn.microsoft.com/en-us/rest/api/defenderforcloud//AlertListResult>
#[derive(Debug, Clone, Default, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct AlertListResult {
    /// The list of security alerts
    #[serde(default)]
    #[serde(skip_serializing_if = "Vec::is_empty")]
    pub value: Vec<Alert>,

    /// The URI to fetch the next page of alerts
    #[serde(skip_serializing_if = "Option::is_none")]
    pub next_link: Option<String>,
}

impl AlertListResult {
    #[cfg(any(test, feature = "test-support"))]
    /// Create a fixture instance for testing.
    pub fn fixture() -> Self {
        Self {
            value: vec![],
            next_link: Some("test-next_link".into()),
        }
    }
}

/// Calculation result data.
///
/// **Azure API**: `security.v1.ScoreDetails`
/// **Reference**: <https://learn.microsoft.com/en-us/rest/api/defenderforcloud//ScoreDetails>
#[derive(Debug, Clone, Default, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct ScoreDetails {
    /// Maximum score available
    #[serde(skip_serializing_if = "Option::is_none")]
    pub max: Option<i32>,

    /// Current score
    #[serde(skip_serializing_if = "Option::is_none")]
    pub current: Option<f64>,

    /// Ratio of the current score divided by the maximum (0-1)
    #[serde(skip_serializing_if = "Option::is_none")]
    pub percentage: Option<f64>,
}

impl ScoreDetails {
    #[cfg(any(test, feature = "test-support"))]
    /// Create a fixture instance for testing.
    pub fn fixture() -> Self {
        Self {
            max: Some(100),
            ..Default::default()
        }
    }
}

/// Describes the properties of a security score.
///
/// **Azure API**: `security.v1.SecureScoreProperties`
/// **Reference**: <https://learn.microsoft.com/en-us/rest/api/defenderforcloud//SecureScoreProperties>
#[derive(Debug, Clone, Default, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct SecureScoreProperties {
    /// The initiative's name
    #[serde(skip_serializing_if = "Option::is_none")]
    pub display_name: Option<String>,

    /// Calculation result data
    #[serde(skip_serializing_if = "Option::is_none")]
    pub score: Option<ScoreDetails>,

    /// The relative weight for each subscription
    #[serde(skip_serializing_if = "Option::is_none")]
    pub weight: Option<i64>,
}

impl SecureScoreProperties {
    #[cfg(any(test, feature = "test-support"))]
    /// Create a fixture instance for testing.
    pub fn fixture() -> Self {
        Self {
            display_name: Some("test-display_name".into()),
            score: Some(ScoreDetails::fixture()),
            weight: Some(100),
        }
    }
}

/// Microsoft Defender for Cloud secure score.
///
/// **Azure API**: `security.v1.SecureScore`
/// **Reference**: <https://learn.microsoft.com/en-us/rest/api/defenderforcloud//SecureScore>
#[derive(Debug, Clone, Default, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct SecureScore {
    /// Fully qualified resource ID
    #[serde(skip_serializing_if = "Option::is_none")]
    pub id: Option<String>,

    /// The name of the resource
    #[serde(skip_serializing_if = "Option::is_none")]
    pub name: Option<String>,

    /// The type of the resource
    #[serde(rename = "type")]
    #[serde(skip_serializing_if = "Option::is_none")]
    pub r#type: Option<String>,

    /// Secure score properties
    #[serde(skip_serializing_if = "Option::is_none")]
    pub properties: Option<SecureScoreProperties>,
}

impl SecureScore {
    #[cfg(any(test, feature = "test-support"))]
    /// Create a fixture instance for testing.
    pub fn fixture() -> Self {
        Self {
            id: Some("test-id".into()),
            name: Some("test-secure_score".into()),
            r#type: Some("test-type".into()),
            properties: Some(SecureScoreProperties::fixture()),
        }
    }
}

/// List of secure scores.
///
/// **Azure API**: `security.v1.SecureScoreListResult`
/// **Reference**: <https://learn.microsoft.com/en-us/rest/api/defenderforcloud//SecureScoreListResult>
#[derive(Debug, Clone, Default, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct SecureScoreListResult {
    /// The collection of security scores
    #[serde(default)]
    #[serde(skip_serializing_if = "Vec::is_empty")]
    pub value: Vec<SecureScore>,

    /// The URI to fetch the next page of results
    #[serde(skip_serializing_if = "Option::is_none")]
    pub next_link: Option<String>,
}

impl SecureScoreListResult {
    #[cfg(any(test, feature = "test-support"))]
    /// Create a fixture instance for testing.
    pub fn fixture() -> Self {
        Self {
            value: vec![],
            next_link: Some("test-next_link".into()),
        }
    }
}

/// The result of the assessment.
///
/// **Azure API**: `security.v1.AssessmentStatus`
/// **Reference**: <https://learn.microsoft.com/en-us/rest/api/defenderforcloud//AssessmentStatus>
#[derive(Debug, Clone, Default, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct AssessmentStatus {
    /// Programmatic code for the status of the assessment (Healthy, Unhealthy, NotApplicable)
    #[serde(skip_serializing_if = "Option::is_none")]
    pub code: Option<String>,

    /// Programmatic code for the cause of the assessment status
    #[serde(skip_serializing_if = "Option::is_none")]
    pub cause: Option<String>,

    /// Human readable description of the assessment status
    #[serde(skip_serializing_if = "Option::is_none")]
    pub description: Option<String>,
}

impl AssessmentStatus {
    #[cfg(any(test, feature = "test-support"))]
    /// Create a fixture instance for testing.
    pub fn fixture() -> Self {
        Self {
            code: Some("test-code".into()),
            cause: Some("test-cause".into()),
            description: Some("test-description".into()),
        }
    }
}

/// Describes the properties of an assessment.
///
/// **Azure API**: `security.v1.AssessmentProperties`
/// **Reference**: <https://learn.microsoft.com/en-us/rest/api/defenderforcloud//AssessmentProperties>
#[derive(Debug, Clone, Default, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct AssessmentProperties {
    /// User-friendly display name of the assessment
    #[serde(skip_serializing_if = "Option::is_none")]
    pub display_name: Option<String>,

    /// The result of the assessment
    #[serde(skip_serializing_if = "Option::is_none")]
    pub status: Option<AssessmentStatus>,

    /// Human readable description of the assessment
    #[serde(skip_serializing_if = "Option::is_none")]
    pub description: Option<String>,

    /// Human readable description of what you should do to mitigate this security issue
    #[serde(skip_serializing_if = "Option::is_none")]
    pub remediation_description: Option<String>,
}

impl AssessmentProperties {
    #[cfg(any(test, feature = "test-support"))]
    /// Create a fixture instance for testing.
    pub fn fixture() -> Self {
        Self {
            display_name: Some("test-display_name".into()),
            status: Some(AssessmentStatus::fixture()),
            description: Some("test-description".into()),
            remediation_description: Some("test-remediation_description".into()),
        }
    }
}

/// Security assessment on a resource.
///
/// **Azure API**: `security.v1.Assessment`
/// **Reference**: <https://learn.microsoft.com/en-us/rest/api/defenderforcloud//Assessment>
#[derive(Debug, Clone, Default, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct Assessment {
    /// Fully qualified resource ID
    #[serde(skip_serializing_if = "Option::is_none")]
    pub id: Option<String>,

    /// The name of the resource
    #[serde(skip_serializing_if = "Option::is_none")]
    pub name: Option<String>,

    /// The type of the resource
    #[serde(rename = "type")]
    #[serde(skip_serializing_if = "Option::is_none")]
    pub r#type: Option<String>,

    /// Assessment properties
    #[serde(skip_serializing_if = "Option::is_none")]
    pub properties: Option<AssessmentProperties>,
}

impl Assessment {
    #[cfg(any(test, feature = "test-support"))]
    /// Create a fixture instance for testing.
    pub fn fixture() -> Self {
        Self {
            id: Some("test-id".into()),
            name: Some("test-assessment".into()),
            r#type: Some("test-type".into()),
            properties: Some(AssessmentProperties::fixture()),
        }
    }
}

/// Page of a list of security assessments.
///
/// **Azure API**: `security.v1.AssessmentListResult`
/// **Reference**: <https://learn.microsoft.com/en-us/rest/api/defenderforcloud//AssessmentListResult>
#[derive(Debug, Clone, Default, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct AssessmentListResult {
    /// Collection of security assessments in this page
    #[serde(default)]
    #[serde(skip_serializing_if = "Vec::is_empty")]
    pub value: Vec<Assessment>,

    /// The URI to fetch the next page of assessments
    #[serde(skip_serializing_if = "Option::is_none")]
    pub next_link: Option<String>,
}

impl AssessmentListResult {
    #[cfg(any(test, feature = "test-support"))]
    /// Create a fixture instance for testing.
    pub fn fixture() -> Self {
        Self {
            value: vec![],
            next_link: Some("test-next_link".into()),
        }
    }
}