Skip to main content

azure_lite_rs/types/
graph.rs

1//! Types for the Microsoft Graph 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};
7
8/// An Entra ID (Azure AD) user object returned by Microsoft Graph.
9///
10/// **Azure API**: `graph.v1.GraphUser`
11/// **Reference**: <https://learn.microsoft.com/en-us/graph/api/overview/GraphUser>
12#[derive(Debug, Clone, Default, Serialize, Deserialize)]
13#[serde(rename_all = "camelCase")]
14pub struct GraphUser {
15    /// The unique identifier for the user (object ID / principal ID).
16    #[serde(skip_serializing_if = "Option::is_none")]
17    pub id: Option<String>,
18
19    /// The display name of the user.
20    #[serde(skip_serializing_if = "Option::is_none")]
21    pub display_name: Option<String>,
22
23    /// The user principal name (UPN). External/guest users have '#EXT#' in their UPN.
24    #[serde(skip_serializing_if = "Option::is_none")]
25    pub user_principal_name: Option<String>,
26
27    /// User type: 'Member' for internal users, 'Guest' for external/invited users.
28    #[serde(skip_serializing_if = "Option::is_none")]
29    pub user_type: Option<String>,
30
31    /// Whether the user's sign-in is enabled in Entra ID.
32    /// `false` means the account is blocked (sign-in disabled).
33    #[serde(skip_serializing_if = "Option::is_none")]
34    pub account_enabled: Option<bool>,
35}
36
37impl GraphUser {
38    #[cfg(any(test, feature = "test-support"))]
39    /// Create a fixture instance for testing.
40    pub fn fixture() -> Self {
41        Self {
42            id: Some("test-id".into()),
43            display_name: Some("test-display_name".into()),
44            user_principal_name: Some("test-user_principal_name".into()),
45            user_type: Some("test-user_type".into()),
46            account_enabled: Some(true),
47        }
48    }
49}
50
51/// A single request within a Microsoft Graph batch.
52///
53/// **Azure API**: `graph.v1.GraphBatchRequestItem`
54/// **Reference**: <https://learn.microsoft.com/en-us/graph/api/overview/GraphBatchRequestItem>
55#[derive(Debug, Clone, Default, Serialize, Deserialize)]
56#[serde(rename_all = "camelCase")]
57pub struct GraphBatchRequestItem {
58    /// Unique identifier for this request within the batch (used to correlate responses).
59    pub id: String,
60
61    /// HTTP method for this request (e.g. 'GET').
62    pub method: String,
63
64    /// Relative URL for this request (e.g. '/users/{id}').
65    pub url: String,
66}
67
68impl GraphBatchRequestItem {
69    #[cfg(any(test, feature = "test-support"))]
70    /// Create a fixture instance for testing.
71    pub fn fixture() -> Self {
72        Self {
73            id: "test-id".into(),
74            method: "test-method".into(),
75            url: "test-url".into(),
76        }
77    }
78}
79
80/// Request body for a Microsoft Graph batch operation ($batch).
81///
82/// **Azure API**: `graph.v1.GraphBatchRequest`
83/// **Reference**: <https://learn.microsoft.com/en-us/graph/api/overview/GraphBatchRequest>
84#[derive(Debug, Clone, Default, Serialize, Deserialize)]
85#[serde(rename_all = "camelCase")]
86pub struct GraphBatchRequest {
87    /// List of individual requests to execute in the batch (max 20 per batch).
88    #[serde(default)]
89    pub requests: Vec<GraphBatchRequestItem>,
90}
91
92impl GraphBatchRequest {
93    #[cfg(any(test, feature = "test-support"))]
94    /// Create a fixture instance for testing.
95    pub fn fixture() -> Self {
96        Self { requests: vec![] }
97    }
98}
99
100/// A single response within a Microsoft Graph batch response.
101///
102/// **Azure API**: `graph.v1.GraphBatchResponseItem`
103/// **Reference**: <https://learn.microsoft.com/en-us/graph/api/overview/GraphBatchResponseItem>
104#[derive(Debug, Clone, Default, Serialize, Deserialize)]
105#[serde(rename_all = "camelCase")]
106pub struct GraphBatchResponseItem {
107    /// Correlates to the request item ID.
108    #[serde(skip_serializing_if = "Option::is_none")]
109    pub id: Option<String>,
110
111    /// HTTP status code for this individual response.
112    #[serde(skip_serializing_if = "Option::is_none")]
113    pub status: Option<i32>,
114
115    /// The response body for this item (parsed as JSON).
116    #[serde(skip_serializing_if = "Option::is_none")]
117    pub body: Option<serde_json::Value>,
118}
119
120impl GraphBatchResponseItem {
121    #[cfg(any(test, feature = "test-support"))]
122    /// Create a fixture instance for testing.
123    pub fn fixture() -> Self {
124        Self {
125            id: Some("test-id".into()),
126            status: Some(100),
127            ..Default::default()
128        }
129    }
130}
131
132/// Response from a Microsoft Graph batch operation ($batch).
133///
134/// **Azure API**: `graph.v1.GraphBatchResponse`
135/// **Reference**: <https://learn.microsoft.com/en-us/graph/api/overview/GraphBatchResponse>
136#[derive(Debug, Clone, Default, Serialize, Deserialize)]
137#[serde(rename_all = "camelCase")]
138pub struct GraphBatchResponse {
139    /// List of individual responses, one per request in the batch.
140    #[serde(default)]
141    #[serde(skip_serializing_if = "Vec::is_empty")]
142    pub responses: Vec<GraphBatchResponseItem>,
143}
144
145impl GraphBatchResponse {
146    #[cfg(any(test, feature = "test-support"))]
147    /// Create a fixture instance for testing.
148    pub fn fixture() -> Self {
149        Self { responses: vec![] }
150    }
151}