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    /// Whether the event is an online meeting. Setting it makes Graph
135    /// create one with the calendar's default provider (Teams), whose
136    /// details then come back in `onlineMeeting`.
137    #[serde(default, skip_serializing_if = "MsgraphField::is_unset")]
138    pub is_online_meeting: MsgraphField<bool>,
139    /// The details to join an online meeting (Teams), read-only.
140    #[serde(default, skip_serializing_if = "Option::is_none")]
141    pub online_meeting: Option<MsgraphOnlineMeetingInfo>,
142    /// The occurrence ids (`OID.{seriesMasterId}.{date}`) of a series'
143    /// cancelled occurrences, on a series master, read-only.
144    #[serde(default, skip_serializing_if = "Vec::is_empty")]
145    pub cancelled_occurrences: Vec<String>,
146    /// Single-value extended properties, returned only when expanded.
147    #[serde(default, skip_serializing_if = "MsgraphField::is_unset")]
148    pub single_value_extended_properties: MsgraphField<Vec<MsgraphSingleValueExtendedProperty>>,
149}
150
151/// A wall time in a named zone, Graph's time representation.
152///
153/// The zone is a Windows name (`Romance Standard Time`) or an IANA one,
154/// depending on how the event was created, and `UTC` for a UTC time.
155#[derive(Debug, Clone, Default, Deserialize, Serialize, Eq, PartialEq)]
156#[serde(rename_all = "camelCase")]
157pub struct MsgraphDateTimeTimeZone {
158    /// The wall time, `YYYY-MM-DDTHH:MM:SS` with optional fractional
159    /// seconds.
160    pub date_time: String,
161    /// The zone the wall time is read in.
162    #[serde(default, skip_serializing_if = "Option::is_none")]
163    pub time_zone: Option<String>,
164}
165
166/// The details to join an online meeting, read-only.
167#[derive(Debug, Clone, Default, Deserialize, Serialize, Eq, PartialEq)]
168#[serde(rename_all = "camelCase")]
169pub struct MsgraphOnlineMeetingInfo {
170    /// The link to join the meeting.
171    #[serde(default, skip_serializing_if = "Option::is_none")]
172    pub join_url: Option<String>,
173}
174
175/// An event location.
176#[derive(Debug, Clone, Default, Deserialize, Serialize, Eq, PartialEq)]
177#[serde(rename_all = "camelCase")]
178pub struct MsgraphLocation {
179    /// The name shown for the location.
180    #[serde(default, skip_serializing_if = "Option::is_none")]
181    pub display_name: Option<String>,
182    /// A URI for the location.
183    #[serde(default, skip_serializing_if = "Option::is_none")]
184    pub location_uri: Option<String>,
185    /// The street address.
186    #[serde(default, skip_serializing_if = "Option::is_none")]
187    pub address: Option<MsgraphPhysicalAddress>,
188}
189
190/// The recurrence of a series: a pattern and the range it repeats over.
191#[derive(Debug, Clone, Default, Deserialize, Serialize, Eq, PartialEq)]
192#[serde(rename_all = "camelCase")]
193pub struct MsgraphPatternedRecurrence {
194    /// How often the event repeats.
195    pub pattern: MsgraphRecurrencePattern,
196    /// When the repetition starts and stops.
197    pub range: MsgraphRecurrenceRange,
198}
199
200/// How often a series repeats.
201#[derive(Debug, Clone, Default, Deserialize, Serialize, Eq, PartialEq)]
202#[serde(rename_all = "camelCase")]
203pub struct MsgraphRecurrencePattern {
204    /// The kind of pattern.
205    #[serde(default, rename = "type", skip_serializing_if = "Option::is_none")]
206    pub pattern_type: Option<MsgraphRecurrencePatternType>,
207    /// The number of units between occurrences.
208    #[serde(default, skip_serializing_if = "Option::is_none")]
209    pub interval: Option<u32>,
210    /// The month of a yearly pattern, 1 to 12.
211    #[serde(default, skip_serializing_if = "Option::is_none")]
212    pub month: Option<u32>,
213    /// The day of an absolute monthly or yearly pattern.
214    #[serde(default, skip_serializing_if = "Option::is_none")]
215    pub day_of_month: Option<u32>,
216    /// The weekdays of a weekly or relative pattern.
217    #[serde(default, skip_serializing_if = "Vec::is_empty")]
218    pub days_of_week: Vec<MsgraphDayOfWeek>,
219    /// The first day of the week of a weekly pattern.
220    #[serde(default, skip_serializing_if = "Option::is_none")]
221    pub first_day_of_week: Option<MsgraphDayOfWeek>,
222    /// Which week of the month a relative pattern names.
223    #[serde(default, skip_serializing_if = "Option::is_none")]
224    pub index: Option<MsgraphWeekIndex>,
225}
226
227/// When a series starts and stops repeating.
228#[derive(Debug, Clone, Default, Deserialize, Serialize, Eq, PartialEq)]
229#[serde(rename_all = "camelCase")]
230pub struct MsgraphRecurrenceRange {
231    /// How the range ends.
232    #[serde(default, rename = "type", skip_serializing_if = "Option::is_none")]
233    pub range_type: Option<MsgraphRecurrenceRangeType>,
234    /// The first date of the series, `YYYY-MM-DD`.
235    #[serde(default, skip_serializing_if = "Option::is_none")]
236    pub start_date: Option<String>,
237    /// The last date of an `endDate` range, `YYYY-MM-DD`.
238    #[serde(default, skip_serializing_if = "Option::is_none")]
239    pub end_date: Option<String>,
240    /// The zone the dates are read in.
241    #[serde(default, skip_serializing_if = "Option::is_none")]
242    pub recurrence_time_zone: Option<String>,
243    /// The number of occurrences of a `numbered` range.
244    #[serde(default, skip_serializing_if = "Option::is_none")]
245    pub number_of_occurrences: Option<u32>,
246}
247
248/// An event attendee.
249#[derive(Debug, Clone, Default, Deserialize, Serialize, Eq, PartialEq)]
250#[serde(rename_all = "camelCase")]
251pub struct MsgraphAttendee {
252    /// Whether the attendee is required, optional or a resource.
253    #[serde(default, rename = "type", skip_serializing_if = "Option::is_none")]
254    pub attendee_type: Option<MsgraphAttendeeType>,
255    /// The attendee's response.
256    #[serde(default, skip_serializing_if = "Option::is_none")]
257    pub status: Option<MsgraphResponseStatus>,
258    /// The attendee's name and address.
259    #[serde(default, skip_serializing_if = "Option::is_none")]
260    pub email_address: Option<MsgraphEmailAddress>,
261}
262
263/// A response to an invitation.
264#[derive(Debug, Clone, Default, Deserialize, Serialize, Eq, PartialEq)]
265#[serde(rename_all = "camelCase")]
266pub struct MsgraphResponseStatus {
267    /// The response.
268    #[serde(default, skip_serializing_if = "Option::is_none")]
269    pub response: Option<MsgraphResponseType>,
270    /// When it was given.
271    #[serde(default, skip_serializing_if = "Option::is_none")]
272    pub time: Option<String>,
273}
274
275/// The kind of an event within a series.
276#[derive(Debug, Clone, Copy, Deserialize, Serialize, Eq, PartialEq)]
277#[serde(rename_all = "camelCase")]
278pub enum MsgraphEventType {
279    /// A lone event.
280    SingleInstance,
281    /// An occurrence of a series, computed from its recurrence.
282    Occurrence,
283    /// An occurrence edited on its own.
284    Exception,
285    /// The event carrying a series' recurrence.
286    SeriesMaster,
287}
288
289/// How an event shows in free/busy time.
290#[derive(Debug, Clone, Copy, Deserialize, Serialize, Eq, PartialEq)]
291#[serde(rename_all = "camelCase")]
292pub enum MsgraphFreeBusyStatus {
293    /// Unknown status.
294    Unknown,
295    /// Free.
296    Free,
297    /// Tentative.
298    Tentative,
299    /// Busy.
300    Busy,
301    /// Out of office.
302    Oof,
303    /// Working elsewhere.
304    WorkingElsewhere,
305}
306
307/// How private an event is.
308#[derive(Debug, Clone, Copy, Deserialize, Serialize, Eq, PartialEq)]
309#[serde(rename_all = "camelCase")]
310pub enum MsgraphSensitivity {
311    /// Normal.
312    Normal,
313    /// Personal.
314    Personal,
315    /// Private.
316    Private,
317    /// Confidential.
318    Confidential,
319}
320
321/// A response to an invitation.
322#[derive(Debug, Clone, Copy, Deserialize, Serialize, Eq, PartialEq)]
323#[serde(rename_all = "camelCase")]
324pub enum MsgraphResponseType {
325    /// No response.
326    None,
327    /// The organizer, who does not respond.
328    Organizer,
329    /// Tentatively accepted.
330    TentativelyAccepted,
331    /// Accepted.
332    Accepted,
333    /// Declined.
334    Declined,
335    /// Not responded yet.
336    NotResponded,
337}
338
339/// The role of an attendee.
340#[derive(Debug, Clone, Copy, Deserialize, Serialize, Eq, PartialEq)]
341#[serde(rename_all = "camelCase")]
342pub enum MsgraphAttendeeType {
343    /// A required attendee.
344    Required,
345    /// An optional attendee.
346    Optional,
347    /// A resource, a room or equipment.
348    Resource,
349}
350
351/// The kind of a recurrence pattern.
352#[derive(Debug, Clone, Copy, Deserialize, Serialize, Eq, PartialEq)]
353#[serde(rename_all = "camelCase")]
354pub enum MsgraphRecurrencePatternType {
355    /// Every `interval` days.
356    Daily,
357    /// On `daysOfWeek`, every `interval` weeks.
358    Weekly,
359    /// On `dayOfMonth`, every `interval` months.
360    AbsoluteMonthly,
361    /// On the `index` weekday of `daysOfWeek`, every `interval` months.
362    RelativeMonthly,
363    /// On `dayOfMonth` of `month`, every `interval` years.
364    AbsoluteYearly,
365    /// On the `index` weekday of `daysOfWeek` in `month`, every
366    /// `interval` years.
367    RelativeYearly,
368}
369
370/// How a recurrence range ends.
371#[derive(Debug, Clone, Copy, Deserialize, Serialize, Eq, PartialEq)]
372#[serde(rename_all = "camelCase")]
373pub enum MsgraphRecurrenceRangeType {
374    /// On `endDate`.
375    EndDate,
376    /// Never.
377    NoEnd,
378    /// After `numberOfOccurrences`.
379    Numbered,
380}
381
382/// A day of the week.
383#[derive(Debug, Clone, Copy, Deserialize, Serialize, Eq, PartialEq)]
384#[serde(rename_all = "camelCase")]
385pub enum MsgraphDayOfWeek {
386    /// Sunday.
387    Sunday,
388    /// Monday.
389    Monday,
390    /// Tuesday.
391    Tuesday,
392    /// Wednesday.
393    Wednesday,
394    /// Thursday.
395    Thursday,
396    /// Friday.
397    Friday,
398    /// Saturday.
399    Saturday,
400}
401
402/// Which week of the month a relative pattern names.
403#[derive(Debug, Clone, Copy, Deserialize, Serialize, Eq, PartialEq)]
404#[serde(rename_all = "camelCase")]
405pub enum MsgraphWeekIndex {
406    /// The first.
407    First,
408    /// The second.
409    Second,
410    /// The third.
411    Third,
412    /// The fourth.
413    Fourth,
414    /// The last.
415    Last,
416}