Skip to main content

azure_lite_rs/types/
loganalytics.rs

1//! Types for the Azure Log Analytics 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 SKU (pricing tier) of a Log Analytics workspace.
10///
11/// **Azure API**: `loganalytics.v1.WorkspaceSku`
12/// **Reference**: <https://learn.microsoft.com/en-us/rest/api/loganalytics//WorkspaceSku>
13#[derive(Debug, Clone, Default, Serialize, Deserialize)]
14#[serde(rename_all = "camelCase")]
15pub struct WorkspaceSku {
16    /// The name of the SKU (e.g., PerGB2018, Free, Standard, Premium)
17    pub name: String,
18}
19
20impl WorkspaceSku {
21    #[cfg(any(test, feature = "test-support"))]
22    /// Create a fixture instance for testing.
23    pub fn fixture() -> Self {
24        Self {
25            name: "test-workspace_sku".into(),
26        }
27    }
28}
29
30/// Workspace properties.
31///
32/// **Azure API**: `loganalytics.v1.WorkspaceProperties`
33/// **Reference**: <https://learn.microsoft.com/en-us/rest/api/loganalytics//WorkspaceProperties>
34#[derive(Debug, Clone, Default, Serialize, Deserialize)]
35#[serde(rename_all = "camelCase")]
36pub struct WorkspaceProperties {
37    /// The workspace data retention in days
38    #[serde(skip_serializing_if = "Option::is_none")]
39    pub retention_in_days: Option<i32>,
40
41    /// The SKU of the workspace
42    #[serde(skip_serializing_if = "Option::is_none")]
43    pub sku: Option<WorkspaceSku>,
44
45    /// The network access type for accessing Log Analytics ingestion (Enabled/Disabled)
46    #[serde(skip_serializing_if = "Option::is_none")]
47    pub public_network_access_for_ingestion: Option<String>,
48
49    /// The network access type for accessing Log Analytics query (Enabled/Disabled)
50    #[serde(skip_serializing_if = "Option::is_none")]
51    pub public_network_access_for_query: Option<String>,
52
53    /// This is a read-only property. Represents the ID associated with the workspace
54    #[serde(skip_serializing_if = "Option::is_none")]
55    pub customer_id: Option<String>,
56
57    /// The provisioning state of the workspace
58    #[serde(skip_serializing_if = "Option::is_none")]
59    pub provisioning_state: Option<String>,
60}
61
62impl WorkspaceProperties {
63    #[cfg(any(test, feature = "test-support"))]
64    /// Create a fixture instance for testing.
65    pub fn fixture() -> Self {
66        Self {
67            retention_in_days: Some(100),
68            sku: Some(WorkspaceSku::fixture()),
69            public_network_access_for_ingestion: Some(
70                "test-public_network_access_for_ingestion".into(),
71            ),
72            public_network_access_for_query: Some("test-public_network_access_for_query".into()),
73            customer_id: Some("test-customer_id".into()),
74            provisioning_state: Some("test-provisioning_state".into()),
75        }
76    }
77}
78
79/// The top level Workspace resource container.
80///
81/// **Azure API**: `loganalytics.v1.Workspace`
82/// **Reference**: <https://learn.microsoft.com/en-us/rest/api/loganalytics//Workspace>
83#[derive(Debug, Clone, Default, Serialize, Deserialize)]
84#[serde(rename_all = "camelCase")]
85pub struct Workspace {
86    /// Azure resource identifier
87    #[serde(skip_serializing_if = "Option::is_none")]
88    pub id: Option<String>,
89
90    /// Azure resource name
91    #[serde(skip_serializing_if = "Option::is_none")]
92    pub name: Option<String>,
93
94    /// Azure resource type
95    #[serde(rename = "type")]
96    #[serde(skip_serializing_if = "Option::is_none")]
97    pub r#type: Option<String>,
98
99    /// Resource location
100    pub location: String,
101
102    /// Resource tags
103    #[serde(default)]
104    #[serde(skip_serializing_if = "HashMap::is_empty")]
105    pub tags: HashMap<String, String>,
106
107    /// Workspace properties
108    #[serde(skip_serializing_if = "Option::is_none")]
109    pub properties: Option<WorkspaceProperties>,
110}
111
112impl Workspace {
113    #[cfg(any(test, feature = "test-support"))]
114    /// Create a fixture instance for testing.
115    pub fn fixture() -> Self {
116        Self {
117            id: Some("test-id".into()),
118            name: Some("test-workspace".into()),
119            r#type: Some("test-type".into()),
120            location: "test-location".into(),
121            tags: Default::default(),
122            properties: Some(WorkspaceProperties::fixture()),
123        }
124    }
125}
126
127/// The list workspaces operation response.
128///
129/// **Azure API**: `loganalytics.v1.WorkspaceListResult`
130/// **Reference**: <https://learn.microsoft.com/en-us/rest/api/loganalytics//WorkspaceListResult>
131#[derive(Debug, Clone, Default, Serialize, Deserialize)]
132#[serde(rename_all = "camelCase")]
133pub struct WorkspaceListResult {
134    /// A list of workspaces
135    #[serde(default)]
136    #[serde(skip_serializing_if = "Vec::is_empty")]
137    pub value: Vec<Workspace>,
138}
139
140impl WorkspaceListResult {
141    #[cfg(any(test, feature = "test-support"))]
142    /// Create a fixture instance for testing.
143    pub fn fixture() -> Self {
144        Self { value: vec![] }
145    }
146}
147
148/// The request body for creating or updating a Log Analytics workspace.
149///
150/// **Azure API**: `loganalytics.v1.WorkspaceCreateRequest`
151/// **Reference**: <https://learn.microsoft.com/en-us/rest/api/loganalytics//WorkspaceCreateRequest>
152#[derive(Debug, Clone, Default, Serialize, Deserialize)]
153#[serde(rename_all = "camelCase")]
154pub struct WorkspaceCreateRequest {
155    /// Resource location
156    pub location: String,
157
158    /// Resource tags
159    #[serde(default)]
160    #[serde(skip_serializing_if = "HashMap::is_empty")]
161    pub tags: HashMap<String, String>,
162
163    /// Workspace properties
164    #[serde(skip_serializing_if = "Option::is_none")]
165    pub properties: Option<WorkspaceProperties>,
166}
167
168impl WorkspaceCreateRequest {
169    #[cfg(any(test, feature = "test-support"))]
170    /// Create a fixture instance for testing.
171    pub fn fixture() -> Self {
172        Self {
173            location: "test-location".into(),
174            tags: Default::default(),
175            properties: Some(WorkspaceProperties::fixture()),
176        }
177    }
178}
179
180/// The request body for a Log Analytics query.
181///
182/// **Azure API**: `loganalytics.v1.LogQueryBody`
183/// **Reference**: <https://learn.microsoft.com/en-us/rest/api/loganalytics//LogQueryBody>
184#[derive(Debug, Clone, Default, Serialize, Deserialize)]
185#[serde(rename_all = "camelCase")]
186pub struct LogQueryBody {
187    /// The KQL query to execute
188    pub query: String,
189
190    /// Optional ISO 8601 duration or time range for the query
191    #[serde(skip_serializing_if = "Option::is_none")]
192    pub timespan: Option<String>,
193}
194
195impl LogQueryBody {
196    #[cfg(any(test, feature = "test-support"))]
197    /// Create a fixture instance for testing.
198    pub fn fixture() -> Self {
199        Self {
200            query: "test-query".into(),
201            timespan: Some("test-timespan".into()),
202        }
203    }
204}
205
206/// A column in a Log Analytics query result table.
207///
208/// **Azure API**: `loganalytics.v1.LogQueryColumn`
209/// **Reference**: <https://learn.microsoft.com/en-us/rest/api/loganalytics//LogQueryColumn>
210#[derive(Debug, Clone, Default, Serialize, Deserialize)]
211#[serde(rename_all = "camelCase")]
212pub struct LogQueryColumn {
213    /// The column name
214    #[serde(skip_serializing_if = "Option::is_none")]
215    pub name: Option<String>,
216
217    /// The column data type
218    #[serde(rename = "type")]
219    #[serde(skip_serializing_if = "Option::is_none")]
220    pub r#type: Option<String>,
221}
222
223impl LogQueryColumn {
224    #[cfg(any(test, feature = "test-support"))]
225    /// Create a fixture instance for testing.
226    pub fn fixture() -> Self {
227        Self {
228            name: Some("test-log_query_column".into()),
229            r#type: Some("test-type".into()),
230        }
231    }
232}
233
234/// A table in the Log Analytics query result.
235///
236/// **Azure API**: `loganalytics.v1.LogQueryTable`
237/// **Reference**: <https://learn.microsoft.com/en-us/rest/api/loganalytics//LogQueryTable>
238#[derive(Debug, Clone, Default, Serialize, Deserialize)]
239#[serde(rename_all = "camelCase")]
240pub struct LogQueryTable {
241    /// The name of the table (usually PrimaryResult)
242    #[serde(skip_serializing_if = "Option::is_none")]
243    pub name: Option<String>,
244
245    /// The column schema for this table
246    #[serde(default)]
247    #[serde(skip_serializing_if = "Vec::is_empty")]
248    pub columns: Vec<LogQueryColumn>,
249
250    /// The result rows (each row is a JSON array of values)
251    #[serde(default)]
252    #[serde(skip_serializing_if = "Vec::is_empty")]
253    pub rows: Vec<serde_json::Value>,
254}
255
256impl LogQueryTable {
257    #[cfg(any(test, feature = "test-support"))]
258    /// Create a fixture instance for testing.
259    pub fn fixture() -> Self {
260        Self {
261            name: Some("test-log_query_table".into()),
262            columns: vec![],
263            rows: vec![],
264        }
265    }
266}
267
268/// The response to a Log Analytics query.
269///
270/// **Azure API**: `loganalytics.v1.LogQueryResult`
271/// **Reference**: <https://learn.microsoft.com/en-us/rest/api/loganalytics//LogQueryResult>
272#[derive(Debug, Clone, Default, Serialize, Deserialize)]
273#[serde(rename_all = "camelCase")]
274pub struct LogQueryResult {
275    /// The list of tables, columns and rows
276    #[serde(default)]
277    #[serde(skip_serializing_if = "Vec::is_empty")]
278    pub tables: Vec<LogQueryTable>,
279}
280
281impl LogQueryResult {
282    #[cfg(any(test, feature = "test-support"))]
283    /// Create a fixture instance for testing.
284    pub fn fixture() -> Self {
285        Self { tables: vec![] }
286    }
287}
288
289/// Value object for saved search results.
290///
291/// **Azure API**: `loganalytics.v1.SavedSearchProperties`
292/// **Reference**: <https://learn.microsoft.com/en-us/rest/api/loganalytics//SavedSearchProperties>
293#[derive(Debug, Clone, Default, Serialize, Deserialize)]
294#[serde(rename_all = "camelCase")]
295pub struct SavedSearchProperties {
296    /// The display name of the saved search
297    #[serde(skip_serializing_if = "Option::is_none")]
298    pub display_name: Option<String>,
299
300    /// The category of the saved search
301    #[serde(skip_serializing_if = "Option::is_none")]
302    pub category: Option<String>,
303
304    /// The query expression for the saved search
305    #[serde(skip_serializing_if = "Option::is_none")]
306    pub query: Option<String>,
307
308    /// The version number of the query
309    #[serde(skip_serializing_if = "Option::is_none")]
310    pub version: Option<i32>,
311}
312
313impl SavedSearchProperties {
314    #[cfg(any(test, feature = "test-support"))]
315    /// Create a fixture instance for testing.
316    pub fn fixture() -> Self {
317        Self {
318            display_name: Some("test-display_name".into()),
319            category: Some("test-category".into()),
320            query: Some("test-query".into()),
321            version: Some(100),
322        }
323    }
324}
325
326/// Value object for saved search results.
327///
328/// **Azure API**: `loganalytics.v1.SavedSearch`
329/// **Reference**: <https://learn.microsoft.com/en-us/rest/api/loganalytics//SavedSearch>
330#[derive(Debug, Clone, Default, Serialize, Deserialize)]
331#[serde(rename_all = "camelCase")]
332pub struct SavedSearch {
333    /// The resource ID of the saved search
334    #[serde(skip_serializing_if = "Option::is_none")]
335    pub id: Option<String>,
336
337    /// The name of the saved search resource
338    #[serde(skip_serializing_if = "Option::is_none")]
339    pub name: Option<String>,
340
341    /// The ETag of the saved search
342    #[serde(skip_serializing_if = "Option::is_none")]
343    pub etag: Option<String>,
344
345    /// The properties of the saved search
346    #[serde(skip_serializing_if = "Option::is_none")]
347    pub properties: Option<SavedSearchProperties>,
348}
349
350impl SavedSearch {
351    #[cfg(any(test, feature = "test-support"))]
352    /// Create a fixture instance for testing.
353    pub fn fixture() -> Self {
354        Self {
355            id: Some("test-id".into()),
356            name: Some("test-saved_search".into()),
357            etag: Some("test-etag".into()),
358            properties: Some(SavedSearchProperties::fixture()),
359        }
360    }
361}
362
363/// The saved search list operation response.
364///
365/// **Azure API**: `loganalytics.v1.SavedSearchListResult`
366/// **Reference**: <https://learn.microsoft.com/en-us/rest/api/loganalytics//SavedSearchListResult>
367#[derive(Debug, Clone, Default, Serialize, Deserialize)]
368#[serde(rename_all = "camelCase")]
369pub struct SavedSearchListResult {
370    /// The array of result values
371    #[serde(default)]
372    #[serde(skip_serializing_if = "Vec::is_empty")]
373    pub value: Vec<SavedSearch>,
374}
375
376impl SavedSearchListResult {
377    #[cfg(any(test, feature = "test-support"))]
378    /// Create a fixture instance for testing.
379    pub fn fixture() -> Self {
380        Self { value: vec![] }
381    }
382}