google_calendar3/
api.rs

1#![allow(clippy::ptr_arg)]
2
3use std::collections::{BTreeSet, HashMap};
4
5use tokio::time::sleep;
6
7// ##############
8// UTILITIES ###
9// ############
10
11/// Identifies the an OAuth2 authorization scope.
12/// A scope is needed when requesting an
13/// [authorization token](https://developers.google.com/youtube/v3/guides/authentication).
14#[derive(PartialEq, Eq, Ord, PartialOrd, Hash, Debug, Clone, Copy)]
15pub enum Scope {
16    /// See, edit, share, and permanently delete all the calendars you can access using Google Calendar
17    Full,
18
19    /// View and edit events on all your calendars
20    Event,
21
22    /// View events on all your calendars
23    EventReadonly,
24
25    /// See and download any calendar you can access using your Google Calendar
26    Readonly,
27
28    /// View your Calendar settings
29    SettingReadonly,
30}
31
32impl AsRef<str> for Scope {
33    fn as_ref(&self) -> &str {
34        match *self {
35            Scope::Full => "https://www.googleapis.com/auth/calendar",
36            Scope::Event => "https://www.googleapis.com/auth/calendar.events",
37            Scope::EventReadonly => "https://www.googleapis.com/auth/calendar.events.readonly",
38            Scope::Readonly => "https://www.googleapis.com/auth/calendar.readonly",
39            Scope::SettingReadonly => "https://www.googleapis.com/auth/calendar.settings.readonly",
40        }
41    }
42}
43
44#[allow(clippy::derivable_impls)]
45impl Default for Scope {
46    fn default() -> Scope {
47        Scope::EventReadonly
48    }
49}
50
51// ########
52// HUB ###
53// ######
54
55/// Central instance to access all CalendarHub related resource activities
56///
57/// # Examples
58///
59/// Instantiate a new hub
60///
61/// ```test_harness,no_run
62/// extern crate hyper;
63/// extern crate hyper_rustls;
64/// extern crate google_calendar3 as calendar3;
65/// use calendar3::api::Channel;
66/// use calendar3::{Result, Error};
67/// # async fn dox() {
68/// use calendar3::{CalendarHub, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
69///
70/// // Get an ApplicationSecret instance by some means. It contains the `client_id` and
71/// // `client_secret`, among other things.
72/// let secret: yup_oauth2::ApplicationSecret = Default::default();
73/// // Instantiate the authenticator. It will choose a suitable authentication flow for you,
74/// // unless you replace  `None` with the desired Flow.
75/// // Provide your own `AuthenticatorDelegate` to adjust the way it operates and get feedback about
76/// // what's going on. You probably want to bring in your own `TokenStorage` to persist tokens and
77/// // retrieve them from storage.
78/// let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
79///     secret,
80///     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
81/// ).build().await.unwrap();
82///
83/// let client = hyper_util::client::legacy::Client::builder(
84///     hyper_util::rt::TokioExecutor::new()
85/// )
86/// .build(
87///     hyper_rustls::HttpsConnectorBuilder::new()
88///         .with_native_roots()
89///         .unwrap()
90///         .https_or_http()
91///         .enable_http1()
92///         .build()
93/// );
94/// let mut hub = CalendarHub::new(client, auth);
95/// // As the method needs a request, you would usually fill it with the desired information
96/// // into the respective structure. Some of the parts shown here might not be applicable !
97/// // Values shown here are possibly random and not representative !
98/// let mut req = Channel::default();
99///
100/// // You can configure optional parameters by calling the respective setters at will, and
101/// // execute the final call using `doit()`.
102/// // Values shown here are possibly random and not representative !
103/// let result = hub.events().watch(req, "calendarId")
104///              .updated_min(chrono::Utc::now())
105///              .time_zone("sed")
106///              .time_min(chrono::Utc::now())
107///              .time_max(chrono::Utc::now())
108///              .sync_token("no")
109///              .single_events(true)
110///              .show_hidden_invitations(true)
111///              .show_deleted(false)
112///              .add_shared_extended_property("erat")
113///              .q("sed")
114///              .add_private_extended_property("duo")
115///              .page_token("dolore")
116///              .order_by("et")
117///              .max_results(-28)
118///              .max_attendees(-2)
119///              .i_cal_uid("consetetur")
120///              .add_event_types("diam")
121///              .always_include_email(true)
122///              .doit().await;
123///
124/// match result {
125///     Err(e) => match e {
126///         // The Error enum provides details about what exactly happened.
127///         // You can also just use its `Debug`, `Display` or `Error` traits
128///          Error::HttpError(_)
129///         |Error::Io(_)
130///         |Error::MissingAPIKey
131///         |Error::MissingToken(_)
132///         |Error::Cancelled
133///         |Error::UploadSizeLimitExceeded(_, _)
134///         |Error::Failure(_)
135///         |Error::BadRequest(_)
136///         |Error::FieldClash(_)
137///         |Error::JsonDecodeError(_, _) => println!("{}", e),
138///     },
139///     Ok(res) => println!("Success: {:?}", res),
140/// }
141/// # }
142/// ```
143#[derive(Clone)]
144pub struct CalendarHub<C> {
145    pub client: common::Client<C>,
146    pub auth: Box<dyn common::GetToken>,
147    _user_agent: String,
148    _base_url: String,
149    _root_url: String,
150}
151
152impl<C> common::Hub for CalendarHub<C> {}
153
154impl<'a, C> CalendarHub<C> {
155    pub fn new<A: 'static + common::GetToken>(
156        client: common::Client<C>,
157        auth: A,
158    ) -> CalendarHub<C> {
159        CalendarHub {
160            client,
161            auth: Box::new(auth),
162            _user_agent: "google-api-rust-client/6.0.0".to_string(),
163            _base_url: "https://www.googleapis.com/calendar/v3/".to_string(),
164            _root_url: "https://www.googleapis.com/".to_string(),
165        }
166    }
167
168    pub fn acl(&'a self) -> AclMethods<'a, C> {
169        AclMethods { hub: self }
170    }
171    pub fn calendar_list(&'a self) -> CalendarListMethods<'a, C> {
172        CalendarListMethods { hub: self }
173    }
174    pub fn calendars(&'a self) -> CalendarMethods<'a, C> {
175        CalendarMethods { hub: self }
176    }
177    pub fn channels(&'a self) -> ChannelMethods<'a, C> {
178        ChannelMethods { hub: self }
179    }
180    pub fn colors(&'a self) -> ColorMethods<'a, C> {
181        ColorMethods { hub: self }
182    }
183    pub fn events(&'a self) -> EventMethods<'a, C> {
184        EventMethods { hub: self }
185    }
186    pub fn freebusy(&'a self) -> FreebusyMethods<'a, C> {
187        FreebusyMethods { hub: self }
188    }
189    pub fn settings(&'a self) -> SettingMethods<'a, C> {
190        SettingMethods { hub: self }
191    }
192
193    /// Set the user-agent header field to use in all requests to the server.
194    /// It defaults to `google-api-rust-client/6.0.0`.
195    ///
196    /// Returns the previously set user-agent.
197    pub fn user_agent(&mut self, agent_name: String) -> String {
198        std::mem::replace(&mut self._user_agent, agent_name)
199    }
200
201    /// Set the base url to use in all requests to the server.
202    /// It defaults to `https://www.googleapis.com/calendar/v3/`.
203    ///
204    /// Returns the previously set base url.
205    pub fn base_url(&mut self, new_base_url: String) -> String {
206        std::mem::replace(&mut self._base_url, new_base_url)
207    }
208
209    /// Set the root url to use in all requests to the server.
210    /// It defaults to `https://www.googleapis.com/`.
211    ///
212    /// Returns the previously set root url.
213    pub fn root_url(&mut self, new_root_url: String) -> String {
214        std::mem::replace(&mut self._root_url, new_root_url)
215    }
216}
217
218// ############
219// SCHEMAS ###
220// ##########
221/// There is no detailed description.
222///
223/// # Activities
224///
225/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
226/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
227///
228/// * [list acl](AclListCall) (response)
229#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
230#[serde_with::serde_as]
231#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
232pub struct Acl {
233    /// ETag of the collection.
234    pub etag: Option<String>,
235    /// List of rules on the access control list.
236    pub items: Option<Vec<AclRule>>,
237    /// Type of the collection ("calendar#acl").
238    pub kind: Option<String>,
239    /// Token used to access the next page of this result. Omitted if no further results are available, in which case nextSyncToken is provided.
240    #[serde(rename = "nextPageToken")]
241    pub next_page_token: Option<String>,
242    /// Token used at a later point in time to retrieve only the entries that have changed since this result was returned. Omitted if further results are available, in which case nextPageToken is provided.
243    #[serde(rename = "nextSyncToken")]
244    pub next_sync_token: Option<String>,
245}
246
247impl common::ResponseResult for Acl {}
248
249/// There is no detailed description.
250///
251/// # Activities
252///
253/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
254/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
255///
256/// * [get acl](AclGetCall) (response)
257/// * [insert acl](AclInsertCall) (request|response)
258/// * [patch acl](AclPatchCall) (request|response)
259/// * [update acl](AclUpdateCall) (request|response)
260#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
261#[serde_with::serde_as]
262#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
263pub struct AclRule {
264    /// ETag of the resource.
265    pub etag: Option<String>,
266    /// Identifier of the Access Control List (ACL) rule. See Sharing calendars.
267    pub id: Option<String>,
268    /// Type of the resource ("calendar#aclRule").
269    pub kind: Option<String>,
270    /// The role assigned to the scope. Possible values are:  
271    /// - "none" - Provides no access.
272    /// - "freeBusyReader" - Provides read access to free/busy information.
273    /// - "reader" - Provides read access to the calendar. Private events will appear to users with reader access, but event details will be hidden.
274    /// - "writer" - Provides read and write access to the calendar. Private events will appear to users with writer access, and event details will be visible.
275    /// - "owner" - Provides ownership of the calendar. This role has all of the permissions of the writer role with the additional ability to see and manipulate ACLs.
276    pub role: Option<String>,
277    /// The extent to which calendar access is granted by this ACL rule.
278    pub scope: Option<AclRuleScope>,
279}
280
281impl common::RequestValue for AclRule {}
282impl common::ResponseResult for AclRule {}
283
284/// There is no detailed description.
285///
286/// # Activities
287///
288/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
289/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
290///
291/// * [clear calendars](CalendarClearCall) (none)
292/// * [delete calendars](CalendarDeleteCall) (none)
293/// * [get calendars](CalendarGetCall) (response)
294/// * [insert calendars](CalendarInsertCall) (request|response)
295/// * [patch calendars](CalendarPatchCall) (request|response)
296/// * [update calendars](CalendarUpdateCall) (request|response)
297#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
298#[serde_with::serde_as]
299#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
300pub struct Calendar {
301    /// Conferencing properties for this calendar, for example what types of conferences are allowed.
302    #[serde(rename = "conferenceProperties")]
303    pub conference_properties: Option<ConferenceProperties>,
304    /// Description of the calendar. Optional.
305    pub description: Option<String>,
306    /// ETag of the resource.
307    pub etag: Option<String>,
308    /// Identifier of the calendar. To retrieve IDs call the calendarList.list() method.
309    pub id: Option<String>,
310    /// Type of the resource ("calendar#calendar").
311    pub kind: Option<String>,
312    /// Geographic location of the calendar as free-form text. Optional.
313    pub location: Option<String>,
314    /// Title of the calendar.
315    pub summary: Option<String>,
316    /// The time zone of the calendar. (Formatted as an IANA Time Zone Database name, e.g. "Europe/Zurich".) Optional.
317    #[serde(rename = "timeZone")]
318    pub time_zone: Option<String>,
319}
320
321impl common::RequestValue for Calendar {}
322impl common::Resource for Calendar {}
323impl common::ResponseResult for Calendar {}
324
325/// There is no detailed description.
326///
327/// # Activities
328///
329/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
330/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
331///
332/// * [list calendar list](CalendarListListCall) (response)
333#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
334#[serde_with::serde_as]
335#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
336pub struct CalendarList {
337    /// ETag of the collection.
338    pub etag: Option<String>,
339    /// Calendars that are present on the user's calendar list.
340    pub items: Option<Vec<CalendarListEntry>>,
341    /// Type of the collection ("calendar#calendarList").
342    pub kind: Option<String>,
343    /// Token used to access the next page of this result. Omitted if no further results are available, in which case nextSyncToken is provided.
344    #[serde(rename = "nextPageToken")]
345    pub next_page_token: Option<String>,
346    /// Token used at a later point in time to retrieve only the entries that have changed since this result was returned. Omitted if further results are available, in which case nextPageToken is provided.
347    #[serde(rename = "nextSyncToken")]
348    pub next_sync_token: Option<String>,
349}
350
351impl common::ResponseResult for CalendarList {}
352
353/// There is no detailed description.
354///
355/// # Activities
356///
357/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
358/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
359///
360/// * [get calendar list](CalendarListGetCall) (response)
361/// * [insert calendar list](CalendarListInsertCall) (request|response)
362/// * [patch calendar list](CalendarListPatchCall) (request|response)
363/// * [update calendar list](CalendarListUpdateCall) (request|response)
364#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
365#[serde_with::serde_as]
366#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
367pub struct CalendarListEntry {
368    /// The effective access role that the authenticated user has on the calendar. Read-only. Possible values are:  
369    /// - "freeBusyReader" - Provides read access to free/busy information.
370    /// - "reader" - Provides read access to the calendar. Private events will appear to users with reader access, but event details will be hidden.
371    /// - "writer" - Provides read and write access to the calendar. Private events will appear to users with writer access, and event details will be visible.
372    /// - "owner" - Provides ownership of the calendar. This role has all of the permissions of the writer role with the additional ability to see and manipulate ACLs.
373    #[serde(rename = "accessRole")]
374    pub access_role: Option<String>,
375    /// The main color of the calendar in the hexadecimal format "#0088aa". This property supersedes the index-based colorId property. To set or change this property, you need to specify colorRgbFormat=true in the parameters of the insert, update and patch methods. Optional.
376    #[serde(rename = "backgroundColor")]
377    pub background_color: Option<String>,
378    /// The color of the calendar. This is an ID referring to an entry in the calendar section of the colors definition (see the colors endpoint). This property is superseded by the backgroundColor and foregroundColor properties and can be ignored when using these properties. Optional.
379    #[serde(rename = "colorId")]
380    pub color_id: Option<String>,
381    /// Conferencing properties for this calendar, for example what types of conferences are allowed.
382    #[serde(rename = "conferenceProperties")]
383    pub conference_properties: Option<ConferenceProperties>,
384    /// The default reminders that the authenticated user has for this calendar.
385    #[serde(rename = "defaultReminders")]
386    pub default_reminders: Option<Vec<EventReminder>>,
387    /// Whether this calendar list entry has been deleted from the calendar list. Read-only. Optional. The default is False.
388    pub deleted: Option<bool>,
389    /// Description of the calendar. Optional. Read-only.
390    pub description: Option<String>,
391    /// ETag of the resource.
392    pub etag: Option<String>,
393    /// The foreground color of the calendar in the hexadecimal format "#ffffff". This property supersedes the index-based colorId property. To set or change this property, you need to specify colorRgbFormat=true in the parameters of the insert, update and patch methods. Optional.
394    #[serde(rename = "foregroundColor")]
395    pub foreground_color: Option<String>,
396    /// Whether the calendar has been hidden from the list. Optional. The attribute is only returned when the calendar is hidden, in which case the value is true.
397    pub hidden: Option<bool>,
398    /// Identifier of the calendar.
399    pub id: Option<String>,
400    /// Type of the resource ("calendar#calendarListEntry").
401    pub kind: Option<String>,
402    /// Geographic location of the calendar as free-form text. Optional. Read-only.
403    pub location: Option<String>,
404    /// The notifications that the authenticated user is receiving for this calendar.
405    #[serde(rename = "notificationSettings")]
406    pub notification_settings: Option<CalendarListEntryNotificationSettings>,
407    /// Whether the calendar is the primary calendar of the authenticated user. Read-only. Optional. The default is False.
408    pub primary: Option<bool>,
409    /// Whether the calendar content shows up in the calendar UI. Optional. The default is False.
410    pub selected: Option<bool>,
411    /// Title of the calendar. Read-only.
412    pub summary: Option<String>,
413    /// The summary that the authenticated user has set for this calendar. Optional.
414    #[serde(rename = "summaryOverride")]
415    pub summary_override: Option<String>,
416    /// The time zone of the calendar. Optional. Read-only.
417    #[serde(rename = "timeZone")]
418    pub time_zone: Option<String>,
419}
420
421impl common::RequestValue for CalendarListEntry {}
422impl common::ResponseResult for CalendarListEntry {}
423
424/// There is no detailed description.
425///
426/// This type is not used in any activity, and only used as *part* of another schema.
427///
428#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
429#[serde_with::serde_as]
430#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
431pub struct CalendarNotification {
432    /// The method used to deliver the notification. The possible value is:  
433    /// - "email" - Notifications are sent via email.  
434    /// Required when adding a notification.
435    pub method: Option<String>,
436    /// The type of notification. Possible values are:  
437    /// - "eventCreation" - Notification sent when a new event is put on the calendar.
438    /// - "eventChange" - Notification sent when an event is changed.
439    /// - "eventCancellation" - Notification sent when an event is cancelled.
440    /// - "eventResponse" - Notification sent when an attendee responds to the event invitation.
441    /// - "agenda" - An agenda with the events of the day (sent out in the morning).  
442    /// Required when adding a notification.
443    #[serde(rename = "type")]
444    pub type_: Option<String>,
445}
446
447impl common::Part for CalendarNotification {}
448
449/// There is no detailed description.
450///
451/// # Activities
452///
453/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
454/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
455///
456/// * [watch acl](AclWatchCall) (request|response)
457/// * [watch calendar list](CalendarListWatchCall) (request|response)
458/// * [stop channels](ChannelStopCall) (request)
459/// * [watch events](EventWatchCall) (request|response)
460/// * [watch settings](SettingWatchCall) (request|response)
461#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
462#[serde_with::serde_as]
463#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
464pub struct Channel {
465    /// The address where notifications are delivered for this channel.
466    pub address: Option<String>,
467    /// Date and time of notification channel expiration, expressed as a Unix timestamp, in milliseconds. Optional.
468    #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
469    pub expiration: Option<i64>,
470    /// A UUID or similar unique string that identifies this channel.
471    pub id: Option<String>,
472    /// Identifies this as a notification channel used to watch for changes to a resource, which is "api#channel".
473    pub kind: Option<String>,
474    /// Additional parameters controlling delivery channel behavior. Optional.
475    pub params: Option<HashMap<String, String>>,
476    /// A Boolean value to indicate whether payload is wanted. Optional.
477    pub payload: Option<bool>,
478    /// An opaque ID that identifies the resource being watched on this channel. Stable across different API versions.
479    #[serde(rename = "resourceId")]
480    pub resource_id: Option<String>,
481    /// A version-specific identifier for the watched resource.
482    #[serde(rename = "resourceUri")]
483    pub resource_uri: Option<String>,
484    /// An arbitrary string delivered to the target address with each notification delivered over this channel. Optional.
485    pub token: Option<String>,
486    /// The type of delivery mechanism used for this channel. Valid values are "web_hook" (or "webhook"). Both values refer to a channel where Http requests are used to deliver messages.
487    #[serde(rename = "type")]
488    pub type_: Option<String>,
489}
490
491impl common::RequestValue for Channel {}
492impl common::Resource for Channel {}
493impl common::ResponseResult for Channel {}
494
495/// There is no detailed description.
496///
497/// This type is not used in any activity, and only used as *part* of another schema.
498///
499#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
500#[serde_with::serde_as]
501#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
502pub struct ColorDefinition {
503    /// The background color associated with this color definition.
504    pub background: Option<String>,
505    /// The foreground color that can be used to write on top of a background with 'background' color.
506    pub foreground: Option<String>,
507}
508
509impl common::Part for ColorDefinition {}
510
511/// There is no detailed description.
512///
513/// # Activities
514///
515/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
516/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
517///
518/// * [get colors](ColorGetCall) (response)
519#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
520#[serde_with::serde_as]
521#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
522pub struct Colors {
523    /// A global palette of calendar colors, mapping from the color ID to its definition. A calendarListEntry resource refers to one of these color IDs in its colorId field. Read-only.
524    pub calendar: Option<HashMap<String, ColorDefinition>>,
525    /// A global palette of event colors, mapping from the color ID to its definition. An event resource may refer to one of these color IDs in its colorId field. Read-only.
526    pub event: Option<HashMap<String, ColorDefinition>>,
527    /// Type of the resource ("calendar#colors").
528    pub kind: Option<String>,
529    /// Last modification time of the color palette (as a RFC3339 timestamp). Read-only.
530    pub updated: Option<chrono::DateTime<chrono::offset::Utc>>,
531}
532
533impl common::ResponseResult for Colors {}
534
535/// There is no detailed description.
536///
537/// This type is not used in any activity, and only used as *part* of another schema.
538///
539#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
540#[serde_with::serde_as]
541#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
542pub struct ConferenceData {
543    /// The ID of the conference.
544    /// Can be used by developers to keep track of conferences, should not be displayed to users.
545    /// The ID value is formed differently for each conference solution type:  
546    /// - eventHangout: ID is not set. (This conference type is deprecated.)
547    /// - eventNamedHangout: ID is the name of the Hangout. (This conference type is deprecated.)
548    /// - hangoutsMeet: ID is the 10-letter meeting code, for example aaa-bbbb-ccc.
549    /// - addOn: ID is defined by the third-party provider.  Optional.
550    #[serde(rename = "conferenceId")]
551    pub conference_id: Option<String>,
552    /// The conference solution, such as Google Meet.
553    /// Unset for a conference with a failed create request.
554    /// Either conferenceSolution and at least one entryPoint, or createRequest is required.
555    #[serde(rename = "conferenceSolution")]
556    pub conference_solution: Option<ConferenceSolution>,
557    /// A request to generate a new conference and attach it to the event. The data is generated asynchronously. To see whether the data is present check the status field.
558    /// Either conferenceSolution and at least one entryPoint, or createRequest is required.
559    #[serde(rename = "createRequest")]
560    pub create_request: Option<CreateConferenceRequest>,
561    /// Information about individual conference entry points, such as URLs or phone numbers.
562    /// All of them must belong to the same conference.
563    /// Either conferenceSolution and at least one entryPoint, or createRequest is required.
564    #[serde(rename = "entryPoints")]
565    pub entry_points: Option<Vec<EntryPoint>>,
566    /// Additional notes (such as instructions from the domain administrator, legal notices) to display to the user. Can contain HTML. The maximum length is 2048 characters. Optional.
567    pub notes: Option<String>,
568    /// Additional properties related to a conference. An example would be a solution-specific setting for enabling video streaming.
569    pub parameters: Option<ConferenceParameters>,
570    /// The signature of the conference data.
571    /// Generated on server side.
572    /// Unset for a conference with a failed create request.
573    /// Optional for a conference with a pending create request.
574    pub signature: Option<String>,
575}
576
577impl common::Part for ConferenceData {}
578
579/// There is no detailed description.
580///
581/// This type is not used in any activity, and only used as *part* of another schema.
582///
583#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
584#[serde_with::serde_as]
585#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
586pub struct ConferenceParameters {
587    /// Additional add-on specific data.
588    #[serde(rename = "addOnParameters")]
589    pub add_on_parameters: Option<ConferenceParametersAddOnParameters>,
590}
591
592impl common::Part for ConferenceParameters {}
593
594/// There is no detailed description.
595///
596/// This type is not used in any activity, and only used as *part* of another schema.
597///
598#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
599#[serde_with::serde_as]
600#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
601pub struct ConferenceParametersAddOnParameters {
602    /// no description provided
603    pub parameters: Option<HashMap<String, String>>,
604}
605
606impl common::Part for ConferenceParametersAddOnParameters {}
607
608/// There is no detailed description.
609///
610/// This type is not used in any activity, and only used as *part* of another schema.
611///
612#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
613#[serde_with::serde_as]
614#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
615pub struct ConferenceProperties {
616    /// The types of conference solutions that are supported for this calendar.
617    /// The possible values are:  
618    /// - "eventHangout"
619    /// - "eventNamedHangout"
620    /// - "hangoutsMeet"  Optional.
621    #[serde(rename = "allowedConferenceSolutionTypes")]
622    pub allowed_conference_solution_types: Option<Vec<String>>,
623}
624
625impl common::Part for ConferenceProperties {}
626
627/// There is no detailed description.
628///
629/// This type is not used in any activity, and only used as *part* of another schema.
630///
631#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
632#[serde_with::serde_as]
633#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
634pub struct ConferenceRequestStatus {
635    /// The current status of the conference create request. Read-only.
636    /// The possible values are:  
637    /// - "pending": the conference create request is still being processed.
638    /// - "success": the conference create request succeeded, the entry points are populated.
639    /// - "failure": the conference create request failed, there are no entry points.
640    #[serde(rename = "statusCode")]
641    pub status_code: Option<String>,
642}
643
644impl common::Part for ConferenceRequestStatus {}
645
646/// There is no detailed description.
647///
648/// This type is not used in any activity, and only used as *part* of another schema.
649///
650#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
651#[serde_with::serde_as]
652#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
653pub struct ConferenceSolution {
654    /// The user-visible icon for this solution.
655    #[serde(rename = "iconUri")]
656    pub icon_uri: Option<String>,
657    /// The key which can uniquely identify the conference solution for this event.
658    pub key: Option<ConferenceSolutionKey>,
659    /// The user-visible name of this solution. Not localized.
660    pub name: Option<String>,
661}
662
663impl common::Part for ConferenceSolution {}
664
665/// There is no detailed description.
666///
667/// This type is not used in any activity, and only used as *part* of another schema.
668///
669#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
670#[serde_with::serde_as]
671#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
672pub struct ConferenceSolutionKey {
673    /// The conference solution type.
674    /// If a client encounters an unfamiliar or empty type, it should still be able to display the entry points. However, it should disallow modifications.
675    /// The possible values are:  
676    /// - "eventHangout" for Hangouts for consumers (deprecated; existing events may show this conference solution type but new conferences cannot be created)
677    /// - "eventNamedHangout" for classic Hangouts for Google Workspace users (deprecated; existing events may show this conference solution type but new conferences cannot be created)
678    /// - "hangoutsMeet" for Google Meet (http://meet.google.com)
679    /// - "addOn" for 3P conference providers
680    #[serde(rename = "type")]
681    pub type_: Option<String>,
682}
683
684impl common::Part for ConferenceSolutionKey {}
685
686/// There is no detailed description.
687///
688/// This type is not used in any activity, and only used as *part* of another schema.
689///
690#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
691#[serde_with::serde_as]
692#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
693pub struct CreateConferenceRequest {
694    /// The conference solution, such as Hangouts or Google Meet.
695    #[serde(rename = "conferenceSolutionKey")]
696    pub conference_solution_key: Option<ConferenceSolutionKey>,
697    /// The client-generated unique ID for this request.
698    /// Clients should regenerate this ID for every new request. If an ID provided is the same as for the previous request, the request is ignored.
699    #[serde(rename = "requestId")]
700    pub request_id: Option<String>,
701    /// The status of the conference create request.
702    pub status: Option<ConferenceRequestStatus>,
703}
704
705impl common::Part for CreateConferenceRequest {}
706
707/// There is no detailed description.
708///
709/// This type is not used in any activity, and only used as *part* of another schema.
710///
711#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
712#[serde_with::serde_as]
713#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
714pub struct EntryPoint {
715    /// The access code to access the conference. The maximum length is 128 characters.
716    /// When creating new conference data, populate only the subset of {meetingCode, accessCode, passcode, password, pin} fields that match the terminology that the conference provider uses. Only the populated fields should be displayed.
717    /// Optional.
718    #[serde(rename = "accessCode")]
719    pub access_code: Option<String>,
720    /// Features of the entry point, such as being toll or toll-free. One entry point can have multiple features. However, toll and toll-free cannot be both set on the same entry point.
721    #[serde(rename = "entryPointFeatures")]
722    pub entry_point_features: Option<Vec<String>>,
723    /// The type of the conference entry point.
724    /// Possible values are:  
725    /// - "video" - joining a conference over HTTP. A conference can have zero or one video entry point.
726    /// - "phone" - joining a conference by dialing a phone number. A conference can have zero or more phone entry points.
727    /// - "sip" - joining a conference over SIP. A conference can have zero or one sip entry point.
728    /// - "more" - further conference joining instructions, for example additional phone numbers. A conference can have zero or one more entry point. A conference with only a more entry point is not a valid conference.
729    #[serde(rename = "entryPointType")]
730    pub entry_point_type: Option<String>,
731    /// The label for the URI. Visible to end users. Not localized. The maximum length is 512 characters.
732    /// Examples:  
733    /// - for video: meet.google.com/aaa-bbbb-ccc
734    /// - for phone: +1 123 268 2601
735    /// - for sip: 12345678@altostrat.com
736    /// - for more: should not be filled  
737    /// Optional.
738    pub label: Option<String>,
739    /// The meeting code to access the conference. The maximum length is 128 characters.
740    /// When creating new conference data, populate only the subset of {meetingCode, accessCode, passcode, password, pin} fields that match the terminology that the conference provider uses. Only the populated fields should be displayed.
741    /// Optional.
742    #[serde(rename = "meetingCode")]
743    pub meeting_code: Option<String>,
744    /// The passcode to access the conference. The maximum length is 128 characters.
745    /// When creating new conference data, populate only the subset of {meetingCode, accessCode, passcode, password, pin} fields that match the terminology that the conference provider uses. Only the populated fields should be displayed.
746    pub passcode: Option<String>,
747    /// The password to access the conference. The maximum length is 128 characters.
748    /// When creating new conference data, populate only the subset of {meetingCode, accessCode, passcode, password, pin} fields that match the terminology that the conference provider uses. Only the populated fields should be displayed.
749    /// Optional.
750    pub password: Option<String>,
751    /// The PIN to access the conference. The maximum length is 128 characters.
752    /// When creating new conference data, populate only the subset of {meetingCode, accessCode, passcode, password, pin} fields that match the terminology that the conference provider uses. Only the populated fields should be displayed.
753    /// Optional.
754    pub pin: Option<String>,
755    /// The CLDR/ISO 3166 region code for the country associated with this phone access. Example: "SE" for Sweden.
756    /// Calendar backend will populate this field only for EntryPointType.PHONE.
757    #[serde(rename = "regionCode")]
758    pub region_code: Option<String>,
759    /// The URI of the entry point. The maximum length is 1300 characters.
760    /// Format:  
761    /// - for video, http: or https: schema is required.
762    /// - for phone, tel: schema is required. The URI should include the entire dial sequence (e.g., tel:+12345678900,,,123456789;1234).
763    /// - for sip, sip: schema is required, e.g., sip:12345678@myprovider.com.
764    /// - for more, http: or https: schema is required.
765    pub uri: Option<String>,
766}
767
768impl common::Part for EntryPoint {}
769
770/// There is no detailed description.
771///
772/// This type is not used in any activity, and only used as *part* of another schema.
773///
774#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
775#[serde_with::serde_as]
776#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
777pub struct Error {
778    /// Domain, or broad category, of the error.
779    pub domain: Option<String>,
780    /// Specific reason for the error. Some of the possible values are:  
781    /// - "groupTooBig" - The group of users requested is too large for a single query.
782    /// - "tooManyCalendarsRequested" - The number of calendars requested is too large for a single query.
783    /// - "notFound" - The requested resource was not found.
784    /// - "internalError" - The API service has encountered an internal error.  Additional error types may be added in the future, so clients should gracefully handle additional error statuses not included in this list.
785    pub reason: Option<String>,
786}
787
788impl common::Part for Error {}
789
790/// There is no detailed description.
791///
792/// # Activities
793///
794/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
795/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
796///
797/// * [delete events](EventDeleteCall) (none)
798/// * [get events](EventGetCall) (response)
799/// * [import events](EventImportCall) (request|response)
800/// * [insert events](EventInsertCall) (request|response)
801/// * [instances events](EventInstanceCall) (none)
802/// * [list events](EventListCall) (none)
803/// * [move events](EventMoveCall) (response)
804/// * [patch events](EventPatchCall) (request|response)
805/// * [quick add events](EventQuickAddCall) (response)
806/// * [update events](EventUpdateCall) (request|response)
807/// * [watch events](EventWatchCall) (none)
808#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
809#[serde_with::serde_as]
810#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
811pub struct Event {
812    /// Whether anyone can invite themselves to the event (deprecated). Optional. The default is False.
813    #[serde(rename = "anyoneCanAddSelf")]
814    pub anyone_can_add_self: Option<bool>,
815    /// File attachments for the event.
816    /// In order to modify attachments the supportsAttachments request parameter should be set to true.
817    /// There can be at most 25 attachments per event,
818    pub attachments: Option<Vec<EventAttachment>>,
819    /// The attendees of the event. See the Events with attendees guide for more information on scheduling events with other calendar users. Service accounts need to use domain-wide delegation of authority to populate the attendee list.
820    pub attendees: Option<Vec<EventAttendee>>,
821    /// Whether attendees may have been omitted from the event's representation. When retrieving an event, this may be due to a restriction specified by the maxAttendee query parameter. When updating an event, this can be used to only update the participant's response. Optional. The default is False.
822    #[serde(rename = "attendeesOmitted")]
823    pub attendees_omitted: Option<bool>,
824    /// The color of the event. This is an ID referring to an entry in the event section of the colors definition (see the  colors endpoint). Optional.
825    #[serde(rename = "colorId")]
826    pub color_id: Option<String>,
827    /// The conference-related information, such as details of a Google Meet conference. To create new conference details use the createRequest field. To persist your changes, remember to set the conferenceDataVersion request parameter to 1 for all event modification requests.
828    #[serde(rename = "conferenceData")]
829    pub conference_data: Option<ConferenceData>,
830    /// Creation time of the event (as a RFC3339 timestamp). Read-only.
831    pub created: Option<chrono::DateTime<chrono::offset::Utc>>,
832    /// The creator of the event. Read-only.
833    pub creator: Option<EventCreator>,
834    /// Description of the event. Can contain HTML. Optional.
835    pub description: Option<String>,
836    /// The (exclusive) end time of the event. For a recurring event, this is the end time of the first instance.
837    pub end: Option<EventDateTime>,
838    /// Whether the end time is actually unspecified. An end time is still provided for compatibility reasons, even if this attribute is set to True. The default is False.
839    #[serde(rename = "endTimeUnspecified")]
840    pub end_time_unspecified: Option<bool>,
841    /// ETag of the resource.
842    pub etag: Option<String>,
843    /// Specific type of the event. This cannot be modified after the event is created. Possible values are:  
844    /// - "default" - A regular event or not further specified.
845    /// - "outOfOffice" - An out-of-office event.
846    /// - "focusTime" - A focus-time event.
847    /// - "workingLocation" - A working location event.
848    /// - "fromGmail" - An event from Gmail. This type of event cannot be created.
849    #[serde(rename = "eventType")]
850    pub event_type: Option<String>,
851    /// Extended properties of the event.
852    #[serde(rename = "extendedProperties")]
853    pub extended_properties: Option<EventExtendedProperties>,
854    /// Focus Time event data. Used if eventType is focusTime.
855    #[serde(rename = "focusTimeProperties")]
856    pub focus_time_properties: Option<EventFocusTimeProperties>,
857    /// A gadget that extends this event. Gadgets are deprecated; this structure is instead only used for returning birthday calendar metadata.
858    pub gadget: Option<EventGadget>,
859    /// Whether attendees other than the organizer can invite others to the event. Optional. The default is True.
860    #[serde(rename = "guestsCanInviteOthers")]
861    pub guests_can_invite_others: Option<bool>,
862    /// Whether attendees other than the organizer can modify the event. Optional. The default is False.
863    #[serde(rename = "guestsCanModify")]
864    pub guests_can_modify: Option<bool>,
865    /// Whether attendees other than the organizer can see who the event's attendees are. Optional. The default is True.
866    #[serde(rename = "guestsCanSeeOtherGuests")]
867    pub guests_can_see_other_guests: Option<bool>,
868    /// An absolute link to the Google Hangout associated with this event. Read-only.
869    #[serde(rename = "hangoutLink")]
870    pub hangout_link: Option<String>,
871    /// An absolute link to this event in the Google Calendar Web UI. Read-only.
872    #[serde(rename = "htmlLink")]
873    pub html_link: Option<String>,
874    /// Event unique identifier as defined in RFC5545. It is used to uniquely identify events accross calendaring systems and must be supplied when importing events via the import method.
875    /// Note that the iCalUID and the id are not identical and only one of them should be supplied at event creation time. One difference in their semantics is that in recurring events, all occurrences of one event have different ids while they all share the same iCalUIDs. To retrieve an event using its iCalUID, call the events.list method using the iCalUID parameter. To retrieve an event using its id, call the events.get method.
876    #[serde(rename = "iCalUID")]
877    pub i_cal_uid: Option<String>,
878    /// Opaque identifier of the event. When creating new single or recurring events, you can specify their IDs. Provided IDs must follow these rules:  
879    /// - characters allowed in the ID are those used in base32hex encoding, i.e. lowercase letters a-v and digits 0-9, see section 3.1.2 in RFC2938
880    /// - the length of the ID must be between 5 and 1024 characters
881    /// - the ID must be unique per calendar  Due to the globally distributed nature of the system, we cannot guarantee that ID collisions will be detected at event creation time. To minimize the risk of collisions we recommend using an established UUID algorithm such as one described in RFC4122.
882    /// If you do not specify an ID, it will be automatically generated by the server.
883    /// Note that the icalUID and the id are not identical and only one of them should be supplied at event creation time. One difference in their semantics is that in recurring events, all occurrences of one event have different ids while they all share the same icalUIDs.
884    pub id: Option<String>,
885    /// Type of the resource ("calendar#event").
886    pub kind: Option<String>,
887    /// Geographic location of the event as free-form text. Optional.
888    pub location: Option<String>,
889    /// Whether this is a locked event copy where no changes can be made to the main event fields "summary", "description", "location", "start", "end" or "recurrence". The default is False. Read-Only.
890    pub locked: Option<bool>,
891    /// The organizer of the event. If the organizer is also an attendee, this is indicated with a separate entry in attendees with the organizer field set to True. To change the organizer, use the move operation. Read-only, except when importing an event.
892    pub organizer: Option<EventOrganizer>,
893    /// For an instance of a recurring event, this is the time at which this event would start according to the recurrence data in the recurring event identified by recurringEventId. It uniquely identifies the instance within the recurring event series even if the instance was moved to a different time. Immutable.
894    #[serde(rename = "originalStartTime")]
895    pub original_start_time: Option<EventDateTime>,
896    /// Out of office event data. Used if eventType is outOfOffice.
897    #[serde(rename = "outOfOfficeProperties")]
898    pub out_of_office_properties: Option<EventOutOfOfficeProperties>,
899    /// If set to True, Event propagation is disabled. Note that it is not the same thing as Private event properties. Optional. Immutable. The default is False.
900    #[serde(rename = "privateCopy")]
901    pub private_copy: Option<bool>,
902    /// List of RRULE, EXRULE, RDATE and EXDATE lines for a recurring event, as specified in RFC5545. Note that DTSTART and DTEND lines are not allowed in this field; event start and end times are specified in the start and end fields. This field is omitted for single events or instances of recurring events.
903    pub recurrence: Option<Vec<String>>,
904    /// For an instance of a recurring event, this is the id of the recurring event to which this instance belongs. Immutable.
905    #[serde(rename = "recurringEventId")]
906    pub recurring_event_id: Option<String>,
907    /// Information about the event's reminders for the authenticated user.
908    pub reminders: Option<EventReminders>,
909    /// Sequence number as per iCalendar.
910    pub sequence: Option<i32>,
911    /// Source from which the event was created. For example, a web page, an email message or any document identifiable by an URL with HTTP or HTTPS scheme. Can only be seen or modified by the creator of the event.
912    pub source: Option<EventSource>,
913    /// The (inclusive) start time of the event. For a recurring event, this is the start time of the first instance.
914    pub start: Option<EventDateTime>,
915    /// Status of the event. Optional. Possible values are:  
916    /// - "confirmed" - The event is confirmed. This is the default status.
917    /// - "tentative" - The event is tentatively confirmed.
918    /// - "cancelled" - The event is cancelled (deleted). The list method returns cancelled events only on incremental sync (when syncToken or updatedMin are specified) or if the showDeleted flag is set to true. The get method always returns them.
919    /// A cancelled status represents two different states depending on the event type:  
920    /// - Cancelled exceptions of an uncancelled recurring event indicate that this instance should no longer be presented to the user. Clients should store these events for the lifetime of the parent recurring event.
921    /// Cancelled exceptions are only guaranteed to have values for the id, recurringEventId and originalStartTime fields populated. The other fields might be empty.  
922    /// - All other cancelled events represent deleted events. Clients should remove their locally synced copies. Such cancelled events will eventually disappear, so do not rely on them being available indefinitely.
923    /// Deleted events are only guaranteed to have the id field populated.   On the organizer's calendar, cancelled events continue to expose event details (summary, location, etc.) so that they can be restored (undeleted). Similarly, the events to which the user was invited and that they manually removed continue to provide details. However, incremental sync requests with showDeleted set to false will not return these details.
924    /// If an event changes its organizer (for example via the move operation) and the original organizer is not on the attendee list, it will leave behind a cancelled event where only the id field is guaranteed to be populated.
925    pub status: Option<String>,
926    /// Title of the event.
927    pub summary: Option<String>,
928    /// Whether the event blocks time on the calendar. Optional. Possible values are:  
929    /// - "opaque" - Default value. The event does block time on the calendar. This is equivalent to setting Show me as to Busy in the Calendar UI.
930    /// - "transparent" - The event does not block time on the calendar. This is equivalent to setting Show me as to Available in the Calendar UI.
931    pub transparency: Option<String>,
932    /// Last modification time of the event (as a RFC3339 timestamp). Read-only.
933    pub updated: Option<chrono::DateTime<chrono::offset::Utc>>,
934    /// Visibility of the event. Optional. Possible values are:  
935    /// - "default" - Uses the default visibility for events on the calendar. This is the default value.
936    /// - "public" - The event is public and event details are visible to all readers of the calendar.
937    /// - "private" - The event is private and only event attendees may view event details.
938    /// - "confidential" - The event is private. This value is provided for compatibility reasons.
939    pub visibility: Option<String>,
940    /// Working location event data.
941    #[serde(rename = "workingLocationProperties")]
942    pub working_location_properties: Option<EventWorkingLocationProperties>,
943}
944
945impl common::RequestValue for Event {}
946impl common::Resource for Event {}
947impl common::ResponseResult for Event {}
948
949/// There is no detailed description.
950///
951/// This type is not used in any activity, and only used as *part* of another schema.
952///
953#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
954#[serde_with::serde_as]
955#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
956pub struct EventAttachment {
957    /// ID of the attached file. Read-only.
958    /// For Google Drive files, this is the ID of the corresponding Files resource entry in the Drive API.
959    #[serde(rename = "fileId")]
960    pub file_id: Option<String>,
961    /// URL link to the attachment.
962    /// For adding Google Drive file attachments use the same format as in alternateLink property of the Files resource in the Drive API.
963    /// Required when adding an attachment.
964    #[serde(rename = "fileUrl")]
965    pub file_url: Option<String>,
966    /// URL link to the attachment's icon. This field can only be modified for custom third-party attachments.
967    #[serde(rename = "iconLink")]
968    pub icon_link: Option<String>,
969    /// Internet media type (MIME type) of the attachment.
970    #[serde(rename = "mimeType")]
971    pub mime_type: Option<String>,
972    /// Attachment title.
973    pub title: Option<String>,
974}
975
976impl common::Part for EventAttachment {}
977
978/// There is no detailed description.
979///
980/// This type is not used in any activity, and only used as *part* of another schema.
981///
982#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
983#[serde_with::serde_as]
984#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
985pub struct EventAttendee {
986    /// Number of additional guests. Optional. The default is 0.
987    #[serde(rename = "additionalGuests")]
988    pub additional_guests: Option<i32>,
989    /// The attendee's response comment. Optional.
990    pub comment: Option<String>,
991    /// The attendee's name, if available. Optional.
992    #[serde(rename = "displayName")]
993    pub display_name: Option<String>,
994    /// The attendee's email address, if available. This field must be present when adding an attendee. It must be a valid email address as per RFC5322.
995    /// Required when adding an attendee.
996    pub email: Option<String>,
997    /// The attendee's Profile ID, if available.
998    pub id: Option<String>,
999    /// Whether this is an optional attendee. Optional. The default is False.
1000    pub optional: Option<bool>,
1001    /// Whether the attendee is the organizer of the event. Read-only. The default is False.
1002    pub organizer: Option<bool>,
1003    /// Whether the attendee is a resource. Can only be set when the attendee is added to the event for the first time. Subsequent modifications are ignored. Optional. The default is False.
1004    pub resource: Option<bool>,
1005    /// The attendee's response status. Possible values are:  
1006    /// - "needsAction" - The attendee has not responded to the invitation (recommended for new events).
1007    /// - "declined" - The attendee has declined the invitation.
1008    /// - "tentative" - The attendee has tentatively accepted the invitation.
1009    /// - "accepted" - The attendee has accepted the invitation.  Warning: If you add an event using the values declined, tentative, or accepted, attendees with the "Add invitations to my calendar" setting set to "When I respond to invitation in email" won't see an event on their calendar unless they choose to change their invitation response in the event invitation email.
1010    #[serde(rename = "responseStatus")]
1011    pub response_status: Option<String>,
1012    /// Whether this entry represents the calendar on which this copy of the event appears. Read-only. The default is False.
1013    #[serde(rename = "self")]
1014    pub self_: Option<bool>,
1015}
1016
1017impl common::Part for EventAttendee {}
1018
1019/// There is no detailed description.
1020///
1021/// This type is not used in any activity, and only used as *part* of another schema.
1022///
1023#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1024#[serde_with::serde_as]
1025#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1026pub struct EventDateTime {
1027    /// The date, in the format "yyyy-mm-dd", if this is an all-day event.
1028    pub date: Option<chrono::NaiveDate>,
1029    /// The time, as a combined date-time value (formatted according to RFC3339). A time zone offset is required unless a time zone is explicitly specified in timeZone.
1030    #[serde(rename = "dateTime")]
1031    pub date_time: Option<chrono::DateTime<chrono::offset::Utc>>,
1032    /// The time zone in which the time is specified. (Formatted as an IANA Time Zone Database name, e.g. "Europe/Zurich".) For recurring events this field is required and specifies the time zone in which the recurrence is expanded. For single events this field is optional and indicates a custom time zone for the event start/end.
1033    #[serde(rename = "timeZone")]
1034    pub time_zone: Option<String>,
1035}
1036
1037impl common::Part for EventDateTime {}
1038
1039/// There is no detailed description.
1040///
1041/// This type is not used in any activity, and only used as *part* of another schema.
1042///
1043#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1044#[serde_with::serde_as]
1045#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1046pub struct EventFocusTimeProperties {
1047    /// Whether to decline meeting invitations which overlap Focus Time events. Valid values are declineNone, meaning that no meeting invitations are declined; declineAllConflictingInvitations, meaning that all conflicting meeting invitations that conflict with the event are declined; and declineOnlyNewConflictingInvitations, meaning that only new conflicting meeting invitations which arrive while the Focus Time event is present are to be declined.
1048    #[serde(rename = "autoDeclineMode")]
1049    pub auto_decline_mode: Option<String>,
1050    /// The status to mark the user in Chat and related products. This can be available or doNotDisturb.
1051    #[serde(rename = "chatStatus")]
1052    pub chat_status: Option<String>,
1053    /// Response message to set if an existing event or new invitation is automatically declined by Calendar.
1054    #[serde(rename = "declineMessage")]
1055    pub decline_message: Option<String>,
1056}
1057
1058impl common::Part for EventFocusTimeProperties {}
1059
1060/// There is no detailed description.
1061///
1062/// This type is not used in any activity, and only used as *part* of another schema.
1063///
1064#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1065#[serde_with::serde_as]
1066#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1067pub struct EventOutOfOfficeProperties {
1068    /// Whether to decline meeting invitations which overlap Out of office events. Valid values are declineNone, meaning that no meeting invitations are declined; declineAllConflictingInvitations, meaning that all conflicting meeting invitations that conflict with the event are declined; and declineOnlyNewConflictingInvitations, meaning that only new conflicting meeting invitations which arrive while the Out of office event is present are to be declined.
1069    #[serde(rename = "autoDeclineMode")]
1070    pub auto_decline_mode: Option<String>,
1071    /// Response message to set if an existing event or new invitation is automatically declined by Calendar.
1072    #[serde(rename = "declineMessage")]
1073    pub decline_message: Option<String>,
1074}
1075
1076impl common::Part for EventOutOfOfficeProperties {}
1077
1078/// There is no detailed description.
1079///
1080/// This type is not used in any activity, and only used as *part* of another schema.
1081///
1082#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1083#[serde_with::serde_as]
1084#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1085pub struct EventReminder {
1086    /// The method used by this reminder. Possible values are:  
1087    /// - "email" - Reminders are sent via email.
1088    /// - "popup" - Reminders are sent via a UI popup.  
1089    /// Required when adding a reminder.
1090    pub method: Option<String>,
1091    /// Number of minutes before the start of the event when the reminder should trigger. Valid values are between 0 and 40320 (4 weeks in minutes).
1092    /// Required when adding a reminder.
1093    pub minutes: Option<i32>,
1094}
1095
1096impl common::Part for EventReminder {}
1097
1098/// There is no detailed description.
1099///
1100/// This type is not used in any activity, and only used as *part* of another schema.
1101///
1102#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1103#[serde_with::serde_as]
1104#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1105pub struct EventWorkingLocationProperties {
1106    /// If present, specifies that the user is working from a custom location.
1107    #[serde(rename = "customLocation")]
1108    pub custom_location: Option<EventWorkingLocationPropertiesCustomLocation>,
1109    /// If present, specifies that the user is working at home.
1110    #[serde(rename = "homeOffice")]
1111    pub home_office: Option<serde_json::Value>,
1112    /// If present, specifies that the user is working from an office.
1113    #[serde(rename = "officeLocation")]
1114    pub office_location: Option<EventWorkingLocationPropertiesOfficeLocation>,
1115    /// Type of the working location. Possible values are:  
1116    /// - "homeOffice" - The user is working at home.
1117    /// - "officeLocation" - The user is working from an office.
1118    /// - "customLocation" - The user is working from a custom location.  Any details are specified in a sub-field of the specified name, but this field may be missing if empty. Any other fields are ignored.
1119    /// Required when adding working location properties.
1120    #[serde(rename = "type")]
1121    pub type_: Option<String>,
1122}
1123
1124impl common::Part for EventWorkingLocationProperties {}
1125
1126/// There is no detailed description.
1127///
1128/// # Activities
1129///
1130/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1131/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1132///
1133/// * [instances events](EventInstanceCall) (response)
1134/// * [list events](EventListCall) (response)
1135#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1136#[serde_with::serde_as]
1137#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1138pub struct Events {
1139    /// The user's access role for this calendar. Read-only. Possible values are:  
1140    /// - "none" - The user has no access.
1141    /// - "freeBusyReader" - The user has read access to free/busy information.
1142    /// - "reader" - The user has read access to the calendar. Private events will appear to users with reader access, but event details will be hidden.
1143    /// - "writer" - The user has read and write access to the calendar. Private events will appear to users with writer access, and event details will be visible.
1144    /// - "owner" - The user has ownership of the calendar. This role has all of the permissions of the writer role with the additional ability to see and manipulate ACLs.
1145    #[serde(rename = "accessRole")]
1146    pub access_role: Option<String>,
1147    /// The default reminders on the calendar for the authenticated user. These reminders apply to all events on this calendar that do not explicitly override them (i.e. do not have reminders.useDefault set to True).
1148    #[serde(rename = "defaultReminders")]
1149    pub default_reminders: Option<Vec<EventReminder>>,
1150    /// Description of the calendar. Read-only.
1151    pub description: Option<String>,
1152    /// ETag of the collection.
1153    pub etag: Option<String>,
1154    /// List of events on the calendar.
1155    pub items: Option<Vec<Event>>,
1156    /// Type of the collection ("calendar#events").
1157    pub kind: Option<String>,
1158    /// Token used to access the next page of this result. Omitted if no further results are available, in which case nextSyncToken is provided.
1159    #[serde(rename = "nextPageToken")]
1160    pub next_page_token: Option<String>,
1161    /// Token used at a later point in time to retrieve only the entries that have changed since this result was returned. Omitted if further results are available, in which case nextPageToken is provided.
1162    #[serde(rename = "nextSyncToken")]
1163    pub next_sync_token: Option<String>,
1164    /// Title of the calendar. Read-only.
1165    pub summary: Option<String>,
1166    /// The time zone of the calendar. Read-only.
1167    #[serde(rename = "timeZone")]
1168    pub time_zone: Option<String>,
1169    /// Last modification time of the calendar (as a RFC3339 timestamp). Read-only.
1170    pub updated: Option<chrono::DateTime<chrono::offset::Utc>>,
1171}
1172
1173impl common::ResponseResult for Events {}
1174
1175/// There is no detailed description.
1176///
1177/// This type is not used in any activity, and only used as *part* of another schema.
1178///
1179#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1180#[serde_with::serde_as]
1181#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1182pub struct FreeBusyCalendar {
1183    /// List of time ranges during which this calendar should be regarded as busy.
1184    pub busy: Option<Vec<TimePeriod>>,
1185    /// Optional error(s) (if computation for the calendar failed).
1186    pub errors: Option<Vec<Error>>,
1187}
1188
1189impl common::Part for FreeBusyCalendar {}
1190
1191/// There is no detailed description.
1192///
1193/// This type is not used in any activity, and only used as *part* of another schema.
1194///
1195#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1196#[serde_with::serde_as]
1197#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1198pub struct FreeBusyGroup {
1199    /// List of calendars' identifiers within a group.
1200    pub calendars: Option<Vec<String>>,
1201    /// Optional error(s) (if computation for the group failed).
1202    pub errors: Option<Vec<Error>>,
1203}
1204
1205impl common::Part for FreeBusyGroup {}
1206
1207/// There is no detailed description.
1208///
1209/// # Activities
1210///
1211/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1212/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1213///
1214/// * [query freebusy](FreebusyQueryCall) (request)
1215#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1216#[serde_with::serde_as]
1217#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1218pub struct FreeBusyRequest {
1219    /// Maximal number of calendars for which FreeBusy information is to be provided. Optional. Maximum value is 50.
1220    #[serde(rename = "calendarExpansionMax")]
1221    pub calendar_expansion_max: Option<i32>,
1222    /// Maximal number of calendar identifiers to be provided for a single group. Optional. An error is returned for a group with more members than this value. Maximum value is 100.
1223    #[serde(rename = "groupExpansionMax")]
1224    pub group_expansion_max: Option<i32>,
1225    /// List of calendars and/or groups to query.
1226    pub items: Option<Vec<FreeBusyRequestItem>>,
1227    /// The end of the interval for the query formatted as per RFC3339.
1228    #[serde(rename = "timeMax")]
1229    pub time_max: Option<chrono::DateTime<chrono::offset::Utc>>,
1230    /// The start of the interval for the query formatted as per RFC3339.
1231    #[serde(rename = "timeMin")]
1232    pub time_min: Option<chrono::DateTime<chrono::offset::Utc>>,
1233    /// Time zone used in the response. Optional. The default is UTC.
1234    #[serde(rename = "timeZone")]
1235    pub time_zone: Option<String>,
1236}
1237
1238impl common::RequestValue for FreeBusyRequest {}
1239
1240/// There is no detailed description.
1241///
1242/// This type is not used in any activity, and only used as *part* of another schema.
1243///
1244#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1245#[serde_with::serde_as]
1246#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1247pub struct FreeBusyRequestItem {
1248    /// The identifier of a calendar or a group.
1249    pub id: Option<String>,
1250}
1251
1252impl common::Part for FreeBusyRequestItem {}
1253
1254/// There is no detailed description.
1255///
1256/// # Activities
1257///
1258/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1259/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1260///
1261/// * [query freebusy](FreebusyQueryCall) (response)
1262#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1263#[serde_with::serde_as]
1264#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1265pub struct FreeBusyResponse {
1266    /// List of free/busy information for calendars.
1267    pub calendars: Option<HashMap<String, FreeBusyCalendar>>,
1268    /// Expansion of groups.
1269    pub groups: Option<HashMap<String, FreeBusyGroup>>,
1270    /// Type of the resource ("calendar#freeBusy").
1271    pub kind: Option<String>,
1272    /// The end of the interval.
1273    #[serde(rename = "timeMax")]
1274    pub time_max: Option<chrono::DateTime<chrono::offset::Utc>>,
1275    /// The start of the interval.
1276    #[serde(rename = "timeMin")]
1277    pub time_min: Option<chrono::DateTime<chrono::offset::Utc>>,
1278}
1279
1280impl common::ResponseResult for FreeBusyResponse {}
1281
1282/// There is no detailed description.
1283///
1284/// # Activities
1285///
1286/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1287/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1288///
1289/// * [get settings](SettingGetCall) (response)
1290/// * [list settings](SettingListCall) (none)
1291/// * [watch settings](SettingWatchCall) (none)
1292#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1293#[serde_with::serde_as]
1294#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1295pub struct Setting {
1296    /// ETag of the resource.
1297    pub etag: Option<String>,
1298    /// The id of the user setting.
1299    pub id: Option<String>,
1300    /// Type of the resource ("calendar#setting").
1301    pub kind: Option<String>,
1302    /// Value of the user setting. The format of the value depends on the ID of the setting. It must always be a UTF-8 string of length up to 1024 characters.
1303    pub value: Option<String>,
1304}
1305
1306impl common::Resource for Setting {}
1307impl common::ResponseResult for Setting {}
1308
1309/// There is no detailed description.
1310///
1311/// # Activities
1312///
1313/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1314/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1315///
1316/// * [list settings](SettingListCall) (response)
1317#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1318#[serde_with::serde_as]
1319#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1320pub struct Settings {
1321    /// Etag of the collection.
1322    pub etag: Option<String>,
1323    /// List of user settings.
1324    pub items: Option<Vec<Setting>>,
1325    /// Type of the collection ("calendar#settings").
1326    pub kind: Option<String>,
1327    /// Token used to access the next page of this result. Omitted if no further results are available, in which case nextSyncToken is provided.
1328    #[serde(rename = "nextPageToken")]
1329    pub next_page_token: Option<String>,
1330    /// Token used at a later point in time to retrieve only the entries that have changed since this result was returned. Omitted if further results are available, in which case nextPageToken is provided.
1331    #[serde(rename = "nextSyncToken")]
1332    pub next_sync_token: Option<String>,
1333}
1334
1335impl common::ResponseResult for Settings {}
1336
1337/// There is no detailed description.
1338///
1339/// This type is not used in any activity, and only used as *part* of another schema.
1340///
1341#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1342#[serde_with::serde_as]
1343#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1344pub struct TimePeriod {
1345    /// The (exclusive) end of the time period.
1346    pub end: Option<chrono::DateTime<chrono::offset::Utc>>,
1347    /// The (inclusive) start of the time period.
1348    pub start: Option<chrono::DateTime<chrono::offset::Utc>>,
1349}
1350
1351impl common::Part for TimePeriod {}
1352
1353/// The extent to which calendar access is granted by this ACL rule.
1354///
1355/// This type is not used in any activity, and only used as *part* of another schema.
1356///
1357#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1358#[serde_with::serde_as]
1359#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1360pub struct AclRuleScope {
1361    /// The type of the scope. Possible values are:  
1362    /// - "default" - The public scope. This is the default value.
1363    /// - "user" - Limits the scope to a single user.
1364    /// - "group" - Limits the scope to a group.
1365    /// - "domain" - Limits the scope to a domain.  Note: The permissions granted to the "default", or public, scope apply to any user, authenticated or not.
1366    #[serde(rename = "type")]
1367    pub type_: Option<String>,
1368    /// The email address of a user or group, or the name of a domain, depending on the scope type. Omitted for type "default".
1369    pub value: Option<String>,
1370}
1371
1372impl common::NestedType for AclRuleScope {}
1373impl common::Part for AclRuleScope {}
1374
1375/// The notifications that the authenticated user is receiving for this calendar.
1376///
1377/// This type is not used in any activity, and only used as *part* of another schema.
1378///
1379#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1380#[serde_with::serde_as]
1381#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1382pub struct CalendarListEntryNotificationSettings {
1383    /// The list of notifications set for this calendar.
1384    pub notifications: Option<Vec<CalendarNotification>>,
1385}
1386
1387impl common::NestedType for CalendarListEntryNotificationSettings {}
1388impl common::Part for CalendarListEntryNotificationSettings {}
1389
1390/// The creator of the event. Read-only.
1391///
1392/// This type is not used in any activity, and only used as *part* of another schema.
1393///
1394#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1395#[serde_with::serde_as]
1396#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1397pub struct EventCreator {
1398    /// The creator's name, if available.
1399    #[serde(rename = "displayName")]
1400    pub display_name: Option<String>,
1401    /// The creator's email address, if available.
1402    pub email: Option<String>,
1403    /// The creator's Profile ID, if available.
1404    pub id: Option<String>,
1405    /// Whether the creator corresponds to the calendar on which this copy of the event appears. Read-only. The default is False.
1406    #[serde(rename = "self")]
1407    pub self_: Option<bool>,
1408}
1409
1410impl common::NestedType for EventCreator {}
1411impl common::Part for EventCreator {}
1412
1413/// Extended properties of the event.
1414///
1415/// This type is not used in any activity, and only used as *part* of another schema.
1416///
1417#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1418#[serde_with::serde_as]
1419#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1420pub struct EventExtendedProperties {
1421    /// Properties that are private to the copy of the event that appears on this calendar.
1422    pub private: Option<HashMap<String, String>>,
1423    /// Properties that are shared between copies of the event on other attendees' calendars.
1424    pub shared: Option<HashMap<String, String>>,
1425}
1426
1427impl common::NestedType for EventExtendedProperties {}
1428impl common::Part for EventExtendedProperties {}
1429
1430/// A gadget that extends this event. Gadgets are deprecated; this structure is instead only used for returning birthday calendar metadata.
1431///
1432/// This type is not used in any activity, and only used as *part* of another schema.
1433///
1434#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1435#[serde_with::serde_as]
1436#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1437pub struct EventGadget {
1438    /// The gadget's display mode. Deprecated. Possible values are:  
1439    /// - "icon" - The gadget displays next to the event's title in the calendar view.
1440    /// - "chip" - The gadget displays when the event is clicked.
1441    pub display: Option<String>,
1442    /// The gadget's height in pixels. The height must be an integer greater than 0. Optional. Deprecated.
1443    pub height: Option<i32>,
1444    /// The gadget's icon URL. The URL scheme must be HTTPS. Deprecated.
1445    #[serde(rename = "iconLink")]
1446    pub icon_link: Option<String>,
1447    /// The gadget's URL. The URL scheme must be HTTPS. Deprecated.
1448    pub link: Option<String>,
1449    /// Preferences.
1450    pub preferences: Option<HashMap<String, String>>,
1451    /// The gadget's title. Deprecated.
1452    pub title: Option<String>,
1453    /// The gadget's type. Deprecated.
1454    #[serde(rename = "type")]
1455    pub type_: Option<String>,
1456    /// The gadget's width in pixels. The width must be an integer greater than 0. Optional. Deprecated.
1457    pub width: Option<i32>,
1458}
1459
1460impl common::NestedType for EventGadget {}
1461impl common::Part for EventGadget {}
1462
1463/// The organizer of the event. If the organizer is also an attendee, this is indicated with a separate entry in attendees with the organizer field set to True. To change the organizer, use the move operation. Read-only, except when importing an event.
1464///
1465/// This type is not used in any activity, and only used as *part* of another schema.
1466///
1467#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1468#[serde_with::serde_as]
1469#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1470pub struct EventOrganizer {
1471    /// The organizer's name, if available.
1472    #[serde(rename = "displayName")]
1473    pub display_name: Option<String>,
1474    /// The organizer's email address, if available. It must be a valid email address as per RFC5322.
1475    pub email: Option<String>,
1476    /// The organizer's Profile ID, if available.
1477    pub id: Option<String>,
1478    /// Whether the organizer corresponds to the calendar on which this copy of the event appears. Read-only. The default is False.
1479    #[serde(rename = "self")]
1480    pub self_: Option<bool>,
1481}
1482
1483impl common::NestedType for EventOrganizer {}
1484impl common::Part for EventOrganizer {}
1485
1486/// Information about the event's reminders for the authenticated user.
1487///
1488/// This type is not used in any activity, and only used as *part* of another schema.
1489///
1490#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1491#[serde_with::serde_as]
1492#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1493pub struct EventReminders {
1494    /// If the event doesn't use the default reminders, this lists the reminders specific to the event, or, if not set, indicates that no reminders are set for this event. The maximum number of override reminders is 5.
1495    pub overrides: Option<Vec<EventReminder>>,
1496    /// Whether the default reminders of the calendar apply to the event.
1497    #[serde(rename = "useDefault")]
1498    pub use_default: Option<bool>,
1499}
1500
1501impl common::NestedType for EventReminders {}
1502impl common::Part for EventReminders {}
1503
1504/// Source from which the event was created. For example, a web page, an email message or any document identifiable by an URL with HTTP or HTTPS scheme. Can only be seen or modified by the creator of the event.
1505///
1506/// This type is not used in any activity, and only used as *part* of another schema.
1507///
1508#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1509#[serde_with::serde_as]
1510#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1511pub struct EventSource {
1512    /// Title of the source; for example a title of a web page or an email subject.
1513    pub title: Option<String>,
1514    /// URL of the source pointing to a resource. The URL scheme must be HTTP or HTTPS.
1515    pub url: Option<String>,
1516}
1517
1518impl common::NestedType for EventSource {}
1519impl common::Part for EventSource {}
1520
1521/// If present, specifies that the user is working from a custom location.
1522///
1523/// This type is not used in any activity, and only used as *part* of another schema.
1524///
1525#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1526#[serde_with::serde_as]
1527#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1528pub struct EventWorkingLocationPropertiesCustomLocation {
1529    /// An optional extra label for additional information.
1530    pub label: Option<String>,
1531}
1532
1533impl common::NestedType for EventWorkingLocationPropertiesCustomLocation {}
1534impl common::Part for EventWorkingLocationPropertiesCustomLocation {}
1535
1536/// If present, specifies that the user is working from an office.
1537///
1538/// This type is not used in any activity, and only used as *part* of another schema.
1539///
1540#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1541#[serde_with::serde_as]
1542#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1543pub struct EventWorkingLocationPropertiesOfficeLocation {
1544    /// An optional building identifier. This should reference a building ID in the organization's Resources database.
1545    #[serde(rename = "buildingId")]
1546    pub building_id: Option<String>,
1547    /// An optional desk identifier.
1548    #[serde(rename = "deskId")]
1549    pub desk_id: Option<String>,
1550    /// An optional floor identifier.
1551    #[serde(rename = "floorId")]
1552    pub floor_id: Option<String>,
1553    /// An optional floor section identifier.
1554    #[serde(rename = "floorSectionId")]
1555    pub floor_section_id: Option<String>,
1556    /// The office name that's displayed in Calendar Web and Mobile clients. We recommend you reference a building name in the organization's Resources database.
1557    pub label: Option<String>,
1558}
1559
1560impl common::NestedType for EventWorkingLocationPropertiesOfficeLocation {}
1561impl common::Part for EventWorkingLocationPropertiesOfficeLocation {}
1562
1563// ###################
1564// MethodBuilders ###
1565// #################
1566
1567/// A builder providing access to all methods supported on *acl* resources.
1568/// It is not used directly, but through the [`CalendarHub`] hub.
1569///
1570/// # Example
1571///
1572/// Instantiate a resource builder
1573///
1574/// ```test_harness,no_run
1575/// extern crate hyper;
1576/// extern crate hyper_rustls;
1577/// extern crate google_calendar3 as calendar3;
1578///
1579/// # async fn dox() {
1580/// use calendar3::{CalendarHub, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
1581///
1582/// let secret: yup_oauth2::ApplicationSecret = Default::default();
1583/// let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
1584///     secret,
1585///     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
1586/// ).build().await.unwrap();
1587///
1588/// let client = hyper_util::client::legacy::Client::builder(
1589///     hyper_util::rt::TokioExecutor::new()
1590/// )
1591/// .build(
1592///     hyper_rustls::HttpsConnectorBuilder::new()
1593///         .with_native_roots()
1594///         .unwrap()
1595///         .https_or_http()
1596///         .enable_http1()
1597///         .build()
1598/// );
1599/// let mut hub = CalendarHub::new(client, auth);
1600/// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders*
1601/// // like `delete(...)`, `get(...)`, `insert(...)`, `list(...)`, `patch(...)`, `update(...)` and `watch(...)`
1602/// // to build up your call.
1603/// let rb = hub.acl();
1604/// # }
1605/// ```
1606pub struct AclMethods<'a, C>
1607where
1608    C: 'a,
1609{
1610    hub: &'a CalendarHub<C>,
1611}
1612
1613impl<'a, C> common::MethodsBuilder for AclMethods<'a, C> {}
1614
1615impl<'a, C> AclMethods<'a, C> {
1616    /// Create a builder to help you perform the following task:
1617    ///
1618    /// Deletes an access control rule.
1619    ///
1620    /// # Arguments
1621    ///
1622    /// * `calendarId` - 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.
1623    /// * `ruleId` - ACL rule identifier.
1624    pub fn delete(&self, calendar_id: &str, rule_id: &str) -> AclDeleteCall<'a, C> {
1625        AclDeleteCall {
1626            hub: self.hub,
1627            _calendar_id: calendar_id.to_string(),
1628            _rule_id: rule_id.to_string(),
1629            _delegate: Default::default(),
1630            _additional_params: Default::default(),
1631            _scopes: Default::default(),
1632        }
1633    }
1634
1635    /// Create a builder to help you perform the following task:
1636    ///
1637    /// Returns an access control rule.
1638    ///
1639    /// # Arguments
1640    ///
1641    /// * `calendarId` - 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.
1642    /// * `ruleId` - ACL rule identifier.
1643    pub fn get(&self, calendar_id: &str, rule_id: &str) -> AclGetCall<'a, C> {
1644        AclGetCall {
1645            hub: self.hub,
1646            _calendar_id: calendar_id.to_string(),
1647            _rule_id: rule_id.to_string(),
1648            _delegate: Default::default(),
1649            _additional_params: Default::default(),
1650            _scopes: Default::default(),
1651        }
1652    }
1653
1654    /// Create a builder to help you perform the following task:
1655    ///
1656    /// Creates an access control rule.
1657    ///
1658    /// # Arguments
1659    ///
1660    /// * `request` - No description provided.
1661    /// * `calendarId` - 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.
1662    pub fn insert(&self, request: AclRule, calendar_id: &str) -> AclInsertCall<'a, C> {
1663        AclInsertCall {
1664            hub: self.hub,
1665            _request: request,
1666            _calendar_id: calendar_id.to_string(),
1667            _send_notifications: Default::default(),
1668            _delegate: Default::default(),
1669            _additional_params: Default::default(),
1670            _scopes: Default::default(),
1671        }
1672    }
1673
1674    /// Create a builder to help you perform the following task:
1675    ///
1676    /// Returns the rules in the access control list for the calendar.
1677    ///
1678    /// # Arguments
1679    ///
1680    /// * `calendarId` - 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.
1681    pub fn list(&self, calendar_id: &str) -> AclListCall<'a, C> {
1682        AclListCall {
1683            hub: self.hub,
1684            _calendar_id: calendar_id.to_string(),
1685            _sync_token: Default::default(),
1686            _show_deleted: Default::default(),
1687            _page_token: Default::default(),
1688            _max_results: Default::default(),
1689            _delegate: Default::default(),
1690            _additional_params: Default::default(),
1691            _scopes: Default::default(),
1692        }
1693    }
1694
1695    /// Create a builder to help you perform the following task:
1696    ///
1697    /// Updates an access control rule. This method supports patch semantics.
1698    ///
1699    /// # Arguments
1700    ///
1701    /// * `request` - No description provided.
1702    /// * `calendarId` - 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.
1703    /// * `ruleId` - ACL rule identifier.
1704    pub fn patch(&self, request: AclRule, calendar_id: &str, rule_id: &str) -> AclPatchCall<'a, C> {
1705        AclPatchCall {
1706            hub: self.hub,
1707            _request: request,
1708            _calendar_id: calendar_id.to_string(),
1709            _rule_id: rule_id.to_string(),
1710            _send_notifications: Default::default(),
1711            _delegate: Default::default(),
1712            _additional_params: Default::default(),
1713            _scopes: Default::default(),
1714        }
1715    }
1716
1717    /// Create a builder to help you perform the following task:
1718    ///
1719    /// Updates an access control rule.
1720    ///
1721    /// # Arguments
1722    ///
1723    /// * `request` - No description provided.
1724    /// * `calendarId` - 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.
1725    /// * `ruleId` - ACL rule identifier.
1726    pub fn update(
1727        &self,
1728        request: AclRule,
1729        calendar_id: &str,
1730        rule_id: &str,
1731    ) -> AclUpdateCall<'a, C> {
1732        AclUpdateCall {
1733            hub: self.hub,
1734            _request: request,
1735            _calendar_id: calendar_id.to_string(),
1736            _rule_id: rule_id.to_string(),
1737            _send_notifications: Default::default(),
1738            _delegate: Default::default(),
1739            _additional_params: Default::default(),
1740            _scopes: Default::default(),
1741        }
1742    }
1743
1744    /// Create a builder to help you perform the following task:
1745    ///
1746    /// Watch for changes to ACL resources.
1747    ///
1748    /// # Arguments
1749    ///
1750    /// * `request` - No description provided.
1751    /// * `calendarId` - 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.
1752    pub fn watch(&self, request: Channel, calendar_id: &str) -> AclWatchCall<'a, C> {
1753        AclWatchCall {
1754            hub: self.hub,
1755            _request: request,
1756            _calendar_id: calendar_id.to_string(),
1757            _sync_token: Default::default(),
1758            _show_deleted: Default::default(),
1759            _page_token: Default::default(),
1760            _max_results: Default::default(),
1761            _delegate: Default::default(),
1762            _additional_params: Default::default(),
1763            _scopes: Default::default(),
1764        }
1765    }
1766}
1767
1768/// A builder providing access to all methods supported on *calendarList* resources.
1769/// It is not used directly, but through the [`CalendarHub`] hub.
1770///
1771/// # Example
1772///
1773/// Instantiate a resource builder
1774///
1775/// ```test_harness,no_run
1776/// extern crate hyper;
1777/// extern crate hyper_rustls;
1778/// extern crate google_calendar3 as calendar3;
1779///
1780/// # async fn dox() {
1781/// use calendar3::{CalendarHub, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
1782///
1783/// let secret: yup_oauth2::ApplicationSecret = Default::default();
1784/// let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
1785///     secret,
1786///     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
1787/// ).build().await.unwrap();
1788///
1789/// let client = hyper_util::client::legacy::Client::builder(
1790///     hyper_util::rt::TokioExecutor::new()
1791/// )
1792/// .build(
1793///     hyper_rustls::HttpsConnectorBuilder::new()
1794///         .with_native_roots()
1795///         .unwrap()
1796///         .https_or_http()
1797///         .enable_http1()
1798///         .build()
1799/// );
1800/// let mut hub = CalendarHub::new(client, auth);
1801/// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders*
1802/// // like `delete(...)`, `get(...)`, `insert(...)`, `list(...)`, `patch(...)`, `update(...)` and `watch(...)`
1803/// // to build up your call.
1804/// let rb = hub.calendar_list();
1805/// # }
1806/// ```
1807pub struct CalendarListMethods<'a, C>
1808where
1809    C: 'a,
1810{
1811    hub: &'a CalendarHub<C>,
1812}
1813
1814impl<'a, C> common::MethodsBuilder for CalendarListMethods<'a, C> {}
1815
1816impl<'a, C> CalendarListMethods<'a, C> {
1817    /// Create a builder to help you perform the following task:
1818    ///
1819    /// Removes a calendar from the user's calendar list.
1820    ///
1821    /// # Arguments
1822    ///
1823    /// * `calendarId` - 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.
1824    pub fn delete(&self, calendar_id: &str) -> CalendarListDeleteCall<'a, C> {
1825        CalendarListDeleteCall {
1826            hub: self.hub,
1827            _calendar_id: calendar_id.to_string(),
1828            _delegate: Default::default(),
1829            _additional_params: Default::default(),
1830            _scopes: Default::default(),
1831        }
1832    }
1833
1834    /// Create a builder to help you perform the following task:
1835    ///
1836    /// Returns a calendar from the user's calendar list.
1837    ///
1838    /// # Arguments
1839    ///
1840    /// * `calendarId` - 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.
1841    pub fn get(&self, calendar_id: &str) -> CalendarListGetCall<'a, C> {
1842        CalendarListGetCall {
1843            hub: self.hub,
1844            _calendar_id: calendar_id.to_string(),
1845            _delegate: Default::default(),
1846            _additional_params: Default::default(),
1847            _scopes: Default::default(),
1848        }
1849    }
1850
1851    /// Create a builder to help you perform the following task:
1852    ///
1853    /// Inserts an existing calendar into the user's calendar list.
1854    ///
1855    /// # Arguments
1856    ///
1857    /// * `request` - No description provided.
1858    pub fn insert(&self, request: CalendarListEntry) -> CalendarListInsertCall<'a, C> {
1859        CalendarListInsertCall {
1860            hub: self.hub,
1861            _request: request,
1862            _color_rgb_format: Default::default(),
1863            _delegate: Default::default(),
1864            _additional_params: Default::default(),
1865            _scopes: Default::default(),
1866        }
1867    }
1868
1869    /// Create a builder to help you perform the following task:
1870    ///
1871    /// Returns the calendars on the user's calendar list.
1872    pub fn list(&self) -> CalendarListListCall<'a, C> {
1873        CalendarListListCall {
1874            hub: self.hub,
1875            _sync_token: Default::default(),
1876            _show_hidden: Default::default(),
1877            _show_deleted: Default::default(),
1878            _page_token: Default::default(),
1879            _min_access_role: Default::default(),
1880            _max_results: Default::default(),
1881            _delegate: Default::default(),
1882            _additional_params: Default::default(),
1883            _scopes: Default::default(),
1884        }
1885    }
1886
1887    /// Create a builder to help you perform the following task:
1888    ///
1889    /// Updates an existing calendar on the user's calendar list. This method supports patch semantics.
1890    ///
1891    /// # Arguments
1892    ///
1893    /// * `request` - No description provided.
1894    /// * `calendarId` - 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.
1895    pub fn patch(
1896        &self,
1897        request: CalendarListEntry,
1898        calendar_id: &str,
1899    ) -> CalendarListPatchCall<'a, C> {
1900        CalendarListPatchCall {
1901            hub: self.hub,
1902            _request: request,
1903            _calendar_id: calendar_id.to_string(),
1904            _color_rgb_format: Default::default(),
1905            _delegate: Default::default(),
1906            _additional_params: Default::default(),
1907            _scopes: Default::default(),
1908        }
1909    }
1910
1911    /// Create a builder to help you perform the following task:
1912    ///
1913    /// Updates an existing calendar on the user's calendar list.
1914    ///
1915    /// # Arguments
1916    ///
1917    /// * `request` - No description provided.
1918    /// * `calendarId` - 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.
1919    pub fn update(
1920        &self,
1921        request: CalendarListEntry,
1922        calendar_id: &str,
1923    ) -> CalendarListUpdateCall<'a, C> {
1924        CalendarListUpdateCall {
1925            hub: self.hub,
1926            _request: request,
1927            _calendar_id: calendar_id.to_string(),
1928            _color_rgb_format: Default::default(),
1929            _delegate: Default::default(),
1930            _additional_params: Default::default(),
1931            _scopes: Default::default(),
1932        }
1933    }
1934
1935    /// Create a builder to help you perform the following task:
1936    ///
1937    /// Watch for changes to CalendarList resources.
1938    ///
1939    /// # Arguments
1940    ///
1941    /// * `request` - No description provided.
1942    pub fn watch(&self, request: Channel) -> CalendarListWatchCall<'a, C> {
1943        CalendarListWatchCall {
1944            hub: self.hub,
1945            _request: request,
1946            _sync_token: Default::default(),
1947            _show_hidden: Default::default(),
1948            _show_deleted: Default::default(),
1949            _page_token: Default::default(),
1950            _min_access_role: Default::default(),
1951            _max_results: Default::default(),
1952            _delegate: Default::default(),
1953            _additional_params: Default::default(),
1954            _scopes: Default::default(),
1955        }
1956    }
1957}
1958
1959/// A builder providing access to all methods supported on *calendar* resources.
1960/// It is not used directly, but through the [`CalendarHub`] hub.
1961///
1962/// # Example
1963///
1964/// Instantiate a resource builder
1965///
1966/// ```test_harness,no_run
1967/// extern crate hyper;
1968/// extern crate hyper_rustls;
1969/// extern crate google_calendar3 as calendar3;
1970///
1971/// # async fn dox() {
1972/// use calendar3::{CalendarHub, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
1973///
1974/// let secret: yup_oauth2::ApplicationSecret = Default::default();
1975/// let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
1976///     secret,
1977///     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
1978/// ).build().await.unwrap();
1979///
1980/// let client = hyper_util::client::legacy::Client::builder(
1981///     hyper_util::rt::TokioExecutor::new()
1982/// )
1983/// .build(
1984///     hyper_rustls::HttpsConnectorBuilder::new()
1985///         .with_native_roots()
1986///         .unwrap()
1987///         .https_or_http()
1988///         .enable_http1()
1989///         .build()
1990/// );
1991/// let mut hub = CalendarHub::new(client, auth);
1992/// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders*
1993/// // like `clear(...)`, `delete(...)`, `get(...)`, `insert(...)`, `patch(...)` and `update(...)`
1994/// // to build up your call.
1995/// let rb = hub.calendars();
1996/// # }
1997/// ```
1998pub struct CalendarMethods<'a, C>
1999where
2000    C: 'a,
2001{
2002    hub: &'a CalendarHub<C>,
2003}
2004
2005impl<'a, C> common::MethodsBuilder for CalendarMethods<'a, C> {}
2006
2007impl<'a, C> CalendarMethods<'a, C> {
2008    /// Create a builder to help you perform the following task:
2009    ///
2010    /// Clears a primary calendar. This operation deletes all events associated with the primary calendar of an account.
2011    ///
2012    /// # Arguments
2013    ///
2014    /// * `calendarId` - 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.
2015    pub fn clear(&self, calendar_id: &str) -> CalendarClearCall<'a, C> {
2016        CalendarClearCall {
2017            hub: self.hub,
2018            _calendar_id: calendar_id.to_string(),
2019            _delegate: Default::default(),
2020            _additional_params: Default::default(),
2021            _scopes: Default::default(),
2022        }
2023    }
2024
2025    /// Create a builder to help you perform the following task:
2026    ///
2027    /// Deletes a secondary calendar. Use calendars.clear for clearing all events on primary calendars.
2028    ///
2029    /// # Arguments
2030    ///
2031    /// * `calendarId` - 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.
2032    pub fn delete(&self, calendar_id: &str) -> CalendarDeleteCall<'a, C> {
2033        CalendarDeleteCall {
2034            hub: self.hub,
2035            _calendar_id: calendar_id.to_string(),
2036            _delegate: Default::default(),
2037            _additional_params: Default::default(),
2038            _scopes: Default::default(),
2039        }
2040    }
2041
2042    /// Create a builder to help you perform the following task:
2043    ///
2044    /// Returns metadata for a calendar.
2045    ///
2046    /// # Arguments
2047    ///
2048    /// * `calendarId` - 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.
2049    pub fn get(&self, calendar_id: &str) -> CalendarGetCall<'a, C> {
2050        CalendarGetCall {
2051            hub: self.hub,
2052            _calendar_id: calendar_id.to_string(),
2053            _delegate: Default::default(),
2054            _additional_params: Default::default(),
2055            _scopes: Default::default(),
2056        }
2057    }
2058
2059    /// Create a builder to help you perform the following task:
2060    ///
2061    /// Creates a secondary calendar.
2062    ///
2063    /// # Arguments
2064    ///
2065    /// * `request` - No description provided.
2066    pub fn insert(&self, request: Calendar) -> CalendarInsertCall<'a, C> {
2067        CalendarInsertCall {
2068            hub: self.hub,
2069            _request: request,
2070            _delegate: Default::default(),
2071            _additional_params: Default::default(),
2072            _scopes: Default::default(),
2073        }
2074    }
2075
2076    /// Create a builder to help you perform the following task:
2077    ///
2078    /// Updates metadata for a calendar. This method supports patch semantics.
2079    ///
2080    /// # Arguments
2081    ///
2082    /// * `request` - No description provided.
2083    /// * `calendarId` - 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.
2084    pub fn patch(&self, request: Calendar, calendar_id: &str) -> CalendarPatchCall<'a, C> {
2085        CalendarPatchCall {
2086            hub: self.hub,
2087            _request: request,
2088            _calendar_id: calendar_id.to_string(),
2089            _delegate: Default::default(),
2090            _additional_params: Default::default(),
2091            _scopes: Default::default(),
2092        }
2093    }
2094
2095    /// Create a builder to help you perform the following task:
2096    ///
2097    /// Updates metadata for a calendar.
2098    ///
2099    /// # Arguments
2100    ///
2101    /// * `request` - No description provided.
2102    /// * `calendarId` - 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.
2103    pub fn update(&self, request: Calendar, calendar_id: &str) -> CalendarUpdateCall<'a, C> {
2104        CalendarUpdateCall {
2105            hub: self.hub,
2106            _request: request,
2107            _calendar_id: calendar_id.to_string(),
2108            _delegate: Default::default(),
2109            _additional_params: Default::default(),
2110            _scopes: Default::default(),
2111        }
2112    }
2113}
2114
2115/// A builder providing access to all methods supported on *channel* resources.
2116/// It is not used directly, but through the [`CalendarHub`] hub.
2117///
2118/// # Example
2119///
2120/// Instantiate a resource builder
2121///
2122/// ```test_harness,no_run
2123/// extern crate hyper;
2124/// extern crate hyper_rustls;
2125/// extern crate google_calendar3 as calendar3;
2126///
2127/// # async fn dox() {
2128/// use calendar3::{CalendarHub, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
2129///
2130/// let secret: yup_oauth2::ApplicationSecret = Default::default();
2131/// let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
2132///     secret,
2133///     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
2134/// ).build().await.unwrap();
2135///
2136/// let client = hyper_util::client::legacy::Client::builder(
2137///     hyper_util::rt::TokioExecutor::new()
2138/// )
2139/// .build(
2140///     hyper_rustls::HttpsConnectorBuilder::new()
2141///         .with_native_roots()
2142///         .unwrap()
2143///         .https_or_http()
2144///         .enable_http1()
2145///         .build()
2146/// );
2147/// let mut hub = CalendarHub::new(client, auth);
2148/// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders*
2149/// // like `stop(...)`
2150/// // to build up your call.
2151/// let rb = hub.channels();
2152/// # }
2153/// ```
2154pub struct ChannelMethods<'a, C>
2155where
2156    C: 'a,
2157{
2158    hub: &'a CalendarHub<C>,
2159}
2160
2161impl<'a, C> common::MethodsBuilder for ChannelMethods<'a, C> {}
2162
2163impl<'a, C> ChannelMethods<'a, C> {
2164    /// Create a builder to help you perform the following task:
2165    ///
2166    /// Stop watching resources through this channel
2167    ///
2168    /// # Arguments
2169    ///
2170    /// * `request` - No description provided.
2171    pub fn stop(&self, request: Channel) -> ChannelStopCall<'a, C> {
2172        ChannelStopCall {
2173            hub: self.hub,
2174            _request: request,
2175            _delegate: Default::default(),
2176            _additional_params: Default::default(),
2177            _scopes: Default::default(),
2178        }
2179    }
2180}
2181
2182/// A builder providing access to all methods supported on *color* resources.
2183/// It is not used directly, but through the [`CalendarHub`] hub.
2184///
2185/// # Example
2186///
2187/// Instantiate a resource builder
2188///
2189/// ```test_harness,no_run
2190/// extern crate hyper;
2191/// extern crate hyper_rustls;
2192/// extern crate google_calendar3 as calendar3;
2193///
2194/// # async fn dox() {
2195/// use calendar3::{CalendarHub, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
2196///
2197/// let secret: yup_oauth2::ApplicationSecret = Default::default();
2198/// let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
2199///     secret,
2200///     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
2201/// ).build().await.unwrap();
2202///
2203/// let client = hyper_util::client::legacy::Client::builder(
2204///     hyper_util::rt::TokioExecutor::new()
2205/// )
2206/// .build(
2207///     hyper_rustls::HttpsConnectorBuilder::new()
2208///         .with_native_roots()
2209///         .unwrap()
2210///         .https_or_http()
2211///         .enable_http1()
2212///         .build()
2213/// );
2214/// let mut hub = CalendarHub::new(client, auth);
2215/// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders*
2216/// // like `get(...)`
2217/// // to build up your call.
2218/// let rb = hub.colors();
2219/// # }
2220/// ```
2221pub struct ColorMethods<'a, C>
2222where
2223    C: 'a,
2224{
2225    hub: &'a CalendarHub<C>,
2226}
2227
2228impl<'a, C> common::MethodsBuilder for ColorMethods<'a, C> {}
2229
2230impl<'a, C> ColorMethods<'a, C> {
2231    /// Create a builder to help you perform the following task:
2232    ///
2233    /// Returns the color definitions for calendars and events.
2234    pub fn get(&self) -> ColorGetCall<'a, C> {
2235        ColorGetCall {
2236            hub: self.hub,
2237            _delegate: Default::default(),
2238            _additional_params: Default::default(),
2239            _scopes: Default::default(),
2240        }
2241    }
2242}
2243
2244/// A builder providing access to all methods supported on *event* resources.
2245/// It is not used directly, but through the [`CalendarHub`] hub.
2246///
2247/// # Example
2248///
2249/// Instantiate a resource builder
2250///
2251/// ```test_harness,no_run
2252/// extern crate hyper;
2253/// extern crate hyper_rustls;
2254/// extern crate google_calendar3 as calendar3;
2255///
2256/// # async fn dox() {
2257/// use calendar3::{CalendarHub, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
2258///
2259/// let secret: yup_oauth2::ApplicationSecret = Default::default();
2260/// let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
2261///     secret,
2262///     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
2263/// ).build().await.unwrap();
2264///
2265/// let client = hyper_util::client::legacy::Client::builder(
2266///     hyper_util::rt::TokioExecutor::new()
2267/// )
2268/// .build(
2269///     hyper_rustls::HttpsConnectorBuilder::new()
2270///         .with_native_roots()
2271///         .unwrap()
2272///         .https_or_http()
2273///         .enable_http1()
2274///         .build()
2275/// );
2276/// let mut hub = CalendarHub::new(client, auth);
2277/// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders*
2278/// // like `delete(...)`, `get(...)`, `import(...)`, `insert(...)`, `instances(...)`, `list(...)`, `move_(...)`, `patch(...)`, `quick_add(...)`, `update(...)` and `watch(...)`
2279/// // to build up your call.
2280/// let rb = hub.events();
2281/// # }
2282/// ```
2283pub struct EventMethods<'a, C>
2284where
2285    C: 'a,
2286{
2287    hub: &'a CalendarHub<C>,
2288}
2289
2290impl<'a, C> common::MethodsBuilder for EventMethods<'a, C> {}
2291
2292impl<'a, C> EventMethods<'a, C> {
2293    /// Create a builder to help you perform the following task:
2294    ///
2295    /// Deletes an event.
2296    ///
2297    /// # Arguments
2298    ///
2299    /// * `calendarId` - 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.
2300    /// * `eventId` - Event identifier.
2301    pub fn delete(&self, calendar_id: &str, event_id: &str) -> EventDeleteCall<'a, C> {
2302        EventDeleteCall {
2303            hub: self.hub,
2304            _calendar_id: calendar_id.to_string(),
2305            _event_id: event_id.to_string(),
2306            _send_updates: Default::default(),
2307            _send_notifications: Default::default(),
2308            _delegate: Default::default(),
2309            _additional_params: Default::default(),
2310            _scopes: Default::default(),
2311        }
2312    }
2313
2314    /// Create a builder to help you perform the following task:
2315    ///
2316    /// Returns an event based on its Google Calendar ID. To retrieve an event using its iCalendar ID, call the events.list method using the iCalUID parameter.
2317    ///
2318    /// # Arguments
2319    ///
2320    /// * `calendarId` - 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.
2321    /// * `eventId` - Event identifier.
2322    pub fn get(&self, calendar_id: &str, event_id: &str) -> EventGetCall<'a, C> {
2323        EventGetCall {
2324            hub: self.hub,
2325            _calendar_id: calendar_id.to_string(),
2326            _event_id: event_id.to_string(),
2327            _time_zone: Default::default(),
2328            _max_attendees: Default::default(),
2329            _always_include_email: Default::default(),
2330            _delegate: Default::default(),
2331            _additional_params: Default::default(),
2332            _scopes: Default::default(),
2333        }
2334    }
2335
2336    /// Create a builder to help you perform the following task:
2337    ///
2338    /// Imports an event. This operation is used to add a private copy of an existing event to a calendar. Only events with an eventType of default may be imported.
2339    /// Deprecated behavior: If a non-default event is imported, its type will be changed to default and any event-type-specific properties it may have will be dropped.
2340    ///
2341    /// # Arguments
2342    ///
2343    /// * `request` - No description provided.
2344    /// * `calendarId` - 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.
2345    pub fn import(&self, request: Event, calendar_id: &str) -> EventImportCall<'a, C> {
2346        EventImportCall {
2347            hub: self.hub,
2348            _request: request,
2349            _calendar_id: calendar_id.to_string(),
2350            _supports_attachments: Default::default(),
2351            _conference_data_version: Default::default(),
2352            _delegate: Default::default(),
2353            _additional_params: Default::default(),
2354            _scopes: Default::default(),
2355        }
2356    }
2357
2358    /// Create a builder to help you perform the following task:
2359    ///
2360    /// Creates an event.
2361    ///
2362    /// # Arguments
2363    ///
2364    /// * `request` - No description provided.
2365    /// * `calendarId` - 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.
2366    pub fn insert(&self, request: Event, calendar_id: &str) -> EventInsertCall<'a, C> {
2367        EventInsertCall {
2368            hub: self.hub,
2369            _request: request,
2370            _calendar_id: calendar_id.to_string(),
2371            _supports_attachments: Default::default(),
2372            _send_updates: Default::default(),
2373            _send_notifications: Default::default(),
2374            _max_attendees: Default::default(),
2375            _conference_data_version: Default::default(),
2376            _delegate: Default::default(),
2377            _additional_params: Default::default(),
2378            _scopes: Default::default(),
2379        }
2380    }
2381
2382    /// Create a builder to help you perform the following task:
2383    ///
2384    /// Returns instances of the specified recurring event.
2385    ///
2386    /// # Arguments
2387    ///
2388    /// * `calendarId` - 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.
2389    /// * `eventId` - Recurring event identifier.
2390    pub fn instances(&self, calendar_id: &str, event_id: &str) -> EventInstanceCall<'a, C> {
2391        EventInstanceCall {
2392            hub: self.hub,
2393            _calendar_id: calendar_id.to_string(),
2394            _event_id: event_id.to_string(),
2395            _time_zone: Default::default(),
2396            _time_min: Default::default(),
2397            _time_max: Default::default(),
2398            _show_deleted: Default::default(),
2399            _page_token: Default::default(),
2400            _original_start: Default::default(),
2401            _max_results: Default::default(),
2402            _max_attendees: Default::default(),
2403            _always_include_email: Default::default(),
2404            _delegate: Default::default(),
2405            _additional_params: Default::default(),
2406            _scopes: Default::default(),
2407        }
2408    }
2409
2410    /// Create a builder to help you perform the following task:
2411    ///
2412    /// Returns events on the specified calendar.
2413    ///
2414    /// # Arguments
2415    ///
2416    /// * `calendarId` - 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.
2417    pub fn list(&self, calendar_id: &str) -> EventListCall<'a, C> {
2418        EventListCall {
2419            hub: self.hub,
2420            _calendar_id: calendar_id.to_string(),
2421            _updated_min: Default::default(),
2422            _time_zone: Default::default(),
2423            _time_min: Default::default(),
2424            _time_max: Default::default(),
2425            _sync_token: Default::default(),
2426            _single_events: Default::default(),
2427            _show_hidden_invitations: Default::default(),
2428            _show_deleted: Default::default(),
2429            _shared_extended_property: Default::default(),
2430            _q: Default::default(),
2431            _private_extended_property: Default::default(),
2432            _page_token: Default::default(),
2433            _order_by: Default::default(),
2434            _max_results: Default::default(),
2435            _max_attendees: Default::default(),
2436            _i_cal_uid: Default::default(),
2437            _event_types: Default::default(),
2438            _always_include_email: Default::default(),
2439            _delegate: Default::default(),
2440            _additional_params: Default::default(),
2441            _scopes: Default::default(),
2442        }
2443    }
2444
2445    /// Create a builder to help you perform the following task:
2446    ///
2447    /// Moves an event to another calendar, i.e. changes an event's organizer. Note that only default events can be moved; outOfOffice, focusTime, workingLocation and fromGmail events cannot be moved.
2448    ///
2449    /// # Arguments
2450    ///
2451    /// * `calendarId` - Calendar identifier of the source calendar where the event currently is on.
2452    /// * `eventId` - Event identifier.
2453    /// * `destination` - Calendar identifier of the target calendar where the event is to be moved to.
2454    pub fn move_(
2455        &self,
2456        calendar_id: &str,
2457        event_id: &str,
2458        destination: &str,
2459    ) -> EventMoveCall<'a, C> {
2460        EventMoveCall {
2461            hub: self.hub,
2462            _calendar_id: calendar_id.to_string(),
2463            _event_id: event_id.to_string(),
2464            _destination: destination.to_string(),
2465            _send_updates: Default::default(),
2466            _send_notifications: Default::default(),
2467            _delegate: Default::default(),
2468            _additional_params: Default::default(),
2469            _scopes: Default::default(),
2470        }
2471    }
2472
2473    /// Create a builder to help you perform the following task:
2474    ///
2475    /// Updates an event. This method supports patch semantics.
2476    ///
2477    /// # Arguments
2478    ///
2479    /// * `request` - No description provided.
2480    /// * `calendarId` - 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.
2481    /// * `eventId` - Event identifier.
2482    pub fn patch(
2483        &self,
2484        request: Event,
2485        calendar_id: &str,
2486        event_id: &str,
2487    ) -> EventPatchCall<'a, C> {
2488        EventPatchCall {
2489            hub: self.hub,
2490            _request: request,
2491            _calendar_id: calendar_id.to_string(),
2492            _event_id: event_id.to_string(),
2493            _supports_attachments: Default::default(),
2494            _send_updates: Default::default(),
2495            _send_notifications: Default::default(),
2496            _max_attendees: Default::default(),
2497            _conference_data_version: Default::default(),
2498            _always_include_email: Default::default(),
2499            _delegate: Default::default(),
2500            _additional_params: Default::default(),
2501            _scopes: Default::default(),
2502        }
2503    }
2504
2505    /// Create a builder to help you perform the following task:
2506    ///
2507    /// Creates an event based on a simple text string.
2508    ///
2509    /// # Arguments
2510    ///
2511    /// * `calendarId` - 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.
2512    /// * `text` - The text describing the event to be created.
2513    pub fn quick_add(&self, calendar_id: &str, text: &str) -> EventQuickAddCall<'a, C> {
2514        EventQuickAddCall {
2515            hub: self.hub,
2516            _calendar_id: calendar_id.to_string(),
2517            _text: text.to_string(),
2518            _send_updates: Default::default(),
2519            _send_notifications: Default::default(),
2520            _delegate: Default::default(),
2521            _additional_params: Default::default(),
2522            _scopes: Default::default(),
2523        }
2524    }
2525
2526    /// Create a builder to help you perform the following task:
2527    ///
2528    /// Updates an event.
2529    ///
2530    /// # Arguments
2531    ///
2532    /// * `request` - No description provided.
2533    /// * `calendarId` - 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.
2534    /// * `eventId` - Event identifier.
2535    pub fn update(
2536        &self,
2537        request: Event,
2538        calendar_id: &str,
2539        event_id: &str,
2540    ) -> EventUpdateCall<'a, C> {
2541        EventUpdateCall {
2542            hub: self.hub,
2543            _request: request,
2544            _calendar_id: calendar_id.to_string(),
2545            _event_id: event_id.to_string(),
2546            _supports_attachments: Default::default(),
2547            _send_updates: Default::default(),
2548            _send_notifications: Default::default(),
2549            _max_attendees: Default::default(),
2550            _conference_data_version: Default::default(),
2551            _always_include_email: Default::default(),
2552            _delegate: Default::default(),
2553            _additional_params: Default::default(),
2554            _scopes: Default::default(),
2555        }
2556    }
2557
2558    /// Create a builder to help you perform the following task:
2559    ///
2560    /// Watch for changes to Events resources.
2561    ///
2562    /// # Arguments
2563    ///
2564    /// * `request` - No description provided.
2565    /// * `calendarId` - 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.
2566    pub fn watch(&self, request: Channel, calendar_id: &str) -> EventWatchCall<'a, C> {
2567        EventWatchCall {
2568            hub: self.hub,
2569            _request: request,
2570            _calendar_id: calendar_id.to_string(),
2571            _updated_min: Default::default(),
2572            _time_zone: Default::default(),
2573            _time_min: Default::default(),
2574            _time_max: Default::default(),
2575            _sync_token: Default::default(),
2576            _single_events: Default::default(),
2577            _show_hidden_invitations: Default::default(),
2578            _show_deleted: Default::default(),
2579            _shared_extended_property: Default::default(),
2580            _q: Default::default(),
2581            _private_extended_property: Default::default(),
2582            _page_token: Default::default(),
2583            _order_by: Default::default(),
2584            _max_results: Default::default(),
2585            _max_attendees: Default::default(),
2586            _i_cal_uid: Default::default(),
2587            _event_types: Default::default(),
2588            _always_include_email: Default::default(),
2589            _delegate: Default::default(),
2590            _additional_params: Default::default(),
2591            _scopes: Default::default(),
2592        }
2593    }
2594}
2595
2596/// A builder providing access to all methods supported on *freebusy* resources.
2597/// It is not used directly, but through the [`CalendarHub`] hub.
2598///
2599/// # Example
2600///
2601/// Instantiate a resource builder
2602///
2603/// ```test_harness,no_run
2604/// extern crate hyper;
2605/// extern crate hyper_rustls;
2606/// extern crate google_calendar3 as calendar3;
2607///
2608/// # async fn dox() {
2609/// use calendar3::{CalendarHub, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
2610///
2611/// let secret: yup_oauth2::ApplicationSecret = Default::default();
2612/// let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
2613///     secret,
2614///     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
2615/// ).build().await.unwrap();
2616///
2617/// let client = hyper_util::client::legacy::Client::builder(
2618///     hyper_util::rt::TokioExecutor::new()
2619/// )
2620/// .build(
2621///     hyper_rustls::HttpsConnectorBuilder::new()
2622///         .with_native_roots()
2623///         .unwrap()
2624///         .https_or_http()
2625///         .enable_http1()
2626///         .build()
2627/// );
2628/// let mut hub = CalendarHub::new(client, auth);
2629/// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders*
2630/// // like `query(...)`
2631/// // to build up your call.
2632/// let rb = hub.freebusy();
2633/// # }
2634/// ```
2635pub struct FreebusyMethods<'a, C>
2636where
2637    C: 'a,
2638{
2639    hub: &'a CalendarHub<C>,
2640}
2641
2642impl<'a, C> common::MethodsBuilder for FreebusyMethods<'a, C> {}
2643
2644impl<'a, C> FreebusyMethods<'a, C> {
2645    /// Create a builder to help you perform the following task:
2646    ///
2647    /// Returns free/busy information for a set of calendars.
2648    ///
2649    /// # Arguments
2650    ///
2651    /// * `request` - No description provided.
2652    pub fn query(&self, request: FreeBusyRequest) -> FreebusyQueryCall<'a, C> {
2653        FreebusyQueryCall {
2654            hub: self.hub,
2655            _request: request,
2656            _delegate: Default::default(),
2657            _additional_params: Default::default(),
2658            _scopes: Default::default(),
2659        }
2660    }
2661}
2662
2663/// A builder providing access to all methods supported on *setting* resources.
2664/// It is not used directly, but through the [`CalendarHub`] hub.
2665///
2666/// # Example
2667///
2668/// Instantiate a resource builder
2669///
2670/// ```test_harness,no_run
2671/// extern crate hyper;
2672/// extern crate hyper_rustls;
2673/// extern crate google_calendar3 as calendar3;
2674///
2675/// # async fn dox() {
2676/// use calendar3::{CalendarHub, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
2677///
2678/// let secret: yup_oauth2::ApplicationSecret = Default::default();
2679/// let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
2680///     secret,
2681///     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
2682/// ).build().await.unwrap();
2683///
2684/// let client = hyper_util::client::legacy::Client::builder(
2685///     hyper_util::rt::TokioExecutor::new()
2686/// )
2687/// .build(
2688///     hyper_rustls::HttpsConnectorBuilder::new()
2689///         .with_native_roots()
2690///         .unwrap()
2691///         .https_or_http()
2692///         .enable_http1()
2693///         .build()
2694/// );
2695/// let mut hub = CalendarHub::new(client, auth);
2696/// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders*
2697/// // like `get(...)`, `list(...)` and `watch(...)`
2698/// // to build up your call.
2699/// let rb = hub.settings();
2700/// # }
2701/// ```
2702pub struct SettingMethods<'a, C>
2703where
2704    C: 'a,
2705{
2706    hub: &'a CalendarHub<C>,
2707}
2708
2709impl<'a, C> common::MethodsBuilder for SettingMethods<'a, C> {}
2710
2711impl<'a, C> SettingMethods<'a, C> {
2712    /// Create a builder to help you perform the following task:
2713    ///
2714    /// Returns a single user setting.
2715    ///
2716    /// # Arguments
2717    ///
2718    /// * `setting` - The id of the user setting.
2719    pub fn get(&self, setting: &str) -> SettingGetCall<'a, C> {
2720        SettingGetCall {
2721            hub: self.hub,
2722            _setting: setting.to_string(),
2723            _delegate: Default::default(),
2724            _additional_params: Default::default(),
2725            _scopes: Default::default(),
2726        }
2727    }
2728
2729    /// Create a builder to help you perform the following task:
2730    ///
2731    /// Returns all user settings for the authenticated user.
2732    pub fn list(&self) -> SettingListCall<'a, C> {
2733        SettingListCall {
2734            hub: self.hub,
2735            _sync_token: Default::default(),
2736            _page_token: Default::default(),
2737            _max_results: Default::default(),
2738            _delegate: Default::default(),
2739            _additional_params: Default::default(),
2740            _scopes: Default::default(),
2741        }
2742    }
2743
2744    /// Create a builder to help you perform the following task:
2745    ///
2746    /// Watch for changes to Settings resources.
2747    ///
2748    /// # Arguments
2749    ///
2750    /// * `request` - No description provided.
2751    pub fn watch(&self, request: Channel) -> SettingWatchCall<'a, C> {
2752        SettingWatchCall {
2753            hub: self.hub,
2754            _request: request,
2755            _sync_token: Default::default(),
2756            _page_token: Default::default(),
2757            _max_results: Default::default(),
2758            _delegate: Default::default(),
2759            _additional_params: Default::default(),
2760            _scopes: Default::default(),
2761        }
2762    }
2763}
2764
2765// ###################
2766// CallBuilders   ###
2767// #################
2768
2769/// Deletes an access control rule.
2770///
2771/// A builder for the *delete* method supported by a *acl* resource.
2772/// It is not used directly, but through a [`AclMethods`] instance.
2773///
2774/// # Example
2775///
2776/// Instantiate a resource method builder
2777///
2778/// ```test_harness,no_run
2779/// # extern crate hyper;
2780/// # extern crate hyper_rustls;
2781/// # extern crate google_calendar3 as calendar3;
2782/// # async fn dox() {
2783/// # use calendar3::{CalendarHub, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
2784///
2785/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
2786/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
2787/// #     secret,
2788/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
2789/// # ).build().await.unwrap();
2790///
2791/// # let client = hyper_util::client::legacy::Client::builder(
2792/// #     hyper_util::rt::TokioExecutor::new()
2793/// # )
2794/// # .build(
2795/// #     hyper_rustls::HttpsConnectorBuilder::new()
2796/// #         .with_native_roots()
2797/// #         .unwrap()
2798/// #         .https_or_http()
2799/// #         .enable_http1()
2800/// #         .build()
2801/// # );
2802/// # let mut hub = CalendarHub::new(client, auth);
2803/// // You can configure optional parameters by calling the respective setters at will, and
2804/// // execute the final call using `doit()`.
2805/// // Values shown here are possibly random and not representative !
2806/// let result = hub.acl().delete("calendarId", "ruleId")
2807///              .doit().await;
2808/// # }
2809/// ```
2810pub struct AclDeleteCall<'a, C>
2811where
2812    C: 'a,
2813{
2814    hub: &'a CalendarHub<C>,
2815    _calendar_id: String,
2816    _rule_id: String,
2817    _delegate: Option<&'a mut dyn common::Delegate>,
2818    _additional_params: HashMap<String, String>,
2819    _scopes: BTreeSet<String>,
2820}
2821
2822impl<'a, C> common::CallBuilder for AclDeleteCall<'a, C> {}
2823
2824impl<'a, C> AclDeleteCall<'a, C>
2825where
2826    C: common::Connector,
2827{
2828    /// Perform the operation you have build so far.
2829    pub async fn doit(mut self) -> common::Result<common::Response> {
2830        use std::borrow::Cow;
2831        use std::io::{Read, Seek};
2832
2833        use common::{url::Params, ToParts};
2834        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
2835
2836        let mut dd = common::DefaultDelegate;
2837        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
2838        dlg.begin(common::MethodInfo {
2839            id: "calendar.acl.delete",
2840            http_method: hyper::Method::DELETE,
2841        });
2842
2843        for &field in ["calendarId", "ruleId"].iter() {
2844            if self._additional_params.contains_key(field) {
2845                dlg.finished(false);
2846                return Err(common::Error::FieldClash(field));
2847            }
2848        }
2849
2850        let mut params = Params::with_capacity(3 + self._additional_params.len());
2851        params.push("calendarId", self._calendar_id);
2852        params.push("ruleId", self._rule_id);
2853
2854        params.extend(self._additional_params.iter());
2855
2856        let mut url = self.hub._base_url.clone() + "calendars/{calendarId}/acl/{ruleId}";
2857        if self._scopes.is_empty() {
2858            self._scopes.insert(Scope::Full.as_ref().to_string());
2859        }
2860
2861        #[allow(clippy::single_element_loop)]
2862        for &(find_this, param_name) in
2863            [("{calendarId}", "calendarId"), ("{ruleId}", "ruleId")].iter()
2864        {
2865            url = params.uri_replacement(url, param_name, find_this, false);
2866        }
2867        {
2868            let to_remove = ["ruleId", "calendarId"];
2869            params.remove_params(&to_remove);
2870        }
2871
2872        let url = params.parse_with_url(&url);
2873
2874        loop {
2875            let token = match self
2876                .hub
2877                .auth
2878                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
2879                .await
2880            {
2881                Ok(token) => token,
2882                Err(e) => match dlg.token(e) {
2883                    Ok(token) => token,
2884                    Err(e) => {
2885                        dlg.finished(false);
2886                        return Err(common::Error::MissingToken(e));
2887                    }
2888                },
2889            };
2890            let mut req_result = {
2891                let client = &self.hub.client;
2892                dlg.pre_request();
2893                let mut req_builder = hyper::Request::builder()
2894                    .method(hyper::Method::DELETE)
2895                    .uri(url.as_str())
2896                    .header(USER_AGENT, self.hub._user_agent.clone());
2897
2898                if let Some(token) = token.as_ref() {
2899                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
2900                }
2901
2902                let request = req_builder
2903                    .header(CONTENT_LENGTH, 0_u64)
2904                    .body(common::to_body::<String>(None));
2905
2906                client.request(request.unwrap()).await
2907            };
2908
2909            match req_result {
2910                Err(err) => {
2911                    if let common::Retry::After(d) = dlg.http_error(&err) {
2912                        sleep(d).await;
2913                        continue;
2914                    }
2915                    dlg.finished(false);
2916                    return Err(common::Error::HttpError(err));
2917                }
2918                Ok(res) => {
2919                    let (mut parts, body) = res.into_parts();
2920                    let mut body = common::Body::new(body);
2921                    if !parts.status.is_success() {
2922                        let bytes = common::to_bytes(body).await.unwrap_or_default();
2923                        let error = serde_json::from_str(&common::to_string(&bytes));
2924                        let response = common::to_response(parts, bytes.into());
2925
2926                        if let common::Retry::After(d) =
2927                            dlg.http_failure(&response, error.as_ref().ok())
2928                        {
2929                            sleep(d).await;
2930                            continue;
2931                        }
2932
2933                        dlg.finished(false);
2934
2935                        return Err(match error {
2936                            Ok(value) => common::Error::BadRequest(value),
2937                            _ => common::Error::Failure(response),
2938                        });
2939                    }
2940                    let response = common::Response::from_parts(parts, body);
2941
2942                    dlg.finished(true);
2943                    return Ok(response);
2944                }
2945            }
2946        }
2947    }
2948
2949    /// 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.
2950    ///
2951    /// Sets the *calendar id* path property to the given value.
2952    ///
2953    /// Even though the property as already been set when instantiating this call,
2954    /// we provide this method for API completeness.
2955    pub fn calendar_id(mut self, new_value: &str) -> AclDeleteCall<'a, C> {
2956        self._calendar_id = new_value.to_string();
2957        self
2958    }
2959    /// ACL rule identifier.
2960    ///
2961    /// Sets the *rule id* path property to the given value.
2962    ///
2963    /// Even though the property as already been set when instantiating this call,
2964    /// we provide this method for API completeness.
2965    pub fn rule_id(mut self, new_value: &str) -> AclDeleteCall<'a, C> {
2966        self._rule_id = new_value.to_string();
2967        self
2968    }
2969    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
2970    /// while executing the actual API request.
2971    ///
2972    /// ````text
2973    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
2974    /// ````
2975    ///
2976    /// Sets the *delegate* property to the given value.
2977    pub fn delegate(mut self, new_value: &'a mut dyn common::Delegate) -> AclDeleteCall<'a, C> {
2978        self._delegate = Some(new_value);
2979        self
2980    }
2981
2982    /// Set any additional parameter of the query string used in the request.
2983    /// It should be used to set parameters which are not yet available through their own
2984    /// setters.
2985    ///
2986    /// Please note that this method must not be used to set any of the known parameters
2987    /// which have their own setter method. If done anyway, the request will fail.
2988    ///
2989    /// # Additional Parameters
2990    ///
2991    /// * *alt* (query-string) - Data format for the response.
2992    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
2993    /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
2994    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
2995    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
2996    /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
2997    /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
2998    pub fn param<T>(mut self, name: T, value: T) -> AclDeleteCall<'a, C>
2999    where
3000        T: AsRef<str>,
3001    {
3002        self._additional_params
3003            .insert(name.as_ref().to_string(), value.as_ref().to_string());
3004        self
3005    }
3006
3007    /// Identifies the authorization scope for the method you are building.
3008    ///
3009    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
3010    /// [`Scope::Full`].
3011    ///
3012    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
3013    /// tokens for more than one scope.
3014    ///
3015    /// Usually there is more than one suitable scope to authorize an operation, some of which may
3016    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
3017    /// sufficient, a read-write scope will do as well.
3018    pub fn add_scope<St>(mut self, scope: St) -> AclDeleteCall<'a, C>
3019    where
3020        St: AsRef<str>,
3021    {
3022        self._scopes.insert(String::from(scope.as_ref()));
3023        self
3024    }
3025    /// Identifies the authorization scope(s) for the method you are building.
3026    ///
3027    /// See [`Self::add_scope()`] for details.
3028    pub fn add_scopes<I, St>(mut self, scopes: I) -> AclDeleteCall<'a, C>
3029    where
3030        I: IntoIterator<Item = St>,
3031        St: AsRef<str>,
3032    {
3033        self._scopes
3034            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
3035        self
3036    }
3037
3038    /// Removes all scopes, and no default scope will be used either.
3039    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
3040    /// for details).
3041    pub fn clear_scopes(mut self) -> AclDeleteCall<'a, C> {
3042        self._scopes.clear();
3043        self
3044    }
3045}
3046
3047/// Returns an access control rule.
3048///
3049/// A builder for the *get* method supported by a *acl* resource.
3050/// It is not used directly, but through a [`AclMethods`] instance.
3051///
3052/// # Example
3053///
3054/// Instantiate a resource method builder
3055///
3056/// ```test_harness,no_run
3057/// # extern crate hyper;
3058/// # extern crate hyper_rustls;
3059/// # extern crate google_calendar3 as calendar3;
3060/// # async fn dox() {
3061/// # use calendar3::{CalendarHub, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
3062///
3063/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
3064/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
3065/// #     secret,
3066/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
3067/// # ).build().await.unwrap();
3068///
3069/// # let client = hyper_util::client::legacy::Client::builder(
3070/// #     hyper_util::rt::TokioExecutor::new()
3071/// # )
3072/// # .build(
3073/// #     hyper_rustls::HttpsConnectorBuilder::new()
3074/// #         .with_native_roots()
3075/// #         .unwrap()
3076/// #         .https_or_http()
3077/// #         .enable_http1()
3078/// #         .build()
3079/// # );
3080/// # let mut hub = CalendarHub::new(client, auth);
3081/// // You can configure optional parameters by calling the respective setters at will, and
3082/// // execute the final call using `doit()`.
3083/// // Values shown here are possibly random and not representative !
3084/// let result = hub.acl().get("calendarId", "ruleId")
3085///              .doit().await;
3086/// # }
3087/// ```
3088pub struct AclGetCall<'a, C>
3089where
3090    C: 'a,
3091{
3092    hub: &'a CalendarHub<C>,
3093    _calendar_id: String,
3094    _rule_id: String,
3095    _delegate: Option<&'a mut dyn common::Delegate>,
3096    _additional_params: HashMap<String, String>,
3097    _scopes: BTreeSet<String>,
3098}
3099
3100impl<'a, C> common::CallBuilder for AclGetCall<'a, C> {}
3101
3102impl<'a, C> AclGetCall<'a, C>
3103where
3104    C: common::Connector,
3105{
3106    /// Perform the operation you have build so far.
3107    pub async fn doit(mut self) -> common::Result<(common::Response, AclRule)> {
3108        use std::borrow::Cow;
3109        use std::io::{Read, Seek};
3110
3111        use common::{url::Params, ToParts};
3112        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
3113
3114        let mut dd = common::DefaultDelegate;
3115        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
3116        dlg.begin(common::MethodInfo {
3117            id: "calendar.acl.get",
3118            http_method: hyper::Method::GET,
3119        });
3120
3121        for &field in ["alt", "calendarId", "ruleId"].iter() {
3122            if self._additional_params.contains_key(field) {
3123                dlg.finished(false);
3124                return Err(common::Error::FieldClash(field));
3125            }
3126        }
3127
3128        let mut params = Params::with_capacity(4 + self._additional_params.len());
3129        params.push("calendarId", self._calendar_id);
3130        params.push("ruleId", self._rule_id);
3131
3132        params.extend(self._additional_params.iter());
3133
3134        params.push("alt", "json");
3135        let mut url = self.hub._base_url.clone() + "calendars/{calendarId}/acl/{ruleId}";
3136        if self._scopes.is_empty() {
3137            self._scopes.insert(Scope::Readonly.as_ref().to_string());
3138        }
3139
3140        #[allow(clippy::single_element_loop)]
3141        for &(find_this, param_name) in
3142            [("{calendarId}", "calendarId"), ("{ruleId}", "ruleId")].iter()
3143        {
3144            url = params.uri_replacement(url, param_name, find_this, false);
3145        }
3146        {
3147            let to_remove = ["ruleId", "calendarId"];
3148            params.remove_params(&to_remove);
3149        }
3150
3151        let url = params.parse_with_url(&url);
3152
3153        loop {
3154            let token = match self
3155                .hub
3156                .auth
3157                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
3158                .await
3159            {
3160                Ok(token) => token,
3161                Err(e) => match dlg.token(e) {
3162                    Ok(token) => token,
3163                    Err(e) => {
3164                        dlg.finished(false);
3165                        return Err(common::Error::MissingToken(e));
3166                    }
3167                },
3168            };
3169            let mut req_result = {
3170                let client = &self.hub.client;
3171                dlg.pre_request();
3172                let mut req_builder = hyper::Request::builder()
3173                    .method(hyper::Method::GET)
3174                    .uri(url.as_str())
3175                    .header(USER_AGENT, self.hub._user_agent.clone());
3176
3177                if let Some(token) = token.as_ref() {
3178                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
3179                }
3180
3181                let request = req_builder
3182                    .header(CONTENT_LENGTH, 0_u64)
3183                    .body(common::to_body::<String>(None));
3184
3185                client.request(request.unwrap()).await
3186            };
3187
3188            match req_result {
3189                Err(err) => {
3190                    if let common::Retry::After(d) = dlg.http_error(&err) {
3191                        sleep(d).await;
3192                        continue;
3193                    }
3194                    dlg.finished(false);
3195                    return Err(common::Error::HttpError(err));
3196                }
3197                Ok(res) => {
3198                    let (mut parts, body) = res.into_parts();
3199                    let mut body = common::Body::new(body);
3200                    if !parts.status.is_success() {
3201                        let bytes = common::to_bytes(body).await.unwrap_or_default();
3202                        let error = serde_json::from_str(&common::to_string(&bytes));
3203                        let response = common::to_response(parts, bytes.into());
3204
3205                        if let common::Retry::After(d) =
3206                            dlg.http_failure(&response, error.as_ref().ok())
3207                        {
3208                            sleep(d).await;
3209                            continue;
3210                        }
3211
3212                        dlg.finished(false);
3213
3214                        return Err(match error {
3215                            Ok(value) => common::Error::BadRequest(value),
3216                            _ => common::Error::Failure(response),
3217                        });
3218                    }
3219                    let response = {
3220                        let bytes = common::to_bytes(body).await.unwrap_or_default();
3221                        let encoded = common::to_string(&bytes);
3222                        match serde_json::from_str(&encoded) {
3223                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
3224                            Err(error) => {
3225                                dlg.response_json_decode_error(&encoded, &error);
3226                                return Err(common::Error::JsonDecodeError(
3227                                    encoded.to_string(),
3228                                    error,
3229                                ));
3230                            }
3231                        }
3232                    };
3233
3234                    dlg.finished(true);
3235                    return Ok(response);
3236                }
3237            }
3238        }
3239    }
3240
3241    /// 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.
3242    ///
3243    /// Sets the *calendar id* path property to the given value.
3244    ///
3245    /// Even though the property as already been set when instantiating this call,
3246    /// we provide this method for API completeness.
3247    pub fn calendar_id(mut self, new_value: &str) -> AclGetCall<'a, C> {
3248        self._calendar_id = new_value.to_string();
3249        self
3250    }
3251    /// ACL rule identifier.
3252    ///
3253    /// Sets the *rule id* path property to the given value.
3254    ///
3255    /// Even though the property as already been set when instantiating this call,
3256    /// we provide this method for API completeness.
3257    pub fn rule_id(mut self, new_value: &str) -> AclGetCall<'a, C> {
3258        self._rule_id = new_value.to_string();
3259        self
3260    }
3261    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
3262    /// while executing the actual API request.
3263    ///
3264    /// ````text
3265    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
3266    /// ````
3267    ///
3268    /// Sets the *delegate* property to the given value.
3269    pub fn delegate(mut self, new_value: &'a mut dyn common::Delegate) -> AclGetCall<'a, C> {
3270        self._delegate = Some(new_value);
3271        self
3272    }
3273
3274    /// Set any additional parameter of the query string used in the request.
3275    /// It should be used to set parameters which are not yet available through their own
3276    /// setters.
3277    ///
3278    /// Please note that this method must not be used to set any of the known parameters
3279    /// which have their own setter method. If done anyway, the request will fail.
3280    ///
3281    /// # Additional Parameters
3282    ///
3283    /// * *alt* (query-string) - Data format for the response.
3284    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
3285    /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
3286    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
3287    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
3288    /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
3289    /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
3290    pub fn param<T>(mut self, name: T, value: T) -> AclGetCall<'a, C>
3291    where
3292        T: AsRef<str>,
3293    {
3294        self._additional_params
3295            .insert(name.as_ref().to_string(), value.as_ref().to_string());
3296        self
3297    }
3298
3299    /// Identifies the authorization scope for the method you are building.
3300    ///
3301    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
3302    /// [`Scope::Readonly`].
3303    ///
3304    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
3305    /// tokens for more than one scope.
3306    ///
3307    /// Usually there is more than one suitable scope to authorize an operation, some of which may
3308    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
3309    /// sufficient, a read-write scope will do as well.
3310    pub fn add_scope<St>(mut self, scope: St) -> AclGetCall<'a, C>
3311    where
3312        St: AsRef<str>,
3313    {
3314        self._scopes.insert(String::from(scope.as_ref()));
3315        self
3316    }
3317    /// Identifies the authorization scope(s) for the method you are building.
3318    ///
3319    /// See [`Self::add_scope()`] for details.
3320    pub fn add_scopes<I, St>(mut self, scopes: I) -> AclGetCall<'a, C>
3321    where
3322        I: IntoIterator<Item = St>,
3323        St: AsRef<str>,
3324    {
3325        self._scopes
3326            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
3327        self
3328    }
3329
3330    /// Removes all scopes, and no default scope will be used either.
3331    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
3332    /// for details).
3333    pub fn clear_scopes(mut self) -> AclGetCall<'a, C> {
3334        self._scopes.clear();
3335        self
3336    }
3337}
3338
3339/// Creates an access control rule.
3340///
3341/// A builder for the *insert* method supported by a *acl* resource.
3342/// It is not used directly, but through a [`AclMethods`] instance.
3343///
3344/// # Example
3345///
3346/// Instantiate a resource method builder
3347///
3348/// ```test_harness,no_run
3349/// # extern crate hyper;
3350/// # extern crate hyper_rustls;
3351/// # extern crate google_calendar3 as calendar3;
3352/// use calendar3::api::AclRule;
3353/// # async fn dox() {
3354/// # use calendar3::{CalendarHub, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
3355///
3356/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
3357/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
3358/// #     secret,
3359/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
3360/// # ).build().await.unwrap();
3361///
3362/// # let client = hyper_util::client::legacy::Client::builder(
3363/// #     hyper_util::rt::TokioExecutor::new()
3364/// # )
3365/// # .build(
3366/// #     hyper_rustls::HttpsConnectorBuilder::new()
3367/// #         .with_native_roots()
3368/// #         .unwrap()
3369/// #         .https_or_http()
3370/// #         .enable_http1()
3371/// #         .build()
3372/// # );
3373/// # let mut hub = CalendarHub::new(client, auth);
3374/// // As the method needs a request, you would usually fill it with the desired information
3375/// // into the respective structure. Some of the parts shown here might not be applicable !
3376/// // Values shown here are possibly random and not representative !
3377/// let mut req = AclRule::default();
3378///
3379/// // You can configure optional parameters by calling the respective setters at will, and
3380/// // execute the final call using `doit()`.
3381/// // Values shown here are possibly random and not representative !
3382/// let result = hub.acl().insert(req, "calendarId")
3383///              .send_notifications(false)
3384///              .doit().await;
3385/// # }
3386/// ```
3387pub struct AclInsertCall<'a, C>
3388where
3389    C: 'a,
3390{
3391    hub: &'a CalendarHub<C>,
3392    _request: AclRule,
3393    _calendar_id: String,
3394    _send_notifications: Option<bool>,
3395    _delegate: Option<&'a mut dyn common::Delegate>,
3396    _additional_params: HashMap<String, String>,
3397    _scopes: BTreeSet<String>,
3398}
3399
3400impl<'a, C> common::CallBuilder for AclInsertCall<'a, C> {}
3401
3402impl<'a, C> AclInsertCall<'a, C>
3403where
3404    C: common::Connector,
3405{
3406    /// Perform the operation you have build so far.
3407    pub async fn doit(mut self) -> common::Result<(common::Response, AclRule)> {
3408        use std::borrow::Cow;
3409        use std::io::{Read, Seek};
3410
3411        use common::{url::Params, ToParts};
3412        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
3413
3414        let mut dd = common::DefaultDelegate;
3415        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
3416        dlg.begin(common::MethodInfo {
3417            id: "calendar.acl.insert",
3418            http_method: hyper::Method::POST,
3419        });
3420
3421        for &field in ["alt", "calendarId", "sendNotifications"].iter() {
3422            if self._additional_params.contains_key(field) {
3423                dlg.finished(false);
3424                return Err(common::Error::FieldClash(field));
3425            }
3426        }
3427
3428        let mut params = Params::with_capacity(5 + self._additional_params.len());
3429        params.push("calendarId", self._calendar_id);
3430        if let Some(value) = self._send_notifications.as_ref() {
3431            params.push("sendNotifications", value.to_string());
3432        }
3433
3434        params.extend(self._additional_params.iter());
3435
3436        params.push("alt", "json");
3437        let mut url = self.hub._base_url.clone() + "calendars/{calendarId}/acl";
3438        if self._scopes.is_empty() {
3439            self._scopes.insert(Scope::Full.as_ref().to_string());
3440        }
3441
3442        #[allow(clippy::single_element_loop)]
3443        for &(find_this, param_name) in [("{calendarId}", "calendarId")].iter() {
3444            url = params.uri_replacement(url, param_name, find_this, false);
3445        }
3446        {
3447            let to_remove = ["calendarId"];
3448            params.remove_params(&to_remove);
3449        }
3450
3451        let url = params.parse_with_url(&url);
3452
3453        let mut json_mime_type = mime::APPLICATION_JSON;
3454        let mut request_value_reader = {
3455            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
3456            common::remove_json_null_values(&mut value);
3457            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
3458            serde_json::to_writer(&mut dst, &value).unwrap();
3459            dst
3460        };
3461        let request_size = request_value_reader
3462            .seek(std::io::SeekFrom::End(0))
3463            .unwrap();
3464        request_value_reader
3465            .seek(std::io::SeekFrom::Start(0))
3466            .unwrap();
3467
3468        loop {
3469            let token = match self
3470                .hub
3471                .auth
3472                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
3473                .await
3474            {
3475                Ok(token) => token,
3476                Err(e) => match dlg.token(e) {
3477                    Ok(token) => token,
3478                    Err(e) => {
3479                        dlg.finished(false);
3480                        return Err(common::Error::MissingToken(e));
3481                    }
3482                },
3483            };
3484            request_value_reader
3485                .seek(std::io::SeekFrom::Start(0))
3486                .unwrap();
3487            let mut req_result = {
3488                let client = &self.hub.client;
3489                dlg.pre_request();
3490                let mut req_builder = hyper::Request::builder()
3491                    .method(hyper::Method::POST)
3492                    .uri(url.as_str())
3493                    .header(USER_AGENT, self.hub._user_agent.clone());
3494
3495                if let Some(token) = token.as_ref() {
3496                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
3497                }
3498
3499                let request = req_builder
3500                    .header(CONTENT_TYPE, json_mime_type.to_string())
3501                    .header(CONTENT_LENGTH, request_size as u64)
3502                    .body(common::to_body(
3503                        request_value_reader.get_ref().clone().into(),
3504                    ));
3505
3506                client.request(request.unwrap()).await
3507            };
3508
3509            match req_result {
3510                Err(err) => {
3511                    if let common::Retry::After(d) = dlg.http_error(&err) {
3512                        sleep(d).await;
3513                        continue;
3514                    }
3515                    dlg.finished(false);
3516                    return Err(common::Error::HttpError(err));
3517                }
3518                Ok(res) => {
3519                    let (mut parts, body) = res.into_parts();
3520                    let mut body = common::Body::new(body);
3521                    if !parts.status.is_success() {
3522                        let bytes = common::to_bytes(body).await.unwrap_or_default();
3523                        let error = serde_json::from_str(&common::to_string(&bytes));
3524                        let response = common::to_response(parts, bytes.into());
3525
3526                        if let common::Retry::After(d) =
3527                            dlg.http_failure(&response, error.as_ref().ok())
3528                        {
3529                            sleep(d).await;
3530                            continue;
3531                        }
3532
3533                        dlg.finished(false);
3534
3535                        return Err(match error {
3536                            Ok(value) => common::Error::BadRequest(value),
3537                            _ => common::Error::Failure(response),
3538                        });
3539                    }
3540                    let response = {
3541                        let bytes = common::to_bytes(body).await.unwrap_or_default();
3542                        let encoded = common::to_string(&bytes);
3543                        match serde_json::from_str(&encoded) {
3544                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
3545                            Err(error) => {
3546                                dlg.response_json_decode_error(&encoded, &error);
3547                                return Err(common::Error::JsonDecodeError(
3548                                    encoded.to_string(),
3549                                    error,
3550                                ));
3551                            }
3552                        }
3553                    };
3554
3555                    dlg.finished(true);
3556                    return Ok(response);
3557                }
3558            }
3559        }
3560    }
3561
3562    ///
3563    /// Sets the *request* property to the given value.
3564    ///
3565    /// Even though the property as already been set when instantiating this call,
3566    /// we provide this method for API completeness.
3567    pub fn request(mut self, new_value: AclRule) -> AclInsertCall<'a, C> {
3568        self._request = new_value;
3569        self
3570    }
3571    /// 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.
3572    ///
3573    /// Sets the *calendar id* path property to the given value.
3574    ///
3575    /// Even though the property as already been set when instantiating this call,
3576    /// we provide this method for API completeness.
3577    pub fn calendar_id(mut self, new_value: &str) -> AclInsertCall<'a, C> {
3578        self._calendar_id = new_value.to_string();
3579        self
3580    }
3581    /// Whether to send notifications about the calendar sharing change. Optional. The default is True.
3582    ///
3583    /// Sets the *send notifications* query property to the given value.
3584    pub fn send_notifications(mut self, new_value: bool) -> AclInsertCall<'a, C> {
3585        self._send_notifications = Some(new_value);
3586        self
3587    }
3588    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
3589    /// while executing the actual API request.
3590    ///
3591    /// ````text
3592    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
3593    /// ````
3594    ///
3595    /// Sets the *delegate* property to the given value.
3596    pub fn delegate(mut self, new_value: &'a mut dyn common::Delegate) -> AclInsertCall<'a, C> {
3597        self._delegate = Some(new_value);
3598        self
3599    }
3600
3601    /// Set any additional parameter of the query string used in the request.
3602    /// It should be used to set parameters which are not yet available through their own
3603    /// setters.
3604    ///
3605    /// Please note that this method must not be used to set any of the known parameters
3606    /// which have their own setter method. If done anyway, the request will fail.
3607    ///
3608    /// # Additional Parameters
3609    ///
3610    /// * *alt* (query-string) - Data format for the response.
3611    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
3612    /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
3613    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
3614    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
3615    /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
3616    /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
3617    pub fn param<T>(mut self, name: T, value: T) -> AclInsertCall<'a, C>
3618    where
3619        T: AsRef<str>,
3620    {
3621        self._additional_params
3622            .insert(name.as_ref().to_string(), value.as_ref().to_string());
3623        self
3624    }
3625
3626    /// Identifies the authorization scope for the method you are building.
3627    ///
3628    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
3629    /// [`Scope::Full`].
3630    ///
3631    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
3632    /// tokens for more than one scope.
3633    ///
3634    /// Usually there is more than one suitable scope to authorize an operation, some of which may
3635    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
3636    /// sufficient, a read-write scope will do as well.
3637    pub fn add_scope<St>(mut self, scope: St) -> AclInsertCall<'a, C>
3638    where
3639        St: AsRef<str>,
3640    {
3641        self._scopes.insert(String::from(scope.as_ref()));
3642        self
3643    }
3644    /// Identifies the authorization scope(s) for the method you are building.
3645    ///
3646    /// See [`Self::add_scope()`] for details.
3647    pub fn add_scopes<I, St>(mut self, scopes: I) -> AclInsertCall<'a, C>
3648    where
3649        I: IntoIterator<Item = St>,
3650        St: AsRef<str>,
3651    {
3652        self._scopes
3653            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
3654        self
3655    }
3656
3657    /// Removes all scopes, and no default scope will be used either.
3658    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
3659    /// for details).
3660    pub fn clear_scopes(mut self) -> AclInsertCall<'a, C> {
3661        self._scopes.clear();
3662        self
3663    }
3664}
3665
3666/// Returns the rules in the access control list for the calendar.
3667///
3668/// A builder for the *list* method supported by a *acl* resource.
3669/// It is not used directly, but through a [`AclMethods`] instance.
3670///
3671/// # Example
3672///
3673/// Instantiate a resource method builder
3674///
3675/// ```test_harness,no_run
3676/// # extern crate hyper;
3677/// # extern crate hyper_rustls;
3678/// # extern crate google_calendar3 as calendar3;
3679/// # async fn dox() {
3680/// # use calendar3::{CalendarHub, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
3681///
3682/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
3683/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
3684/// #     secret,
3685/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
3686/// # ).build().await.unwrap();
3687///
3688/// # let client = hyper_util::client::legacy::Client::builder(
3689/// #     hyper_util::rt::TokioExecutor::new()
3690/// # )
3691/// # .build(
3692/// #     hyper_rustls::HttpsConnectorBuilder::new()
3693/// #         .with_native_roots()
3694/// #         .unwrap()
3695/// #         .https_or_http()
3696/// #         .enable_http1()
3697/// #         .build()
3698/// # );
3699/// # let mut hub = CalendarHub::new(client, auth);
3700/// // You can configure optional parameters by calling the respective setters at will, and
3701/// // execute the final call using `doit()`.
3702/// // Values shown here are possibly random and not representative !
3703/// let result = hub.acl().list("calendarId")
3704///              .sync_token("invidunt")
3705///              .show_deleted(true)
3706///              .page_token("vero")
3707///              .max_results(-44)
3708///              .doit().await;
3709/// # }
3710/// ```
3711pub struct AclListCall<'a, C>
3712where
3713    C: 'a,
3714{
3715    hub: &'a CalendarHub<C>,
3716    _calendar_id: String,
3717    _sync_token: Option<String>,
3718    _show_deleted: Option<bool>,
3719    _page_token: Option<String>,
3720    _max_results: Option<i32>,
3721    _delegate: Option<&'a mut dyn common::Delegate>,
3722    _additional_params: HashMap<String, String>,
3723    _scopes: BTreeSet<String>,
3724}
3725
3726impl<'a, C> common::CallBuilder for AclListCall<'a, C> {}
3727
3728impl<'a, C> AclListCall<'a, C>
3729where
3730    C: common::Connector,
3731{
3732    /// Perform the operation you have build so far.
3733    pub async fn doit(mut self) -> common::Result<(common::Response, Acl)> {
3734        use std::borrow::Cow;
3735        use std::io::{Read, Seek};
3736
3737        use common::{url::Params, ToParts};
3738        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
3739
3740        let mut dd = common::DefaultDelegate;
3741        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
3742        dlg.begin(common::MethodInfo {
3743            id: "calendar.acl.list",
3744            http_method: hyper::Method::GET,
3745        });
3746
3747        for &field in [
3748            "alt",
3749            "calendarId",
3750            "syncToken",
3751            "showDeleted",
3752            "pageToken",
3753            "maxResults",
3754        ]
3755        .iter()
3756        {
3757            if self._additional_params.contains_key(field) {
3758                dlg.finished(false);
3759                return Err(common::Error::FieldClash(field));
3760            }
3761        }
3762
3763        let mut params = Params::with_capacity(7 + self._additional_params.len());
3764        params.push("calendarId", self._calendar_id);
3765        if let Some(value) = self._sync_token.as_ref() {
3766            params.push("syncToken", value);
3767        }
3768        if let Some(value) = self._show_deleted.as_ref() {
3769            params.push("showDeleted", value.to_string());
3770        }
3771        if let Some(value) = self._page_token.as_ref() {
3772            params.push("pageToken", value);
3773        }
3774        if let Some(value) = self._max_results.as_ref() {
3775            params.push("maxResults", value.to_string());
3776        }
3777
3778        params.extend(self._additional_params.iter());
3779
3780        params.push("alt", "json");
3781        let mut url = self.hub._base_url.clone() + "calendars/{calendarId}/acl";
3782        if self._scopes.is_empty() {
3783            self._scopes.insert(Scope::Full.as_ref().to_string());
3784        }
3785
3786        #[allow(clippy::single_element_loop)]
3787        for &(find_this, param_name) in [("{calendarId}", "calendarId")].iter() {
3788            url = params.uri_replacement(url, param_name, find_this, false);
3789        }
3790        {
3791            let to_remove = ["calendarId"];
3792            params.remove_params(&to_remove);
3793        }
3794
3795        let url = params.parse_with_url(&url);
3796
3797        loop {
3798            let token = match self
3799                .hub
3800                .auth
3801                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
3802                .await
3803            {
3804                Ok(token) => token,
3805                Err(e) => match dlg.token(e) {
3806                    Ok(token) => token,
3807                    Err(e) => {
3808                        dlg.finished(false);
3809                        return Err(common::Error::MissingToken(e));
3810                    }
3811                },
3812            };
3813            let mut req_result = {
3814                let client = &self.hub.client;
3815                dlg.pre_request();
3816                let mut req_builder = hyper::Request::builder()
3817                    .method(hyper::Method::GET)
3818                    .uri(url.as_str())
3819                    .header(USER_AGENT, self.hub._user_agent.clone());
3820
3821                if let Some(token) = token.as_ref() {
3822                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
3823                }
3824
3825                let request = req_builder
3826                    .header(CONTENT_LENGTH, 0_u64)
3827                    .body(common::to_body::<String>(None));
3828
3829                client.request(request.unwrap()).await
3830            };
3831
3832            match req_result {
3833                Err(err) => {
3834                    if let common::Retry::After(d) = dlg.http_error(&err) {
3835                        sleep(d).await;
3836                        continue;
3837                    }
3838                    dlg.finished(false);
3839                    return Err(common::Error::HttpError(err));
3840                }
3841                Ok(res) => {
3842                    let (mut parts, body) = res.into_parts();
3843                    let mut body = common::Body::new(body);
3844                    if !parts.status.is_success() {
3845                        let bytes = common::to_bytes(body).await.unwrap_or_default();
3846                        let error = serde_json::from_str(&common::to_string(&bytes));
3847                        let response = common::to_response(parts, bytes.into());
3848
3849                        if let common::Retry::After(d) =
3850                            dlg.http_failure(&response, error.as_ref().ok())
3851                        {
3852                            sleep(d).await;
3853                            continue;
3854                        }
3855
3856                        dlg.finished(false);
3857
3858                        return Err(match error {
3859                            Ok(value) => common::Error::BadRequest(value),
3860                            _ => common::Error::Failure(response),
3861                        });
3862                    }
3863                    let response = {
3864                        let bytes = common::to_bytes(body).await.unwrap_or_default();
3865                        let encoded = common::to_string(&bytes);
3866                        match serde_json::from_str(&encoded) {
3867                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
3868                            Err(error) => {
3869                                dlg.response_json_decode_error(&encoded, &error);
3870                                return Err(common::Error::JsonDecodeError(
3871                                    encoded.to_string(),
3872                                    error,
3873                                ));
3874                            }
3875                        }
3876                    };
3877
3878                    dlg.finished(true);
3879                    return Ok(response);
3880                }
3881            }
3882        }
3883    }
3884
3885    /// 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.
3886    ///
3887    /// Sets the *calendar id* path property to the given value.
3888    ///
3889    /// Even though the property as already been set when instantiating this call,
3890    /// we provide this method for API completeness.
3891    pub fn calendar_id(mut self, new_value: &str) -> AclListCall<'a, C> {
3892        self._calendar_id = new_value.to_string();
3893        self
3894    }
3895    /// 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 entries deleted since the previous list request will always be in the result set and it is not allowed to set showDeleted to False.
3896    /// 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.
3897    /// Learn more about incremental synchronization.
3898    /// Optional. The default is to return all entries.
3899    ///
3900    /// Sets the *sync token* query property to the given value.
3901    pub fn sync_token(mut self, new_value: &str) -> AclListCall<'a, C> {
3902        self._sync_token = Some(new_value.to_string());
3903        self
3904    }
3905    /// Whether to include deleted ACLs in the result. Deleted ACLs are represented by role equal to "none". Deleted ACLs will always be included if syncToken is provided. Optional. The default is False.
3906    ///
3907    /// Sets the *show deleted* query property to the given value.
3908    pub fn show_deleted(mut self, new_value: bool) -> AclListCall<'a, C> {
3909        self._show_deleted = Some(new_value);
3910        self
3911    }
3912    /// Token specifying which result page to return. Optional.
3913    ///
3914    /// Sets the *page token* query property to the given value.
3915    pub fn page_token(mut self, new_value: &str) -> AclListCall<'a, C> {
3916        self._page_token = Some(new_value.to_string());
3917        self
3918    }
3919    /// Maximum number of entries returned on one result page. By default the value is 100 entries. The page size can never be larger than 250 entries. Optional.
3920    ///
3921    /// Sets the *max results* query property to the given value.
3922    pub fn max_results(mut self, new_value: i32) -> AclListCall<'a, C> {
3923        self._max_results = Some(new_value);
3924        self
3925    }
3926    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
3927    /// while executing the actual API request.
3928    ///
3929    /// ````text
3930    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
3931    /// ````
3932    ///
3933    /// Sets the *delegate* property to the given value.
3934    pub fn delegate(mut self, new_value: &'a mut dyn common::Delegate) -> AclListCall<'a, C> {
3935        self._delegate = Some(new_value);
3936        self
3937    }
3938
3939    /// Set any additional parameter of the query string used in the request.
3940    /// It should be used to set parameters which are not yet available through their own
3941    /// setters.
3942    ///
3943    /// Please note that this method must not be used to set any of the known parameters
3944    /// which have their own setter method. If done anyway, the request will fail.
3945    ///
3946    /// # Additional Parameters
3947    ///
3948    /// * *alt* (query-string) - Data format for the response.
3949    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
3950    /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
3951    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
3952    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
3953    /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
3954    /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
3955    pub fn param<T>(mut self, name: T, value: T) -> AclListCall<'a, C>
3956    where
3957        T: AsRef<str>,
3958    {
3959        self._additional_params
3960            .insert(name.as_ref().to_string(), value.as_ref().to_string());
3961        self
3962    }
3963
3964    /// Identifies the authorization scope for the method you are building.
3965    ///
3966    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
3967    /// [`Scope::Full`].
3968    ///
3969    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
3970    /// tokens for more than one scope.
3971    ///
3972    /// Usually there is more than one suitable scope to authorize an operation, some of which may
3973    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
3974    /// sufficient, a read-write scope will do as well.
3975    pub fn add_scope<St>(mut self, scope: St) -> AclListCall<'a, C>
3976    where
3977        St: AsRef<str>,
3978    {
3979        self._scopes.insert(String::from(scope.as_ref()));
3980        self
3981    }
3982    /// Identifies the authorization scope(s) for the method you are building.
3983    ///
3984    /// See [`Self::add_scope()`] for details.
3985    pub fn add_scopes<I, St>(mut self, scopes: I) -> AclListCall<'a, C>
3986    where
3987        I: IntoIterator<Item = St>,
3988        St: AsRef<str>,
3989    {
3990        self._scopes
3991            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
3992        self
3993    }
3994
3995    /// Removes all scopes, and no default scope will be used either.
3996    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
3997    /// for details).
3998    pub fn clear_scopes(mut self) -> AclListCall<'a, C> {
3999        self._scopes.clear();
4000        self
4001    }
4002}
4003
4004/// Updates an access control rule. This method supports patch semantics.
4005///
4006/// A builder for the *patch* method supported by a *acl* resource.
4007/// It is not used directly, but through a [`AclMethods`] instance.
4008///
4009/// # Example
4010///
4011/// Instantiate a resource method builder
4012///
4013/// ```test_harness,no_run
4014/// # extern crate hyper;
4015/// # extern crate hyper_rustls;
4016/// # extern crate google_calendar3 as calendar3;
4017/// use calendar3::api::AclRule;
4018/// # async fn dox() {
4019/// # use calendar3::{CalendarHub, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
4020///
4021/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
4022/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
4023/// #     secret,
4024/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
4025/// # ).build().await.unwrap();
4026///
4027/// # let client = hyper_util::client::legacy::Client::builder(
4028/// #     hyper_util::rt::TokioExecutor::new()
4029/// # )
4030/// # .build(
4031/// #     hyper_rustls::HttpsConnectorBuilder::new()
4032/// #         .with_native_roots()
4033/// #         .unwrap()
4034/// #         .https_or_http()
4035/// #         .enable_http1()
4036/// #         .build()
4037/// # );
4038/// # let mut hub = CalendarHub::new(client, auth);
4039/// // As the method needs a request, you would usually fill it with the desired information
4040/// // into the respective structure. Some of the parts shown here might not be applicable !
4041/// // Values shown here are possibly random and not representative !
4042/// let mut req = AclRule::default();
4043///
4044/// // You can configure optional parameters by calling the respective setters at will, and
4045/// // execute the final call using `doit()`.
4046/// // Values shown here are possibly random and not representative !
4047/// let result = hub.acl().patch(req, "calendarId", "ruleId")
4048///              .send_notifications(true)
4049///              .doit().await;
4050/// # }
4051/// ```
4052pub struct AclPatchCall<'a, C>
4053where
4054    C: 'a,
4055{
4056    hub: &'a CalendarHub<C>,
4057    _request: AclRule,
4058    _calendar_id: String,
4059    _rule_id: String,
4060    _send_notifications: Option<bool>,
4061    _delegate: Option<&'a mut dyn common::Delegate>,
4062    _additional_params: HashMap<String, String>,
4063    _scopes: BTreeSet<String>,
4064}
4065
4066impl<'a, C> common::CallBuilder for AclPatchCall<'a, C> {}
4067
4068impl<'a, C> AclPatchCall<'a, C>
4069where
4070    C: common::Connector,
4071{
4072    /// Perform the operation you have build so far.
4073    pub async fn doit(mut self) -> common::Result<(common::Response, AclRule)> {
4074        use std::borrow::Cow;
4075        use std::io::{Read, Seek};
4076
4077        use common::{url::Params, ToParts};
4078        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
4079
4080        let mut dd = common::DefaultDelegate;
4081        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
4082        dlg.begin(common::MethodInfo {
4083            id: "calendar.acl.patch",
4084            http_method: hyper::Method::PATCH,
4085        });
4086
4087        for &field in ["alt", "calendarId", "ruleId", "sendNotifications"].iter() {
4088            if self._additional_params.contains_key(field) {
4089                dlg.finished(false);
4090                return Err(common::Error::FieldClash(field));
4091            }
4092        }
4093
4094        let mut params = Params::with_capacity(6 + self._additional_params.len());
4095        params.push("calendarId", self._calendar_id);
4096        params.push("ruleId", self._rule_id);
4097        if let Some(value) = self._send_notifications.as_ref() {
4098            params.push("sendNotifications", value.to_string());
4099        }
4100
4101        params.extend(self._additional_params.iter());
4102
4103        params.push("alt", "json");
4104        let mut url = self.hub._base_url.clone() + "calendars/{calendarId}/acl/{ruleId}";
4105        if self._scopes.is_empty() {
4106            self._scopes.insert(Scope::Full.as_ref().to_string());
4107        }
4108
4109        #[allow(clippy::single_element_loop)]
4110        for &(find_this, param_name) in
4111            [("{calendarId}", "calendarId"), ("{ruleId}", "ruleId")].iter()
4112        {
4113            url = params.uri_replacement(url, param_name, find_this, false);
4114        }
4115        {
4116            let to_remove = ["ruleId", "calendarId"];
4117            params.remove_params(&to_remove);
4118        }
4119
4120        let url = params.parse_with_url(&url);
4121
4122        let mut json_mime_type = mime::APPLICATION_JSON;
4123        let mut request_value_reader = {
4124            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
4125            common::remove_json_null_values(&mut value);
4126            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
4127            serde_json::to_writer(&mut dst, &value).unwrap();
4128            dst
4129        };
4130        let request_size = request_value_reader
4131            .seek(std::io::SeekFrom::End(0))
4132            .unwrap();
4133        request_value_reader
4134            .seek(std::io::SeekFrom::Start(0))
4135            .unwrap();
4136
4137        loop {
4138            let token = match self
4139                .hub
4140                .auth
4141                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
4142                .await
4143            {
4144                Ok(token) => token,
4145                Err(e) => match dlg.token(e) {
4146                    Ok(token) => token,
4147                    Err(e) => {
4148                        dlg.finished(false);
4149                        return Err(common::Error::MissingToken(e));
4150                    }
4151                },
4152            };
4153            request_value_reader
4154                .seek(std::io::SeekFrom::Start(0))
4155                .unwrap();
4156            let mut req_result = {
4157                let client = &self.hub.client;
4158                dlg.pre_request();
4159                let mut req_builder = hyper::Request::builder()
4160                    .method(hyper::Method::PATCH)
4161                    .uri(url.as_str())
4162                    .header(USER_AGENT, self.hub._user_agent.clone());
4163
4164                if let Some(token) = token.as_ref() {
4165                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
4166                }
4167
4168                let request = req_builder
4169                    .header(CONTENT_TYPE, json_mime_type.to_string())
4170                    .header(CONTENT_LENGTH, request_size as u64)
4171                    .body(common::to_body(
4172                        request_value_reader.get_ref().clone().into(),
4173                    ));
4174
4175                client.request(request.unwrap()).await
4176            };
4177
4178            match req_result {
4179                Err(err) => {
4180                    if let common::Retry::After(d) = dlg.http_error(&err) {
4181                        sleep(d).await;
4182                        continue;
4183                    }
4184                    dlg.finished(false);
4185                    return Err(common::Error::HttpError(err));
4186                }
4187                Ok(res) => {
4188                    let (mut parts, body) = res.into_parts();
4189                    let mut body = common::Body::new(body);
4190                    if !parts.status.is_success() {
4191                        let bytes = common::to_bytes(body).await.unwrap_or_default();
4192                        let error = serde_json::from_str(&common::to_string(&bytes));
4193                        let response = common::to_response(parts, bytes.into());
4194
4195                        if let common::Retry::After(d) =
4196                            dlg.http_failure(&response, error.as_ref().ok())
4197                        {
4198                            sleep(d).await;
4199                            continue;
4200                        }
4201
4202                        dlg.finished(false);
4203
4204                        return Err(match error {
4205                            Ok(value) => common::Error::BadRequest(value),
4206                            _ => common::Error::Failure(response),
4207                        });
4208                    }
4209                    let response = {
4210                        let bytes = common::to_bytes(body).await.unwrap_or_default();
4211                        let encoded = common::to_string(&bytes);
4212                        match serde_json::from_str(&encoded) {
4213                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
4214                            Err(error) => {
4215                                dlg.response_json_decode_error(&encoded, &error);
4216                                return Err(common::Error::JsonDecodeError(
4217                                    encoded.to_string(),
4218                                    error,
4219                                ));
4220                            }
4221                        }
4222                    };
4223
4224                    dlg.finished(true);
4225                    return Ok(response);
4226                }
4227            }
4228        }
4229    }
4230
4231    ///
4232    /// Sets the *request* property to the given value.
4233    ///
4234    /// Even though the property as already been set when instantiating this call,
4235    /// we provide this method for API completeness.
4236    pub fn request(mut self, new_value: AclRule) -> AclPatchCall<'a, C> {
4237        self._request = new_value;
4238        self
4239    }
4240    /// 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.
4241    ///
4242    /// Sets the *calendar id* path property to the given value.
4243    ///
4244    /// Even though the property as already been set when instantiating this call,
4245    /// we provide this method for API completeness.
4246    pub fn calendar_id(mut self, new_value: &str) -> AclPatchCall<'a, C> {
4247        self._calendar_id = new_value.to_string();
4248        self
4249    }
4250    /// ACL rule identifier.
4251    ///
4252    /// Sets the *rule id* path property to the given value.
4253    ///
4254    /// Even though the property as already been set when instantiating this call,
4255    /// we provide this method for API completeness.
4256    pub fn rule_id(mut self, new_value: &str) -> AclPatchCall<'a, C> {
4257        self._rule_id = new_value.to_string();
4258        self
4259    }
4260    /// Whether to send notifications about the calendar sharing change. Note that there are no notifications on access removal. Optional. The default is True.
4261    ///
4262    /// Sets the *send notifications* query property to the given value.
4263    pub fn send_notifications(mut self, new_value: bool) -> AclPatchCall<'a, C> {
4264        self._send_notifications = Some(new_value);
4265        self
4266    }
4267    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
4268    /// while executing the actual API request.
4269    ///
4270    /// ````text
4271    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
4272    /// ````
4273    ///
4274    /// Sets the *delegate* property to the given value.
4275    pub fn delegate(mut self, new_value: &'a mut dyn common::Delegate) -> AclPatchCall<'a, C> {
4276        self._delegate = Some(new_value);
4277        self
4278    }
4279
4280    /// Set any additional parameter of the query string used in the request.
4281    /// It should be used to set parameters which are not yet available through their own
4282    /// setters.
4283    ///
4284    /// Please note that this method must not be used to set any of the known parameters
4285    /// which have their own setter method. If done anyway, the request will fail.
4286    ///
4287    /// # Additional Parameters
4288    ///
4289    /// * *alt* (query-string) - Data format for the response.
4290    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
4291    /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
4292    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
4293    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
4294    /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
4295    /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
4296    pub fn param<T>(mut self, name: T, value: T) -> AclPatchCall<'a, C>
4297    where
4298        T: AsRef<str>,
4299    {
4300        self._additional_params
4301            .insert(name.as_ref().to_string(), value.as_ref().to_string());
4302        self
4303    }
4304
4305    /// Identifies the authorization scope for the method you are building.
4306    ///
4307    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
4308    /// [`Scope::Full`].
4309    ///
4310    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
4311    /// tokens for more than one scope.
4312    ///
4313    /// Usually there is more than one suitable scope to authorize an operation, some of which may
4314    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
4315    /// sufficient, a read-write scope will do as well.
4316    pub fn add_scope<St>(mut self, scope: St) -> AclPatchCall<'a, C>
4317    where
4318        St: AsRef<str>,
4319    {
4320        self._scopes.insert(String::from(scope.as_ref()));
4321        self
4322    }
4323    /// Identifies the authorization scope(s) for the method you are building.
4324    ///
4325    /// See [`Self::add_scope()`] for details.
4326    pub fn add_scopes<I, St>(mut self, scopes: I) -> AclPatchCall<'a, C>
4327    where
4328        I: IntoIterator<Item = St>,
4329        St: AsRef<str>,
4330    {
4331        self._scopes
4332            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
4333        self
4334    }
4335
4336    /// Removes all scopes, and no default scope will be used either.
4337    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
4338    /// for details).
4339    pub fn clear_scopes(mut self) -> AclPatchCall<'a, C> {
4340        self._scopes.clear();
4341        self
4342    }
4343}
4344
4345/// Updates an access control rule.
4346///
4347/// A builder for the *update* method supported by a *acl* resource.
4348/// It is not used directly, but through a [`AclMethods`] instance.
4349///
4350/// # Example
4351///
4352/// Instantiate a resource method builder
4353///
4354/// ```test_harness,no_run
4355/// # extern crate hyper;
4356/// # extern crate hyper_rustls;
4357/// # extern crate google_calendar3 as calendar3;
4358/// use calendar3::api::AclRule;
4359/// # async fn dox() {
4360/// # use calendar3::{CalendarHub, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
4361///
4362/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
4363/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
4364/// #     secret,
4365/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
4366/// # ).build().await.unwrap();
4367///
4368/// # let client = hyper_util::client::legacy::Client::builder(
4369/// #     hyper_util::rt::TokioExecutor::new()
4370/// # )
4371/// # .build(
4372/// #     hyper_rustls::HttpsConnectorBuilder::new()
4373/// #         .with_native_roots()
4374/// #         .unwrap()
4375/// #         .https_or_http()
4376/// #         .enable_http1()
4377/// #         .build()
4378/// # );
4379/// # let mut hub = CalendarHub::new(client, auth);
4380/// // As the method needs a request, you would usually fill it with the desired information
4381/// // into the respective structure. Some of the parts shown here might not be applicable !
4382/// // Values shown here are possibly random and not representative !
4383/// let mut req = AclRule::default();
4384///
4385/// // You can configure optional parameters by calling the respective setters at will, and
4386/// // execute the final call using `doit()`.
4387/// // Values shown here are possibly random and not representative !
4388/// let result = hub.acl().update(req, "calendarId", "ruleId")
4389///              .send_notifications(true)
4390///              .doit().await;
4391/// # }
4392/// ```
4393pub struct AclUpdateCall<'a, C>
4394where
4395    C: 'a,
4396{
4397    hub: &'a CalendarHub<C>,
4398    _request: AclRule,
4399    _calendar_id: String,
4400    _rule_id: String,
4401    _send_notifications: Option<bool>,
4402    _delegate: Option<&'a mut dyn common::Delegate>,
4403    _additional_params: HashMap<String, String>,
4404    _scopes: BTreeSet<String>,
4405}
4406
4407impl<'a, C> common::CallBuilder for AclUpdateCall<'a, C> {}
4408
4409impl<'a, C> AclUpdateCall<'a, C>
4410where
4411    C: common::Connector,
4412{
4413    /// Perform the operation you have build so far.
4414    pub async fn doit(mut self) -> common::Result<(common::Response, AclRule)> {
4415        use std::borrow::Cow;
4416        use std::io::{Read, Seek};
4417
4418        use common::{url::Params, ToParts};
4419        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
4420
4421        let mut dd = common::DefaultDelegate;
4422        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
4423        dlg.begin(common::MethodInfo {
4424            id: "calendar.acl.update",
4425            http_method: hyper::Method::PUT,
4426        });
4427
4428        for &field in ["alt", "calendarId", "ruleId", "sendNotifications"].iter() {
4429            if self._additional_params.contains_key(field) {
4430                dlg.finished(false);
4431                return Err(common::Error::FieldClash(field));
4432            }
4433        }
4434
4435        let mut params = Params::with_capacity(6 + self._additional_params.len());
4436        params.push("calendarId", self._calendar_id);
4437        params.push("ruleId", self._rule_id);
4438        if let Some(value) = self._send_notifications.as_ref() {
4439            params.push("sendNotifications", value.to_string());
4440        }
4441
4442        params.extend(self._additional_params.iter());
4443
4444        params.push("alt", "json");
4445        let mut url = self.hub._base_url.clone() + "calendars/{calendarId}/acl/{ruleId}";
4446        if self._scopes.is_empty() {
4447            self._scopes.insert(Scope::Full.as_ref().to_string());
4448        }
4449
4450        #[allow(clippy::single_element_loop)]
4451        for &(find_this, param_name) in
4452            [("{calendarId}", "calendarId"), ("{ruleId}", "ruleId")].iter()
4453        {
4454            url = params.uri_replacement(url, param_name, find_this, false);
4455        }
4456        {
4457            let to_remove = ["ruleId", "calendarId"];
4458            params.remove_params(&to_remove);
4459        }
4460
4461        let url = params.parse_with_url(&url);
4462
4463        let mut json_mime_type = mime::APPLICATION_JSON;
4464        let mut request_value_reader = {
4465            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
4466            common::remove_json_null_values(&mut value);
4467            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
4468            serde_json::to_writer(&mut dst, &value).unwrap();
4469            dst
4470        };
4471        let request_size = request_value_reader
4472            .seek(std::io::SeekFrom::End(0))
4473            .unwrap();
4474        request_value_reader
4475            .seek(std::io::SeekFrom::Start(0))
4476            .unwrap();
4477
4478        loop {
4479            let token = match self
4480                .hub
4481                .auth
4482                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
4483                .await
4484            {
4485                Ok(token) => token,
4486                Err(e) => match dlg.token(e) {
4487                    Ok(token) => token,
4488                    Err(e) => {
4489                        dlg.finished(false);
4490                        return Err(common::Error::MissingToken(e));
4491                    }
4492                },
4493            };
4494            request_value_reader
4495                .seek(std::io::SeekFrom::Start(0))
4496                .unwrap();
4497            let mut req_result = {
4498                let client = &self.hub.client;
4499                dlg.pre_request();
4500                let mut req_builder = hyper::Request::builder()
4501                    .method(hyper::Method::PUT)
4502                    .uri(url.as_str())
4503                    .header(USER_AGENT, self.hub._user_agent.clone());
4504
4505                if let Some(token) = token.as_ref() {
4506                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
4507                }
4508
4509                let request = req_builder
4510                    .header(CONTENT_TYPE, json_mime_type.to_string())
4511                    .header(CONTENT_LENGTH, request_size as u64)
4512                    .body(common::to_body(
4513                        request_value_reader.get_ref().clone().into(),
4514                    ));
4515
4516                client.request(request.unwrap()).await
4517            };
4518
4519            match req_result {
4520                Err(err) => {
4521                    if let common::Retry::After(d) = dlg.http_error(&err) {
4522                        sleep(d).await;
4523                        continue;
4524                    }
4525                    dlg.finished(false);
4526                    return Err(common::Error::HttpError(err));
4527                }
4528                Ok(res) => {
4529                    let (mut parts, body) = res.into_parts();
4530                    let mut body = common::Body::new(body);
4531                    if !parts.status.is_success() {
4532                        let bytes = common::to_bytes(body).await.unwrap_or_default();
4533                        let error = serde_json::from_str(&common::to_string(&bytes));
4534                        let response = common::to_response(parts, bytes.into());
4535
4536                        if let common::Retry::After(d) =
4537                            dlg.http_failure(&response, error.as_ref().ok())
4538                        {
4539                            sleep(d).await;
4540                            continue;
4541                        }
4542
4543                        dlg.finished(false);
4544
4545                        return Err(match error {
4546                            Ok(value) => common::Error::BadRequest(value),
4547                            _ => common::Error::Failure(response),
4548                        });
4549                    }
4550                    let response = {
4551                        let bytes = common::to_bytes(body).await.unwrap_or_default();
4552                        let encoded = common::to_string(&bytes);
4553                        match serde_json::from_str(&encoded) {
4554                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
4555                            Err(error) => {
4556                                dlg.response_json_decode_error(&encoded, &error);
4557                                return Err(common::Error::JsonDecodeError(
4558                                    encoded.to_string(),
4559                                    error,
4560                                ));
4561                            }
4562                        }
4563                    };
4564
4565                    dlg.finished(true);
4566                    return Ok(response);
4567                }
4568            }
4569        }
4570    }
4571
4572    ///
4573    /// Sets the *request* property to the given value.
4574    ///
4575    /// Even though the property as already been set when instantiating this call,
4576    /// we provide this method for API completeness.
4577    pub fn request(mut self, new_value: AclRule) -> AclUpdateCall<'a, C> {
4578        self._request = new_value;
4579        self
4580    }
4581    /// 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.
4582    ///
4583    /// Sets the *calendar id* path property to the given value.
4584    ///
4585    /// Even though the property as already been set when instantiating this call,
4586    /// we provide this method for API completeness.
4587    pub fn calendar_id(mut self, new_value: &str) -> AclUpdateCall<'a, C> {
4588        self._calendar_id = new_value.to_string();
4589        self
4590    }
4591    /// ACL rule identifier.
4592    ///
4593    /// Sets the *rule id* path property to the given value.
4594    ///
4595    /// Even though the property as already been set when instantiating this call,
4596    /// we provide this method for API completeness.
4597    pub fn rule_id(mut self, new_value: &str) -> AclUpdateCall<'a, C> {
4598        self._rule_id = new_value.to_string();
4599        self
4600    }
4601    /// Whether to send notifications about the calendar sharing change. Note that there are no notifications on access removal. Optional. The default is True.
4602    ///
4603    /// Sets the *send notifications* query property to the given value.
4604    pub fn send_notifications(mut self, new_value: bool) -> AclUpdateCall<'a, C> {
4605        self._send_notifications = Some(new_value);
4606        self
4607    }
4608    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
4609    /// while executing the actual API request.
4610    ///
4611    /// ````text
4612    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
4613    /// ````
4614    ///
4615    /// Sets the *delegate* property to the given value.
4616    pub fn delegate(mut self, new_value: &'a mut dyn common::Delegate) -> AclUpdateCall<'a, C> {
4617        self._delegate = Some(new_value);
4618        self
4619    }
4620
4621    /// Set any additional parameter of the query string used in the request.
4622    /// It should be used to set parameters which are not yet available through their own
4623    /// setters.
4624    ///
4625    /// Please note that this method must not be used to set any of the known parameters
4626    /// which have their own setter method. If done anyway, the request will fail.
4627    ///
4628    /// # Additional Parameters
4629    ///
4630    /// * *alt* (query-string) - Data format for the response.
4631    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
4632    /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
4633    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
4634    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
4635    /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
4636    /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
4637    pub fn param<T>(mut self, name: T, value: T) -> AclUpdateCall<'a, C>
4638    where
4639        T: AsRef<str>,
4640    {
4641        self._additional_params
4642            .insert(name.as_ref().to_string(), value.as_ref().to_string());
4643        self
4644    }
4645
4646    /// Identifies the authorization scope for the method you are building.
4647    ///
4648    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
4649    /// [`Scope::Full`].
4650    ///
4651    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
4652    /// tokens for more than one scope.
4653    ///
4654    /// Usually there is more than one suitable scope to authorize an operation, some of which may
4655    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
4656    /// sufficient, a read-write scope will do as well.
4657    pub fn add_scope<St>(mut self, scope: St) -> AclUpdateCall<'a, C>
4658    where
4659        St: AsRef<str>,
4660    {
4661        self._scopes.insert(String::from(scope.as_ref()));
4662        self
4663    }
4664    /// Identifies the authorization scope(s) for the method you are building.
4665    ///
4666    /// See [`Self::add_scope()`] for details.
4667    pub fn add_scopes<I, St>(mut self, scopes: I) -> AclUpdateCall<'a, C>
4668    where
4669        I: IntoIterator<Item = St>,
4670        St: AsRef<str>,
4671    {
4672        self._scopes
4673            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
4674        self
4675    }
4676
4677    /// Removes all scopes, and no default scope will be used either.
4678    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
4679    /// for details).
4680    pub fn clear_scopes(mut self) -> AclUpdateCall<'a, C> {
4681        self._scopes.clear();
4682        self
4683    }
4684}
4685
4686/// Watch for changes to ACL resources.
4687///
4688/// A builder for the *watch* method supported by a *acl* resource.
4689/// It is not used directly, but through a [`AclMethods`] instance.
4690///
4691/// # Example
4692///
4693/// Instantiate a resource method builder
4694///
4695/// ```test_harness,no_run
4696/// # extern crate hyper;
4697/// # extern crate hyper_rustls;
4698/// # extern crate google_calendar3 as calendar3;
4699/// use calendar3::api::Channel;
4700/// # async fn dox() {
4701/// # use calendar3::{CalendarHub, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
4702///
4703/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
4704/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
4705/// #     secret,
4706/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
4707/// # ).build().await.unwrap();
4708///
4709/// # let client = hyper_util::client::legacy::Client::builder(
4710/// #     hyper_util::rt::TokioExecutor::new()
4711/// # )
4712/// # .build(
4713/// #     hyper_rustls::HttpsConnectorBuilder::new()
4714/// #         .with_native_roots()
4715/// #         .unwrap()
4716/// #         .https_or_http()
4717/// #         .enable_http1()
4718/// #         .build()
4719/// # );
4720/// # let mut hub = CalendarHub::new(client, auth);
4721/// // As the method needs a request, you would usually fill it with the desired information
4722/// // into the respective structure. Some of the parts shown here might not be applicable !
4723/// // Values shown here are possibly random and not representative !
4724/// let mut req = Channel::default();
4725///
4726/// // You can configure optional parameters by calling the respective setters at will, and
4727/// // execute the final call using `doit()`.
4728/// // Values shown here are possibly random and not representative !
4729/// let result = hub.acl().watch(req, "calendarId")
4730///              .sync_token("voluptua.")
4731///              .show_deleted(false)
4732///              .page_token("erat")
4733///              .max_results(-96)
4734///              .doit().await;
4735/// # }
4736/// ```
4737pub struct AclWatchCall<'a, C>
4738where
4739    C: 'a,
4740{
4741    hub: &'a CalendarHub<C>,
4742    _request: Channel,
4743    _calendar_id: String,
4744    _sync_token: Option<String>,
4745    _show_deleted: Option<bool>,
4746    _page_token: Option<String>,
4747    _max_results: Option<i32>,
4748    _delegate: Option<&'a mut dyn common::Delegate>,
4749    _additional_params: HashMap<String, String>,
4750    _scopes: BTreeSet<String>,
4751}
4752
4753impl<'a, C> common::CallBuilder for AclWatchCall<'a, C> {}
4754
4755impl<'a, C> AclWatchCall<'a, C>
4756where
4757    C: common::Connector,
4758{
4759    /// Perform the operation you have build so far.
4760    pub async fn doit(mut self) -> common::Result<(common::Response, Channel)> {
4761        use std::borrow::Cow;
4762        use std::io::{Read, Seek};
4763
4764        use common::{url::Params, ToParts};
4765        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
4766
4767        let mut dd = common::DefaultDelegate;
4768        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
4769        dlg.begin(common::MethodInfo {
4770            id: "calendar.acl.watch",
4771            http_method: hyper::Method::POST,
4772        });
4773
4774        for &field in [
4775            "alt",
4776            "calendarId",
4777            "syncToken",
4778            "showDeleted",
4779            "pageToken",
4780            "maxResults",
4781        ]
4782        .iter()
4783        {
4784            if self._additional_params.contains_key(field) {
4785                dlg.finished(false);
4786                return Err(common::Error::FieldClash(field));
4787            }
4788        }
4789
4790        let mut params = Params::with_capacity(8 + self._additional_params.len());
4791        params.push("calendarId", self._calendar_id);
4792        if let Some(value) = self._sync_token.as_ref() {
4793            params.push("syncToken", value);
4794        }
4795        if let Some(value) = self._show_deleted.as_ref() {
4796            params.push("showDeleted", value.to_string());
4797        }
4798        if let Some(value) = self._page_token.as_ref() {
4799            params.push("pageToken", value);
4800        }
4801        if let Some(value) = self._max_results.as_ref() {
4802            params.push("maxResults", value.to_string());
4803        }
4804
4805        params.extend(self._additional_params.iter());
4806
4807        params.push("alt", "json");
4808        let mut url = self.hub._base_url.clone() + "calendars/{calendarId}/acl/watch";
4809        if self._scopes.is_empty() {
4810            self._scopes.insert(Scope::Full.as_ref().to_string());
4811        }
4812
4813        #[allow(clippy::single_element_loop)]
4814        for &(find_this, param_name) in [("{calendarId}", "calendarId")].iter() {
4815            url = params.uri_replacement(url, param_name, find_this, false);
4816        }
4817        {
4818            let to_remove = ["calendarId"];
4819            params.remove_params(&to_remove);
4820        }
4821
4822        let url = params.parse_with_url(&url);
4823
4824        let mut json_mime_type = mime::APPLICATION_JSON;
4825        let mut request_value_reader = {
4826            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
4827            common::remove_json_null_values(&mut value);
4828            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
4829            serde_json::to_writer(&mut dst, &value).unwrap();
4830            dst
4831        };
4832        let request_size = request_value_reader
4833            .seek(std::io::SeekFrom::End(0))
4834            .unwrap();
4835        request_value_reader
4836            .seek(std::io::SeekFrom::Start(0))
4837            .unwrap();
4838
4839        loop {
4840            let token = match self
4841                .hub
4842                .auth
4843                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
4844                .await
4845            {
4846                Ok(token) => token,
4847                Err(e) => match dlg.token(e) {
4848                    Ok(token) => token,
4849                    Err(e) => {
4850                        dlg.finished(false);
4851                        return Err(common::Error::MissingToken(e));
4852                    }
4853                },
4854            };
4855            request_value_reader
4856                .seek(std::io::SeekFrom::Start(0))
4857                .unwrap();
4858            let mut req_result = {
4859                let client = &self.hub.client;
4860                dlg.pre_request();
4861                let mut req_builder = hyper::Request::builder()
4862                    .method(hyper::Method::POST)
4863                    .uri(url.as_str())
4864                    .header(USER_AGENT, self.hub._user_agent.clone());
4865
4866                if let Some(token) = token.as_ref() {
4867                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
4868                }
4869
4870                let request = req_builder
4871                    .header(CONTENT_TYPE, json_mime_type.to_string())
4872                    .header(CONTENT_LENGTH, request_size as u64)
4873                    .body(common::to_body(
4874                        request_value_reader.get_ref().clone().into(),
4875                    ));
4876
4877                client.request(request.unwrap()).await
4878            };
4879
4880            match req_result {
4881                Err(err) => {
4882                    if let common::Retry::After(d) = dlg.http_error(&err) {
4883                        sleep(d).await;
4884                        continue;
4885                    }
4886                    dlg.finished(false);
4887                    return Err(common::Error::HttpError(err));
4888                }
4889                Ok(res) => {
4890                    let (mut parts, body) = res.into_parts();
4891                    let mut body = common::Body::new(body);
4892                    if !parts.status.is_success() {
4893                        let bytes = common::to_bytes(body).await.unwrap_or_default();
4894                        let error = serde_json::from_str(&common::to_string(&bytes));
4895                        let response = common::to_response(parts, bytes.into());
4896
4897                        if let common::Retry::After(d) =
4898                            dlg.http_failure(&response, error.as_ref().ok())
4899                        {
4900                            sleep(d).await;
4901                            continue;
4902                        }
4903
4904                        dlg.finished(false);
4905
4906                        return Err(match error {
4907                            Ok(value) => common::Error::BadRequest(value),
4908                            _ => common::Error::Failure(response),
4909                        });
4910                    }
4911                    let response = {
4912                        let bytes = common::to_bytes(body).await.unwrap_or_default();
4913                        let encoded = common::to_string(&bytes);
4914                        match serde_json::from_str(&encoded) {
4915                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
4916                            Err(error) => {
4917                                dlg.response_json_decode_error(&encoded, &error);
4918                                return Err(common::Error::JsonDecodeError(
4919                                    encoded.to_string(),
4920                                    error,
4921                                ));
4922                            }
4923                        }
4924                    };
4925
4926                    dlg.finished(true);
4927                    return Ok(response);
4928                }
4929            }
4930        }
4931    }
4932
4933    ///
4934    /// Sets the *request* property to the given value.
4935    ///
4936    /// Even though the property as already been set when instantiating this call,
4937    /// we provide this method for API completeness.
4938    pub fn request(mut self, new_value: Channel) -> AclWatchCall<'a, C> {
4939        self._request = new_value;
4940        self
4941    }
4942    /// 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.
4943    ///
4944    /// Sets the *calendar id* path property to the given value.
4945    ///
4946    /// Even though the property as already been set when instantiating this call,
4947    /// we provide this method for API completeness.
4948    pub fn calendar_id(mut self, new_value: &str) -> AclWatchCall<'a, C> {
4949        self._calendar_id = new_value.to_string();
4950        self
4951    }
4952    /// 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 entries deleted since the previous list request will always be in the result set and it is not allowed to set showDeleted to False.
4953    /// 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.
4954    /// Learn more about incremental synchronization.
4955    /// Optional. The default is to return all entries.
4956    ///
4957    /// Sets the *sync token* query property to the given value.
4958    pub fn sync_token(mut self, new_value: &str) -> AclWatchCall<'a, C> {
4959        self._sync_token = Some(new_value.to_string());
4960        self
4961    }
4962    /// Whether to include deleted ACLs in the result. Deleted ACLs are represented by role equal to "none". Deleted ACLs will always be included if syncToken is provided. Optional. The default is False.
4963    ///
4964    /// Sets the *show deleted* query property to the given value.
4965    pub fn show_deleted(mut self, new_value: bool) -> AclWatchCall<'a, C> {
4966        self._show_deleted = Some(new_value);
4967        self
4968    }
4969    /// Token specifying which result page to return. Optional.
4970    ///
4971    /// Sets the *page token* query property to the given value.
4972    pub fn page_token(mut self, new_value: &str) -> AclWatchCall<'a, C> {
4973        self._page_token = Some(new_value.to_string());
4974        self
4975    }
4976    /// Maximum number of entries returned on one result page. By default the value is 100 entries. The page size can never be larger than 250 entries. Optional.
4977    ///
4978    /// Sets the *max results* query property to the given value.
4979    pub fn max_results(mut self, new_value: i32) -> AclWatchCall<'a, C> {
4980        self._max_results = Some(new_value);
4981        self
4982    }
4983    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
4984    /// while executing the actual API request.
4985    ///
4986    /// ````text
4987    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
4988    /// ````
4989    ///
4990    /// Sets the *delegate* property to the given value.
4991    pub fn delegate(mut self, new_value: &'a mut dyn common::Delegate) -> AclWatchCall<'a, C> {
4992        self._delegate = Some(new_value);
4993        self
4994    }
4995
4996    /// Set any additional parameter of the query string used in the request.
4997    /// It should be used to set parameters which are not yet available through their own
4998    /// setters.
4999    ///
5000    /// Please note that this method must not be used to set any of the known parameters
5001    /// which have their own setter method. If done anyway, the request will fail.
5002    ///
5003    /// # Additional Parameters
5004    ///
5005    /// * *alt* (query-string) - Data format for the response.
5006    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
5007    /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
5008    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
5009    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
5010    /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
5011    /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
5012    pub fn param<T>(mut self, name: T, value: T) -> AclWatchCall<'a, C>
5013    where
5014        T: AsRef<str>,
5015    {
5016        self._additional_params
5017            .insert(name.as_ref().to_string(), value.as_ref().to_string());
5018        self
5019    }
5020
5021    /// Identifies the authorization scope for the method you are building.
5022    ///
5023    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
5024    /// [`Scope::Full`].
5025    ///
5026    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
5027    /// tokens for more than one scope.
5028    ///
5029    /// Usually there is more than one suitable scope to authorize an operation, some of which may
5030    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
5031    /// sufficient, a read-write scope will do as well.
5032    pub fn add_scope<St>(mut self, scope: St) -> AclWatchCall<'a, C>
5033    where
5034        St: AsRef<str>,
5035    {
5036        self._scopes.insert(String::from(scope.as_ref()));
5037        self
5038    }
5039    /// Identifies the authorization scope(s) for the method you are building.
5040    ///
5041    /// See [`Self::add_scope()`] for details.
5042    pub fn add_scopes<I, St>(mut self, scopes: I) -> AclWatchCall<'a, C>
5043    where
5044        I: IntoIterator<Item = St>,
5045        St: AsRef<str>,
5046    {
5047        self._scopes
5048            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
5049        self
5050    }
5051
5052    /// Removes all scopes, and no default scope will be used either.
5053    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
5054    /// for details).
5055    pub fn clear_scopes(mut self) -> AclWatchCall<'a, C> {
5056        self._scopes.clear();
5057        self
5058    }
5059}
5060
5061/// Removes a calendar from the user's calendar list.
5062///
5063/// A builder for the *delete* method supported by a *calendarList* resource.
5064/// It is not used directly, but through a [`CalendarListMethods`] instance.
5065///
5066/// # Example
5067///
5068/// Instantiate a resource method builder
5069///
5070/// ```test_harness,no_run
5071/// # extern crate hyper;
5072/// # extern crate hyper_rustls;
5073/// # extern crate google_calendar3 as calendar3;
5074/// # async fn dox() {
5075/// # use calendar3::{CalendarHub, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
5076///
5077/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
5078/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
5079/// #     secret,
5080/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
5081/// # ).build().await.unwrap();
5082///
5083/// # let client = hyper_util::client::legacy::Client::builder(
5084/// #     hyper_util::rt::TokioExecutor::new()
5085/// # )
5086/// # .build(
5087/// #     hyper_rustls::HttpsConnectorBuilder::new()
5088/// #         .with_native_roots()
5089/// #         .unwrap()
5090/// #         .https_or_http()
5091/// #         .enable_http1()
5092/// #         .build()
5093/// # );
5094/// # let mut hub = CalendarHub::new(client, auth);
5095/// // You can configure optional parameters by calling the respective setters at will, and
5096/// // execute the final call using `doit()`.
5097/// // Values shown here are possibly random and not representative !
5098/// let result = hub.calendar_list().delete("calendarId")
5099///              .doit().await;
5100/// # }
5101/// ```
5102pub struct CalendarListDeleteCall<'a, C>
5103where
5104    C: 'a,
5105{
5106    hub: &'a CalendarHub<C>,
5107    _calendar_id: String,
5108    _delegate: Option<&'a mut dyn common::Delegate>,
5109    _additional_params: HashMap<String, String>,
5110    _scopes: BTreeSet<String>,
5111}
5112
5113impl<'a, C> common::CallBuilder for CalendarListDeleteCall<'a, C> {}
5114
5115impl<'a, C> CalendarListDeleteCall<'a, C>
5116where
5117    C: common::Connector,
5118{
5119    /// Perform the operation you have build so far.
5120    pub async fn doit(mut self) -> common::Result<common::Response> {
5121        use std::borrow::Cow;
5122        use std::io::{Read, Seek};
5123
5124        use common::{url::Params, ToParts};
5125        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
5126
5127        let mut dd = common::DefaultDelegate;
5128        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
5129        dlg.begin(common::MethodInfo {
5130            id: "calendar.calendarList.delete",
5131            http_method: hyper::Method::DELETE,
5132        });
5133
5134        for &field in ["calendarId"].iter() {
5135            if self._additional_params.contains_key(field) {
5136                dlg.finished(false);
5137                return Err(common::Error::FieldClash(field));
5138            }
5139        }
5140
5141        let mut params = Params::with_capacity(2 + self._additional_params.len());
5142        params.push("calendarId", self._calendar_id);
5143
5144        params.extend(self._additional_params.iter());
5145
5146        let mut url = self.hub._base_url.clone() + "users/me/calendarList/{calendarId}";
5147        if self._scopes.is_empty() {
5148            self._scopes.insert(Scope::Full.as_ref().to_string());
5149        }
5150
5151        #[allow(clippy::single_element_loop)]
5152        for &(find_this, param_name) in [("{calendarId}", "calendarId")].iter() {
5153            url = params.uri_replacement(url, param_name, find_this, false);
5154        }
5155        {
5156            let to_remove = ["calendarId"];
5157            params.remove_params(&to_remove);
5158        }
5159
5160        let url = params.parse_with_url(&url);
5161
5162        loop {
5163            let token = match self
5164                .hub
5165                .auth
5166                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
5167                .await
5168            {
5169                Ok(token) => token,
5170                Err(e) => match dlg.token(e) {
5171                    Ok(token) => token,
5172                    Err(e) => {
5173                        dlg.finished(false);
5174                        return Err(common::Error::MissingToken(e));
5175                    }
5176                },
5177            };
5178            let mut req_result = {
5179                let client = &self.hub.client;
5180                dlg.pre_request();
5181                let mut req_builder = hyper::Request::builder()
5182                    .method(hyper::Method::DELETE)
5183                    .uri(url.as_str())
5184                    .header(USER_AGENT, self.hub._user_agent.clone());
5185
5186                if let Some(token) = token.as_ref() {
5187                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
5188                }
5189
5190                let request = req_builder
5191                    .header(CONTENT_LENGTH, 0_u64)
5192                    .body(common::to_body::<String>(None));
5193
5194                client.request(request.unwrap()).await
5195            };
5196
5197            match req_result {
5198                Err(err) => {
5199                    if let common::Retry::After(d) = dlg.http_error(&err) {
5200                        sleep(d).await;
5201                        continue;
5202                    }
5203                    dlg.finished(false);
5204                    return Err(common::Error::HttpError(err));
5205                }
5206                Ok(res) => {
5207                    let (mut parts, body) = res.into_parts();
5208                    let mut body = common::Body::new(body);
5209                    if !parts.status.is_success() {
5210                        let bytes = common::to_bytes(body).await.unwrap_or_default();
5211                        let error = serde_json::from_str(&common::to_string(&bytes));
5212                        let response = common::to_response(parts, bytes.into());
5213
5214                        if let common::Retry::After(d) =
5215                            dlg.http_failure(&response, error.as_ref().ok())
5216                        {
5217                            sleep(d).await;
5218                            continue;
5219                        }
5220
5221                        dlg.finished(false);
5222
5223                        return Err(match error {
5224                            Ok(value) => common::Error::BadRequest(value),
5225                            _ => common::Error::Failure(response),
5226                        });
5227                    }
5228                    let response = common::Response::from_parts(parts, body);
5229
5230                    dlg.finished(true);
5231                    return Ok(response);
5232                }
5233            }
5234        }
5235    }
5236
5237    /// 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.
5238    ///
5239    /// Sets the *calendar id* path property to the given value.
5240    ///
5241    /// Even though the property as already been set when instantiating this call,
5242    /// we provide this method for API completeness.
5243    pub fn calendar_id(mut self, new_value: &str) -> CalendarListDeleteCall<'a, C> {
5244        self._calendar_id = new_value.to_string();
5245        self
5246    }
5247    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
5248    /// while executing the actual API request.
5249    ///
5250    /// ````text
5251    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
5252    /// ````
5253    ///
5254    /// Sets the *delegate* property to the given value.
5255    pub fn delegate(
5256        mut self,
5257        new_value: &'a mut dyn common::Delegate,
5258    ) -> CalendarListDeleteCall<'a, C> {
5259        self._delegate = Some(new_value);
5260        self
5261    }
5262
5263    /// Set any additional parameter of the query string used in the request.
5264    /// It should be used to set parameters which are not yet available through their own
5265    /// setters.
5266    ///
5267    /// Please note that this method must not be used to set any of the known parameters
5268    /// which have their own setter method. If done anyway, the request will fail.
5269    ///
5270    /// # Additional Parameters
5271    ///
5272    /// * *alt* (query-string) - Data format for the response.
5273    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
5274    /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
5275    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
5276    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
5277    /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
5278    /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
5279    pub fn param<T>(mut self, name: T, value: T) -> CalendarListDeleteCall<'a, C>
5280    where
5281        T: AsRef<str>,
5282    {
5283        self._additional_params
5284            .insert(name.as_ref().to_string(), value.as_ref().to_string());
5285        self
5286    }
5287
5288    /// Identifies the authorization scope for the method you are building.
5289    ///
5290    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
5291    /// [`Scope::Full`].
5292    ///
5293    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
5294    /// tokens for more than one scope.
5295    ///
5296    /// Usually there is more than one suitable scope to authorize an operation, some of which may
5297    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
5298    /// sufficient, a read-write scope will do as well.
5299    pub fn add_scope<St>(mut self, scope: St) -> CalendarListDeleteCall<'a, C>
5300    where
5301        St: AsRef<str>,
5302    {
5303        self._scopes.insert(String::from(scope.as_ref()));
5304        self
5305    }
5306    /// Identifies the authorization scope(s) for the method you are building.
5307    ///
5308    /// See [`Self::add_scope()`] for details.
5309    pub fn add_scopes<I, St>(mut self, scopes: I) -> CalendarListDeleteCall<'a, C>
5310    where
5311        I: IntoIterator<Item = St>,
5312        St: AsRef<str>,
5313    {
5314        self._scopes
5315            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
5316        self
5317    }
5318
5319    /// Removes all scopes, and no default scope will be used either.
5320    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
5321    /// for details).
5322    pub fn clear_scopes(mut self) -> CalendarListDeleteCall<'a, C> {
5323        self._scopes.clear();
5324        self
5325    }
5326}
5327
5328/// Returns a calendar from the user's calendar list.
5329///
5330/// A builder for the *get* method supported by a *calendarList* resource.
5331/// It is not used directly, but through a [`CalendarListMethods`] instance.
5332///
5333/// # Example
5334///
5335/// Instantiate a resource method builder
5336///
5337/// ```test_harness,no_run
5338/// # extern crate hyper;
5339/// # extern crate hyper_rustls;
5340/// # extern crate google_calendar3 as calendar3;
5341/// # async fn dox() {
5342/// # use calendar3::{CalendarHub, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
5343///
5344/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
5345/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
5346/// #     secret,
5347/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
5348/// # ).build().await.unwrap();
5349///
5350/// # let client = hyper_util::client::legacy::Client::builder(
5351/// #     hyper_util::rt::TokioExecutor::new()
5352/// # )
5353/// # .build(
5354/// #     hyper_rustls::HttpsConnectorBuilder::new()
5355/// #         .with_native_roots()
5356/// #         .unwrap()
5357/// #         .https_or_http()
5358/// #         .enable_http1()
5359/// #         .build()
5360/// # );
5361/// # let mut hub = CalendarHub::new(client, auth);
5362/// // You can configure optional parameters by calling the respective setters at will, and
5363/// // execute the final call using `doit()`.
5364/// // Values shown here are possibly random and not representative !
5365/// let result = hub.calendar_list().get("calendarId")
5366///              .doit().await;
5367/// # }
5368/// ```
5369pub struct CalendarListGetCall<'a, C>
5370where
5371    C: 'a,
5372{
5373    hub: &'a CalendarHub<C>,
5374    _calendar_id: String,
5375    _delegate: Option<&'a mut dyn common::Delegate>,
5376    _additional_params: HashMap<String, String>,
5377    _scopes: BTreeSet<String>,
5378}
5379
5380impl<'a, C> common::CallBuilder for CalendarListGetCall<'a, C> {}
5381
5382impl<'a, C> CalendarListGetCall<'a, C>
5383where
5384    C: common::Connector,
5385{
5386    /// Perform the operation you have build so far.
5387    pub async fn doit(mut self) -> common::Result<(common::Response, CalendarListEntry)> {
5388        use std::borrow::Cow;
5389        use std::io::{Read, Seek};
5390
5391        use common::{url::Params, ToParts};
5392        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
5393
5394        let mut dd = common::DefaultDelegate;
5395        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
5396        dlg.begin(common::MethodInfo {
5397            id: "calendar.calendarList.get",
5398            http_method: hyper::Method::GET,
5399        });
5400
5401        for &field in ["alt", "calendarId"].iter() {
5402            if self._additional_params.contains_key(field) {
5403                dlg.finished(false);
5404                return Err(common::Error::FieldClash(field));
5405            }
5406        }
5407
5408        let mut params = Params::with_capacity(3 + self._additional_params.len());
5409        params.push("calendarId", self._calendar_id);
5410
5411        params.extend(self._additional_params.iter());
5412
5413        params.push("alt", "json");
5414        let mut url = self.hub._base_url.clone() + "users/me/calendarList/{calendarId}";
5415        if self._scopes.is_empty() {
5416            self._scopes.insert(Scope::Readonly.as_ref().to_string());
5417        }
5418
5419        #[allow(clippy::single_element_loop)]
5420        for &(find_this, param_name) in [("{calendarId}", "calendarId")].iter() {
5421            url = params.uri_replacement(url, param_name, find_this, false);
5422        }
5423        {
5424            let to_remove = ["calendarId"];
5425            params.remove_params(&to_remove);
5426        }
5427
5428        let url = params.parse_with_url(&url);
5429
5430        loop {
5431            let token = match self
5432                .hub
5433                .auth
5434                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
5435                .await
5436            {
5437                Ok(token) => token,
5438                Err(e) => match dlg.token(e) {
5439                    Ok(token) => token,
5440                    Err(e) => {
5441                        dlg.finished(false);
5442                        return Err(common::Error::MissingToken(e));
5443                    }
5444                },
5445            };
5446            let mut req_result = {
5447                let client = &self.hub.client;
5448                dlg.pre_request();
5449                let mut req_builder = hyper::Request::builder()
5450                    .method(hyper::Method::GET)
5451                    .uri(url.as_str())
5452                    .header(USER_AGENT, self.hub._user_agent.clone());
5453
5454                if let Some(token) = token.as_ref() {
5455                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
5456                }
5457
5458                let request = req_builder
5459                    .header(CONTENT_LENGTH, 0_u64)
5460                    .body(common::to_body::<String>(None));
5461
5462                client.request(request.unwrap()).await
5463            };
5464
5465            match req_result {
5466                Err(err) => {
5467                    if let common::Retry::After(d) = dlg.http_error(&err) {
5468                        sleep(d).await;
5469                        continue;
5470                    }
5471                    dlg.finished(false);
5472                    return Err(common::Error::HttpError(err));
5473                }
5474                Ok(res) => {
5475                    let (mut parts, body) = res.into_parts();
5476                    let mut body = common::Body::new(body);
5477                    if !parts.status.is_success() {
5478                        let bytes = common::to_bytes(body).await.unwrap_or_default();
5479                        let error = serde_json::from_str(&common::to_string(&bytes));
5480                        let response = common::to_response(parts, bytes.into());
5481
5482                        if let common::Retry::After(d) =
5483                            dlg.http_failure(&response, error.as_ref().ok())
5484                        {
5485                            sleep(d).await;
5486                            continue;
5487                        }
5488
5489                        dlg.finished(false);
5490
5491                        return Err(match error {
5492                            Ok(value) => common::Error::BadRequest(value),
5493                            _ => common::Error::Failure(response),
5494                        });
5495                    }
5496                    let response = {
5497                        let bytes = common::to_bytes(body).await.unwrap_or_default();
5498                        let encoded = common::to_string(&bytes);
5499                        match serde_json::from_str(&encoded) {
5500                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
5501                            Err(error) => {
5502                                dlg.response_json_decode_error(&encoded, &error);
5503                                return Err(common::Error::JsonDecodeError(
5504                                    encoded.to_string(),
5505                                    error,
5506                                ));
5507                            }
5508                        }
5509                    };
5510
5511                    dlg.finished(true);
5512                    return Ok(response);
5513                }
5514            }
5515        }
5516    }
5517
5518    /// 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.
5519    ///
5520    /// Sets the *calendar id* path property to the given value.
5521    ///
5522    /// Even though the property as already been set when instantiating this call,
5523    /// we provide this method for API completeness.
5524    pub fn calendar_id(mut self, new_value: &str) -> CalendarListGetCall<'a, C> {
5525        self._calendar_id = new_value.to_string();
5526        self
5527    }
5528    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
5529    /// while executing the actual API request.
5530    ///
5531    /// ````text
5532    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
5533    /// ````
5534    ///
5535    /// Sets the *delegate* property to the given value.
5536    pub fn delegate(
5537        mut self,
5538        new_value: &'a mut dyn common::Delegate,
5539    ) -> CalendarListGetCall<'a, C> {
5540        self._delegate = Some(new_value);
5541        self
5542    }
5543
5544    /// Set any additional parameter of the query string used in the request.
5545    /// It should be used to set parameters which are not yet available through their own
5546    /// setters.
5547    ///
5548    /// Please note that this method must not be used to set any of the known parameters
5549    /// which have their own setter method. If done anyway, the request will fail.
5550    ///
5551    /// # Additional Parameters
5552    ///
5553    /// * *alt* (query-string) - Data format for the response.
5554    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
5555    /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
5556    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
5557    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
5558    /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
5559    /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
5560    pub fn param<T>(mut self, name: T, value: T) -> CalendarListGetCall<'a, C>
5561    where
5562        T: AsRef<str>,
5563    {
5564        self._additional_params
5565            .insert(name.as_ref().to_string(), value.as_ref().to_string());
5566        self
5567    }
5568
5569    /// Identifies the authorization scope for the method you are building.
5570    ///
5571    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
5572    /// [`Scope::Readonly`].
5573    ///
5574    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
5575    /// tokens for more than one scope.
5576    ///
5577    /// Usually there is more than one suitable scope to authorize an operation, some of which may
5578    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
5579    /// sufficient, a read-write scope will do as well.
5580    pub fn add_scope<St>(mut self, scope: St) -> CalendarListGetCall<'a, C>
5581    where
5582        St: AsRef<str>,
5583    {
5584        self._scopes.insert(String::from(scope.as_ref()));
5585        self
5586    }
5587    /// Identifies the authorization scope(s) for the method you are building.
5588    ///
5589    /// See [`Self::add_scope()`] for details.
5590    pub fn add_scopes<I, St>(mut self, scopes: I) -> CalendarListGetCall<'a, C>
5591    where
5592        I: IntoIterator<Item = St>,
5593        St: AsRef<str>,
5594    {
5595        self._scopes
5596            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
5597        self
5598    }
5599
5600    /// Removes all scopes, and no default scope will be used either.
5601    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
5602    /// for details).
5603    pub fn clear_scopes(mut self) -> CalendarListGetCall<'a, C> {
5604        self._scopes.clear();
5605        self
5606    }
5607}
5608
5609/// Inserts an existing calendar into the user's calendar list.
5610///
5611/// A builder for the *insert* method supported by a *calendarList* resource.
5612/// It is not used directly, but through a [`CalendarListMethods`] instance.
5613///
5614/// # Example
5615///
5616/// Instantiate a resource method builder
5617///
5618/// ```test_harness,no_run
5619/// # extern crate hyper;
5620/// # extern crate hyper_rustls;
5621/// # extern crate google_calendar3 as calendar3;
5622/// use calendar3::api::CalendarListEntry;
5623/// # async fn dox() {
5624/// # use calendar3::{CalendarHub, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
5625///
5626/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
5627/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
5628/// #     secret,
5629/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
5630/// # ).build().await.unwrap();
5631///
5632/// # let client = hyper_util::client::legacy::Client::builder(
5633/// #     hyper_util::rt::TokioExecutor::new()
5634/// # )
5635/// # .build(
5636/// #     hyper_rustls::HttpsConnectorBuilder::new()
5637/// #         .with_native_roots()
5638/// #         .unwrap()
5639/// #         .https_or_http()
5640/// #         .enable_http1()
5641/// #         .build()
5642/// # );
5643/// # let mut hub = CalendarHub::new(client, auth);
5644/// // As the method needs a request, you would usually fill it with the desired information
5645/// // into the respective structure. Some of the parts shown here might not be applicable !
5646/// // Values shown here are possibly random and not representative !
5647/// let mut req = CalendarListEntry::default();
5648///
5649/// // You can configure optional parameters by calling the respective setters at will, and
5650/// // execute the final call using `doit()`.
5651/// // Values shown here are possibly random and not representative !
5652/// let result = hub.calendar_list().insert(req)
5653///              .color_rgb_format(true)
5654///              .doit().await;
5655/// # }
5656/// ```
5657pub struct CalendarListInsertCall<'a, C>
5658where
5659    C: 'a,
5660{
5661    hub: &'a CalendarHub<C>,
5662    _request: CalendarListEntry,
5663    _color_rgb_format: Option<bool>,
5664    _delegate: Option<&'a mut dyn common::Delegate>,
5665    _additional_params: HashMap<String, String>,
5666    _scopes: BTreeSet<String>,
5667}
5668
5669impl<'a, C> common::CallBuilder for CalendarListInsertCall<'a, C> {}
5670
5671impl<'a, C> CalendarListInsertCall<'a, C>
5672where
5673    C: common::Connector,
5674{
5675    /// Perform the operation you have build so far.
5676    pub async fn doit(mut self) -> common::Result<(common::Response, CalendarListEntry)> {
5677        use std::borrow::Cow;
5678        use std::io::{Read, Seek};
5679
5680        use common::{url::Params, ToParts};
5681        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
5682
5683        let mut dd = common::DefaultDelegate;
5684        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
5685        dlg.begin(common::MethodInfo {
5686            id: "calendar.calendarList.insert",
5687            http_method: hyper::Method::POST,
5688        });
5689
5690        for &field in ["alt", "colorRgbFormat"].iter() {
5691            if self._additional_params.contains_key(field) {
5692                dlg.finished(false);
5693                return Err(common::Error::FieldClash(field));
5694            }
5695        }
5696
5697        let mut params = Params::with_capacity(4 + self._additional_params.len());
5698        if let Some(value) = self._color_rgb_format.as_ref() {
5699            params.push("colorRgbFormat", value.to_string());
5700        }
5701
5702        params.extend(self._additional_params.iter());
5703
5704        params.push("alt", "json");
5705        let mut url = self.hub._base_url.clone() + "users/me/calendarList";
5706        if self._scopes.is_empty() {
5707            self._scopes.insert(Scope::Full.as_ref().to_string());
5708        }
5709
5710        let url = params.parse_with_url(&url);
5711
5712        let mut json_mime_type = mime::APPLICATION_JSON;
5713        let mut request_value_reader = {
5714            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
5715            common::remove_json_null_values(&mut value);
5716            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
5717            serde_json::to_writer(&mut dst, &value).unwrap();
5718            dst
5719        };
5720        let request_size = request_value_reader
5721            .seek(std::io::SeekFrom::End(0))
5722            .unwrap();
5723        request_value_reader
5724            .seek(std::io::SeekFrom::Start(0))
5725            .unwrap();
5726
5727        loop {
5728            let token = match self
5729                .hub
5730                .auth
5731                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
5732                .await
5733            {
5734                Ok(token) => token,
5735                Err(e) => match dlg.token(e) {
5736                    Ok(token) => token,
5737                    Err(e) => {
5738                        dlg.finished(false);
5739                        return Err(common::Error::MissingToken(e));
5740                    }
5741                },
5742            };
5743            request_value_reader
5744                .seek(std::io::SeekFrom::Start(0))
5745                .unwrap();
5746            let mut req_result = {
5747                let client = &self.hub.client;
5748                dlg.pre_request();
5749                let mut req_builder = hyper::Request::builder()
5750                    .method(hyper::Method::POST)
5751                    .uri(url.as_str())
5752                    .header(USER_AGENT, self.hub._user_agent.clone());
5753
5754                if let Some(token) = token.as_ref() {
5755                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
5756                }
5757
5758                let request = req_builder
5759                    .header(CONTENT_TYPE, json_mime_type.to_string())
5760                    .header(CONTENT_LENGTH, request_size as u64)
5761                    .body(common::to_body(
5762                        request_value_reader.get_ref().clone().into(),
5763                    ));
5764
5765                client.request(request.unwrap()).await
5766            };
5767
5768            match req_result {
5769                Err(err) => {
5770                    if let common::Retry::After(d) = dlg.http_error(&err) {
5771                        sleep(d).await;
5772                        continue;
5773                    }
5774                    dlg.finished(false);
5775                    return Err(common::Error::HttpError(err));
5776                }
5777                Ok(res) => {
5778                    let (mut parts, body) = res.into_parts();
5779                    let mut body = common::Body::new(body);
5780                    if !parts.status.is_success() {
5781                        let bytes = common::to_bytes(body).await.unwrap_or_default();
5782                        let error = serde_json::from_str(&common::to_string(&bytes));
5783                        let response = common::to_response(parts, bytes.into());
5784
5785                        if let common::Retry::After(d) =
5786                            dlg.http_failure(&response, error.as_ref().ok())
5787                        {
5788                            sleep(d).await;
5789                            continue;
5790                        }
5791
5792                        dlg.finished(false);
5793
5794                        return Err(match error {
5795                            Ok(value) => common::Error::BadRequest(value),
5796                            _ => common::Error::Failure(response),
5797                        });
5798                    }
5799                    let response = {
5800                        let bytes = common::to_bytes(body).await.unwrap_or_default();
5801                        let encoded = common::to_string(&bytes);
5802                        match serde_json::from_str(&encoded) {
5803                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
5804                            Err(error) => {
5805                                dlg.response_json_decode_error(&encoded, &error);
5806                                return Err(common::Error::JsonDecodeError(
5807                                    encoded.to_string(),
5808                                    error,
5809                                ));
5810                            }
5811                        }
5812                    };
5813
5814                    dlg.finished(true);
5815                    return Ok(response);
5816                }
5817            }
5818        }
5819    }
5820
5821    ///
5822    /// Sets the *request* property to the given value.
5823    ///
5824    /// Even though the property as already been set when instantiating this call,
5825    /// we provide this method for API completeness.
5826    pub fn request(mut self, new_value: CalendarListEntry) -> CalendarListInsertCall<'a, C> {
5827        self._request = new_value;
5828        self
5829    }
5830    /// Whether to use the foregroundColor and backgroundColor fields to write the calendar colors (RGB). If this feature is used, the index-based colorId field will be set to the best matching option automatically. Optional. The default is False.
5831    ///
5832    /// Sets the *color rgb format* query property to the given value.
5833    pub fn color_rgb_format(mut self, new_value: bool) -> CalendarListInsertCall<'a, C> {
5834        self._color_rgb_format = Some(new_value);
5835        self
5836    }
5837    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
5838    /// while executing the actual API request.
5839    ///
5840    /// ````text
5841    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
5842    /// ````
5843    ///
5844    /// Sets the *delegate* property to the given value.
5845    pub fn delegate(
5846        mut self,
5847        new_value: &'a mut dyn common::Delegate,
5848    ) -> CalendarListInsertCall<'a, C> {
5849        self._delegate = Some(new_value);
5850        self
5851    }
5852
5853    /// Set any additional parameter of the query string used in the request.
5854    /// It should be used to set parameters which are not yet available through their own
5855    /// setters.
5856    ///
5857    /// Please note that this method must not be used to set any of the known parameters
5858    /// which have their own setter method. If done anyway, the request will fail.
5859    ///
5860    /// # Additional Parameters
5861    ///
5862    /// * *alt* (query-string) - Data format for the response.
5863    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
5864    /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
5865    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
5866    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
5867    /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
5868    /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
5869    pub fn param<T>(mut self, name: T, value: T) -> CalendarListInsertCall<'a, C>
5870    where
5871        T: AsRef<str>,
5872    {
5873        self._additional_params
5874            .insert(name.as_ref().to_string(), value.as_ref().to_string());
5875        self
5876    }
5877
5878    /// Identifies the authorization scope for the method you are building.
5879    ///
5880    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
5881    /// [`Scope::Full`].
5882    ///
5883    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
5884    /// tokens for more than one scope.
5885    ///
5886    /// Usually there is more than one suitable scope to authorize an operation, some of which may
5887    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
5888    /// sufficient, a read-write scope will do as well.
5889    pub fn add_scope<St>(mut self, scope: St) -> CalendarListInsertCall<'a, C>
5890    where
5891        St: AsRef<str>,
5892    {
5893        self._scopes.insert(String::from(scope.as_ref()));
5894        self
5895    }
5896    /// Identifies the authorization scope(s) for the method you are building.
5897    ///
5898    /// See [`Self::add_scope()`] for details.
5899    pub fn add_scopes<I, St>(mut self, scopes: I) -> CalendarListInsertCall<'a, C>
5900    where
5901        I: IntoIterator<Item = St>,
5902        St: AsRef<str>,
5903    {
5904        self._scopes
5905            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
5906        self
5907    }
5908
5909    /// Removes all scopes, and no default scope will be used either.
5910    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
5911    /// for details).
5912    pub fn clear_scopes(mut self) -> CalendarListInsertCall<'a, C> {
5913        self._scopes.clear();
5914        self
5915    }
5916}
5917
5918/// Returns the calendars on the user's calendar list.
5919///
5920/// A builder for the *list* method supported by a *calendarList* resource.
5921/// It is not used directly, but through a [`CalendarListMethods`] instance.
5922///
5923/// # Example
5924///
5925/// Instantiate a resource method builder
5926///
5927/// ```test_harness,no_run
5928/// # extern crate hyper;
5929/// # extern crate hyper_rustls;
5930/// # extern crate google_calendar3 as calendar3;
5931/// # async fn dox() {
5932/// # use calendar3::{CalendarHub, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
5933///
5934/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
5935/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
5936/// #     secret,
5937/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
5938/// # ).build().await.unwrap();
5939///
5940/// # let client = hyper_util::client::legacy::Client::builder(
5941/// #     hyper_util::rt::TokioExecutor::new()
5942/// # )
5943/// # .build(
5944/// #     hyper_rustls::HttpsConnectorBuilder::new()
5945/// #         .with_native_roots()
5946/// #         .unwrap()
5947/// #         .https_or_http()
5948/// #         .enable_http1()
5949/// #         .build()
5950/// # );
5951/// # let mut hub = CalendarHub::new(client, auth);
5952/// // You can configure optional parameters by calling the respective setters at will, and
5953/// // execute the final call using `doit()`.
5954/// // Values shown here are possibly random and not representative !
5955/// let result = hub.calendar_list().list()
5956///              .sync_token("et")
5957///              .show_hidden(false)
5958///              .show_deleted(false)
5959///              .page_token("amet.")
5960///              .min_access_role("ea")
5961///              .max_results(-95)
5962///              .doit().await;
5963/// # }
5964/// ```
5965pub struct CalendarListListCall<'a, C>
5966where
5967    C: 'a,
5968{
5969    hub: &'a CalendarHub<C>,
5970    _sync_token: Option<String>,
5971    _show_hidden: Option<bool>,
5972    _show_deleted: Option<bool>,
5973    _page_token: Option<String>,
5974    _min_access_role: Option<String>,
5975    _max_results: Option<i32>,
5976    _delegate: Option<&'a mut dyn common::Delegate>,
5977    _additional_params: HashMap<String, String>,
5978    _scopes: BTreeSet<String>,
5979}
5980
5981impl<'a, C> common::CallBuilder for CalendarListListCall<'a, C> {}
5982
5983impl<'a, C> CalendarListListCall<'a, C>
5984where
5985    C: common::Connector,
5986{
5987    /// Perform the operation you have build so far.
5988    pub async fn doit(mut self) -> common::Result<(common::Response, CalendarList)> {
5989        use std::borrow::Cow;
5990        use std::io::{Read, Seek};
5991
5992        use common::{url::Params, ToParts};
5993        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
5994
5995        let mut dd = common::DefaultDelegate;
5996        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
5997        dlg.begin(common::MethodInfo {
5998            id: "calendar.calendarList.list",
5999            http_method: hyper::Method::GET,
6000        });
6001
6002        for &field in [
6003            "alt",
6004            "syncToken",
6005            "showHidden",
6006            "showDeleted",
6007            "pageToken",
6008            "minAccessRole",
6009            "maxResults",
6010        ]
6011        .iter()
6012        {
6013            if self._additional_params.contains_key(field) {
6014                dlg.finished(false);
6015                return Err(common::Error::FieldClash(field));
6016            }
6017        }
6018
6019        let mut params = Params::with_capacity(8 + self._additional_params.len());
6020        if let Some(value) = self._sync_token.as_ref() {
6021            params.push("syncToken", value);
6022        }
6023        if let Some(value) = self._show_hidden.as_ref() {
6024            params.push("showHidden", value.to_string());
6025        }
6026        if let Some(value) = self._show_deleted.as_ref() {
6027            params.push("showDeleted", value.to_string());
6028        }
6029        if let Some(value) = self._page_token.as_ref() {
6030            params.push("pageToken", value);
6031        }
6032        if let Some(value) = self._min_access_role.as_ref() {
6033            params.push("minAccessRole", value);
6034        }
6035        if let Some(value) = self._max_results.as_ref() {
6036            params.push("maxResults", value.to_string());
6037        }
6038
6039        params.extend(self._additional_params.iter());
6040
6041        params.push("alt", "json");
6042        let mut url = self.hub._base_url.clone() + "users/me/calendarList";
6043        if self._scopes.is_empty() {
6044            self._scopes.insert(Scope::Readonly.as_ref().to_string());
6045        }
6046
6047        let url = params.parse_with_url(&url);
6048
6049        loop {
6050            let token = match self
6051                .hub
6052                .auth
6053                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
6054                .await
6055            {
6056                Ok(token) => token,
6057                Err(e) => match dlg.token(e) {
6058                    Ok(token) => token,
6059                    Err(e) => {
6060                        dlg.finished(false);
6061                        return Err(common::Error::MissingToken(e));
6062                    }
6063                },
6064            };
6065            let mut req_result = {
6066                let client = &self.hub.client;
6067                dlg.pre_request();
6068                let mut req_builder = hyper::Request::builder()
6069                    .method(hyper::Method::GET)
6070                    .uri(url.as_str())
6071                    .header(USER_AGENT, self.hub._user_agent.clone());
6072
6073                if let Some(token) = token.as_ref() {
6074                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
6075                }
6076
6077                let request = req_builder
6078                    .header(CONTENT_LENGTH, 0_u64)
6079                    .body(common::to_body::<String>(None));
6080
6081                client.request(request.unwrap()).await
6082            };
6083
6084            match req_result {
6085                Err(err) => {
6086                    if let common::Retry::After(d) = dlg.http_error(&err) {
6087                        sleep(d).await;
6088                        continue;
6089                    }
6090                    dlg.finished(false);
6091                    return Err(common::Error::HttpError(err));
6092                }
6093                Ok(res) => {
6094                    let (mut parts, body) = res.into_parts();
6095                    let mut body = common::Body::new(body);
6096                    if !parts.status.is_success() {
6097                        let bytes = common::to_bytes(body).await.unwrap_or_default();
6098                        let error = serde_json::from_str(&common::to_string(&bytes));
6099                        let response = common::to_response(parts, bytes.into());
6100
6101                        if let common::Retry::After(d) =
6102                            dlg.http_failure(&response, error.as_ref().ok())
6103                        {
6104                            sleep(d).await;
6105                            continue;
6106                        }
6107
6108                        dlg.finished(false);
6109
6110                        return Err(match error {
6111                            Ok(value) => common::Error::BadRequest(value),
6112                            _ => common::Error::Failure(response),
6113                        });
6114                    }
6115                    let response = {
6116                        let bytes = common::to_bytes(body).await.unwrap_or_default();
6117                        let encoded = common::to_string(&bytes);
6118                        match serde_json::from_str(&encoded) {
6119                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
6120                            Err(error) => {
6121                                dlg.response_json_decode_error(&encoded, &error);
6122                                return Err(common::Error::JsonDecodeError(
6123                                    encoded.to_string(),
6124                                    error,
6125                                ));
6126                            }
6127                        }
6128                    };
6129
6130                    dlg.finished(true);
6131                    return Ok(response);
6132                }
6133            }
6134        }
6135    }
6136
6137    /// 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. If only read-only fields such as calendar properties or ACLs have changed, the entry won't be returned. All entries deleted and hidden since the previous list request will always be in the result set and it is not allowed to set showDeleted neither showHidden to False.
6138    /// To ensure client state consistency minAccessRole query parameter cannot be specified together with nextSyncToken.
6139    /// 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.
6140    /// Learn more about incremental synchronization.
6141    /// Optional. The default is to return all entries.
6142    ///
6143    /// Sets the *sync token* query property to the given value.
6144    pub fn sync_token(mut self, new_value: &str) -> CalendarListListCall<'a, C> {
6145        self._sync_token = Some(new_value.to_string());
6146        self
6147    }
6148    /// Whether to show hidden entries. Optional. The default is False.
6149    ///
6150    /// Sets the *show hidden* query property to the given value.
6151    pub fn show_hidden(mut self, new_value: bool) -> CalendarListListCall<'a, C> {
6152        self._show_hidden = Some(new_value);
6153        self
6154    }
6155    /// Whether to include deleted calendar list entries in the result. Optional. The default is False.
6156    ///
6157    /// Sets the *show deleted* query property to the given value.
6158    pub fn show_deleted(mut self, new_value: bool) -> CalendarListListCall<'a, C> {
6159        self._show_deleted = Some(new_value);
6160        self
6161    }
6162    /// Token specifying which result page to return. Optional.
6163    ///
6164    /// Sets the *page token* query property to the given value.
6165    pub fn page_token(mut self, new_value: &str) -> CalendarListListCall<'a, C> {
6166        self._page_token = Some(new_value.to_string());
6167        self
6168    }
6169    /// The minimum access role for the user in the returned entries. Optional. The default is no restriction.
6170    ///
6171    /// Sets the *min access role* query property to the given value.
6172    pub fn min_access_role(mut self, new_value: &str) -> CalendarListListCall<'a, C> {
6173        self._min_access_role = Some(new_value.to_string());
6174        self
6175    }
6176    /// Maximum number of entries returned on one result page. By default the value is 100 entries. The page size can never be larger than 250 entries. Optional.
6177    ///
6178    /// Sets the *max results* query property to the given value.
6179    pub fn max_results(mut self, new_value: i32) -> CalendarListListCall<'a, C> {
6180        self._max_results = Some(new_value);
6181        self
6182    }
6183    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
6184    /// while executing the actual API request.
6185    ///
6186    /// ````text
6187    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
6188    /// ````
6189    ///
6190    /// Sets the *delegate* property to the given value.
6191    pub fn delegate(
6192        mut self,
6193        new_value: &'a mut dyn common::Delegate,
6194    ) -> CalendarListListCall<'a, C> {
6195        self._delegate = Some(new_value);
6196        self
6197    }
6198
6199    /// Set any additional parameter of the query string used in the request.
6200    /// It should be used to set parameters which are not yet available through their own
6201    /// setters.
6202    ///
6203    /// Please note that this method must not be used to set any of the known parameters
6204    /// which have their own setter method. If done anyway, the request will fail.
6205    ///
6206    /// # Additional Parameters
6207    ///
6208    /// * *alt* (query-string) - Data format for the response.
6209    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
6210    /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
6211    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
6212    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
6213    /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
6214    /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
6215    pub fn param<T>(mut self, name: T, value: T) -> CalendarListListCall<'a, C>
6216    where
6217        T: AsRef<str>,
6218    {
6219        self._additional_params
6220            .insert(name.as_ref().to_string(), value.as_ref().to_string());
6221        self
6222    }
6223
6224    /// Identifies the authorization scope for the method you are building.
6225    ///
6226    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
6227    /// [`Scope::Readonly`].
6228    ///
6229    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
6230    /// tokens for more than one scope.
6231    ///
6232    /// Usually there is more than one suitable scope to authorize an operation, some of which may
6233    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
6234    /// sufficient, a read-write scope will do as well.
6235    pub fn add_scope<St>(mut self, scope: St) -> CalendarListListCall<'a, C>
6236    where
6237        St: AsRef<str>,
6238    {
6239        self._scopes.insert(String::from(scope.as_ref()));
6240        self
6241    }
6242    /// Identifies the authorization scope(s) for the method you are building.
6243    ///
6244    /// See [`Self::add_scope()`] for details.
6245    pub fn add_scopes<I, St>(mut self, scopes: I) -> CalendarListListCall<'a, C>
6246    where
6247        I: IntoIterator<Item = St>,
6248        St: AsRef<str>,
6249    {
6250        self._scopes
6251            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
6252        self
6253    }
6254
6255    /// Removes all scopes, and no default scope will be used either.
6256    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
6257    /// for details).
6258    pub fn clear_scopes(mut self) -> CalendarListListCall<'a, C> {
6259        self._scopes.clear();
6260        self
6261    }
6262}
6263
6264/// Updates an existing calendar on the user's calendar list. This method supports patch semantics.
6265///
6266/// A builder for the *patch* method supported by a *calendarList* resource.
6267/// It is not used directly, but through a [`CalendarListMethods`] instance.
6268///
6269/// # Example
6270///
6271/// Instantiate a resource method builder
6272///
6273/// ```test_harness,no_run
6274/// # extern crate hyper;
6275/// # extern crate hyper_rustls;
6276/// # extern crate google_calendar3 as calendar3;
6277/// use calendar3::api::CalendarListEntry;
6278/// # async fn dox() {
6279/// # use calendar3::{CalendarHub, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
6280///
6281/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
6282/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
6283/// #     secret,
6284/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
6285/// # ).build().await.unwrap();
6286///
6287/// # let client = hyper_util::client::legacy::Client::builder(
6288/// #     hyper_util::rt::TokioExecutor::new()
6289/// # )
6290/// # .build(
6291/// #     hyper_rustls::HttpsConnectorBuilder::new()
6292/// #         .with_native_roots()
6293/// #         .unwrap()
6294/// #         .https_or_http()
6295/// #         .enable_http1()
6296/// #         .build()
6297/// # );
6298/// # let mut hub = CalendarHub::new(client, auth);
6299/// // As the method needs a request, you would usually fill it with the desired information
6300/// // into the respective structure. Some of the parts shown here might not be applicable !
6301/// // Values shown here are possibly random and not representative !
6302/// let mut req = CalendarListEntry::default();
6303///
6304/// // You can configure optional parameters by calling the respective setters at will, and
6305/// // execute the final call using `doit()`.
6306/// // Values shown here are possibly random and not representative !
6307/// let result = hub.calendar_list().patch(req, "calendarId")
6308///              .color_rgb_format(true)
6309///              .doit().await;
6310/// # }
6311/// ```
6312pub struct CalendarListPatchCall<'a, C>
6313where
6314    C: 'a,
6315{
6316    hub: &'a CalendarHub<C>,
6317    _request: CalendarListEntry,
6318    _calendar_id: String,
6319    _color_rgb_format: Option<bool>,
6320    _delegate: Option<&'a mut dyn common::Delegate>,
6321    _additional_params: HashMap<String, String>,
6322    _scopes: BTreeSet<String>,
6323}
6324
6325impl<'a, C> common::CallBuilder for CalendarListPatchCall<'a, C> {}
6326
6327impl<'a, C> CalendarListPatchCall<'a, C>
6328where
6329    C: common::Connector,
6330{
6331    /// Perform the operation you have build so far.
6332    pub async fn doit(mut self) -> common::Result<(common::Response, CalendarListEntry)> {
6333        use std::borrow::Cow;
6334        use std::io::{Read, Seek};
6335
6336        use common::{url::Params, ToParts};
6337        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
6338
6339        let mut dd = common::DefaultDelegate;
6340        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
6341        dlg.begin(common::MethodInfo {
6342            id: "calendar.calendarList.patch",
6343            http_method: hyper::Method::PATCH,
6344        });
6345
6346        for &field in ["alt", "calendarId", "colorRgbFormat"].iter() {
6347            if self._additional_params.contains_key(field) {
6348                dlg.finished(false);
6349                return Err(common::Error::FieldClash(field));
6350            }
6351        }
6352
6353        let mut params = Params::with_capacity(5 + self._additional_params.len());
6354        params.push("calendarId", self._calendar_id);
6355        if let Some(value) = self._color_rgb_format.as_ref() {
6356            params.push("colorRgbFormat", value.to_string());
6357        }
6358
6359        params.extend(self._additional_params.iter());
6360
6361        params.push("alt", "json");
6362        let mut url = self.hub._base_url.clone() + "users/me/calendarList/{calendarId}";
6363        if self._scopes.is_empty() {
6364            self._scopes.insert(Scope::Full.as_ref().to_string());
6365        }
6366
6367        #[allow(clippy::single_element_loop)]
6368        for &(find_this, param_name) in [("{calendarId}", "calendarId")].iter() {
6369            url = params.uri_replacement(url, param_name, find_this, false);
6370        }
6371        {
6372            let to_remove = ["calendarId"];
6373            params.remove_params(&to_remove);
6374        }
6375
6376        let url = params.parse_with_url(&url);
6377
6378        let mut json_mime_type = mime::APPLICATION_JSON;
6379        let mut request_value_reader = {
6380            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
6381            common::remove_json_null_values(&mut value);
6382            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
6383            serde_json::to_writer(&mut dst, &value).unwrap();
6384            dst
6385        };
6386        let request_size = request_value_reader
6387            .seek(std::io::SeekFrom::End(0))
6388            .unwrap();
6389        request_value_reader
6390            .seek(std::io::SeekFrom::Start(0))
6391            .unwrap();
6392
6393        loop {
6394            let token = match self
6395                .hub
6396                .auth
6397                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
6398                .await
6399            {
6400                Ok(token) => token,
6401                Err(e) => match dlg.token(e) {
6402                    Ok(token) => token,
6403                    Err(e) => {
6404                        dlg.finished(false);
6405                        return Err(common::Error::MissingToken(e));
6406                    }
6407                },
6408            };
6409            request_value_reader
6410                .seek(std::io::SeekFrom::Start(0))
6411                .unwrap();
6412            let mut req_result = {
6413                let client = &self.hub.client;
6414                dlg.pre_request();
6415                let mut req_builder = hyper::Request::builder()
6416                    .method(hyper::Method::PATCH)
6417                    .uri(url.as_str())
6418                    .header(USER_AGENT, self.hub._user_agent.clone());
6419
6420                if let Some(token) = token.as_ref() {
6421                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
6422                }
6423
6424                let request = req_builder
6425                    .header(CONTENT_TYPE, json_mime_type.to_string())
6426                    .header(CONTENT_LENGTH, request_size as u64)
6427                    .body(common::to_body(
6428                        request_value_reader.get_ref().clone().into(),
6429                    ));
6430
6431                client.request(request.unwrap()).await
6432            };
6433
6434            match req_result {
6435                Err(err) => {
6436                    if let common::Retry::After(d) = dlg.http_error(&err) {
6437                        sleep(d).await;
6438                        continue;
6439                    }
6440                    dlg.finished(false);
6441                    return Err(common::Error::HttpError(err));
6442                }
6443                Ok(res) => {
6444                    let (mut parts, body) = res.into_parts();
6445                    let mut body = common::Body::new(body);
6446                    if !parts.status.is_success() {
6447                        let bytes = common::to_bytes(body).await.unwrap_or_default();
6448                        let error = serde_json::from_str(&common::to_string(&bytes));
6449                        let response = common::to_response(parts, bytes.into());
6450
6451                        if let common::Retry::After(d) =
6452                            dlg.http_failure(&response, error.as_ref().ok())
6453                        {
6454                            sleep(d).await;
6455                            continue;
6456                        }
6457
6458                        dlg.finished(false);
6459
6460                        return Err(match error {
6461                            Ok(value) => common::Error::BadRequest(value),
6462                            _ => common::Error::Failure(response),
6463                        });
6464                    }
6465                    let response = {
6466                        let bytes = common::to_bytes(body).await.unwrap_or_default();
6467                        let encoded = common::to_string(&bytes);
6468                        match serde_json::from_str(&encoded) {
6469                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
6470                            Err(error) => {
6471                                dlg.response_json_decode_error(&encoded, &error);
6472                                return Err(common::Error::JsonDecodeError(
6473                                    encoded.to_string(),
6474                                    error,
6475                                ));
6476                            }
6477                        }
6478                    };
6479
6480                    dlg.finished(true);
6481                    return Ok(response);
6482                }
6483            }
6484        }
6485    }
6486
6487    ///
6488    /// Sets the *request* property to the given value.
6489    ///
6490    /// Even though the property as already been set when instantiating this call,
6491    /// we provide this method for API completeness.
6492    pub fn request(mut self, new_value: CalendarListEntry) -> CalendarListPatchCall<'a, C> {
6493        self._request = new_value;
6494        self
6495    }
6496    /// 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.
6497    ///
6498    /// Sets the *calendar id* path property to the given value.
6499    ///
6500    /// Even though the property as already been set when instantiating this call,
6501    /// we provide this method for API completeness.
6502    pub fn calendar_id(mut self, new_value: &str) -> CalendarListPatchCall<'a, C> {
6503        self._calendar_id = new_value.to_string();
6504        self
6505    }
6506    /// Whether to use the foregroundColor and backgroundColor fields to write the calendar colors (RGB). If this feature is used, the index-based colorId field will be set to the best matching option automatically. Optional. The default is False.
6507    ///
6508    /// Sets the *color rgb format* query property to the given value.
6509    pub fn color_rgb_format(mut self, new_value: bool) -> CalendarListPatchCall<'a, C> {
6510        self._color_rgb_format = Some(new_value);
6511        self
6512    }
6513    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
6514    /// while executing the actual API request.
6515    ///
6516    /// ````text
6517    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
6518    /// ````
6519    ///
6520    /// Sets the *delegate* property to the given value.
6521    pub fn delegate(
6522        mut self,
6523        new_value: &'a mut dyn common::Delegate,
6524    ) -> CalendarListPatchCall<'a, C> {
6525        self._delegate = Some(new_value);
6526        self
6527    }
6528
6529    /// Set any additional parameter of the query string used in the request.
6530    /// It should be used to set parameters which are not yet available through their own
6531    /// setters.
6532    ///
6533    /// Please note that this method must not be used to set any of the known parameters
6534    /// which have their own setter method. If done anyway, the request will fail.
6535    ///
6536    /// # Additional Parameters
6537    ///
6538    /// * *alt* (query-string) - Data format for the response.
6539    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
6540    /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
6541    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
6542    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
6543    /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
6544    /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
6545    pub fn param<T>(mut self, name: T, value: T) -> CalendarListPatchCall<'a, C>
6546    where
6547        T: AsRef<str>,
6548    {
6549        self._additional_params
6550            .insert(name.as_ref().to_string(), value.as_ref().to_string());
6551        self
6552    }
6553
6554    /// Identifies the authorization scope for the method you are building.
6555    ///
6556    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
6557    /// [`Scope::Full`].
6558    ///
6559    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
6560    /// tokens for more than one scope.
6561    ///
6562    /// Usually there is more than one suitable scope to authorize an operation, some of which may
6563    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
6564    /// sufficient, a read-write scope will do as well.
6565    pub fn add_scope<St>(mut self, scope: St) -> CalendarListPatchCall<'a, C>
6566    where
6567        St: AsRef<str>,
6568    {
6569        self._scopes.insert(String::from(scope.as_ref()));
6570        self
6571    }
6572    /// Identifies the authorization scope(s) for the method you are building.
6573    ///
6574    /// See [`Self::add_scope()`] for details.
6575    pub fn add_scopes<I, St>(mut self, scopes: I) -> CalendarListPatchCall<'a, C>
6576    where
6577        I: IntoIterator<Item = St>,
6578        St: AsRef<str>,
6579    {
6580        self._scopes
6581            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
6582        self
6583    }
6584
6585    /// Removes all scopes, and no default scope will be used either.
6586    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
6587    /// for details).
6588    pub fn clear_scopes(mut self) -> CalendarListPatchCall<'a, C> {
6589        self._scopes.clear();
6590        self
6591    }
6592}
6593
6594/// Updates an existing calendar on the user's calendar list.
6595///
6596/// A builder for the *update* method supported by a *calendarList* resource.
6597/// It is not used directly, but through a [`CalendarListMethods`] instance.
6598///
6599/// # Example
6600///
6601/// Instantiate a resource method builder
6602///
6603/// ```test_harness,no_run
6604/// # extern crate hyper;
6605/// # extern crate hyper_rustls;
6606/// # extern crate google_calendar3 as calendar3;
6607/// use calendar3::api::CalendarListEntry;
6608/// # async fn dox() {
6609/// # use calendar3::{CalendarHub, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
6610///
6611/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
6612/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
6613/// #     secret,
6614/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
6615/// # ).build().await.unwrap();
6616///
6617/// # let client = hyper_util::client::legacy::Client::builder(
6618/// #     hyper_util::rt::TokioExecutor::new()
6619/// # )
6620/// # .build(
6621/// #     hyper_rustls::HttpsConnectorBuilder::new()
6622/// #         .with_native_roots()
6623/// #         .unwrap()
6624/// #         .https_or_http()
6625/// #         .enable_http1()
6626/// #         .build()
6627/// # );
6628/// # let mut hub = CalendarHub::new(client, auth);
6629/// // As the method needs a request, you would usually fill it with the desired information
6630/// // into the respective structure. Some of the parts shown here might not be applicable !
6631/// // Values shown here are possibly random and not representative !
6632/// let mut req = CalendarListEntry::default();
6633///
6634/// // You can configure optional parameters by calling the respective setters at will, and
6635/// // execute the final call using `doit()`.
6636/// // Values shown here are possibly random and not representative !
6637/// let result = hub.calendar_list().update(req, "calendarId")
6638///              .color_rgb_format(true)
6639///              .doit().await;
6640/// # }
6641/// ```
6642pub struct CalendarListUpdateCall<'a, C>
6643where
6644    C: 'a,
6645{
6646    hub: &'a CalendarHub<C>,
6647    _request: CalendarListEntry,
6648    _calendar_id: String,
6649    _color_rgb_format: Option<bool>,
6650    _delegate: Option<&'a mut dyn common::Delegate>,
6651    _additional_params: HashMap<String, String>,
6652    _scopes: BTreeSet<String>,
6653}
6654
6655impl<'a, C> common::CallBuilder for CalendarListUpdateCall<'a, C> {}
6656
6657impl<'a, C> CalendarListUpdateCall<'a, C>
6658where
6659    C: common::Connector,
6660{
6661    /// Perform the operation you have build so far.
6662    pub async fn doit(mut self) -> common::Result<(common::Response, CalendarListEntry)> {
6663        use std::borrow::Cow;
6664        use std::io::{Read, Seek};
6665
6666        use common::{url::Params, ToParts};
6667        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
6668
6669        let mut dd = common::DefaultDelegate;
6670        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
6671        dlg.begin(common::MethodInfo {
6672            id: "calendar.calendarList.update",
6673            http_method: hyper::Method::PUT,
6674        });
6675
6676        for &field in ["alt", "calendarId", "colorRgbFormat"].iter() {
6677            if self._additional_params.contains_key(field) {
6678                dlg.finished(false);
6679                return Err(common::Error::FieldClash(field));
6680            }
6681        }
6682
6683        let mut params = Params::with_capacity(5 + self._additional_params.len());
6684        params.push("calendarId", self._calendar_id);
6685        if let Some(value) = self._color_rgb_format.as_ref() {
6686            params.push("colorRgbFormat", value.to_string());
6687        }
6688
6689        params.extend(self._additional_params.iter());
6690
6691        params.push("alt", "json");
6692        let mut url = self.hub._base_url.clone() + "users/me/calendarList/{calendarId}";
6693        if self._scopes.is_empty() {
6694            self._scopes.insert(Scope::Full.as_ref().to_string());
6695        }
6696
6697        #[allow(clippy::single_element_loop)]
6698        for &(find_this, param_name) in [("{calendarId}", "calendarId")].iter() {
6699            url = params.uri_replacement(url, param_name, find_this, false);
6700        }
6701        {
6702            let to_remove = ["calendarId"];
6703            params.remove_params(&to_remove);
6704        }
6705
6706        let url = params.parse_with_url(&url);
6707
6708        let mut json_mime_type = mime::APPLICATION_JSON;
6709        let mut request_value_reader = {
6710            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
6711            common::remove_json_null_values(&mut value);
6712            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
6713            serde_json::to_writer(&mut dst, &value).unwrap();
6714            dst
6715        };
6716        let request_size = request_value_reader
6717            .seek(std::io::SeekFrom::End(0))
6718            .unwrap();
6719        request_value_reader
6720            .seek(std::io::SeekFrom::Start(0))
6721            .unwrap();
6722
6723        loop {
6724            let token = match self
6725                .hub
6726                .auth
6727                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
6728                .await
6729            {
6730                Ok(token) => token,
6731                Err(e) => match dlg.token(e) {
6732                    Ok(token) => token,
6733                    Err(e) => {
6734                        dlg.finished(false);
6735                        return Err(common::Error::MissingToken(e));
6736                    }
6737                },
6738            };
6739            request_value_reader
6740                .seek(std::io::SeekFrom::Start(0))
6741                .unwrap();
6742            let mut req_result = {
6743                let client = &self.hub.client;
6744                dlg.pre_request();
6745                let mut req_builder = hyper::Request::builder()
6746                    .method(hyper::Method::PUT)
6747                    .uri(url.as_str())
6748                    .header(USER_AGENT, self.hub._user_agent.clone());
6749
6750                if let Some(token) = token.as_ref() {
6751                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
6752                }
6753
6754                let request = req_builder
6755                    .header(CONTENT_TYPE, json_mime_type.to_string())
6756                    .header(CONTENT_LENGTH, request_size as u64)
6757                    .body(common::to_body(
6758                        request_value_reader.get_ref().clone().into(),
6759                    ));
6760
6761                client.request(request.unwrap()).await
6762            };
6763
6764            match req_result {
6765                Err(err) => {
6766                    if let common::Retry::After(d) = dlg.http_error(&err) {
6767                        sleep(d).await;
6768                        continue;
6769                    }
6770                    dlg.finished(false);
6771                    return Err(common::Error::HttpError(err));
6772                }
6773                Ok(res) => {
6774                    let (mut parts, body) = res.into_parts();
6775                    let mut body = common::Body::new(body);
6776                    if !parts.status.is_success() {
6777                        let bytes = common::to_bytes(body).await.unwrap_or_default();
6778                        let error = serde_json::from_str(&common::to_string(&bytes));
6779                        let response = common::to_response(parts, bytes.into());
6780
6781                        if let common::Retry::After(d) =
6782                            dlg.http_failure(&response, error.as_ref().ok())
6783                        {
6784                            sleep(d).await;
6785                            continue;
6786                        }
6787
6788                        dlg.finished(false);
6789
6790                        return Err(match error {
6791                            Ok(value) => common::Error::BadRequest(value),
6792                            _ => common::Error::Failure(response),
6793                        });
6794                    }
6795                    let response = {
6796                        let bytes = common::to_bytes(body).await.unwrap_or_default();
6797                        let encoded = common::to_string(&bytes);
6798                        match serde_json::from_str(&encoded) {
6799                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
6800                            Err(error) => {
6801                                dlg.response_json_decode_error(&encoded, &error);
6802                                return Err(common::Error::JsonDecodeError(
6803                                    encoded.to_string(),
6804                                    error,
6805                                ));
6806                            }
6807                        }
6808                    };
6809
6810                    dlg.finished(true);
6811                    return Ok(response);
6812                }
6813            }
6814        }
6815    }
6816
6817    ///
6818    /// Sets the *request* property to the given value.
6819    ///
6820    /// Even though the property as already been set when instantiating this call,
6821    /// we provide this method for API completeness.
6822    pub fn request(mut self, new_value: CalendarListEntry) -> CalendarListUpdateCall<'a, C> {
6823        self._request = new_value;
6824        self
6825    }
6826    /// 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.
6827    ///
6828    /// Sets the *calendar id* path property to the given value.
6829    ///
6830    /// Even though the property as already been set when instantiating this call,
6831    /// we provide this method for API completeness.
6832    pub fn calendar_id(mut self, new_value: &str) -> CalendarListUpdateCall<'a, C> {
6833        self._calendar_id = new_value.to_string();
6834        self
6835    }
6836    /// Whether to use the foregroundColor and backgroundColor fields to write the calendar colors (RGB). If this feature is used, the index-based colorId field will be set to the best matching option automatically. Optional. The default is False.
6837    ///
6838    /// Sets the *color rgb format* query property to the given value.
6839    pub fn color_rgb_format(mut self, new_value: bool) -> CalendarListUpdateCall<'a, C> {
6840        self._color_rgb_format = Some(new_value);
6841        self
6842    }
6843    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
6844    /// while executing the actual API request.
6845    ///
6846    /// ````text
6847    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
6848    /// ````
6849    ///
6850    /// Sets the *delegate* property to the given value.
6851    pub fn delegate(
6852        mut self,
6853        new_value: &'a mut dyn common::Delegate,
6854    ) -> CalendarListUpdateCall<'a, C> {
6855        self._delegate = Some(new_value);
6856        self
6857    }
6858
6859    /// Set any additional parameter of the query string used in the request.
6860    /// It should be used to set parameters which are not yet available through their own
6861    /// setters.
6862    ///
6863    /// Please note that this method must not be used to set any of the known parameters
6864    /// which have their own setter method. If done anyway, the request will fail.
6865    ///
6866    /// # Additional Parameters
6867    ///
6868    /// * *alt* (query-string) - Data format for the response.
6869    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
6870    /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
6871    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
6872    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
6873    /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
6874    /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
6875    pub fn param<T>(mut self, name: T, value: T) -> CalendarListUpdateCall<'a, C>
6876    where
6877        T: AsRef<str>,
6878    {
6879        self._additional_params
6880            .insert(name.as_ref().to_string(), value.as_ref().to_string());
6881        self
6882    }
6883
6884    /// Identifies the authorization scope for the method you are building.
6885    ///
6886    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
6887    /// [`Scope::Full`].
6888    ///
6889    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
6890    /// tokens for more than one scope.
6891    ///
6892    /// Usually there is more than one suitable scope to authorize an operation, some of which may
6893    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
6894    /// sufficient, a read-write scope will do as well.
6895    pub fn add_scope<St>(mut self, scope: St) -> CalendarListUpdateCall<'a, C>
6896    where
6897        St: AsRef<str>,
6898    {
6899        self._scopes.insert(String::from(scope.as_ref()));
6900        self
6901    }
6902    /// Identifies the authorization scope(s) for the method you are building.
6903    ///
6904    /// See [`Self::add_scope()`] for details.
6905    pub fn add_scopes<I, St>(mut self, scopes: I) -> CalendarListUpdateCall<'a, C>
6906    where
6907        I: IntoIterator<Item = St>,
6908        St: AsRef<str>,
6909    {
6910        self._scopes
6911            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
6912        self
6913    }
6914
6915    /// Removes all scopes, and no default scope will be used either.
6916    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
6917    /// for details).
6918    pub fn clear_scopes(mut self) -> CalendarListUpdateCall<'a, C> {
6919        self._scopes.clear();
6920        self
6921    }
6922}
6923
6924/// Watch for changes to CalendarList resources.
6925///
6926/// A builder for the *watch* method supported by a *calendarList* resource.
6927/// It is not used directly, but through a [`CalendarListMethods`] instance.
6928///
6929/// # Example
6930///
6931/// Instantiate a resource method builder
6932///
6933/// ```test_harness,no_run
6934/// # extern crate hyper;
6935/// # extern crate hyper_rustls;
6936/// # extern crate google_calendar3 as calendar3;
6937/// use calendar3::api::Channel;
6938/// # async fn dox() {
6939/// # use calendar3::{CalendarHub, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
6940///
6941/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
6942/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
6943/// #     secret,
6944/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
6945/// # ).build().await.unwrap();
6946///
6947/// # let client = hyper_util::client::legacy::Client::builder(
6948/// #     hyper_util::rt::TokioExecutor::new()
6949/// # )
6950/// # .build(
6951/// #     hyper_rustls::HttpsConnectorBuilder::new()
6952/// #         .with_native_roots()
6953/// #         .unwrap()
6954/// #         .https_or_http()
6955/// #         .enable_http1()
6956/// #         .build()
6957/// # );
6958/// # let mut hub = CalendarHub::new(client, auth);
6959/// // As the method needs a request, you would usually fill it with the desired information
6960/// // into the respective structure. Some of the parts shown here might not be applicable !
6961/// // Values shown here are possibly random and not representative !
6962/// let mut req = Channel::default();
6963///
6964/// // You can configure optional parameters by calling the respective setters at will, and
6965/// // execute the final call using `doit()`.
6966/// // Values shown here are possibly random and not representative !
6967/// let result = hub.calendar_list().watch(req)
6968///              .sync_token("sit")
6969///              .show_hidden(true)
6970///              .show_deleted(true)
6971///              .page_token("est")
6972///              .min_access_role("sed")
6973///              .max_results(-29)
6974///              .doit().await;
6975/// # }
6976/// ```
6977pub struct CalendarListWatchCall<'a, C>
6978where
6979    C: 'a,
6980{
6981    hub: &'a CalendarHub<C>,
6982    _request: Channel,
6983    _sync_token: Option<String>,
6984    _show_hidden: Option<bool>,
6985    _show_deleted: Option<bool>,
6986    _page_token: Option<String>,
6987    _min_access_role: Option<String>,
6988    _max_results: Option<i32>,
6989    _delegate: Option<&'a mut dyn common::Delegate>,
6990    _additional_params: HashMap<String, String>,
6991    _scopes: BTreeSet<String>,
6992}
6993
6994impl<'a, C> common::CallBuilder for CalendarListWatchCall<'a, C> {}
6995
6996impl<'a, C> CalendarListWatchCall<'a, C>
6997where
6998    C: common::Connector,
6999{
7000    /// Perform the operation you have build so far.
7001    pub async fn doit(mut self) -> common::Result<(common::Response, Channel)> {
7002        use std::borrow::Cow;
7003        use std::io::{Read, Seek};
7004
7005        use common::{url::Params, ToParts};
7006        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
7007
7008        let mut dd = common::DefaultDelegate;
7009        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
7010        dlg.begin(common::MethodInfo {
7011            id: "calendar.calendarList.watch",
7012            http_method: hyper::Method::POST,
7013        });
7014
7015        for &field in [
7016            "alt",
7017            "syncToken",
7018            "showHidden",
7019            "showDeleted",
7020            "pageToken",
7021            "minAccessRole",
7022            "maxResults",
7023        ]
7024        .iter()
7025        {
7026            if self._additional_params.contains_key(field) {
7027                dlg.finished(false);
7028                return Err(common::Error::FieldClash(field));
7029            }
7030        }
7031
7032        let mut params = Params::with_capacity(9 + self._additional_params.len());
7033        if let Some(value) = self._sync_token.as_ref() {
7034            params.push("syncToken", value);
7035        }
7036        if let Some(value) = self._show_hidden.as_ref() {
7037            params.push("showHidden", value.to_string());
7038        }
7039        if let Some(value) = self._show_deleted.as_ref() {
7040            params.push("showDeleted", value.to_string());
7041        }
7042        if let Some(value) = self._page_token.as_ref() {
7043            params.push("pageToken", value);
7044        }
7045        if let Some(value) = self._min_access_role.as_ref() {
7046            params.push("minAccessRole", value);
7047        }
7048        if let Some(value) = self._max_results.as_ref() {
7049            params.push("maxResults", value.to_string());
7050        }
7051
7052        params.extend(self._additional_params.iter());
7053
7054        params.push("alt", "json");
7055        let mut url = self.hub._base_url.clone() + "users/me/calendarList/watch";
7056        if self._scopes.is_empty() {
7057            self._scopes.insert(Scope::Full.as_ref().to_string());
7058        }
7059
7060        let url = params.parse_with_url(&url);
7061
7062        let mut json_mime_type = mime::APPLICATION_JSON;
7063        let mut request_value_reader = {
7064            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
7065            common::remove_json_null_values(&mut value);
7066            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
7067            serde_json::to_writer(&mut dst, &value).unwrap();
7068            dst
7069        };
7070        let request_size = request_value_reader
7071            .seek(std::io::SeekFrom::End(0))
7072            .unwrap();
7073        request_value_reader
7074            .seek(std::io::SeekFrom::Start(0))
7075            .unwrap();
7076
7077        loop {
7078            let token = match self
7079                .hub
7080                .auth
7081                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
7082                .await
7083            {
7084                Ok(token) => token,
7085                Err(e) => match dlg.token(e) {
7086                    Ok(token) => token,
7087                    Err(e) => {
7088                        dlg.finished(false);
7089                        return Err(common::Error::MissingToken(e));
7090                    }
7091                },
7092            };
7093            request_value_reader
7094                .seek(std::io::SeekFrom::Start(0))
7095                .unwrap();
7096            let mut req_result = {
7097                let client = &self.hub.client;
7098                dlg.pre_request();
7099                let mut req_builder = hyper::Request::builder()
7100                    .method(hyper::Method::POST)
7101                    .uri(url.as_str())
7102                    .header(USER_AGENT, self.hub._user_agent.clone());
7103
7104                if let Some(token) = token.as_ref() {
7105                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
7106                }
7107
7108                let request = req_builder
7109                    .header(CONTENT_TYPE, json_mime_type.to_string())
7110                    .header(CONTENT_LENGTH, request_size as u64)
7111                    .body(common::to_body(
7112                        request_value_reader.get_ref().clone().into(),
7113                    ));
7114
7115                client.request(request.unwrap()).await
7116            };
7117
7118            match req_result {
7119                Err(err) => {
7120                    if let common::Retry::After(d) = dlg.http_error(&err) {
7121                        sleep(d).await;
7122                        continue;
7123                    }
7124                    dlg.finished(false);
7125                    return Err(common::Error::HttpError(err));
7126                }
7127                Ok(res) => {
7128                    let (mut parts, body) = res.into_parts();
7129                    let mut body = common::Body::new(body);
7130                    if !parts.status.is_success() {
7131                        let bytes = common::to_bytes(body).await.unwrap_or_default();
7132                        let error = serde_json::from_str(&common::to_string(&bytes));
7133                        let response = common::to_response(parts, bytes.into());
7134
7135                        if let common::Retry::After(d) =
7136                            dlg.http_failure(&response, error.as_ref().ok())
7137                        {
7138                            sleep(d).await;
7139                            continue;
7140                        }
7141
7142                        dlg.finished(false);
7143
7144                        return Err(match error {
7145                            Ok(value) => common::Error::BadRequest(value),
7146                            _ => common::Error::Failure(response),
7147                        });
7148                    }
7149                    let response = {
7150                        let bytes = common::to_bytes(body).await.unwrap_or_default();
7151                        let encoded = common::to_string(&bytes);
7152                        match serde_json::from_str(&encoded) {
7153                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
7154                            Err(error) => {
7155                                dlg.response_json_decode_error(&encoded, &error);
7156                                return Err(common::Error::JsonDecodeError(
7157                                    encoded.to_string(),
7158                                    error,
7159                                ));
7160                            }
7161                        }
7162                    };
7163
7164                    dlg.finished(true);
7165                    return Ok(response);
7166                }
7167            }
7168        }
7169    }
7170
7171    ///
7172    /// Sets the *request* property to the given value.
7173    ///
7174    /// Even though the property as already been set when instantiating this call,
7175    /// we provide this method for API completeness.
7176    pub fn request(mut self, new_value: Channel) -> CalendarListWatchCall<'a, C> {
7177        self._request = new_value;
7178        self
7179    }
7180    /// 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. If only read-only fields such as calendar properties or ACLs have changed, the entry won't be returned. All entries deleted and hidden since the previous list request will always be in the result set and it is not allowed to set showDeleted neither showHidden to False.
7181    /// To ensure client state consistency minAccessRole query parameter cannot be specified together with nextSyncToken.
7182    /// 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.
7183    /// Learn more about incremental synchronization.
7184    /// Optional. The default is to return all entries.
7185    ///
7186    /// Sets the *sync token* query property to the given value.
7187    pub fn sync_token(mut self, new_value: &str) -> CalendarListWatchCall<'a, C> {
7188        self._sync_token = Some(new_value.to_string());
7189        self
7190    }
7191    /// Whether to show hidden entries. Optional. The default is False.
7192    ///
7193    /// Sets the *show hidden* query property to the given value.
7194    pub fn show_hidden(mut self, new_value: bool) -> CalendarListWatchCall<'a, C> {
7195        self._show_hidden = Some(new_value);
7196        self
7197    }
7198    /// Whether to include deleted calendar list entries in the result. Optional. The default is False.
7199    ///
7200    /// Sets the *show deleted* query property to the given value.
7201    pub fn show_deleted(mut self, new_value: bool) -> CalendarListWatchCall<'a, C> {
7202        self._show_deleted = Some(new_value);
7203        self
7204    }
7205    /// Token specifying which result page to return. Optional.
7206    ///
7207    /// Sets the *page token* query property to the given value.
7208    pub fn page_token(mut self, new_value: &str) -> CalendarListWatchCall<'a, C> {
7209        self._page_token = Some(new_value.to_string());
7210        self
7211    }
7212    /// The minimum access role for the user in the returned entries. Optional. The default is no restriction.
7213    ///
7214    /// Sets the *min access role* query property to the given value.
7215    pub fn min_access_role(mut self, new_value: &str) -> CalendarListWatchCall<'a, C> {
7216        self._min_access_role = Some(new_value.to_string());
7217        self
7218    }
7219    /// Maximum number of entries returned on one result page. By default the value is 100 entries. The page size can never be larger than 250 entries. Optional.
7220    ///
7221    /// Sets the *max results* query property to the given value.
7222    pub fn max_results(mut self, new_value: i32) -> CalendarListWatchCall<'a, C> {
7223        self._max_results = Some(new_value);
7224        self
7225    }
7226    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
7227    /// while executing the actual API request.
7228    ///
7229    /// ````text
7230    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
7231    /// ````
7232    ///
7233    /// Sets the *delegate* property to the given value.
7234    pub fn delegate(
7235        mut self,
7236        new_value: &'a mut dyn common::Delegate,
7237    ) -> CalendarListWatchCall<'a, C> {
7238        self._delegate = Some(new_value);
7239        self
7240    }
7241
7242    /// Set any additional parameter of the query string used in the request.
7243    /// It should be used to set parameters which are not yet available through their own
7244    /// setters.
7245    ///
7246    /// Please note that this method must not be used to set any of the known parameters
7247    /// which have their own setter method. If done anyway, the request will fail.
7248    ///
7249    /// # Additional Parameters
7250    ///
7251    /// * *alt* (query-string) - Data format for the response.
7252    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
7253    /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
7254    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
7255    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
7256    /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
7257    /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
7258    pub fn param<T>(mut self, name: T, value: T) -> CalendarListWatchCall<'a, C>
7259    where
7260        T: AsRef<str>,
7261    {
7262        self._additional_params
7263            .insert(name.as_ref().to_string(), value.as_ref().to_string());
7264        self
7265    }
7266
7267    /// Identifies the authorization scope for the method you are building.
7268    ///
7269    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
7270    /// [`Scope::Full`].
7271    ///
7272    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
7273    /// tokens for more than one scope.
7274    ///
7275    /// Usually there is more than one suitable scope to authorize an operation, some of which may
7276    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
7277    /// sufficient, a read-write scope will do as well.
7278    pub fn add_scope<St>(mut self, scope: St) -> CalendarListWatchCall<'a, C>
7279    where
7280        St: AsRef<str>,
7281    {
7282        self._scopes.insert(String::from(scope.as_ref()));
7283        self
7284    }
7285    /// Identifies the authorization scope(s) for the method you are building.
7286    ///
7287    /// See [`Self::add_scope()`] for details.
7288    pub fn add_scopes<I, St>(mut self, scopes: I) -> CalendarListWatchCall<'a, C>
7289    where
7290        I: IntoIterator<Item = St>,
7291        St: AsRef<str>,
7292    {
7293        self._scopes
7294            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
7295        self
7296    }
7297
7298    /// Removes all scopes, and no default scope will be used either.
7299    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
7300    /// for details).
7301    pub fn clear_scopes(mut self) -> CalendarListWatchCall<'a, C> {
7302        self._scopes.clear();
7303        self
7304    }
7305}
7306
7307/// Clears a primary calendar. This operation deletes all events associated with the primary calendar of an account.
7308///
7309/// A builder for the *clear* method supported by a *calendar* resource.
7310/// It is not used directly, but through a [`CalendarMethods`] instance.
7311///
7312/// # Example
7313///
7314/// Instantiate a resource method builder
7315///
7316/// ```test_harness,no_run
7317/// # extern crate hyper;
7318/// # extern crate hyper_rustls;
7319/// # extern crate google_calendar3 as calendar3;
7320/// # async fn dox() {
7321/// # use calendar3::{CalendarHub, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
7322///
7323/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
7324/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
7325/// #     secret,
7326/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
7327/// # ).build().await.unwrap();
7328///
7329/// # let client = hyper_util::client::legacy::Client::builder(
7330/// #     hyper_util::rt::TokioExecutor::new()
7331/// # )
7332/// # .build(
7333/// #     hyper_rustls::HttpsConnectorBuilder::new()
7334/// #         .with_native_roots()
7335/// #         .unwrap()
7336/// #         .https_or_http()
7337/// #         .enable_http1()
7338/// #         .build()
7339/// # );
7340/// # let mut hub = CalendarHub::new(client, auth);
7341/// // You can configure optional parameters by calling the respective setters at will, and
7342/// // execute the final call using `doit()`.
7343/// // Values shown here are possibly random and not representative !
7344/// let result = hub.calendars().clear("calendarId")
7345///              .doit().await;
7346/// # }
7347/// ```
7348pub struct CalendarClearCall<'a, C>
7349where
7350    C: 'a,
7351{
7352    hub: &'a CalendarHub<C>,
7353    _calendar_id: String,
7354    _delegate: Option<&'a mut dyn common::Delegate>,
7355    _additional_params: HashMap<String, String>,
7356    _scopes: BTreeSet<String>,
7357}
7358
7359impl<'a, C> common::CallBuilder for CalendarClearCall<'a, C> {}
7360
7361impl<'a, C> CalendarClearCall<'a, C>
7362where
7363    C: common::Connector,
7364{
7365    /// Perform the operation you have build so far.
7366    pub async fn doit(mut self) -> common::Result<common::Response> {
7367        use std::borrow::Cow;
7368        use std::io::{Read, Seek};
7369
7370        use common::{url::Params, ToParts};
7371        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
7372
7373        let mut dd = common::DefaultDelegate;
7374        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
7375        dlg.begin(common::MethodInfo {
7376            id: "calendar.calendars.clear",
7377            http_method: hyper::Method::POST,
7378        });
7379
7380        for &field in ["calendarId"].iter() {
7381            if self._additional_params.contains_key(field) {
7382                dlg.finished(false);
7383                return Err(common::Error::FieldClash(field));
7384            }
7385        }
7386
7387        let mut params = Params::with_capacity(2 + self._additional_params.len());
7388        params.push("calendarId", self._calendar_id);
7389
7390        params.extend(self._additional_params.iter());
7391
7392        let mut url = self.hub._base_url.clone() + "calendars/{calendarId}/clear";
7393        if self._scopes.is_empty() {
7394            self._scopes.insert(Scope::Full.as_ref().to_string());
7395        }
7396
7397        #[allow(clippy::single_element_loop)]
7398        for &(find_this, param_name) in [("{calendarId}", "calendarId")].iter() {
7399            url = params.uri_replacement(url, param_name, find_this, false);
7400        }
7401        {
7402            let to_remove = ["calendarId"];
7403            params.remove_params(&to_remove);
7404        }
7405
7406        let url = params.parse_with_url(&url);
7407
7408        loop {
7409            let token = match self
7410                .hub
7411                .auth
7412                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
7413                .await
7414            {
7415                Ok(token) => token,
7416                Err(e) => match dlg.token(e) {
7417                    Ok(token) => token,
7418                    Err(e) => {
7419                        dlg.finished(false);
7420                        return Err(common::Error::MissingToken(e));
7421                    }
7422                },
7423            };
7424            let mut req_result = {
7425                let client = &self.hub.client;
7426                dlg.pre_request();
7427                let mut req_builder = hyper::Request::builder()
7428                    .method(hyper::Method::POST)
7429                    .uri(url.as_str())
7430                    .header(USER_AGENT, self.hub._user_agent.clone());
7431
7432                if let Some(token) = token.as_ref() {
7433                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
7434                }
7435
7436                let request = req_builder
7437                    .header(CONTENT_LENGTH, 0_u64)
7438                    .body(common::to_body::<String>(None));
7439
7440                client.request(request.unwrap()).await
7441            };
7442
7443            match req_result {
7444                Err(err) => {
7445                    if let common::Retry::After(d) = dlg.http_error(&err) {
7446                        sleep(d).await;
7447                        continue;
7448                    }
7449                    dlg.finished(false);
7450                    return Err(common::Error::HttpError(err));
7451                }
7452                Ok(res) => {
7453                    let (mut parts, body) = res.into_parts();
7454                    let mut body = common::Body::new(body);
7455                    if !parts.status.is_success() {
7456                        let bytes = common::to_bytes(body).await.unwrap_or_default();
7457                        let error = serde_json::from_str(&common::to_string(&bytes));
7458                        let response = common::to_response(parts, bytes.into());
7459
7460                        if let common::Retry::After(d) =
7461                            dlg.http_failure(&response, error.as_ref().ok())
7462                        {
7463                            sleep(d).await;
7464                            continue;
7465                        }
7466
7467                        dlg.finished(false);
7468
7469                        return Err(match error {
7470                            Ok(value) => common::Error::BadRequest(value),
7471                            _ => common::Error::Failure(response),
7472                        });
7473                    }
7474                    let response = common::Response::from_parts(parts, body);
7475
7476                    dlg.finished(true);
7477                    return Ok(response);
7478                }
7479            }
7480        }
7481    }
7482
7483    /// 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.
7484    ///
7485    /// Sets the *calendar id* path property to the given value.
7486    ///
7487    /// Even though the property as already been set when instantiating this call,
7488    /// we provide this method for API completeness.
7489    pub fn calendar_id(mut self, new_value: &str) -> CalendarClearCall<'a, C> {
7490        self._calendar_id = new_value.to_string();
7491        self
7492    }
7493    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
7494    /// while executing the actual API request.
7495    ///
7496    /// ````text
7497    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
7498    /// ````
7499    ///
7500    /// Sets the *delegate* property to the given value.
7501    pub fn delegate(mut self, new_value: &'a mut dyn common::Delegate) -> CalendarClearCall<'a, C> {
7502        self._delegate = Some(new_value);
7503        self
7504    }
7505
7506    /// Set any additional parameter of the query string used in the request.
7507    /// It should be used to set parameters which are not yet available through their own
7508    /// setters.
7509    ///
7510    /// Please note that this method must not be used to set any of the known parameters
7511    /// which have their own setter method. If done anyway, the request will fail.
7512    ///
7513    /// # Additional Parameters
7514    ///
7515    /// * *alt* (query-string) - Data format for the response.
7516    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
7517    /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
7518    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
7519    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
7520    /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
7521    /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
7522    pub fn param<T>(mut self, name: T, value: T) -> CalendarClearCall<'a, C>
7523    where
7524        T: AsRef<str>,
7525    {
7526        self._additional_params
7527            .insert(name.as_ref().to_string(), value.as_ref().to_string());
7528        self
7529    }
7530
7531    /// Identifies the authorization scope for the method you are building.
7532    ///
7533    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
7534    /// [`Scope::Full`].
7535    ///
7536    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
7537    /// tokens for more than one scope.
7538    ///
7539    /// Usually there is more than one suitable scope to authorize an operation, some of which may
7540    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
7541    /// sufficient, a read-write scope will do as well.
7542    pub fn add_scope<St>(mut self, scope: St) -> CalendarClearCall<'a, C>
7543    where
7544        St: AsRef<str>,
7545    {
7546        self._scopes.insert(String::from(scope.as_ref()));
7547        self
7548    }
7549    /// Identifies the authorization scope(s) for the method you are building.
7550    ///
7551    /// See [`Self::add_scope()`] for details.
7552    pub fn add_scopes<I, St>(mut self, scopes: I) -> CalendarClearCall<'a, C>
7553    where
7554        I: IntoIterator<Item = St>,
7555        St: AsRef<str>,
7556    {
7557        self._scopes
7558            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
7559        self
7560    }
7561
7562    /// Removes all scopes, and no default scope will be used either.
7563    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
7564    /// for details).
7565    pub fn clear_scopes(mut self) -> CalendarClearCall<'a, C> {
7566        self._scopes.clear();
7567        self
7568    }
7569}
7570
7571/// Deletes a secondary calendar. Use calendars.clear for clearing all events on primary calendars.
7572///
7573/// A builder for the *delete* method supported by a *calendar* resource.
7574/// It is not used directly, but through a [`CalendarMethods`] instance.
7575///
7576/// # Example
7577///
7578/// Instantiate a resource method builder
7579///
7580/// ```test_harness,no_run
7581/// # extern crate hyper;
7582/// # extern crate hyper_rustls;
7583/// # extern crate google_calendar3 as calendar3;
7584/// # async fn dox() {
7585/// # use calendar3::{CalendarHub, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
7586///
7587/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
7588/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
7589/// #     secret,
7590/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
7591/// # ).build().await.unwrap();
7592///
7593/// # let client = hyper_util::client::legacy::Client::builder(
7594/// #     hyper_util::rt::TokioExecutor::new()
7595/// # )
7596/// # .build(
7597/// #     hyper_rustls::HttpsConnectorBuilder::new()
7598/// #         .with_native_roots()
7599/// #         .unwrap()
7600/// #         .https_or_http()
7601/// #         .enable_http1()
7602/// #         .build()
7603/// # );
7604/// # let mut hub = CalendarHub::new(client, auth);
7605/// // You can configure optional parameters by calling the respective setters at will, and
7606/// // execute the final call using `doit()`.
7607/// // Values shown here are possibly random and not representative !
7608/// let result = hub.calendars().delete("calendarId")
7609///              .doit().await;
7610/// # }
7611/// ```
7612pub struct CalendarDeleteCall<'a, C>
7613where
7614    C: 'a,
7615{
7616    hub: &'a CalendarHub<C>,
7617    _calendar_id: String,
7618    _delegate: Option<&'a mut dyn common::Delegate>,
7619    _additional_params: HashMap<String, String>,
7620    _scopes: BTreeSet<String>,
7621}
7622
7623impl<'a, C> common::CallBuilder for CalendarDeleteCall<'a, C> {}
7624
7625impl<'a, C> CalendarDeleteCall<'a, C>
7626where
7627    C: common::Connector,
7628{
7629    /// Perform the operation you have build so far.
7630    pub async fn doit(mut self) -> common::Result<common::Response> {
7631        use std::borrow::Cow;
7632        use std::io::{Read, Seek};
7633
7634        use common::{url::Params, ToParts};
7635        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
7636
7637        let mut dd = common::DefaultDelegate;
7638        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
7639        dlg.begin(common::MethodInfo {
7640            id: "calendar.calendars.delete",
7641            http_method: hyper::Method::DELETE,
7642        });
7643
7644        for &field in ["calendarId"].iter() {
7645            if self._additional_params.contains_key(field) {
7646                dlg.finished(false);
7647                return Err(common::Error::FieldClash(field));
7648            }
7649        }
7650
7651        let mut params = Params::with_capacity(2 + self._additional_params.len());
7652        params.push("calendarId", self._calendar_id);
7653
7654        params.extend(self._additional_params.iter());
7655
7656        let mut url = self.hub._base_url.clone() + "calendars/{calendarId}";
7657        if self._scopes.is_empty() {
7658            self._scopes.insert(Scope::Full.as_ref().to_string());
7659        }
7660
7661        #[allow(clippy::single_element_loop)]
7662        for &(find_this, param_name) in [("{calendarId}", "calendarId")].iter() {
7663            url = params.uri_replacement(url, param_name, find_this, false);
7664        }
7665        {
7666            let to_remove = ["calendarId"];
7667            params.remove_params(&to_remove);
7668        }
7669
7670        let url = params.parse_with_url(&url);
7671
7672        loop {
7673            let token = match self
7674                .hub
7675                .auth
7676                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
7677                .await
7678            {
7679                Ok(token) => token,
7680                Err(e) => match dlg.token(e) {
7681                    Ok(token) => token,
7682                    Err(e) => {
7683                        dlg.finished(false);
7684                        return Err(common::Error::MissingToken(e));
7685                    }
7686                },
7687            };
7688            let mut req_result = {
7689                let client = &self.hub.client;
7690                dlg.pre_request();
7691                let mut req_builder = hyper::Request::builder()
7692                    .method(hyper::Method::DELETE)
7693                    .uri(url.as_str())
7694                    .header(USER_AGENT, self.hub._user_agent.clone());
7695
7696                if let Some(token) = token.as_ref() {
7697                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
7698                }
7699
7700                let request = req_builder
7701                    .header(CONTENT_LENGTH, 0_u64)
7702                    .body(common::to_body::<String>(None));
7703
7704                client.request(request.unwrap()).await
7705            };
7706
7707            match req_result {
7708                Err(err) => {
7709                    if let common::Retry::After(d) = dlg.http_error(&err) {
7710                        sleep(d).await;
7711                        continue;
7712                    }
7713                    dlg.finished(false);
7714                    return Err(common::Error::HttpError(err));
7715                }
7716                Ok(res) => {
7717                    let (mut parts, body) = res.into_parts();
7718                    let mut body = common::Body::new(body);
7719                    if !parts.status.is_success() {
7720                        let bytes = common::to_bytes(body).await.unwrap_or_default();
7721                        let error = serde_json::from_str(&common::to_string(&bytes));
7722                        let response = common::to_response(parts, bytes.into());
7723
7724                        if let common::Retry::After(d) =
7725                            dlg.http_failure(&response, error.as_ref().ok())
7726                        {
7727                            sleep(d).await;
7728                            continue;
7729                        }
7730
7731                        dlg.finished(false);
7732
7733                        return Err(match error {
7734                            Ok(value) => common::Error::BadRequest(value),
7735                            _ => common::Error::Failure(response),
7736                        });
7737                    }
7738                    let response = common::Response::from_parts(parts, body);
7739
7740                    dlg.finished(true);
7741                    return Ok(response);
7742                }
7743            }
7744        }
7745    }
7746
7747    /// 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.
7748    ///
7749    /// Sets the *calendar id* path property to the given value.
7750    ///
7751    /// Even though the property as already been set when instantiating this call,
7752    /// we provide this method for API completeness.
7753    pub fn calendar_id(mut self, new_value: &str) -> CalendarDeleteCall<'a, C> {
7754        self._calendar_id = new_value.to_string();
7755        self
7756    }
7757    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
7758    /// while executing the actual API request.
7759    ///
7760    /// ````text
7761    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
7762    /// ````
7763    ///
7764    /// Sets the *delegate* property to the given value.
7765    pub fn delegate(
7766        mut self,
7767        new_value: &'a mut dyn common::Delegate,
7768    ) -> CalendarDeleteCall<'a, C> {
7769        self._delegate = Some(new_value);
7770        self
7771    }
7772
7773    /// Set any additional parameter of the query string used in the request.
7774    /// It should be used to set parameters which are not yet available through their own
7775    /// setters.
7776    ///
7777    /// Please note that this method must not be used to set any of the known parameters
7778    /// which have their own setter method. If done anyway, the request will fail.
7779    ///
7780    /// # Additional Parameters
7781    ///
7782    /// * *alt* (query-string) - Data format for the response.
7783    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
7784    /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
7785    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
7786    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
7787    /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
7788    /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
7789    pub fn param<T>(mut self, name: T, value: T) -> CalendarDeleteCall<'a, C>
7790    where
7791        T: AsRef<str>,
7792    {
7793        self._additional_params
7794            .insert(name.as_ref().to_string(), value.as_ref().to_string());
7795        self
7796    }
7797
7798    /// Identifies the authorization scope for the method you are building.
7799    ///
7800    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
7801    /// [`Scope::Full`].
7802    ///
7803    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
7804    /// tokens for more than one scope.
7805    ///
7806    /// Usually there is more than one suitable scope to authorize an operation, some of which may
7807    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
7808    /// sufficient, a read-write scope will do as well.
7809    pub fn add_scope<St>(mut self, scope: St) -> CalendarDeleteCall<'a, C>
7810    where
7811        St: AsRef<str>,
7812    {
7813        self._scopes.insert(String::from(scope.as_ref()));
7814        self
7815    }
7816    /// Identifies the authorization scope(s) for the method you are building.
7817    ///
7818    /// See [`Self::add_scope()`] for details.
7819    pub fn add_scopes<I, St>(mut self, scopes: I) -> CalendarDeleteCall<'a, C>
7820    where
7821        I: IntoIterator<Item = St>,
7822        St: AsRef<str>,
7823    {
7824        self._scopes
7825            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
7826        self
7827    }
7828
7829    /// Removes all scopes, and no default scope will be used either.
7830    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
7831    /// for details).
7832    pub fn clear_scopes(mut self) -> CalendarDeleteCall<'a, C> {
7833        self._scopes.clear();
7834        self
7835    }
7836}
7837
7838/// Returns metadata for a calendar.
7839///
7840/// A builder for the *get* method supported by a *calendar* resource.
7841/// It is not used directly, but through a [`CalendarMethods`] instance.
7842///
7843/// # Example
7844///
7845/// Instantiate a resource method builder
7846///
7847/// ```test_harness,no_run
7848/// # extern crate hyper;
7849/// # extern crate hyper_rustls;
7850/// # extern crate google_calendar3 as calendar3;
7851/// # async fn dox() {
7852/// # use calendar3::{CalendarHub, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
7853///
7854/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
7855/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
7856/// #     secret,
7857/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
7858/// # ).build().await.unwrap();
7859///
7860/// # let client = hyper_util::client::legacy::Client::builder(
7861/// #     hyper_util::rt::TokioExecutor::new()
7862/// # )
7863/// # .build(
7864/// #     hyper_rustls::HttpsConnectorBuilder::new()
7865/// #         .with_native_roots()
7866/// #         .unwrap()
7867/// #         .https_or_http()
7868/// #         .enable_http1()
7869/// #         .build()
7870/// # );
7871/// # let mut hub = CalendarHub::new(client, auth);
7872/// // You can configure optional parameters by calling the respective setters at will, and
7873/// // execute the final call using `doit()`.
7874/// // Values shown here are possibly random and not representative !
7875/// let result = hub.calendars().get("calendarId")
7876///              .doit().await;
7877/// # }
7878/// ```
7879pub struct CalendarGetCall<'a, C>
7880where
7881    C: 'a,
7882{
7883    hub: &'a CalendarHub<C>,
7884    _calendar_id: String,
7885    _delegate: Option<&'a mut dyn common::Delegate>,
7886    _additional_params: HashMap<String, String>,
7887    _scopes: BTreeSet<String>,
7888}
7889
7890impl<'a, C> common::CallBuilder for CalendarGetCall<'a, C> {}
7891
7892impl<'a, C> CalendarGetCall<'a, C>
7893where
7894    C: common::Connector,
7895{
7896    /// Perform the operation you have build so far.
7897    pub async fn doit(mut self) -> common::Result<(common::Response, Calendar)> {
7898        use std::borrow::Cow;
7899        use std::io::{Read, Seek};
7900
7901        use common::{url::Params, ToParts};
7902        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
7903
7904        let mut dd = common::DefaultDelegate;
7905        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
7906        dlg.begin(common::MethodInfo {
7907            id: "calendar.calendars.get",
7908            http_method: hyper::Method::GET,
7909        });
7910
7911        for &field in ["alt", "calendarId"].iter() {
7912            if self._additional_params.contains_key(field) {
7913                dlg.finished(false);
7914                return Err(common::Error::FieldClash(field));
7915            }
7916        }
7917
7918        let mut params = Params::with_capacity(3 + self._additional_params.len());
7919        params.push("calendarId", self._calendar_id);
7920
7921        params.extend(self._additional_params.iter());
7922
7923        params.push("alt", "json");
7924        let mut url = self.hub._base_url.clone() + "calendars/{calendarId}";
7925        if self._scopes.is_empty() {
7926            self._scopes.insert(Scope::Readonly.as_ref().to_string());
7927        }
7928
7929        #[allow(clippy::single_element_loop)]
7930        for &(find_this, param_name) in [("{calendarId}", "calendarId")].iter() {
7931            url = params.uri_replacement(url, param_name, find_this, false);
7932        }
7933        {
7934            let to_remove = ["calendarId"];
7935            params.remove_params(&to_remove);
7936        }
7937
7938        let url = params.parse_with_url(&url);
7939
7940        loop {
7941            let token = match self
7942                .hub
7943                .auth
7944                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
7945                .await
7946            {
7947                Ok(token) => token,
7948                Err(e) => match dlg.token(e) {
7949                    Ok(token) => token,
7950                    Err(e) => {
7951                        dlg.finished(false);
7952                        return Err(common::Error::MissingToken(e));
7953                    }
7954                },
7955            };
7956            let mut req_result = {
7957                let client = &self.hub.client;
7958                dlg.pre_request();
7959                let mut req_builder = hyper::Request::builder()
7960                    .method(hyper::Method::GET)
7961                    .uri(url.as_str())
7962                    .header(USER_AGENT, self.hub._user_agent.clone());
7963
7964                if let Some(token) = token.as_ref() {
7965                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
7966                }
7967
7968                let request = req_builder
7969                    .header(CONTENT_LENGTH, 0_u64)
7970                    .body(common::to_body::<String>(None));
7971
7972                client.request(request.unwrap()).await
7973            };
7974
7975            match req_result {
7976                Err(err) => {
7977                    if let common::Retry::After(d) = dlg.http_error(&err) {
7978                        sleep(d).await;
7979                        continue;
7980                    }
7981                    dlg.finished(false);
7982                    return Err(common::Error::HttpError(err));
7983                }
7984                Ok(res) => {
7985                    let (mut parts, body) = res.into_parts();
7986                    let mut body = common::Body::new(body);
7987                    if !parts.status.is_success() {
7988                        let bytes = common::to_bytes(body).await.unwrap_or_default();
7989                        let error = serde_json::from_str(&common::to_string(&bytes));
7990                        let response = common::to_response(parts, bytes.into());
7991
7992                        if let common::Retry::After(d) =
7993                            dlg.http_failure(&response, error.as_ref().ok())
7994                        {
7995                            sleep(d).await;
7996                            continue;
7997                        }
7998
7999                        dlg.finished(false);
8000
8001                        return Err(match error {
8002                            Ok(value) => common::Error::BadRequest(value),
8003                            _ => common::Error::Failure(response),
8004                        });
8005                    }
8006                    let response = {
8007                        let bytes = common::to_bytes(body).await.unwrap_or_default();
8008                        let encoded = common::to_string(&bytes);
8009                        match serde_json::from_str(&encoded) {
8010                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
8011                            Err(error) => {
8012                                dlg.response_json_decode_error(&encoded, &error);
8013                                return Err(common::Error::JsonDecodeError(
8014                                    encoded.to_string(),
8015                                    error,
8016                                ));
8017                            }
8018                        }
8019                    };
8020
8021                    dlg.finished(true);
8022                    return Ok(response);
8023                }
8024            }
8025        }
8026    }
8027
8028    /// 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.
8029    ///
8030    /// Sets the *calendar id* path property to the given value.
8031    ///
8032    /// Even though the property as already been set when instantiating this call,
8033    /// we provide this method for API completeness.
8034    pub fn calendar_id(mut self, new_value: &str) -> CalendarGetCall<'a, C> {
8035        self._calendar_id = new_value.to_string();
8036        self
8037    }
8038    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
8039    /// while executing the actual API request.
8040    ///
8041    /// ````text
8042    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
8043    /// ````
8044    ///
8045    /// Sets the *delegate* property to the given value.
8046    pub fn delegate(mut self, new_value: &'a mut dyn common::Delegate) -> CalendarGetCall<'a, C> {
8047        self._delegate = Some(new_value);
8048        self
8049    }
8050
8051    /// Set any additional parameter of the query string used in the request.
8052    /// It should be used to set parameters which are not yet available through their own
8053    /// setters.
8054    ///
8055    /// Please note that this method must not be used to set any of the known parameters
8056    /// which have their own setter method. If done anyway, the request will fail.
8057    ///
8058    /// # Additional Parameters
8059    ///
8060    /// * *alt* (query-string) - Data format for the response.
8061    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
8062    /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
8063    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
8064    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
8065    /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
8066    /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
8067    pub fn param<T>(mut self, name: T, value: T) -> CalendarGetCall<'a, C>
8068    where
8069        T: AsRef<str>,
8070    {
8071        self._additional_params
8072            .insert(name.as_ref().to_string(), value.as_ref().to_string());
8073        self
8074    }
8075
8076    /// Identifies the authorization scope for the method you are building.
8077    ///
8078    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
8079    /// [`Scope::Readonly`].
8080    ///
8081    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
8082    /// tokens for more than one scope.
8083    ///
8084    /// Usually there is more than one suitable scope to authorize an operation, some of which may
8085    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
8086    /// sufficient, a read-write scope will do as well.
8087    pub fn add_scope<St>(mut self, scope: St) -> CalendarGetCall<'a, C>
8088    where
8089        St: AsRef<str>,
8090    {
8091        self._scopes.insert(String::from(scope.as_ref()));
8092        self
8093    }
8094    /// Identifies the authorization scope(s) for the method you are building.
8095    ///
8096    /// See [`Self::add_scope()`] for details.
8097    pub fn add_scopes<I, St>(mut self, scopes: I) -> CalendarGetCall<'a, C>
8098    where
8099        I: IntoIterator<Item = St>,
8100        St: AsRef<str>,
8101    {
8102        self._scopes
8103            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
8104        self
8105    }
8106
8107    /// Removes all scopes, and no default scope will be used either.
8108    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
8109    /// for details).
8110    pub fn clear_scopes(mut self) -> CalendarGetCall<'a, C> {
8111        self._scopes.clear();
8112        self
8113    }
8114}
8115
8116/// Creates a secondary calendar.
8117///
8118/// A builder for the *insert* method supported by a *calendar* resource.
8119/// It is not used directly, but through a [`CalendarMethods`] instance.
8120///
8121/// # Example
8122///
8123/// Instantiate a resource method builder
8124///
8125/// ```test_harness,no_run
8126/// # extern crate hyper;
8127/// # extern crate hyper_rustls;
8128/// # extern crate google_calendar3 as calendar3;
8129/// use calendar3::api::Calendar;
8130/// # async fn dox() {
8131/// # use calendar3::{CalendarHub, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
8132///
8133/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
8134/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
8135/// #     secret,
8136/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
8137/// # ).build().await.unwrap();
8138///
8139/// # let client = hyper_util::client::legacy::Client::builder(
8140/// #     hyper_util::rt::TokioExecutor::new()
8141/// # )
8142/// # .build(
8143/// #     hyper_rustls::HttpsConnectorBuilder::new()
8144/// #         .with_native_roots()
8145/// #         .unwrap()
8146/// #         .https_or_http()
8147/// #         .enable_http1()
8148/// #         .build()
8149/// # );
8150/// # let mut hub = CalendarHub::new(client, auth);
8151/// // As the method needs a request, you would usually fill it with the desired information
8152/// // into the respective structure. Some of the parts shown here might not be applicable !
8153/// // Values shown here are possibly random and not representative !
8154/// let mut req = Calendar::default();
8155///
8156/// // You can configure optional parameters by calling the respective setters at will, and
8157/// // execute the final call using `doit()`.
8158/// // Values shown here are possibly random and not representative !
8159/// let result = hub.calendars().insert(req)
8160///              .doit().await;
8161/// # }
8162/// ```
8163pub struct CalendarInsertCall<'a, C>
8164where
8165    C: 'a,
8166{
8167    hub: &'a CalendarHub<C>,
8168    _request: Calendar,
8169    _delegate: Option<&'a mut dyn common::Delegate>,
8170    _additional_params: HashMap<String, String>,
8171    _scopes: BTreeSet<String>,
8172}
8173
8174impl<'a, C> common::CallBuilder for CalendarInsertCall<'a, C> {}
8175
8176impl<'a, C> CalendarInsertCall<'a, C>
8177where
8178    C: common::Connector,
8179{
8180    /// Perform the operation you have build so far.
8181    pub async fn doit(mut self) -> common::Result<(common::Response, Calendar)> {
8182        use std::borrow::Cow;
8183        use std::io::{Read, Seek};
8184
8185        use common::{url::Params, ToParts};
8186        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
8187
8188        let mut dd = common::DefaultDelegate;
8189        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
8190        dlg.begin(common::MethodInfo {
8191            id: "calendar.calendars.insert",
8192            http_method: hyper::Method::POST,
8193        });
8194
8195        for &field in ["alt"].iter() {
8196            if self._additional_params.contains_key(field) {
8197                dlg.finished(false);
8198                return Err(common::Error::FieldClash(field));
8199            }
8200        }
8201
8202        let mut params = Params::with_capacity(3 + self._additional_params.len());
8203
8204        params.extend(self._additional_params.iter());
8205
8206        params.push("alt", "json");
8207        let mut url = self.hub._base_url.clone() + "calendars";
8208        if self._scopes.is_empty() {
8209            self._scopes.insert(Scope::Full.as_ref().to_string());
8210        }
8211
8212        let url = params.parse_with_url(&url);
8213
8214        let mut json_mime_type = mime::APPLICATION_JSON;
8215        let mut request_value_reader = {
8216            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
8217            common::remove_json_null_values(&mut value);
8218            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
8219            serde_json::to_writer(&mut dst, &value).unwrap();
8220            dst
8221        };
8222        let request_size = request_value_reader
8223            .seek(std::io::SeekFrom::End(0))
8224            .unwrap();
8225        request_value_reader
8226            .seek(std::io::SeekFrom::Start(0))
8227            .unwrap();
8228
8229        loop {
8230            let token = match self
8231                .hub
8232                .auth
8233                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
8234                .await
8235            {
8236                Ok(token) => token,
8237                Err(e) => match dlg.token(e) {
8238                    Ok(token) => token,
8239                    Err(e) => {
8240                        dlg.finished(false);
8241                        return Err(common::Error::MissingToken(e));
8242                    }
8243                },
8244            };
8245            request_value_reader
8246                .seek(std::io::SeekFrom::Start(0))
8247                .unwrap();
8248            let mut req_result = {
8249                let client = &self.hub.client;
8250                dlg.pre_request();
8251                let mut req_builder = hyper::Request::builder()
8252                    .method(hyper::Method::POST)
8253                    .uri(url.as_str())
8254                    .header(USER_AGENT, self.hub._user_agent.clone());
8255
8256                if let Some(token) = token.as_ref() {
8257                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
8258                }
8259
8260                let request = req_builder
8261                    .header(CONTENT_TYPE, json_mime_type.to_string())
8262                    .header(CONTENT_LENGTH, request_size as u64)
8263                    .body(common::to_body(
8264                        request_value_reader.get_ref().clone().into(),
8265                    ));
8266
8267                client.request(request.unwrap()).await
8268            };
8269
8270            match req_result {
8271                Err(err) => {
8272                    if let common::Retry::After(d) = dlg.http_error(&err) {
8273                        sleep(d).await;
8274                        continue;
8275                    }
8276                    dlg.finished(false);
8277                    return Err(common::Error::HttpError(err));
8278                }
8279                Ok(res) => {
8280                    let (mut parts, body) = res.into_parts();
8281                    let mut body = common::Body::new(body);
8282                    if !parts.status.is_success() {
8283                        let bytes = common::to_bytes(body).await.unwrap_or_default();
8284                        let error = serde_json::from_str(&common::to_string(&bytes));
8285                        let response = common::to_response(parts, bytes.into());
8286
8287                        if let common::Retry::After(d) =
8288                            dlg.http_failure(&response, error.as_ref().ok())
8289                        {
8290                            sleep(d).await;
8291                            continue;
8292                        }
8293
8294                        dlg.finished(false);
8295
8296                        return Err(match error {
8297                            Ok(value) => common::Error::BadRequest(value),
8298                            _ => common::Error::Failure(response),
8299                        });
8300                    }
8301                    let response = {
8302                        let bytes = common::to_bytes(body).await.unwrap_or_default();
8303                        let encoded = common::to_string(&bytes);
8304                        match serde_json::from_str(&encoded) {
8305                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
8306                            Err(error) => {
8307                                dlg.response_json_decode_error(&encoded, &error);
8308                                return Err(common::Error::JsonDecodeError(
8309                                    encoded.to_string(),
8310                                    error,
8311                                ));
8312                            }
8313                        }
8314                    };
8315
8316                    dlg.finished(true);
8317                    return Ok(response);
8318                }
8319            }
8320        }
8321    }
8322
8323    ///
8324    /// Sets the *request* property to the given value.
8325    ///
8326    /// Even though the property as already been set when instantiating this call,
8327    /// we provide this method for API completeness.
8328    pub fn request(mut self, new_value: Calendar) -> CalendarInsertCall<'a, C> {
8329        self._request = new_value;
8330        self
8331    }
8332    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
8333    /// while executing the actual API request.
8334    ///
8335    /// ````text
8336    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
8337    /// ````
8338    ///
8339    /// Sets the *delegate* property to the given value.
8340    pub fn delegate(
8341        mut self,
8342        new_value: &'a mut dyn common::Delegate,
8343    ) -> CalendarInsertCall<'a, C> {
8344        self._delegate = Some(new_value);
8345        self
8346    }
8347
8348    /// Set any additional parameter of the query string used in the request.
8349    /// It should be used to set parameters which are not yet available through their own
8350    /// setters.
8351    ///
8352    /// Please note that this method must not be used to set any of the known parameters
8353    /// which have their own setter method. If done anyway, the request will fail.
8354    ///
8355    /// # Additional Parameters
8356    ///
8357    /// * *alt* (query-string) - Data format for the response.
8358    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
8359    /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
8360    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
8361    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
8362    /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
8363    /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
8364    pub fn param<T>(mut self, name: T, value: T) -> CalendarInsertCall<'a, C>
8365    where
8366        T: AsRef<str>,
8367    {
8368        self._additional_params
8369            .insert(name.as_ref().to_string(), value.as_ref().to_string());
8370        self
8371    }
8372
8373    /// Identifies the authorization scope for the method you are building.
8374    ///
8375    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
8376    /// [`Scope::Full`].
8377    ///
8378    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
8379    /// tokens for more than one scope.
8380    ///
8381    /// Usually there is more than one suitable scope to authorize an operation, some of which may
8382    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
8383    /// sufficient, a read-write scope will do as well.
8384    pub fn add_scope<St>(mut self, scope: St) -> CalendarInsertCall<'a, C>
8385    where
8386        St: AsRef<str>,
8387    {
8388        self._scopes.insert(String::from(scope.as_ref()));
8389        self
8390    }
8391    /// Identifies the authorization scope(s) for the method you are building.
8392    ///
8393    /// See [`Self::add_scope()`] for details.
8394    pub fn add_scopes<I, St>(mut self, scopes: I) -> CalendarInsertCall<'a, C>
8395    where
8396        I: IntoIterator<Item = St>,
8397        St: AsRef<str>,
8398    {
8399        self._scopes
8400            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
8401        self
8402    }
8403
8404    /// Removes all scopes, and no default scope will be used either.
8405    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
8406    /// for details).
8407    pub fn clear_scopes(mut self) -> CalendarInsertCall<'a, C> {
8408        self._scopes.clear();
8409        self
8410    }
8411}
8412
8413/// Updates metadata for a calendar. This method supports patch semantics.
8414///
8415/// A builder for the *patch* method supported by a *calendar* resource.
8416/// It is not used directly, but through a [`CalendarMethods`] instance.
8417///
8418/// # Example
8419///
8420/// Instantiate a resource method builder
8421///
8422/// ```test_harness,no_run
8423/// # extern crate hyper;
8424/// # extern crate hyper_rustls;
8425/// # extern crate google_calendar3 as calendar3;
8426/// use calendar3::api::Calendar;
8427/// # async fn dox() {
8428/// # use calendar3::{CalendarHub, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
8429///
8430/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
8431/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
8432/// #     secret,
8433/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
8434/// # ).build().await.unwrap();
8435///
8436/// # let client = hyper_util::client::legacy::Client::builder(
8437/// #     hyper_util::rt::TokioExecutor::new()
8438/// # )
8439/// # .build(
8440/// #     hyper_rustls::HttpsConnectorBuilder::new()
8441/// #         .with_native_roots()
8442/// #         .unwrap()
8443/// #         .https_or_http()
8444/// #         .enable_http1()
8445/// #         .build()
8446/// # );
8447/// # let mut hub = CalendarHub::new(client, auth);
8448/// // As the method needs a request, you would usually fill it with the desired information
8449/// // into the respective structure. Some of the parts shown here might not be applicable !
8450/// // Values shown here are possibly random and not representative !
8451/// let mut req = Calendar::default();
8452///
8453/// // You can configure optional parameters by calling the respective setters at will, and
8454/// // execute the final call using `doit()`.
8455/// // Values shown here are possibly random and not representative !
8456/// let result = hub.calendars().patch(req, "calendarId")
8457///              .doit().await;
8458/// # }
8459/// ```
8460pub struct CalendarPatchCall<'a, C>
8461where
8462    C: 'a,
8463{
8464    hub: &'a CalendarHub<C>,
8465    _request: Calendar,
8466    _calendar_id: String,
8467    _delegate: Option<&'a mut dyn common::Delegate>,
8468    _additional_params: HashMap<String, String>,
8469    _scopes: BTreeSet<String>,
8470}
8471
8472impl<'a, C> common::CallBuilder for CalendarPatchCall<'a, C> {}
8473
8474impl<'a, C> CalendarPatchCall<'a, C>
8475where
8476    C: common::Connector,
8477{
8478    /// Perform the operation you have build so far.
8479    pub async fn doit(mut self) -> common::Result<(common::Response, Calendar)> {
8480        use std::borrow::Cow;
8481        use std::io::{Read, Seek};
8482
8483        use common::{url::Params, ToParts};
8484        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
8485
8486        let mut dd = common::DefaultDelegate;
8487        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
8488        dlg.begin(common::MethodInfo {
8489            id: "calendar.calendars.patch",
8490            http_method: hyper::Method::PATCH,
8491        });
8492
8493        for &field in ["alt", "calendarId"].iter() {
8494            if self._additional_params.contains_key(field) {
8495                dlg.finished(false);
8496                return Err(common::Error::FieldClash(field));
8497            }
8498        }
8499
8500        let mut params = Params::with_capacity(4 + self._additional_params.len());
8501        params.push("calendarId", self._calendar_id);
8502
8503        params.extend(self._additional_params.iter());
8504
8505        params.push("alt", "json");
8506        let mut url = self.hub._base_url.clone() + "calendars/{calendarId}";
8507        if self._scopes.is_empty() {
8508            self._scopes.insert(Scope::Full.as_ref().to_string());
8509        }
8510
8511        #[allow(clippy::single_element_loop)]
8512        for &(find_this, param_name) in [("{calendarId}", "calendarId")].iter() {
8513            url = params.uri_replacement(url, param_name, find_this, false);
8514        }
8515        {
8516            let to_remove = ["calendarId"];
8517            params.remove_params(&to_remove);
8518        }
8519
8520        let url = params.parse_with_url(&url);
8521
8522        let mut json_mime_type = mime::APPLICATION_JSON;
8523        let mut request_value_reader = {
8524            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
8525            common::remove_json_null_values(&mut value);
8526            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
8527            serde_json::to_writer(&mut dst, &value).unwrap();
8528            dst
8529        };
8530        let request_size = request_value_reader
8531            .seek(std::io::SeekFrom::End(0))
8532            .unwrap();
8533        request_value_reader
8534            .seek(std::io::SeekFrom::Start(0))
8535            .unwrap();
8536
8537        loop {
8538            let token = match self
8539                .hub
8540                .auth
8541                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
8542                .await
8543            {
8544                Ok(token) => token,
8545                Err(e) => match dlg.token(e) {
8546                    Ok(token) => token,
8547                    Err(e) => {
8548                        dlg.finished(false);
8549                        return Err(common::Error::MissingToken(e));
8550                    }
8551                },
8552            };
8553            request_value_reader
8554                .seek(std::io::SeekFrom::Start(0))
8555                .unwrap();
8556            let mut req_result = {
8557                let client = &self.hub.client;
8558                dlg.pre_request();
8559                let mut req_builder = hyper::Request::builder()
8560                    .method(hyper::Method::PATCH)
8561                    .uri(url.as_str())
8562                    .header(USER_AGENT, self.hub._user_agent.clone());
8563
8564                if let Some(token) = token.as_ref() {
8565                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
8566                }
8567
8568                let request = req_builder
8569                    .header(CONTENT_TYPE, json_mime_type.to_string())
8570                    .header(CONTENT_LENGTH, request_size as u64)
8571                    .body(common::to_body(
8572                        request_value_reader.get_ref().clone().into(),
8573                    ));
8574
8575                client.request(request.unwrap()).await
8576            };
8577
8578            match req_result {
8579                Err(err) => {
8580                    if let common::Retry::After(d) = dlg.http_error(&err) {
8581                        sleep(d).await;
8582                        continue;
8583                    }
8584                    dlg.finished(false);
8585                    return Err(common::Error::HttpError(err));
8586                }
8587                Ok(res) => {
8588                    let (mut parts, body) = res.into_parts();
8589                    let mut body = common::Body::new(body);
8590                    if !parts.status.is_success() {
8591                        let bytes = common::to_bytes(body).await.unwrap_or_default();
8592                        let error = serde_json::from_str(&common::to_string(&bytes));
8593                        let response = common::to_response(parts, bytes.into());
8594
8595                        if let common::Retry::After(d) =
8596                            dlg.http_failure(&response, error.as_ref().ok())
8597                        {
8598                            sleep(d).await;
8599                            continue;
8600                        }
8601
8602                        dlg.finished(false);
8603
8604                        return Err(match error {
8605                            Ok(value) => common::Error::BadRequest(value),
8606                            _ => common::Error::Failure(response),
8607                        });
8608                    }
8609                    let response = {
8610                        let bytes = common::to_bytes(body).await.unwrap_or_default();
8611                        let encoded = common::to_string(&bytes);
8612                        match serde_json::from_str(&encoded) {
8613                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
8614                            Err(error) => {
8615                                dlg.response_json_decode_error(&encoded, &error);
8616                                return Err(common::Error::JsonDecodeError(
8617                                    encoded.to_string(),
8618                                    error,
8619                                ));
8620                            }
8621                        }
8622                    };
8623
8624                    dlg.finished(true);
8625                    return Ok(response);
8626                }
8627            }
8628        }
8629    }
8630
8631    ///
8632    /// Sets the *request* property to the given value.
8633    ///
8634    /// Even though the property as already been set when instantiating this call,
8635    /// we provide this method for API completeness.
8636    pub fn request(mut self, new_value: Calendar) -> CalendarPatchCall<'a, C> {
8637        self._request = new_value;
8638        self
8639    }
8640    /// 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.
8641    ///
8642    /// Sets the *calendar id* path property to the given value.
8643    ///
8644    /// Even though the property as already been set when instantiating this call,
8645    /// we provide this method for API completeness.
8646    pub fn calendar_id(mut self, new_value: &str) -> CalendarPatchCall<'a, C> {
8647        self._calendar_id = new_value.to_string();
8648        self
8649    }
8650    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
8651    /// while executing the actual API request.
8652    ///
8653    /// ````text
8654    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
8655    /// ````
8656    ///
8657    /// Sets the *delegate* property to the given value.
8658    pub fn delegate(mut self, new_value: &'a mut dyn common::Delegate) -> CalendarPatchCall<'a, C> {
8659        self._delegate = Some(new_value);
8660        self
8661    }
8662
8663    /// Set any additional parameter of the query string used in the request.
8664    /// It should be used to set parameters which are not yet available through their own
8665    /// setters.
8666    ///
8667    /// Please note that this method must not be used to set any of the known parameters
8668    /// which have their own setter method. If done anyway, the request will fail.
8669    ///
8670    /// # Additional Parameters
8671    ///
8672    /// * *alt* (query-string) - Data format for the response.
8673    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
8674    /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
8675    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
8676    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
8677    /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
8678    /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
8679    pub fn param<T>(mut self, name: T, value: T) -> CalendarPatchCall<'a, C>
8680    where
8681        T: AsRef<str>,
8682    {
8683        self._additional_params
8684            .insert(name.as_ref().to_string(), value.as_ref().to_string());
8685        self
8686    }
8687
8688    /// Identifies the authorization scope for the method you are building.
8689    ///
8690    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
8691    /// [`Scope::Full`].
8692    ///
8693    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
8694    /// tokens for more than one scope.
8695    ///
8696    /// Usually there is more than one suitable scope to authorize an operation, some of which may
8697    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
8698    /// sufficient, a read-write scope will do as well.
8699    pub fn add_scope<St>(mut self, scope: St) -> CalendarPatchCall<'a, C>
8700    where
8701        St: AsRef<str>,
8702    {
8703        self._scopes.insert(String::from(scope.as_ref()));
8704        self
8705    }
8706    /// Identifies the authorization scope(s) for the method you are building.
8707    ///
8708    /// See [`Self::add_scope()`] for details.
8709    pub fn add_scopes<I, St>(mut self, scopes: I) -> CalendarPatchCall<'a, C>
8710    where
8711        I: IntoIterator<Item = St>,
8712        St: AsRef<str>,
8713    {
8714        self._scopes
8715            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
8716        self
8717    }
8718
8719    /// Removes all scopes, and no default scope will be used either.
8720    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
8721    /// for details).
8722    pub fn clear_scopes(mut self) -> CalendarPatchCall<'a, C> {
8723        self._scopes.clear();
8724        self
8725    }
8726}
8727
8728/// Updates metadata for a calendar.
8729///
8730/// A builder for the *update* method supported by a *calendar* resource.
8731/// It is not used directly, but through a [`CalendarMethods`] instance.
8732///
8733/// # Example
8734///
8735/// Instantiate a resource method builder
8736///
8737/// ```test_harness,no_run
8738/// # extern crate hyper;
8739/// # extern crate hyper_rustls;
8740/// # extern crate google_calendar3 as calendar3;
8741/// use calendar3::api::Calendar;
8742/// # async fn dox() {
8743/// # use calendar3::{CalendarHub, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
8744///
8745/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
8746/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
8747/// #     secret,
8748/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
8749/// # ).build().await.unwrap();
8750///
8751/// # let client = hyper_util::client::legacy::Client::builder(
8752/// #     hyper_util::rt::TokioExecutor::new()
8753/// # )
8754/// # .build(
8755/// #     hyper_rustls::HttpsConnectorBuilder::new()
8756/// #         .with_native_roots()
8757/// #         .unwrap()
8758/// #         .https_or_http()
8759/// #         .enable_http1()
8760/// #         .build()
8761/// # );
8762/// # let mut hub = CalendarHub::new(client, auth);
8763/// // As the method needs a request, you would usually fill it with the desired information
8764/// // into the respective structure. Some of the parts shown here might not be applicable !
8765/// // Values shown here are possibly random and not representative !
8766/// let mut req = Calendar::default();
8767///
8768/// // You can configure optional parameters by calling the respective setters at will, and
8769/// // execute the final call using `doit()`.
8770/// // Values shown here are possibly random and not representative !
8771/// let result = hub.calendars().update(req, "calendarId")
8772///              .doit().await;
8773/// # }
8774/// ```
8775pub struct CalendarUpdateCall<'a, C>
8776where
8777    C: 'a,
8778{
8779    hub: &'a CalendarHub<C>,
8780    _request: Calendar,
8781    _calendar_id: String,
8782    _delegate: Option<&'a mut dyn common::Delegate>,
8783    _additional_params: HashMap<String, String>,
8784    _scopes: BTreeSet<String>,
8785}
8786
8787impl<'a, C> common::CallBuilder for CalendarUpdateCall<'a, C> {}
8788
8789impl<'a, C> CalendarUpdateCall<'a, C>
8790where
8791    C: common::Connector,
8792{
8793    /// Perform the operation you have build so far.
8794    pub async fn doit(mut self) -> common::Result<(common::Response, Calendar)> {
8795        use std::borrow::Cow;
8796        use std::io::{Read, Seek};
8797
8798        use common::{url::Params, ToParts};
8799        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
8800
8801        let mut dd = common::DefaultDelegate;
8802        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
8803        dlg.begin(common::MethodInfo {
8804            id: "calendar.calendars.update",
8805            http_method: hyper::Method::PUT,
8806        });
8807
8808        for &field in ["alt", "calendarId"].iter() {
8809            if self._additional_params.contains_key(field) {
8810                dlg.finished(false);
8811                return Err(common::Error::FieldClash(field));
8812            }
8813        }
8814
8815        let mut params = Params::with_capacity(4 + self._additional_params.len());
8816        params.push("calendarId", self._calendar_id);
8817
8818        params.extend(self._additional_params.iter());
8819
8820        params.push("alt", "json");
8821        let mut url = self.hub._base_url.clone() + "calendars/{calendarId}";
8822        if self._scopes.is_empty() {
8823            self._scopes.insert(Scope::Full.as_ref().to_string());
8824        }
8825
8826        #[allow(clippy::single_element_loop)]
8827        for &(find_this, param_name) in [("{calendarId}", "calendarId")].iter() {
8828            url = params.uri_replacement(url, param_name, find_this, false);
8829        }
8830        {
8831            let to_remove = ["calendarId"];
8832            params.remove_params(&to_remove);
8833        }
8834
8835        let url = params.parse_with_url(&url);
8836
8837        let mut json_mime_type = mime::APPLICATION_JSON;
8838        let mut request_value_reader = {
8839            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
8840            common::remove_json_null_values(&mut value);
8841            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
8842            serde_json::to_writer(&mut dst, &value).unwrap();
8843            dst
8844        };
8845        let request_size = request_value_reader
8846            .seek(std::io::SeekFrom::End(0))
8847            .unwrap();
8848        request_value_reader
8849            .seek(std::io::SeekFrom::Start(0))
8850            .unwrap();
8851
8852        loop {
8853            let token = match self
8854                .hub
8855                .auth
8856                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
8857                .await
8858            {
8859                Ok(token) => token,
8860                Err(e) => match dlg.token(e) {
8861                    Ok(token) => token,
8862                    Err(e) => {
8863                        dlg.finished(false);
8864                        return Err(common::Error::MissingToken(e));
8865                    }
8866                },
8867            };
8868            request_value_reader
8869                .seek(std::io::SeekFrom::Start(0))
8870                .unwrap();
8871            let mut req_result = {
8872                let client = &self.hub.client;
8873                dlg.pre_request();
8874                let mut req_builder = hyper::Request::builder()
8875                    .method(hyper::Method::PUT)
8876                    .uri(url.as_str())
8877                    .header(USER_AGENT, self.hub._user_agent.clone());
8878
8879                if let Some(token) = token.as_ref() {
8880                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
8881                }
8882
8883                let request = req_builder
8884                    .header(CONTENT_TYPE, json_mime_type.to_string())
8885                    .header(CONTENT_LENGTH, request_size as u64)
8886                    .body(common::to_body(
8887                        request_value_reader.get_ref().clone().into(),
8888                    ));
8889
8890                client.request(request.unwrap()).await
8891            };
8892
8893            match req_result {
8894                Err(err) => {
8895                    if let common::Retry::After(d) = dlg.http_error(&err) {
8896                        sleep(d).await;
8897                        continue;
8898                    }
8899                    dlg.finished(false);
8900                    return Err(common::Error::HttpError(err));
8901                }
8902                Ok(res) => {
8903                    let (mut parts, body) = res.into_parts();
8904                    let mut body = common::Body::new(body);
8905                    if !parts.status.is_success() {
8906                        let bytes = common::to_bytes(body).await.unwrap_or_default();
8907                        let error = serde_json::from_str(&common::to_string(&bytes));
8908                        let response = common::to_response(parts, bytes.into());
8909
8910                        if let common::Retry::After(d) =
8911                            dlg.http_failure(&response, error.as_ref().ok())
8912                        {
8913                            sleep(d).await;
8914                            continue;
8915                        }
8916
8917                        dlg.finished(false);
8918
8919                        return Err(match error {
8920                            Ok(value) => common::Error::BadRequest(value),
8921                            _ => common::Error::Failure(response),
8922                        });
8923                    }
8924                    let response = {
8925                        let bytes = common::to_bytes(body).await.unwrap_or_default();
8926                        let encoded = common::to_string(&bytes);
8927                        match serde_json::from_str(&encoded) {
8928                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
8929                            Err(error) => {
8930                                dlg.response_json_decode_error(&encoded, &error);
8931                                return Err(common::Error::JsonDecodeError(
8932                                    encoded.to_string(),
8933                                    error,
8934                                ));
8935                            }
8936                        }
8937                    };
8938
8939                    dlg.finished(true);
8940                    return Ok(response);
8941                }
8942            }
8943        }
8944    }
8945
8946    ///
8947    /// Sets the *request* property to the given value.
8948    ///
8949    /// Even though the property as already been set when instantiating this call,
8950    /// we provide this method for API completeness.
8951    pub fn request(mut self, new_value: Calendar) -> CalendarUpdateCall<'a, C> {
8952        self._request = new_value;
8953        self
8954    }
8955    /// 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.
8956    ///
8957    /// Sets the *calendar id* path property to the given value.
8958    ///
8959    /// Even though the property as already been set when instantiating this call,
8960    /// we provide this method for API completeness.
8961    pub fn calendar_id(mut self, new_value: &str) -> CalendarUpdateCall<'a, C> {
8962        self._calendar_id = new_value.to_string();
8963        self
8964    }
8965    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
8966    /// while executing the actual API request.
8967    ///
8968    /// ````text
8969    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
8970    /// ````
8971    ///
8972    /// Sets the *delegate* property to the given value.
8973    pub fn delegate(
8974        mut self,
8975        new_value: &'a mut dyn common::Delegate,
8976    ) -> CalendarUpdateCall<'a, C> {
8977        self._delegate = Some(new_value);
8978        self
8979    }
8980
8981    /// Set any additional parameter of the query string used in the request.
8982    /// It should be used to set parameters which are not yet available through their own
8983    /// setters.
8984    ///
8985    /// Please note that this method must not be used to set any of the known parameters
8986    /// which have their own setter method. If done anyway, the request will fail.
8987    ///
8988    /// # Additional Parameters
8989    ///
8990    /// * *alt* (query-string) - Data format for the response.
8991    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
8992    /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
8993    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
8994    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
8995    /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
8996    /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
8997    pub fn param<T>(mut self, name: T, value: T) -> CalendarUpdateCall<'a, C>
8998    where
8999        T: AsRef<str>,
9000    {
9001        self._additional_params
9002            .insert(name.as_ref().to_string(), value.as_ref().to_string());
9003        self
9004    }
9005
9006    /// Identifies the authorization scope for the method you are building.
9007    ///
9008    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
9009    /// [`Scope::Full`].
9010    ///
9011    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
9012    /// tokens for more than one scope.
9013    ///
9014    /// Usually there is more than one suitable scope to authorize an operation, some of which may
9015    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
9016    /// sufficient, a read-write scope will do as well.
9017    pub fn add_scope<St>(mut self, scope: St) -> CalendarUpdateCall<'a, C>
9018    where
9019        St: AsRef<str>,
9020    {
9021        self._scopes.insert(String::from(scope.as_ref()));
9022        self
9023    }
9024    /// Identifies the authorization scope(s) for the method you are building.
9025    ///
9026    /// See [`Self::add_scope()`] for details.
9027    pub fn add_scopes<I, St>(mut self, scopes: I) -> CalendarUpdateCall<'a, C>
9028    where
9029        I: IntoIterator<Item = St>,
9030        St: AsRef<str>,
9031    {
9032        self._scopes
9033            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
9034        self
9035    }
9036
9037    /// Removes all scopes, and no default scope will be used either.
9038    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
9039    /// for details).
9040    pub fn clear_scopes(mut self) -> CalendarUpdateCall<'a, C> {
9041        self._scopes.clear();
9042        self
9043    }
9044}
9045
9046/// Stop watching resources through this channel
9047///
9048/// A builder for the *stop* method supported by a *channel* resource.
9049/// It is not used directly, but through a [`ChannelMethods`] instance.
9050///
9051/// # Example
9052///
9053/// Instantiate a resource method builder
9054///
9055/// ```test_harness,no_run
9056/// # extern crate hyper;
9057/// # extern crate hyper_rustls;
9058/// # extern crate google_calendar3 as calendar3;
9059/// use calendar3::api::Channel;
9060/// # async fn dox() {
9061/// # use calendar3::{CalendarHub, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
9062///
9063/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
9064/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
9065/// #     secret,
9066/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
9067/// # ).build().await.unwrap();
9068///
9069/// # let client = hyper_util::client::legacy::Client::builder(
9070/// #     hyper_util::rt::TokioExecutor::new()
9071/// # )
9072/// # .build(
9073/// #     hyper_rustls::HttpsConnectorBuilder::new()
9074/// #         .with_native_roots()
9075/// #         .unwrap()
9076/// #         .https_or_http()
9077/// #         .enable_http1()
9078/// #         .build()
9079/// # );
9080/// # let mut hub = CalendarHub::new(client, auth);
9081/// // As the method needs a request, you would usually fill it with the desired information
9082/// // into the respective structure. Some of the parts shown here might not be applicable !
9083/// // Values shown here are possibly random and not representative !
9084/// let mut req = Channel::default();
9085///
9086/// // You can configure optional parameters by calling the respective setters at will, and
9087/// // execute the final call using `doit()`.
9088/// // Values shown here are possibly random and not representative !
9089/// let result = hub.channels().stop(req)
9090///              .doit().await;
9091/// # }
9092/// ```
9093pub struct ChannelStopCall<'a, C>
9094where
9095    C: 'a,
9096{
9097    hub: &'a CalendarHub<C>,
9098    _request: Channel,
9099    _delegate: Option<&'a mut dyn common::Delegate>,
9100    _additional_params: HashMap<String, String>,
9101    _scopes: BTreeSet<String>,
9102}
9103
9104impl<'a, C> common::CallBuilder for ChannelStopCall<'a, C> {}
9105
9106impl<'a, C> ChannelStopCall<'a, C>
9107where
9108    C: common::Connector,
9109{
9110    /// Perform the operation you have build so far.
9111    pub async fn doit(mut self) -> common::Result<common::Response> {
9112        use std::borrow::Cow;
9113        use std::io::{Read, Seek};
9114
9115        use common::{url::Params, ToParts};
9116        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
9117
9118        let mut dd = common::DefaultDelegate;
9119        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
9120        dlg.begin(common::MethodInfo {
9121            id: "calendar.channels.stop",
9122            http_method: hyper::Method::POST,
9123        });
9124
9125        for &field in [].iter() {
9126            if self._additional_params.contains_key(field) {
9127                dlg.finished(false);
9128                return Err(common::Error::FieldClash(field));
9129            }
9130        }
9131
9132        let mut params = Params::with_capacity(2 + self._additional_params.len());
9133
9134        params.extend(self._additional_params.iter());
9135
9136        let mut url = self.hub._base_url.clone() + "channels/stop";
9137        if self._scopes.is_empty() {
9138            self._scopes.insert(Scope::Full.as_ref().to_string());
9139        }
9140
9141        let url = params.parse_with_url(&url);
9142
9143        let mut json_mime_type = mime::APPLICATION_JSON;
9144        let mut request_value_reader = {
9145            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
9146            common::remove_json_null_values(&mut value);
9147            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
9148            serde_json::to_writer(&mut dst, &value).unwrap();
9149            dst
9150        };
9151        let request_size = request_value_reader
9152            .seek(std::io::SeekFrom::End(0))
9153            .unwrap();
9154        request_value_reader
9155            .seek(std::io::SeekFrom::Start(0))
9156            .unwrap();
9157
9158        loop {
9159            let token = match self
9160                .hub
9161                .auth
9162                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
9163                .await
9164            {
9165                Ok(token) => token,
9166                Err(e) => match dlg.token(e) {
9167                    Ok(token) => token,
9168                    Err(e) => {
9169                        dlg.finished(false);
9170                        return Err(common::Error::MissingToken(e));
9171                    }
9172                },
9173            };
9174            request_value_reader
9175                .seek(std::io::SeekFrom::Start(0))
9176                .unwrap();
9177            let mut req_result = {
9178                let client = &self.hub.client;
9179                dlg.pre_request();
9180                let mut req_builder = hyper::Request::builder()
9181                    .method(hyper::Method::POST)
9182                    .uri(url.as_str())
9183                    .header(USER_AGENT, self.hub._user_agent.clone());
9184
9185                if let Some(token) = token.as_ref() {
9186                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
9187                }
9188
9189                let request = req_builder
9190                    .header(CONTENT_TYPE, json_mime_type.to_string())
9191                    .header(CONTENT_LENGTH, request_size as u64)
9192                    .body(common::to_body(
9193                        request_value_reader.get_ref().clone().into(),
9194                    ));
9195
9196                client.request(request.unwrap()).await
9197            };
9198
9199            match req_result {
9200                Err(err) => {
9201                    if let common::Retry::After(d) = dlg.http_error(&err) {
9202                        sleep(d).await;
9203                        continue;
9204                    }
9205                    dlg.finished(false);
9206                    return Err(common::Error::HttpError(err));
9207                }
9208                Ok(res) => {
9209                    let (mut parts, body) = res.into_parts();
9210                    let mut body = common::Body::new(body);
9211                    if !parts.status.is_success() {
9212                        let bytes = common::to_bytes(body).await.unwrap_or_default();
9213                        let error = serde_json::from_str(&common::to_string(&bytes));
9214                        let response = common::to_response(parts, bytes.into());
9215
9216                        if let common::Retry::After(d) =
9217                            dlg.http_failure(&response, error.as_ref().ok())
9218                        {
9219                            sleep(d).await;
9220                            continue;
9221                        }
9222
9223                        dlg.finished(false);
9224
9225                        return Err(match error {
9226                            Ok(value) => common::Error::BadRequest(value),
9227                            _ => common::Error::Failure(response),
9228                        });
9229                    }
9230                    let response = common::Response::from_parts(parts, body);
9231
9232                    dlg.finished(true);
9233                    return Ok(response);
9234                }
9235            }
9236        }
9237    }
9238
9239    ///
9240    /// Sets the *request* property to the given value.
9241    ///
9242    /// Even though the property as already been set when instantiating this call,
9243    /// we provide this method for API completeness.
9244    pub fn request(mut self, new_value: Channel) -> ChannelStopCall<'a, C> {
9245        self._request = new_value;
9246        self
9247    }
9248    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
9249    /// while executing the actual API request.
9250    ///
9251    /// ````text
9252    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
9253    /// ````
9254    ///
9255    /// Sets the *delegate* property to the given value.
9256    pub fn delegate(mut self, new_value: &'a mut dyn common::Delegate) -> ChannelStopCall<'a, C> {
9257        self._delegate = Some(new_value);
9258        self
9259    }
9260
9261    /// Set any additional parameter of the query string used in the request.
9262    /// It should be used to set parameters which are not yet available through their own
9263    /// setters.
9264    ///
9265    /// Please note that this method must not be used to set any of the known parameters
9266    /// which have their own setter method. If done anyway, the request will fail.
9267    ///
9268    /// # Additional Parameters
9269    ///
9270    /// * *alt* (query-string) - Data format for the response.
9271    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
9272    /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
9273    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
9274    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
9275    /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
9276    /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
9277    pub fn param<T>(mut self, name: T, value: T) -> ChannelStopCall<'a, C>
9278    where
9279        T: AsRef<str>,
9280    {
9281        self._additional_params
9282            .insert(name.as_ref().to_string(), value.as_ref().to_string());
9283        self
9284    }
9285
9286    /// Identifies the authorization scope for the method you are building.
9287    ///
9288    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
9289    /// [`Scope::Full`].
9290    ///
9291    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
9292    /// tokens for more than one scope.
9293    ///
9294    /// Usually there is more than one suitable scope to authorize an operation, some of which may
9295    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
9296    /// sufficient, a read-write scope will do as well.
9297    pub fn add_scope<St>(mut self, scope: St) -> ChannelStopCall<'a, C>
9298    where
9299        St: AsRef<str>,
9300    {
9301        self._scopes.insert(String::from(scope.as_ref()));
9302        self
9303    }
9304    /// Identifies the authorization scope(s) for the method you are building.
9305    ///
9306    /// See [`Self::add_scope()`] for details.
9307    pub fn add_scopes<I, St>(mut self, scopes: I) -> ChannelStopCall<'a, C>
9308    where
9309        I: IntoIterator<Item = St>,
9310        St: AsRef<str>,
9311    {
9312        self._scopes
9313            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
9314        self
9315    }
9316
9317    /// Removes all scopes, and no default scope will be used either.
9318    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
9319    /// for details).
9320    pub fn clear_scopes(mut self) -> ChannelStopCall<'a, C> {
9321        self._scopes.clear();
9322        self
9323    }
9324}
9325
9326/// Returns the color definitions for calendars and events.
9327///
9328/// A builder for the *get* method supported by a *color* resource.
9329/// It is not used directly, but through a [`ColorMethods`] instance.
9330///
9331/// # Example
9332///
9333/// Instantiate a resource method builder
9334///
9335/// ```test_harness,no_run
9336/// # extern crate hyper;
9337/// # extern crate hyper_rustls;
9338/// # extern crate google_calendar3 as calendar3;
9339/// # async fn dox() {
9340/// # use calendar3::{CalendarHub, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
9341///
9342/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
9343/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
9344/// #     secret,
9345/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
9346/// # ).build().await.unwrap();
9347///
9348/// # let client = hyper_util::client::legacy::Client::builder(
9349/// #     hyper_util::rt::TokioExecutor::new()
9350/// # )
9351/// # .build(
9352/// #     hyper_rustls::HttpsConnectorBuilder::new()
9353/// #         .with_native_roots()
9354/// #         .unwrap()
9355/// #         .https_or_http()
9356/// #         .enable_http1()
9357/// #         .build()
9358/// # );
9359/// # let mut hub = CalendarHub::new(client, auth);
9360/// // You can configure optional parameters by calling the respective setters at will, and
9361/// // execute the final call using `doit()`.
9362/// // Values shown here are possibly random and not representative !
9363/// let result = hub.colors().get()
9364///              .doit().await;
9365/// # }
9366/// ```
9367pub struct ColorGetCall<'a, C>
9368where
9369    C: 'a,
9370{
9371    hub: &'a CalendarHub<C>,
9372    _delegate: Option<&'a mut dyn common::Delegate>,
9373    _additional_params: HashMap<String, String>,
9374    _scopes: BTreeSet<String>,
9375}
9376
9377impl<'a, C> common::CallBuilder for ColorGetCall<'a, C> {}
9378
9379impl<'a, C> ColorGetCall<'a, C>
9380where
9381    C: common::Connector,
9382{
9383    /// Perform the operation you have build so far.
9384    pub async fn doit(mut self) -> common::Result<(common::Response, Colors)> {
9385        use std::borrow::Cow;
9386        use std::io::{Read, Seek};
9387
9388        use common::{url::Params, ToParts};
9389        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
9390
9391        let mut dd = common::DefaultDelegate;
9392        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
9393        dlg.begin(common::MethodInfo {
9394            id: "calendar.colors.get",
9395            http_method: hyper::Method::GET,
9396        });
9397
9398        for &field in ["alt"].iter() {
9399            if self._additional_params.contains_key(field) {
9400                dlg.finished(false);
9401                return Err(common::Error::FieldClash(field));
9402            }
9403        }
9404
9405        let mut params = Params::with_capacity(2 + self._additional_params.len());
9406
9407        params.extend(self._additional_params.iter());
9408
9409        params.push("alt", "json");
9410        let mut url = self.hub._base_url.clone() + "colors";
9411        if self._scopes.is_empty() {
9412            self._scopes.insert(Scope::Readonly.as_ref().to_string());
9413        }
9414
9415        let url = params.parse_with_url(&url);
9416
9417        loop {
9418            let token = match self
9419                .hub
9420                .auth
9421                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
9422                .await
9423            {
9424                Ok(token) => token,
9425                Err(e) => match dlg.token(e) {
9426                    Ok(token) => token,
9427                    Err(e) => {
9428                        dlg.finished(false);
9429                        return Err(common::Error::MissingToken(e));
9430                    }
9431                },
9432            };
9433            let mut req_result = {
9434                let client = &self.hub.client;
9435                dlg.pre_request();
9436                let mut req_builder = hyper::Request::builder()
9437                    .method(hyper::Method::GET)
9438                    .uri(url.as_str())
9439                    .header(USER_AGENT, self.hub._user_agent.clone());
9440
9441                if let Some(token) = token.as_ref() {
9442                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
9443                }
9444
9445                let request = req_builder
9446                    .header(CONTENT_LENGTH, 0_u64)
9447                    .body(common::to_body::<String>(None));
9448
9449                client.request(request.unwrap()).await
9450            };
9451
9452            match req_result {
9453                Err(err) => {
9454                    if let common::Retry::After(d) = dlg.http_error(&err) {
9455                        sleep(d).await;
9456                        continue;
9457                    }
9458                    dlg.finished(false);
9459                    return Err(common::Error::HttpError(err));
9460                }
9461                Ok(res) => {
9462                    let (mut parts, body) = res.into_parts();
9463                    let mut body = common::Body::new(body);
9464                    if !parts.status.is_success() {
9465                        let bytes = common::to_bytes(body).await.unwrap_or_default();
9466                        let error = serde_json::from_str(&common::to_string(&bytes));
9467                        let response = common::to_response(parts, bytes.into());
9468
9469                        if let common::Retry::After(d) =
9470                            dlg.http_failure(&response, error.as_ref().ok())
9471                        {
9472                            sleep(d).await;
9473                            continue;
9474                        }
9475
9476                        dlg.finished(false);
9477
9478                        return Err(match error {
9479                            Ok(value) => common::Error::BadRequest(value),
9480                            _ => common::Error::Failure(response),
9481                        });
9482                    }
9483                    let response = {
9484                        let bytes = common::to_bytes(body).await.unwrap_or_default();
9485                        let encoded = common::to_string(&bytes);
9486                        match serde_json::from_str(&encoded) {
9487                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
9488                            Err(error) => {
9489                                dlg.response_json_decode_error(&encoded, &error);
9490                                return Err(common::Error::JsonDecodeError(
9491                                    encoded.to_string(),
9492                                    error,
9493                                ));
9494                            }
9495                        }
9496                    };
9497
9498                    dlg.finished(true);
9499                    return Ok(response);
9500                }
9501            }
9502        }
9503    }
9504
9505    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
9506    /// while executing the actual API request.
9507    ///
9508    /// ````text
9509    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
9510    /// ````
9511    ///
9512    /// Sets the *delegate* property to the given value.
9513    pub fn delegate(mut self, new_value: &'a mut dyn common::Delegate) -> ColorGetCall<'a, C> {
9514        self._delegate = Some(new_value);
9515        self
9516    }
9517
9518    /// Set any additional parameter of the query string used in the request.
9519    /// It should be used to set parameters which are not yet available through their own
9520    /// setters.
9521    ///
9522    /// Please note that this method must not be used to set any of the known parameters
9523    /// which have their own setter method. If done anyway, the request will fail.
9524    ///
9525    /// # Additional Parameters
9526    ///
9527    /// * *alt* (query-string) - Data format for the response.
9528    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
9529    /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
9530    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
9531    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
9532    /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
9533    /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
9534    pub fn param<T>(mut self, name: T, value: T) -> ColorGetCall<'a, C>
9535    where
9536        T: AsRef<str>,
9537    {
9538        self._additional_params
9539            .insert(name.as_ref().to_string(), value.as_ref().to_string());
9540        self
9541    }
9542
9543    /// Identifies the authorization scope for the method you are building.
9544    ///
9545    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
9546    /// [`Scope::Readonly`].
9547    ///
9548    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
9549    /// tokens for more than one scope.
9550    ///
9551    /// Usually there is more than one suitable scope to authorize an operation, some of which may
9552    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
9553    /// sufficient, a read-write scope will do as well.
9554    pub fn add_scope<St>(mut self, scope: St) -> ColorGetCall<'a, C>
9555    where
9556        St: AsRef<str>,
9557    {
9558        self._scopes.insert(String::from(scope.as_ref()));
9559        self
9560    }
9561    /// Identifies the authorization scope(s) for the method you are building.
9562    ///
9563    /// See [`Self::add_scope()`] for details.
9564    pub fn add_scopes<I, St>(mut self, scopes: I) -> ColorGetCall<'a, C>
9565    where
9566        I: IntoIterator<Item = St>,
9567        St: AsRef<str>,
9568    {
9569        self._scopes
9570            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
9571        self
9572    }
9573
9574    /// Removes all scopes, and no default scope will be used either.
9575    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
9576    /// for details).
9577    pub fn clear_scopes(mut self) -> ColorGetCall<'a, C> {
9578        self._scopes.clear();
9579        self
9580    }
9581}
9582
9583/// Deletes an event.
9584///
9585/// A builder for the *delete* method supported by a *event* resource.
9586/// It is not used directly, but through a [`EventMethods`] instance.
9587///
9588/// # Example
9589///
9590/// Instantiate a resource method builder
9591///
9592/// ```test_harness,no_run
9593/// # extern crate hyper;
9594/// # extern crate hyper_rustls;
9595/// # extern crate google_calendar3 as calendar3;
9596/// # async fn dox() {
9597/// # use calendar3::{CalendarHub, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
9598///
9599/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
9600/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
9601/// #     secret,
9602/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
9603/// # ).build().await.unwrap();
9604///
9605/// # let client = hyper_util::client::legacy::Client::builder(
9606/// #     hyper_util::rt::TokioExecutor::new()
9607/// # )
9608/// # .build(
9609/// #     hyper_rustls::HttpsConnectorBuilder::new()
9610/// #         .with_native_roots()
9611/// #         .unwrap()
9612/// #         .https_or_http()
9613/// #         .enable_http1()
9614/// #         .build()
9615/// # );
9616/// # let mut hub = CalendarHub::new(client, auth);
9617/// // You can configure optional parameters by calling the respective setters at will, and
9618/// // execute the final call using `doit()`.
9619/// // Values shown here are possibly random and not representative !
9620/// let result = hub.events().delete("calendarId", "eventId")
9621///              .send_updates("sed")
9622///              .send_notifications(true)
9623///              .doit().await;
9624/// # }
9625/// ```
9626pub struct EventDeleteCall<'a, C>
9627where
9628    C: 'a,
9629{
9630    hub: &'a CalendarHub<C>,
9631    _calendar_id: String,
9632    _event_id: String,
9633    _send_updates: Option<String>,
9634    _send_notifications: Option<bool>,
9635    _delegate: Option<&'a mut dyn common::Delegate>,
9636    _additional_params: HashMap<String, String>,
9637    _scopes: BTreeSet<String>,
9638}
9639
9640impl<'a, C> common::CallBuilder for EventDeleteCall<'a, C> {}
9641
9642impl<'a, C> EventDeleteCall<'a, C>
9643where
9644    C: common::Connector,
9645{
9646    /// Perform the operation you have build so far.
9647    pub async fn doit(mut self) -> common::Result<common::Response> {
9648        use std::borrow::Cow;
9649        use std::io::{Read, Seek};
9650
9651        use common::{url::Params, ToParts};
9652        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
9653
9654        let mut dd = common::DefaultDelegate;
9655        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
9656        dlg.begin(common::MethodInfo {
9657            id: "calendar.events.delete",
9658            http_method: hyper::Method::DELETE,
9659        });
9660
9661        for &field in ["calendarId", "eventId", "sendUpdates", "sendNotifications"].iter() {
9662            if self._additional_params.contains_key(field) {
9663                dlg.finished(false);
9664                return Err(common::Error::FieldClash(field));
9665            }
9666        }
9667
9668        let mut params = Params::with_capacity(5 + self._additional_params.len());
9669        params.push("calendarId", self._calendar_id);
9670        params.push("eventId", self._event_id);
9671        if let Some(value) = self._send_updates.as_ref() {
9672            params.push("sendUpdates", value);
9673        }
9674        if let Some(value) = self._send_notifications.as_ref() {
9675            params.push("sendNotifications", value.to_string());
9676        }
9677
9678        params.extend(self._additional_params.iter());
9679
9680        let mut url = self.hub._base_url.clone() + "calendars/{calendarId}/events/{eventId}";
9681        if self._scopes.is_empty() {
9682            self._scopes.insert(Scope::Full.as_ref().to_string());
9683        }
9684
9685        #[allow(clippy::single_element_loop)]
9686        for &(find_this, param_name) in
9687            [("{calendarId}", "calendarId"), ("{eventId}", "eventId")].iter()
9688        {
9689            url = params.uri_replacement(url, param_name, find_this, false);
9690        }
9691        {
9692            let to_remove = ["eventId", "calendarId"];
9693            params.remove_params(&to_remove);
9694        }
9695
9696        let url = params.parse_with_url(&url);
9697
9698        loop {
9699            let token = match self
9700                .hub
9701                .auth
9702                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
9703                .await
9704            {
9705                Ok(token) => token,
9706                Err(e) => match dlg.token(e) {
9707                    Ok(token) => token,
9708                    Err(e) => {
9709                        dlg.finished(false);
9710                        return Err(common::Error::MissingToken(e));
9711                    }
9712                },
9713            };
9714            let mut req_result = {
9715                let client = &self.hub.client;
9716                dlg.pre_request();
9717                let mut req_builder = hyper::Request::builder()
9718                    .method(hyper::Method::DELETE)
9719                    .uri(url.as_str())
9720                    .header(USER_AGENT, self.hub._user_agent.clone());
9721
9722                if let Some(token) = token.as_ref() {
9723                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
9724                }
9725
9726                let request = req_builder
9727                    .header(CONTENT_LENGTH, 0_u64)
9728                    .body(common::to_body::<String>(None));
9729
9730                client.request(request.unwrap()).await
9731            };
9732
9733            match req_result {
9734                Err(err) => {
9735                    if let common::Retry::After(d) = dlg.http_error(&err) {
9736                        sleep(d).await;
9737                        continue;
9738                    }
9739                    dlg.finished(false);
9740                    return Err(common::Error::HttpError(err));
9741                }
9742                Ok(res) => {
9743                    let (mut parts, body) = res.into_parts();
9744                    let mut body = common::Body::new(body);
9745                    if !parts.status.is_success() {
9746                        let bytes = common::to_bytes(body).await.unwrap_or_default();
9747                        let error = serde_json::from_str(&common::to_string(&bytes));
9748                        let response = common::to_response(parts, bytes.into());
9749
9750                        if let common::Retry::After(d) =
9751                            dlg.http_failure(&response, error.as_ref().ok())
9752                        {
9753                            sleep(d).await;
9754                            continue;
9755                        }
9756
9757                        dlg.finished(false);
9758
9759                        return Err(match error {
9760                            Ok(value) => common::Error::BadRequest(value),
9761                            _ => common::Error::Failure(response),
9762                        });
9763                    }
9764                    let response = common::Response::from_parts(parts, body);
9765
9766                    dlg.finished(true);
9767                    return Ok(response);
9768                }
9769            }
9770        }
9771    }
9772
9773    /// 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.
9774    ///
9775    /// Sets the *calendar id* path property to the given value.
9776    ///
9777    /// Even though the property as already been set when instantiating this call,
9778    /// we provide this method for API completeness.
9779    pub fn calendar_id(mut self, new_value: &str) -> EventDeleteCall<'a, C> {
9780        self._calendar_id = new_value.to_string();
9781        self
9782    }
9783    /// Event identifier.
9784    ///
9785    /// Sets the *event id* path property to the given value.
9786    ///
9787    /// Even though the property as already been set when instantiating this call,
9788    /// we provide this method for API completeness.
9789    pub fn event_id(mut self, new_value: &str) -> EventDeleteCall<'a, C> {
9790        self._event_id = new_value.to_string();
9791        self
9792    }
9793    /// Guests who should receive notifications about the deletion of the event.
9794    ///
9795    /// Sets the *send updates* query property to the given value.
9796    pub fn send_updates(mut self, new_value: &str) -> EventDeleteCall<'a, C> {
9797        self._send_updates = Some(new_value.to_string());
9798        self
9799    }
9800    /// Deprecated. Please use sendUpdates instead.
9801    ///
9802    /// 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.
9803    ///
9804    /// Sets the *send notifications* query property to the given value.
9805    pub fn send_notifications(mut self, new_value: bool) -> EventDeleteCall<'a, C> {
9806        self._send_notifications = Some(new_value);
9807        self
9808    }
9809    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
9810    /// while executing the actual API request.
9811    ///
9812    /// ````text
9813    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
9814    /// ````
9815    ///
9816    /// Sets the *delegate* property to the given value.
9817    pub fn delegate(mut self, new_value: &'a mut dyn common::Delegate) -> EventDeleteCall<'a, C> {
9818        self._delegate = Some(new_value);
9819        self
9820    }
9821
9822    /// Set any additional parameter of the query string used in the request.
9823    /// It should be used to set parameters which are not yet available through their own
9824    /// setters.
9825    ///
9826    /// Please note that this method must not be used to set any of the known parameters
9827    /// which have their own setter method. If done anyway, the request will fail.
9828    ///
9829    /// # Additional Parameters
9830    ///
9831    /// * *alt* (query-string) - Data format for the response.
9832    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
9833    /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
9834    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
9835    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
9836    /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
9837    /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
9838    pub fn param<T>(mut self, name: T, value: T) -> EventDeleteCall<'a, C>
9839    where
9840        T: AsRef<str>,
9841    {
9842        self._additional_params
9843            .insert(name.as_ref().to_string(), value.as_ref().to_string());
9844        self
9845    }
9846
9847    /// Identifies the authorization scope for the method you are building.
9848    ///
9849    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
9850    /// [`Scope::Full`].
9851    ///
9852    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
9853    /// tokens for more than one scope.
9854    ///
9855    /// Usually there is more than one suitable scope to authorize an operation, some of which may
9856    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
9857    /// sufficient, a read-write scope will do as well.
9858    pub fn add_scope<St>(mut self, scope: St) -> EventDeleteCall<'a, C>
9859    where
9860        St: AsRef<str>,
9861    {
9862        self._scopes.insert(String::from(scope.as_ref()));
9863        self
9864    }
9865    /// Identifies the authorization scope(s) for the method you are building.
9866    ///
9867    /// See [`Self::add_scope()`] for details.
9868    pub fn add_scopes<I, St>(mut self, scopes: I) -> EventDeleteCall<'a, C>
9869    where
9870        I: IntoIterator<Item = St>,
9871        St: AsRef<str>,
9872    {
9873        self._scopes
9874            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
9875        self
9876    }
9877
9878    /// Removes all scopes, and no default scope will be used either.
9879    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
9880    /// for details).
9881    pub fn clear_scopes(mut self) -> EventDeleteCall<'a, C> {
9882        self._scopes.clear();
9883        self
9884    }
9885}
9886
9887/// Returns an event based on its Google Calendar ID. To retrieve an event using its iCalendar ID, call the events.list method using the iCalUID parameter.
9888///
9889/// A builder for the *get* method supported by a *event* resource.
9890/// It is not used directly, but through a [`EventMethods`] instance.
9891///
9892/// # Example
9893///
9894/// Instantiate a resource method builder
9895///
9896/// ```test_harness,no_run
9897/// # extern crate hyper;
9898/// # extern crate hyper_rustls;
9899/// # extern crate google_calendar3 as calendar3;
9900/// # async fn dox() {
9901/// # use calendar3::{CalendarHub, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
9902///
9903/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
9904/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
9905/// #     secret,
9906/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
9907/// # ).build().await.unwrap();
9908///
9909/// # let client = hyper_util::client::legacy::Client::builder(
9910/// #     hyper_util::rt::TokioExecutor::new()
9911/// # )
9912/// # .build(
9913/// #     hyper_rustls::HttpsConnectorBuilder::new()
9914/// #         .with_native_roots()
9915/// #         .unwrap()
9916/// #         .https_or_http()
9917/// #         .enable_http1()
9918/// #         .build()
9919/// # );
9920/// # let mut hub = CalendarHub::new(client, auth);
9921/// // You can configure optional parameters by calling the respective setters at will, and
9922/// // execute the final call using `doit()`.
9923/// // Values shown here are possibly random and not representative !
9924/// let result = hub.events().get("calendarId", "eventId")
9925///              .time_zone("sadipscing")
9926///              .max_attendees(-32)
9927///              .always_include_email(true)
9928///              .doit().await;
9929/// # }
9930/// ```
9931pub struct EventGetCall<'a, C>
9932where
9933    C: 'a,
9934{
9935    hub: &'a CalendarHub<C>,
9936    _calendar_id: String,
9937    _event_id: String,
9938    _time_zone: Option<String>,
9939    _max_attendees: Option<i32>,
9940    _always_include_email: Option<bool>,
9941    _delegate: Option<&'a mut dyn common::Delegate>,
9942    _additional_params: HashMap<String, String>,
9943    _scopes: BTreeSet<String>,
9944}
9945
9946impl<'a, C> common::CallBuilder for EventGetCall<'a, C> {}
9947
9948impl<'a, C> EventGetCall<'a, C>
9949where
9950    C: common::Connector,
9951{
9952    /// Perform the operation you have build so far.
9953    pub async fn doit(mut self) -> common::Result<(common::Response, Event)> {
9954        use std::borrow::Cow;
9955        use std::io::{Read, Seek};
9956
9957        use common::{url::Params, ToParts};
9958        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
9959
9960        let mut dd = common::DefaultDelegate;
9961        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
9962        dlg.begin(common::MethodInfo {
9963            id: "calendar.events.get",
9964            http_method: hyper::Method::GET,
9965        });
9966
9967        for &field in [
9968            "alt",
9969            "calendarId",
9970            "eventId",
9971            "timeZone",
9972            "maxAttendees",
9973            "alwaysIncludeEmail",
9974        ]
9975        .iter()
9976        {
9977            if self._additional_params.contains_key(field) {
9978                dlg.finished(false);
9979                return Err(common::Error::FieldClash(field));
9980            }
9981        }
9982
9983        let mut params = Params::with_capacity(7 + self._additional_params.len());
9984        params.push("calendarId", self._calendar_id);
9985        params.push("eventId", self._event_id);
9986        if let Some(value) = self._time_zone.as_ref() {
9987            params.push("timeZone", value);
9988        }
9989        if let Some(value) = self._max_attendees.as_ref() {
9990            params.push("maxAttendees", value.to_string());
9991        }
9992        if let Some(value) = self._always_include_email.as_ref() {
9993            params.push("alwaysIncludeEmail", value.to_string());
9994        }
9995
9996        params.extend(self._additional_params.iter());
9997
9998        params.push("alt", "json");
9999        let mut url = self.hub._base_url.clone() + "calendars/{calendarId}/events/{eventId}";
10000        if self._scopes.is_empty() {
10001            self._scopes
10002                .insert(Scope::EventReadonly.as_ref().to_string());
10003        }
10004
10005        #[allow(clippy::single_element_loop)]
10006        for &(find_this, param_name) in
10007            [("{calendarId}", "calendarId"), ("{eventId}", "eventId")].iter()
10008        {
10009            url = params.uri_replacement(url, param_name, find_this, false);
10010        }
10011        {
10012            let to_remove = ["eventId", "calendarId"];
10013            params.remove_params(&to_remove);
10014        }
10015
10016        let url = params.parse_with_url(&url);
10017
10018        loop {
10019            let token = match self
10020                .hub
10021                .auth
10022                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
10023                .await
10024            {
10025                Ok(token) => token,
10026                Err(e) => match dlg.token(e) {
10027                    Ok(token) => token,
10028                    Err(e) => {
10029                        dlg.finished(false);
10030                        return Err(common::Error::MissingToken(e));
10031                    }
10032                },
10033            };
10034            let mut req_result = {
10035                let client = &self.hub.client;
10036                dlg.pre_request();
10037                let mut req_builder = hyper::Request::builder()
10038                    .method(hyper::Method::GET)
10039                    .uri(url.as_str())
10040                    .header(USER_AGENT, self.hub._user_agent.clone());
10041
10042                if let Some(token) = token.as_ref() {
10043                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
10044                }
10045
10046                let request = req_builder
10047                    .header(CONTENT_LENGTH, 0_u64)
10048                    .body(common::to_body::<String>(None));
10049
10050                client.request(request.unwrap()).await
10051            };
10052
10053            match req_result {
10054                Err(err) => {
10055                    if let common::Retry::After(d) = dlg.http_error(&err) {
10056                        sleep(d).await;
10057                        continue;
10058                    }
10059                    dlg.finished(false);
10060                    return Err(common::Error::HttpError(err));
10061                }
10062                Ok(res) => {
10063                    let (mut parts, body) = res.into_parts();
10064                    let mut body = common::Body::new(body);
10065                    if !parts.status.is_success() {
10066                        let bytes = common::to_bytes(body).await.unwrap_or_default();
10067                        let error = serde_json::from_str(&common::to_string(&bytes));
10068                        let response = common::to_response(parts, bytes.into());
10069
10070                        if let common::Retry::After(d) =
10071                            dlg.http_failure(&response, error.as_ref().ok())
10072                        {
10073                            sleep(d).await;
10074                            continue;
10075                        }
10076
10077                        dlg.finished(false);
10078
10079                        return Err(match error {
10080                            Ok(value) => common::Error::BadRequest(value),
10081                            _ => common::Error::Failure(response),
10082                        });
10083                    }
10084                    let response = {
10085                        let bytes = common::to_bytes(body).await.unwrap_or_default();
10086                        let encoded = common::to_string(&bytes);
10087                        match serde_json::from_str(&encoded) {
10088                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
10089                            Err(error) => {
10090                                dlg.response_json_decode_error(&encoded, &error);
10091                                return Err(common::Error::JsonDecodeError(
10092                                    encoded.to_string(),
10093                                    error,
10094                                ));
10095                            }
10096                        }
10097                    };
10098
10099                    dlg.finished(true);
10100                    return Ok(response);
10101                }
10102            }
10103        }
10104    }
10105
10106    /// 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.
10107    ///
10108    /// Sets the *calendar id* path property to the given value.
10109    ///
10110    /// Even though the property as already been set when instantiating this call,
10111    /// we provide this method for API completeness.
10112    pub fn calendar_id(mut self, new_value: &str) -> EventGetCall<'a, C> {
10113        self._calendar_id = new_value.to_string();
10114        self
10115    }
10116    /// Event identifier.
10117    ///
10118    /// Sets the *event id* path property to the given value.
10119    ///
10120    /// Even though the property as already been set when instantiating this call,
10121    /// we provide this method for API completeness.
10122    pub fn event_id(mut self, new_value: &str) -> EventGetCall<'a, C> {
10123        self._event_id = new_value.to_string();
10124        self
10125    }
10126    /// Time zone used in the response. Optional. The default is the time zone of the calendar.
10127    ///
10128    /// Sets the *time zone* query property to the given value.
10129    pub fn time_zone(mut self, new_value: &str) -> EventGetCall<'a, C> {
10130        self._time_zone = Some(new_value.to_string());
10131        self
10132    }
10133    /// 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.
10134    ///
10135    /// Sets the *max attendees* query property to the given value.
10136    pub fn max_attendees(mut self, new_value: i32) -> EventGetCall<'a, C> {
10137        self._max_attendees = Some(new_value);
10138        self
10139    }
10140    /// 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).
10141    ///
10142    /// Sets the *always include email* query property to the given value.
10143    pub fn always_include_email(mut self, new_value: bool) -> EventGetCall<'a, C> {
10144        self._always_include_email = Some(new_value);
10145        self
10146    }
10147    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
10148    /// while executing the actual API request.
10149    ///
10150    /// ````text
10151    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
10152    /// ````
10153    ///
10154    /// Sets the *delegate* property to the given value.
10155    pub fn delegate(mut self, new_value: &'a mut dyn common::Delegate) -> EventGetCall<'a, C> {
10156        self._delegate = Some(new_value);
10157        self
10158    }
10159
10160    /// Set any additional parameter of the query string used in the request.
10161    /// It should be used to set parameters which are not yet available through their own
10162    /// setters.
10163    ///
10164    /// Please note that this method must not be used to set any of the known parameters
10165    /// which have their own setter method. If done anyway, the request will fail.
10166    ///
10167    /// # Additional Parameters
10168    ///
10169    /// * *alt* (query-string) - Data format for the response.
10170    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
10171    /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
10172    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
10173    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
10174    /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
10175    /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
10176    pub fn param<T>(mut self, name: T, value: T) -> EventGetCall<'a, C>
10177    where
10178        T: AsRef<str>,
10179    {
10180        self._additional_params
10181            .insert(name.as_ref().to_string(), value.as_ref().to_string());
10182        self
10183    }
10184
10185    /// Identifies the authorization scope for the method you are building.
10186    ///
10187    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
10188    /// [`Scope::EventReadonly`].
10189    ///
10190    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
10191    /// tokens for more than one scope.
10192    ///
10193    /// Usually there is more than one suitable scope to authorize an operation, some of which may
10194    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
10195    /// sufficient, a read-write scope will do as well.
10196    pub fn add_scope<St>(mut self, scope: St) -> EventGetCall<'a, C>
10197    where
10198        St: AsRef<str>,
10199    {
10200        self._scopes.insert(String::from(scope.as_ref()));
10201        self
10202    }
10203    /// Identifies the authorization scope(s) for the method you are building.
10204    ///
10205    /// See [`Self::add_scope()`] for details.
10206    pub fn add_scopes<I, St>(mut self, scopes: I) -> EventGetCall<'a, C>
10207    where
10208        I: IntoIterator<Item = St>,
10209        St: AsRef<str>,
10210    {
10211        self._scopes
10212            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
10213        self
10214    }
10215
10216    /// Removes all scopes, and no default scope will be used either.
10217    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
10218    /// for details).
10219    pub fn clear_scopes(mut self) -> EventGetCall<'a, C> {
10220        self._scopes.clear();
10221        self
10222    }
10223}
10224
10225/// Imports an event. This operation is used to add a private copy of an existing event to a calendar. Only events with an eventType of default may be imported.
10226/// Deprecated behavior: If a non-default event is imported, its type will be changed to default and any event-type-specific properties it may have will be dropped.
10227///
10228/// A builder for the *import* method supported by a *event* resource.
10229/// It is not used directly, but through a [`EventMethods`] instance.
10230///
10231/// # Example
10232///
10233/// Instantiate a resource method builder
10234///
10235/// ```test_harness,no_run
10236/// # extern crate hyper;
10237/// # extern crate hyper_rustls;
10238/// # extern crate google_calendar3 as calendar3;
10239/// use calendar3::api::Event;
10240/// # async fn dox() {
10241/// # use calendar3::{CalendarHub, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
10242///
10243/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
10244/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
10245/// #     secret,
10246/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
10247/// # ).build().await.unwrap();
10248///
10249/// # let client = hyper_util::client::legacy::Client::builder(
10250/// #     hyper_util::rt::TokioExecutor::new()
10251/// # )
10252/// # .build(
10253/// #     hyper_rustls::HttpsConnectorBuilder::new()
10254/// #         .with_native_roots()
10255/// #         .unwrap()
10256/// #         .https_or_http()
10257/// #         .enable_http1()
10258/// #         .build()
10259/// # );
10260/// # let mut hub = CalendarHub::new(client, auth);
10261/// // As the method needs a request, you would usually fill it with the desired information
10262/// // into the respective structure. Some of the parts shown here might not be applicable !
10263/// // Values shown here are possibly random and not representative !
10264/// let mut req = Event::default();
10265///
10266/// // You can configure optional parameters by calling the respective setters at will, and
10267/// // execute the final call using `doit()`.
10268/// // Values shown here are possibly random and not representative !
10269/// let result = hub.events().import(req, "calendarId")
10270///              .supports_attachments(false)
10271///              .conference_data_version(-47)
10272///              .doit().await;
10273/// # }
10274/// ```
10275pub struct EventImportCall<'a, C>
10276where
10277    C: 'a,
10278{
10279    hub: &'a CalendarHub<C>,
10280    _request: Event,
10281    _calendar_id: String,
10282    _supports_attachments: Option<bool>,
10283    _conference_data_version: Option<i32>,
10284    _delegate: Option<&'a mut dyn common::Delegate>,
10285    _additional_params: HashMap<String, String>,
10286    _scopes: BTreeSet<String>,
10287}
10288
10289impl<'a, C> common::CallBuilder for EventImportCall<'a, C> {}
10290
10291impl<'a, C> EventImportCall<'a, C>
10292where
10293    C: common::Connector,
10294{
10295    /// Perform the operation you have build so far.
10296    pub async fn doit(mut self) -> common::Result<(common::Response, Event)> {
10297        use std::borrow::Cow;
10298        use std::io::{Read, Seek};
10299
10300        use common::{url::Params, ToParts};
10301        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
10302
10303        let mut dd = common::DefaultDelegate;
10304        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
10305        dlg.begin(common::MethodInfo {
10306            id: "calendar.events.import",
10307            http_method: hyper::Method::POST,
10308        });
10309
10310        for &field in [
10311            "alt",
10312            "calendarId",
10313            "supportsAttachments",
10314            "conferenceDataVersion",
10315        ]
10316        .iter()
10317        {
10318            if self._additional_params.contains_key(field) {
10319                dlg.finished(false);
10320                return Err(common::Error::FieldClash(field));
10321            }
10322        }
10323
10324        let mut params = Params::with_capacity(6 + self._additional_params.len());
10325        params.push("calendarId", self._calendar_id);
10326        if let Some(value) = self._supports_attachments.as_ref() {
10327            params.push("supportsAttachments", value.to_string());
10328        }
10329        if let Some(value) = self._conference_data_version.as_ref() {
10330            params.push("conferenceDataVersion", value.to_string());
10331        }
10332
10333        params.extend(self._additional_params.iter());
10334
10335        params.push("alt", "json");
10336        let mut url = self.hub._base_url.clone() + "calendars/{calendarId}/events/import";
10337        if self._scopes.is_empty() {
10338            self._scopes.insert(Scope::Full.as_ref().to_string());
10339        }
10340
10341        #[allow(clippy::single_element_loop)]
10342        for &(find_this, param_name) in [("{calendarId}", "calendarId")].iter() {
10343            url = params.uri_replacement(url, param_name, find_this, false);
10344        }
10345        {
10346            let to_remove = ["calendarId"];
10347            params.remove_params(&to_remove);
10348        }
10349
10350        let url = params.parse_with_url(&url);
10351
10352        let mut json_mime_type = mime::APPLICATION_JSON;
10353        let mut request_value_reader = {
10354            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
10355            common::remove_json_null_values(&mut value);
10356            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
10357            serde_json::to_writer(&mut dst, &value).unwrap();
10358            dst
10359        };
10360        let request_size = request_value_reader
10361            .seek(std::io::SeekFrom::End(0))
10362            .unwrap();
10363        request_value_reader
10364            .seek(std::io::SeekFrom::Start(0))
10365            .unwrap();
10366
10367        loop {
10368            let token = match self
10369                .hub
10370                .auth
10371                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
10372                .await
10373            {
10374                Ok(token) => token,
10375                Err(e) => match dlg.token(e) {
10376                    Ok(token) => token,
10377                    Err(e) => {
10378                        dlg.finished(false);
10379                        return Err(common::Error::MissingToken(e));
10380                    }
10381                },
10382            };
10383            request_value_reader
10384                .seek(std::io::SeekFrom::Start(0))
10385                .unwrap();
10386            let mut req_result = {
10387                let client = &self.hub.client;
10388                dlg.pre_request();
10389                let mut req_builder = hyper::Request::builder()
10390                    .method(hyper::Method::POST)
10391                    .uri(url.as_str())
10392                    .header(USER_AGENT, self.hub._user_agent.clone());
10393
10394                if let Some(token) = token.as_ref() {
10395                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
10396                }
10397
10398                let request = req_builder
10399                    .header(CONTENT_TYPE, json_mime_type.to_string())
10400                    .header(CONTENT_LENGTH, request_size as u64)
10401                    .body(common::to_body(
10402                        request_value_reader.get_ref().clone().into(),
10403                    ));
10404
10405                client.request(request.unwrap()).await
10406            };
10407
10408            match req_result {
10409                Err(err) => {
10410                    if let common::Retry::After(d) = dlg.http_error(&err) {
10411                        sleep(d).await;
10412                        continue;
10413                    }
10414                    dlg.finished(false);
10415                    return Err(common::Error::HttpError(err));
10416                }
10417                Ok(res) => {
10418                    let (mut parts, body) = res.into_parts();
10419                    let mut body = common::Body::new(body);
10420                    if !parts.status.is_success() {
10421                        let bytes = common::to_bytes(body).await.unwrap_or_default();
10422                        let error = serde_json::from_str(&common::to_string(&bytes));
10423                        let response = common::to_response(parts, bytes.into());
10424
10425                        if let common::Retry::After(d) =
10426                            dlg.http_failure(&response, error.as_ref().ok())
10427                        {
10428                            sleep(d).await;
10429                            continue;
10430                        }
10431
10432                        dlg.finished(false);
10433
10434                        return Err(match error {
10435                            Ok(value) => common::Error::BadRequest(value),
10436                            _ => common::Error::Failure(response),
10437                        });
10438                    }
10439                    let response = {
10440                        let bytes = common::to_bytes(body).await.unwrap_or_default();
10441                        let encoded = common::to_string(&bytes);
10442                        match serde_json::from_str(&encoded) {
10443                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
10444                            Err(error) => {
10445                                dlg.response_json_decode_error(&encoded, &error);
10446                                return Err(common::Error::JsonDecodeError(
10447                                    encoded.to_string(),
10448                                    error,
10449                                ));
10450                            }
10451                        }
10452                    };
10453
10454                    dlg.finished(true);
10455                    return Ok(response);
10456                }
10457            }
10458        }
10459    }
10460
10461    ///
10462    /// Sets the *request* property to the given value.
10463    ///
10464    /// Even though the property as already been set when instantiating this call,
10465    /// we provide this method for API completeness.
10466    pub fn request(mut self, new_value: Event) -> EventImportCall<'a, C> {
10467        self._request = new_value;
10468        self
10469    }
10470    /// 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.
10471    ///
10472    /// Sets the *calendar id* path property to the given value.
10473    ///
10474    /// Even though the property as already been set when instantiating this call,
10475    /// we provide this method for API completeness.
10476    pub fn calendar_id(mut self, new_value: &str) -> EventImportCall<'a, C> {
10477        self._calendar_id = new_value.to_string();
10478        self
10479    }
10480    /// Whether API client performing operation supports event attachments. Optional. The default is False.
10481    ///
10482    /// Sets the *supports attachments* query property to the given value.
10483    pub fn supports_attachments(mut self, new_value: bool) -> EventImportCall<'a, C> {
10484        self._supports_attachments = Some(new_value);
10485        self
10486    }
10487    /// 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.
10488    ///
10489    /// Sets the *conference data version* query property to the given value.
10490    pub fn conference_data_version(mut self, new_value: i32) -> EventImportCall<'a, C> {
10491        self._conference_data_version = Some(new_value);
10492        self
10493    }
10494    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
10495    /// while executing the actual API request.
10496    ///
10497    /// ````text
10498    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
10499    /// ````
10500    ///
10501    /// Sets the *delegate* property to the given value.
10502    pub fn delegate(mut self, new_value: &'a mut dyn common::Delegate) -> EventImportCall<'a, C> {
10503        self._delegate = Some(new_value);
10504        self
10505    }
10506
10507    /// Set any additional parameter of the query string used in the request.
10508    /// It should be used to set parameters which are not yet available through their own
10509    /// setters.
10510    ///
10511    /// Please note that this method must not be used to set any of the known parameters
10512    /// which have their own setter method. If done anyway, the request will fail.
10513    ///
10514    /// # Additional Parameters
10515    ///
10516    /// * *alt* (query-string) - Data format for the response.
10517    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
10518    /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
10519    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
10520    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
10521    /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
10522    /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
10523    pub fn param<T>(mut self, name: T, value: T) -> EventImportCall<'a, C>
10524    where
10525        T: AsRef<str>,
10526    {
10527        self._additional_params
10528            .insert(name.as_ref().to_string(), value.as_ref().to_string());
10529        self
10530    }
10531
10532    /// Identifies the authorization scope for the method you are building.
10533    ///
10534    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
10535    /// [`Scope::Full`].
10536    ///
10537    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
10538    /// tokens for more than one scope.
10539    ///
10540    /// Usually there is more than one suitable scope to authorize an operation, some of which may
10541    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
10542    /// sufficient, a read-write scope will do as well.
10543    pub fn add_scope<St>(mut self, scope: St) -> EventImportCall<'a, C>
10544    where
10545        St: AsRef<str>,
10546    {
10547        self._scopes.insert(String::from(scope.as_ref()));
10548        self
10549    }
10550    /// Identifies the authorization scope(s) for the method you are building.
10551    ///
10552    /// See [`Self::add_scope()`] for details.
10553    pub fn add_scopes<I, St>(mut self, scopes: I) -> EventImportCall<'a, C>
10554    where
10555        I: IntoIterator<Item = St>,
10556        St: AsRef<str>,
10557    {
10558        self._scopes
10559            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
10560        self
10561    }
10562
10563    /// Removes all scopes, and no default scope will be used either.
10564    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
10565    /// for details).
10566    pub fn clear_scopes(mut self) -> EventImportCall<'a, C> {
10567        self._scopes.clear();
10568        self
10569    }
10570}
10571
10572/// Creates an event.
10573///
10574/// A builder for the *insert* method supported by a *event* resource.
10575/// It is not used directly, but through a [`EventMethods`] instance.
10576///
10577/// # Example
10578///
10579/// Instantiate a resource method builder
10580///
10581/// ```test_harness,no_run
10582/// # extern crate hyper;
10583/// # extern crate hyper_rustls;
10584/// # extern crate google_calendar3 as calendar3;
10585/// use calendar3::api::Event;
10586/// # async fn dox() {
10587/// # use calendar3::{CalendarHub, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
10588///
10589/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
10590/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
10591/// #     secret,
10592/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
10593/// # ).build().await.unwrap();
10594///
10595/// # let client = hyper_util::client::legacy::Client::builder(
10596/// #     hyper_util::rt::TokioExecutor::new()
10597/// # )
10598/// # .build(
10599/// #     hyper_rustls::HttpsConnectorBuilder::new()
10600/// #         .with_native_roots()
10601/// #         .unwrap()
10602/// #         .https_or_http()
10603/// #         .enable_http1()
10604/// #         .build()
10605/// # );
10606/// # let mut hub = CalendarHub::new(client, auth);
10607/// // As the method needs a request, you would usually fill it with the desired information
10608/// // into the respective structure. Some of the parts shown here might not be applicable !
10609/// // Values shown here are possibly random and not representative !
10610/// let mut req = Event::default();
10611///
10612/// // You can configure optional parameters by calling the respective setters at will, and
10613/// // execute the final call using `doit()`.
10614/// // Values shown here are possibly random and not representative !
10615/// let result = hub.events().insert(req, "calendarId")
10616///              .supports_attachments(false)
10617///              .send_updates("consetetur")
10618///              .send_notifications(true)
10619///              .max_attendees(-7)
10620///              .conference_data_version(-82)
10621///              .doit().await;
10622/// # }
10623/// ```
10624pub struct EventInsertCall<'a, C>
10625where
10626    C: 'a,
10627{
10628    hub: &'a CalendarHub<C>,
10629    _request: Event,
10630    _calendar_id: String,
10631    _supports_attachments: Option<bool>,
10632    _send_updates: Option<String>,
10633    _send_notifications: Option<bool>,
10634    _max_attendees: Option<i32>,
10635    _conference_data_version: Option<i32>,
10636    _delegate: Option<&'a mut dyn common::Delegate>,
10637    _additional_params: HashMap<String, String>,
10638    _scopes: BTreeSet<String>,
10639}
10640
10641impl<'a, C> common::CallBuilder for EventInsertCall<'a, C> {}
10642
10643impl<'a, C> EventInsertCall<'a, C>
10644where
10645    C: common::Connector,
10646{
10647    /// Perform the operation you have build so far.
10648    pub async fn doit(mut self) -> common::Result<(common::Response, Event)> {
10649        use std::borrow::Cow;
10650        use std::io::{Read, Seek};
10651
10652        use common::{url::Params, ToParts};
10653        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
10654
10655        let mut dd = common::DefaultDelegate;
10656        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
10657        dlg.begin(common::MethodInfo {
10658            id: "calendar.events.insert",
10659            http_method: hyper::Method::POST,
10660        });
10661
10662        for &field in [
10663            "alt",
10664            "calendarId",
10665            "supportsAttachments",
10666            "sendUpdates",
10667            "sendNotifications",
10668            "maxAttendees",
10669            "conferenceDataVersion",
10670        ]
10671        .iter()
10672        {
10673            if self._additional_params.contains_key(field) {
10674                dlg.finished(false);
10675                return Err(common::Error::FieldClash(field));
10676            }
10677        }
10678
10679        let mut params = Params::with_capacity(9 + self._additional_params.len());
10680        params.push("calendarId", self._calendar_id);
10681        if let Some(value) = self._supports_attachments.as_ref() {
10682            params.push("supportsAttachments", value.to_string());
10683        }
10684        if let Some(value) = self._send_updates.as_ref() {
10685            params.push("sendUpdates", value);
10686        }
10687        if let Some(value) = self._send_notifications.as_ref() {
10688            params.push("sendNotifications", value.to_string());
10689        }
10690        if let Some(value) = self._max_attendees.as_ref() {
10691            params.push("maxAttendees", value.to_string());
10692        }
10693        if let Some(value) = self._conference_data_version.as_ref() {
10694            params.push("conferenceDataVersion", value.to_string());
10695        }
10696
10697        params.extend(self._additional_params.iter());
10698
10699        params.push("alt", "json");
10700        let mut url = self.hub._base_url.clone() + "calendars/{calendarId}/events";
10701        if self._scopes.is_empty() {
10702            self._scopes.insert(Scope::Full.as_ref().to_string());
10703        }
10704
10705        #[allow(clippy::single_element_loop)]
10706        for &(find_this, param_name) in [("{calendarId}", "calendarId")].iter() {
10707            url = params.uri_replacement(url, param_name, find_this, false);
10708        }
10709        {
10710            let to_remove = ["calendarId"];
10711            params.remove_params(&to_remove);
10712        }
10713
10714        let url = params.parse_with_url(&url);
10715
10716        let mut json_mime_type = mime::APPLICATION_JSON;
10717        let mut request_value_reader = {
10718            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
10719            common::remove_json_null_values(&mut value);
10720            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
10721            serde_json::to_writer(&mut dst, &value).unwrap();
10722            dst
10723        };
10724        let request_size = request_value_reader
10725            .seek(std::io::SeekFrom::End(0))
10726            .unwrap();
10727        request_value_reader
10728            .seek(std::io::SeekFrom::Start(0))
10729            .unwrap();
10730
10731        loop {
10732            let token = match self
10733                .hub
10734                .auth
10735                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
10736                .await
10737            {
10738                Ok(token) => token,
10739                Err(e) => match dlg.token(e) {
10740                    Ok(token) => token,
10741                    Err(e) => {
10742                        dlg.finished(false);
10743                        return Err(common::Error::MissingToken(e));
10744                    }
10745                },
10746            };
10747            request_value_reader
10748                .seek(std::io::SeekFrom::Start(0))
10749                .unwrap();
10750            let mut req_result = {
10751                let client = &self.hub.client;
10752                dlg.pre_request();
10753                let mut req_builder = hyper::Request::builder()
10754                    .method(hyper::Method::POST)
10755                    .uri(url.as_str())
10756                    .header(USER_AGENT, self.hub._user_agent.clone());
10757
10758                if let Some(token) = token.as_ref() {
10759                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
10760                }
10761
10762                let request = req_builder
10763                    .header(CONTENT_TYPE, json_mime_type.to_string())
10764                    .header(CONTENT_LENGTH, request_size as u64)
10765                    .body(common::to_body(
10766                        request_value_reader.get_ref().clone().into(),
10767                    ));
10768
10769                client.request(request.unwrap()).await
10770            };
10771
10772            match req_result {
10773                Err(err) => {
10774                    if let common::Retry::After(d) = dlg.http_error(&err) {
10775                        sleep(d).await;
10776                        continue;
10777                    }
10778                    dlg.finished(false);
10779                    return Err(common::Error::HttpError(err));
10780                }
10781                Ok(res) => {
10782                    let (mut parts, body) = res.into_parts();
10783                    let mut body = common::Body::new(body);
10784                    if !parts.status.is_success() {
10785                        let bytes = common::to_bytes(body).await.unwrap_or_default();
10786                        let error = serde_json::from_str(&common::to_string(&bytes));
10787                        let response = common::to_response(parts, bytes.into());
10788
10789                        if let common::Retry::After(d) =
10790                            dlg.http_failure(&response, error.as_ref().ok())
10791                        {
10792                            sleep(d).await;
10793                            continue;
10794                        }
10795
10796                        dlg.finished(false);
10797
10798                        return Err(match error {
10799                            Ok(value) => common::Error::BadRequest(value),
10800                            _ => common::Error::Failure(response),
10801                        });
10802                    }
10803                    let response = {
10804                        let bytes = common::to_bytes(body).await.unwrap_or_default();
10805                        let encoded = common::to_string(&bytes);
10806                        match serde_json::from_str(&encoded) {
10807                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
10808                            Err(error) => {
10809                                dlg.response_json_decode_error(&encoded, &error);
10810                                return Err(common::Error::JsonDecodeError(
10811                                    encoded.to_string(),
10812                                    error,
10813                                ));
10814                            }
10815                        }
10816                    };
10817
10818                    dlg.finished(true);
10819                    return Ok(response);
10820                }
10821            }
10822        }
10823    }
10824
10825    ///
10826    /// Sets the *request* property to the given value.
10827    ///
10828    /// Even though the property as already been set when instantiating this call,
10829    /// we provide this method for API completeness.
10830    pub fn request(mut self, new_value: Event) -> EventInsertCall<'a, C> {
10831        self._request = new_value;
10832        self
10833    }
10834    /// 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.
10835    ///
10836    /// Sets the *calendar id* path property to the given value.
10837    ///
10838    /// Even though the property as already been set when instantiating this call,
10839    /// we provide this method for API completeness.
10840    pub fn calendar_id(mut self, new_value: &str) -> EventInsertCall<'a, C> {
10841        self._calendar_id = new_value.to_string();
10842        self
10843    }
10844    /// Whether API client performing operation supports event attachments. Optional. The default is False.
10845    ///
10846    /// Sets the *supports attachments* query property to the given value.
10847    pub fn supports_attachments(mut self, new_value: bool) -> EventInsertCall<'a, C> {
10848        self._supports_attachments = Some(new_value);
10849        self
10850    }
10851    /// Whether to send notifications about the creation of the new event. Note that some emails might still be sent. The default is false.
10852    ///
10853    /// Sets the *send updates* query property to the given value.
10854    pub fn send_updates(mut self, new_value: &str) -> EventInsertCall<'a, C> {
10855        self._send_updates = Some(new_value.to_string());
10856        self
10857    }
10858    /// Deprecated. Please use sendUpdates instead.
10859    ///
10860    /// 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.
10861    ///
10862    /// Sets the *send notifications* query property to the given value.
10863    pub fn send_notifications(mut self, new_value: bool) -> EventInsertCall<'a, C> {
10864        self._send_notifications = Some(new_value);
10865        self
10866    }
10867    /// 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.
10868    ///
10869    /// Sets the *max attendees* query property to the given value.
10870    pub fn max_attendees(mut self, new_value: i32) -> EventInsertCall<'a, C> {
10871        self._max_attendees = Some(new_value);
10872        self
10873    }
10874    /// 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.
10875    ///
10876    /// Sets the *conference data version* query property to the given value.
10877    pub fn conference_data_version(mut self, new_value: i32) -> EventInsertCall<'a, C> {
10878        self._conference_data_version = Some(new_value);
10879        self
10880    }
10881    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
10882    /// while executing the actual API request.
10883    ///
10884    /// ````text
10885    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
10886    /// ````
10887    ///
10888    /// Sets the *delegate* property to the given value.
10889    pub fn delegate(mut self, new_value: &'a mut dyn common::Delegate) -> EventInsertCall<'a, C> {
10890        self._delegate = Some(new_value);
10891        self
10892    }
10893
10894    /// Set any additional parameter of the query string used in the request.
10895    /// It should be used to set parameters which are not yet available through their own
10896    /// setters.
10897    ///
10898    /// Please note that this method must not be used to set any of the known parameters
10899    /// which have their own setter method. If done anyway, the request will fail.
10900    ///
10901    /// # Additional Parameters
10902    ///
10903    /// * *alt* (query-string) - Data format for the response.
10904    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
10905    /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
10906    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
10907    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
10908    /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
10909    /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
10910    pub fn param<T>(mut self, name: T, value: T) -> EventInsertCall<'a, C>
10911    where
10912        T: AsRef<str>,
10913    {
10914        self._additional_params
10915            .insert(name.as_ref().to_string(), value.as_ref().to_string());
10916        self
10917    }
10918
10919    /// Identifies the authorization scope for the method you are building.
10920    ///
10921    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
10922    /// [`Scope::Full`].
10923    ///
10924    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
10925    /// tokens for more than one scope.
10926    ///
10927    /// Usually there is more than one suitable scope to authorize an operation, some of which may
10928    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
10929    /// sufficient, a read-write scope will do as well.
10930    pub fn add_scope<St>(mut self, scope: St) -> EventInsertCall<'a, C>
10931    where
10932        St: AsRef<str>,
10933    {
10934        self._scopes.insert(String::from(scope.as_ref()));
10935        self
10936    }
10937    /// Identifies the authorization scope(s) for the method you are building.
10938    ///
10939    /// See [`Self::add_scope()`] for details.
10940    pub fn add_scopes<I, St>(mut self, scopes: I) -> EventInsertCall<'a, C>
10941    where
10942        I: IntoIterator<Item = St>,
10943        St: AsRef<str>,
10944    {
10945        self._scopes
10946            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
10947        self
10948    }
10949
10950    /// Removes all scopes, and no default scope will be used either.
10951    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
10952    /// for details).
10953    pub fn clear_scopes(mut self) -> EventInsertCall<'a, C> {
10954        self._scopes.clear();
10955        self
10956    }
10957}
10958
10959/// Returns instances of the specified recurring event.
10960///
10961/// A builder for the *instances* method supported by a *event* resource.
10962/// It is not used directly, but through a [`EventMethods`] instance.
10963///
10964/// # Example
10965///
10966/// Instantiate a resource method builder
10967///
10968/// ```test_harness,no_run
10969/// # extern crate hyper;
10970/// # extern crate hyper_rustls;
10971/// # extern crate google_calendar3 as calendar3;
10972/// # async fn dox() {
10973/// # use calendar3::{CalendarHub, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
10974///
10975/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
10976/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
10977/// #     secret,
10978/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
10979/// # ).build().await.unwrap();
10980///
10981/// # let client = hyper_util::client::legacy::Client::builder(
10982/// #     hyper_util::rt::TokioExecutor::new()
10983/// # )
10984/// # .build(
10985/// #     hyper_rustls::HttpsConnectorBuilder::new()
10986/// #         .with_native_roots()
10987/// #         .unwrap()
10988/// #         .https_or_http()
10989/// #         .enable_http1()
10990/// #         .build()
10991/// # );
10992/// # let mut hub = CalendarHub::new(client, auth);
10993/// // You can configure optional parameters by calling the respective setters at will, and
10994/// // execute the final call using `doit()`.
10995/// // Values shown here are possibly random and not representative !
10996/// let result = hub.events().instances("calendarId", "eventId")
10997///              .time_zone("diam")
10998///              .time_min(chrono::Utc::now())
10999///              .time_max(chrono::Utc::now())
11000///              .show_deleted(true)
11001///              .page_token("sit")
11002///              .original_start("sed")
11003///              .max_results(-75)
11004///              .max_attendees(-56)
11005///              .always_include_email(true)
11006///              .doit().await;
11007/// # }
11008/// ```
11009pub struct EventInstanceCall<'a, C>
11010where
11011    C: 'a,
11012{
11013    hub: &'a CalendarHub<C>,
11014    _calendar_id: String,
11015    _event_id: String,
11016    _time_zone: Option<String>,
11017    _time_min: Option<chrono::DateTime<chrono::offset::Utc>>,
11018    _time_max: Option<chrono::DateTime<chrono::offset::Utc>>,
11019    _show_deleted: Option<bool>,
11020    _page_token: Option<String>,
11021    _original_start: Option<String>,
11022    _max_results: Option<i32>,
11023    _max_attendees: Option<i32>,
11024    _always_include_email: Option<bool>,
11025    _delegate: Option<&'a mut dyn common::Delegate>,
11026    _additional_params: HashMap<String, String>,
11027    _scopes: BTreeSet<String>,
11028}
11029
11030impl<'a, C> common::CallBuilder for EventInstanceCall<'a, C> {}
11031
11032impl<'a, C> EventInstanceCall<'a, C>
11033where
11034    C: common::Connector,
11035{
11036    /// Perform the operation you have build so far.
11037    pub async fn doit(mut self) -> common::Result<(common::Response, Events)> {
11038        use std::borrow::Cow;
11039        use std::io::{Read, Seek};
11040
11041        use common::{url::Params, ToParts};
11042        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
11043
11044        let mut dd = common::DefaultDelegate;
11045        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
11046        dlg.begin(common::MethodInfo {
11047            id: "calendar.events.instances",
11048            http_method: hyper::Method::GET,
11049        });
11050
11051        for &field in [
11052            "alt",
11053            "calendarId",
11054            "eventId",
11055            "timeZone",
11056            "timeMin",
11057            "timeMax",
11058            "showDeleted",
11059            "pageToken",
11060            "originalStart",
11061            "maxResults",
11062            "maxAttendees",
11063            "alwaysIncludeEmail",
11064        ]
11065        .iter()
11066        {
11067            if self._additional_params.contains_key(field) {
11068                dlg.finished(false);
11069                return Err(common::Error::FieldClash(field));
11070            }
11071        }
11072
11073        let mut params = Params::with_capacity(13 + self._additional_params.len());
11074        params.push("calendarId", self._calendar_id);
11075        params.push("eventId", self._event_id);
11076        if let Some(value) = self._time_zone.as_ref() {
11077            params.push("timeZone", value);
11078        }
11079        if let Some(value) = self._time_min.as_ref() {
11080            params.push("timeMin", common::serde::datetime_to_string(&value));
11081        }
11082        if let Some(value) = self._time_max.as_ref() {
11083            params.push("timeMax", common::serde::datetime_to_string(&value));
11084        }
11085        if let Some(value) = self._show_deleted.as_ref() {
11086            params.push("showDeleted", value.to_string());
11087        }
11088        if let Some(value) = self._page_token.as_ref() {
11089            params.push("pageToken", value);
11090        }
11091        if let Some(value) = self._original_start.as_ref() {
11092            params.push("originalStart", value);
11093        }
11094        if let Some(value) = self._max_results.as_ref() {
11095            params.push("maxResults", value.to_string());
11096        }
11097        if let Some(value) = self._max_attendees.as_ref() {
11098            params.push("maxAttendees", value.to_string());
11099        }
11100        if let Some(value) = self._always_include_email.as_ref() {
11101            params.push("alwaysIncludeEmail", value.to_string());
11102        }
11103
11104        params.extend(self._additional_params.iter());
11105
11106        params.push("alt", "json");
11107        let mut url =
11108            self.hub._base_url.clone() + "calendars/{calendarId}/events/{eventId}/instances";
11109        if self._scopes.is_empty() {
11110            self._scopes
11111                .insert(Scope::EventReadonly.as_ref().to_string());
11112        }
11113
11114        #[allow(clippy::single_element_loop)]
11115        for &(find_this, param_name) in
11116            [("{calendarId}", "calendarId"), ("{eventId}", "eventId")].iter()
11117        {
11118            url = params.uri_replacement(url, param_name, find_this, false);
11119        }
11120        {
11121            let to_remove = ["eventId", "calendarId"];
11122            params.remove_params(&to_remove);
11123        }
11124
11125        let url = params.parse_with_url(&url);
11126
11127        loop {
11128            let token = match self
11129                .hub
11130                .auth
11131                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
11132                .await
11133            {
11134                Ok(token) => token,
11135                Err(e) => match dlg.token(e) {
11136                    Ok(token) => token,
11137                    Err(e) => {
11138                        dlg.finished(false);
11139                        return Err(common::Error::MissingToken(e));
11140                    }
11141                },
11142            };
11143            let mut req_result = {
11144                let client = &self.hub.client;
11145                dlg.pre_request();
11146                let mut req_builder = hyper::Request::builder()
11147                    .method(hyper::Method::GET)
11148                    .uri(url.as_str())
11149                    .header(USER_AGENT, self.hub._user_agent.clone());
11150
11151                if let Some(token) = token.as_ref() {
11152                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
11153                }
11154
11155                let request = req_builder
11156                    .header(CONTENT_LENGTH, 0_u64)
11157                    .body(common::to_body::<String>(None));
11158
11159                client.request(request.unwrap()).await
11160            };
11161
11162            match req_result {
11163                Err(err) => {
11164                    if let common::Retry::After(d) = dlg.http_error(&err) {
11165                        sleep(d).await;
11166                        continue;
11167                    }
11168                    dlg.finished(false);
11169                    return Err(common::Error::HttpError(err));
11170                }
11171                Ok(res) => {
11172                    let (mut parts, body) = res.into_parts();
11173                    let mut body = common::Body::new(body);
11174                    if !parts.status.is_success() {
11175                        let bytes = common::to_bytes(body).await.unwrap_or_default();
11176                        let error = serde_json::from_str(&common::to_string(&bytes));
11177                        let response = common::to_response(parts, bytes.into());
11178
11179                        if let common::Retry::After(d) =
11180                            dlg.http_failure(&response, error.as_ref().ok())
11181                        {
11182                            sleep(d).await;
11183                            continue;
11184                        }
11185
11186                        dlg.finished(false);
11187
11188                        return Err(match error {
11189                            Ok(value) => common::Error::BadRequest(value),
11190                            _ => common::Error::Failure(response),
11191                        });
11192                    }
11193                    let response = {
11194                        let bytes = common::to_bytes(body).await.unwrap_or_default();
11195                        let encoded = common::to_string(&bytes);
11196                        match serde_json::from_str(&encoded) {
11197                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
11198                            Err(error) => {
11199                                dlg.response_json_decode_error(&encoded, &error);
11200                                return Err(common::Error::JsonDecodeError(
11201                                    encoded.to_string(),
11202                                    error,
11203                                ));
11204                            }
11205                        }
11206                    };
11207
11208                    dlg.finished(true);
11209                    return Ok(response);
11210                }
11211            }
11212        }
11213    }
11214
11215    /// 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.
11216    ///
11217    /// Sets the *calendar id* path property to the given value.
11218    ///
11219    /// Even though the property as already been set when instantiating this call,
11220    /// we provide this method for API completeness.
11221    pub fn calendar_id(mut self, new_value: &str) -> EventInstanceCall<'a, C> {
11222        self._calendar_id = new_value.to_string();
11223        self
11224    }
11225    /// Recurring event identifier.
11226    ///
11227    /// Sets the *event id* path property to the given value.
11228    ///
11229    /// Even though the property as already been set when instantiating this call,
11230    /// we provide this method for API completeness.
11231    pub fn event_id(mut self, new_value: &str) -> EventInstanceCall<'a, C> {
11232        self._event_id = new_value.to_string();
11233        self
11234    }
11235    /// Time zone used in the response. Optional. The default is the time zone of the calendar.
11236    ///
11237    /// Sets the *time zone* query property to the given value.
11238    pub fn time_zone(mut self, new_value: &str) -> EventInstanceCall<'a, C> {
11239        self._time_zone = Some(new_value.to_string());
11240        self
11241    }
11242    /// 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.
11243    ///
11244    /// Sets the *time min* query property to the given value.
11245    pub fn time_min(
11246        mut self,
11247        new_value: chrono::DateTime<chrono::offset::Utc>,
11248    ) -> EventInstanceCall<'a, C> {
11249        self._time_min = Some(new_value);
11250        self
11251    }
11252    /// 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.
11253    ///
11254    /// Sets the *time max* query property to the given value.
11255    pub fn time_max(
11256        mut self,
11257        new_value: chrono::DateTime<chrono::offset::Utc>,
11258    ) -> EventInstanceCall<'a, C> {
11259        self._time_max = Some(new_value);
11260        self
11261    }
11262    /// 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.
11263    ///
11264    /// Sets the *show deleted* query property to the given value.
11265    pub fn show_deleted(mut self, new_value: bool) -> EventInstanceCall<'a, C> {
11266        self._show_deleted = Some(new_value);
11267        self
11268    }
11269    /// Token specifying which result page to return. Optional.
11270    ///
11271    /// Sets the *page token* query property to the given value.
11272    pub fn page_token(mut self, new_value: &str) -> EventInstanceCall<'a, C> {
11273        self._page_token = Some(new_value.to_string());
11274        self
11275    }
11276    /// The original start time of the instance in the result. Optional.
11277    ///
11278    /// Sets the *original start* query property to the given value.
11279    pub fn original_start(mut self, new_value: &str) -> EventInstanceCall<'a, C> {
11280        self._original_start = Some(new_value.to_string());
11281        self
11282    }
11283    /// 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.
11284    ///
11285    /// Sets the *max results* query property to the given value.
11286    pub fn max_results(mut self, new_value: i32) -> EventInstanceCall<'a, C> {
11287        self._max_results = Some(new_value);
11288        self
11289    }
11290    /// 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.
11291    ///
11292    /// Sets the *max attendees* query property to the given value.
11293    pub fn max_attendees(mut self, new_value: i32) -> EventInstanceCall<'a, C> {
11294        self._max_attendees = Some(new_value);
11295        self
11296    }
11297    /// 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).
11298    ///
11299    /// Sets the *always include email* query property to the given value.
11300    pub fn always_include_email(mut self, new_value: bool) -> EventInstanceCall<'a, C> {
11301        self._always_include_email = Some(new_value);
11302        self
11303    }
11304    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
11305    /// while executing the actual API request.
11306    ///
11307    /// ````text
11308    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
11309    /// ````
11310    ///
11311    /// Sets the *delegate* property to the given value.
11312    pub fn delegate(mut self, new_value: &'a mut dyn common::Delegate) -> EventInstanceCall<'a, C> {
11313        self._delegate = Some(new_value);
11314        self
11315    }
11316
11317    /// Set any additional parameter of the query string used in the request.
11318    /// It should be used to set parameters which are not yet available through their own
11319    /// setters.
11320    ///
11321    /// Please note that this method must not be used to set any of the known parameters
11322    /// which have their own setter method. If done anyway, the request will fail.
11323    ///
11324    /// # Additional Parameters
11325    ///
11326    /// * *alt* (query-string) - Data format for the response.
11327    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
11328    /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
11329    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
11330    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
11331    /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
11332    /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
11333    pub fn param<T>(mut self, name: T, value: T) -> EventInstanceCall<'a, C>
11334    where
11335        T: AsRef<str>,
11336    {
11337        self._additional_params
11338            .insert(name.as_ref().to_string(), value.as_ref().to_string());
11339        self
11340    }
11341
11342    /// Identifies the authorization scope for the method you are building.
11343    ///
11344    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
11345    /// [`Scope::EventReadonly`].
11346    ///
11347    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
11348    /// tokens for more than one scope.
11349    ///
11350    /// Usually there is more than one suitable scope to authorize an operation, some of which may
11351    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
11352    /// sufficient, a read-write scope will do as well.
11353    pub fn add_scope<St>(mut self, scope: St) -> EventInstanceCall<'a, C>
11354    where
11355        St: AsRef<str>,
11356    {
11357        self._scopes.insert(String::from(scope.as_ref()));
11358        self
11359    }
11360    /// Identifies the authorization scope(s) for the method you are building.
11361    ///
11362    /// See [`Self::add_scope()`] for details.
11363    pub fn add_scopes<I, St>(mut self, scopes: I) -> EventInstanceCall<'a, C>
11364    where
11365        I: IntoIterator<Item = St>,
11366        St: AsRef<str>,
11367    {
11368        self._scopes
11369            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
11370        self
11371    }
11372
11373    /// Removes all scopes, and no default scope will be used either.
11374    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
11375    /// for details).
11376    pub fn clear_scopes(mut self) -> EventInstanceCall<'a, C> {
11377        self._scopes.clear();
11378        self
11379    }
11380}
11381
11382/// Returns events on the specified calendar.
11383///
11384/// A builder for the *list* method supported by a *event* resource.
11385/// It is not used directly, but through a [`EventMethods`] instance.
11386///
11387/// # Example
11388///
11389/// Instantiate a resource method builder
11390///
11391/// ```test_harness,no_run
11392/// # extern crate hyper;
11393/// # extern crate hyper_rustls;
11394/// # extern crate google_calendar3 as calendar3;
11395/// # async fn dox() {
11396/// # use calendar3::{CalendarHub, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
11397///
11398/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
11399/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
11400/// #     secret,
11401/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
11402/// # ).build().await.unwrap();
11403///
11404/// # let client = hyper_util::client::legacy::Client::builder(
11405/// #     hyper_util::rt::TokioExecutor::new()
11406/// # )
11407/// # .build(
11408/// #     hyper_rustls::HttpsConnectorBuilder::new()
11409/// #         .with_native_roots()
11410/// #         .unwrap()
11411/// #         .https_or_http()
11412/// #         .enable_http1()
11413/// #         .build()
11414/// # );
11415/// # let mut hub = CalendarHub::new(client, auth);
11416/// // You can configure optional parameters by calling the respective setters at will, and
11417/// // execute the final call using `doit()`.
11418/// // Values shown here are possibly random and not representative !
11419/// let result = hub.events().list("calendarId")
11420///              .updated_min(chrono::Utc::now())
11421///              .time_zone("et")
11422///              .time_min(chrono::Utc::now())
11423///              .time_max(chrono::Utc::now())
11424///              .sync_token("At")
11425///              .single_events(false)
11426///              .show_hidden_invitations(true)
11427///              .show_deleted(true)
11428///              .add_shared_extended_property("accusam")
11429///              .q("amet")
11430///              .add_private_extended_property("erat")
11431///              .page_token("dolores")
11432///              .order_by("erat")
11433///              .max_results(-73)
11434///              .max_attendees(-10)
11435///              .i_cal_uid("takimata")
11436///              .add_event_types("Lorem")
11437///              .always_include_email(false)
11438///              .doit().await;
11439/// # }
11440/// ```
11441pub struct EventListCall<'a, C>
11442where
11443    C: 'a,
11444{
11445    hub: &'a CalendarHub<C>,
11446    _calendar_id: String,
11447    _updated_min: Option<chrono::DateTime<chrono::offset::Utc>>,
11448    _time_zone: Option<String>,
11449    _time_min: Option<chrono::DateTime<chrono::offset::Utc>>,
11450    _time_max: Option<chrono::DateTime<chrono::offset::Utc>>,
11451    _sync_token: Option<String>,
11452    _single_events: Option<bool>,
11453    _show_hidden_invitations: Option<bool>,
11454    _show_deleted: Option<bool>,
11455    _shared_extended_property: Vec<String>,
11456    _q: Option<String>,
11457    _private_extended_property: Vec<String>,
11458    _page_token: Option<String>,
11459    _order_by: Option<String>,
11460    _max_results: Option<i32>,
11461    _max_attendees: Option<i32>,
11462    _i_cal_uid: Option<String>,
11463    _event_types: Vec<String>,
11464    _always_include_email: Option<bool>,
11465    _delegate: Option<&'a mut dyn common::Delegate>,
11466    _additional_params: HashMap<String, String>,
11467    _scopes: BTreeSet<String>,
11468}
11469
11470impl<'a, C> common::CallBuilder for EventListCall<'a, C> {}
11471
11472impl<'a, C> EventListCall<'a, C>
11473where
11474    C: common::Connector,
11475{
11476    /// Perform the operation you have build so far.
11477    pub async fn doit(mut self) -> common::Result<(common::Response, Events)> {
11478        use std::borrow::Cow;
11479        use std::io::{Read, Seek};
11480
11481        use common::{url::Params, ToParts};
11482        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
11483
11484        let mut dd = common::DefaultDelegate;
11485        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
11486        dlg.begin(common::MethodInfo {
11487            id: "calendar.events.list",
11488            http_method: hyper::Method::GET,
11489        });
11490
11491        for &field in [
11492            "alt",
11493            "calendarId",
11494            "updatedMin",
11495            "timeZone",
11496            "timeMin",
11497            "timeMax",
11498            "syncToken",
11499            "singleEvents",
11500            "showHiddenInvitations",
11501            "showDeleted",
11502            "sharedExtendedProperty",
11503            "q",
11504            "privateExtendedProperty",
11505            "pageToken",
11506            "orderBy",
11507            "maxResults",
11508            "maxAttendees",
11509            "iCalUID",
11510            "eventTypes",
11511            "alwaysIncludeEmail",
11512        ]
11513        .iter()
11514        {
11515            if self._additional_params.contains_key(field) {
11516                dlg.finished(false);
11517                return Err(common::Error::FieldClash(field));
11518            }
11519        }
11520
11521        let mut params = Params::with_capacity(21 + self._additional_params.len());
11522        params.push("calendarId", self._calendar_id);
11523        if let Some(value) = self._updated_min.as_ref() {
11524            params.push("updatedMin", common::serde::datetime_to_string(&value));
11525        }
11526        if let Some(value) = self._time_zone.as_ref() {
11527            params.push("timeZone", value);
11528        }
11529        if let Some(value) = self._time_min.as_ref() {
11530            params.push("timeMin", common::serde::datetime_to_string(&value));
11531        }
11532        if let Some(value) = self._time_max.as_ref() {
11533            params.push("timeMax", common::serde::datetime_to_string(&value));
11534        }
11535        if let Some(value) = self._sync_token.as_ref() {
11536            params.push("syncToken", value);
11537        }
11538        if let Some(value) = self._single_events.as_ref() {
11539            params.push("singleEvents", value.to_string());
11540        }
11541        if let Some(value) = self._show_hidden_invitations.as_ref() {
11542            params.push("showHiddenInvitations", value.to_string());
11543        }
11544        if let Some(value) = self._show_deleted.as_ref() {
11545            params.push("showDeleted", value.to_string());
11546        }
11547        if !self._shared_extended_property.is_empty() {
11548            for f in self._shared_extended_property.iter() {
11549                params.push("sharedExtendedProperty", f);
11550            }
11551        }
11552        if let Some(value) = self._q.as_ref() {
11553            params.push("q", value);
11554        }
11555        if !self._private_extended_property.is_empty() {
11556            for f in self._private_extended_property.iter() {
11557                params.push("privateExtendedProperty", f);
11558            }
11559        }
11560        if let Some(value) = self._page_token.as_ref() {
11561            params.push("pageToken", value);
11562        }
11563        if let Some(value) = self._order_by.as_ref() {
11564            params.push("orderBy", value);
11565        }
11566        if let Some(value) = self._max_results.as_ref() {
11567            params.push("maxResults", value.to_string());
11568        }
11569        if let Some(value) = self._max_attendees.as_ref() {
11570            params.push("maxAttendees", value.to_string());
11571        }
11572        if let Some(value) = self._i_cal_uid.as_ref() {
11573            params.push("iCalUID", value);
11574        }
11575        if !self._event_types.is_empty() {
11576            for f in self._event_types.iter() {
11577                params.push("eventTypes", f);
11578            }
11579        }
11580        if let Some(value) = self._always_include_email.as_ref() {
11581            params.push("alwaysIncludeEmail", value.to_string());
11582        }
11583
11584        params.extend(self._additional_params.iter());
11585
11586        params.push("alt", "json");
11587        let mut url = self.hub._base_url.clone() + "calendars/{calendarId}/events";
11588        if self._scopes.is_empty() {
11589            self._scopes
11590                .insert(Scope::EventReadonly.as_ref().to_string());
11591        }
11592
11593        #[allow(clippy::single_element_loop)]
11594        for &(find_this, param_name) in [("{calendarId}", "calendarId")].iter() {
11595            url = params.uri_replacement(url, param_name, find_this, false);
11596        }
11597        {
11598            let to_remove = ["calendarId"];
11599            params.remove_params(&to_remove);
11600        }
11601
11602        let url = params.parse_with_url(&url);
11603
11604        loop {
11605            let token = match self
11606                .hub
11607                .auth
11608                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
11609                .await
11610            {
11611                Ok(token) => token,
11612                Err(e) => match dlg.token(e) {
11613                    Ok(token) => token,
11614                    Err(e) => {
11615                        dlg.finished(false);
11616                        return Err(common::Error::MissingToken(e));
11617                    }
11618                },
11619            };
11620            let mut req_result = {
11621                let client = &self.hub.client;
11622                dlg.pre_request();
11623                let mut req_builder = hyper::Request::builder()
11624                    .method(hyper::Method::GET)
11625                    .uri(url.as_str())
11626                    .header(USER_AGENT, self.hub._user_agent.clone());
11627
11628                if let Some(token) = token.as_ref() {
11629                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
11630                }
11631
11632                let request = req_builder
11633                    .header(CONTENT_LENGTH, 0_u64)
11634                    .body(common::to_body::<String>(None));
11635
11636                client.request(request.unwrap()).await
11637            };
11638
11639            match req_result {
11640                Err(err) => {
11641                    if let common::Retry::After(d) = dlg.http_error(&err) {
11642                        sleep(d).await;
11643                        continue;
11644                    }
11645                    dlg.finished(false);
11646                    return Err(common::Error::HttpError(err));
11647                }
11648                Ok(res) => {
11649                    let (mut parts, body) = res.into_parts();
11650                    let mut body = common::Body::new(body);
11651                    if !parts.status.is_success() {
11652                        let bytes = common::to_bytes(body).await.unwrap_or_default();
11653                        let error = serde_json::from_str(&common::to_string(&bytes));
11654                        let response = common::to_response(parts, bytes.into());
11655
11656                        if let common::Retry::After(d) =
11657                            dlg.http_failure(&response, error.as_ref().ok())
11658                        {
11659                            sleep(d).await;
11660                            continue;
11661                        }
11662
11663                        dlg.finished(false);
11664
11665                        return Err(match error {
11666                            Ok(value) => common::Error::BadRequest(value),
11667                            _ => common::Error::Failure(response),
11668                        });
11669                    }
11670                    let response = {
11671                        let bytes = common::to_bytes(body).await.unwrap_or_default();
11672                        let encoded = common::to_string(&bytes);
11673                        match serde_json::from_str(&encoded) {
11674                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
11675                            Err(error) => {
11676                                dlg.response_json_decode_error(&encoded, &error);
11677                                return Err(common::Error::JsonDecodeError(
11678                                    encoded.to_string(),
11679                                    error,
11680                                ));
11681                            }
11682                        }
11683                    };
11684
11685                    dlg.finished(true);
11686                    return Ok(response);
11687                }
11688            }
11689        }
11690    }
11691
11692    /// 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.
11693    ///
11694    /// Sets the *calendar id* path property to the given value.
11695    ///
11696    /// Even though the property as already been set when instantiating this call,
11697    /// we provide this method for API completeness.
11698    pub fn calendar_id(mut self, new_value: &str) -> EventListCall<'a, C> {
11699        self._calendar_id = new_value.to_string();
11700        self
11701    }
11702    /// 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.
11703    ///
11704    /// Sets the *updated min* query property to the given value.
11705    pub fn updated_min(
11706        mut self,
11707        new_value: chrono::DateTime<chrono::offset::Utc>,
11708    ) -> EventListCall<'a, C> {
11709        self._updated_min = Some(new_value);
11710        self
11711    }
11712    /// Time zone used in the response. Optional. The default is the time zone of the calendar.
11713    ///
11714    /// Sets the *time zone* query property to the given value.
11715    pub fn time_zone(mut self, new_value: &str) -> EventListCall<'a, C> {
11716        self._time_zone = Some(new_value.to_string());
11717        self
11718    }
11719    /// 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.
11720    ///
11721    /// Sets the *time min* query property to the given value.
11722    pub fn time_min(
11723        mut self,
11724        new_value: chrono::DateTime<chrono::offset::Utc>,
11725    ) -> EventListCall<'a, C> {
11726        self._time_min = Some(new_value);
11727        self
11728    }
11729    /// 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.
11730    ///
11731    /// Sets the *time max* query property to the given value.
11732    pub fn time_max(
11733        mut self,
11734        new_value: chrono::DateTime<chrono::offset::Utc>,
11735    ) -> EventListCall<'a, C> {
11736        self._time_max = Some(new_value);
11737        self
11738    }
11739    /// 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.
11740    /// There are several query parameters that cannot be specified together with nextSyncToken to ensure consistency of the client state.
11741    ///
11742    /// These are:
11743    /// - iCalUID
11744    /// - orderBy
11745    /// - privateExtendedProperty
11746    /// - q
11747    /// - sharedExtendedProperty
11748    /// - timeMin
11749    /// - timeMax
11750    /// - updatedMin All other query parameters should be the same as for the initial synchronization to avoid undefined behavior. 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.
11751    /// Learn more about incremental synchronization.
11752    /// Optional. The default is to return all entries.
11753    ///
11754    /// Sets the *sync token* query property to the given value.
11755    pub fn sync_token(mut self, new_value: &str) -> EventListCall<'a, C> {
11756        self._sync_token = Some(new_value.to_string());
11757        self
11758    }
11759    /// 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.
11760    ///
11761    /// Sets the *single events* query property to the given value.
11762    pub fn single_events(mut self, new_value: bool) -> EventListCall<'a, C> {
11763        self._single_events = Some(new_value);
11764        self
11765    }
11766    /// Whether to include hidden invitations in the result. Optional. The default is False.
11767    ///
11768    /// Sets the *show hidden invitations* query property to the given value.
11769    pub fn show_hidden_invitations(mut self, new_value: bool) -> EventListCall<'a, C> {
11770        self._show_hidden_invitations = Some(new_value);
11771        self
11772    }
11773    /// 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.
11774    ///
11775    /// Sets the *show deleted* query property to the given value.
11776    pub fn show_deleted(mut self, new_value: bool) -> EventListCall<'a, C> {
11777        self._show_deleted = Some(new_value);
11778        self
11779    }
11780    /// 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.
11781    ///
11782    /// Append the given value to the *shared extended property* query property.
11783    /// Each appended value will retain its original ordering and be '/'-separated in the URL's parameters.
11784    pub fn add_shared_extended_property(mut self, new_value: &str) -> EventListCall<'a, C> {
11785        self._shared_extended_property.push(new_value.to_string());
11786        self
11787    }
11788    /// Free text search terms to find events that match these terms in the following fields:
11789    ///
11790    /// - summary
11791    /// - description
11792    /// - location
11793    /// - attendee's displayName
11794    /// - attendee's email
11795    /// - organizer's displayName
11796    /// - organizer's email
11797    /// - workingLocationProperties.officeLocation.buildingId
11798    /// - workingLocationProperties.officeLocation.deskId
11799    /// - workingLocationProperties.officeLocation.label
11800    /// - workingLocationProperties.customLocation.label
11801    /// These search terms also match predefined keywords against all display title translations of working location, out-of-office, and focus-time events. For example, searching for "Office" or "Bureau" returns working location events of type officeLocation, whereas searching for "Out of office" or "Abwesend" returns out-of-office events. Optional.
11802    ///
11803    /// Sets the *q* query property to the given value.
11804    pub fn q(mut self, new_value: &str) -> EventListCall<'a, C> {
11805        self._q = Some(new_value.to_string());
11806        self
11807    }
11808    /// 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.
11809    ///
11810    /// Append the given value to the *private extended property* query property.
11811    /// Each appended value will retain its original ordering and be '/'-separated in the URL's parameters.
11812    pub fn add_private_extended_property(mut self, new_value: &str) -> EventListCall<'a, C> {
11813        self._private_extended_property.push(new_value.to_string());
11814        self
11815    }
11816    /// Token specifying which result page to return. Optional.
11817    ///
11818    /// Sets the *page token* query property to the given value.
11819    pub fn page_token(mut self, new_value: &str) -> EventListCall<'a, C> {
11820        self._page_token = Some(new_value.to_string());
11821        self
11822    }
11823    /// The order of the events returned in the result. Optional. The default is an unspecified, stable order.
11824    ///
11825    /// Sets the *order by* query property to the given value.
11826    pub fn order_by(mut self, new_value: &str) -> EventListCall<'a, C> {
11827        self._order_by = Some(new_value.to_string());
11828        self
11829    }
11830    /// 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.
11831    ///
11832    /// Sets the *max results* query property to the given value.
11833    pub fn max_results(mut self, new_value: i32) -> EventListCall<'a, C> {
11834        self._max_results = Some(new_value);
11835        self
11836    }
11837    /// 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.
11838    ///
11839    /// Sets the *max attendees* query property to the given value.
11840    pub fn max_attendees(mut self, new_value: i32) -> EventListCall<'a, C> {
11841        self._max_attendees = Some(new_value);
11842        self
11843    }
11844    /// Specifies an event ID in the iCalendar format to be provided in the response. Optional. Use this if you want to search for an event by its iCalendar ID.
11845    ///
11846    /// Sets the *i cal uid* query property to the given value.
11847    pub fn i_cal_uid(mut self, new_value: &str) -> EventListCall<'a, C> {
11848        self._i_cal_uid = Some(new_value.to_string());
11849        self
11850    }
11851    /// Event types to return. Optional. This parameter can be repeated multiple times to return events of different types. If unset, returns all event types.
11852    ///
11853    /// Append the given value to the *event types* query property.
11854    /// Each appended value will retain its original ordering and be '/'-separated in the URL's parameters.
11855    pub fn add_event_types(mut self, new_value: &str) -> EventListCall<'a, C> {
11856        self._event_types.push(new_value.to_string());
11857        self
11858    }
11859    /// Deprecated and ignored.
11860    ///
11861    /// Sets the *always include email* query property to the given value.
11862    pub fn always_include_email(mut self, new_value: bool) -> EventListCall<'a, C> {
11863        self._always_include_email = Some(new_value);
11864        self
11865    }
11866    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
11867    /// while executing the actual API request.
11868    ///
11869    /// ````text
11870    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
11871    /// ````
11872    ///
11873    /// Sets the *delegate* property to the given value.
11874    pub fn delegate(mut self, new_value: &'a mut dyn common::Delegate) -> EventListCall<'a, C> {
11875        self._delegate = Some(new_value);
11876        self
11877    }
11878
11879    /// Set any additional parameter of the query string used in the request.
11880    /// It should be used to set parameters which are not yet available through their own
11881    /// setters.
11882    ///
11883    /// Please note that this method must not be used to set any of the known parameters
11884    /// which have their own setter method. If done anyway, the request will fail.
11885    ///
11886    /// # Additional Parameters
11887    ///
11888    /// * *alt* (query-string) - Data format for the response.
11889    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
11890    /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
11891    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
11892    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
11893    /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
11894    /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
11895    pub fn param<T>(mut self, name: T, value: T) -> EventListCall<'a, C>
11896    where
11897        T: AsRef<str>,
11898    {
11899        self._additional_params
11900            .insert(name.as_ref().to_string(), value.as_ref().to_string());
11901        self
11902    }
11903
11904    /// Identifies the authorization scope for the method you are building.
11905    ///
11906    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
11907    /// [`Scope::EventReadonly`].
11908    ///
11909    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
11910    /// tokens for more than one scope.
11911    ///
11912    /// Usually there is more than one suitable scope to authorize an operation, some of which may
11913    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
11914    /// sufficient, a read-write scope will do as well.
11915    pub fn add_scope<St>(mut self, scope: St) -> EventListCall<'a, C>
11916    where
11917        St: AsRef<str>,
11918    {
11919        self._scopes.insert(String::from(scope.as_ref()));
11920        self
11921    }
11922    /// Identifies the authorization scope(s) for the method you are building.
11923    ///
11924    /// See [`Self::add_scope()`] for details.
11925    pub fn add_scopes<I, St>(mut self, scopes: I) -> EventListCall<'a, C>
11926    where
11927        I: IntoIterator<Item = St>,
11928        St: AsRef<str>,
11929    {
11930        self._scopes
11931            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
11932        self
11933    }
11934
11935    /// Removes all scopes, and no default scope will be used either.
11936    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
11937    /// for details).
11938    pub fn clear_scopes(mut self) -> EventListCall<'a, C> {
11939        self._scopes.clear();
11940        self
11941    }
11942}
11943
11944/// Moves an event to another calendar, i.e. changes an event's organizer. Note that only default events can be moved; outOfOffice, focusTime, workingLocation and fromGmail events cannot be moved.
11945///
11946/// A builder for the *move* method supported by a *event* resource.
11947/// It is not used directly, but through a [`EventMethods`] instance.
11948///
11949/// # Example
11950///
11951/// Instantiate a resource method builder
11952///
11953/// ```test_harness,no_run
11954/// # extern crate hyper;
11955/// # extern crate hyper_rustls;
11956/// # extern crate google_calendar3 as calendar3;
11957/// # async fn dox() {
11958/// # use calendar3::{CalendarHub, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
11959///
11960/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
11961/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
11962/// #     secret,
11963/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
11964/// # ).build().await.unwrap();
11965///
11966/// # let client = hyper_util::client::legacy::Client::builder(
11967/// #     hyper_util::rt::TokioExecutor::new()
11968/// # )
11969/// # .build(
11970/// #     hyper_rustls::HttpsConnectorBuilder::new()
11971/// #         .with_native_roots()
11972/// #         .unwrap()
11973/// #         .https_or_http()
11974/// #         .enable_http1()
11975/// #         .build()
11976/// # );
11977/// # let mut hub = CalendarHub::new(client, auth);
11978/// // You can configure optional parameters by calling the respective setters at will, and
11979/// // execute the final call using `doit()`.
11980/// // Values shown here are possibly random and not representative !
11981/// let result = hub.events().move_("calendarId", "eventId", "destination")
11982///              .send_updates("erat")
11983///              .send_notifications(true)
11984///              .doit().await;
11985/// # }
11986/// ```
11987pub struct EventMoveCall<'a, C>
11988where
11989    C: 'a,
11990{
11991    hub: &'a CalendarHub<C>,
11992    _calendar_id: String,
11993    _event_id: String,
11994    _destination: String,
11995    _send_updates: Option<String>,
11996    _send_notifications: Option<bool>,
11997    _delegate: Option<&'a mut dyn common::Delegate>,
11998    _additional_params: HashMap<String, String>,
11999    _scopes: BTreeSet<String>,
12000}
12001
12002impl<'a, C> common::CallBuilder for EventMoveCall<'a, C> {}
12003
12004impl<'a, C> EventMoveCall<'a, C>
12005where
12006    C: common::Connector,
12007{
12008    /// Perform the operation you have build so far.
12009    pub async fn doit(mut self) -> common::Result<(common::Response, Event)> {
12010        use std::borrow::Cow;
12011        use std::io::{Read, Seek};
12012
12013        use common::{url::Params, ToParts};
12014        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
12015
12016        let mut dd = common::DefaultDelegate;
12017        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
12018        dlg.begin(common::MethodInfo {
12019            id: "calendar.events.move",
12020            http_method: hyper::Method::POST,
12021        });
12022
12023        for &field in [
12024            "alt",
12025            "calendarId",
12026            "eventId",
12027            "destination",
12028            "sendUpdates",
12029            "sendNotifications",
12030        ]
12031        .iter()
12032        {
12033            if self._additional_params.contains_key(field) {
12034                dlg.finished(false);
12035                return Err(common::Error::FieldClash(field));
12036            }
12037        }
12038
12039        let mut params = Params::with_capacity(7 + self._additional_params.len());
12040        params.push("calendarId", self._calendar_id);
12041        params.push("eventId", self._event_id);
12042        params.push("destination", self._destination);
12043        if let Some(value) = self._send_updates.as_ref() {
12044            params.push("sendUpdates", value);
12045        }
12046        if let Some(value) = self._send_notifications.as_ref() {
12047            params.push("sendNotifications", value.to_string());
12048        }
12049
12050        params.extend(self._additional_params.iter());
12051
12052        params.push("alt", "json");
12053        let mut url = self.hub._base_url.clone() + "calendars/{calendarId}/events/{eventId}/move";
12054        if self._scopes.is_empty() {
12055            self._scopes.insert(Scope::Full.as_ref().to_string());
12056        }
12057
12058        #[allow(clippy::single_element_loop)]
12059        for &(find_this, param_name) in
12060            [("{calendarId}", "calendarId"), ("{eventId}", "eventId")].iter()
12061        {
12062            url = params.uri_replacement(url, param_name, find_this, false);
12063        }
12064        {
12065            let to_remove = ["eventId", "calendarId"];
12066            params.remove_params(&to_remove);
12067        }
12068
12069        let url = params.parse_with_url(&url);
12070
12071        loop {
12072            let token = match self
12073                .hub
12074                .auth
12075                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
12076                .await
12077            {
12078                Ok(token) => token,
12079                Err(e) => match dlg.token(e) {
12080                    Ok(token) => token,
12081                    Err(e) => {
12082                        dlg.finished(false);
12083                        return Err(common::Error::MissingToken(e));
12084                    }
12085                },
12086            };
12087            let mut req_result = {
12088                let client = &self.hub.client;
12089                dlg.pre_request();
12090                let mut req_builder = hyper::Request::builder()
12091                    .method(hyper::Method::POST)
12092                    .uri(url.as_str())
12093                    .header(USER_AGENT, self.hub._user_agent.clone());
12094
12095                if let Some(token) = token.as_ref() {
12096                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
12097                }
12098
12099                let request = req_builder
12100                    .header(CONTENT_LENGTH, 0_u64)
12101                    .body(common::to_body::<String>(None));
12102
12103                client.request(request.unwrap()).await
12104            };
12105
12106            match req_result {
12107                Err(err) => {
12108                    if let common::Retry::After(d) = dlg.http_error(&err) {
12109                        sleep(d).await;
12110                        continue;
12111                    }
12112                    dlg.finished(false);
12113                    return Err(common::Error::HttpError(err));
12114                }
12115                Ok(res) => {
12116                    let (mut parts, body) = res.into_parts();
12117                    let mut body = common::Body::new(body);
12118                    if !parts.status.is_success() {
12119                        let bytes = common::to_bytes(body).await.unwrap_or_default();
12120                        let error = serde_json::from_str(&common::to_string(&bytes));
12121                        let response = common::to_response(parts, bytes.into());
12122
12123                        if let common::Retry::After(d) =
12124                            dlg.http_failure(&response, error.as_ref().ok())
12125                        {
12126                            sleep(d).await;
12127                            continue;
12128                        }
12129
12130                        dlg.finished(false);
12131
12132                        return Err(match error {
12133                            Ok(value) => common::Error::BadRequest(value),
12134                            _ => common::Error::Failure(response),
12135                        });
12136                    }
12137                    let response = {
12138                        let bytes = common::to_bytes(body).await.unwrap_or_default();
12139                        let encoded = common::to_string(&bytes);
12140                        match serde_json::from_str(&encoded) {
12141                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
12142                            Err(error) => {
12143                                dlg.response_json_decode_error(&encoded, &error);
12144                                return Err(common::Error::JsonDecodeError(
12145                                    encoded.to_string(),
12146                                    error,
12147                                ));
12148                            }
12149                        }
12150                    };
12151
12152                    dlg.finished(true);
12153                    return Ok(response);
12154                }
12155            }
12156        }
12157    }
12158
12159    /// Calendar identifier of the source calendar where the event currently is on.
12160    ///
12161    /// Sets the *calendar id* path property to the given value.
12162    ///
12163    /// Even though the property as already been set when instantiating this call,
12164    /// we provide this method for API completeness.
12165    pub fn calendar_id(mut self, new_value: &str) -> EventMoveCall<'a, C> {
12166        self._calendar_id = new_value.to_string();
12167        self
12168    }
12169    /// Event identifier.
12170    ///
12171    /// Sets the *event id* path property to the given value.
12172    ///
12173    /// Even though the property as already been set when instantiating this call,
12174    /// we provide this method for API completeness.
12175    pub fn event_id(mut self, new_value: &str) -> EventMoveCall<'a, C> {
12176        self._event_id = new_value.to_string();
12177        self
12178    }
12179    /// Calendar identifier of the target calendar where the event is to be moved to.
12180    ///
12181    /// Sets the *destination* query property to the given value.
12182    ///
12183    /// Even though the property as already been set when instantiating this call,
12184    /// we provide this method for API completeness.
12185    pub fn destination(mut self, new_value: &str) -> EventMoveCall<'a, C> {
12186        self._destination = new_value.to_string();
12187        self
12188    }
12189    /// Guests who should receive notifications about the change of the event's organizer.
12190    ///
12191    /// Sets the *send updates* query property to the given value.
12192    pub fn send_updates(mut self, new_value: &str) -> EventMoveCall<'a, C> {
12193        self._send_updates = Some(new_value.to_string());
12194        self
12195    }
12196    /// Deprecated. Please use sendUpdates instead.
12197    ///
12198    /// 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.
12199    ///
12200    /// Sets the *send notifications* query property to the given value.
12201    pub fn send_notifications(mut self, new_value: bool) -> EventMoveCall<'a, C> {
12202        self._send_notifications = Some(new_value);
12203        self
12204    }
12205    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
12206    /// while executing the actual API request.
12207    ///
12208    /// ````text
12209    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
12210    /// ````
12211    ///
12212    /// Sets the *delegate* property to the given value.
12213    pub fn delegate(mut self, new_value: &'a mut dyn common::Delegate) -> EventMoveCall<'a, C> {
12214        self._delegate = Some(new_value);
12215        self
12216    }
12217
12218    /// Set any additional parameter of the query string used in the request.
12219    /// It should be used to set parameters which are not yet available through their own
12220    /// setters.
12221    ///
12222    /// Please note that this method must not be used to set any of the known parameters
12223    /// which have their own setter method. If done anyway, the request will fail.
12224    ///
12225    /// # Additional Parameters
12226    ///
12227    /// * *alt* (query-string) - Data format for the response.
12228    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
12229    /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
12230    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
12231    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
12232    /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
12233    /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
12234    pub fn param<T>(mut self, name: T, value: T) -> EventMoveCall<'a, C>
12235    where
12236        T: AsRef<str>,
12237    {
12238        self._additional_params
12239            .insert(name.as_ref().to_string(), value.as_ref().to_string());
12240        self
12241    }
12242
12243    /// Identifies the authorization scope for the method you are building.
12244    ///
12245    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
12246    /// [`Scope::Full`].
12247    ///
12248    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
12249    /// tokens for more than one scope.
12250    ///
12251    /// Usually there is more than one suitable scope to authorize an operation, some of which may
12252    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
12253    /// sufficient, a read-write scope will do as well.
12254    pub fn add_scope<St>(mut self, scope: St) -> EventMoveCall<'a, C>
12255    where
12256        St: AsRef<str>,
12257    {
12258        self._scopes.insert(String::from(scope.as_ref()));
12259        self
12260    }
12261    /// Identifies the authorization scope(s) for the method you are building.
12262    ///
12263    /// See [`Self::add_scope()`] for details.
12264    pub fn add_scopes<I, St>(mut self, scopes: I) -> EventMoveCall<'a, C>
12265    where
12266        I: IntoIterator<Item = St>,
12267        St: AsRef<str>,
12268    {
12269        self._scopes
12270            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
12271        self
12272    }
12273
12274    /// Removes all scopes, and no default scope will be used either.
12275    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
12276    /// for details).
12277    pub fn clear_scopes(mut self) -> EventMoveCall<'a, C> {
12278        self._scopes.clear();
12279        self
12280    }
12281}
12282
12283/// Updates an event. This method supports patch semantics.
12284///
12285/// A builder for the *patch* method supported by a *event* resource.
12286/// It is not used directly, but through a [`EventMethods`] instance.
12287///
12288/// # Example
12289///
12290/// Instantiate a resource method builder
12291///
12292/// ```test_harness,no_run
12293/// # extern crate hyper;
12294/// # extern crate hyper_rustls;
12295/// # extern crate google_calendar3 as calendar3;
12296/// use calendar3::api::Event;
12297/// # async fn dox() {
12298/// # use calendar3::{CalendarHub, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
12299///
12300/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
12301/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
12302/// #     secret,
12303/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
12304/// # ).build().await.unwrap();
12305///
12306/// # let client = hyper_util::client::legacy::Client::builder(
12307/// #     hyper_util::rt::TokioExecutor::new()
12308/// # )
12309/// # .build(
12310/// #     hyper_rustls::HttpsConnectorBuilder::new()
12311/// #         .with_native_roots()
12312/// #         .unwrap()
12313/// #         .https_or_http()
12314/// #         .enable_http1()
12315/// #         .build()
12316/// # );
12317/// # let mut hub = CalendarHub::new(client, auth);
12318/// // As the method needs a request, you would usually fill it with the desired information
12319/// // into the respective structure. Some of the parts shown here might not be applicable !
12320/// // Values shown here are possibly random and not representative !
12321/// let mut req = Event::default();
12322///
12323/// // You can configure optional parameters by calling the respective setters at will, and
12324/// // execute the final call using `doit()`.
12325/// // Values shown here are possibly random and not representative !
12326/// let result = hub.events().patch(req, "calendarId", "eventId")
12327///              .supports_attachments(true)
12328///              .send_updates("consetetur")
12329///              .send_notifications(false)
12330///              .max_attendees(-32)
12331///              .conference_data_version(-25)
12332///              .always_include_email(false)
12333///              .doit().await;
12334/// # }
12335/// ```
12336pub struct EventPatchCall<'a, C>
12337where
12338    C: 'a,
12339{
12340    hub: &'a CalendarHub<C>,
12341    _request: Event,
12342    _calendar_id: String,
12343    _event_id: String,
12344    _supports_attachments: Option<bool>,
12345    _send_updates: Option<String>,
12346    _send_notifications: Option<bool>,
12347    _max_attendees: Option<i32>,
12348    _conference_data_version: Option<i32>,
12349    _always_include_email: Option<bool>,
12350    _delegate: Option<&'a mut dyn common::Delegate>,
12351    _additional_params: HashMap<String, String>,
12352    _scopes: BTreeSet<String>,
12353}
12354
12355impl<'a, C> common::CallBuilder for EventPatchCall<'a, C> {}
12356
12357impl<'a, C> EventPatchCall<'a, C>
12358where
12359    C: common::Connector,
12360{
12361    /// Perform the operation you have build so far.
12362    pub async fn doit(mut self) -> common::Result<(common::Response, Event)> {
12363        use std::borrow::Cow;
12364        use std::io::{Read, Seek};
12365
12366        use common::{url::Params, ToParts};
12367        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
12368
12369        let mut dd = common::DefaultDelegate;
12370        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
12371        dlg.begin(common::MethodInfo {
12372            id: "calendar.events.patch",
12373            http_method: hyper::Method::PATCH,
12374        });
12375
12376        for &field in [
12377            "alt",
12378            "calendarId",
12379            "eventId",
12380            "supportsAttachments",
12381            "sendUpdates",
12382            "sendNotifications",
12383            "maxAttendees",
12384            "conferenceDataVersion",
12385            "alwaysIncludeEmail",
12386        ]
12387        .iter()
12388        {
12389            if self._additional_params.contains_key(field) {
12390                dlg.finished(false);
12391                return Err(common::Error::FieldClash(field));
12392            }
12393        }
12394
12395        let mut params = Params::with_capacity(11 + self._additional_params.len());
12396        params.push("calendarId", self._calendar_id);
12397        params.push("eventId", self._event_id);
12398        if let Some(value) = self._supports_attachments.as_ref() {
12399            params.push("supportsAttachments", value.to_string());
12400        }
12401        if let Some(value) = self._send_updates.as_ref() {
12402            params.push("sendUpdates", value);
12403        }
12404        if let Some(value) = self._send_notifications.as_ref() {
12405            params.push("sendNotifications", value.to_string());
12406        }
12407        if let Some(value) = self._max_attendees.as_ref() {
12408            params.push("maxAttendees", value.to_string());
12409        }
12410        if let Some(value) = self._conference_data_version.as_ref() {
12411            params.push("conferenceDataVersion", value.to_string());
12412        }
12413        if let Some(value) = self._always_include_email.as_ref() {
12414            params.push("alwaysIncludeEmail", value.to_string());
12415        }
12416
12417        params.extend(self._additional_params.iter());
12418
12419        params.push("alt", "json");
12420        let mut url = self.hub._base_url.clone() + "calendars/{calendarId}/events/{eventId}";
12421        if self._scopes.is_empty() {
12422            self._scopes.insert(Scope::Full.as_ref().to_string());
12423        }
12424
12425        #[allow(clippy::single_element_loop)]
12426        for &(find_this, param_name) in
12427            [("{calendarId}", "calendarId"), ("{eventId}", "eventId")].iter()
12428        {
12429            url = params.uri_replacement(url, param_name, find_this, false);
12430        }
12431        {
12432            let to_remove = ["eventId", "calendarId"];
12433            params.remove_params(&to_remove);
12434        }
12435
12436        let url = params.parse_with_url(&url);
12437
12438        let mut json_mime_type = mime::APPLICATION_JSON;
12439        let mut request_value_reader = {
12440            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
12441            common::remove_json_null_values(&mut value);
12442            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
12443            serde_json::to_writer(&mut dst, &value).unwrap();
12444            dst
12445        };
12446        let request_size = request_value_reader
12447            .seek(std::io::SeekFrom::End(0))
12448            .unwrap();
12449        request_value_reader
12450            .seek(std::io::SeekFrom::Start(0))
12451            .unwrap();
12452
12453        loop {
12454            let token = match self
12455                .hub
12456                .auth
12457                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
12458                .await
12459            {
12460                Ok(token) => token,
12461                Err(e) => match dlg.token(e) {
12462                    Ok(token) => token,
12463                    Err(e) => {
12464                        dlg.finished(false);
12465                        return Err(common::Error::MissingToken(e));
12466                    }
12467                },
12468            };
12469            request_value_reader
12470                .seek(std::io::SeekFrom::Start(0))
12471                .unwrap();
12472            let mut req_result = {
12473                let client = &self.hub.client;
12474                dlg.pre_request();
12475                let mut req_builder = hyper::Request::builder()
12476                    .method(hyper::Method::PATCH)
12477                    .uri(url.as_str())
12478                    .header(USER_AGENT, self.hub._user_agent.clone());
12479
12480                if let Some(token) = token.as_ref() {
12481                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
12482                }
12483
12484                let request = req_builder
12485                    .header(CONTENT_TYPE, json_mime_type.to_string())
12486                    .header(CONTENT_LENGTH, request_size as u64)
12487                    .body(common::to_body(
12488                        request_value_reader.get_ref().clone().into(),
12489                    ));
12490
12491                client.request(request.unwrap()).await
12492            };
12493
12494            match req_result {
12495                Err(err) => {
12496                    if let common::Retry::After(d) = dlg.http_error(&err) {
12497                        sleep(d).await;
12498                        continue;
12499                    }
12500                    dlg.finished(false);
12501                    return Err(common::Error::HttpError(err));
12502                }
12503                Ok(res) => {
12504                    let (mut parts, body) = res.into_parts();
12505                    let mut body = common::Body::new(body);
12506                    if !parts.status.is_success() {
12507                        let bytes = common::to_bytes(body).await.unwrap_or_default();
12508                        let error = serde_json::from_str(&common::to_string(&bytes));
12509                        let response = common::to_response(parts, bytes.into());
12510
12511                        if let common::Retry::After(d) =
12512                            dlg.http_failure(&response, error.as_ref().ok())
12513                        {
12514                            sleep(d).await;
12515                            continue;
12516                        }
12517
12518                        dlg.finished(false);
12519
12520                        return Err(match error {
12521                            Ok(value) => common::Error::BadRequest(value),
12522                            _ => common::Error::Failure(response),
12523                        });
12524                    }
12525                    let response = {
12526                        let bytes = common::to_bytes(body).await.unwrap_or_default();
12527                        let encoded = common::to_string(&bytes);
12528                        match serde_json::from_str(&encoded) {
12529                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
12530                            Err(error) => {
12531                                dlg.response_json_decode_error(&encoded, &error);
12532                                return Err(common::Error::JsonDecodeError(
12533                                    encoded.to_string(),
12534                                    error,
12535                                ));
12536                            }
12537                        }
12538                    };
12539
12540                    dlg.finished(true);
12541                    return Ok(response);
12542                }
12543            }
12544        }
12545    }
12546
12547    ///
12548    /// Sets the *request* property to the given value.
12549    ///
12550    /// Even though the property as already been set when instantiating this call,
12551    /// we provide this method for API completeness.
12552    pub fn request(mut self, new_value: Event) -> EventPatchCall<'a, C> {
12553        self._request = new_value;
12554        self
12555    }
12556    /// 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.
12557    ///
12558    /// Sets the *calendar id* path property to the given value.
12559    ///
12560    /// Even though the property as already been set when instantiating this call,
12561    /// we provide this method for API completeness.
12562    pub fn calendar_id(mut self, new_value: &str) -> EventPatchCall<'a, C> {
12563        self._calendar_id = new_value.to_string();
12564        self
12565    }
12566    /// Event identifier.
12567    ///
12568    /// Sets the *event id* path property to the given value.
12569    ///
12570    /// Even though the property as already been set when instantiating this call,
12571    /// we provide this method for API completeness.
12572    pub fn event_id(mut self, new_value: &str) -> EventPatchCall<'a, C> {
12573        self._event_id = new_value.to_string();
12574        self
12575    }
12576    /// Whether API client performing operation supports event attachments. Optional. The default is False.
12577    ///
12578    /// Sets the *supports attachments* query property to the given value.
12579    pub fn supports_attachments(mut self, new_value: bool) -> EventPatchCall<'a, C> {
12580        self._supports_attachments = Some(new_value);
12581        self
12582    }
12583    /// Guests who should receive notifications about the event update (for example, title changes, etc.).
12584    ///
12585    /// Sets the *send updates* query property to the given value.
12586    pub fn send_updates(mut self, new_value: &str) -> EventPatchCall<'a, C> {
12587        self._send_updates = Some(new_value.to_string());
12588        self
12589    }
12590    /// Deprecated. Please use sendUpdates instead.
12591    ///
12592    /// 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.
12593    ///
12594    /// Sets the *send notifications* query property to the given value.
12595    pub fn send_notifications(mut self, new_value: bool) -> EventPatchCall<'a, C> {
12596        self._send_notifications = Some(new_value);
12597        self
12598    }
12599    /// 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.
12600    ///
12601    /// Sets the *max attendees* query property to the given value.
12602    pub fn max_attendees(mut self, new_value: i32) -> EventPatchCall<'a, C> {
12603        self._max_attendees = Some(new_value);
12604        self
12605    }
12606    /// 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.
12607    ///
12608    /// Sets the *conference data version* query property to the given value.
12609    pub fn conference_data_version(mut self, new_value: i32) -> EventPatchCall<'a, C> {
12610        self._conference_data_version = Some(new_value);
12611        self
12612    }
12613    /// 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).
12614    ///
12615    /// Sets the *always include email* query property to the given value.
12616    pub fn always_include_email(mut self, new_value: bool) -> EventPatchCall<'a, C> {
12617        self._always_include_email = Some(new_value);
12618        self
12619    }
12620    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
12621    /// while executing the actual API request.
12622    ///
12623    /// ````text
12624    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
12625    /// ````
12626    ///
12627    /// Sets the *delegate* property to the given value.
12628    pub fn delegate(mut self, new_value: &'a mut dyn common::Delegate) -> EventPatchCall<'a, C> {
12629        self._delegate = Some(new_value);
12630        self
12631    }
12632
12633    /// Set any additional parameter of the query string used in the request.
12634    /// It should be used to set parameters which are not yet available through their own
12635    /// setters.
12636    ///
12637    /// Please note that this method must not be used to set any of the known parameters
12638    /// which have their own setter method. If done anyway, the request will fail.
12639    ///
12640    /// # Additional Parameters
12641    ///
12642    /// * *alt* (query-string) - Data format for the response.
12643    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
12644    /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
12645    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
12646    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
12647    /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
12648    /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
12649    pub fn param<T>(mut self, name: T, value: T) -> EventPatchCall<'a, C>
12650    where
12651        T: AsRef<str>,
12652    {
12653        self._additional_params
12654            .insert(name.as_ref().to_string(), value.as_ref().to_string());
12655        self
12656    }
12657
12658    /// Identifies the authorization scope for the method you are building.
12659    ///
12660    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
12661    /// [`Scope::Full`].
12662    ///
12663    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
12664    /// tokens for more than one scope.
12665    ///
12666    /// Usually there is more than one suitable scope to authorize an operation, some of which may
12667    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
12668    /// sufficient, a read-write scope will do as well.
12669    pub fn add_scope<St>(mut self, scope: St) -> EventPatchCall<'a, C>
12670    where
12671        St: AsRef<str>,
12672    {
12673        self._scopes.insert(String::from(scope.as_ref()));
12674        self
12675    }
12676    /// Identifies the authorization scope(s) for the method you are building.
12677    ///
12678    /// See [`Self::add_scope()`] for details.
12679    pub fn add_scopes<I, St>(mut self, scopes: I) -> EventPatchCall<'a, C>
12680    where
12681        I: IntoIterator<Item = St>,
12682        St: AsRef<str>,
12683    {
12684        self._scopes
12685            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
12686        self
12687    }
12688
12689    /// Removes all scopes, and no default scope will be used either.
12690    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
12691    /// for details).
12692    pub fn clear_scopes(mut self) -> EventPatchCall<'a, C> {
12693        self._scopes.clear();
12694        self
12695    }
12696}
12697
12698/// Creates an event based on a simple text string.
12699///
12700/// A builder for the *quickAdd* method supported by a *event* resource.
12701/// It is not used directly, but through a [`EventMethods`] instance.
12702///
12703/// # Example
12704///
12705/// Instantiate a resource method builder
12706///
12707/// ```test_harness,no_run
12708/// # extern crate hyper;
12709/// # extern crate hyper_rustls;
12710/// # extern crate google_calendar3 as calendar3;
12711/// # async fn dox() {
12712/// # use calendar3::{CalendarHub, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
12713///
12714/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
12715/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
12716/// #     secret,
12717/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
12718/// # ).build().await.unwrap();
12719///
12720/// # let client = hyper_util::client::legacy::Client::builder(
12721/// #     hyper_util::rt::TokioExecutor::new()
12722/// # )
12723/// # .build(
12724/// #     hyper_rustls::HttpsConnectorBuilder::new()
12725/// #         .with_native_roots()
12726/// #         .unwrap()
12727/// #         .https_or_http()
12728/// #         .enable_http1()
12729/// #         .build()
12730/// # );
12731/// # let mut hub = CalendarHub::new(client, auth);
12732/// // You can configure optional parameters by calling the respective setters at will, and
12733/// // execute the final call using `doit()`.
12734/// // Values shown here are possibly random and not representative !
12735/// let result = hub.events().quick_add("calendarId", "text")
12736///              .send_updates("gubergren")
12737///              .send_notifications(true)
12738///              .doit().await;
12739/// # }
12740/// ```
12741pub struct EventQuickAddCall<'a, C>
12742where
12743    C: 'a,
12744{
12745    hub: &'a CalendarHub<C>,
12746    _calendar_id: String,
12747    _text: String,
12748    _send_updates: Option<String>,
12749    _send_notifications: Option<bool>,
12750    _delegate: Option<&'a mut dyn common::Delegate>,
12751    _additional_params: HashMap<String, String>,
12752    _scopes: BTreeSet<String>,
12753}
12754
12755impl<'a, C> common::CallBuilder for EventQuickAddCall<'a, C> {}
12756
12757impl<'a, C> EventQuickAddCall<'a, C>
12758where
12759    C: common::Connector,
12760{
12761    /// Perform the operation you have build so far.
12762    pub async fn doit(mut self) -> common::Result<(common::Response, Event)> {
12763        use std::borrow::Cow;
12764        use std::io::{Read, Seek};
12765
12766        use common::{url::Params, ToParts};
12767        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
12768
12769        let mut dd = common::DefaultDelegate;
12770        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
12771        dlg.begin(common::MethodInfo {
12772            id: "calendar.events.quickAdd",
12773            http_method: hyper::Method::POST,
12774        });
12775
12776        for &field in [
12777            "alt",
12778            "calendarId",
12779            "text",
12780            "sendUpdates",
12781            "sendNotifications",
12782        ]
12783        .iter()
12784        {
12785            if self._additional_params.contains_key(field) {
12786                dlg.finished(false);
12787                return Err(common::Error::FieldClash(field));
12788            }
12789        }
12790
12791        let mut params = Params::with_capacity(6 + self._additional_params.len());
12792        params.push("calendarId", self._calendar_id);
12793        params.push("text", self._text);
12794        if let Some(value) = self._send_updates.as_ref() {
12795            params.push("sendUpdates", value);
12796        }
12797        if let Some(value) = self._send_notifications.as_ref() {
12798            params.push("sendNotifications", value.to_string());
12799        }
12800
12801        params.extend(self._additional_params.iter());
12802
12803        params.push("alt", "json");
12804        let mut url = self.hub._base_url.clone() + "calendars/{calendarId}/events/quickAdd";
12805        if self._scopes.is_empty() {
12806            self._scopes.insert(Scope::Full.as_ref().to_string());
12807        }
12808
12809        #[allow(clippy::single_element_loop)]
12810        for &(find_this, param_name) in [("{calendarId}", "calendarId")].iter() {
12811            url = params.uri_replacement(url, param_name, find_this, false);
12812        }
12813        {
12814            let to_remove = ["calendarId"];
12815            params.remove_params(&to_remove);
12816        }
12817
12818        let url = params.parse_with_url(&url);
12819
12820        loop {
12821            let token = match self
12822                .hub
12823                .auth
12824                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
12825                .await
12826            {
12827                Ok(token) => token,
12828                Err(e) => match dlg.token(e) {
12829                    Ok(token) => token,
12830                    Err(e) => {
12831                        dlg.finished(false);
12832                        return Err(common::Error::MissingToken(e));
12833                    }
12834                },
12835            };
12836            let mut req_result = {
12837                let client = &self.hub.client;
12838                dlg.pre_request();
12839                let mut req_builder = hyper::Request::builder()
12840                    .method(hyper::Method::POST)
12841                    .uri(url.as_str())
12842                    .header(USER_AGENT, self.hub._user_agent.clone());
12843
12844                if let Some(token) = token.as_ref() {
12845                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
12846                }
12847
12848                let request = req_builder
12849                    .header(CONTENT_LENGTH, 0_u64)
12850                    .body(common::to_body::<String>(None));
12851
12852                client.request(request.unwrap()).await
12853            };
12854
12855            match req_result {
12856                Err(err) => {
12857                    if let common::Retry::After(d) = dlg.http_error(&err) {
12858                        sleep(d).await;
12859                        continue;
12860                    }
12861                    dlg.finished(false);
12862                    return Err(common::Error::HttpError(err));
12863                }
12864                Ok(res) => {
12865                    let (mut parts, body) = res.into_parts();
12866                    let mut body = common::Body::new(body);
12867                    if !parts.status.is_success() {
12868                        let bytes = common::to_bytes(body).await.unwrap_or_default();
12869                        let error = serde_json::from_str(&common::to_string(&bytes));
12870                        let response = common::to_response(parts, bytes.into());
12871
12872                        if let common::Retry::After(d) =
12873                            dlg.http_failure(&response, error.as_ref().ok())
12874                        {
12875                            sleep(d).await;
12876                            continue;
12877                        }
12878
12879                        dlg.finished(false);
12880
12881                        return Err(match error {
12882                            Ok(value) => common::Error::BadRequest(value),
12883                            _ => common::Error::Failure(response),
12884                        });
12885                    }
12886                    let response = {
12887                        let bytes = common::to_bytes(body).await.unwrap_or_default();
12888                        let encoded = common::to_string(&bytes);
12889                        match serde_json::from_str(&encoded) {
12890                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
12891                            Err(error) => {
12892                                dlg.response_json_decode_error(&encoded, &error);
12893                                return Err(common::Error::JsonDecodeError(
12894                                    encoded.to_string(),
12895                                    error,
12896                                ));
12897                            }
12898                        }
12899                    };
12900
12901                    dlg.finished(true);
12902                    return Ok(response);
12903                }
12904            }
12905        }
12906    }
12907
12908    /// 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.
12909    ///
12910    /// Sets the *calendar id* path property to the given value.
12911    ///
12912    /// Even though the property as already been set when instantiating this call,
12913    /// we provide this method for API completeness.
12914    pub fn calendar_id(mut self, new_value: &str) -> EventQuickAddCall<'a, C> {
12915        self._calendar_id = new_value.to_string();
12916        self
12917    }
12918    /// The text describing the event to be created.
12919    ///
12920    /// Sets the *text* query property to the given value.
12921    ///
12922    /// Even though the property as already been set when instantiating this call,
12923    /// we provide this method for API completeness.
12924    pub fn text(mut self, new_value: &str) -> EventQuickAddCall<'a, C> {
12925        self._text = new_value.to_string();
12926        self
12927    }
12928    /// Guests who should receive notifications about the creation of the new event.
12929    ///
12930    /// Sets the *send updates* query property to the given value.
12931    pub fn send_updates(mut self, new_value: &str) -> EventQuickAddCall<'a, C> {
12932        self._send_updates = Some(new_value.to_string());
12933        self
12934    }
12935    /// Deprecated. Please use sendUpdates instead.
12936    ///
12937    /// 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.
12938    ///
12939    /// Sets the *send notifications* query property to the given value.
12940    pub fn send_notifications(mut self, new_value: bool) -> EventQuickAddCall<'a, C> {
12941        self._send_notifications = Some(new_value);
12942        self
12943    }
12944    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
12945    /// while executing the actual API request.
12946    ///
12947    /// ````text
12948    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
12949    /// ````
12950    ///
12951    /// Sets the *delegate* property to the given value.
12952    pub fn delegate(mut self, new_value: &'a mut dyn common::Delegate) -> EventQuickAddCall<'a, C> {
12953        self._delegate = Some(new_value);
12954        self
12955    }
12956
12957    /// Set any additional parameter of the query string used in the request.
12958    /// It should be used to set parameters which are not yet available through their own
12959    /// setters.
12960    ///
12961    /// Please note that this method must not be used to set any of the known parameters
12962    /// which have their own setter method. If done anyway, the request will fail.
12963    ///
12964    /// # Additional Parameters
12965    ///
12966    /// * *alt* (query-string) - Data format for the response.
12967    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
12968    /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
12969    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
12970    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
12971    /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
12972    /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
12973    pub fn param<T>(mut self, name: T, value: T) -> EventQuickAddCall<'a, C>
12974    where
12975        T: AsRef<str>,
12976    {
12977        self._additional_params
12978            .insert(name.as_ref().to_string(), value.as_ref().to_string());
12979        self
12980    }
12981
12982    /// Identifies the authorization scope for the method you are building.
12983    ///
12984    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
12985    /// [`Scope::Full`].
12986    ///
12987    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
12988    /// tokens for more than one scope.
12989    ///
12990    /// Usually there is more than one suitable scope to authorize an operation, some of which may
12991    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
12992    /// sufficient, a read-write scope will do as well.
12993    pub fn add_scope<St>(mut self, scope: St) -> EventQuickAddCall<'a, C>
12994    where
12995        St: AsRef<str>,
12996    {
12997        self._scopes.insert(String::from(scope.as_ref()));
12998        self
12999    }
13000    /// Identifies the authorization scope(s) for the method you are building.
13001    ///
13002    /// See [`Self::add_scope()`] for details.
13003    pub fn add_scopes<I, St>(mut self, scopes: I) -> EventQuickAddCall<'a, C>
13004    where
13005        I: IntoIterator<Item = St>,
13006        St: AsRef<str>,
13007    {
13008        self._scopes
13009            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
13010        self
13011    }
13012
13013    /// Removes all scopes, and no default scope will be used either.
13014    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
13015    /// for details).
13016    pub fn clear_scopes(mut self) -> EventQuickAddCall<'a, C> {
13017        self._scopes.clear();
13018        self
13019    }
13020}
13021
13022/// Updates an event.
13023///
13024/// A builder for the *update* method supported by a *event* resource.
13025/// It is not used directly, but through a [`EventMethods`] instance.
13026///
13027/// # Example
13028///
13029/// Instantiate a resource method builder
13030///
13031/// ```test_harness,no_run
13032/// # extern crate hyper;
13033/// # extern crate hyper_rustls;
13034/// # extern crate google_calendar3 as calendar3;
13035/// use calendar3::api::Event;
13036/// # async fn dox() {
13037/// # use calendar3::{CalendarHub, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
13038///
13039/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
13040/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
13041/// #     secret,
13042/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
13043/// # ).build().await.unwrap();
13044///
13045/// # let client = hyper_util::client::legacy::Client::builder(
13046/// #     hyper_util::rt::TokioExecutor::new()
13047/// # )
13048/// # .build(
13049/// #     hyper_rustls::HttpsConnectorBuilder::new()
13050/// #         .with_native_roots()
13051/// #         .unwrap()
13052/// #         .https_or_http()
13053/// #         .enable_http1()
13054/// #         .build()
13055/// # );
13056/// # let mut hub = CalendarHub::new(client, auth);
13057/// // As the method needs a request, you would usually fill it with the desired information
13058/// // into the respective structure. Some of the parts shown here might not be applicable !
13059/// // Values shown here are possibly random and not representative !
13060/// let mut req = Event::default();
13061///
13062/// // You can configure optional parameters by calling the respective setters at will, and
13063/// // execute the final call using `doit()`.
13064/// // Values shown here are possibly random and not representative !
13065/// let result = hub.events().update(req, "calendarId", "eventId")
13066///              .supports_attachments(true)
13067///              .send_updates("accusam")
13068///              .send_notifications(true)
13069///              .max_attendees(-45)
13070///              .conference_data_version(-27)
13071///              .always_include_email(true)
13072///              .doit().await;
13073/// # }
13074/// ```
13075pub struct EventUpdateCall<'a, C>
13076where
13077    C: 'a,
13078{
13079    hub: &'a CalendarHub<C>,
13080    _request: Event,
13081    _calendar_id: String,
13082    _event_id: String,
13083    _supports_attachments: Option<bool>,
13084    _send_updates: Option<String>,
13085    _send_notifications: Option<bool>,
13086    _max_attendees: Option<i32>,
13087    _conference_data_version: Option<i32>,
13088    _always_include_email: Option<bool>,
13089    _delegate: Option<&'a mut dyn common::Delegate>,
13090    _additional_params: HashMap<String, String>,
13091    _scopes: BTreeSet<String>,
13092}
13093
13094impl<'a, C> common::CallBuilder for EventUpdateCall<'a, C> {}
13095
13096impl<'a, C> EventUpdateCall<'a, C>
13097where
13098    C: common::Connector,
13099{
13100    /// Perform the operation you have build so far.
13101    pub async fn doit(mut self) -> common::Result<(common::Response, Event)> {
13102        use std::borrow::Cow;
13103        use std::io::{Read, Seek};
13104
13105        use common::{url::Params, ToParts};
13106        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
13107
13108        let mut dd = common::DefaultDelegate;
13109        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
13110        dlg.begin(common::MethodInfo {
13111            id: "calendar.events.update",
13112            http_method: hyper::Method::PUT,
13113        });
13114
13115        for &field in [
13116            "alt",
13117            "calendarId",
13118            "eventId",
13119            "supportsAttachments",
13120            "sendUpdates",
13121            "sendNotifications",
13122            "maxAttendees",
13123            "conferenceDataVersion",
13124            "alwaysIncludeEmail",
13125        ]
13126        .iter()
13127        {
13128            if self._additional_params.contains_key(field) {
13129                dlg.finished(false);
13130                return Err(common::Error::FieldClash(field));
13131            }
13132        }
13133
13134        let mut params = Params::with_capacity(11 + self._additional_params.len());
13135        params.push("calendarId", self._calendar_id);
13136        params.push("eventId", self._event_id);
13137        if let Some(value) = self._supports_attachments.as_ref() {
13138            params.push("supportsAttachments", value.to_string());
13139        }
13140        if let Some(value) = self._send_updates.as_ref() {
13141            params.push("sendUpdates", value);
13142        }
13143        if let Some(value) = self._send_notifications.as_ref() {
13144            params.push("sendNotifications", value.to_string());
13145        }
13146        if let Some(value) = self._max_attendees.as_ref() {
13147            params.push("maxAttendees", value.to_string());
13148        }
13149        if let Some(value) = self._conference_data_version.as_ref() {
13150            params.push("conferenceDataVersion", value.to_string());
13151        }
13152        if let Some(value) = self._always_include_email.as_ref() {
13153            params.push("alwaysIncludeEmail", value.to_string());
13154        }
13155
13156        params.extend(self._additional_params.iter());
13157
13158        params.push("alt", "json");
13159        let mut url = self.hub._base_url.clone() + "calendars/{calendarId}/events/{eventId}";
13160        if self._scopes.is_empty() {
13161            self._scopes.insert(Scope::Full.as_ref().to_string());
13162        }
13163
13164        #[allow(clippy::single_element_loop)]
13165        for &(find_this, param_name) in
13166            [("{calendarId}", "calendarId"), ("{eventId}", "eventId")].iter()
13167        {
13168            url = params.uri_replacement(url, param_name, find_this, false);
13169        }
13170        {
13171            let to_remove = ["eventId", "calendarId"];
13172            params.remove_params(&to_remove);
13173        }
13174
13175        let url = params.parse_with_url(&url);
13176
13177        let mut json_mime_type = mime::APPLICATION_JSON;
13178        let mut request_value_reader = {
13179            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
13180            common::remove_json_null_values(&mut value);
13181            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
13182            serde_json::to_writer(&mut dst, &value).unwrap();
13183            dst
13184        };
13185        let request_size = request_value_reader
13186            .seek(std::io::SeekFrom::End(0))
13187            .unwrap();
13188        request_value_reader
13189            .seek(std::io::SeekFrom::Start(0))
13190            .unwrap();
13191
13192        loop {
13193            let token = match self
13194                .hub
13195                .auth
13196                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
13197                .await
13198            {
13199                Ok(token) => token,
13200                Err(e) => match dlg.token(e) {
13201                    Ok(token) => token,
13202                    Err(e) => {
13203                        dlg.finished(false);
13204                        return Err(common::Error::MissingToken(e));
13205                    }
13206                },
13207            };
13208            request_value_reader
13209                .seek(std::io::SeekFrom::Start(0))
13210                .unwrap();
13211            let mut req_result = {
13212                let client = &self.hub.client;
13213                dlg.pre_request();
13214                let mut req_builder = hyper::Request::builder()
13215                    .method(hyper::Method::PUT)
13216                    .uri(url.as_str())
13217                    .header(USER_AGENT, self.hub._user_agent.clone());
13218
13219                if let Some(token) = token.as_ref() {
13220                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
13221                }
13222
13223                let request = req_builder
13224                    .header(CONTENT_TYPE, json_mime_type.to_string())
13225                    .header(CONTENT_LENGTH, request_size as u64)
13226                    .body(common::to_body(
13227                        request_value_reader.get_ref().clone().into(),
13228                    ));
13229
13230                client.request(request.unwrap()).await
13231            };
13232
13233            match req_result {
13234                Err(err) => {
13235                    if let common::Retry::After(d) = dlg.http_error(&err) {
13236                        sleep(d).await;
13237                        continue;
13238                    }
13239                    dlg.finished(false);
13240                    return Err(common::Error::HttpError(err));
13241                }
13242                Ok(res) => {
13243                    let (mut parts, body) = res.into_parts();
13244                    let mut body = common::Body::new(body);
13245                    if !parts.status.is_success() {
13246                        let bytes = common::to_bytes(body).await.unwrap_or_default();
13247                        let error = serde_json::from_str(&common::to_string(&bytes));
13248                        let response = common::to_response(parts, bytes.into());
13249
13250                        if let common::Retry::After(d) =
13251                            dlg.http_failure(&response, error.as_ref().ok())
13252                        {
13253                            sleep(d).await;
13254                            continue;
13255                        }
13256
13257                        dlg.finished(false);
13258
13259                        return Err(match error {
13260                            Ok(value) => common::Error::BadRequest(value),
13261                            _ => common::Error::Failure(response),
13262                        });
13263                    }
13264                    let response = {
13265                        let bytes = common::to_bytes(body).await.unwrap_or_default();
13266                        let encoded = common::to_string(&bytes);
13267                        match serde_json::from_str(&encoded) {
13268                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
13269                            Err(error) => {
13270                                dlg.response_json_decode_error(&encoded, &error);
13271                                return Err(common::Error::JsonDecodeError(
13272                                    encoded.to_string(),
13273                                    error,
13274                                ));
13275                            }
13276                        }
13277                    };
13278
13279                    dlg.finished(true);
13280                    return Ok(response);
13281                }
13282            }
13283        }
13284    }
13285
13286    ///
13287    /// Sets the *request* property to the given value.
13288    ///
13289    /// Even though the property as already been set when instantiating this call,
13290    /// we provide this method for API completeness.
13291    pub fn request(mut self, new_value: Event) -> EventUpdateCall<'a, C> {
13292        self._request = new_value;
13293        self
13294    }
13295    /// 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.
13296    ///
13297    /// Sets the *calendar id* path property to the given value.
13298    ///
13299    /// Even though the property as already been set when instantiating this call,
13300    /// we provide this method for API completeness.
13301    pub fn calendar_id(mut self, new_value: &str) -> EventUpdateCall<'a, C> {
13302        self._calendar_id = new_value.to_string();
13303        self
13304    }
13305    /// Event identifier.
13306    ///
13307    /// Sets the *event id* path property to the given value.
13308    ///
13309    /// Even though the property as already been set when instantiating this call,
13310    /// we provide this method for API completeness.
13311    pub fn event_id(mut self, new_value: &str) -> EventUpdateCall<'a, C> {
13312        self._event_id = new_value.to_string();
13313        self
13314    }
13315    /// Whether API client performing operation supports event attachments. Optional. The default is False.
13316    ///
13317    /// Sets the *supports attachments* query property to the given value.
13318    pub fn supports_attachments(mut self, new_value: bool) -> EventUpdateCall<'a, C> {
13319        self._supports_attachments = Some(new_value);
13320        self
13321    }
13322    /// Guests who should receive notifications about the event update (for example, title changes, etc.).
13323    ///
13324    /// Sets the *send updates* query property to the given value.
13325    pub fn send_updates(mut self, new_value: &str) -> EventUpdateCall<'a, C> {
13326        self._send_updates = Some(new_value.to_string());
13327        self
13328    }
13329    /// Deprecated. Please use sendUpdates instead.
13330    ///
13331    /// 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.
13332    ///
13333    /// Sets the *send notifications* query property to the given value.
13334    pub fn send_notifications(mut self, new_value: bool) -> EventUpdateCall<'a, C> {
13335        self._send_notifications = Some(new_value);
13336        self
13337    }
13338    /// 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.
13339    ///
13340    /// Sets the *max attendees* query property to the given value.
13341    pub fn max_attendees(mut self, new_value: i32) -> EventUpdateCall<'a, C> {
13342        self._max_attendees = Some(new_value);
13343        self
13344    }
13345    /// 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.
13346    ///
13347    /// Sets the *conference data version* query property to the given value.
13348    pub fn conference_data_version(mut self, new_value: i32) -> EventUpdateCall<'a, C> {
13349        self._conference_data_version = Some(new_value);
13350        self
13351    }
13352    /// 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).
13353    ///
13354    /// Sets the *always include email* query property to the given value.
13355    pub fn always_include_email(mut self, new_value: bool) -> EventUpdateCall<'a, C> {
13356        self._always_include_email = Some(new_value);
13357        self
13358    }
13359    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
13360    /// while executing the actual API request.
13361    ///
13362    /// ````text
13363    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
13364    /// ````
13365    ///
13366    /// Sets the *delegate* property to the given value.
13367    pub fn delegate(mut self, new_value: &'a mut dyn common::Delegate) -> EventUpdateCall<'a, C> {
13368        self._delegate = Some(new_value);
13369        self
13370    }
13371
13372    /// Set any additional parameter of the query string used in the request.
13373    /// It should be used to set parameters which are not yet available through their own
13374    /// setters.
13375    ///
13376    /// Please note that this method must not be used to set any of the known parameters
13377    /// which have their own setter method. If done anyway, the request will fail.
13378    ///
13379    /// # Additional Parameters
13380    ///
13381    /// * *alt* (query-string) - Data format for the response.
13382    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
13383    /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
13384    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
13385    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
13386    /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
13387    /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
13388    pub fn param<T>(mut self, name: T, value: T) -> EventUpdateCall<'a, C>
13389    where
13390        T: AsRef<str>,
13391    {
13392        self._additional_params
13393            .insert(name.as_ref().to_string(), value.as_ref().to_string());
13394        self
13395    }
13396
13397    /// Identifies the authorization scope for the method you are building.
13398    ///
13399    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
13400    /// [`Scope::Full`].
13401    ///
13402    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
13403    /// tokens for more than one scope.
13404    ///
13405    /// Usually there is more than one suitable scope to authorize an operation, some of which may
13406    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
13407    /// sufficient, a read-write scope will do as well.
13408    pub fn add_scope<St>(mut self, scope: St) -> EventUpdateCall<'a, C>
13409    where
13410        St: AsRef<str>,
13411    {
13412        self._scopes.insert(String::from(scope.as_ref()));
13413        self
13414    }
13415    /// Identifies the authorization scope(s) for the method you are building.
13416    ///
13417    /// See [`Self::add_scope()`] for details.
13418    pub fn add_scopes<I, St>(mut self, scopes: I) -> EventUpdateCall<'a, C>
13419    where
13420        I: IntoIterator<Item = St>,
13421        St: AsRef<str>,
13422    {
13423        self._scopes
13424            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
13425        self
13426    }
13427
13428    /// Removes all scopes, and no default scope will be used either.
13429    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
13430    /// for details).
13431    pub fn clear_scopes(mut self) -> EventUpdateCall<'a, C> {
13432        self._scopes.clear();
13433        self
13434    }
13435}
13436
13437/// Watch for changes to Events resources.
13438///
13439/// A builder for the *watch* method supported by a *event* resource.
13440/// It is not used directly, but through a [`EventMethods`] instance.
13441///
13442/// # Example
13443///
13444/// Instantiate a resource method builder
13445///
13446/// ```test_harness,no_run
13447/// # extern crate hyper;
13448/// # extern crate hyper_rustls;
13449/// # extern crate google_calendar3 as calendar3;
13450/// use calendar3::api::Channel;
13451/// # async fn dox() {
13452/// # use calendar3::{CalendarHub, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
13453///
13454/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
13455/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
13456/// #     secret,
13457/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
13458/// # ).build().await.unwrap();
13459///
13460/// # let client = hyper_util::client::legacy::Client::builder(
13461/// #     hyper_util::rt::TokioExecutor::new()
13462/// # )
13463/// # .build(
13464/// #     hyper_rustls::HttpsConnectorBuilder::new()
13465/// #         .with_native_roots()
13466/// #         .unwrap()
13467/// #         .https_or_http()
13468/// #         .enable_http1()
13469/// #         .build()
13470/// # );
13471/// # let mut hub = CalendarHub::new(client, auth);
13472/// // As the method needs a request, you would usually fill it with the desired information
13473/// // into the respective structure. Some of the parts shown here might not be applicable !
13474/// // Values shown here are possibly random and not representative !
13475/// let mut req = Channel::default();
13476///
13477/// // You can configure optional parameters by calling the respective setters at will, and
13478/// // execute the final call using `doit()`.
13479/// // Values shown here are possibly random and not representative !
13480/// let result = hub.events().watch(req, "calendarId")
13481///              .updated_min(chrono::Utc::now())
13482///              .time_zone("sit")
13483///              .time_min(chrono::Utc::now())
13484///              .time_max(chrono::Utc::now())
13485///              .sync_token("magna")
13486///              .single_events(true)
13487///              .show_hidden_invitations(false)
13488///              .show_deleted(true)
13489///              .add_shared_extended_property("no")
13490///              .q("nonumy")
13491///              .add_private_extended_property("sed")
13492///              .page_token("kasd")
13493///              .order_by("Lorem")
13494///              .max_results(-58)
13495///              .max_attendees(-91)
13496///              .i_cal_uid("rebum.")
13497///              .add_event_types("tempor")
13498///              .always_include_email(true)
13499///              .doit().await;
13500/// # }
13501/// ```
13502pub struct EventWatchCall<'a, C>
13503where
13504    C: 'a,
13505{
13506    hub: &'a CalendarHub<C>,
13507    _request: Channel,
13508    _calendar_id: String,
13509    _updated_min: Option<chrono::DateTime<chrono::offset::Utc>>,
13510    _time_zone: Option<String>,
13511    _time_min: Option<chrono::DateTime<chrono::offset::Utc>>,
13512    _time_max: Option<chrono::DateTime<chrono::offset::Utc>>,
13513    _sync_token: Option<String>,
13514    _single_events: Option<bool>,
13515    _show_hidden_invitations: Option<bool>,
13516    _show_deleted: Option<bool>,
13517    _shared_extended_property: Vec<String>,
13518    _q: Option<String>,
13519    _private_extended_property: Vec<String>,
13520    _page_token: Option<String>,
13521    _order_by: Option<String>,
13522    _max_results: Option<i32>,
13523    _max_attendees: Option<i32>,
13524    _i_cal_uid: Option<String>,
13525    _event_types: Vec<String>,
13526    _always_include_email: Option<bool>,
13527    _delegate: Option<&'a mut dyn common::Delegate>,
13528    _additional_params: HashMap<String, String>,
13529    _scopes: BTreeSet<String>,
13530}
13531
13532impl<'a, C> common::CallBuilder for EventWatchCall<'a, C> {}
13533
13534impl<'a, C> EventWatchCall<'a, C>
13535where
13536    C: common::Connector,
13537{
13538    /// Perform the operation you have build so far.
13539    pub async fn doit(mut self) -> common::Result<(common::Response, Channel)> {
13540        use std::borrow::Cow;
13541        use std::io::{Read, Seek};
13542
13543        use common::{url::Params, ToParts};
13544        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
13545
13546        let mut dd = common::DefaultDelegate;
13547        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
13548        dlg.begin(common::MethodInfo {
13549            id: "calendar.events.watch",
13550            http_method: hyper::Method::POST,
13551        });
13552
13553        for &field in [
13554            "alt",
13555            "calendarId",
13556            "updatedMin",
13557            "timeZone",
13558            "timeMin",
13559            "timeMax",
13560            "syncToken",
13561            "singleEvents",
13562            "showHiddenInvitations",
13563            "showDeleted",
13564            "sharedExtendedProperty",
13565            "q",
13566            "privateExtendedProperty",
13567            "pageToken",
13568            "orderBy",
13569            "maxResults",
13570            "maxAttendees",
13571            "iCalUID",
13572            "eventTypes",
13573            "alwaysIncludeEmail",
13574        ]
13575        .iter()
13576        {
13577            if self._additional_params.contains_key(field) {
13578                dlg.finished(false);
13579                return Err(common::Error::FieldClash(field));
13580            }
13581        }
13582
13583        let mut params = Params::with_capacity(22 + self._additional_params.len());
13584        params.push("calendarId", self._calendar_id);
13585        if let Some(value) = self._updated_min.as_ref() {
13586            params.push("updatedMin", common::serde::datetime_to_string(&value));
13587        }
13588        if let Some(value) = self._time_zone.as_ref() {
13589            params.push("timeZone", value);
13590        }
13591        if let Some(value) = self._time_min.as_ref() {
13592            params.push("timeMin", common::serde::datetime_to_string(&value));
13593        }
13594        if let Some(value) = self._time_max.as_ref() {
13595            params.push("timeMax", common::serde::datetime_to_string(&value));
13596        }
13597        if let Some(value) = self._sync_token.as_ref() {
13598            params.push("syncToken", value);
13599        }
13600        if let Some(value) = self._single_events.as_ref() {
13601            params.push("singleEvents", value.to_string());
13602        }
13603        if let Some(value) = self._show_hidden_invitations.as_ref() {
13604            params.push("showHiddenInvitations", value.to_string());
13605        }
13606        if let Some(value) = self._show_deleted.as_ref() {
13607            params.push("showDeleted", value.to_string());
13608        }
13609        if !self._shared_extended_property.is_empty() {
13610            for f in self._shared_extended_property.iter() {
13611                params.push("sharedExtendedProperty", f);
13612            }
13613        }
13614        if let Some(value) = self._q.as_ref() {
13615            params.push("q", value);
13616        }
13617        if !self._private_extended_property.is_empty() {
13618            for f in self._private_extended_property.iter() {
13619                params.push("privateExtendedProperty", f);
13620            }
13621        }
13622        if let Some(value) = self._page_token.as_ref() {
13623            params.push("pageToken", value);
13624        }
13625        if let Some(value) = self._order_by.as_ref() {
13626            params.push("orderBy", value);
13627        }
13628        if let Some(value) = self._max_results.as_ref() {
13629            params.push("maxResults", value.to_string());
13630        }
13631        if let Some(value) = self._max_attendees.as_ref() {
13632            params.push("maxAttendees", value.to_string());
13633        }
13634        if let Some(value) = self._i_cal_uid.as_ref() {
13635            params.push("iCalUID", value);
13636        }
13637        if !self._event_types.is_empty() {
13638            for f in self._event_types.iter() {
13639                params.push("eventTypes", f);
13640            }
13641        }
13642        if let Some(value) = self._always_include_email.as_ref() {
13643            params.push("alwaysIncludeEmail", value.to_string());
13644        }
13645
13646        params.extend(self._additional_params.iter());
13647
13648        params.push("alt", "json");
13649        let mut url = self.hub._base_url.clone() + "calendars/{calendarId}/events/watch";
13650        if self._scopes.is_empty() {
13651            self._scopes.insert(Scope::Full.as_ref().to_string());
13652        }
13653
13654        #[allow(clippy::single_element_loop)]
13655        for &(find_this, param_name) in [("{calendarId}", "calendarId")].iter() {
13656            url = params.uri_replacement(url, param_name, find_this, false);
13657        }
13658        {
13659            let to_remove = ["calendarId"];
13660            params.remove_params(&to_remove);
13661        }
13662
13663        let url = params.parse_with_url(&url);
13664
13665        let mut json_mime_type = mime::APPLICATION_JSON;
13666        let mut request_value_reader = {
13667            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
13668            common::remove_json_null_values(&mut value);
13669            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
13670            serde_json::to_writer(&mut dst, &value).unwrap();
13671            dst
13672        };
13673        let request_size = request_value_reader
13674            .seek(std::io::SeekFrom::End(0))
13675            .unwrap();
13676        request_value_reader
13677            .seek(std::io::SeekFrom::Start(0))
13678            .unwrap();
13679
13680        loop {
13681            let token = match self
13682                .hub
13683                .auth
13684                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
13685                .await
13686            {
13687                Ok(token) => token,
13688                Err(e) => match dlg.token(e) {
13689                    Ok(token) => token,
13690                    Err(e) => {
13691                        dlg.finished(false);
13692                        return Err(common::Error::MissingToken(e));
13693                    }
13694                },
13695            };
13696            request_value_reader
13697                .seek(std::io::SeekFrom::Start(0))
13698                .unwrap();
13699            let mut req_result = {
13700                let client = &self.hub.client;
13701                dlg.pre_request();
13702                let mut req_builder = hyper::Request::builder()
13703                    .method(hyper::Method::POST)
13704                    .uri(url.as_str())
13705                    .header(USER_AGENT, self.hub._user_agent.clone());
13706
13707                if let Some(token) = token.as_ref() {
13708                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
13709                }
13710
13711                let request = req_builder
13712                    .header(CONTENT_TYPE, json_mime_type.to_string())
13713                    .header(CONTENT_LENGTH, request_size as u64)
13714                    .body(common::to_body(
13715                        request_value_reader.get_ref().clone().into(),
13716                    ));
13717
13718                client.request(request.unwrap()).await
13719            };
13720
13721            match req_result {
13722                Err(err) => {
13723                    if let common::Retry::After(d) = dlg.http_error(&err) {
13724                        sleep(d).await;
13725                        continue;
13726                    }
13727                    dlg.finished(false);
13728                    return Err(common::Error::HttpError(err));
13729                }
13730                Ok(res) => {
13731                    let (mut parts, body) = res.into_parts();
13732                    let mut body = common::Body::new(body);
13733                    if !parts.status.is_success() {
13734                        let bytes = common::to_bytes(body).await.unwrap_or_default();
13735                        let error = serde_json::from_str(&common::to_string(&bytes));
13736                        let response = common::to_response(parts, bytes.into());
13737
13738                        if let common::Retry::After(d) =
13739                            dlg.http_failure(&response, error.as_ref().ok())
13740                        {
13741                            sleep(d).await;
13742                            continue;
13743                        }
13744
13745                        dlg.finished(false);
13746
13747                        return Err(match error {
13748                            Ok(value) => common::Error::BadRequest(value),
13749                            _ => common::Error::Failure(response),
13750                        });
13751                    }
13752                    let response = {
13753                        let bytes = common::to_bytes(body).await.unwrap_or_default();
13754                        let encoded = common::to_string(&bytes);
13755                        match serde_json::from_str(&encoded) {
13756                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
13757                            Err(error) => {
13758                                dlg.response_json_decode_error(&encoded, &error);
13759                                return Err(common::Error::JsonDecodeError(
13760                                    encoded.to_string(),
13761                                    error,
13762                                ));
13763                            }
13764                        }
13765                    };
13766
13767                    dlg.finished(true);
13768                    return Ok(response);
13769                }
13770            }
13771        }
13772    }
13773
13774    ///
13775    /// Sets the *request* property to the given value.
13776    ///
13777    /// Even though the property as already been set when instantiating this call,
13778    /// we provide this method for API completeness.
13779    pub fn request(mut self, new_value: Channel) -> EventWatchCall<'a, C> {
13780        self._request = new_value;
13781        self
13782    }
13783    /// 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.
13784    ///
13785    /// Sets the *calendar id* path property to the given value.
13786    ///
13787    /// Even though the property as already been set when instantiating this call,
13788    /// we provide this method for API completeness.
13789    pub fn calendar_id(mut self, new_value: &str) -> EventWatchCall<'a, C> {
13790        self._calendar_id = new_value.to_string();
13791        self
13792    }
13793    /// 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.
13794    ///
13795    /// Sets the *updated min* query property to the given value.
13796    pub fn updated_min(
13797        mut self,
13798        new_value: chrono::DateTime<chrono::offset::Utc>,
13799    ) -> EventWatchCall<'a, C> {
13800        self._updated_min = Some(new_value);
13801        self
13802    }
13803    /// Time zone used in the response. Optional. The default is the time zone of the calendar.
13804    ///
13805    /// Sets the *time zone* query property to the given value.
13806    pub fn time_zone(mut self, new_value: &str) -> EventWatchCall<'a, C> {
13807        self._time_zone = Some(new_value.to_string());
13808        self
13809    }
13810    /// 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.
13811    ///
13812    /// Sets the *time min* query property to the given value.
13813    pub fn time_min(
13814        mut self,
13815        new_value: chrono::DateTime<chrono::offset::Utc>,
13816    ) -> EventWatchCall<'a, C> {
13817        self._time_min = Some(new_value);
13818        self
13819    }
13820    /// 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.
13821    ///
13822    /// Sets the *time max* query property to the given value.
13823    pub fn time_max(
13824        mut self,
13825        new_value: chrono::DateTime<chrono::offset::Utc>,
13826    ) -> EventWatchCall<'a, C> {
13827        self._time_max = Some(new_value);
13828        self
13829    }
13830    /// 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.
13831    /// There are several query parameters that cannot be specified together with nextSyncToken to ensure consistency of the client state.
13832    ///
13833    /// These are:
13834    /// - iCalUID
13835    /// - orderBy
13836    /// - privateExtendedProperty
13837    /// - q
13838    /// - sharedExtendedProperty
13839    /// - timeMin
13840    /// - timeMax
13841    /// - updatedMin All other query parameters should be the same as for the initial synchronization to avoid undefined behavior. 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.
13842    /// Learn more about incremental synchronization.
13843    /// Optional. The default is to return all entries.
13844    ///
13845    /// Sets the *sync token* query property to the given value.
13846    pub fn sync_token(mut self, new_value: &str) -> EventWatchCall<'a, C> {
13847        self._sync_token = Some(new_value.to_string());
13848        self
13849    }
13850    /// 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.
13851    ///
13852    /// Sets the *single events* query property to the given value.
13853    pub fn single_events(mut self, new_value: bool) -> EventWatchCall<'a, C> {
13854        self._single_events = Some(new_value);
13855        self
13856    }
13857    /// Whether to include hidden invitations in the result. Optional. The default is False.
13858    ///
13859    /// Sets the *show hidden invitations* query property to the given value.
13860    pub fn show_hidden_invitations(mut self, new_value: bool) -> EventWatchCall<'a, C> {
13861        self._show_hidden_invitations = Some(new_value);
13862        self
13863    }
13864    /// 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.
13865    ///
13866    /// Sets the *show deleted* query property to the given value.
13867    pub fn show_deleted(mut self, new_value: bool) -> EventWatchCall<'a, C> {
13868        self._show_deleted = Some(new_value);
13869        self
13870    }
13871    /// 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.
13872    ///
13873    /// Append the given value to the *shared extended property* query property.
13874    /// Each appended value will retain its original ordering and be '/'-separated in the URL's parameters.
13875    pub fn add_shared_extended_property(mut self, new_value: &str) -> EventWatchCall<'a, C> {
13876        self._shared_extended_property.push(new_value.to_string());
13877        self
13878    }
13879    /// Free text search terms to find events that match these terms in the following fields:
13880    ///
13881    /// - summary
13882    /// - description
13883    /// - location
13884    /// - attendee's displayName
13885    /// - attendee's email
13886    /// - organizer's displayName
13887    /// - organizer's email
13888    /// - workingLocationProperties.officeLocation.buildingId
13889    /// - workingLocationProperties.officeLocation.deskId
13890    /// - workingLocationProperties.officeLocation.label
13891    /// - workingLocationProperties.customLocation.label
13892    /// These search terms also match predefined keywords against all display title translations of working location, out-of-office, and focus-time events. For example, searching for "Office" or "Bureau" returns working location events of type officeLocation, whereas searching for "Out of office" or "Abwesend" returns out-of-office events. Optional.
13893    ///
13894    /// Sets the *q* query property to the given value.
13895    pub fn q(mut self, new_value: &str) -> EventWatchCall<'a, C> {
13896        self._q = Some(new_value.to_string());
13897        self
13898    }
13899    /// 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.
13900    ///
13901    /// Append the given value to the *private extended property* query property.
13902    /// Each appended value will retain its original ordering and be '/'-separated in the URL's parameters.
13903    pub fn add_private_extended_property(mut self, new_value: &str) -> EventWatchCall<'a, C> {
13904        self._private_extended_property.push(new_value.to_string());
13905        self
13906    }
13907    /// Token specifying which result page to return. Optional.
13908    ///
13909    /// Sets the *page token* query property to the given value.
13910    pub fn page_token(mut self, new_value: &str) -> EventWatchCall<'a, C> {
13911        self._page_token = Some(new_value.to_string());
13912        self
13913    }
13914    /// The order of the events returned in the result. Optional. The default is an unspecified, stable order.
13915    ///
13916    /// Sets the *order by* query property to the given value.
13917    pub fn order_by(mut self, new_value: &str) -> EventWatchCall<'a, C> {
13918        self._order_by = Some(new_value.to_string());
13919        self
13920    }
13921    /// 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.
13922    ///
13923    /// Sets the *max results* query property to the given value.
13924    pub fn max_results(mut self, new_value: i32) -> EventWatchCall<'a, C> {
13925        self._max_results = Some(new_value);
13926        self
13927    }
13928    /// 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.
13929    ///
13930    /// Sets the *max attendees* query property to the given value.
13931    pub fn max_attendees(mut self, new_value: i32) -> EventWatchCall<'a, C> {
13932        self._max_attendees = Some(new_value);
13933        self
13934    }
13935    /// Specifies an event ID in the iCalendar format to be provided in the response. Optional. Use this if you want to search for an event by its iCalendar ID.
13936    ///
13937    /// Sets the *i cal uid* query property to the given value.
13938    pub fn i_cal_uid(mut self, new_value: &str) -> EventWatchCall<'a, C> {
13939        self._i_cal_uid = Some(new_value.to_string());
13940        self
13941    }
13942    /// Event types to return. Optional. This parameter can be repeated multiple times to return events of different types. If unset, returns all event types.
13943    ///
13944    /// Append the given value to the *event types* query property.
13945    /// Each appended value will retain its original ordering and be '/'-separated in the URL's parameters.
13946    pub fn add_event_types(mut self, new_value: &str) -> EventWatchCall<'a, C> {
13947        self._event_types.push(new_value.to_string());
13948        self
13949    }
13950    /// Deprecated and ignored.
13951    ///
13952    /// Sets the *always include email* query property to the given value.
13953    pub fn always_include_email(mut self, new_value: bool) -> EventWatchCall<'a, C> {
13954        self._always_include_email = Some(new_value);
13955        self
13956    }
13957    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
13958    /// while executing the actual API request.
13959    ///
13960    /// ````text
13961    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
13962    /// ````
13963    ///
13964    /// Sets the *delegate* property to the given value.
13965    pub fn delegate(mut self, new_value: &'a mut dyn common::Delegate) -> EventWatchCall<'a, C> {
13966        self._delegate = Some(new_value);
13967        self
13968    }
13969
13970    /// Set any additional parameter of the query string used in the request.
13971    /// It should be used to set parameters which are not yet available through their own
13972    /// setters.
13973    ///
13974    /// Please note that this method must not be used to set any of the known parameters
13975    /// which have their own setter method. If done anyway, the request will fail.
13976    ///
13977    /// # Additional Parameters
13978    ///
13979    /// * *alt* (query-string) - Data format for the response.
13980    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
13981    /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
13982    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
13983    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
13984    /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
13985    /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
13986    pub fn param<T>(mut self, name: T, value: T) -> EventWatchCall<'a, C>
13987    where
13988        T: AsRef<str>,
13989    {
13990        self._additional_params
13991            .insert(name.as_ref().to_string(), value.as_ref().to_string());
13992        self
13993    }
13994
13995    /// Identifies the authorization scope for the method you are building.
13996    ///
13997    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
13998    /// [`Scope::Full`].
13999    ///
14000    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
14001    /// tokens for more than one scope.
14002    ///
14003    /// Usually there is more than one suitable scope to authorize an operation, some of which may
14004    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
14005    /// sufficient, a read-write scope will do as well.
14006    pub fn add_scope<St>(mut self, scope: St) -> EventWatchCall<'a, C>
14007    where
14008        St: AsRef<str>,
14009    {
14010        self._scopes.insert(String::from(scope.as_ref()));
14011        self
14012    }
14013    /// Identifies the authorization scope(s) for the method you are building.
14014    ///
14015    /// See [`Self::add_scope()`] for details.
14016    pub fn add_scopes<I, St>(mut self, scopes: I) -> EventWatchCall<'a, C>
14017    where
14018        I: IntoIterator<Item = St>,
14019        St: AsRef<str>,
14020    {
14021        self._scopes
14022            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
14023        self
14024    }
14025
14026    /// Removes all scopes, and no default scope will be used either.
14027    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
14028    /// for details).
14029    pub fn clear_scopes(mut self) -> EventWatchCall<'a, C> {
14030        self._scopes.clear();
14031        self
14032    }
14033}
14034
14035/// Returns free/busy information for a set of calendars.
14036///
14037/// A builder for the *query* method supported by a *freebusy* resource.
14038/// It is not used directly, but through a [`FreebusyMethods`] instance.
14039///
14040/// # Example
14041///
14042/// Instantiate a resource method builder
14043///
14044/// ```test_harness,no_run
14045/// # extern crate hyper;
14046/// # extern crate hyper_rustls;
14047/// # extern crate google_calendar3 as calendar3;
14048/// use calendar3::api::FreeBusyRequest;
14049/// # async fn dox() {
14050/// # use calendar3::{CalendarHub, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
14051///
14052/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
14053/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
14054/// #     secret,
14055/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
14056/// # ).build().await.unwrap();
14057///
14058/// # let client = hyper_util::client::legacy::Client::builder(
14059/// #     hyper_util::rt::TokioExecutor::new()
14060/// # )
14061/// # .build(
14062/// #     hyper_rustls::HttpsConnectorBuilder::new()
14063/// #         .with_native_roots()
14064/// #         .unwrap()
14065/// #         .https_or_http()
14066/// #         .enable_http1()
14067/// #         .build()
14068/// # );
14069/// # let mut hub = CalendarHub::new(client, auth);
14070/// // As the method needs a request, you would usually fill it with the desired information
14071/// // into the respective structure. Some of the parts shown here might not be applicable !
14072/// // Values shown here are possibly random and not representative !
14073/// let mut req = FreeBusyRequest::default();
14074///
14075/// // You can configure optional parameters by calling the respective setters at will, and
14076/// // execute the final call using `doit()`.
14077/// // Values shown here are possibly random and not representative !
14078/// let result = hub.freebusy().query(req)
14079///              .doit().await;
14080/// # }
14081/// ```
14082pub struct FreebusyQueryCall<'a, C>
14083where
14084    C: 'a,
14085{
14086    hub: &'a CalendarHub<C>,
14087    _request: FreeBusyRequest,
14088    _delegate: Option<&'a mut dyn common::Delegate>,
14089    _additional_params: HashMap<String, String>,
14090    _scopes: BTreeSet<String>,
14091}
14092
14093impl<'a, C> common::CallBuilder for FreebusyQueryCall<'a, C> {}
14094
14095impl<'a, C> FreebusyQueryCall<'a, C>
14096where
14097    C: common::Connector,
14098{
14099    /// Perform the operation you have build so far.
14100    pub async fn doit(mut self) -> common::Result<(common::Response, FreeBusyResponse)> {
14101        use std::borrow::Cow;
14102        use std::io::{Read, Seek};
14103
14104        use common::{url::Params, ToParts};
14105        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
14106
14107        let mut dd = common::DefaultDelegate;
14108        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
14109        dlg.begin(common::MethodInfo {
14110            id: "calendar.freebusy.query",
14111            http_method: hyper::Method::POST,
14112        });
14113
14114        for &field in ["alt"].iter() {
14115            if self._additional_params.contains_key(field) {
14116                dlg.finished(false);
14117                return Err(common::Error::FieldClash(field));
14118            }
14119        }
14120
14121        let mut params = Params::with_capacity(3 + self._additional_params.len());
14122
14123        params.extend(self._additional_params.iter());
14124
14125        params.push("alt", "json");
14126        let mut url = self.hub._base_url.clone() + "freeBusy";
14127        if self._scopes.is_empty() {
14128            self._scopes.insert(Scope::Full.as_ref().to_string());
14129        }
14130
14131        let url = params.parse_with_url(&url);
14132
14133        let mut json_mime_type = mime::APPLICATION_JSON;
14134        let mut request_value_reader = {
14135            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
14136            common::remove_json_null_values(&mut value);
14137            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
14138            serde_json::to_writer(&mut dst, &value).unwrap();
14139            dst
14140        };
14141        let request_size = request_value_reader
14142            .seek(std::io::SeekFrom::End(0))
14143            .unwrap();
14144        request_value_reader
14145            .seek(std::io::SeekFrom::Start(0))
14146            .unwrap();
14147
14148        loop {
14149            let token = match self
14150                .hub
14151                .auth
14152                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
14153                .await
14154            {
14155                Ok(token) => token,
14156                Err(e) => match dlg.token(e) {
14157                    Ok(token) => token,
14158                    Err(e) => {
14159                        dlg.finished(false);
14160                        return Err(common::Error::MissingToken(e));
14161                    }
14162                },
14163            };
14164            request_value_reader
14165                .seek(std::io::SeekFrom::Start(0))
14166                .unwrap();
14167            let mut req_result = {
14168                let client = &self.hub.client;
14169                dlg.pre_request();
14170                let mut req_builder = hyper::Request::builder()
14171                    .method(hyper::Method::POST)
14172                    .uri(url.as_str())
14173                    .header(USER_AGENT, self.hub._user_agent.clone());
14174
14175                if let Some(token) = token.as_ref() {
14176                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
14177                }
14178
14179                let request = req_builder
14180                    .header(CONTENT_TYPE, json_mime_type.to_string())
14181                    .header(CONTENT_LENGTH, request_size as u64)
14182                    .body(common::to_body(
14183                        request_value_reader.get_ref().clone().into(),
14184                    ));
14185
14186                client.request(request.unwrap()).await
14187            };
14188
14189            match req_result {
14190                Err(err) => {
14191                    if let common::Retry::After(d) = dlg.http_error(&err) {
14192                        sleep(d).await;
14193                        continue;
14194                    }
14195                    dlg.finished(false);
14196                    return Err(common::Error::HttpError(err));
14197                }
14198                Ok(res) => {
14199                    let (mut parts, body) = res.into_parts();
14200                    let mut body = common::Body::new(body);
14201                    if !parts.status.is_success() {
14202                        let bytes = common::to_bytes(body).await.unwrap_or_default();
14203                        let error = serde_json::from_str(&common::to_string(&bytes));
14204                        let response = common::to_response(parts, bytes.into());
14205
14206                        if let common::Retry::After(d) =
14207                            dlg.http_failure(&response, error.as_ref().ok())
14208                        {
14209                            sleep(d).await;
14210                            continue;
14211                        }
14212
14213                        dlg.finished(false);
14214
14215                        return Err(match error {
14216                            Ok(value) => common::Error::BadRequest(value),
14217                            _ => common::Error::Failure(response),
14218                        });
14219                    }
14220                    let response = {
14221                        let bytes = common::to_bytes(body).await.unwrap_or_default();
14222                        let encoded = common::to_string(&bytes);
14223                        match serde_json::from_str(&encoded) {
14224                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
14225                            Err(error) => {
14226                                dlg.response_json_decode_error(&encoded, &error);
14227                                return Err(common::Error::JsonDecodeError(
14228                                    encoded.to_string(),
14229                                    error,
14230                                ));
14231                            }
14232                        }
14233                    };
14234
14235                    dlg.finished(true);
14236                    return Ok(response);
14237                }
14238            }
14239        }
14240    }
14241
14242    ///
14243    /// Sets the *request* property to the given value.
14244    ///
14245    /// Even though the property as already been set when instantiating this call,
14246    /// we provide this method for API completeness.
14247    pub fn request(mut self, new_value: FreeBusyRequest) -> FreebusyQueryCall<'a, C> {
14248        self._request = new_value;
14249        self
14250    }
14251    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
14252    /// while executing the actual API request.
14253    ///
14254    /// ````text
14255    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
14256    /// ````
14257    ///
14258    /// Sets the *delegate* property to the given value.
14259    pub fn delegate(mut self, new_value: &'a mut dyn common::Delegate) -> FreebusyQueryCall<'a, C> {
14260        self._delegate = Some(new_value);
14261        self
14262    }
14263
14264    /// Set any additional parameter of the query string used in the request.
14265    /// It should be used to set parameters which are not yet available through their own
14266    /// setters.
14267    ///
14268    /// Please note that this method must not be used to set any of the known parameters
14269    /// which have their own setter method. If done anyway, the request will fail.
14270    ///
14271    /// # Additional Parameters
14272    ///
14273    /// * *alt* (query-string) - Data format for the response.
14274    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
14275    /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
14276    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
14277    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
14278    /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
14279    /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
14280    pub fn param<T>(mut self, name: T, value: T) -> FreebusyQueryCall<'a, C>
14281    where
14282        T: AsRef<str>,
14283    {
14284        self._additional_params
14285            .insert(name.as_ref().to_string(), value.as_ref().to_string());
14286        self
14287    }
14288
14289    /// Identifies the authorization scope for the method you are building.
14290    ///
14291    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
14292    /// [`Scope::Full`].
14293    ///
14294    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
14295    /// tokens for more than one scope.
14296    ///
14297    /// Usually there is more than one suitable scope to authorize an operation, some of which may
14298    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
14299    /// sufficient, a read-write scope will do as well.
14300    pub fn add_scope<St>(mut self, scope: St) -> FreebusyQueryCall<'a, C>
14301    where
14302        St: AsRef<str>,
14303    {
14304        self._scopes.insert(String::from(scope.as_ref()));
14305        self
14306    }
14307    /// Identifies the authorization scope(s) for the method you are building.
14308    ///
14309    /// See [`Self::add_scope()`] for details.
14310    pub fn add_scopes<I, St>(mut self, scopes: I) -> FreebusyQueryCall<'a, C>
14311    where
14312        I: IntoIterator<Item = St>,
14313        St: AsRef<str>,
14314    {
14315        self._scopes
14316            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
14317        self
14318    }
14319
14320    /// Removes all scopes, and no default scope will be used either.
14321    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
14322    /// for details).
14323    pub fn clear_scopes(mut self) -> FreebusyQueryCall<'a, C> {
14324        self._scopes.clear();
14325        self
14326    }
14327}
14328
14329/// Returns a single user setting.
14330///
14331/// A builder for the *get* method supported by a *setting* resource.
14332/// It is not used directly, but through a [`SettingMethods`] instance.
14333///
14334/// # Example
14335///
14336/// Instantiate a resource method builder
14337///
14338/// ```test_harness,no_run
14339/// # extern crate hyper;
14340/// # extern crate hyper_rustls;
14341/// # extern crate google_calendar3 as calendar3;
14342/// # async fn dox() {
14343/// # use calendar3::{CalendarHub, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
14344///
14345/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
14346/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
14347/// #     secret,
14348/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
14349/// # ).build().await.unwrap();
14350///
14351/// # let client = hyper_util::client::legacy::Client::builder(
14352/// #     hyper_util::rt::TokioExecutor::new()
14353/// # )
14354/// # .build(
14355/// #     hyper_rustls::HttpsConnectorBuilder::new()
14356/// #         .with_native_roots()
14357/// #         .unwrap()
14358/// #         .https_or_http()
14359/// #         .enable_http1()
14360/// #         .build()
14361/// # );
14362/// # let mut hub = CalendarHub::new(client, auth);
14363/// // You can configure optional parameters by calling the respective setters at will, and
14364/// // execute the final call using `doit()`.
14365/// // Values shown here are possibly random and not representative !
14366/// let result = hub.settings().get("setting")
14367///              .doit().await;
14368/// # }
14369/// ```
14370pub struct SettingGetCall<'a, C>
14371where
14372    C: 'a,
14373{
14374    hub: &'a CalendarHub<C>,
14375    _setting: String,
14376    _delegate: Option<&'a mut dyn common::Delegate>,
14377    _additional_params: HashMap<String, String>,
14378    _scopes: BTreeSet<String>,
14379}
14380
14381impl<'a, C> common::CallBuilder for SettingGetCall<'a, C> {}
14382
14383impl<'a, C> SettingGetCall<'a, C>
14384where
14385    C: common::Connector,
14386{
14387    /// Perform the operation you have build so far.
14388    pub async fn doit(mut self) -> common::Result<(common::Response, Setting)> {
14389        use std::borrow::Cow;
14390        use std::io::{Read, Seek};
14391
14392        use common::{url::Params, ToParts};
14393        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
14394
14395        let mut dd = common::DefaultDelegate;
14396        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
14397        dlg.begin(common::MethodInfo {
14398            id: "calendar.settings.get",
14399            http_method: hyper::Method::GET,
14400        });
14401
14402        for &field in ["alt", "setting"].iter() {
14403            if self._additional_params.contains_key(field) {
14404                dlg.finished(false);
14405                return Err(common::Error::FieldClash(field));
14406            }
14407        }
14408
14409        let mut params = Params::with_capacity(3 + self._additional_params.len());
14410        params.push("setting", self._setting);
14411
14412        params.extend(self._additional_params.iter());
14413
14414        params.push("alt", "json");
14415        let mut url = self.hub._base_url.clone() + "users/me/settings/{setting}";
14416        if self._scopes.is_empty() {
14417            self._scopes.insert(Scope::Readonly.as_ref().to_string());
14418        }
14419
14420        #[allow(clippy::single_element_loop)]
14421        for &(find_this, param_name) in [("{setting}", "setting")].iter() {
14422            url = params.uri_replacement(url, param_name, find_this, false);
14423        }
14424        {
14425            let to_remove = ["setting"];
14426            params.remove_params(&to_remove);
14427        }
14428
14429        let url = params.parse_with_url(&url);
14430
14431        loop {
14432            let token = match self
14433                .hub
14434                .auth
14435                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
14436                .await
14437            {
14438                Ok(token) => token,
14439                Err(e) => match dlg.token(e) {
14440                    Ok(token) => token,
14441                    Err(e) => {
14442                        dlg.finished(false);
14443                        return Err(common::Error::MissingToken(e));
14444                    }
14445                },
14446            };
14447            let mut req_result = {
14448                let client = &self.hub.client;
14449                dlg.pre_request();
14450                let mut req_builder = hyper::Request::builder()
14451                    .method(hyper::Method::GET)
14452                    .uri(url.as_str())
14453                    .header(USER_AGENT, self.hub._user_agent.clone());
14454
14455                if let Some(token) = token.as_ref() {
14456                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
14457                }
14458
14459                let request = req_builder
14460                    .header(CONTENT_LENGTH, 0_u64)
14461                    .body(common::to_body::<String>(None));
14462
14463                client.request(request.unwrap()).await
14464            };
14465
14466            match req_result {
14467                Err(err) => {
14468                    if let common::Retry::After(d) = dlg.http_error(&err) {
14469                        sleep(d).await;
14470                        continue;
14471                    }
14472                    dlg.finished(false);
14473                    return Err(common::Error::HttpError(err));
14474                }
14475                Ok(res) => {
14476                    let (mut parts, body) = res.into_parts();
14477                    let mut body = common::Body::new(body);
14478                    if !parts.status.is_success() {
14479                        let bytes = common::to_bytes(body).await.unwrap_or_default();
14480                        let error = serde_json::from_str(&common::to_string(&bytes));
14481                        let response = common::to_response(parts, bytes.into());
14482
14483                        if let common::Retry::After(d) =
14484                            dlg.http_failure(&response, error.as_ref().ok())
14485                        {
14486                            sleep(d).await;
14487                            continue;
14488                        }
14489
14490                        dlg.finished(false);
14491
14492                        return Err(match error {
14493                            Ok(value) => common::Error::BadRequest(value),
14494                            _ => common::Error::Failure(response),
14495                        });
14496                    }
14497                    let response = {
14498                        let bytes = common::to_bytes(body).await.unwrap_or_default();
14499                        let encoded = common::to_string(&bytes);
14500                        match serde_json::from_str(&encoded) {
14501                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
14502                            Err(error) => {
14503                                dlg.response_json_decode_error(&encoded, &error);
14504                                return Err(common::Error::JsonDecodeError(
14505                                    encoded.to_string(),
14506                                    error,
14507                                ));
14508                            }
14509                        }
14510                    };
14511
14512                    dlg.finished(true);
14513                    return Ok(response);
14514                }
14515            }
14516        }
14517    }
14518
14519    /// The id of the user setting.
14520    ///
14521    /// Sets the *setting* path property to the given value.
14522    ///
14523    /// Even though the property as already been set when instantiating this call,
14524    /// we provide this method for API completeness.
14525    pub fn setting(mut self, new_value: &str) -> SettingGetCall<'a, C> {
14526        self._setting = new_value.to_string();
14527        self
14528    }
14529    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
14530    /// while executing the actual API request.
14531    ///
14532    /// ````text
14533    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
14534    /// ````
14535    ///
14536    /// Sets the *delegate* property to the given value.
14537    pub fn delegate(mut self, new_value: &'a mut dyn common::Delegate) -> SettingGetCall<'a, C> {
14538        self._delegate = Some(new_value);
14539        self
14540    }
14541
14542    /// Set any additional parameter of the query string used in the request.
14543    /// It should be used to set parameters which are not yet available through their own
14544    /// setters.
14545    ///
14546    /// Please note that this method must not be used to set any of the known parameters
14547    /// which have their own setter method. If done anyway, the request will fail.
14548    ///
14549    /// # Additional Parameters
14550    ///
14551    /// * *alt* (query-string) - Data format for the response.
14552    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
14553    /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
14554    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
14555    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
14556    /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
14557    /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
14558    pub fn param<T>(mut self, name: T, value: T) -> SettingGetCall<'a, C>
14559    where
14560        T: AsRef<str>,
14561    {
14562        self._additional_params
14563            .insert(name.as_ref().to_string(), value.as_ref().to_string());
14564        self
14565    }
14566
14567    /// Identifies the authorization scope for the method you are building.
14568    ///
14569    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
14570    /// [`Scope::Readonly`].
14571    ///
14572    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
14573    /// tokens for more than one scope.
14574    ///
14575    /// Usually there is more than one suitable scope to authorize an operation, some of which may
14576    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
14577    /// sufficient, a read-write scope will do as well.
14578    pub fn add_scope<St>(mut self, scope: St) -> SettingGetCall<'a, C>
14579    where
14580        St: AsRef<str>,
14581    {
14582        self._scopes.insert(String::from(scope.as_ref()));
14583        self
14584    }
14585    /// Identifies the authorization scope(s) for the method you are building.
14586    ///
14587    /// See [`Self::add_scope()`] for details.
14588    pub fn add_scopes<I, St>(mut self, scopes: I) -> SettingGetCall<'a, C>
14589    where
14590        I: IntoIterator<Item = St>,
14591        St: AsRef<str>,
14592    {
14593        self._scopes
14594            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
14595        self
14596    }
14597
14598    /// Removes all scopes, and no default scope will be used either.
14599    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
14600    /// for details).
14601    pub fn clear_scopes(mut self) -> SettingGetCall<'a, C> {
14602        self._scopes.clear();
14603        self
14604    }
14605}
14606
14607/// Returns all user settings for the authenticated user.
14608///
14609/// A builder for the *list* method supported by a *setting* resource.
14610/// It is not used directly, but through a [`SettingMethods`] instance.
14611///
14612/// # Example
14613///
14614/// Instantiate a resource method builder
14615///
14616/// ```test_harness,no_run
14617/// # extern crate hyper;
14618/// # extern crate hyper_rustls;
14619/// # extern crate google_calendar3 as calendar3;
14620/// # async fn dox() {
14621/// # use calendar3::{CalendarHub, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
14622///
14623/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
14624/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
14625/// #     secret,
14626/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
14627/// # ).build().await.unwrap();
14628///
14629/// # let client = hyper_util::client::legacy::Client::builder(
14630/// #     hyper_util::rt::TokioExecutor::new()
14631/// # )
14632/// # .build(
14633/// #     hyper_rustls::HttpsConnectorBuilder::new()
14634/// #         .with_native_roots()
14635/// #         .unwrap()
14636/// #         .https_or_http()
14637/// #         .enable_http1()
14638/// #         .build()
14639/// # );
14640/// # let mut hub = CalendarHub::new(client, auth);
14641/// // You can configure optional parameters by calling the respective setters at will, and
14642/// // execute the final call using `doit()`.
14643/// // Values shown here are possibly random and not representative !
14644/// let result = hub.settings().list()
14645///              .sync_token("amet")
14646///              .page_token("ut")
14647///              .max_results(-27)
14648///              .doit().await;
14649/// # }
14650/// ```
14651pub struct SettingListCall<'a, C>
14652where
14653    C: 'a,
14654{
14655    hub: &'a CalendarHub<C>,
14656    _sync_token: Option<String>,
14657    _page_token: Option<String>,
14658    _max_results: Option<i32>,
14659    _delegate: Option<&'a mut dyn common::Delegate>,
14660    _additional_params: HashMap<String, String>,
14661    _scopes: BTreeSet<String>,
14662}
14663
14664impl<'a, C> common::CallBuilder for SettingListCall<'a, C> {}
14665
14666impl<'a, C> SettingListCall<'a, C>
14667where
14668    C: common::Connector,
14669{
14670    /// Perform the operation you have build so far.
14671    pub async fn doit(mut self) -> common::Result<(common::Response, Settings)> {
14672        use std::borrow::Cow;
14673        use std::io::{Read, Seek};
14674
14675        use common::{url::Params, ToParts};
14676        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
14677
14678        let mut dd = common::DefaultDelegate;
14679        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
14680        dlg.begin(common::MethodInfo {
14681            id: "calendar.settings.list",
14682            http_method: hyper::Method::GET,
14683        });
14684
14685        for &field in ["alt", "syncToken", "pageToken", "maxResults"].iter() {
14686            if self._additional_params.contains_key(field) {
14687                dlg.finished(false);
14688                return Err(common::Error::FieldClash(field));
14689            }
14690        }
14691
14692        let mut params = Params::with_capacity(5 + self._additional_params.len());
14693        if let Some(value) = self._sync_token.as_ref() {
14694            params.push("syncToken", value);
14695        }
14696        if let Some(value) = self._page_token.as_ref() {
14697            params.push("pageToken", value);
14698        }
14699        if let Some(value) = self._max_results.as_ref() {
14700            params.push("maxResults", value.to_string());
14701        }
14702
14703        params.extend(self._additional_params.iter());
14704
14705        params.push("alt", "json");
14706        let mut url = self.hub._base_url.clone() + "users/me/settings";
14707        if self._scopes.is_empty() {
14708            self._scopes.insert(Scope::Readonly.as_ref().to_string());
14709        }
14710
14711        let url = params.parse_with_url(&url);
14712
14713        loop {
14714            let token = match self
14715                .hub
14716                .auth
14717                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
14718                .await
14719            {
14720                Ok(token) => token,
14721                Err(e) => match dlg.token(e) {
14722                    Ok(token) => token,
14723                    Err(e) => {
14724                        dlg.finished(false);
14725                        return Err(common::Error::MissingToken(e));
14726                    }
14727                },
14728            };
14729            let mut req_result = {
14730                let client = &self.hub.client;
14731                dlg.pre_request();
14732                let mut req_builder = hyper::Request::builder()
14733                    .method(hyper::Method::GET)
14734                    .uri(url.as_str())
14735                    .header(USER_AGENT, self.hub._user_agent.clone());
14736
14737                if let Some(token) = token.as_ref() {
14738                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
14739                }
14740
14741                let request = req_builder
14742                    .header(CONTENT_LENGTH, 0_u64)
14743                    .body(common::to_body::<String>(None));
14744
14745                client.request(request.unwrap()).await
14746            };
14747
14748            match req_result {
14749                Err(err) => {
14750                    if let common::Retry::After(d) = dlg.http_error(&err) {
14751                        sleep(d).await;
14752                        continue;
14753                    }
14754                    dlg.finished(false);
14755                    return Err(common::Error::HttpError(err));
14756                }
14757                Ok(res) => {
14758                    let (mut parts, body) = res.into_parts();
14759                    let mut body = common::Body::new(body);
14760                    if !parts.status.is_success() {
14761                        let bytes = common::to_bytes(body).await.unwrap_or_default();
14762                        let error = serde_json::from_str(&common::to_string(&bytes));
14763                        let response = common::to_response(parts, bytes.into());
14764
14765                        if let common::Retry::After(d) =
14766                            dlg.http_failure(&response, error.as_ref().ok())
14767                        {
14768                            sleep(d).await;
14769                            continue;
14770                        }
14771
14772                        dlg.finished(false);
14773
14774                        return Err(match error {
14775                            Ok(value) => common::Error::BadRequest(value),
14776                            _ => common::Error::Failure(response),
14777                        });
14778                    }
14779                    let response = {
14780                        let bytes = common::to_bytes(body).await.unwrap_or_default();
14781                        let encoded = common::to_string(&bytes);
14782                        match serde_json::from_str(&encoded) {
14783                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
14784                            Err(error) => {
14785                                dlg.response_json_decode_error(&encoded, &error);
14786                                return Err(common::Error::JsonDecodeError(
14787                                    encoded.to_string(),
14788                                    error,
14789                                ));
14790                            }
14791                        }
14792                    };
14793
14794                    dlg.finished(true);
14795                    return Ok(response);
14796                }
14797            }
14798        }
14799    }
14800
14801    /// 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.
14802    /// 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.
14803    /// Learn more about incremental synchronization.
14804    /// Optional. The default is to return all entries.
14805    ///
14806    /// Sets the *sync token* query property to the given value.
14807    pub fn sync_token(mut self, new_value: &str) -> SettingListCall<'a, C> {
14808        self._sync_token = Some(new_value.to_string());
14809        self
14810    }
14811    /// Token specifying which result page to return. Optional.
14812    ///
14813    /// Sets the *page token* query property to the given value.
14814    pub fn page_token(mut self, new_value: &str) -> SettingListCall<'a, C> {
14815        self._page_token = Some(new_value.to_string());
14816        self
14817    }
14818    /// Maximum number of entries returned on one result page. By default the value is 100 entries. The page size can never be larger than 250 entries. Optional.
14819    ///
14820    /// Sets the *max results* query property to the given value.
14821    pub fn max_results(mut self, new_value: i32) -> SettingListCall<'a, C> {
14822        self._max_results = Some(new_value);
14823        self
14824    }
14825    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
14826    /// while executing the actual API request.
14827    ///
14828    /// ````text
14829    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
14830    /// ````
14831    ///
14832    /// Sets the *delegate* property to the given value.
14833    pub fn delegate(mut self, new_value: &'a mut dyn common::Delegate) -> SettingListCall<'a, C> {
14834        self._delegate = Some(new_value);
14835        self
14836    }
14837
14838    /// Set any additional parameter of the query string used in the request.
14839    /// It should be used to set parameters which are not yet available through their own
14840    /// setters.
14841    ///
14842    /// Please note that this method must not be used to set any of the known parameters
14843    /// which have their own setter method. If done anyway, the request will fail.
14844    ///
14845    /// # Additional Parameters
14846    ///
14847    /// * *alt* (query-string) - Data format for the response.
14848    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
14849    /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
14850    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
14851    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
14852    /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
14853    /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
14854    pub fn param<T>(mut self, name: T, value: T) -> SettingListCall<'a, C>
14855    where
14856        T: AsRef<str>,
14857    {
14858        self._additional_params
14859            .insert(name.as_ref().to_string(), value.as_ref().to_string());
14860        self
14861    }
14862
14863    /// Identifies the authorization scope for the method you are building.
14864    ///
14865    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
14866    /// [`Scope::Readonly`].
14867    ///
14868    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
14869    /// tokens for more than one scope.
14870    ///
14871    /// Usually there is more than one suitable scope to authorize an operation, some of which may
14872    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
14873    /// sufficient, a read-write scope will do as well.
14874    pub fn add_scope<St>(mut self, scope: St) -> SettingListCall<'a, C>
14875    where
14876        St: AsRef<str>,
14877    {
14878        self._scopes.insert(String::from(scope.as_ref()));
14879        self
14880    }
14881    /// Identifies the authorization scope(s) for the method you are building.
14882    ///
14883    /// See [`Self::add_scope()`] for details.
14884    pub fn add_scopes<I, St>(mut self, scopes: I) -> SettingListCall<'a, C>
14885    where
14886        I: IntoIterator<Item = St>,
14887        St: AsRef<str>,
14888    {
14889        self._scopes
14890            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
14891        self
14892    }
14893
14894    /// Removes all scopes, and no default scope will be used either.
14895    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
14896    /// for details).
14897    pub fn clear_scopes(mut self) -> SettingListCall<'a, C> {
14898        self._scopes.clear();
14899        self
14900    }
14901}
14902
14903/// Watch for changes to Settings resources.
14904///
14905/// A builder for the *watch* method supported by a *setting* resource.
14906/// It is not used directly, but through a [`SettingMethods`] instance.
14907///
14908/// # Example
14909///
14910/// Instantiate a resource method builder
14911///
14912/// ```test_harness,no_run
14913/// # extern crate hyper;
14914/// # extern crate hyper_rustls;
14915/// # extern crate google_calendar3 as calendar3;
14916/// use calendar3::api::Channel;
14917/// # async fn dox() {
14918/// # use calendar3::{CalendarHub, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
14919///
14920/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
14921/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
14922/// #     secret,
14923/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
14924/// # ).build().await.unwrap();
14925///
14926/// # let client = hyper_util::client::legacy::Client::builder(
14927/// #     hyper_util::rt::TokioExecutor::new()
14928/// # )
14929/// # .build(
14930/// #     hyper_rustls::HttpsConnectorBuilder::new()
14931/// #         .with_native_roots()
14932/// #         .unwrap()
14933/// #         .https_or_http()
14934/// #         .enable_http1()
14935/// #         .build()
14936/// # );
14937/// # let mut hub = CalendarHub::new(client, auth);
14938/// // As the method needs a request, you would usually fill it with the desired information
14939/// // into the respective structure. Some of the parts shown here might not be applicable !
14940/// // Values shown here are possibly random and not representative !
14941/// let mut req = Channel::default();
14942///
14943/// // You can configure optional parameters by calling the respective setters at will, and
14944/// // execute the final call using `doit()`.
14945/// // Values shown here are possibly random and not representative !
14946/// let result = hub.settings().watch(req)
14947///              .sync_token("sit")
14948///              .page_token("vero")
14949///              .max_results(-20)
14950///              .doit().await;
14951/// # }
14952/// ```
14953pub struct SettingWatchCall<'a, C>
14954where
14955    C: 'a,
14956{
14957    hub: &'a CalendarHub<C>,
14958    _request: Channel,
14959    _sync_token: Option<String>,
14960    _page_token: Option<String>,
14961    _max_results: Option<i32>,
14962    _delegate: Option<&'a mut dyn common::Delegate>,
14963    _additional_params: HashMap<String, String>,
14964    _scopes: BTreeSet<String>,
14965}
14966
14967impl<'a, C> common::CallBuilder for SettingWatchCall<'a, C> {}
14968
14969impl<'a, C> SettingWatchCall<'a, C>
14970where
14971    C: common::Connector,
14972{
14973    /// Perform the operation you have build so far.
14974    pub async fn doit(mut self) -> common::Result<(common::Response, Channel)> {
14975        use std::borrow::Cow;
14976        use std::io::{Read, Seek};
14977
14978        use common::{url::Params, ToParts};
14979        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
14980
14981        let mut dd = common::DefaultDelegate;
14982        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
14983        dlg.begin(common::MethodInfo {
14984            id: "calendar.settings.watch",
14985            http_method: hyper::Method::POST,
14986        });
14987
14988        for &field in ["alt", "syncToken", "pageToken", "maxResults"].iter() {
14989            if self._additional_params.contains_key(field) {
14990                dlg.finished(false);
14991                return Err(common::Error::FieldClash(field));
14992            }
14993        }
14994
14995        let mut params = Params::with_capacity(6 + self._additional_params.len());
14996        if let Some(value) = self._sync_token.as_ref() {
14997            params.push("syncToken", value);
14998        }
14999        if let Some(value) = self._page_token.as_ref() {
15000            params.push("pageToken", value);
15001        }
15002        if let Some(value) = self._max_results.as_ref() {
15003            params.push("maxResults", value.to_string());
15004        }
15005
15006        params.extend(self._additional_params.iter());
15007
15008        params.push("alt", "json");
15009        let mut url = self.hub._base_url.clone() + "users/me/settings/watch";
15010        if self._scopes.is_empty() {
15011            self._scopes.insert(Scope::Full.as_ref().to_string());
15012        }
15013
15014        let url = params.parse_with_url(&url);
15015
15016        let mut json_mime_type = mime::APPLICATION_JSON;
15017        let mut request_value_reader = {
15018            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
15019            common::remove_json_null_values(&mut value);
15020            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
15021            serde_json::to_writer(&mut dst, &value).unwrap();
15022            dst
15023        };
15024        let request_size = request_value_reader
15025            .seek(std::io::SeekFrom::End(0))
15026            .unwrap();
15027        request_value_reader
15028            .seek(std::io::SeekFrom::Start(0))
15029            .unwrap();
15030
15031        loop {
15032            let token = match self
15033                .hub
15034                .auth
15035                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
15036                .await
15037            {
15038                Ok(token) => token,
15039                Err(e) => match dlg.token(e) {
15040                    Ok(token) => token,
15041                    Err(e) => {
15042                        dlg.finished(false);
15043                        return Err(common::Error::MissingToken(e));
15044                    }
15045                },
15046            };
15047            request_value_reader
15048                .seek(std::io::SeekFrom::Start(0))
15049                .unwrap();
15050            let mut req_result = {
15051                let client = &self.hub.client;
15052                dlg.pre_request();
15053                let mut req_builder = hyper::Request::builder()
15054                    .method(hyper::Method::POST)
15055                    .uri(url.as_str())
15056                    .header(USER_AGENT, self.hub._user_agent.clone());
15057
15058                if let Some(token) = token.as_ref() {
15059                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
15060                }
15061
15062                let request = req_builder
15063                    .header(CONTENT_TYPE, json_mime_type.to_string())
15064                    .header(CONTENT_LENGTH, request_size as u64)
15065                    .body(common::to_body(
15066                        request_value_reader.get_ref().clone().into(),
15067                    ));
15068
15069                client.request(request.unwrap()).await
15070            };
15071
15072            match req_result {
15073                Err(err) => {
15074                    if let common::Retry::After(d) = dlg.http_error(&err) {
15075                        sleep(d).await;
15076                        continue;
15077                    }
15078                    dlg.finished(false);
15079                    return Err(common::Error::HttpError(err));
15080                }
15081                Ok(res) => {
15082                    let (mut parts, body) = res.into_parts();
15083                    let mut body = common::Body::new(body);
15084                    if !parts.status.is_success() {
15085                        let bytes = common::to_bytes(body).await.unwrap_or_default();
15086                        let error = serde_json::from_str(&common::to_string(&bytes));
15087                        let response = common::to_response(parts, bytes.into());
15088
15089                        if let common::Retry::After(d) =
15090                            dlg.http_failure(&response, error.as_ref().ok())
15091                        {
15092                            sleep(d).await;
15093                            continue;
15094                        }
15095
15096                        dlg.finished(false);
15097
15098                        return Err(match error {
15099                            Ok(value) => common::Error::BadRequest(value),
15100                            _ => common::Error::Failure(response),
15101                        });
15102                    }
15103                    let response = {
15104                        let bytes = common::to_bytes(body).await.unwrap_or_default();
15105                        let encoded = common::to_string(&bytes);
15106                        match serde_json::from_str(&encoded) {
15107                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
15108                            Err(error) => {
15109                                dlg.response_json_decode_error(&encoded, &error);
15110                                return Err(common::Error::JsonDecodeError(
15111                                    encoded.to_string(),
15112                                    error,
15113                                ));
15114                            }
15115                        }
15116                    };
15117
15118                    dlg.finished(true);
15119                    return Ok(response);
15120                }
15121            }
15122        }
15123    }
15124
15125    ///
15126    /// Sets the *request* property to the given value.
15127    ///
15128    /// Even though the property as already been set when instantiating this call,
15129    /// we provide this method for API completeness.
15130    pub fn request(mut self, new_value: Channel) -> SettingWatchCall<'a, C> {
15131        self._request = new_value;
15132        self
15133    }
15134    /// 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.
15135    /// 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.
15136    /// Learn more about incremental synchronization.
15137    /// Optional. The default is to return all entries.
15138    ///
15139    /// Sets the *sync token* query property to the given value.
15140    pub fn sync_token(mut self, new_value: &str) -> SettingWatchCall<'a, C> {
15141        self._sync_token = Some(new_value.to_string());
15142        self
15143    }
15144    /// Token specifying which result page to return. Optional.
15145    ///
15146    /// Sets the *page token* query property to the given value.
15147    pub fn page_token(mut self, new_value: &str) -> SettingWatchCall<'a, C> {
15148        self._page_token = Some(new_value.to_string());
15149        self
15150    }
15151    /// Maximum number of entries returned on one result page. By default the value is 100 entries. The page size can never be larger than 250 entries. Optional.
15152    ///
15153    /// Sets the *max results* query property to the given value.
15154    pub fn max_results(mut self, new_value: i32) -> SettingWatchCall<'a, C> {
15155        self._max_results = Some(new_value);
15156        self
15157    }
15158    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
15159    /// while executing the actual API request.
15160    ///
15161    /// ````text
15162    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
15163    /// ````
15164    ///
15165    /// Sets the *delegate* property to the given value.
15166    pub fn delegate(mut self, new_value: &'a mut dyn common::Delegate) -> SettingWatchCall<'a, C> {
15167        self._delegate = Some(new_value);
15168        self
15169    }
15170
15171    /// Set any additional parameter of the query string used in the request.
15172    /// It should be used to set parameters which are not yet available through their own
15173    /// setters.
15174    ///
15175    /// Please note that this method must not be used to set any of the known parameters
15176    /// which have their own setter method. If done anyway, the request will fail.
15177    ///
15178    /// # Additional Parameters
15179    ///
15180    /// * *alt* (query-string) - Data format for the response.
15181    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
15182    /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
15183    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
15184    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
15185    /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
15186    /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
15187    pub fn param<T>(mut self, name: T, value: T) -> SettingWatchCall<'a, C>
15188    where
15189        T: AsRef<str>,
15190    {
15191        self._additional_params
15192            .insert(name.as_ref().to_string(), value.as_ref().to_string());
15193        self
15194    }
15195
15196    /// Identifies the authorization scope for the method you are building.
15197    ///
15198    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
15199    /// [`Scope::Full`].
15200    ///
15201    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
15202    /// tokens for more than one scope.
15203    ///
15204    /// Usually there is more than one suitable scope to authorize an operation, some of which may
15205    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
15206    /// sufficient, a read-write scope will do as well.
15207    pub fn add_scope<St>(mut self, scope: St) -> SettingWatchCall<'a, C>
15208    where
15209        St: AsRef<str>,
15210    {
15211        self._scopes.insert(String::from(scope.as_ref()));
15212        self
15213    }
15214    /// Identifies the authorization scope(s) for the method you are building.
15215    ///
15216    /// See [`Self::add_scope()`] for details.
15217    pub fn add_scopes<I, St>(mut self, scopes: I) -> SettingWatchCall<'a, C>
15218    where
15219        I: IntoIterator<Item = St>,
15220        St: AsRef<str>,
15221    {
15222        self._scopes
15223            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
15224        self
15225    }
15226
15227    /// Removes all scopes, and no default scope will be used either.
15228    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
15229    /// for details).
15230    pub fn clear_scopes(mut self) -> SettingWatchCall<'a, C> {
15231        self._scopes.clear();
15232        self
15233    }
15234}