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
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
//! Types for the Azure Storage 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};

/// The SKU of a storage account.
///
/// **Azure API**: `storage.v1.StorageAccountSku`
/// **Reference**: <https://learn.microsoft.com/en-us/rest/api/storagerp/storage-accounts/StorageAccountSku>
#[derive(Debug, Clone, Default, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct StorageAccountSku {
    /// SKU name (e.g. Standard_LRS, Standard_GRS, Premium_LRS)
    pub name: String,

    /// SKU tier (Standard or Premium)
    #[serde(skip_serializing_if = "Option::is_none")]
    pub tier: Option<String>,
}

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

/// Properties of a storage account.
///
/// **Azure API**: `storage.v1.StorageAccountProperties`
/// **Reference**: <https://learn.microsoft.com/en-us/rest/api/storagerp/storage-accounts/StorageAccountProperties>
#[derive(Debug, Clone, Default, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct StorageAccountProperties {
    /// Provisioning state of the storage account (e.g. Succeeded)
    #[serde(skip_serializing_if = "Option::is_none")]
    pub provisioning_state: Option<String>,

    /// The primary region for the storage account
    #[serde(skip_serializing_if = "Option::is_none")]
    pub primary_location: Option<String>,

    /// The secondary region for geo-redundant storage
    #[serde(skip_serializing_if = "Option::is_none")]
    pub secondary_location: Option<String>,

    /// Status of the primary endpoint (available or unavailable)
    #[serde(skip_serializing_if = "Option::is_none")]
    pub status_of_primary: Option<String>,

    /// Status of the secondary endpoint (available or unavailable)
    #[serde(skip_serializing_if = "Option::is_none")]
    pub status_of_secondary: Option<String>,

    /// Timestamp when the storage account was created
    #[serde(skip_serializing_if = "Option::is_none")]
    pub creation_time: Option<String>,

    /// Primary service endpoints for the storage account
    #[serde(skip_serializing_if = "Option::is_none")]
    pub primary_endpoints: Option<serde_json::Value>,

    /// Whether only HTTPS traffic is permitted
    #[serde(skip_serializing_if = "Option::is_none")]
    pub supports_https_traffic_only: Option<bool>,

    /// Whether hierarchical namespace is enabled
    #[serde(skip_serializing_if = "Option::is_none")]
    pub is_hns_enabled: Option<bool>,

    /// Minimum TLS version (TLS1_0, TLS1_1, TLS1_2)
    #[serde(skip_serializing_if = "Option::is_none")]
    pub minimum_tls_version: Option<String>,

    /// Whether blob public access is allowed
    #[serde(skip_serializing_if = "Option::is_none")]
    pub allow_blob_public_access: Option<bool>,
}

impl StorageAccountProperties {
    #[cfg(any(test, feature = "test-support"))]
    /// Create a fixture instance for testing.
    pub fn fixture() -> Self {
        Self {
            provisioning_state: Some("test-provisioning_state".into()),
            primary_location: Some("test-primary_location".into()),
            secondary_location: Some("test-secondary_location".into()),
            status_of_primary: Some("test-status_of_primary".into()),
            status_of_secondary: Some("test-status_of_secondary".into()),
            creation_time: Some("test-creation_time".into()),
            supports_https_traffic_only: Some(false),
            is_hns_enabled: Some(false),
            minimum_tls_version: Some("test-minimum_tls_version".into()),
            allow_blob_public_access: Some(false),
            ..Default::default()
        }
    }
}

/// An Azure storage account.
///
/// **Azure API**: `storage.v1.StorageAccount`
/// **Reference**: <https://learn.microsoft.com/en-us/rest/api/storagerp/storage-accounts/StorageAccount>
#[derive(Debug, Clone, Default, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct StorageAccount {
    /// Resource ID
    #[serde(skip_serializing_if = "Option::is_none")]
    pub id: Option<String>,

    /// Resource name
    #[serde(skip_serializing_if = "Option::is_none")]
    pub name: Option<String>,

    /// Resource type (Microsoft.Storage/storageAccounts)
    #[serde(rename = "type")]
    #[serde(skip_serializing_if = "Option::is_none")]
    pub r#type: Option<String>,

    /// Azure region where the storage account is located
    pub location: String,

    /// Kind of storage account (Storage, StorageV2, BlobStorage, FileStorage, BlockBlobStorage)
    #[serde(skip_serializing_if = "Option::is_none")]
    pub kind: Option<String>,

    /// SKU of the storage account
    #[serde(skip_serializing_if = "Option::is_none")]
    pub sku: Option<serde_json::Value>,

    /// Resource tags
    #[serde(skip_serializing_if = "Option::is_none")]
    pub tags: Option<serde_json::Value>,

    /// Storage account properties
    #[serde(skip_serializing_if = "Option::is_none")]
    pub properties: Option<serde_json::Value>,
}

