Skip to main content

ibridge_server/
calendar_dto.rs

1// SPDX-License-Identifier: Apache-2.0
2
3//! Calendar and reminders tool arguments and structured results.
4
5use schemars::JsonSchema;
6use serde::{Deserialize, Serialize};
7
8fn default_page_limit() -> u32 {
9    25
10}
11
12/// Arguments for `calendar_list_events`.
13#[derive(Debug, Default, Deserialize, JsonSchema)]
14pub struct ListEventsParams {
15    /// Calendar ids from `calendar_list_calendars`. Omit for every calendar that holds events.
16    #[serde(default)]
17    pub calendars: Vec<String>,
18    /// Start of the range, as an ISO-8601 date or timestamp. Included.
19    pub start: String,
20    /// End of the range, as an ISO-8601 date or timestamp. Excluded.
21    pub end: String,
22    /// Page size. Omitted means 25. More than 100 is rejected.
23    #[serde(default = "default_page_limit")]
24    pub limit: u32,
25    /// Cursor from the previous page.
26    #[serde(default)]
27    pub cursor: Option<String>,
28}
29
30/// Arguments for `calendar_get_event`.
31#[derive(Debug, Default, Deserialize, JsonSchema)]
32pub struct GetByIdParams {
33    /// Opaque id from a list result.
34    pub id: String,
35}
36
37/// Arguments for `calendar_create_event`.
38#[derive(Debug, Default, Deserialize, JsonSchema)]
39pub struct CreateEventParams {
40    /// Calendar id from `calendar_list_calendars`. It must hold events.
41    pub calendar: String,
42    /// Title of the event.
43    pub summary: String,
44    /// Notes.
45    #[serde(default)]
46    pub description: Option<String>,
47    /// Start: an ISO-8601 date for an all-day event, otherwise a timestamp.
48    pub start: String,
49    /// End. Omit for one hour after the start, or one day for an all-day event.
50    #[serde(default)]
51    pub end: Option<String>,
52    /// IANA time zone name, such as Europe/Berlin. Omit for UTC.
53    #[serde(default)]
54    pub time_zone: Option<String>,
55}
56
57/// Arguments for `calendar_update_event`.
58#[derive(Debug, Default, Deserialize, JsonSchema)]
59pub struct UpdateEventParams {
60    /// Opaque event id.
61    pub id: String,
62    /// The `etag` from the last read. A different one means the event changed.
63    pub etag: String,
64    /// New title. Omit to keep it.
65    #[serde(default)]
66    pub summary: Option<String>,
67    /// New notes. Omit to keep them.
68    #[serde(default)]
69    pub description: Option<String>,
70    /// New start. Omit to keep it.
71    #[serde(default)]
72    pub start: Option<String>,
73    /// New end. Omit to keep it.
74    #[serde(default)]
75    pub end: Option<String>,
76    /// IANA time zone for the new times. Omit to keep the event's zone.
77    #[serde(default)]
78    pub time_zone: Option<String>,
79    /// For a repeating event: the `recurrence_id` of one occurrence to change on its own.
80    /// Omit to change the whole series. Changing one occurrence needs `start` and `end`.
81    #[serde(default)]
82    pub occurrence: Option<String>,
83}
84
85/// Arguments for the delete tools.
86#[derive(Debug, Default, Deserialize, JsonSchema)]
87pub struct DeleteParams {
88    /// Opaque id.
89    pub id: String,
90    /// The `etag` from the last read.
91    pub etag: String,
92}
93
94/// Arguments for `reminders_list`.
95#[derive(Debug, Default, Deserialize, JsonSchema)]
96pub struct ListRemindersParams {
97    /// List id from `reminders_list_lists`. Omit for every list.
98    #[serde(default)]
99    pub list: Option<String>,
100    /// Also return completed reminders. Omitted means open reminders only.
101    #[serde(default)]
102    pub include_completed: Option<bool>,
103    /// Page size. Omitted means 25. More than 100 is rejected.
104    #[serde(default = "default_page_limit")]
105    pub limit: u32,
106    /// Cursor from the previous page.
107    #[serde(default)]
108    pub cursor: Option<String>,
109}
110
111/// Arguments for `reminders_create`.
112#[derive(Debug, Default, Deserialize, JsonSchema)]
113pub struct CreateReminderParams {
114    /// List id from `reminders_list_lists`.
115    pub list: String,
116    /// Title.
117    pub title: String,
118    /// Notes.
119    #[serde(default)]
120    pub notes: Option<String>,
121    /// Due date or timestamp, ISO-8601.
122    #[serde(default)]
123    pub due: Option<String>,
124    /// Priority from 1 (highest) to 9.
125    #[serde(default)]
126    pub priority: Option<u8>,
127}
128
129/// Arguments for `reminders_update`.
130#[derive(Debug, Default, Deserialize, JsonSchema)]
131pub struct UpdateReminderParams {
132    /// Opaque reminder id.
133    pub id: String,
134    /// The `etag` from the last read.
135    pub etag: String,
136    /// New title. Omit to keep it.
137    #[serde(default)]
138    pub title: Option<String>,
139    /// New notes. Omit to keep them.
140    #[serde(default)]
141    pub notes: Option<String>,
142    /// New due date. Omit to keep it; an empty string removes it.
143    #[serde(default)]
144    pub due: Option<String>,
145    /// New priority, 1 to 9. Omit to keep it; 0 removes it.
146    #[serde(default)]
147    pub priority: Option<u8>,
148    /// Mark completed or open. Omit to keep it.
149    #[serde(default)]
150    pub completed: Option<bool>,
151}
152
153#[derive(Debug, Serialize, JsonSchema)]
154pub(crate) struct CalendarOut {
155    pub(crate) id: String,
156    /// As the calendar's owner named it.
157    pub(crate) name: String,
158    /// `events`, `tasks` or `both`.
159    pub(crate) kind: &'static str,
160}
161
162#[derive(Debug, Serialize, JsonSchema)]
163pub(crate) struct CalendarListOut {
164    pub(crate) calendars: Vec<CalendarOut>,
165}
166
167#[derive(Debug, Serialize, JsonSchema)]
168pub(crate) struct EventOut {
169    pub(crate) id: String,
170    pub(crate) etag: String,
171    pub(crate) uid: String,
172    /// As the event's author wrote it.
173    pub(crate) summary: String,
174    /// As the event's author wrote it.
175    pub(crate) description: String,
176    pub(crate) start: String,
177    pub(crate) end: String,
178    pub(crate) time_zone: Option<String>,
179    pub(crate) all_day: bool,
180    pub(crate) recurring: bool,
181    /// Pass as `occurrence` to change only this occurrence.
182    pub(crate) recurrence_id: Option<String>,
183    /// As the event's author entered them.
184    pub(crate) attendees: Vec<String>,
185    pub(crate) alarms: Vec<String>,
186}
187
188#[derive(Debug, Serialize, JsonSchema)]
189pub(crate) struct EventListOut {
190    pub(crate) events: Vec<EventOut>,
191    pub(crate) next_cursor: Option<String>,
192    /// Items that could not be read and were skipped.
193    pub(crate) warnings: u32,
194}
195
196#[derive(Debug, Serialize, JsonSchema)]
197pub(crate) struct WriteOut {
198    pub(crate) id: String,
199    /// The new `etag`, when the write returned one.
200    pub(crate) etag: Option<String>,
201}
202
203#[derive(Debug, Serialize, JsonSchema)]
204pub(crate) struct DeleteOut {
205    pub(crate) deleted: bool,
206}
207
208#[derive(Debug, Serialize, JsonSchema)]
209pub(crate) struct ReminderListOut {
210    pub(crate) id: String,
211    /// As the calendar's owner named it.
212    pub(crate) name: String,
213}
214
215#[derive(Debug, Serialize, JsonSchema)]
216pub(crate) struct ReminderListsOut {
217    pub(crate) lists: Vec<ReminderListOut>,
218    /// Says that lists the Reminders app upgraded are not reachable.
219    pub(crate) note: &'static str,
220}
221
222#[derive(Debug, Serialize, JsonSchema)]
223pub(crate) struct ReminderOut {
224    pub(crate) id: String,
225    pub(crate) etag: String,
226    /// As the reminder's author wrote it.
227    pub(crate) title: String,
228    /// As the reminder's author wrote it.
229    pub(crate) notes: String,
230    pub(crate) due: Option<String>,
231    pub(crate) priority: Option<u8>,
232    pub(crate) completed: bool,
233}
234
235#[derive(Debug, Serialize, JsonSchema)]
236pub(crate) struct RemindersOut {
237    pub(crate) reminders: Vec<ReminderOut>,
238    pub(crate) next_cursor: Option<String>,
239    /// Items that could not be read and were skipped.
240    pub(crate) warnings: u32,
241}