Skip to main content

io_msgraph/v1/rest/users/
events.rs

1//! Microsoft Graph events (`users.events`): list, get, create, update,
2//! delete, the instances of a series, the calendar view and its delta.
3//!
4//! A recurring series is one `seriesMaster` event carrying the
5//! recurrence; its `occurrence`s are computed, and an occurrence edited on
6//! its own becomes an `exception`, both pointing at the master through
7//! `seriesMasterId`. The events listing returns masters and lone events,
8//! the calendar view and the instances listing expand occurrences.
9//!
10//! <https://learn.microsoft.com/en-us/graph/api/resources/event>
11
12use alloc::{string::String, vec::Vec};
13
14use serde::{Deserialize, Serialize};
15
16use crate::v1::{
17    field::MsgraphField,
18    rest::users::{
19        contacts::{MsgraphPhysicalAddress, MsgraphSingleValueExtendedProperty},
20        messages::{MsgraphEmailAddress, MsgraphImportance, MsgraphItemBody, MsgraphRecipient},
21    },
22};
23
24pub mod calendar_view;
25pub mod create;
26pub mod delete;
27pub mod delta;
28pub mod get;
29#[cfg(feature = "ical")]
30pub mod ical;
31pub mod instances;
32pub mod list;
33pub mod update;
34
35/// An event of a calendar. Doubles as the create/update body.
36///
37/// Unset fields are left out (an update preserves them), null fields are
38/// serialized as explicit nulls (an update clears them), and a set empty
39/// collection clears the collection.
40#[derive(Debug, Clone, Default, Deserialize, Serialize, Eq, PartialEq)]
41#[serde(rename_all = "camelCase")]
42pub struct MsgraphEvent {
43    /// The unique identifier of the event.
44    #[serde(default, skip_serializing_if = "String::is_empty")]
45    pub id: String,
46    /// The iCalendar UID shared by every event of a series across
47    /// calendars, read-only.
48    #[serde(default, rename = "iCalUId", skip_serializing_if = "Option::is_none")]
49    pub ical_uid: Option<String>,
50    /// The version of the event, changing with every edit, read-only.
51    #[serde(default, skip_serializing_if = "Option::is_none")]
52    pub change_key: Option<String>,
53    /// When the event was created, read-only.
54    #[serde(default, skip_serializing_if = "Option::is_none")]
55    pub created_date_time: Option<String>,
56    /// When the event was last modified, read-only.
57    #[serde(default, skip_serializing_if = "Option::is_none")]
58    pub last_modified_date_time: Option<String>,
59    /// The kind of event: lone, series master, occurrence or exception,
60    /// read-only.
61    #[serde(default, rename = "type", skip_serializing_if = "Option::is_none")]
62    pub event_type: Option<MsgraphEventType>,
63    /// The series master of an occurrence or exception, read-only.
64    #[serde(default, skip_serializing_if = "Option::is_none")]
65    pub series_master_id: Option<String>,
66    /// The start the occurrence had in its series, for an occurrence or
67    /// an exception, read-only.
68    #[serde(default, skip_serializing_if = "Option::is_none")]
69    pub original_start: Option<String>,
70    /// The zone the event's start was created in, read-only.
71    #[serde(default, skip_serializing_if = "Option::is_none")]
72    pub original_start_time_zone: Option<String>,
73    /// The zone the event's end was created in, read-only.
74    #[serde(default, skip_serializing_if = "Option::is_none")]
75    pub original_end_time_zone: Option<String>,
76    /// The subject.
77    #[serde(default, skip_serializing_if = "MsgraphField::is_unset")]
78    pub subject: MsgraphField<String>,
79    /// The body.
80    #[serde(default, skip_serializing_if = "MsgraphField::is_unset")]
81    pub body: MsgraphField<MsgraphItemBody>,
82    /// The start, a wall time in a zone.
83    #[serde(default, skip_serializing_if = "MsgraphField::is_unset")]
84    pub start: MsgraphField<MsgraphDateTimeTimeZone>,
85    /// The end, a wall time in a zone.
86    #[serde(default, skip_serializing_if = "MsgraphField::is_unset")]
87    pub end: MsgraphField<MsgraphDateTimeTimeZone>,
88    /// Whether the event lasts whole days, its start and end then being
89    /// midnights.
90    #[serde(default, skip_serializing_if = "MsgraphField::is_unset")]
91    pub is_all_day: MsgraphField<bool>,
92    /// The location.
93    #[serde(default, skip_serializing_if = "MsgraphField::is_unset")]
94    pub location: MsgraphField<MsgraphLocation>,
95    /// The recurrence of a series master.
96    #[serde(default, skip_serializing_if = "MsgraphField::is_unset")]
97    pub recurrence: MsgraphField<MsgraphPatternedRecurrence>,
98    /// The attendees.
99    #[serde(default, skip_serializing_if = "MsgraphField::is_unset")]
100    pub attendees: MsgraphField<Vec<MsgraphAttendee>>,
101    /// The organizer, read-only once the event exists.
102    #[serde(default, skip_serializing_if = "MsgraphField::is_unset")]
103    pub organizer: MsgraphField<MsgraphRecipient>,
104    /// The categories.
105    #[serde(default, skip_serializing_if = "MsgraphField::is_unset")]
106    pub categories: MsgraphField<Vec<String>>,
107    /// How the event shows in the user's free/busy time.
108    #[serde(default, skip_serializing_if = "MsgraphField::is_unset")]
109    pub show_as: MsgraphField<MsgraphFreeBusyStatus>,
110    /// The sensitivity.
111    #[serde(default, skip_serializing_if = "MsgraphField::is_unset")]
112    pub sensitivity: MsgraphField<MsgraphSensitivity>,
113    /// The importance.
114    #[serde(default, skip_serializing_if = "MsgraphField::is_unset")]
115    pub importance: MsgraphField<MsgraphImportance>,
116    /// Whether a reminder is set.
117    #[serde(default, skip_serializing_if = "MsgraphField::is_unset")]
118    pub is_reminder_on: MsgraphField<bool>,
119    /// How long before the start the reminder fires, in minutes.
120    #[serde(default, skip_serializing_if = "MsgraphField::is_unset")]
121    pub reminder_minutes_before_start: MsgraphField<u32>,
122    /// Whether the event was cancelled, read-only.
123    #[serde(default, skip_serializing_if = "Option::is_none")]
124    pub is_cancelled: Option<bool>,
125    /// Whether the user organizes the event, read-only.
126    #[serde(default, skip_serializing_if = "Option::is_none")]
127    pub is_organizer: Option<bool>,
128    /// The user's own response, read-only.
129    #[serde(default, skip_serializing_if = "Option::is_none")]
130    pub response_status: Option<MsgraphResponseStatus>,
131    /// The Outlook web link, read-only.
132    #[serde(default, skip_serializing_if = "Option::is_none")]
133    pub web_link: Option<String>,
134    /// The occurrence ids (`OID.{seriesMasterId}.{date}`) of a series'
135    /// cancelled occurrences, on a series master, read-only.
136    #[serde(default, skip_serializing_if = "Vec::is_empty")]
137    pub cancelled_occurrences: Vec<String>,
138    /// Single-value extended properties, returned only when expanded.
139    #[serde(default, skip_serializing_if = "MsgraphField::is_unset")]
140    pub single_value_extended_properties: MsgraphField<Vec<MsgraphSingleValueExtendedProperty>>,
141}
142
143/// A wall time in a named zone, Graph's time representation.
144///
145/// The zone is a Windows name (`Romance Standard Time`) or an IANA one,
146/// depending on how the event was created, and `UTC` for a UTC time.
147#[derive(Debug, Clone, Default, Deserialize, Serialize, Eq, PartialEq)]
148#[serde(rename_all = "camelCase")]
149pub struct MsgraphDateTimeTimeZone {
150    /// The wall time, `YYYY-MM-DDTHH:MM:SS` with optional fractional
151    /// seconds.
152    pub date_time: String,
153    /// The zone the wall time is read in.
154    #[serde(default, skip_serializing_if = "Option::is_none")]
155    pub time_zone: Option<String>,
156}
157
158/// An event location.
159#[derive(Debug, Clone, Default, Deserialize, Serialize, Eq, PartialEq)]
160#[serde(rename_all = "camelCase")]
161pub struct MsgraphLocation {
162    /// The name shown for the location.
163    #[serde(default, skip_serializing_if = "Option::is_none")]
164    pub display_name: Option<String>,
165    /// A URI for the location.
166    #[serde(default, skip_serializing_if = "Option::is_none")]
167    pub location_uri: Option<String>,
168    /// The street address.
169    #[serde(default, skip_serializing_if = "Option::is_none")]
170    pub address: Option<MsgraphPhysicalAddress>,
171}
172
173/// The recurrence of a series: a pattern and the range it repeats over.
174#[derive(Debug, Clone, Default, Deserialize, Serialize, Eq, PartialEq)]
175#[serde(rename_all = "camelCase")]
176pub struct MsgraphPatternedRecurrence {
177    /// How often the event repeats.
178    pub pattern: MsgraphRecurrencePattern,
179    /// When the repetition starts and stops.
180    pub range: MsgraphRecurrenceRange,
181}
182
183/// How often a series repeats.
184#[derive(Debug, Clone, Default, Deserialize, Serialize, Eq, PartialEq)]
185#[serde(rename_all = "camelCase")]
186pub struct MsgraphRecurrencePattern {
187    /// The kind of pattern.
188    #[serde(default, rename = "type", skip_serializing_if = "Option::is_none")]
189    pub pattern_type: Option<MsgraphRecurrencePatternType>,
190    /// The number of units between occurrences.
191    #[serde(default, skip_serializing_if = "Option::is_none")]
192    pub interval: Option<u32>,
193    /// The month of a yearly pattern, 1 to 12.
194    #[serde(default, skip_serializing_if = "Option::is_none")]
195    pub month: Option<u32>,
196    /// The day of an absolute monthly or yearly pattern.
197    #[serde(default, skip_serializing_if = "Option::is_none")]
198    pub day_of_month: Option<u32>,
199    /// The weekdays of a weekly or relative pattern.
200    #[serde(default, skip_serializing_if = "Vec::is_empty")]
201    pub days_of_week: Vec<MsgraphDayOfWeek>,
202    /// The first day of the week of a weekly pattern.
203    #[serde(default, skip_serializing_if = "Option::is_none")]
204    pub first_day_of_week: Option<MsgraphDayOfWeek>,
205    /// Which week of the month a relative pattern names.
206    #[serde(default, skip_serializing_if = "Option::is_none")]
207    pub index: Option<MsgraphWeekIndex>,
208}
209
210/// When a series starts and stops repeating.
211#[derive(Debug, Clone, Default, Deserialize, Serialize, Eq, PartialEq)]
212#[serde(rename_all = "camelCase")]
213pub struct MsgraphRecurrenceRange {
214    /// How the range ends.
215    #[serde(default, rename = "type", skip_serializing_if = "Option::is_none")]
216    pub range_type: Option<MsgraphRecurrenceRangeType>,
217    /// The first date of the series, `YYYY-MM-DD`.
218    #[serde(default, skip_serializing_if = "Option::is_none")]
219    pub start_date: Option<String>,
220    /// The last date of an `endDate` range, `YYYY-MM-DD`.
221    #[serde(default, skip_serializing_if = "Option::is_none")]
222    pub end_date: Option<String>,
223    /// The zone the dates are read in.
224    #[serde(default, skip_serializing_if = "Option::is_none")]
225    pub recurrence_time_zone: Option<String>,
226    /// The number of occurrences of a `numbered` range.
227    #[serde(default, skip_serializing_if = "Option::is_none")]
228    pub number_of_occurrences: Option<u32>,
229}
230
231/// An event attendee.
232#[derive(Debug, Clone, Default, Deserialize, Serialize, Eq, PartialEq)]
233#[serde(rename_all = "camelCase")]
234pub struct MsgraphAttendee {
235    /// Whether the attendee is required, optional or a resource.
236    #[serde(default, rename = "type", skip_serializing_if = "Option::is_none")]
237    pub attendee_type: Option<MsgraphAttendeeType>,
238    /// The attendee's response.
239    #[serde(default, skip_serializing_if = "Option::is_none")]
240    pub status: Option<MsgraphResponseStatus>,
241    /// The attendee's name and address.
242    #[serde(default, skip_serializing_if = "Option::is_none")]
243    pub email_address: Option<MsgraphEmailAddress>,
244}
245
246/// A response to an invitation.
247#[derive(Debug, Clone, Default, Deserialize, Serialize, Eq, PartialEq)]
248#[serde(rename_all = "camelCase")]
249pub struct MsgraphResponseStatus {
250    /// The response.
251    #[serde(default, skip_serializing_if = "Option::is_none")]
252    pub response: Option<MsgraphResponseType>,
253    /// When it was given.
254    #[serde(default, skip_serializing_if = "Option::is_none")]
255    pub time: Option<String>,
256}
257
258/// The kind of an event within a series.
259#[derive(Debug, Clone, Copy, Deserialize, Serialize, Eq, PartialEq)]
260#[serde(rename_all = "camelCase")]
261pub enum MsgraphEventType {
262    /// A lone event.
263    SingleInstance,
264    /// An occurrence of a series, computed from its recurrence.
265    Occurrence,
266    /// An occurrence edited on its own.
267    Exception,
268    /// The event carrying a series' recurrence.
269    SeriesMaster,
270}
271
272/// How an event shows in free/busy time.
273#[derive(Debug, Clone, Copy, Deserialize, Serialize, Eq, PartialEq)]
274#[serde(rename_all = "camelCase")]
275pub enum MsgraphFreeBusyStatus {
276    /// Unknown status.
277    Unknown,
278    /// Free.
279    Free,
280    /// Tentative.
281    Tentative,
282    /// Busy.
283    Busy,
284    /// Out of office.
285    Oof,
286    /// Working elsewhere.
287    WorkingElsewhere,
288}
289
290/// How private an event is.
291#[derive(Debug, Clone, Copy, Deserialize, Serialize, Eq, PartialEq)]
292#[serde(rename_all = "camelCase")]
293pub enum MsgraphSensitivity {
294    /// Normal.
295    Normal,
296    /// Personal.
297    Personal,
298    /// Private.
299    Private,
300    /// Confidential.
301    Confidential,
302}
303
304/// A response to an invitation.
305#[derive(Debug, Clone, Copy, Deserialize, Serialize, Eq, PartialEq)]
306#[serde(rename_all = "camelCase")]
307pub enum MsgraphResponseType {
308    /// No response.
309    None,
310    /// The organizer, who does not respond.
311    Organizer,
312    /// Tentatively accepted.
313    TentativelyAccepted,
314    /// Accepted.
315    Accepted,
316    /// Declined.
317    Declined,
318    /// Not responded yet.
319    NotResponded,
320}
321
322/// The role of an attendee.
323#[derive(Debug, Clone, Copy, Deserialize, Serialize, Eq, PartialEq)]
324#[serde(rename_all = "camelCase")]
325pub enum MsgraphAttendeeType {
326    /// A required attendee.
327    Required,
328    /// An optional attendee.
329    Optional,
330    /// A resource, a room or equipment.
331    Resource,
332}
333
334/// The kind of a recurrence pattern.
335#[derive(Debug, Clone, Copy, Deserialize, Serialize, Eq, PartialEq)]
336#[serde(rename_all = "camelCase")]
337pub enum MsgraphRecurrencePatternType {
338    /// Every `interval` days.
339    Daily,
340    /// On `daysOfWeek`, every `interval` weeks.
341    Weekly,
342    /// On `dayOfMonth`, every `interval` months.
343    AbsoluteMonthly,
344    /// On the `index` weekday of `daysOfWeek`, every `interval` months.
345    RelativeMonthly,
346    /// On `dayOfMonth` of `month`, every `interval` years.
347    AbsoluteYearly,
348    /// On the `index` weekday of `daysOfWeek` in `month`, every
349    /// `interval` years.
350    RelativeYearly,
351}
352
353/// How a recurrence range ends.
354#[derive(Debug, Clone, Copy, Deserialize, Serialize, Eq, PartialEq)]
355#[serde(rename_all = "camelCase")]
356pub enum MsgraphRecurrenceRangeType {
357    /// On `endDate`.
358    EndDate,
359    /// Never.
360    NoEnd,
361    /// After `numberOfOccurrences`.
362    Numbered,
363}
364
365/// A day of the week.
366#[derive(Debug, Clone, Copy, Deserialize, Serialize, Eq, PartialEq)]
367#[serde(rename_all = "camelCase")]
368pub enum MsgraphDayOfWeek {
369    /// Sunday.
370    Sunday,
371    /// Monday.
372    Monday,
373    /// Tuesday.
374    Tuesday,
375    /// Wednesday.
376    Wednesday,
377    /// Thursday.
378    Thursday,
379    /// Friday.
380    Friday,
381    /// Saturday.
382    Saturday,
383}
384
385/// Which week of the month a relative pattern names.
386#[derive(Debug, Clone, Copy, Deserialize, Serialize, Eq, PartialEq)]
387#[serde(rename_all = "camelCase")]
388pub enum MsgraphWeekIndex {
389    /// The first.
390    First,
391    /// The second.
392    Second,
393    /// The third.
394    Third,
395    /// The fourth.
396    Fourth,
397    /// The last.
398    Last,
399}