impl StorageAccount {
    #[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-storage_account".into()),
            r#type: Some("test-type".into()),
            location: "test-location".into(),
            kind: Some("test-kind".into()),
            ..Default::default()
        }
    }
}

/// Response from list storage accounts operations.
///
/// **Azure API**: `storage.v1.StorageAccountListResult`
/// **Reference**: <https://learn.microsoft.com/en-us/rest/api/storagerp/storage-accounts/StorageAccountListResult>
#[derive(Debug, Clone, Default, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct StorageAccountListResult {
    /// List of storage accounts
    #[serde(default)]
    #[serde(skip_serializing_if = "Vec::is_empty")]
    pub value: Vec<serde_json::Value>,

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

impl StorageAccountListResult {
    #[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()),
        }
    }
}

/// Request body for creating a storage account.
///
/// **Azure API**: `storage.v1.StorageAccountCreateRequest`
/// **Reference**: <https://learn.microsoft.com/en-us/rest/api/storagerp/storage-accounts/StorageAccountCreateRequest>
#[derive(Debug, Clone, Default, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct StorageAccountCreateRequest {
    /// Azure region where the storage account should be created
    pub location: String,

    /// Kind of storage account (StorageV2, BlobStorage, etc.)
    pub kind: String,

    /// SKU for the storage account
    pub sku: serde_json::Value,

    /// Resource tags
    #[serde(skip_serializing_if = "Option::is_none")]
    pub tags: Option<serde_json::Value>,

    /// Additional storage account properties
    #[serde(skip_serializing_if = "Option::is_none")]
    pub properties: Option<serde_json::Value>,
}

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

/// An access key for a storage account.
///
/// **Azure API**: `storage.v1.StorageAccountKey`
/// **Reference**: <https://learn.microsoft.com/en-us/rest/api/storagerp/storage-accounts/StorageAccountKey>
#[derive(Debug, Clone, Default, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct StorageAccountKey {
    /// Name of the key (key1, key2)
    #[serde(skip_serializing_if = "Option::is_none")]
    pub key_name: Option<String>,

    /// Base64-encoded key value
    #[serde(skip_serializing_if = "Option::is_none")]
    pub value: Option<String>,

    /// Key permissions (Full or Read)
    #[serde(skip_serializing_if = "Option::is_none")]
    pub permissions: Option<String>,

    /// Timestamp when the key was created
    #[serde(skip_serializing_if = "Option::is_none")]
    pub creation_time: Option<String>,
}

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

/// Response from the ListKeys and RegenerateKey operations.
///
/// **Azure API**: `storage.v1.StorageAccountListKeysResult`
/// **Reference**: <https://learn.microsoft.com/en-us/rest/api/storagerp/storage-accounts/StorageAccountListKeysResult>
#[derive(Debug, Clone, Default, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct StorageAccountListKeysResult {
    /// List of storage account access keys
    #[serde(default)]
    #[serde(skip_serializing_if = "Vec::is_empty")]
    pub keys: Vec<serde_json::Value>,
}

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

/// Request body for regenerating a storage account key.
///
/// **Azure API**: `storage.v1.StorageAccountRegenerateKeyRequest`
/// **Reference**: <https://learn.microsoft.com/en-us/rest/api/storagerp/storage-accounts/StorageAccountRegenerateKeyRequest>
#[derive(Debug, Clone, Default, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct StorageAccountRegenerateKeyRequest {
    /// Name of the key to regenerate (key1 or key2)
    pub key_name: String,
}

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

