google_calendar/
events.rs

1use crate::Client;
2use crate::ClientResult;
3
4pub struct Events {
5    pub client: Client,
6}
7
8impl Events {
9    #[doc(hidden)]
10    pub fn new(client: Client) -> Self {
11        Events { client }
12    }
13
14    /**
15     * This function performs a `GET` to the `/calendars/{calendarId}/events` endpoint.
16     *
17     * Returns events on the specified calendar.
18     *
19     * **Parameters:**
20     *
21     * * `calendar_id: &str` -- Calendar identifier. To retrieve calendar IDs call the calendarList.list method. If you want to access the primary calendar of the currently logged in user, use the "primary" keyword.
22     * * `always_include_email: bool` -- Deprecated and ignored. A value will always be returned in the email field for the organizer, creator and attendees, even if no real email address is available (i.e. a generated, non-working value will be provided).
23     * * `i_cal_uid: &str` -- Specifies event ID in the iCalendar format to be included in the response. Optional.
24     * * `max_attendees: i64` -- The maximum number of attendees to include in the response. If there are more than the specified number of attendees, only the participant is returned. Optional.
25     * * `max_results: i64` -- Maximum number of events returned on one result page. The number of events in the resulting page may be less than this value, or none at all, even if there are more events matching the query. Incomplete pages can be detected by a non-empty nextPageToken field in the response. By default the value is 250 events. The page size can never be larger than 2500 events. Optional.
26     * * `order_by: crate::types::OrderBy` -- The order of the events returned in the result. Optional. The default is an unspecified, stable order.
27     * * `page_token: &str` -- Token specifying which result page to return. Optional.
28     * * `private_extended_property: &[String]` -- Extended properties constraint specified as propertyName=value. Matches only private properties. This parameter might be repeated multiple times to return events that match all given constraints.
29     * * `q: &str` -- Free text search terms to find events that match these terms in any field, except for extended properties. Optional.
30     * * `shared_extended_property: &[String]` -- Extended properties constraint specified as propertyName=value. Matches only shared properties. This parameter might be repeated multiple times to return events that match all given constraints.
31     * * `show_deleted: bool` -- Whether to include deleted events (with status equals "cancelled") in the result. Cancelled instances of recurring events (but not the underlying recurring event) will still be included if showDeleted and singleEvents are both False. If showDeleted and singleEvents are both True, only single instances of deleted events (but not the underlying recurring events) are returned. Optional. The default is False.
32     * * `show_hidden_invitations: bool` -- Whether this calendar list entry has been deleted from the calendar list. Read-only. Optional. The default is False.
33     * * `single_events: bool` -- Whether to expand recurring events into instances and only return single one-off events and instances of recurring events, but not the underlying recurring events themselves. Optional. The default is False.
34     * * `sync_token: &str` -- Token obtained from the nextSyncToken field returned on the last page of results from the previous list request. It makes the result of this list request contain only entries that have changed since then. All events deleted since the previous list request will always be in the result set and it is not allowed to set showDeleted to False.
35     *   There are several query parameters that cannot be specified together with nextSyncToken to ensure consistency of the client state.
36     *   
37     *   These are:
38     *   - iCalUID
39     *   - orderBy
40     *   - privateExtendedProperty
41     *   - q
42     *   - sharedExtendedProperty
43     *   - timeMin
44     *   - timeMax
45     *   - updatedMin If the syncToken expires, the server will respond with a 410 GONE response code and the client should clear its storage and perform a full synchronization without any syncToken.
46     *   Learn more about incremental synchronization.
47     *   Optional. The default is to return all entries.
48     * * `time_max: &str` -- Upper bound (exclusive) for an event's start time to filter by. Optional. The default is not to filter by start time. Must be an RFC3339 timestamp with mandatory time zone offset, for example, 2011-06-03T10:00:00-07:00, 2011-06-03T10:00:00Z. Milliseconds may be provided but are ignored. If timeMin is set, timeMax must be greater than timeMin.
49     * * `time_min: &str` -- Lower bound (exclusive) for an event's end time to filter by. Optional. The default is not to filter by end time. Must be an RFC3339 timestamp with mandatory time zone offset, for example, 2011-06-03T10:00:00-07:00, 2011-06-03T10:00:00Z. Milliseconds may be provided but are ignored. If timeMax is set, timeMin must be smaller than timeMax.
50     * * `time_zone: &str` -- Time zone used in the response. Optional. The default is the time zone of the calendar.
51     * * `updated_min: &str` -- Lower bound for an event's last modification time (as a RFC3339 timestamp) to filter by. When specified, entries deleted since this time will always be included regardless of showDeleted. Optional. The default is not to filter by last modification time.
52     */
53    pub async fn list(
54        &self,
55        calendar_id: &str,
56        i_cal_uid: &str,
57        max_attendees: i64,
58        max_results: i64,
59        order_by: crate::types::OrderBy,
60        page_token: &str,
61        private_extended_property: &[String],
62        q: &str,
63        shared_extended_property: &[String],
64        show_deleted: bool,
65        show_hidden_invitations: bool,
66        single_events: bool,
67        time_max: &str,
68        time_min: &str,
69        time_zone: &str,
70        updated_min: &str,
71    ) -> ClientResult<crate::Response<Vec<crate::types::Event>>> {
72        let mut query_args: Vec<(String, String)> = Default::default();
73        if !i_cal_uid.is_empty() {
74            query_args.push(("iCalUID".to_string(), i_cal_uid.to_string()));
75        }
76        if max_attendees > 0 {
77            query_args.push(("maxAttendees".to_string(), max_attendees.to_string()));
78        }
79        if max_results > 0 {
80            query_args.push(("maxResults".to_string(), max_results.to_string()));
81        }
82        if !order_by.to_string().is_empty() {
83            query_args.push(("orderBy".to_string(), order_by.to_string()));
84        }
85        if !page_token.is_empty() {
86            query_args.push(("pageToken".to_string(), page_token.to_string()));
87        }
88        if !private_extended_property.is_empty() {
89            query_args.push((
90                "privateExtendedProperty".to_string(),
91                private_extended_property.join(" "),
92            ));
93        }
94        if !q.is_empty() {
95            query_args.push(("q".to_string(), q.to_string()));
96        }
97        if !shared_extended_property.is_empty() {
98            query_args.push((
99                "sharedExtendedProperty".to_string(),
100                shared_extended_property.join(" "),
101            ));
102        }
103        if show_deleted {
104            query_args.push(("showDeleted".to_string(), show_deleted.to_string()));
105        }
106        if show_hidden_invitations {
107            query_args.push((
108                "showHiddenInvitations".to_string(),
109                show_hidden_invitations.to_string(),
110            ));
111        }
112        if single_events {
113            query_args.push(("singleEvents".to_string(), single_events.to_string()));
114        }
115        if !time_max.is_empty() {
116            query_args.push(("timeMax".to_string(), time_max.to_string()));
117        }
118        if !time_min.is_empty() {
119            query_args.push(("timeMin".to_string(), time_min.to_string()));
120        }
121        if !time_zone.is_empty() {
122            query_args.push(("timeZone".to_string(), time_zone.to_string()));
123        }
124        if !updated_min.is_empty() {
125            query_args.push(("updatedMin".to_string(), updated_min.to_string()));
126        }
127        let query_ = serde_urlencoded::to_string(&query_args).unwrap();
128        let url = self.client.url(
129            &format!(
130                "/calendars/{}/events?{}",
131                crate::progenitor_support::encode_path(calendar_id),
132                query_
133            ),
134            None,
135        );
136        let resp: crate::Response<crate::types::Events> = self
137            .client
138            .get(
139                &url,
140                crate::Message {
141                    body: None,
142                    content_type: None,
143                },
144            )
145            .await?;
146
147        // Return our response data.
148        Ok(crate::Response::new(
149            resp.status,
150            resp.headers,
151            resp.body.items.to_vec(),
152        ))
153    }
154    /**
155     * This function performs a `GET` to the `/calendars/{calendarId}/events` endpoint.
156     *
157     * As opposed to `list`, this function returns all the pages of the request at once.
158     *
159     * Returns events on the specified calendar.
160     */
161    pub async fn list_all(
162        &self,
163        calendar_id: &str,
164        i_cal_uid: &str,
165        max_attendees: i64,
166        order_by: crate::types::OrderBy,
167        private_extended_property: &[String],
168        q: &str,
169        shared_extended_property: &[String],
170        show_deleted: bool,
171        show_hidden_invitations: bool,
172        single_events: bool,
173        time_max: &str,
174        time_min: &str,
175        time_zone: &str,
176        updated_min: &str,
177    ) -> ClientResult<crate::Response<Vec<crate::types::Event>>> {
178        let mut query_args: Vec<(String, String)> = Default::default();
179        if !i_cal_uid.is_empty() {
180            query_args.push(("iCalUID".to_string(), i_cal_uid.to_string()));
181        }
182        if max_attendees > 0 {
183            query_args.push(("maxAttendees".to_string(), max_attendees.to_string()));
184        }
185        if !order_by.to_string().is_empty() {
186            query_args.push(("orderBy".to_string(), order_by.to_string()));
187        }
188        if !private_extended_property.is_empty() {
189            query_args.push((
190                "privateExtendedProperty".to_string(),
191                private_extended_property.join(" "),
192            ));
193        }
194        if !q.is_empty() {
195            query_args.push(("q".to_string(), q.to_string()));
196        }
197        if !shared_extended_property.is_empty() {
198            query_args.push((
199                "sharedExtendedProperty".to_string(),
200                shared_extended_property.join(" "),
201            ));
202        }
203        if show_deleted {
204            query_args.push(("showDeleted".to_string(), show_deleted.to_string()));
205        }
206        if show_hidden_invitations {
207            query_args.push((
208                "showHiddenInvitations".to_string(),
209                show_hidden_invitations.to_string(),
210            ));
211        }
212        if single_events {
213            query_args.push(("singleEvents".to_string(), single_events.to_string()));
214        }
215        if !time_max.is_empty() {
216            query_args.push(("timeMax".to_string(), time_max.to_string()));
217        }
218        if !time_min.is_empty() {
219            query_args.push(("timeMin".to_string(), time_min.to_string()));
220        }
221        if !time_zone.is_empty() {
222            query_args.push(("timeZone".to_string(), time_zone.to_string()));
223        }
224        if !updated_min.is_empty() {
225            query_args.push(("updatedMin".to_string(), updated_min.to_string()));
226        }
227        let query_ = serde_urlencoded::to_string(&query_args).unwrap();
228        let url = self.client.url(
229            &format!(
230                "/calendars/{}/events?{}",
231                crate::progenitor_support::encode_path(calendar_id),
232                query_
233            ),
234            None,
235        );
236        let crate::Response::<crate::types::Events> {
237            mut status,
238            mut headers,
239            mut body,
240        } = self
241            .client
242            .get(
243                &url,
244                crate::Message {
245                    body: None,
246                    content_type: None,
247                },
248            )
249            .await?;
250
251        let mut items = body.items;
252        let mut page = body.next_page_token;
253
254        // Paginate if we should.
255        while !page.is_empty() {
256            if !url.contains('?') {
257                crate::Response::<crate::types::Events> {
258                    status,
259                    headers,
260                    body,
261                } = self
262                    .client
263                    .get(
264                        &format!("{}?pageToken={}", url, page),
265                        crate::Message {
266                            body: None,
267                            content_type: None,
268                        },
269                    )
270                    .await?;
271            } else {
272                crate::Response::<crate::types::Events> {
273                    status,
274                    headers,
275                    body,
276                } = self
277                    .client
278                    .get(
279                        &format!("{}&pageToken={}", url, page),
280                        crate::Message {
281                            body: None,
282                            content_type: None,
283                        },
284                    )
285                    .await?;
286            }
287
288            items.append(&mut body.items);
289
290            if !body.next_page_token.is_empty() && body.next_page_token != page {
291                page = body.next_page_token.to_string();
292            } else {
293                page = "".to_string();
294            }
295        }
296
297        // Return our response data.
298        Ok(crate::Response::new(status, headers, items))
299    }
300    /**
301     * This function performs a `POST` to the `/calendars/{calendarId}/events` endpoint.
302     *
303     * Creates an event.
304     *
305     * **Parameters:**
306     *
307     * * `calendar_id: &str` -- Calendar identifier. To retrieve calendar IDs call the calendarList.list method. If you want to access the primary calendar of the currently logged in user, use the "primary" keyword.
308     * * `conference_data_version: u64` -- Version number of conference data supported by the API client. Version 0 assumes no conference data support and ignores conference data in the event's body. Version 1 enables support for copying of ConferenceData as well as for creating new conferences using the createRequest field of conferenceData. The default is 0.
309     * * `max_attendees: i64` -- The maximum number of attendees to include in the response. If there are more than the specified number of attendees, only the participant is returned. Optional.
310     * * `send_notifications: bool` -- Deprecated. Please use sendUpdates instead.
311     *   
312     *   Whether to send notifications about the creation of the new event. Note that some emails might still be sent even if you set the value to false. The default is false.
313     * * `send_updates: crate::types::SendUpdates` -- Whether to send notifications about the creation of the new event. Note that some emails might still be sent. The default is false.
314     * * `supports_attachments: bool` -- Whether this calendar list entry has been deleted from the calendar list. Read-only. Optional. The default is False.
315     */
316    pub async fn insert(
317        &self,
318        calendar_id: &str,
319        conference_data_version: u64,
320        max_attendees: i64,
321        send_notifications: bool,
322        send_updates: crate::types::SendUpdates,
323        supports_attachments: bool,
324        body: &crate::types::Event,
325    ) -> ClientResult<crate::Response<crate::types::Event>> {
326        let mut query_args: Vec<(String, String)> = Default::default();
327        if !conference_data_version.to_string().is_empty() {
328            query_args.push((
329                "conferenceDataVersion".to_string(),
330                conference_data_version.to_string(),
331            ));
332        }
333        if max_attendees > 0 {
334            query_args.push(("maxAttendees".to_string(), max_attendees.to_string()));
335        }
336        if send_notifications {
337            query_args.push((
338                "sendNotifications".to_string(),
339                send_notifications.to_string(),
340            ));
341        }
342        if !send_updates.to_string().is_empty() {
343            query_args.push(("sendUpdates".to_string(), send_updates.to_string()));
344        }
345        if supports_attachments {
346            query_args.push((
347                "supportsAttachments".to_string(),
348                supports_attachments.to_string(),
349            ));
350        }
351        let query_ = serde_urlencoded::to_string(&query_args).unwrap();
352        let url = self.client.url(
353            &format!(
354                "/calendars/{}/events?{}",
355                crate::progenitor_support::encode_path(calendar_id),
356                query_
357            ),
358            None,
359        );
360        self.client
361            .post(
362                &url,
363                crate::Message {
364                    body: Some(reqwest::Body::from(serde_json::to_vec(body)?)),
365                    content_type: Some("application/json".to_string()),
366                },
367            )
368            .await
369    }
370    /**
371     * This function performs a `POST` to the `/calendars/{calendarId}/events/import` endpoint.
372     *
373     * Imports an event. This operation is used to add a private copy of an existing event to a calendar.
374     *
375     * **Parameters:**
376     *
377     * * `calendar_id: &str` -- Calendar identifier. To retrieve calendar IDs call the calendarList.list method. If you want to access the primary calendar of the currently logged in user, use the "primary" keyword.
378     * * `conference_data_version: u64` -- Version number of conference data supported by the API client. Version 0 assumes no conference data support and ignores conference data in the event's body. Version 1 enables support for copying of ConferenceData as well as for creating new conferences using the createRequest field of conferenceData. The default is 0.
379     * * `supports_attachments: bool` -- Whether this calendar list entry has been deleted from the calendar list. Read-only. Optional. The default is False.
380     */
381    pub async fn import(
382        &self,
383        calendar_id: &str,
384        conference_data_version: u64,
385        supports_attachments: bool,
386        body: &crate::types::Event,
387    ) -> ClientResult<crate::Response<crate::types::Event>> {
388        let mut query_args: Vec<(String, String)> = Default::default();
389        if !conference_data_version.to_string().is_empty() {
390            query_args.push((
391                "conferenceDataVersion".to_string(),
392                conference_data_version.to_string(),
393            ));
394        }
395        if supports_attachments {
396            query_args.push((
397                "supportsAttachments".to_string(),
398                supports_attachments.to_string(),
399            ));
400        }
401        let query_ = serde_urlencoded::to_string(&query_args).unwrap();
402        let url = self.client.url(
403            &format!(
404                "/calendars/{}/events/import?{}",
405                crate::progenitor_support::encode_path(calendar_id),
406                query_
407            ),
408            None,
409        );
410        self.client
411            .post(
412                &url,
413                crate::Message {
414                    body: Some(reqwest::Body::from(serde_json::to_vec(body)?)),
415                    content_type: Some("application/json".to_string()),
416                },
417            )
418            .await
419    }
420    /**
421     * This function performs a `POST` to the `/calendars/{calendarId}/events/quickAdd` endpoint.
422     *
423     * Creates an event based on a simple text string.
424     *
425     * **Parameters:**
426     *
427     * * `calendar_id: &str` -- Calendar identifier. To retrieve calendar IDs call the calendarList.list method. If you want to access the primary calendar of the currently logged in user, use the "primary" keyword.
428     * * `text: &str` -- The text describing the event to be created.
429     * * `send_notifications: bool` -- Deprecated. Please use sendUpdates instead.
430     *   
431     *   Whether to send notifications about the creation of the event. Note that some emails might still be sent even if you set the value to false. The default is false.
432     * * `send_updates: crate::types::SendUpdates` -- Whether to send notifications about the creation of the new event. Note that some emails might still be sent. The default is false.
433     */
434    pub async fn quick_add(
435        &self,
436        calendar_id: &str,
437        text: &str,
438        send_notifications: bool,
439        send_updates: crate::types::SendUpdates,
440    ) -> ClientResult<crate::Response<crate::types::Event>> {
441        let mut query_args: Vec<(String, String)> = Default::default();
442        if send_notifications {
443            query_args.push((
444                "sendNotifications".to_string(),
445                send_notifications.to_string(),
446            ));
447        }
448        if !send_updates.to_string().is_empty() {
449            query_args.push(("sendUpdates".to_string(), send_updates.to_string()));
450        }
451        if !text.is_empty() {
452            query_args.push(("text".to_string(), text.to_string()));
453        }
454        let query_ = serde_urlencoded::to_string(&query_args).unwrap();
455        let url = self.client.url(
456            &format!(
457                "/calendars/{}/events/quickAdd?{}",
458                crate::progenitor_support::encode_path(calendar_id),
459                query_
460            ),
461            None,
462        );
463        self.client
464            .post(
465                &url,
466                crate::Message {
467                    body: None,
468                    content_type: None,
469                },
470            )
471            .await
472    }
473    /**
474     * This function performs a `POST` to the `/calendars/{calendarId}/events/watch` endpoint.
475     *
476     * Watch for changes to Events resources.
477     *
478     * **Parameters:**
479     *
480     * * `calendar_id: &str` -- Calendar identifier. To retrieve calendar IDs call the calendarList.list method. If you want to access the primary calendar of the currently logged in user, use the "primary" keyword.
481     * * `always_include_email: bool` -- Deprecated and ignored. A value will always be returned in the email field for the organizer, creator and attendees, even if no real email address is available (i.e. a generated, non-working value will be provided).
482     * * `i_cal_uid: &str` -- Specifies event ID in the iCalendar format to be included in the response. Optional.
483     * * `max_attendees: i64` -- The maximum number of attendees to include in the response. If there are more than the specified number of attendees, only the participant is returned. Optional.
484     * * `max_results: i64` -- Maximum number of events returned on one result page. The number of events in the resulting page may be less than this value, or none at all, even if there are more events matching the query. Incomplete pages can be detected by a non-empty nextPageToken field in the response. By default the value is 250 events. The page size can never be larger than 2500 events. Optional.
485     * * `order_by: crate::types::OrderBy` -- The order of the events returned in the result. Optional. The default is an unspecified, stable order.
486     * * `page_token: &str` -- Token specifying which result page to return. Optional.
487     * * `private_extended_property: &[String]` -- Extended properties constraint specified as propertyName=value. Matches only private properties. This parameter might be repeated multiple times to return events that match all given constraints.
488     * * `q: &str` -- Free text search terms to find events that match these terms in any field, except for extended properties. Optional.
489     * * `shared_extended_property: &[String]` -- Extended properties constraint specified as propertyName=value. Matches only shared properties. This parameter might be repeated multiple times to return events that match all given constraints.
490     * * `show_deleted: bool` -- Whether to include deleted events (with status equals "cancelled") in the result. Cancelled instances of recurring events (but not the underlying recurring event) will still be included if showDeleted and singleEvents are both False. If showDeleted and singleEvents are both True, only single instances of deleted events (but not the underlying recurring events) are returned. Optional. The default is False.
491     * * `show_hidden_invitations: bool` -- Whether this calendar list entry has been deleted from the calendar list. Read-only. Optional. The default is False.
492     * * `single_events: bool` -- Whether to expand recurring events into instances and only return single one-off events and instances of recurring events, but not the underlying recurring events themselves. Optional. The default is False.
493     * * `sync_token: &str` -- Token obtained from the nextSyncToken field returned on the last page of results from the previous list request. It makes the result of this list request contain only entries that have changed since then. All events deleted since the previous list request will always be in the result set and it is not allowed to set showDeleted to False.
494     *   There are several query parameters that cannot be specified together with nextSyncToken to ensure consistency of the client state.
495     *   
496     *   These are:
497     *   - iCalUID
498     *   - orderBy
499     *   - privateExtendedProperty
500     *   - q
501     *   - sharedExtendedProperty
502     *   - timeMin
503     *   - timeMax
504     *   - updatedMin If the syncToken expires, the server will respond with a 410 GONE response code and the client should clear its storage and perform a full synchronization without any syncToken.
505     *   Learn more about incremental synchronization.
506     *   Optional. The default is to return all entries.
507     * * `time_max: &str` -- Upper bound (exclusive) for an event's start time to filter by. Optional. The default is not to filter by start time. Must be an RFC3339 timestamp with mandatory time zone offset, for example, 2011-06-03T10:00:00-07:00, 2011-06-03T10:00:00Z. Milliseconds may be provided but are ignored. If timeMin is set, timeMax must be greater than timeMin.
508     * * `time_min: &str` -- Lower bound (exclusive) for an event's end time to filter by. Optional. The default is not to filter by end time. Must be an RFC3339 timestamp with mandatory time zone offset, for example, 2011-06-03T10:00:00-07:00, 2011-06-03T10:00:00Z. Milliseconds may be provided but are ignored. If timeMax is set, timeMin must be smaller than timeMax.
509     * * `time_zone: &str` -- Time zone used in the response. Optional. The default is the time zone of the calendar.
510     * * `updated_min: &str` -- Lower bound for an event's last modification time (as a RFC3339 timestamp) to filter by. When specified, entries deleted since this time will always be included regardless of showDeleted. Optional. The default is not to filter by last modification time.
511     */
512    pub async fn watch(
513        &self,
514        calendar_id: &str,
515        i_cal_uid: &str,
516        max_attendees: i64,
517        max_results: i64,
518        order_by: crate::types::OrderBy,
519        page_token: &str,
520        private_extended_property: &[String],
521        q: &str,
522        shared_extended_property: &[String],
523        show_deleted: bool,
524        show_hidden_invitations: bool,
525        single_events: bool,
526        time_max: &str,
527        time_min: &str,
528        time_zone: &str,
529        updated_min: &str,
530        body: &crate::types::Channel,
531    ) -> ClientResult<crate::Response<crate::types::Channel>> {
532        let mut query_args: Vec<(String, String)> = Default::default();
533        if !i_cal_uid.is_empty() {
534            query_args.push(("iCalUID".to_string(), i_cal_uid.to_string()));
535        }
536        if max_attendees > 0 {
537            query_args.push(("maxAttendees".to_string(), max_attendees.to_string()));
538        }
539        if max_results > 0 {
540            query_args.push(("maxResults".to_string(), max_results.to_string()));
541        }
542        if !order_by.to_string().is_empty() {
543            query_args.push(("orderBy".to_string(), order_by.to_string()));
544        }
545        if !page_token.is_empty() {
546            query_args.push(("pageToken".to_string(), page_token.to_string()));
547        }
548        if !private_extended_property.is_empty() {
549            query_args.push((
550                "privateExtendedProperty".to_string(),
551                private_extended_property.join(" "),
552            ));
553        }
554        if !q.is_empty() {
555            query_args.push(("q".to_string(), q.to_string()));
556        }
557        if !shared_extended_property.is_empty() {
558            query_args.push((
559                "sharedExtendedProperty".to_string(),
560                shared_extended_property.join(" "),
561            ));
562        }
563        if show_deleted {
564            query_args.push(("showDeleted".to_string(), show_deleted.to_string()));
565        }
566        if show_hidden_invitations {
567            query_args.push((
568                "showHiddenInvitations".to_string(),
569                show_hidden_invitations.to_string(),
570            ));
571        }
572        if single_events {
573            query_args.push(("singleEvents".to_string(), single_events.to_string()));
574        }
575        if !time_max.is_empty() {
576            query_args.push(("timeMax".to_string(), time_max.to_string()));
577        }
578        if !time_min.is_empty() {
579            query_args.push(("timeMin".to_string(), time_min.to_string()));
580        }
581        if !time_zone.is_empty() {
582            query_args.push(("timeZone".to_string(), time_zone.to_string()));
583        }
584        if !updated_min.is_empty() {
585            query_args.push(("updatedMin".to_string(), updated_min.to_string()));
586        }
587        let query_ = serde_urlencoded::to_string(&query_args).unwrap();
588        let url = self.client.url(
589            &format!(
590                "/calendars/{}/events/watch?{}",
591                crate::progenitor_support::encode_path(calendar_id),
592                query_
593            ),
594            None,
595        );
596        self.client
597            .post(
598                &url,
599                crate::Message {
600                    body: Some(reqwest::Body::from(serde_json::to_vec(body)?)),
601                    content_type: Some("application/json".to_string()),
602                },
603            )
604            .await
605    }
606    /**
607     * This function performs a `GET` to the `/calendars/{calendarId}/events/{eventId}` endpoint.
608     *
609     * Returns an event.
610     *
611     * **Parameters:**
612     *
613     * * `calendar_id: &str` -- Calendar identifier. To retrieve calendar IDs call the calendarList.list method. If you want to access the primary calendar of the currently logged in user, use the "primary" keyword.
614     * * `event_id: &str` -- ETag of the collection.
615     * * `always_include_email: bool` -- Deprecated and ignored. A value will always be returned in the email field for the organizer, creator and attendees, even if no real email address is available (i.e. a generated, non-working value will be provided).
616     * * `max_attendees: i64` -- The maximum number of attendees to include in the response. If there are more than the specified number of attendees, only the participant is returned. Optional.
617     * * `time_zone: &str` -- Time zone used in the response. Optional. The default is the time zone of the calendar.
618     */
619    pub async fn get(
620        &self,
621        calendar_id: &str,
622        event_id: &str,
623        max_attendees: i64,
624        time_zone: &str,
625    ) -> ClientResult<crate::Response<crate::types::Event>> {
626        let mut query_args: Vec<(String, String)> = Default::default();
627        if max_attendees > 0 {
628            query_args.push(("maxAttendees".to_string(), max_attendees.to_string()));
629        }
630        if !time_zone.is_empty() {
631            query_args.push(("timeZone".to_string(), time_zone.to_string()));
632        }
633        let query_ = serde_urlencoded::to_string(&query_args).unwrap();
634        let url = self.client.url(
635            &format!(
636                "/calendars/{}/events/{}?{}",
637                crate::progenitor_support::encode_path(calendar_id),
638                crate::progenitor_support::encode_path(event_id),
639                query_
640            ),
641            None,
642        );
643        self.client
644            .get(
645                &url,
646                crate::Message {
647                    body: None,
648                    content_type: None,
649                },
650            )
651            .await
652    }
653    /**
654     * This function performs a `PUT` to the `/calendars/{calendarId}/events/{eventId}` endpoint.
655     *
656     * Updates an event.
657     *
658     * **Parameters:**
659     *
660     * * `calendar_id: &str` -- Calendar identifier. To retrieve calendar IDs call the calendarList.list method. If you want to access the primary calendar of the currently logged in user, use the "primary" keyword.
661     * * `event_id: &str` -- ETag of the collection.
662     * * `always_include_email: bool` -- Deprecated and ignored. A value will always be returned in the email field for the organizer, creator and attendees, even if no real email address is available (i.e. a generated, non-working value will be provided).
663     * * `conference_data_version: u64` -- Version number of conference data supported by the API client. Version 0 assumes no conference data support and ignores conference data in the event's body. Version 1 enables support for copying of ConferenceData as well as for creating new conferences using the createRequest field of conferenceData. The default is 0.
664     * * `max_attendees: i64` -- The maximum number of attendees to include in the response. If there are more than the specified number of attendees, only the participant is returned. Optional.
665     * * `send_notifications: bool` -- Deprecated. Please use sendUpdates instead.
666     *   
667     *   Whether to send notifications about the event update (for example, description changes, etc.). Note that some emails might still be sent even if you set the value to false. The default is false.
668     * * `send_updates: crate::types::SendUpdates` -- Whether to send notifications about the creation of the new event. Note that some emails might still be sent. The default is false.
669     * * `supports_attachments: bool` -- Whether this calendar list entry has been deleted from the calendar list. Read-only. Optional. The default is False.
670     */
671    pub async fn update(
672        &self,
673        calendar_id: &str,
674        event_id: &str,
675        conference_data_version: u64,
676        max_attendees: i64,
677        send_notifications: bool,
678        send_updates: crate::types::SendUpdates,
679        supports_attachments: bool,
680        body: &crate::types::Event,
681    ) -> ClientResult<crate::Response<crate::types::Event>> {
682        let mut query_args: Vec<(String, String)> = Default::default();
683        if !conference_data_version.to_string().is_empty() {
684            query_args.push((
685                "conferenceDataVersion".to_string(),
686                conference_data_version.to_string(),
687            ));
688        }
689        if max_attendees > 0 {
690            query_args.push(("maxAttendees".to_string(), max_attendees.to_string()));
691        }
692        if send_notifications {
693            query_args.push((
694                "sendNotifications".to_string(),
695                send_notifications.to_string(),
696            ));
697        }
698        if !send_updates.to_string().is_empty() {
699            query_args.push(("sendUpdates".to_string(), send_updates.to_string()));
700        }
701        if supports_attachments {
702            query_args.push((
703                "supportsAttachments".to_string(),
704                supports_attachments.to_string(),
705            ));
706        }
707        let query_ = serde_urlencoded::to_string(&query_args).unwrap();
708        let url = self.client.url(
709            &format!(
710                "/calendars/{}/events/{}?{}",
711                crate::progenitor_support::encode_path(calendar_id),
712                crate::progenitor_support::encode_path(event_id),
713                query_
714            ),
715            None,
716        );
717        self.client
718            .put(
719                &url,
720                crate::Message {
721                    body: Some(reqwest::Body::from(serde_json::to_vec(body)?)),
722                    content_type: Some("application/json".to_string()),
723                },
724            )
725            .await
726    }
727    /**
728     * This function performs a `DELETE` to the `/calendars/{calendarId}/events/{eventId}` endpoint.
729     *
730     * Deletes an event.
731     *
732     * **Parameters:**
733     *
734     * * `calendar_id: &str` -- Calendar identifier. To retrieve calendar IDs call the calendarList.list method. If you want to access the primary calendar of the currently logged in user, use the "primary" keyword.
735     * * `event_id: &str` -- ETag of the collection.
736     * * `send_notifications: bool` -- Deprecated. Please use sendUpdates instead.
737     *   
738     *   Whether to send notifications about the deletion of the event. Note that some emails might still be sent even if you set the value to false. The default is false.
739     * * `send_updates: crate::types::SendUpdates` -- Whether to send notifications about the creation of the new event. Note that some emails might still be sent. The default is false.
740     */
741    pub async fn delete(
742        &self,
743        calendar_id: &str,
744        event_id: &str,
745        send_notifications: bool,
746        send_updates: crate::types::SendUpdates,
747    ) -> ClientResult<crate::Response<()>> {
748        let mut query_args: Vec<(String, String)> = Default::default();
749        if send_notifications {
750            query_args.push((
751                "sendNotifications".to_string(),
752                send_notifications.to_string(),
753            ));
754        }
755        if !send_updates.to_string().is_empty() {
756            query_args.push(("sendUpdates".to_string(), send_updates.to_string()));
757        }
758        let query_ = serde_urlencoded::to_string(&query_args).unwrap();
759        let url = self.client.url(
760            &format!(
761                "/calendars/{}/events/{}?{}",
762                crate::progenitor_support::encode_path(calendar_id),
763                crate::progenitor_support::encode_path(event_id),
764                query_
765            ),
766            None,
767        );
768        self.client
769            .delete(
770                &url,
771                crate::Message {
772                    body: None,
773                    content_type: None,
774                },
775            )
776            .await
777    }
778    /**
779     * This function performs a `PATCH` to the `/calendars/{calendarId}/events/{eventId}` endpoint.
780     *
781     * Updates an event. This method supports patch semantics.
782     *
783     * **Parameters:**
784     *
785     * * `calendar_id: &str` -- Calendar identifier. To retrieve calendar IDs call the calendarList.list method. If you want to access the primary calendar of the currently logged in user, use the "primary" keyword.
786     * * `event_id: &str` -- ETag of the collection.
787     * * `always_include_email: bool` -- Deprecated and ignored. A value will always be returned in the email field for the organizer, creator and attendees, even if no real email address is available (i.e. a generated, non-working value will be provided).
788     * * `conference_data_version: u64` -- Version number of conference data supported by the API client. Version 0 assumes no conference data support and ignores conference data in the event's body. Version 1 enables support for copying of ConferenceData as well as for creating new conferences using the createRequest field of conferenceData. The default is 0.
789     * * `max_attendees: i64` -- The maximum number of attendees to include in the response. If there are more than the specified number of attendees, only the participant is returned. Optional.
790     * * `send_notifications: bool` -- Deprecated. Please use sendUpdates instead.
791     *   
792     *   Whether to send notifications about the event update (for example, description changes, etc.). Note that some emails might still be sent even if you set the value to false. The default is false.
793     * * `send_updates: crate::types::SendUpdates` -- Whether to send notifications about the creation of the new event. Note that some emails might still be sent. The default is false.
794     * * `supports_attachments: bool` -- Whether this calendar list entry has been deleted from the calendar list. Read-only. Optional. The default is False.
795     */
796    pub async fn patch(
797        &self,
798        calendar_id: &str,
799        event_id: &str,
800        conference_data_version: u64,
801        max_attendees: i64,
802        send_notifications: bool,
803        send_updates: crate::types::SendUpdates,
804        supports_attachments: bool,
805        body: &crate::types::Event,
806    ) -> ClientResult<crate::Response<crate::types::Event>> {
807        let mut query_args: Vec<(String, String)> = Default::default();
808        if !conference_data_version.to_string().is_empty() {
809            query_args.push((
810                "conferenceDataVersion".to_string(),
811                conference_data_version.to_string(),
812            ));
813        }
814        if max_attendees > 0 {
815            query_args.push(("maxAttendees".to_string(), max_attendees.to_string()));
816        }
817        if send_notifications {
818            query_args.push((
819                "sendNotifications".to_string(),
820                send_notifications.to_string(),
821            ));
822        }
823        if !send_updates.to_string().is_empty() {
824            query_args.push(("sendUpdates".to_string(), send_updates.to_string()));
825        }
826        if supports_attachments {
827            query_args.push((
828                "supportsAttachments".to_string(),
829                supports_attachments.to_string(),
830            ));
831        }
832        let query_ = serde_urlencoded::to_string(&query_args).unwrap();
833        let url = self.client.url(
834            &format!(
835                "/calendars/{}/events/{}?{}",
836                crate::progenitor_support::encode_path(calendar_id),
837                crate::progenitor_support::encode_path(event_id),
838                query_
839            ),
840            None,
841        );
842        self.client
843            .patch(
844                &url,
845                crate::Message {
846                    body: Some(reqwest::Body::from(serde_json::to_vec(body)?)),
847                    content_type: Some("application/json".to_string()),
848                },
849            )
850            .await
851    }
852    /**
853     * This function performs a `GET` to the `/calendars/{calendarId}/events/{eventId}/instances` endpoint.
854     *
855     * Returns instances of the specified recurring event.
856     *
857     * **Parameters:**
858     *
859     * * `calendar_id: &str` -- Calendar identifier. To retrieve calendar IDs call the calendarList.list method. If you want to access the primary calendar of the currently logged in user, use the "primary" keyword.
860     * * `event_id: &str` -- Recurring event identifier.
861     * * `always_include_email: bool` -- Deprecated and ignored. A value will always be returned in the email field for the organizer, creator and attendees, even if no real email address is available (i.e. a generated, non-working value will be provided).
862     * * `max_attendees: i64` -- The maximum number of attendees to include in the response. If there are more than the specified number of attendees, only the participant is returned. Optional.
863     * * `max_results: i64` -- Maximum number of events returned on one result page. By default the value is 250 events. The page size can never be larger than 2500 events. Optional.
864     * * `original_start: &str` -- The original start time of the instance in the result. Optional.
865     * * `page_token: &str` -- Token specifying which result page to return. Optional.
866     * * `show_deleted: bool` -- Whether to include deleted events (with status equals "cancelled") in the result. Cancelled instances of recurring events will still be included if singleEvents is False. Optional. The default is False.
867     * * `time_max: &str` -- Upper bound (exclusive) for an event's start time to filter by. Optional. The default is not to filter by start time. Must be an RFC3339 timestamp with mandatory time zone offset.
868     * * `time_min: &str` -- Lower bound (inclusive) for an event's end time to filter by. Optional. The default is not to filter by end time. Must be an RFC3339 timestamp with mandatory time zone offset.
869     * * `time_zone: &str` -- Time zone used in the response. Optional. The default is the time zone of the calendar.
870     */
871    pub async fn instances(
872        &self,
873        calendar_id: &str,
874        event_id: &str,
875        max_attendees: i64,
876        max_results: i64,
877        original_start: &str,
878        page_token: &str,
879        show_deleted: bool,
880        time_max: &str,
881        time_min: &str,
882        time_zone: &str,
883    ) -> ClientResult<crate::Response<Vec<crate::types::Event>>> {
884        let mut query_args: Vec<(String, String)> = Default::default();
885        if max_attendees > 0 {
886            query_args.push(("maxAttendees".to_string(), max_attendees.to_string()));
887        }
888        if max_results > 0 {
889            query_args.push(("maxResults".to_string(), max_results.to_string()));
890        }
891        if !original_start.is_empty() {
892            query_args.push(("originalStart".to_string(), original_start.to_string()));
893        }
894        if !page_token.is_empty() {
895            query_args.push(("pageToken".to_string(), page_token.to_string()));
896        }
897        if show_deleted {
898            query_args.push(("showDeleted".to_string(), show_deleted.to_string()));
899        }
900        if !time_max.is_empty() {
901            query_args.push(("timeMax".to_string(), time_max.to_string()));
902        }
903        if !time_min.is_empty() {
904            query_args.push(("timeMin".to_string(), time_min.to_string()));
905        }
906        if !time_zone.is_empty() {
907            query_args.push(("timeZone".to_string(), time_zone.to_string()));
908        }
909        let query_ = serde_urlencoded::to_string(&query_args).unwrap();
910        let url = self.client.url(
911            &format!(
912                "/calendars/{}/events/{}/instances?{}",
913                crate::progenitor_support::encode_path(calendar_id),
914                crate::progenitor_support::encode_path(event_id),
915                query_
916            ),
917            None,
918        );
919        let resp: crate::Response<crate::types::Events> = self
920            .client
921            .get(
922                &url,
923                crate::Message {
924                    body: None,
925                    content_type: None,
926                },
927            )
928            .await?;
929
930        // Return our response data.
931        Ok(crate::Response::new(
932            resp.status,
933            resp.headers,
934            resp.body.items.to_vec(),
935        ))
936    }
937    /**
938     * This function performs a `GET` to the `/calendars/{calendarId}/events/{eventId}/instances` endpoint.
939     *
940     * As opposed to `instances`, this function returns all the pages of the request at once.
941     *
942     * Returns instances of the specified recurring event.
943     */
944    pub async fn get_all_instances(
945        &self,
946        calendar_id: &str,
947        event_id: &str,
948        max_attendees: i64,
949        original_start: &str,
950        show_deleted: bool,
951        time_max: &str,
952        time_min: &str,
953        time_zone: &str,
954    ) -> ClientResult<crate::Response<Vec<crate::types::Event>>> {
955        let mut query_args: Vec<(String, String)> = Default::default();
956        if max_attendees > 0 {
957            query_args.push(("maxAttendees".to_string(), max_attendees.to_string()));
958        }
959        if !original_start.is_empty() {
960            query_args.push(("originalStart".to_string(), original_start.to_string()));
961        }
962        if show_deleted {
963            query_args.push(("showDeleted".to_string(), show_deleted.to_string()));
964        }
965        if !time_max.is_empty() {
966            query_args.push(("timeMax".to_string(), time_max.to_string()));
967        }
968        if !time_min.is_empty() {
969            query_args.push(("timeMin".to_string(), time_min.to_string()));
970        }
971        if !time_zone.is_empty() {
972            query_args.push(("timeZone".to_string(), time_zone.to_string()));
973        }
974        let query_ = serde_urlencoded::to_string(&query_args).unwrap();
975        let url = self.client.url(
976            &format!(
977                "/calendars/{}/events/{}/instances?{}",
978                crate::progenitor_support::encode_path(calendar_id),
979                crate::progenitor_support::encode_path(event_id),
980                query_
981            ),
982            None,
983        );
984        let crate::Response::<crate::types::Events> {
985            mut status,
986            mut headers,
987            mut body,
988        } = self
989            .client
990            .get(
991                &url,
992                crate::Message {
993                    body: None,
994                    content_type: None,
995                },
996            )
997            .await?;
998
999        let mut items = body.items;
1000        let mut page = body.next_page_token;
1001
1002        // Paginate if we should.
1003        while !page.is_empty() {
1004            if !url.contains('?') {
1005                crate::Response::<crate::types::Events> {
1006                    status,
1007                    headers,
1008                    body,
1009                } = self
1010                    .client
1011                    .get(
1012                        &format!("{}?pageToken={}", url, page),
1013                        crate::Message {
1014                            body: None,
1015                            content_type: None,
1016                        },
1017                    )
1018                    .await?;
1019            } else {
1020                crate::Response::<crate::types::Events> {
1021                    status,
1022                    headers,
1023                    body,
1024                } = self
1025                    .client
1026                    .get(
1027                        &format!("{}&pageToken={}", url, page),
1028                        crate::Message {
1029                            body: None,
1030                            content_type: None,
1031                        },
1032                    )
1033                    .await?;
1034            }
1035
1036            items.append(&mut body.items);
1037
1038            if !body.next_page_token.is_empty() && body.next_page_token != page {
1039                page = body.next_page_token.to_string();
1040            } else {
1041                page = "".to_string();
1042            }
1043        }
1044
1045        // Return our response data.
1046        Ok(crate::Response::new(status, headers, items))
1047    }
1048    /**
1049     * This function performs a `POST` to the `/calendars/{calendarId}/events/{eventId}/move` endpoint.
1050     *
1051     * Moves an event to another calendar, i.e. changes an event's organizer.
1052     *
1053     * **Parameters:**
1054     *
1055     * * `calendar_id: &str` -- Calendar identifier of the source calendar where the event currently is on.
1056     * * `event_id: &str` -- ETag of the collection.
1057     * * `destination: &str` -- Calendar identifier of the target calendar where the event is to be moved to.
1058     * * `send_notifications: bool` -- Deprecated. Please use sendUpdates instead.
1059     *   
1060     *   Whether to send notifications about the change of the event's organizer. Note that some emails might still be sent even if you set the value to false. The default is false.
1061     * * `send_updates: crate::types::SendUpdates` -- Whether to send notifications about the creation of the new event. Note that some emails might still be sent. The default is false.
1062     */
1063    pub async fn mv(
1064        &self,
1065        calendar_id: &str,
1066        event_id: &str,
1067        destination: &str,
1068        send_notifications: bool,
1069        send_updates: crate::types::SendUpdates,
1070    ) -> ClientResult<crate::Response<crate::types::Event>> {
1071        let mut query_args: Vec<(String, String)> = Default::default();
1072        if !destination.is_empty() {
1073            query_args.push(("destination".to_string(), destination.to_string()));
1074        }
1075        if send_notifications {
1076            query_args.push((
1077                "sendNotifications".to_string(),
1078                send_notifications.to_string(),
1079            ));
1080        }
1081        if !send_updates.to_string().is_empty() {
1082            query_args.push(("sendUpdates".to_string(), send_updates.to_string()));
1083        }
1084        let query_ = serde_urlencoded::to_string(&query_args).unwrap();
1085        let url = self.client.url(
1086            &format!(
1087                "/calendars/{}/events/{}/move?{}",
1088                crate::progenitor_support::encode_path(calendar_id),
1089                crate::progenitor_support::encode_path(event_id),
1090                query_
1091            ),
1092            None,
1093        );
1094        self.client
1095            .post(
1096                &url,
1097                crate::Message {
1098                    body: None,
1099                    content_type: None,
1100                },
1101            )
1102            .await
1103    }
1104}