Skip to main content

azure_lite_rs/types/
sql.rs

1//! Types for the Azure SQL API (v1).
2//!
3//! Auto-generated from the Azure ARM REST Specification.
4//! **Do not edit manually** — modify the manifest and re-run codegen.
5
6use serde::{Deserialize, Serialize};
7use std::collections::HashMap;
8
9/// The properties of a server.
10///
11/// **Azure API**: `sql.v1.ServerProperties`
12/// **Reference**: <https://learn.microsoft.com/en-us/rest/api/sql//ServerProperties>
13#[derive(Debug, Clone, Default, Serialize, Deserialize)]
14#[serde(rename_all = "camelCase")]
15pub struct ServerProperties {
16    /// Administrator username for the server
17    #[serde(skip_serializing_if = "Option::is_none")]
18    pub administrator_login: Option<String>,
19
20    /// The fully qualified domain name of the server
21    #[serde(skip_serializing_if = "Option::is_none")]
22    pub fully_qualified_domain_name: Option<String>,
23
24    /// The state of the server (Ready, Disabled, etc.)
25    #[serde(skip_serializing_if = "Option::is_none")]
26    pub state: Option<String>,
27
28    /// The version of the server
29    #[serde(skip_serializing_if = "Option::is_none")]
30    pub version: Option<String>,
31}
32
33impl ServerProperties {
34    #[cfg(any(test, feature = "test-support"))]
35    /// Create a fixture instance for testing.
36    pub fn fixture() -> Self {
37        Self {
38            administrator_login: Some("test-administrator_login".into()),
39            fully_qualified_domain_name: Some("test-fully_qualified_domain_name".into()),
40            state: Some("test-state".into()),
41            version: Some("test-version".into()),
42        }
43    }
44}
45
46/// An Azure SQL Database server.
47///
48/// **Azure API**: `sql.v1.Server`
49/// **Reference**: <https://learn.microsoft.com/en-us/rest/api/sql//Server>
50#[derive(Debug, Clone, Default, Serialize, Deserialize)]
51#[serde(rename_all = "camelCase")]
52pub struct Server {
53    /// Fully qualified resource ID
54    #[serde(skip_serializing_if = "Option::is_none")]
55    pub id: Option<String>,
56
57    /// The name of the resource
58    #[serde(skip_serializing_if = "Option::is_none")]
59    pub name: Option<String>,
60
61    /// The type of the resource
62    #[serde(rename = "type")]
63    #[serde(skip_serializing_if = "Option::is_none")]
64    pub r#type: Option<String>,
65
66    /// Resource location
67    #[serde(skip_serializing_if = "Option::is_none")]
68    pub location: Option<String>,
69
70    /// Resource tags
71    #[serde(default)]
72    #[serde(skip_serializing_if = "HashMap::is_empty")]
73    pub tags: HashMap<String, String>,
74
75    /// Server resource properties
76    #[serde(skip_serializing_if = "Option::is_none")]
77    pub properties: Option<ServerProperties>,
78}
79
80impl Server {
81    #[cfg(any(test, feature = "test-support"))]
82    /// Create a fixture instance for testing.
83    pub fn fixture() -> Self {
84        Self {
85            id: Some("test-id".into()),
86            name: Some("test-server".into()),
87            r#type: Some("test-type".into()),
88            location: Some("test-location".into()),
89            tags: Default::default(),
90            properties: Some(ServerProperties::fixture()),
91        }
92    }
93}
94
95/// A list of servers.
96///
97/// **Azure API**: `sql.v1.ServerListResult`
98/// **Reference**: <https://learn.microsoft.com/en-us/rest/api/sql//ServerListResult>
99#[derive(Debug, Clone, Default, Serialize, Deserialize)]
100#[serde(rename_all = "camelCase")]
101pub struct ServerListResult {
102    /// Array of results
103    #[serde(default)]
104    #[serde(skip_serializing_if = "Vec::is_empty")]
105    pub value: Vec<Server>,
106
107    /// Link to retrieve next page
108    #[serde(skip_serializing_if = "Option::is_none")]
109    pub next_link: Option<String>,
110}
111
112impl ServerListResult {
113    #[cfg(any(test, feature = "test-support"))]
114    /// Create a fixture instance for testing.
115    pub fn fixture() -> Self {
116        Self {
117            value: vec![],
118            next_link: Some("test-next_link".into()),
119        }
120    }
121}
122
123/// The properties used to create a new server.
124///
125/// **Azure API**: `sql.v1.ServerCreateOrUpdateProperties`
126/// **Reference**: <https://learn.microsoft.com/en-us/rest/api/sql//ServerCreateOrUpdateProperties>
127#[derive(Debug, Clone, Default, Serialize, Deserialize)]
128#[serde(rename_all = "camelCase")]
129pub struct ServerCreateOrUpdateProperties {
130    /// Administrator username for the server
131    pub administrator_login: String,
132
133    /// Administrator login password (required for create)
134    #[serde(skip_serializing_if = "Option::is_none")]
135    pub administrator_login_password: Option<String>,
136
137    /// The version of the server (e.g. 12.0)
138    #[serde(skip_serializing_if = "Option::is_none")]
139    pub version: Option<String>,
140}
141
142impl ServerCreateOrUpdateProperties {
143    #[cfg(any(test, feature = "test-support"))]
144    /// Create a fixture instance for testing.
145    pub fn fixture() -> Self {
146        Self {
147            administrator_login: "test-administrator_login".into(),
148            administrator_login_password: Some("test-administrator_login_password".into()),
149            version: Some("test-version".into()),
150        }
151    }
152}
153
154/// An Azure SQL Database server.
155///
156/// **Azure API**: `sql.v1.ServerCreateRequest`
157/// **Reference**: <https://learn.microsoft.com/en-us/rest/api/sql//ServerCreateRequest>
158#[derive(Debug, Clone, Default, Serialize, Deserialize)]
159#[serde(rename_all = "camelCase")]
160pub struct ServerCreateRequest {
161    /// Resource location
162    pub location: String,
163
164    /// Resource tags
165    #[serde(default)]
166    #[serde(skip_serializing_if = "HashMap::is_empty")]
167    pub tags: HashMap<String, String>,
168
169    /// Resource properties
170    #[serde(skip_serializing_if = "Option::is_none")]
171    pub properties: Option<ServerCreateOrUpdateProperties>,
172}
173
174impl ServerCreateRequest {
175    #[cfg(any(test, feature = "test-support"))]
176    /// Create a fixture instance for testing.
177    pub fn fixture() -> Self {
178        Self {
179            location: "test-location".into(),
180            tags: Default::default(),
181            properties: Some(ServerCreateOrUpdateProperties::fixture()),
182        }
183    }
184}
185
186/// The database's properties.
187///
188/// **Azure API**: `sql.v1.DatabaseProperties`
189/// **Reference**: <https://learn.microsoft.com/en-us/rest/api/sql//DatabaseProperties>
190#[derive(Debug, Clone, Default, Serialize, Deserialize)]
191#[serde(rename_all = "camelCase")]
192pub struct DatabaseProperties {
193    /// The status of the database
194    #[serde(skip_serializing_if = "Option::is_none")]
195    pub status: Option<String>,
196
197    /// The ID of the database
198    #[serde(skip_serializing_if = "Option::is_none")]
199    pub database_id: Option<String>,
200
201    /// The collation of the database
202    #[serde(skip_serializing_if = "Option::is_none")]
203    pub collation: Option<String>,
204
205    /// The max size of the database expressed in bytes
206    #[serde(skip_serializing_if = "Option::is_none")]
207    pub max_size_bytes: Option<i64>,
208
209    /// The name of the configured service level objective
210    #[serde(skip_serializing_if = "Option::is_none")]
211    pub requested_service_objective_name: Option<String>,
212
213    /// The current service level objective name
214    #[serde(skip_serializing_if = "Option::is_none")]
215    pub current_service_objective_name: Option<String>,
216
217    /// The default secondary region for this database
218    #[serde(skip_serializing_if = "Option::is_none")]
219    pub default_secondary_location: Option<String>,
220}
221
222impl DatabaseProperties {
223    #[cfg(any(test, feature = "test-support"))]
224    /// Create a fixture instance for testing.
225    pub fn fixture() -> Self {
226        Self {
227            status: Some("test-status".into()),
228            database_id: Some("test-database_id".into()),
229            collation: Some("test-collation".into()),
230            max_size_bytes: Some(100),
231            requested_service_objective_name: Some("test-requested_service_objective_name".into()),
232            current_service_objective_name: Some("test-current_service_objective_name".into()),
233            default_secondary_location: Some("test-default_secondary_location".into()),
234        }
235    }
236}
237
238/// A database resource.
239///
240/// **Azure API**: `sql.v1.Database`
241/// **Reference**: <https://learn.microsoft.com/en-us/rest/api/sql//Database>
242#[derive(Debug, Clone, Default, Serialize, Deserialize)]
243#[serde(rename_all = "camelCase")]
244pub struct Database {
245    /// Fully qualified resource ID
246    #[serde(skip_serializing_if = "Option::is_none")]
247    pub id: Option<String>,
248
249    /// The name of the resource
250    #[serde(skip_serializing_if = "Option::is_none")]
251    pub name: Option<String>,
252
253    /// The type of the resource
254    #[serde(rename = "type")]
255    #[serde(skip_serializing_if = "Option::is_none")]
256    pub r#type: Option<String>,
257
258    /// Resource location
259    #[serde(skip_serializing_if = "Option::is_none")]
260    pub location: Option<String>,
261
262    /// The database SKU
263    #[serde(skip_serializing_if = "Option::is_none")]
264    pub sku: Option<DatabaseSku>,
265
266    /// Resource tags
267    #[serde(default)]
268    #[serde(skip_serializing_if = "HashMap::is_empty")]
269    pub tags: HashMap<String, String>,
270
271    /// Resource properties
272    #[serde(skip_serializing_if = "Option::is_none")]
273    pub properties: Option<DatabaseProperties>,
274}
275
276impl Database {
277    #[cfg(any(test, feature = "test-support"))]
278    /// Create a fixture instance for testing.
279    pub fn fixture() -> Self {
280        Self {
281            id: Some("test-id".into()),
282            name: Some("test-database".into()),
283            r#type: Some("test-type".into()),
284            location: Some("test-location".into()),
285            sku: Some(DatabaseSku::fixture()),
286            tags: Default::default(),
287            properties: Some(DatabaseProperties::fixture()),
288        }
289    }
290}
291
292/// An ARM Resource SKU.
293///
294/// **Azure API**: `sql.v1.DatabaseSku`
295/// **Reference**: <https://learn.microsoft.com/en-us/rest/api/sql//DatabaseSku>
296#[derive(Debug, Clone, Default, Serialize, Deserialize)]
297#[serde(rename_all = "camelCase")]
298pub struct DatabaseSku {
299    /// The name of the SKU (e.g. Basic, Standard, Premium)
300    pub name: String,
301
302    /// The tier or edition of the particular SKU
303    #[serde(skip_serializing_if = "Option::is_none")]
304    pub tier: Option<String>,
305
306    /// Capacity of the particular SKU
307    #[serde(skip_serializing_if = "Option::is_none")]
308    pub capacity: Option<i32>,
309}
310
311impl DatabaseSku {
312    #[cfg(any(test, feature = "test-support"))]
313    /// Create a fixture instance for testing.
314    pub fn fixture() -> Self {
315        Self {
316            name: "test-database_sku".into(),
317            tier: Some("test-tier".into()),
318            capacity: Some(100),
319        }
320    }
321}
322
323/// A list of databases.
324///
325/// **Azure API**: `sql.v1.DatabaseListResult`
326/// **Reference**: <https://learn.microsoft.com/en-us/rest/api/sql//DatabaseListResult>
327#[derive(Debug, Clone, Default, Serialize, Deserialize)]
328#[serde(rename_all = "camelCase")]
329pub struct DatabaseListResult {
330    /// Array of results
331    #[serde(default)]
332    #[serde(skip_serializing_if = "Vec::is_empty")]
333    pub value: Vec<Database>,
334
335    /// Link to retrieve next page
336    #[serde(skip_serializing_if = "Option::is_none")]
337    pub next_link: Option<String>,
338}
339
340impl DatabaseListResult {
341    #[cfg(any(test, feature = "test-support"))]
342    /// Create a fixture instance for testing.
343    pub fn fixture() -> Self {
344        Self {
345            value: vec![],
346            next_link: Some("test-next_link".into()),
347        }
348    }
349}
350
351/// The database's create or update properties.
352///
353/// **Azure API**: `sql.v1.DatabaseCreateOrUpdateProperties`
354/// **Reference**: <https://learn.microsoft.com/en-us/rest/api/sql//DatabaseCreateOrUpdateProperties>
355#[derive(Debug, Clone, Default, Serialize, Deserialize)]
356#[serde(rename_all = "camelCase")]
357pub struct DatabaseCreateOrUpdateProperties {
358    /// The collation of the database
359    #[serde(skip_serializing_if = "Option::is_none")]
360    pub collation: Option<String>,
361
362    /// The max size of the database expressed in bytes
363    #[serde(skip_serializing_if = "Option::is_none")]
364    pub max_size_bytes: Option<i64>,
365}
366
367impl DatabaseCreateOrUpdateProperties {
368    #[cfg(any(test, feature = "test-support"))]
369    /// Create a fixture instance for testing.
370    pub fn fixture() -> Self {
371        Self {
372            collation: Some("test-collation".into()),
373            max_size_bytes: Some(100),
374        }
375    }
376}
377
378/// A database resource.
379///
380/// **Azure API**: `sql.v1.DatabaseCreateRequest`
381/// **Reference**: <https://learn.microsoft.com/en-us/rest/api/sql//DatabaseCreateRequest>
382#[derive(Debug, Clone, Default, Serialize, Deserialize)]
383#[serde(rename_all = "camelCase")]
384pub struct DatabaseCreateRequest {
385    /// Resource location
386    pub location: String,
387
388    /// The database SKU
389    #[serde(skip_serializing_if = "Option::is_none")]
390    pub sku: Option<DatabaseSku>,
391
392    /// Resource tags
393    #[serde(default)]
394    #[serde(skip_serializing_if = "HashMap::is_empty")]
395    pub tags: HashMap<String, String>,
396
397    /// Resource properties
398    #[serde(skip_serializing_if = "Option::is_none")]
399    pub properties: Option<DatabaseCreateOrUpdateProperties>,
400}
401
402impl DatabaseCreateRequest {
403    #[cfg(any(test, feature = "test-support"))]
404    /// Create a fixture instance for testing.
405    pub fn fixture() -> Self {
406        Self {
407            location: "test-location".into(),
408            sku: Some(DatabaseSku::fixture()),
409            tags: Default::default(),
410            properties: Some(DatabaseCreateOrUpdateProperties::fixture()),
411        }
412    }
413}
414
415/// The properties of a server firewall rule.
416///
417/// **Azure API**: `sql.v1.FirewallRuleProperties`
418/// **Reference**: <https://learn.microsoft.com/en-us/rest/api/sql//FirewallRuleProperties>
419#[derive(Debug, Clone, Default, Serialize, Deserialize)]
420#[serde(rename_all = "camelCase")]
421pub struct FirewallRuleProperties {
422    /// The start IP address of the firewall rule
423    pub start_ip_address: String,
424
425    /// The end IP address of the firewall rule
426    pub end_ip_address: String,
427}
428
429impl FirewallRuleProperties {
430    #[cfg(any(test, feature = "test-support"))]
431    /// Create a fixture instance for testing.
432    pub fn fixture() -> Self {
433        Self {
434            start_ip_address: "test-start_ip_address".into(),
435            end_ip_address: "test-end_ip_address".into(),
436        }
437    }
438}
439
440/// A server firewall rule.
441///
442/// **Azure API**: `sql.v1.FirewallRule`
443/// **Reference**: <https://learn.microsoft.com/en-us/rest/api/sql//FirewallRule>
444#[derive(Debug, Clone, Default, Serialize, Deserialize)]
445#[serde(rename_all = "camelCase")]
446pub struct FirewallRule {
447    /// Resource ID
448    #[serde(skip_serializing_if = "Option::is_none")]
449    pub id: Option<String>,
450
451    /// Resource name
452    #[serde(skip_serializing_if = "Option::is_none")]
453    pub name: Option<String>,
454
455    /// Resource type
456    #[serde(rename = "type")]
457    #[serde(skip_serializing_if = "Option::is_none")]
458    pub r#type: Option<String>,
459
460    /// Resource properties
461    #[serde(skip_serializing_if = "Option::is_none")]
462    pub properties: Option<FirewallRuleProperties>,
463}
464
465impl FirewallRule {
466    #[cfg(any(test, feature = "test-support"))]
467    /// Create a fixture instance for testing.
468    pub fn fixture() -> Self {
469        Self {
470            id: Some("test-id".into()),
471            name: Some("test-firewall_rule".into()),
472            r#type: Some("test-type".into()),
473            properties: Some(FirewallRuleProperties::fixture()),
474        }
475    }
476}
477
478/// The response to a list firewall rules request.
479///
480/// **Azure API**: `sql.v1.FirewallRuleListResult`
481/// **Reference**: <https://learn.microsoft.com/en-us/rest/api/sql//FirewallRuleListResult>
482#[derive(Debug, Clone, Default, Serialize, Deserialize)]
483#[serde(rename_all = "camelCase")]
484pub struct FirewallRuleListResult {
485    /// Array of results
486    #[serde(default)]
487    #[serde(skip_serializing_if = "Vec::is_empty")]
488    pub value: Vec<FirewallRule>,
489
490    /// Link to retrieve next page
491    #[serde(skip_serializing_if = "Option::is_none")]
492    pub next_link: Option<String>,
493}
494
495impl FirewallRuleListResult {
496    #[cfg(any(test, feature = "test-support"))]
497    /// Create a fixture instance for testing.
498    pub fn fixture() -> Self {
499        Self {
500            value: vec![],
501            next_link: Some("test-next_link".into()),
502        }
503    }
504}
505
506/// A server firewall rule.
507///
508/// **Azure API**: `sql.v1.FirewallRuleCreateRequest`
509/// **Reference**: <https://learn.microsoft.com/en-us/rest/api/sql//FirewallRuleCreateRequest>
510#[derive(Debug, Clone, Default, Serialize, Deserialize)]
511#[serde(rename_all = "camelCase")]
512pub struct FirewallRuleCreateRequest {
513    /// Resource properties
514    #[serde(skip_serializing_if = "Option::is_none")]
515    pub properties: Option<FirewallRuleProperties>,
516}
517
518impl FirewallRuleCreateRequest {
519    #[cfg(any(test, feature = "test-support"))]
520    /// Create a fixture instance for testing.
521    pub fn fixture() -> Self {
522        Self {
523            properties: Some(FirewallRuleProperties::fixture()),
524        }
525    }
526}
527
528/// Properties of a server blob auditing policy.
529///
530/// **Azure API**: `sql.v1.ServerBlobAuditingPolicyProperties`
531/// **Reference**: <https://learn.microsoft.com/en-us/rest/api/sql/server-blob-auditing-policies/get>
532#[derive(Debug, Clone, Default, Serialize, Deserialize)]
533#[serde(rename_all = "camelCase")]
534pub struct ServerBlobAuditingPolicyProperties {
535    /// The state of the auditing policy (`"Enabled"` or `"Disabled"`).
536    #[serde(skip_serializing_if = "Option::is_none")]
537    pub state: Option<String>,
538
539    /// The blob storage endpoint to send audit logs to (optional).
540    #[serde(skip_serializing_if = "Option::is_none")]
541    pub storage_endpoint: Option<String>,
542
543    /// Days to retain audit logs in the storage account. 0 = unlimited.
544    #[serde(skip_serializing_if = "Option::is_none")]
545    pub retention_days: Option<i32>,
546
547    /// Whether Azure Monitor is enabled as an audit log destination.
548    #[serde(skip_serializing_if = "Option::is_none")]
549    pub is_azure_monitor_target_enabled: Option<bool>,
550}
551
552impl ServerBlobAuditingPolicyProperties {
553    #[cfg(any(test, feature = "test-support"))]
554    /// Create a fixture instance for testing.
555    pub fn fixture() -> Self {
556        Self {
557            state: Some("Enabled".into()),
558            storage_endpoint: None,
559            retention_days: Some(90),
560            is_azure_monitor_target_enabled: Some(true),
561        }
562    }
563}
564
565/// A server blob auditing policy (the `default` auditing settings for an Azure SQL Server).
566///
567/// **Azure API**: `sql.v1.ServerBlobAuditingPolicy`
568/// **Reference**: <https://learn.microsoft.com/en-us/rest/api/sql/server-blob-auditing-policies/get>
569#[derive(Debug, Clone, Default, Serialize, Deserialize)]
570#[serde(rename_all = "camelCase")]
571pub struct ServerBlobAuditingPolicy {
572    /// Resource ID.
573    #[serde(skip_serializing_if = "Option::is_none")]
574    pub id: Option<String>,
575
576    /// Resource name.
577    #[serde(skip_serializing_if = "Option::is_none")]
578    pub name: Option<String>,
579
580    /// Auditing policy properties.
581    #[serde(skip_serializing_if = "Option::is_none")]
582    pub properties: Option<ServerBlobAuditingPolicyProperties>,
583}
584
585impl ServerBlobAuditingPolicy {
586    #[cfg(any(test, feature = "test-support"))]
587    /// Create a fixture instance for testing.
588    pub fn fixture() -> Self {
589        Self {
590            id: Some("/subscriptions/test-sub/resourceGroups/test-rg/providers/Microsoft.Sql/servers/test-server/auditingSettings/default".into()),
591            name: Some("default".into()),
592            properties: Some(ServerBlobAuditingPolicyProperties::fixture()),
593        }
594    }
595}
596
597/// Request body for enabling server-level blob auditing.
598///
599/// **Azure API**: `PUT .../auditingSettings/default`
600#[derive(Debug, Clone, Serialize, Deserialize)]
601#[serde(rename_all = "camelCase")]
602pub struct EnableServerAuditingRequest {
603    pub properties: EnableServerAuditingProperties,
604}
605
606/// Properties for enabling server auditing.
607#[derive(Debug, Clone, Serialize, Deserialize)]
608#[serde(rename_all = "camelCase")]
609pub struct EnableServerAuditingProperties {
610    /// Must be `"Enabled"`.
611    pub state: String,
612
613    /// The blob storage endpoint (e.g. `https://myaccount.blob.core.windows.net`).
614    /// Required when the server already has blob-storage auditing configured.
615    #[serde(skip_serializing_if = "Option::is_none")]
616    pub storage_endpoint: Option<String>,
617
618    /// Primary access key for the storage account. Required when `storage_endpoint` is set.
619    #[serde(skip_serializing_if = "Option::is_none")]
620    pub storage_account_access_key: Option<String>,
621
622    /// Enable Azure Monitor as the audit log destination.
623    #[serde(skip_serializing_if = "Option::is_none")]
624    pub is_azure_monitor_target_enabled: Option<bool>,
625
626    /// Days to retain audit logs in the storage account. 0 = unlimited.
627    #[serde(skip_serializing_if = "Option::is_none")]
628    pub retention_days: Option<u32>,
629}
630
631impl EnableServerAuditingRequest {
632    /// Build a request that enables auditing to Azure Monitor.
633    pub fn enable_to_azure_monitor() -> Self {
634        Self {
635            properties: EnableServerAuditingProperties {
636                state: "Enabled".into(),
637                storage_endpoint: None,
638                storage_account_access_key: None,
639                is_azure_monitor_target_enabled: Some(true),
640                retention_days: None,
641            },
642        }
643    }
644}