/// Properties to update on a storage account (partial PATCH — only set fields are sent).
///
/// **Azure API**: `storage.v1.StorageAccountUpdateProperties`
/// **Reference**: <https://learn.microsoft.com/en-us/rest/api/storagerp/storage-accounts/StorageAccountUpdateProperties>
#[derive(Debug, Clone, Default, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct StorageAccountUpdateProperties {
    /// Whether blob public access is allowed
    #[serde(skip_serializing_if = "Option::is_none")]
    pub allow_blob_public_access: Option<bool>,

    /// Whether only HTTPS traffic is permitted
    #[serde(skip_serializing_if = "Option::is_none")]
    pub supports_https_traffic_only: Option<bool>,

    /// Minimum TLS version (TLS1_0, TLS1_1, TLS1_2)
    #[serde(skip_serializing_if = "Option::is_none")]
    pub minimum_tls_version: Option<String>,
}

impl StorageAccountUpdateProperties {
    #[cfg(any(test, feature = "test-support"))]
    /// Create a fixture instance for testing.
    pub fn fixture() -> Self {
        Self {
            allow_blob_public_access: Some(false),
            supports_https_traffic_only: Some(false),
            minimum_tls_version: Some("test-minimum_tls_version".into()),
        }
    }
}

/// Request body for updating a storage account (PATCH — partial update, ARM merges with
/// existing state).
///
/// **Azure API**: `storage.v1.StorageAccountUpdateRequest`
/// **Reference**: <https://learn.microsoft.com/en-us/rest/api/storagerp/storage-accounts/StorageAccountUpdateRequest>
#[derive(Debug, Clone, Default, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct StorageAccountUpdateRequest {
    /// Properties to update (partial — only set fields are sent)
    #[serde(skip_serializing_if = "Option::is_none")]
    pub properties: Option<StorageAccountUpdateProperties>,

    /// Tags to update
    #[serde(skip_serializing_if = "Option::is_none")]
    pub tags: Option<serde_json::Value>,
}

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

/// A rule in a blob lifecycle management policy.
///
/// **Azure API**: `storage.v1.ManagementPolicyRule`
/// **Reference**: <https://learn.microsoft.com/en-us/rest/api/storagerp/storage-accounts/ManagementPolicyRule>
#[derive(Debug, Clone, Default, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct ManagementPolicyRule {
    /// Whether the rule is enabled
    #[serde(default)]
    pub enabled: bool,

    /// The name of the rule
    pub name: String,

    /// The type of the rule (e.g. Lifecycle)
    #[serde(rename = "type")]
    #[serde(skip_serializing_if = "Option::is_none")]
    pub r#type: Option<String>,
}

impl ManagementPolicyRule {
    #[cfg(any(test, feature = "test-support"))]
    /// Create a fixture instance for testing.
    pub fn fixture() -> Self {
        Self {
            enabled: false,
            name: "test-management_policy_rule".into(),
            r#type: Some("test-type".into()),
        }
    }
}

/// The Storage Account ManagementPolicy schema containing lifecycle rules.
///
/// **Azure API**: `storage.v1.ManagementPolicySchema`
/// **Reference**: <https://learn.microsoft.com/en-us/rest/api/storagerp/storage-accounts/ManagementPolicySchema>
#[derive(Debug, Clone, Default, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct ManagementPolicySchema {
    /// The list of lifecycle management policy rules
    #[serde(default)]
    pub rules: Vec<ManagementPolicyRule>,
}

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

/// Properties of a blob lifecycle management policy.
///
/// **Azure API**: `storage.v1.ManagementPolicyProperties`
/// **Reference**: <https://learn.microsoft.com/en-us/rest/api/storagerp/storage-accounts/ManagementPolicyProperties>
#[derive(Debug, Clone, Default, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct ManagementPolicyProperties {
    /// The date and time the policy was last modified
    #[serde(skip_serializing_if = "Option::is_none")]
    pub last_modified_time: Option<String>,

    /// The lifecycle management policy schema
    #[serde(skip_serializing_if = "Option::is_none")]
    pub policy: Option<ManagementPolicySchema>,
}

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

/// The Get Storage Account ManagementPolicies operation response.
///
/// **Azure API**: `storage.v1.ManagementPolicy`
/// **Reference**: <https://learn.microsoft.com/en-us/rest/api/storagerp/storage-accounts/ManagementPolicy>
#[derive(Debug, Clone, Default, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct ManagementPolicy {
    /// 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>,

    /// The management policy properties
    #[serde(skip_serializing_if = "Option::is_none")]
    pub properties: Option<ManagementPolicyProperties>,
}

impl ManagementPolicy {
    #[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-management_policy".into()),
            r#type: Some("test-type".into()),
            properties: Some(ManagementPolicyProperties::fixture()),
        }
    }
}