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 /// See and change the sharing permissions of Google calendars you own
20 Acl,
21
22 /// See the sharing permissions of Google calendars you own
23 AclReadonly,
24
25 /// Make secondary Google calendars, and see, create, change, and delete events on them
26 AppCreated,
27
28 /// See, add, and remove Google calendars you’re subscribed to
29 Calendarlist,
30
31 /// See the list of Google calendars you’re subscribed to
32 CalendarlistReadonly,
33
34 /// See and change the properties of Google calendars you have access to, and create secondary calendars
35 Calendar,
36
37 /// See the title, description, default time zone, and other properties of Google calendars you have access to
38 CalendarReadonly,
39
40 /// View and edit events on all your calendars
41 Event,
42
43 /// See the availability on Google calendars you have access to
44 EventFreebusy,
45
46 /// See, create, change, and delete events on Google calendars you own
47 EventOwned,
48
49 /// See the events on Google calendars you own
50 EventOwnedReadonly,
51
52 /// See the events on public calendars
53 EventPublicReadonly,
54
55 /// View events on all your calendars
56 EventReadonly,
57
58 /// View your availability in your calendars
59 Freebusy,
60
61 /// See and download any calendar you can access using your Google Calendar
62 Readonly,
63
64 /// View your Calendar settings
65 SettingReadonly,
66}
67
68impl AsRef<str> for Scope {
69 fn as_ref(&self) -> &str {
70 match *self {
71 Scope::Full => "https://www.googleapis.com/auth/calendar",
72 Scope::Acl => "https://www.googleapis.com/auth/calendar.acls",
73 Scope::AclReadonly => "https://www.googleapis.com/auth/calendar.acls.readonly",
74 Scope::AppCreated => "https://www.googleapis.com/auth/calendar.app.created",
75 Scope::Calendarlist => "https://www.googleapis.com/auth/calendar.calendarlist",
76 Scope::CalendarlistReadonly => {
77 "https://www.googleapis.com/auth/calendar.calendarlist.readonly"
78 }
79 Scope::Calendar => "https://www.googleapis.com/auth/calendar.calendars",
80 Scope::CalendarReadonly => {
81 "https://www.googleapis.com/auth/calendar.calendars.readonly"
82 }
83 Scope::Event => "https://www.googleapis.com/auth/calendar.events",
84 Scope::EventFreebusy => "https://www.googleapis.com/auth/calendar.events.freebusy",
85 Scope::EventOwned => "https://www.googleapis.com/auth/calendar.events.owned",
86 Scope::EventOwnedReadonly => {
87 "https://www.googleapis.com/auth/calendar.events.owned.readonly"
88 }
89 Scope::EventPublicReadonly => {
90 "https://www.googleapis.com/auth/calendar.events.public.readonly"
91 }
92 Scope::EventReadonly => "https://www.googleapis.com/auth/calendar.events.readonly",
93 Scope::Freebusy => "https://www.googleapis.com/auth/calendar.freebusy",
94 Scope::Readonly => "https://www.googleapis.com/auth/calendar.readonly",
95 Scope::SettingReadonly => "https://www.googleapis.com/auth/calendar.settings.readonly",
96 }
97 }
98}
99
100#[allow(clippy::derivable_impls)]
101impl Default for Scope {
102 fn default() -> Scope {
103 Scope::AclReadonly
104 }
105}
106
107// ########
108// HUB ###
109// ######
110
111/// Central instance to access all CalendarHub related resource activities
112///
113/// # Examples
114///
115/// Instantiate a new hub
116///
117/// ```test_harness,no_run
118/// extern crate hyper;
119/// extern crate hyper_rustls;
120/// extern crate google_calendar3 as calendar3;
121/// use calendar3::api::Channel;
122/// use calendar3::{Result, Error};
123/// # async fn dox() {
124/// use calendar3::{CalendarHub, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
125///
126/// // Get an ApplicationSecret instance by some means. It contains the `client_id` and
127/// // `client_secret`, among other things.
128/// let secret: yup_oauth2::ApplicationSecret = Default::default();
129/// // Instantiate the authenticator. It will choose a suitable authentication flow for you,
130/// // unless you replace `None` with the desired Flow.
131/// // Provide your own `AuthenticatorDelegate` to adjust the way it operates and get feedback about
132/// // what's going on. You probably want to bring in your own `TokenStorage` to persist tokens and
133/// // retrieve them from storage.
134/// let connector = hyper_rustls::HttpsConnectorBuilder::new()
135/// .with_native_roots()
136/// .unwrap()
137/// .https_only()
138/// .enable_http2()
139/// .build();
140///
141/// let executor = hyper_util::rt::TokioExecutor::new();
142/// let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
143/// secret,
144/// yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
145/// yup_oauth2::client::CustomHyperClientBuilder::from(
146/// hyper_util::client::legacy::Client::builder(executor).build(connector),
147/// ),
148/// ).build().await.unwrap();
149///
150/// let client = hyper_util::client::legacy::Client::builder(
151/// hyper_util::rt::TokioExecutor::new()
152/// )
153/// .build(
154/// hyper_rustls::HttpsConnectorBuilder::new()
155/// .with_native_roots()
156/// .unwrap()
157/// .https_or_http()
158/// .enable_http2()
159/// .build()
160/// );
161/// let mut hub = CalendarHub::new(client, auth);
162/// // As the method needs a request, you would usually fill it with the desired information
163/// // into the respective structure. Some of the parts shown here might not be applicable !
164/// // Values shown here are possibly random and not representative !
165/// let mut req = Channel::default();
166///
167/// // You can configure optional parameters by calling the respective setters at will, and
168/// // execute the final call using `doit()`.
169/// // Values shown here are possibly random and not representative !
170/// let result = hub.events().watch(req, "calendarId")
171/// .updated_min(chrono::Utc::now())
172/// .time_zone("sed")
173/// .time_min(chrono::Utc::now())
174/// .time_max(chrono::Utc::now())
175/// .sync_token("no")
176/// .single_events(true)
177/// .show_hidden_invitations(true)
178/// .show_deleted(false)
179/// .add_shared_extended_property("erat")
180/// .q("sed")
181/// .add_private_extended_property("duo")
182/// .page_token("dolore")
183/// .order_by("et")
184/// .max_results(-28)
185/// .max_attendees(-2)
186/// .i_cal_uid("consetetur")
187/// .add_event_types("diam")
188/// .always_include_email(true)
189/// .doit().await;
190///
191/// match result {
192/// Err(e) => match e {
193/// // The Error enum provides details about what exactly happened.
194/// // You can also just use its `Debug`, `Display` or `Error` traits
195/// Error::HttpError(_)
196/// |Error::Io(_)
197/// |Error::MissingAPIKey
198/// |Error::MissingToken(_)
199/// |Error::Cancelled
200/// |Error::UploadSizeLimitExceeded(_, _)
201/// |Error::Failure(_)
202/// |Error::BadRequest(_)
203/// |Error::FieldClash(_)
204/// |Error::JsonDecodeError(_, _) => println!("{}", e),
205/// },
206/// Ok(res) => println!("Success: {:?}", res),
207/// }
208/// # }
209/// ```
210#[derive(Clone)]
211pub struct CalendarHub<C> {
212 pub client: common::Client<C>,
213 pub auth: Box<dyn common::GetToken>,
214 _user_agent: String,
215 _base_url: String,
216 _root_url: String,
217}
218
219impl<C> common::Hub for CalendarHub<C> {}
220
221impl<'a, C> CalendarHub<C> {
222 pub fn new<A: 'static + common::GetToken>(
223 client: common::Client<C>,
224 auth: A,
225 ) -> CalendarHub<C> {
226 CalendarHub {
227 client,
228 auth: Box::new(auth),
229 _user_agent: "google-api-rust-client/7.0.0".to_string(),
230 _base_url: "https://www.googleapis.com/calendar/v3/".to_string(),
231 _root_url: "https://www.googleapis.com/".to_string(),
232 }
233 }
234
235 pub fn acl(&'a self) -> AclMethods<'a, C> {
236 AclMethods { hub: self }
237 }
238 pub fn calendar_list(&'a self) -> CalendarListMethods<'a, C> {
239 CalendarListMethods { hub: self }
240 }
241 pub fn calendars(&'a self) -> CalendarMethods<'a, C> {
242 CalendarMethods { hub: self }
243 }
244 pub fn channels(&'a self) -> ChannelMethods<'a, C> {
245 ChannelMethods { hub: self }
246 }
247 pub fn colors(&'a self) -> ColorMethods<'a, C> {
248 ColorMethods { hub: self }
249 }
250 pub fn events(&'a self) -> EventMethods<'a, C> {
251 EventMethods { hub: self }
252 }
253 pub fn freebusy(&'a self) -> FreebusyMethods<'a, C> {
254 FreebusyMethods { hub: self }
255 }
256 pub fn settings(&'a self) -> SettingMethods<'a, C> {
257 SettingMethods { hub: self }
258 }
259
260 /// Set the user-agent header field to use in all requests to the server.
261 /// It defaults to `google-api-rust-client/7.0.0`.
262 ///
263 /// Returns the previously set user-agent.
264 pub fn user_agent(&mut self, agent_name: String) -> String {
265 std::mem::replace(&mut self._user_agent, agent_name)
266 }
267
268 /// Set the base url to use in all requests to the server.
269 /// It defaults to `https://www.googleapis.com/calendar/v3/`.
270 ///
271 /// Returns the previously set base url.
272 pub fn base_url(&mut self, new_base_url: String) -> String {
273 std::mem::replace(&mut self._base_url, new_base_url)
274 }
275
276 /// Set the root url to use in all requests to the server.
277 /// It defaults to `https://www.googleapis.com/`.
278 ///
279 /// Returns the previously set root url.
280 pub fn root_url(&mut self, new_root_url: String) -> String {
281 std::mem::replace(&mut self._root_url, new_root_url)
282 }
283}
284
285// ############
286// SCHEMAS ###
287// ##########
288/// There is no detailed description.
289///
290/// # Activities
291///
292/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
293/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
294///
295/// * [list acl](AclListCall) (response)
296#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
297#[serde_with::serde_as]
298#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
299pub struct Acl {
300 /// ETag of the collection.
301 pub etag: Option<String>,
302 /// List of rules on the access control list.
303 pub items: Option<Vec<AclRule>>,
304 /// Type of the collection ("calendar#acl").
305 pub kind: Option<String>,
306 /// Token used to access the next page of this result. Omitted if no further results are available, in which case nextSyncToken is provided.
307 #[serde(rename = "nextPageToken")]
308 pub next_page_token: Option<String>,
309 /// 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.
310 #[serde(rename = "nextSyncToken")]
311 pub next_sync_token: Option<String>,
312}
313
314impl common::ResponseResult for Acl {}
315
316/// There is no detailed description.
317///
318/// # Activities
319///
320/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
321/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
322///
323/// * [get acl](AclGetCall) (response)
324/// * [insert acl](AclInsertCall) (request|response)
325/// * [patch acl](AclPatchCall) (request|response)
326/// * [update acl](AclUpdateCall) (request|response)
327#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
328#[serde_with::serde_as]
329#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
330pub struct AclRule {
331 /// ETag of the resource.
332 pub etag: Option<String>,
333 /// Identifier of the Access Control List (ACL) rule. See Sharing calendars.
334 pub id: Option<String>,
335 /// Type of the resource ("calendar#aclRule").
336 pub kind: Option<String>,
337 /// The role assigned to the scope. Possible values are:
338 /// - "none" - Provides no access.
339 /// - "freeBusyReader" - Provides read access to free/busy information.
340 /// - "reader" - Provides read access to the calendar. Private events will appear to users with reader access, but event details will be hidden.
341 /// - "writer" - Provides read and write access to the calendar. Private events will appear to users with writer access, and event details will be visible. Provides read access to the calendar's ACLs.
342 /// - "owner" - Provides manager access to the calendar. This role has all of the permissions of the writer role with the additional ability to modify access levels of other users.
343 /// Important: the owner role is different from the calendar's data owner. A calendar has a single data owner, but can have multiple users with owner role.
344 pub role: Option<String>,
345 /// The extent to which calendar access is granted by this ACL rule.
346 pub scope: Option<AclRuleScope>,
347}
348
349impl common::RequestValue for AclRule {}
350impl common::ResponseResult for AclRule {}
351
352/// There is no detailed description.
353///
354/// # Activities
355///
356/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
357/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
358///
359/// * [clear calendars](CalendarClearCall) (none)
360/// * [delete calendars](CalendarDeleteCall) (none)
361/// * [get calendars](CalendarGetCall) (response)
362/// * [insert calendars](CalendarInsertCall) (request|response)
363/// * [patch calendars](CalendarPatchCall) (request|response)
364/// * [update calendars](CalendarUpdateCall) (request|response)
365#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
366#[serde_with::serde_as]
367#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
368pub struct Calendar {
369 /// Whether this calendar automatically accepts invitations. Only valid for resource calendars.
370 #[serde(rename = "autoAcceptInvitations")]
371 pub auto_accept_invitations: Option<bool>,
372 /// Conferencing properties for this calendar, for example what types of conferences are allowed.
373 #[serde(rename = "conferenceProperties")]
374 pub conference_properties: Option<ConferenceProperties>,
375 /// The email of the owner of the calendar. Set only for secondary calendars. Read-only.
376 #[serde(rename = "dataOwner")]
377 pub data_owner: Option<String>,
378 /// Description of the calendar. Optional.
379 pub description: Option<String>,
380 /// ETag of the resource.
381 pub etag: Option<String>,
382 /// Identifier of the calendar. To retrieve IDs call the calendarList.list() method.
383 pub id: Option<String>,
384 /// Type of the resource ("calendar#calendar").
385 pub kind: Option<String>,
386 /// Geographic location of the calendar as free-form text. Optional.
387 pub location: Option<String>,
388 /// Title of the calendar.
389 pub summary: Option<String>,
390 /// The time zone of the calendar. (Formatted as an IANA Time Zone Database name, e.g. "Europe/Zurich".) Optional.
391 #[serde(rename = "timeZone")]
392 pub time_zone: Option<String>,
393}
394
395impl common::RequestValue for Calendar {}
396impl common::Resource for Calendar {}
397impl common::ResponseResult for Calendar {}
398
399/// There is no detailed description.
400///
401/// # Activities
402///
403/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
404/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
405///
406/// * [list calendar list](CalendarListListCall) (response)
407#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
408#[serde_with::serde_as]
409#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
410pub struct CalendarList {
411 /// ETag of the collection.
412 pub etag: Option<String>,
413 /// Calendars that are present on the user's calendar list.
414 pub items: Option<Vec<CalendarListEntry>>,
415 /// Type of the collection ("calendar#calendarList").
416 pub kind: Option<String>,
417 /// Token used to access the next page of this result. Omitted if no further results are available, in which case nextSyncToken is provided.
418 #[serde(rename = "nextPageToken")]
419 pub next_page_token: Option<String>,
420 /// 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.
421 #[serde(rename = "nextSyncToken")]
422 pub next_sync_token: Option<String>,
423}
424
425impl common::ResponseResult for CalendarList {}
426
427/// There is no detailed description.
428///
429/// # Activities
430///
431/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
432/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
433///
434/// * [get calendar list](CalendarListGetCall) (response)
435/// * [insert calendar list](CalendarListInsertCall) (request|response)
436/// * [patch calendar list](CalendarListPatchCall) (request|response)
437/// * [update calendar list](CalendarListUpdateCall) (request|response)
438#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
439#[serde_with::serde_as]
440#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
441pub struct CalendarListEntry {
442 /// The effective access role that the authenticated user has on the calendar. Read-only. Possible values are:
443 /// - "freeBusyReader" - Provides read access to free/busy information.
444 /// - "reader" - Provides read access to the calendar. Private events will appear to users with reader access, but event details will be hidden.
445 /// - "writer" - Provides read and write access to the calendar. Private events will appear to users with writer access, and event details will be visible.
446 /// - "owner" - Provides manager access to the calendar. This role has all of the permissions of the writer role with the additional ability to see and modify access levels of other users.
447 /// Important: the owner role is different from the calendar's data owner. A calendar has a single data owner, but can have multiple users with owner role.
448 #[serde(rename = "accessRole")]
449 pub access_role: Option<String>,
450 /// Whether this calendar automatically accepts invitations. Only valid for resource calendars. Read-only.
451 #[serde(rename = "autoAcceptInvitations")]
452 pub auto_accept_invitations: Option<bool>,
453 /// 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.
454 #[serde(rename = "backgroundColor")]
455 pub background_color: Option<String>,
456 /// 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.
457 #[serde(rename = "colorId")]
458 pub color_id: Option<String>,
459 /// Conferencing properties for this calendar, for example what types of conferences are allowed.
460 #[serde(rename = "conferenceProperties")]
461 pub conference_properties: Option<ConferenceProperties>,
462 /// The email of the owner of the calendar. Set only for secondary calendars. Read-only.
463 #[serde(rename = "dataOwner")]
464 pub data_owner: Option<String>,
465 /// The default reminders that the authenticated user has for this calendar.
466 #[serde(rename = "defaultReminders")]
467 pub default_reminders: Option<Vec<EventReminder>>,
468 /// Whether this calendar list entry has been deleted from the calendar list. Read-only. Optional. The default is False.
469 pub deleted: Option<bool>,
470 /// Description of the calendar. Optional. Read-only.
471 pub description: Option<String>,
472 /// ETag of the resource.
473 pub etag: Option<String>,
474 /// 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.
475 #[serde(rename = "foregroundColor")]
476 pub foreground_color: Option<String>,
477 /// 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.
478 pub hidden: Option<bool>,
479 /// Identifier of the calendar.
480 pub id: Option<String>,
481 /// Type of the resource ("calendar#calendarListEntry").
482 pub kind: Option<String>,
483 /// Geographic location of the calendar as free-form text. Optional. Read-only.
484 pub location: Option<String>,
485 /// The notifications that the authenticated user is receiving for this calendar.
486 #[serde(rename = "notificationSettings")]
487 pub notification_settings: Option<CalendarListEntryNotificationSettings>,
488 /// Whether the calendar is the primary calendar of the authenticated user. Read-only. Optional. The default is False.
489 pub primary: Option<bool>,
490 /// Whether the calendar content shows up in the calendar UI. Optional. The default is False.
491 pub selected: Option<bool>,
492 /// Title of the calendar. Read-only.
493 pub summary: Option<String>,
494 /// The summary that the authenticated user has set for this calendar. Optional.
495 #[serde(rename = "summaryOverride")]
496 pub summary_override: Option<String>,
497 /// The time zone of the calendar. Optional. Read-only.
498 #[serde(rename = "timeZone")]
499 pub time_zone: Option<String>,
500}
501
502impl common::RequestValue for CalendarListEntry {}
503impl common::ResponseResult for CalendarListEntry {}
504
505/// There is no detailed description.
506///
507/// This type is not used in any activity, and only used as *part* of another schema.
508///
509#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
510#[serde_with::serde_as]
511#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
512pub struct CalendarNotification {
513 /// The method used to deliver the notification. The possible value is:
514 /// - "email" - Notifications are sent via email.
515 /// Required when adding a notification.
516 pub method: Option<String>,
517 /// The type of notification. Possible values are:
518 /// - "eventCreation" - Notification sent when a new event is put on the calendar.
519 /// - "eventChange" - Notification sent when an event is changed.
520 /// - "eventCancellation" - Notification sent when an event is cancelled.
521 /// - "eventResponse" - Notification sent when an attendee responds to the event invitation.
522 /// - "agenda" - An agenda with the events of the day (sent out in the morning).
523 /// Required when adding a notification.
524 #[serde(rename = "type")]
525 pub type_: Option<String>,
526}
527
528impl common::Part for CalendarNotification {}
529
530/// There is no detailed description.
531///
532/// # Activities
533///
534/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
535/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
536///
537/// * [watch acl](AclWatchCall) (request|response)
538/// * [watch calendar list](CalendarListWatchCall) (request|response)
539/// * [stop channels](ChannelStopCall) (request)
540/// * [watch events](EventWatchCall) (request|response)
541/// * [watch settings](SettingWatchCall) (request|response)
542#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
543#[serde_with::serde_as]
544#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
545pub struct Channel {
546 /// The address where notifications are delivered for this channel.
547 pub address: Option<String>,
548 /// Date and time of notification channel expiration, expressed as a Unix timestamp, in milliseconds. Optional.
549 #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
550 pub expiration: Option<i64>,
551 /// A UUID or similar unique string that identifies this channel.
552 pub id: Option<String>,
553 /// Identifies this as a notification channel used to watch for changes to a resource, which is "api#channel".
554 pub kind: Option<String>,
555 /// Additional parameters controlling delivery channel behavior. Optional.
556 pub params: Option<HashMap<String, String>>,
557 /// A Boolean value to indicate whether payload is wanted. Optional.
558 pub payload: Option<bool>,
559 /// An opaque ID that identifies the resource being watched on this channel. Stable across different API versions.
560 #[serde(rename = "resourceId")]
561 pub resource_id: Option<String>,
562 /// A version-specific identifier for the watched resource.
563 #[serde(rename = "resourceUri")]
564 pub resource_uri: Option<String>,
565 /// An arbitrary string delivered to the target address with each notification delivered over this channel. Optional.
566 pub token: Option<String>,
567 /// 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.
568 #[serde(rename = "type")]
569 pub type_: Option<String>,
570}
571
572impl common::RequestValue for Channel {}
573impl common::Resource for Channel {}
574impl common::ResponseResult for Channel {}
575
576/// There is no detailed description.
577///
578/// This type is not used in any activity, and only used as *part* of another schema.
579///
580#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
581#[serde_with::serde_as]
582#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
583pub struct ColorDefinition {
584 /// The background color associated with this color definition.
585 pub background: Option<String>,
586 /// The foreground color that can be used to write on top of a background with 'background' color.
587 pub foreground: Option<String>,
588}
589
590impl common::Part for ColorDefinition {}
591
592/// There is no detailed description.
593///
594/// # Activities
595///
596/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
597/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
598///
599/// * [get colors](ColorGetCall) (response)
600#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
601#[serde_with::serde_as]
602#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
603pub struct Colors {
604 /// 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.
605 pub calendar: Option<HashMap<String, ColorDefinition>>,
606 /// 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.
607 pub event: Option<HashMap<String, ColorDefinition>>,
608 /// Type of the resource ("calendar#colors").
609 pub kind: Option<String>,
610 /// Last modification time of the color palette (as a RFC3339 timestamp). Read-only.
611 pub updated: Option<chrono::DateTime<chrono::offset::Utc>>,
612}
613
614impl common::ResponseResult for Colors {}
615
616/// There is no detailed description.
617///
618/// This type is not used in any activity, and only used as *part* of another schema.
619///
620#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
621#[serde_with::serde_as]
622#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
623pub struct ConferenceData {
624 /// The ID of the conference.
625 /// Can be used by developers to keep track of conferences, should not be displayed to users.
626 /// The ID value is formed differently for each conference solution type:
627 /// - eventHangout: ID is not set. (This conference type is deprecated.)
628 /// - eventNamedHangout: ID is the name of the Hangout. (This conference type is deprecated.)
629 /// - hangoutsMeet: ID is the 10-letter meeting code, for example aaa-bbbb-ccc.
630 /// - addOn: ID is defined by the third-party provider. Optional.
631 #[serde(rename = "conferenceId")]
632 pub conference_id: Option<String>,
633 /// The conference solution, such as Google Meet.
634 /// Unset for a conference with a failed create request.
635 /// Either conferenceSolution and at least one entryPoint, or createRequest is required.
636 #[serde(rename = "conferenceSolution")]
637 pub conference_solution: Option<ConferenceSolution>,
638 /// 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.
639 /// Either conferenceSolution and at least one entryPoint, or createRequest is required.
640 #[serde(rename = "createRequest")]
641 pub create_request: Option<CreateConferenceRequest>,
642 /// Information about individual conference entry points, such as URLs or phone numbers.
643 /// All of them must belong to the same conference.
644 /// Either conferenceSolution and at least one entryPoint, or createRequest is required.
645 #[serde(rename = "entryPoints")]
646 pub entry_points: Option<Vec<EntryPoint>>,
647 /// 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.
648 pub notes: Option<String>,
649 /// Additional properties related to a conference. An example would be a solution-specific setting for enabling video streaming.
650 pub parameters: Option<ConferenceParameters>,
651 /// The signature of the conference data.
652 /// Generated on server side.
653 /// Unset for a conference with a failed create request.
654 /// Optional for a conference with a pending create request.
655 pub signature: Option<String>,
656}
657
658impl common::Part for ConferenceData {}
659
660/// There is no detailed description.
661///
662/// This type is not used in any activity, and only used as *part* of another schema.
663///
664#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
665#[serde_with::serde_as]
666#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
667pub struct ConferenceParameters {
668 /// Additional add-on specific data.
669 #[serde(rename = "addOnParameters")]
670 pub add_on_parameters: Option<ConferenceParametersAddOnParameters>,
671}
672
673impl common::Part for ConferenceParameters {}
674
675/// There is no detailed description.
676///
677/// This type is not used in any activity, and only used as *part* of another schema.
678///
679#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
680#[serde_with::serde_as]
681#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
682pub struct ConferenceParametersAddOnParameters {
683 /// no description provided
684 pub parameters: Option<HashMap<String, String>>,
685}
686
687impl common::Part for ConferenceParametersAddOnParameters {}
688
689/// There is no detailed description.
690///
691/// This type is not used in any activity, and only used as *part* of another schema.
692///
693#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
694#[serde_with::serde_as]
695#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
696pub struct ConferenceProperties {
697 /// The types of conference solutions that are supported for this calendar.
698 /// The possible values are:
699 /// - "eventHangout"
700 /// - "eventNamedHangout"
701 /// - "hangoutsMeet" Optional.
702 #[serde(rename = "allowedConferenceSolutionTypes")]
703 pub allowed_conference_solution_types: Option<Vec<String>>,
704}
705
706impl common::Part for ConferenceProperties {}
707
708/// There is no detailed description.
709///
710/// This type is not used in any activity, and only used as *part* of another schema.
711///
712#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
713#[serde_with::serde_as]
714#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
715pub struct ConferenceRequestStatus {
716 /// The current status of the conference create request. Read-only.
717 /// The possible values are:
718 /// - "pending": the conference create request is still being processed.
719 /// - "success": the conference create request succeeded, the entry points are populated.
720 /// - "failure": the conference create request failed, there are no entry points.
721 #[serde(rename = "statusCode")]
722 pub status_code: Option<String>,
723}
724
725impl common::Part for ConferenceRequestStatus {}
726
727/// There is no detailed description.
728///
729/// This type is not used in any activity, and only used as *part* of another schema.
730///
731#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
732#[serde_with::serde_as]
733#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
734pub struct ConferenceSolution {
735 /// The user-visible icon for this solution.
736 #[serde(rename = "iconUri")]
737 pub icon_uri: Option<String>,
738 /// The key which can uniquely identify the conference solution for this event.
739 pub key: Option<ConferenceSolutionKey>,
740 /// The user-visible name of this solution. Not localized.
741 pub name: Option<String>,
742}
743
744impl common::Part for ConferenceSolution {}
745
746/// There is no detailed description.
747///
748/// This type is not used in any activity, and only used as *part* of another schema.
749///
750#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
751#[serde_with::serde_as]
752#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
753pub struct ConferenceSolutionKey {
754 /// The conference solution type.
755 /// If a client encounters an unfamiliar or empty type, it should still be able to display the entry points. However, it should disallow modifications.
756 /// The possible values are:
757 /// - "eventHangout" for Hangouts for consumers (deprecated; existing events may show this conference solution type but new conferences cannot be created)
758 /// - "eventNamedHangout" for classic Hangouts for Google Workspace users (deprecated; existing events may show this conference solution type but new conferences cannot be created)
759 /// - "hangoutsMeet" for Google Meet (http://meet.google.com)
760 /// - "addOn" for 3P conference providers
761 #[serde(rename = "type")]
762 pub type_: Option<String>,
763}
764
765impl common::Part for ConferenceSolutionKey {}
766
767/// There is no detailed description.
768///
769/// This type is not used in any activity, and only used as *part* of another schema.
770///
771#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
772#[serde_with::serde_as]
773#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
774pub struct CreateConferenceRequest {
775 /// The conference solution, such as Hangouts or Google Meet.
776 #[serde(rename = "conferenceSolutionKey")]
777 pub conference_solution_key: Option<ConferenceSolutionKey>,
778 /// The client-generated unique ID for this request.
779 /// 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.
780 #[serde(rename = "requestId")]
781 pub request_id: Option<String>,
782 /// The status of the conference create request.
783 pub status: Option<ConferenceRequestStatus>,
784}
785
786impl common::Part for CreateConferenceRequest {}
787
788/// There is no detailed description.
789///
790/// This type is not used in any activity, and only used as *part* of another schema.
791///
792#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
793#[serde_with::serde_as]
794#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
795pub struct EntryPoint {
796 /// The access code to access the conference. The maximum length is 128 characters.
797 /// 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.
798 /// Optional.
799 #[serde(rename = "accessCode")]
800 pub access_code: Option<String>,
801 /// 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.
802 #[serde(rename = "entryPointFeatures")]
803 pub entry_point_features: Option<Vec<String>>,
804 /// The type of the conference entry point.
805 /// Possible values are:
806 /// - "video" - joining a conference over HTTP. A conference can have zero or one video entry point.
807 /// - "phone" - joining a conference by dialing a phone number. A conference can have zero or more phone entry points.
808 /// - "sip" - joining a conference over SIP. A conference can have zero or one sip entry point.
809 /// - "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.
810 #[serde(rename = "entryPointType")]
811 pub entry_point_type: Option<String>,
812 /// The label for the URI. Visible to end users. Not localized. The maximum length is 512 characters.
813 /// Examples:
814 /// - for video: meet.google.com/aaa-bbbb-ccc
815 /// - for phone: +1 123 268 2601
816 /// - for sip: 12345678@altostrat.com
817 /// - for more: should not be filled
818 /// Optional.
819 pub label: Option<String>,
820 /// The meeting code to access the conference. The maximum length is 128 characters.
821 /// 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.
822 /// Optional.
823 #[serde(rename = "meetingCode")]
824 pub meeting_code: Option<String>,
825 /// The passcode to access the conference. The maximum length is 128 characters.
826 /// 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.
827 pub passcode: Option<String>,
828 /// The password to access the conference. The maximum length is 128 characters.
829 /// 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.
830 /// Optional.
831 pub password: Option<String>,
832 /// The PIN to access the conference. The maximum length is 128 characters.
833 /// 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.
834 /// Optional.
835 pub pin: Option<String>,
836 /// The CLDR/ISO 3166 region code for the country associated with this phone access. Example: "SE" for Sweden.
837 /// Calendar backend will populate this field only for EntryPointType.PHONE.
838 #[serde(rename = "regionCode")]
839 pub region_code: Option<String>,
840 /// The URI of the entry point. The maximum length is 1300 characters.
841 /// Format:
842 /// - for video, http: or https: schema is required.
843 /// - for phone, tel: schema is required. The URI should include the entire dial sequence (e.g., tel:+12345678900,,,123456789;1234).
844 /// - for sip, sip: schema is required, e.g., sip:12345678@myprovider.com.
845 /// - for more, http: or https: schema is required.
846 pub uri: Option<String>,
847}
848
849impl common::Part for EntryPoint {}
850
851/// There is no detailed description.
852///
853/// This type is not used in any activity, and only used as *part* of another schema.
854///
855#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
856#[serde_with::serde_as]
857#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
858pub struct Error {
859 /// Domain, or broad category, of the error.
860 pub domain: Option<String>,
861 /// Specific reason for the error. Some of the possible values are:
862 /// - "groupTooBig" - The group of users requested is too large for a single query.
863 /// - "tooManyCalendarsRequested" - The number of calendars requested is too large for a single query.
864 /// - "notFound" - The requested resource was not found.
865 /// - "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.
866 pub reason: Option<String>,
867}
868
869impl common::Part for Error {}
870
871/// There is no detailed description.
872///
873/// # Activities
874///
875/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
876/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
877///
878/// * [delete events](EventDeleteCall) (none)
879/// * [get events](EventGetCall) (response)
880/// * [import events](EventImportCall) (request|response)
881/// * [insert events](EventInsertCall) (request|response)
882/// * [instances events](EventInstanceCall) (none)
883/// * [list events](EventListCall) (none)
884/// * [move events](EventMoveCall) (response)
885/// * [patch events](EventPatchCall) (request|response)
886/// * [quick add events](EventQuickAddCall) (response)
887/// * [update events](EventUpdateCall) (request|response)
888/// * [watch events](EventWatchCall) (none)
889#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
890#[serde_with::serde_as]
891#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
892pub struct Event {
893 /// Whether anyone can invite themselves to the event (deprecated). Optional. The default is False.
894 #[serde(rename = "anyoneCanAddSelf")]
895 pub anyone_can_add_self: Option<bool>,
896 /// File attachments for the event.
897 /// In order to modify attachments the supportsAttachments request parameter should be set to true.
898 /// There can be at most 25 attachments per event,
899 pub attachments: Option<Vec<EventAttachment>>,
900 /// 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.
901 pub attendees: Option<Vec<EventAttendee>>,
902 /// 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.
903 #[serde(rename = "attendeesOmitted")]
904 pub attendees_omitted: Option<bool>,
905 /// Birthday or special event data. Used if eventType is "birthday". Immutable.
906 #[serde(rename = "birthdayProperties")]
907 pub birthday_properties: Option<EventBirthdayProperties>,
908 /// 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.
909 #[serde(rename = "colorId")]
910 pub color_id: Option<String>,
911 /// 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.
912 #[serde(rename = "conferenceData")]
913 pub conference_data: Option<ConferenceData>,
914 /// Creation time of the event (as a RFC3339 timestamp). Read-only.
915 pub created: Option<chrono::DateTime<chrono::offset::Utc>>,
916 /// The creator of the event. Read-only.
917 pub creator: Option<EventCreator>,
918 /// Description of the event. Can contain HTML. Optional.
919 pub description: Option<String>,
920 /// The (exclusive) end time of the event. For a recurring event, this is the end time of the first instance.
921 pub end: Option<EventDateTime>,
922 /// 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.
923 #[serde(rename = "endTimeUnspecified")]
924 pub end_time_unspecified: Option<bool>,
925 /// ETag of the resource.
926 pub etag: Option<String>,
927 /// Specific type of the event. This cannot be modified after the event is created. Possible values are:
928 /// - "birthday" - A special all-day event with an annual recurrence.
929 /// - "default" - A regular event or not further specified.
930 /// - "focusTime" - A focus-time event.
931 /// - "fromGmail" - An event from Gmail. This type of event cannot be created.
932 /// - "outOfOffice" - An out-of-office event.
933 /// - "workingLocation" - A working location event.
934 #[serde(rename = "eventType")]
935 pub event_type: Option<String>,
936 /// Extended properties of the event.
937 #[serde(rename = "extendedProperties")]
938 pub extended_properties: Option<EventExtendedProperties>,
939 /// Focus Time event data. Used if eventType is focusTime.
940 #[serde(rename = "focusTimeProperties")]
941 pub focus_time_properties: Option<EventFocusTimeProperties>,
942 /// A gadget that extends this event. Gadgets are deprecated; this structure is instead only used for returning birthday calendar metadata.
943 pub gadget: Option<EventGadget>,
944 /// Whether attendees other than the organizer can invite others to the event. Optional. The default is True.
945 #[serde(rename = "guestsCanInviteOthers")]
946 pub guests_can_invite_others: Option<bool>,
947 /// Whether attendees other than the organizer can modify the event. Optional. The default is False.
948 #[serde(rename = "guestsCanModify")]
949 pub guests_can_modify: Option<bool>,
950 /// Whether attendees other than the organizer can see who the event's attendees are. Optional. The default is True.
951 #[serde(rename = "guestsCanSeeOtherGuests")]
952 pub guests_can_see_other_guests: Option<bool>,
953 /// An absolute link to the Google Hangout associated with this event. Read-only.
954 #[serde(rename = "hangoutLink")]
955 pub hangout_link: Option<String>,
956 /// An absolute link to this event in the Google Calendar Web UI. Read-only.
957 #[serde(rename = "htmlLink")]
958 pub html_link: Option<String>,
959 /// 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.
960 /// 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.
961 #[serde(rename = "iCalUID")]
962 pub i_cal_uid: Option<String>,
963 /// Opaque identifier of the event. When creating new single or recurring events, you can specify their IDs. Provided IDs must follow these rules:
964 /// - 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
965 /// - the length of the ID must be between 5 and 1024 characters
966 /// - 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.
967 /// If you do not specify an ID, it will be automatically generated by the server.
968 /// 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.
969 pub id: Option<String>,
970 /// Type of the resource ("calendar#event").
971 pub kind: Option<String>,
972 /// Geographic location of the event as free-form text. Optional.
973 pub location: Option<String>,
974 /// 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.
975 pub locked: Option<bool>,
976 /// 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.
977 pub organizer: Option<EventOrganizer>,
978 /// 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.
979 #[serde(rename = "originalStartTime")]
980 pub original_start_time: Option<EventDateTime>,
981 /// Out of office event data. Used if eventType is outOfOffice.
982 #[serde(rename = "outOfOfficeProperties")]
983 pub out_of_office_properties: Option<EventOutOfOfficeProperties>,
984 /// 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.
985 #[serde(rename = "privateCopy")]
986 pub private_copy: Option<bool>,
987 /// 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.
988 pub recurrence: Option<Vec<String>>,
989 /// For an instance of a recurring event, this is the id of the recurring event to which this instance belongs. Immutable.
990 #[serde(rename = "recurringEventId")]
991 pub recurring_event_id: Option<String>,
992 /// Information about the event's reminders for the authenticated user. Note that changing reminders does not also change the updated property of the enclosing event.
993 pub reminders: Option<EventReminders>,
994 /// Sequence number as per iCalendar.
995 pub sequence: Option<i32>,
996 /// 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.
997 pub source: Option<EventSource>,
998 /// The (inclusive) start time of the event. For a recurring event, this is the start time of the first instance.
999 pub start: Option<EventDateTime>,
1000 /// Status of the event. Optional. Possible values are:
1001 /// - "confirmed" - The event is confirmed. This is the default status.
1002 /// - "tentative" - The event is tentatively confirmed.
1003 /// - "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.
1004 /// A cancelled status represents two different states depending on the event type:
1005 /// - 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.
1006 /// Cancelled exceptions are only guaranteed to have values for the id, recurringEventId and originalStartTime fields populated. The other fields might be empty.
1007 /// - 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.
1008 /// 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.
1009 /// 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.
1010 pub status: Option<String>,
1011 /// Title of the event.
1012 pub summary: Option<String>,
1013 /// Whether the event blocks time on the calendar. Optional. Possible values are:
1014 /// - "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.
1015 /// - "transparent" - The event does not block time on the calendar. This is equivalent to setting Show me as to Available in the Calendar UI.
1016 pub transparency: Option<String>,
1017 /// Last modification time of the main event data (as a RFC3339 timestamp). Updating event reminders will not cause this to change. Read-only.
1018 pub updated: Option<chrono::DateTime<chrono::offset::Utc>>,
1019 /// Visibility of the event. Optional. Possible values are:
1020 /// - "default" - Uses the default visibility for events on the calendar. This is the default value.
1021 /// - "public" - The event is public and event details are visible to all readers of the calendar.
1022 /// - "private" - The event is private and only event attendees may view event details.
1023 /// - "confidential" - The event is private. This value is provided for compatibility reasons.
1024 pub visibility: Option<String>,
1025 /// Working location event data.
1026 #[serde(rename = "workingLocationProperties")]
1027 pub working_location_properties: Option<EventWorkingLocationProperties>,
1028}
1029
1030impl common::RequestValue for Event {}
1031impl common::Resource for Event {}
1032impl common::ResponseResult for Event {}
1033
1034/// There is no detailed description.
1035///
1036/// This type is not used in any activity, and only used as *part* of another schema.
1037///
1038#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1039#[serde_with::serde_as]
1040#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1041pub struct EventAttachment {
1042 /// ID of the attached file. Read-only.
1043 /// For Google Drive files, this is the ID of the corresponding Files resource entry in the Drive API.
1044 #[serde(rename = "fileId")]
1045 pub file_id: Option<String>,
1046 /// URL link to the attachment.
1047 /// For adding Google Drive file attachments use the same format as in alternateLink property of the Files resource in the Drive API.
1048 /// Required when adding an attachment.
1049 #[serde(rename = "fileUrl")]
1050 pub file_url: Option<String>,
1051 /// URL link to the attachment's icon. This field can only be modified for custom third-party attachments.
1052 #[serde(rename = "iconLink")]
1053 pub icon_link: Option<String>,
1054 /// Internet media type (MIME type) of the attachment.
1055 #[serde(rename = "mimeType")]
1056 pub mime_type: Option<String>,
1057 /// Attachment title.
1058 pub title: Option<String>,
1059}
1060
1061impl common::Part for EventAttachment {}
1062
1063/// There is no detailed description.
1064///
1065/// This type is not used in any activity, and only used as *part* of another schema.
1066///
1067#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1068#[serde_with::serde_as]
1069#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1070pub struct EventAttendee {
1071 /// Number of additional guests. Optional. The default is 0.
1072 #[serde(rename = "additionalGuests")]
1073 pub additional_guests: Option<i32>,
1074 /// The attendee's response comment. Optional.
1075 pub comment: Option<String>,
1076 /// The attendee's name, if available. Optional.
1077 #[serde(rename = "displayName")]
1078 pub display_name: Option<String>,
1079 /// 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.
1080 /// Required when adding an attendee.
1081 pub email: Option<String>,
1082 /// The attendee's Profile ID, if available.
1083 pub id: Option<String>,
1084 /// Whether this is an optional attendee. Optional. The default is False.
1085 pub optional: Option<bool>,
1086 /// Whether the attendee is the organizer of the event. Read-only. The default is False.
1087 pub organizer: Option<bool>,
1088 /// 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.
1089 pub resource: Option<bool>,
1090 /// The attendee's response status. Possible values are:
1091 /// - "needsAction" - The attendee has not responded to the invitation (recommended for new events).
1092 /// - "declined" - The attendee has declined the invitation.
1093 /// - "tentative" - The attendee has tentatively accepted the invitation.
1094 /// - "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" or "Only if the sender is known" might have their response reset to needsAction and won't see an event in their calendar unless they change their response in the event invitation email. Furthermore, if more than 200 guests are invited to the event, response status is not propagated to the guests.
1095 #[serde(rename = "responseStatus")]
1096 pub response_status: Option<String>,
1097 /// Whether this entry represents the calendar on which this copy of the event appears. Read-only. The default is False.
1098 #[serde(rename = "self")]
1099 pub self_: Option<bool>,
1100}
1101
1102impl common::Part for EventAttendee {}
1103
1104/// There is no detailed description.
1105///
1106/// This type is not used in any activity, and only used as *part* of another schema.
1107///
1108#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1109#[serde_with::serde_as]
1110#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1111pub struct EventBirthdayProperties {
1112 /// Resource name of the contact this birthday event is linked to. This can be used to fetch contact details from People API. Format: "people/c12345". Read-only.
1113 pub contact: Option<String>,
1114 /// Custom type label specified for this event. This is populated if birthdayProperties.type is set to "custom". Read-only.
1115 #[serde(rename = "customTypeName")]
1116 pub custom_type_name: Option<String>,
1117 /// Type of birthday or special event. Possible values are:
1118 /// - "anniversary" - An anniversary other than birthday. Always has a contact.
1119 /// - "birthday" - A birthday event. This is the default value.
1120 /// - "custom" - A special date whose label is further specified in the customTypeName field. Always has a contact.
1121 /// - "other" - A special date which does not fall into the other categories, and does not have a custom label. Always has a contact.
1122 /// - "self" - Calendar owner's own birthday. Cannot have a contact. The Calendar API only supports creating events with the type "birthday". The type cannot be changed after the event is created.
1123 #[serde(rename = "type")]
1124 pub type_: Option<String>,
1125}
1126
1127impl common::Part for EventBirthdayProperties {}
1128
1129/// There is no detailed description.
1130///
1131/// This type is not used in any activity, and only used as *part* of another schema.
1132///
1133#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1134#[serde_with::serde_as]
1135#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1136pub struct EventDateTime {
1137 /// The date, in the format "yyyy-mm-dd", if this is an all-day event.
1138 pub date: Option<chrono::NaiveDate>,
1139 /// 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.
1140 #[serde(rename = "dateTime")]
1141 pub date_time: Option<chrono::DateTime<chrono::offset::Utc>>,
1142 /// 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.
1143 #[serde(rename = "timeZone")]
1144 pub time_zone: Option<String>,
1145}
1146
1147impl common::Part for EventDateTime {}
1148
1149/// There is no detailed description.
1150///
1151/// This type is not used in any activity, and only used as *part* of another schema.
1152///
1153#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1154#[serde_with::serde_as]
1155#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1156pub struct EventFocusTimeProperties {
1157 /// 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.
1158 #[serde(rename = "autoDeclineMode")]
1159 pub auto_decline_mode: Option<String>,
1160 /// The status to mark the user in Chat and related products. This can be available or doNotDisturb.
1161 #[serde(rename = "chatStatus")]
1162 pub chat_status: Option<String>,
1163 /// Response message to set if an existing event or new invitation is automatically declined by Calendar.
1164 #[serde(rename = "declineMessage")]
1165 pub decline_message: Option<String>,
1166}
1167
1168impl common::Part for EventFocusTimeProperties {}
1169
1170/// There is no detailed description.
1171///
1172/// This type is not used in any activity, and only used as *part* of another schema.
1173///
1174#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1175#[serde_with::serde_as]
1176#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1177pub struct EventOutOfOfficeProperties {
1178 /// 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.
1179 #[serde(rename = "autoDeclineMode")]
1180 pub auto_decline_mode: Option<String>,
1181 /// Response message to set if an existing event or new invitation is automatically declined by Calendar.
1182 #[serde(rename = "declineMessage")]
1183 pub decline_message: Option<String>,
1184}
1185
1186impl common::Part for EventOutOfOfficeProperties {}
1187
1188/// There is no detailed description.
1189///
1190/// This type is not used in any activity, and only used as *part* of another schema.
1191///
1192#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1193#[serde_with::serde_as]
1194#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1195pub struct EventReminder {
1196 /// The method used by this reminder. Possible values are:
1197 /// - "email" - Reminders are sent via email.
1198 /// - "popup" - Reminders are sent via a UI popup.
1199 /// Required when adding a reminder.
1200 pub method: Option<String>,
1201 /// 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).
1202 /// Required when adding a reminder.
1203 pub minutes: Option<i32>,
1204}
1205
1206impl common::Part for EventReminder {}
1207
1208/// There is no detailed description.
1209///
1210/// This type is not used in any activity, and only used as *part* of another schema.
1211///
1212#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1213#[serde_with::serde_as]
1214#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1215pub struct EventWorkingLocationProperties {
1216 /// If present, specifies that the user is working from a custom location.
1217 #[serde(rename = "customLocation")]
1218 pub custom_location: Option<EventWorkingLocationPropertiesCustomLocation>,
1219 /// If present, specifies that the user is working at home.
1220 #[serde(rename = "homeOffice")]
1221 pub home_office: Option<serde_json::Value>,
1222 /// If present, specifies that the user is working from an office.
1223 #[serde(rename = "officeLocation")]
1224 pub office_location: Option<EventWorkingLocationPropertiesOfficeLocation>,
1225 /// Type of the working location. Possible values are:
1226 /// - "homeOffice" - The user is working at home.
1227 /// - "officeLocation" - The user is working from an office.
1228 /// - "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.
1229 /// Required when adding working location properties.
1230 #[serde(rename = "type")]
1231 pub type_: Option<String>,
1232}
1233
1234impl common::Part for EventWorkingLocationProperties {}
1235
1236/// There is no detailed description.
1237///
1238/// # Activities
1239///
1240/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1241/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1242///
1243/// * [instances events](EventInstanceCall) (response)
1244/// * [list events](EventListCall) (response)
1245#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1246#[serde_with::serde_as]
1247#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1248pub struct Events {
1249 /// The user's access role for this calendar. Read-only. Possible values are:
1250 /// - "none" - The user has no access.
1251 /// - "freeBusyReader" - The user has read access to free/busy information.
1252 /// - "reader" - The user has read access to the calendar. Private events will appear to users with reader access, but event details will be hidden.
1253 /// - "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.
1254 /// - "owner" - The user has manager access to the calendar. This role has all of the permissions of the writer role with the additional ability to see and modify access levels of other users.
1255 /// Important: the owner role is different from the calendar's data owner. A calendar has a single data owner, but can have multiple users with owner role.
1256 #[serde(rename = "accessRole")]
1257 pub access_role: Option<String>,
1258 /// 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).
1259 #[serde(rename = "defaultReminders")]
1260 pub default_reminders: Option<Vec<EventReminder>>,
1261 /// Description of the calendar. Read-only.
1262 pub description: Option<String>,
1263 /// ETag of the collection.
1264 pub etag: Option<String>,
1265 /// List of events on the calendar.
1266 pub items: Option<Vec<Event>>,
1267 /// Type of the collection ("calendar#events").
1268 pub kind: Option<String>,
1269 /// Token used to access the next page of this result. Omitted if no further results are available, in which case nextSyncToken is provided.
1270 #[serde(rename = "nextPageToken")]
1271 pub next_page_token: Option<String>,
1272 /// 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.
1273 #[serde(rename = "nextSyncToken")]
1274 pub next_sync_token: Option<String>,
1275 /// Title of the calendar. Read-only.
1276 pub summary: Option<String>,
1277 /// The time zone of the calendar. Read-only.
1278 #[serde(rename = "timeZone")]
1279 pub time_zone: Option<String>,
1280 /// Last modification time of the calendar (as a RFC3339 timestamp). Read-only.
1281 pub updated: Option<chrono::DateTime<chrono::offset::Utc>>,
1282}
1283
1284impl common::ResponseResult for Events {}
1285
1286/// There is no detailed description.
1287///
1288/// This type is not used in any activity, and only used as *part* of another schema.
1289///
1290#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1291#[serde_with::serde_as]
1292#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1293pub struct FreeBusyCalendar {
1294 /// List of time ranges during which this calendar should be regarded as busy.
1295 pub busy: Option<Vec<TimePeriod>>,
1296 /// Optional error(s) (if computation for the calendar failed).
1297 pub errors: Option<Vec<Error>>,
1298}
1299
1300impl common::Part for FreeBusyCalendar {}
1301
1302/// There is no detailed description.
1303///
1304/// This type is not used in any activity, and only used as *part* of another schema.
1305///
1306#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1307#[serde_with::serde_as]
1308#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1309pub struct FreeBusyGroup {
1310 /// List of calendars' identifiers within a group.
1311 pub calendars: Option<Vec<String>>,
1312 /// Optional error(s) (if computation for the group failed).
1313 pub errors: Option<Vec<Error>>,
1314}
1315
1316impl common::Part for FreeBusyGroup {}
1317
1318/// There is no detailed description.
1319///
1320/// # Activities
1321///
1322/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1323/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1324///
1325/// * [query freebusy](FreebusyQueryCall) (request)
1326#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1327#[serde_with::serde_as]
1328#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1329pub struct FreeBusyRequest {
1330 /// Maximal number of calendars for which FreeBusy information is to be provided. Optional. Maximum value is 50.
1331 #[serde(rename = "calendarExpansionMax")]
1332 pub calendar_expansion_max: Option<i32>,
1333 /// 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.
1334 #[serde(rename = "groupExpansionMax")]
1335 pub group_expansion_max: Option<i32>,
1336 /// List of calendars and/or groups to query.
1337 pub items: Option<Vec<FreeBusyRequestItem>>,
1338 /// The end of the interval for the query formatted as per RFC3339.
1339 #[serde(rename = "timeMax")]
1340 pub time_max: Option<chrono::DateTime<chrono::offset::Utc>>,
1341 /// The start of the interval for the query formatted as per RFC3339.
1342 #[serde(rename = "timeMin")]
1343 pub time_min: Option<chrono::DateTime<chrono::offset::Utc>>,
1344 /// Time zone used in the response. Optional. The default is UTC.
1345 #[serde(rename = "timeZone")]
1346 pub time_zone: Option<String>,
1347}
1348
1349impl common::RequestValue for FreeBusyRequest {}
1350
1351/// There is no detailed description.
1352///
1353/// This type is not used in any activity, and only used as *part* of another schema.
1354///
1355#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1356#[serde_with::serde_as]
1357#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1358pub struct FreeBusyRequestItem {
1359 /// The identifier of a calendar or a group.
1360 pub id: Option<String>,
1361}
1362
1363impl common::Part for FreeBusyRequestItem {}
1364
1365/// There is no detailed description.
1366///
1367/// # Activities
1368///
1369/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1370/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1371///
1372/// * [query freebusy](FreebusyQueryCall) (response)
1373#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1374#[serde_with::serde_as]
1375#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1376pub struct FreeBusyResponse {
1377 /// List of free/busy information for calendars.
1378 pub calendars: Option<HashMap<String, FreeBusyCalendar>>,
1379 /// Expansion of groups.
1380 pub groups: Option<HashMap<String, FreeBusyGroup>>,
1381 /// Type of the resource ("calendar#freeBusy").
1382 pub kind: Option<String>,
1383 /// The end of the interval.
1384 #[serde(rename = "timeMax")]
1385 pub time_max: Option<chrono::DateTime<chrono::offset::Utc>>,
1386 /// The start of the interval.
1387 #[serde(rename = "timeMin")]
1388 pub time_min: Option<chrono::DateTime<chrono::offset::Utc>>,
1389}
1390
1391impl common::ResponseResult for FreeBusyResponse {}
1392
1393/// There is no detailed description.
1394///
1395/// # Activities
1396///
1397/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1398/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1399///
1400/// * [get settings](SettingGetCall) (response)
1401/// * [list settings](SettingListCall) (none)
1402/// * [watch settings](SettingWatchCall) (none)
1403#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1404#[serde_with::serde_as]
1405#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1406pub struct Setting {
1407 /// ETag of the resource.
1408 pub etag: Option<String>,
1409 /// The id of the user setting.
1410 pub id: Option<String>,
1411 /// Type of the resource ("calendar#setting").
1412 pub kind: Option<String>,
1413 /// 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.
1414 pub value: Option<String>,
1415}
1416
1417impl common::Resource for Setting {}
1418impl common::ResponseResult for Setting {}
1419
1420/// There is no detailed description.
1421///
1422/// # Activities
1423///
1424/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1425/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1426///
1427/// * [list settings](SettingListCall) (response)
1428#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1429#[serde_with::serde_as]
1430#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1431pub struct Settings {
1432 /// Etag of the collection.
1433 pub etag: Option<String>,
1434 /// List of user settings.
1435 pub items: Option<Vec<Setting>>,
1436 /// Type of the collection ("calendar#settings").
1437 pub kind: Option<String>,
1438 /// Token used to access the next page of this result. Omitted if no further results are available, in which case nextSyncToken is provided.
1439 #[serde(rename = "nextPageToken")]
1440 pub next_page_token: Option<String>,
1441 /// 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.
1442 #[serde(rename = "nextSyncToken")]
1443 pub next_sync_token: Option<String>,
1444}
1445
1446impl common::ResponseResult for Settings {}
1447
1448/// There is no detailed description.
1449///
1450/// This type is not used in any activity, and only used as *part* of another schema.
1451///
1452#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1453#[serde_with::serde_as]
1454#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1455pub struct TimePeriod {
1456 /// The (exclusive) end of the time period.
1457 pub end: Option<chrono::DateTime<chrono::offset::Utc>>,
1458 /// The (inclusive) start of the time period.
1459 pub start: Option<chrono::DateTime<chrono::offset::Utc>>,
1460}
1461
1462impl common::Part for TimePeriod {}
1463
1464/// The extent to which calendar access is granted by this ACL rule.
1465///
1466/// This type is not used in any activity, and only used as *part* of another schema.
1467///
1468#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1469#[serde_with::serde_as]
1470#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1471pub struct AclRuleScope {
1472 /// The type of the scope. Possible values are:
1473 /// - "default" - The public scope. This is the default value.
1474 /// - "user" - Limits the scope to a single user.
1475 /// - "group" - Limits the scope to a group.
1476 /// - "domain" - Limits the scope to a domain. Note: The permissions granted to the "default", or public, scope apply to any user, authenticated or not.
1477 #[serde(rename = "type")]
1478 pub type_: Option<String>,
1479 /// The email address of a user or group, or the name of a domain, depending on the scope type. Omitted for type "default".
1480 pub value: Option<String>,
1481}
1482
1483impl common::NestedType for AclRuleScope {}
1484impl common::Part for AclRuleScope {}
1485
1486/// The notifications that the authenticated user is receiving for this calendar.
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 CalendarListEntryNotificationSettings {
1494 /// The list of notifications set for this calendar.
1495 pub notifications: Option<Vec<CalendarNotification>>,
1496}
1497
1498impl common::NestedType for CalendarListEntryNotificationSettings {}
1499impl common::Part for CalendarListEntryNotificationSettings {}
1500
1501/// The creator of the event. Read-only.
1502///
1503/// This type is not used in any activity, and only used as *part* of another schema.
1504///
1505#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1506#[serde_with::serde_as]
1507#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1508pub struct EventCreator {
1509 /// The creator's name, if available.
1510 #[serde(rename = "displayName")]
1511 pub display_name: Option<String>,
1512 /// The creator's email address, if available.
1513 pub email: Option<String>,
1514 /// The creator's Profile ID, if available.
1515 pub id: Option<String>,
1516 /// Whether the creator corresponds to the calendar on which this copy of the event appears. Read-only. The default is False.
1517 #[serde(rename = "self")]
1518 pub self_: Option<bool>,
1519}
1520
1521impl common::NestedType for EventCreator {}
1522impl common::Part for EventCreator {}
1523
1524/// Extended properties of the event.
1525///
1526/// This type is not used in any activity, and only used as *part* of another schema.
1527///
1528#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1529#[serde_with::serde_as]
1530#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1531pub struct EventExtendedProperties {
1532 /// Properties that are private to the copy of the event that appears on this calendar.
1533 pub private: Option<HashMap<String, String>>,
1534 /// Properties that are shared between copies of the event on other attendees' calendars.
1535 pub shared: Option<HashMap<String, String>>,
1536}
1537
1538impl common::NestedType for EventExtendedProperties {}
1539impl common::Part for EventExtendedProperties {}
1540
1541/// A gadget that extends this event. Gadgets are deprecated; this structure is instead only used for returning birthday calendar metadata.
1542///
1543/// This type is not used in any activity, and only used as *part* of another schema.
1544///
1545#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1546#[serde_with::serde_as]
1547#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1548pub struct EventGadget {
1549 /// The gadget's display mode. Deprecated. Possible values are:
1550 /// - "icon" - The gadget displays next to the event's title in the calendar view.
1551 /// - "chip" - The gadget displays when the event is clicked.
1552 pub display: Option<String>,
1553 /// The gadget's height in pixels. The height must be an integer greater than 0. Optional. Deprecated.
1554 pub height: Option<i32>,
1555 /// The gadget's icon URL. The URL scheme must be HTTPS. Deprecated.
1556 #[serde(rename = "iconLink")]
1557 pub icon_link: Option<String>,
1558 /// The gadget's URL. The URL scheme must be HTTPS. Deprecated.
1559 pub link: Option<String>,
1560 /// Preferences.
1561 pub preferences: Option<HashMap<String, String>>,
1562 /// The gadget's title. Deprecated.
1563 pub title: Option<String>,
1564 /// The gadget's type. Deprecated.
1565 #[serde(rename = "type")]
1566 pub type_: Option<String>,
1567 /// The gadget's width in pixels. The width must be an integer greater than 0. Optional. Deprecated.
1568 pub width: Option<i32>,
1569}
1570
1571impl common::NestedType for EventGadget {}
1572impl common::Part for EventGadget {}
1573
1574/// 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.
1575///
1576/// This type is not used in any activity, and only used as *part* of another schema.
1577///
1578#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1579#[serde_with::serde_as]
1580#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1581pub struct EventOrganizer {
1582 /// The organizer's name, if available.
1583 #[serde(rename = "displayName")]
1584 pub display_name: Option<String>,
1585 /// The organizer's email address, if available. It must be a valid email address as per RFC5322.
1586 pub email: Option<String>,
1587 /// The organizer's Profile ID, if available.
1588 pub id: Option<String>,
1589 /// Whether the organizer corresponds to the calendar on which this copy of the event appears. Read-only. The default is False.
1590 #[serde(rename = "self")]
1591 pub self_: Option<bool>,
1592}
1593
1594impl common::NestedType for EventOrganizer {}
1595impl common::Part for EventOrganizer {}
1596
1597/// Information about the event's reminders for the authenticated user. Note that changing reminders does not also change the updated property of the enclosing event.
1598///
1599/// This type is not used in any activity, and only used as *part* of another schema.
1600///
1601#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1602#[serde_with::serde_as]
1603#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1604pub struct EventReminders {
1605 /// 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.
1606 pub overrides: Option<Vec<EventReminder>>,
1607 /// Whether the default reminders of the calendar apply to the event.
1608 #[serde(rename = "useDefault")]
1609 pub use_default: Option<bool>,
1610}
1611
1612impl common::NestedType for EventReminders {}
1613impl common::Part for EventReminders {}
1614
1615/// 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.
1616///
1617/// This type is not used in any activity, and only used as *part* of another schema.
1618///
1619#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1620#[serde_with::serde_as]
1621#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1622pub struct EventSource {
1623 /// Title of the source; for example a title of a web page or an email subject.
1624 pub title: Option<String>,
1625 /// URL of the source pointing to a resource. The URL scheme must be HTTP or HTTPS.
1626 pub url: Option<String>,
1627}
1628
1629impl common::NestedType for EventSource {}
1630impl common::Part for EventSource {}
1631
1632/// If present, specifies that the user is working from a custom location.
1633///
1634/// This type is not used in any activity, and only used as *part* of another schema.
1635///
1636#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1637#[serde_with::serde_as]
1638#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1639pub struct EventWorkingLocationPropertiesCustomLocation {
1640 /// An optional extra label for additional information.
1641 pub label: Option<String>,
1642}
1643
1644impl common::NestedType for EventWorkingLocationPropertiesCustomLocation {}
1645impl common::Part for EventWorkingLocationPropertiesCustomLocation {}
1646
1647/// If present, specifies that the user is working from an office.
1648///
1649/// This type is not used in any activity, and only used as *part* of another schema.
1650///
1651#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1652#[serde_with::serde_as]
1653#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1654pub struct EventWorkingLocationPropertiesOfficeLocation {
1655 /// An optional building identifier. This should reference a building ID in the organization's Resources database.
1656 #[serde(rename = "buildingId")]
1657 pub building_id: Option<String>,
1658 /// An optional desk identifier.
1659 #[serde(rename = "deskId")]
1660 pub desk_id: Option<String>,
1661 /// An optional floor identifier.
1662 #[serde(rename = "floorId")]
1663 pub floor_id: Option<String>,
1664 /// An optional floor section identifier.
1665 #[serde(rename = "floorSectionId")]
1666 pub floor_section_id: Option<String>,
1667 /// 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.
1668 pub label: Option<String>,
1669}
1670
1671impl common::NestedType for EventWorkingLocationPropertiesOfficeLocation {}
1672impl common::Part for EventWorkingLocationPropertiesOfficeLocation {}
1673
1674// ###################
1675// MethodBuilders ###
1676// #################
1677
1678/// A builder providing access to all methods supported on *acl* resources.
1679/// It is not used directly, but through the [`CalendarHub`] hub.
1680///
1681/// # Example
1682///
1683/// Instantiate a resource builder
1684///
1685/// ```test_harness,no_run
1686/// extern crate hyper;
1687/// extern crate hyper_rustls;
1688/// extern crate google_calendar3 as calendar3;
1689///
1690/// # async fn dox() {
1691/// use calendar3::{CalendarHub, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
1692///
1693/// let secret: yup_oauth2::ApplicationSecret = Default::default();
1694/// let connector = hyper_rustls::HttpsConnectorBuilder::new()
1695/// .with_native_roots()
1696/// .unwrap()
1697/// .https_only()
1698/// .enable_http2()
1699/// .build();
1700///
1701/// let executor = hyper_util::rt::TokioExecutor::new();
1702/// let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
1703/// secret,
1704/// yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
1705/// yup_oauth2::client::CustomHyperClientBuilder::from(
1706/// hyper_util::client::legacy::Client::builder(executor).build(connector),
1707/// ),
1708/// ).build().await.unwrap();
1709///
1710/// let client = hyper_util::client::legacy::Client::builder(
1711/// hyper_util::rt::TokioExecutor::new()
1712/// )
1713/// .build(
1714/// hyper_rustls::HttpsConnectorBuilder::new()
1715/// .with_native_roots()
1716/// .unwrap()
1717/// .https_or_http()
1718/// .enable_http2()
1719/// .build()
1720/// );
1721/// let mut hub = CalendarHub::new(client, auth);
1722/// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders*
1723/// // like `delete(...)`, `get(...)`, `insert(...)`, `list(...)`, `patch(...)`, `update(...)` and `watch(...)`
1724/// // to build up your call.
1725/// let rb = hub.acl();
1726/// # }
1727/// ```
1728pub struct AclMethods<'a, C>
1729where
1730 C: 'a,
1731{
1732 hub: &'a CalendarHub<C>,
1733}
1734
1735impl<'a, C> common::MethodsBuilder for AclMethods<'a, C> {}
1736
1737impl<'a, C> AclMethods<'a, C> {
1738 /// Create a builder to help you perform the following task:
1739 ///
1740 /// Deletes an access control rule.
1741 ///
1742 /// # Arguments
1743 ///
1744 /// * `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.
1745 /// * `ruleId` - ACL rule identifier.
1746 pub fn delete(&self, calendar_id: &str, rule_id: &str) -> AclDeleteCall<'a, C> {
1747 AclDeleteCall {
1748 hub: self.hub,
1749 _calendar_id: calendar_id.to_string(),
1750 _rule_id: rule_id.to_string(),
1751 _delegate: Default::default(),
1752 _additional_params: Default::default(),
1753 _scopes: Default::default(),
1754 }
1755 }
1756
1757 /// Create a builder to help you perform the following task:
1758 ///
1759 /// Returns an access control rule.
1760 ///
1761 /// # Arguments
1762 ///
1763 /// * `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.
1764 /// * `ruleId` - ACL rule identifier.
1765 pub fn get(&self, calendar_id: &str, rule_id: &str) -> AclGetCall<'a, C> {
1766 AclGetCall {
1767 hub: self.hub,
1768 _calendar_id: calendar_id.to_string(),
1769 _rule_id: rule_id.to_string(),
1770 _delegate: Default::default(),
1771 _additional_params: Default::default(),
1772 _scopes: Default::default(),
1773 }
1774 }
1775
1776 /// Create a builder to help you perform the following task:
1777 ///
1778 /// Creates an access control rule.
1779 ///
1780 /// # Arguments
1781 ///
1782 /// * `request` - No description provided.
1783 /// * `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.
1784 pub fn insert(&self, request: AclRule, calendar_id: &str) -> AclInsertCall<'a, C> {
1785 AclInsertCall {
1786 hub: self.hub,
1787 _request: request,
1788 _calendar_id: calendar_id.to_string(),
1789 _send_notifications: Default::default(),
1790 _delegate: Default::default(),
1791 _additional_params: Default::default(),
1792 _scopes: Default::default(),
1793 }
1794 }
1795
1796 /// Create a builder to help you perform the following task:
1797 ///
1798 /// Returns the rules in the access control list for the calendar.
1799 ///
1800 /// # Arguments
1801 ///
1802 /// * `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.
1803 pub fn list(&self, calendar_id: &str) -> AclListCall<'a, C> {
1804 AclListCall {
1805 hub: self.hub,
1806 _calendar_id: calendar_id.to_string(),
1807 _sync_token: Default::default(),
1808 _show_deleted: Default::default(),
1809 _page_token: Default::default(),
1810 _max_results: Default::default(),
1811 _delegate: Default::default(),
1812 _additional_params: Default::default(),
1813 _scopes: Default::default(),
1814 }
1815 }
1816
1817 /// Create a builder to help you perform the following task:
1818 ///
1819 /// Updates an access control rule. This method supports patch semantics.
1820 ///
1821 /// # Arguments
1822 ///
1823 /// * `request` - No description provided.
1824 /// * `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.
1825 /// * `ruleId` - ACL rule identifier.
1826 pub fn patch(&self, request: AclRule, calendar_id: &str, rule_id: &str) -> AclPatchCall<'a, C> {
1827 AclPatchCall {
1828 hub: self.hub,
1829 _request: request,
1830 _calendar_id: calendar_id.to_string(),
1831 _rule_id: rule_id.to_string(),
1832 _send_notifications: Default::default(),
1833 _delegate: Default::default(),
1834 _additional_params: Default::default(),
1835 _scopes: Default::default(),
1836 }
1837 }
1838
1839 /// Create a builder to help you perform the following task:
1840 ///
1841 /// Updates an access control rule.
1842 ///
1843 /// # Arguments
1844 ///
1845 /// * `request` - No description provided.
1846 /// * `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.
1847 /// * `ruleId` - ACL rule identifier.
1848 pub fn update(
1849 &self,
1850 request: AclRule,
1851 calendar_id: &str,
1852 rule_id: &str,
1853 ) -> AclUpdateCall<'a, C> {
1854 AclUpdateCall {
1855 hub: self.hub,
1856 _request: request,
1857 _calendar_id: calendar_id.to_string(),
1858 _rule_id: rule_id.to_string(),
1859 _send_notifications: Default::default(),
1860 _delegate: Default::default(),
1861 _additional_params: Default::default(),
1862 _scopes: Default::default(),
1863 }
1864 }
1865
1866 /// Create a builder to help you perform the following task:
1867 ///
1868 /// Watch for changes to ACL resources.
1869 ///
1870 /// # Arguments
1871 ///
1872 /// * `request` - No description provided.
1873 /// * `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.
1874 pub fn watch(&self, request: Channel, calendar_id: &str) -> AclWatchCall<'a, C> {
1875 AclWatchCall {
1876 hub: self.hub,
1877 _request: request,
1878 _calendar_id: calendar_id.to_string(),
1879 _sync_token: Default::default(),
1880 _show_deleted: Default::default(),
1881 _page_token: Default::default(),
1882 _max_results: Default::default(),
1883 _delegate: Default::default(),
1884 _additional_params: Default::default(),
1885 _scopes: Default::default(),
1886 }
1887 }
1888}
1889
1890/// A builder providing access to all methods supported on *calendarList* resources.
1891/// It is not used directly, but through the [`CalendarHub`] hub.
1892///
1893/// # Example
1894///
1895/// Instantiate a resource builder
1896///
1897/// ```test_harness,no_run
1898/// extern crate hyper;
1899/// extern crate hyper_rustls;
1900/// extern crate google_calendar3 as calendar3;
1901///
1902/// # async fn dox() {
1903/// use calendar3::{CalendarHub, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
1904///
1905/// let secret: yup_oauth2::ApplicationSecret = Default::default();
1906/// let connector = hyper_rustls::HttpsConnectorBuilder::new()
1907/// .with_native_roots()
1908/// .unwrap()
1909/// .https_only()
1910/// .enable_http2()
1911/// .build();
1912///
1913/// let executor = hyper_util::rt::TokioExecutor::new();
1914/// let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
1915/// secret,
1916/// yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
1917/// yup_oauth2::client::CustomHyperClientBuilder::from(
1918/// hyper_util::client::legacy::Client::builder(executor).build(connector),
1919/// ),
1920/// ).build().await.unwrap();
1921///
1922/// let client = hyper_util::client::legacy::Client::builder(
1923/// hyper_util::rt::TokioExecutor::new()
1924/// )
1925/// .build(
1926/// hyper_rustls::HttpsConnectorBuilder::new()
1927/// .with_native_roots()
1928/// .unwrap()
1929/// .https_or_http()
1930/// .enable_http2()
1931/// .build()
1932/// );
1933/// let mut hub = CalendarHub::new(client, auth);
1934/// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders*
1935/// // like `delete(...)`, `get(...)`, `insert(...)`, `list(...)`, `patch(...)`, `update(...)` and `watch(...)`
1936/// // to build up your call.
1937/// let rb = hub.calendar_list();
1938/// # }
1939/// ```
1940pub struct CalendarListMethods<'a, C>
1941where
1942 C: 'a,
1943{
1944 hub: &'a CalendarHub<C>,
1945}
1946
1947impl<'a, C> common::MethodsBuilder for CalendarListMethods<'a, C> {}
1948
1949impl<'a, C> CalendarListMethods<'a, C> {
1950 /// Create a builder to help you perform the following task:
1951 ///
1952 /// Removes a calendar from the user's calendar list.
1953 ///
1954 /// # Arguments
1955 ///
1956 /// * `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.
1957 pub fn delete(&self, calendar_id: &str) -> CalendarListDeleteCall<'a, C> {
1958 CalendarListDeleteCall {
1959 hub: self.hub,
1960 _calendar_id: calendar_id.to_string(),
1961 _delegate: Default::default(),
1962 _additional_params: Default::default(),
1963 _scopes: Default::default(),
1964 }
1965 }
1966
1967 /// Create a builder to help you perform the following task:
1968 ///
1969 /// Returns a calendar from the user's calendar list.
1970 ///
1971 /// # Arguments
1972 ///
1973 /// * `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.
1974 pub fn get(&self, calendar_id: &str) -> CalendarListGetCall<'a, C> {
1975 CalendarListGetCall {
1976 hub: self.hub,
1977 _calendar_id: calendar_id.to_string(),
1978 _delegate: Default::default(),
1979 _additional_params: Default::default(),
1980 _scopes: Default::default(),
1981 }
1982 }
1983
1984 /// Create a builder to help you perform the following task:
1985 ///
1986 /// Inserts an existing calendar into the user's calendar list.
1987 ///
1988 /// # Arguments
1989 ///
1990 /// * `request` - No description provided.
1991 pub fn insert(&self, request: CalendarListEntry) -> CalendarListInsertCall<'a, C> {
1992 CalendarListInsertCall {
1993 hub: self.hub,
1994 _request: request,
1995 _color_rgb_format: Default::default(),
1996 _delegate: Default::default(),
1997 _additional_params: Default::default(),
1998 _scopes: Default::default(),
1999 }
2000 }
2001
2002 /// Create a builder to help you perform the following task:
2003 ///
2004 /// Returns the calendars on the user's calendar list.
2005 pub fn list(&self) -> CalendarListListCall<'a, C> {
2006 CalendarListListCall {
2007 hub: self.hub,
2008 _sync_token: Default::default(),
2009 _show_hidden: Default::default(),
2010 _show_deleted: Default::default(),
2011 _page_token: Default::default(),
2012 _min_access_role: Default::default(),
2013 _max_results: Default::default(),
2014 _delegate: Default::default(),
2015 _additional_params: Default::default(),
2016 _scopes: Default::default(),
2017 }
2018 }
2019
2020 /// Create a builder to help you perform the following task:
2021 ///
2022 /// Updates an existing calendar on the user's calendar list. This method supports patch semantics.
2023 ///
2024 /// # Arguments
2025 ///
2026 /// * `request` - No description provided.
2027 /// * `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.
2028 pub fn patch(
2029 &self,
2030 request: CalendarListEntry,
2031 calendar_id: &str,
2032 ) -> CalendarListPatchCall<'a, C> {
2033 CalendarListPatchCall {
2034 hub: self.hub,
2035 _request: request,
2036 _calendar_id: calendar_id.to_string(),
2037 _color_rgb_format: Default::default(),
2038 _delegate: Default::default(),
2039 _additional_params: Default::default(),
2040 _scopes: Default::default(),
2041 }
2042 }
2043
2044 /// Create a builder to help you perform the following task:
2045 ///
2046 /// Updates an existing calendar on the user's calendar list.
2047 ///
2048 /// # Arguments
2049 ///
2050 /// * `request` - No description provided.
2051 /// * `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.
2052 pub fn update(
2053 &self,
2054 request: CalendarListEntry,
2055 calendar_id: &str,
2056 ) -> CalendarListUpdateCall<'a, C> {
2057 CalendarListUpdateCall {
2058 hub: self.hub,
2059 _request: request,
2060 _calendar_id: calendar_id.to_string(),
2061 _color_rgb_format: Default::default(),
2062 _delegate: Default::default(),
2063 _additional_params: Default::default(),
2064 _scopes: Default::default(),
2065 }
2066 }
2067
2068 /// Create a builder to help you perform the following task:
2069 ///
2070 /// Watch for changes to CalendarList resources.
2071 ///
2072 /// # Arguments
2073 ///
2074 /// * `request` - No description provided.
2075 pub fn watch(&self, request: Channel) -> CalendarListWatchCall<'a, C> {
2076 CalendarListWatchCall {
2077 hub: self.hub,
2078 _request: request,
2079 _sync_token: Default::default(),
2080 _show_hidden: Default::default(),
2081 _show_deleted: Default::default(),
2082 _page_token: Default::default(),
2083 _min_access_role: Default::default(),
2084 _max_results: Default::default(),
2085 _delegate: Default::default(),
2086 _additional_params: Default::default(),
2087 _scopes: Default::default(),
2088 }
2089 }
2090}
2091
2092/// A builder providing access to all methods supported on *calendar* resources.
2093/// It is not used directly, but through the [`CalendarHub`] hub.
2094///
2095/// # Example
2096///
2097/// Instantiate a resource builder
2098///
2099/// ```test_harness,no_run
2100/// extern crate hyper;
2101/// extern crate hyper_rustls;
2102/// extern crate google_calendar3 as calendar3;
2103///
2104/// # async fn dox() {
2105/// use calendar3::{CalendarHub, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
2106///
2107/// let secret: yup_oauth2::ApplicationSecret = Default::default();
2108/// let connector = hyper_rustls::HttpsConnectorBuilder::new()
2109/// .with_native_roots()
2110/// .unwrap()
2111/// .https_only()
2112/// .enable_http2()
2113/// .build();
2114///
2115/// let executor = hyper_util::rt::TokioExecutor::new();
2116/// let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
2117/// secret,
2118/// yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
2119/// yup_oauth2::client::CustomHyperClientBuilder::from(
2120/// hyper_util::client::legacy::Client::builder(executor).build(connector),
2121/// ),
2122/// ).build().await.unwrap();
2123///
2124/// let client = hyper_util::client::legacy::Client::builder(
2125/// hyper_util::rt::TokioExecutor::new()
2126/// )
2127/// .build(
2128/// hyper_rustls::HttpsConnectorBuilder::new()
2129/// .with_native_roots()
2130/// .unwrap()
2131/// .https_or_http()
2132/// .enable_http2()
2133/// .build()
2134/// );
2135/// let mut hub = CalendarHub::new(client, auth);
2136/// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders*
2137/// // like `clear(...)`, `delete(...)`, `get(...)`, `insert(...)`, `patch(...)` and `update(...)`
2138/// // to build up your call.
2139/// let rb = hub.calendars();
2140/// # }
2141/// ```
2142pub struct CalendarMethods<'a, C>
2143where
2144 C: 'a,
2145{
2146 hub: &'a CalendarHub<C>,
2147}
2148
2149impl<'a, C> common::MethodsBuilder for CalendarMethods<'a, C> {}
2150
2151impl<'a, C> CalendarMethods<'a, C> {
2152 /// Create a builder to help you perform the following task:
2153 ///
2154 /// Clears a primary calendar. This operation deletes all events associated with the primary calendar of an account.
2155 ///
2156 /// # Arguments
2157 ///
2158 /// * `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.
2159 pub fn clear(&self, calendar_id: &str) -> CalendarClearCall<'a, C> {
2160 CalendarClearCall {
2161 hub: self.hub,
2162 _calendar_id: calendar_id.to_string(),
2163 _delegate: Default::default(),
2164 _additional_params: Default::default(),
2165 _scopes: Default::default(),
2166 }
2167 }
2168
2169 /// Create a builder to help you perform the following task:
2170 ///
2171 /// Deletes a secondary calendar. Use calendars.clear for clearing all events on primary calendars.
2172 ///
2173 /// # Arguments
2174 ///
2175 /// * `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.
2176 pub fn delete(&self, calendar_id: &str) -> CalendarDeleteCall<'a, C> {
2177 CalendarDeleteCall {
2178 hub: self.hub,
2179 _calendar_id: calendar_id.to_string(),
2180 _delegate: Default::default(),
2181 _additional_params: Default::default(),
2182 _scopes: Default::default(),
2183 }
2184 }
2185
2186 /// Create a builder to help you perform the following task:
2187 ///
2188 /// Returns metadata for a calendar.
2189 ///
2190 /// # Arguments
2191 ///
2192 /// * `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.
2193 pub fn get(&self, calendar_id: &str) -> CalendarGetCall<'a, C> {
2194 CalendarGetCall {
2195 hub: self.hub,
2196 _calendar_id: calendar_id.to_string(),
2197 _delegate: Default::default(),
2198 _additional_params: Default::default(),
2199 _scopes: Default::default(),
2200 }
2201 }
2202
2203 /// Create a builder to help you perform the following task:
2204 ///
2205 /// Creates a secondary calendar.
2206 /// The authenticated user for the request is made the data owner of the new calendar.
2207 ///
2208 /// Note: We recommend to authenticate as the intended data owner of the calendar. You can use domain-wide delegation of authority to allow applications to act on behalf of a specific user. Don't use a service account for authentication. If you use a service account for authentication, the service account is the data owner, which can lead to unexpected behavior. For example, if a service account is the data owner, data ownership cannot be transferred.
2209 ///
2210 /// # Arguments
2211 ///
2212 /// * `request` - No description provided.
2213 pub fn insert(&self, request: Calendar) -> CalendarInsertCall<'a, C> {
2214 CalendarInsertCall {
2215 hub: self.hub,
2216 _request: request,
2217 _delegate: Default::default(),
2218 _additional_params: Default::default(),
2219 _scopes: Default::default(),
2220 }
2221 }
2222
2223 /// Create a builder to help you perform the following task:
2224 ///
2225 /// Updates metadata for a calendar. This method supports patch semantics.
2226 ///
2227 /// # Arguments
2228 ///
2229 /// * `request` - No description provided.
2230 /// * `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.
2231 pub fn patch(&self, request: Calendar, calendar_id: &str) -> CalendarPatchCall<'a, C> {
2232 CalendarPatchCall {
2233 hub: self.hub,
2234 _request: request,
2235 _calendar_id: calendar_id.to_string(),
2236 _delegate: Default::default(),
2237 _additional_params: Default::default(),
2238 _scopes: Default::default(),
2239 }
2240 }
2241
2242 /// Create a builder to help you perform the following task:
2243 ///
2244 /// Updates metadata for a calendar.
2245 ///
2246 /// # Arguments
2247 ///
2248 /// * `request` - No description provided.
2249 /// * `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.
2250 pub fn update(&self, request: Calendar, calendar_id: &str) -> CalendarUpdateCall<'a, C> {
2251 CalendarUpdateCall {
2252 hub: self.hub,
2253 _request: request,
2254 _calendar_id: calendar_id.to_string(),
2255 _delegate: Default::default(),
2256 _additional_params: Default::default(),
2257 _scopes: Default::default(),
2258 }
2259 }
2260}
2261
2262/// A builder providing access to all methods supported on *channel* resources.
2263/// It is not used directly, but through the [`CalendarHub`] hub.
2264///
2265/// # Example
2266///
2267/// Instantiate a resource builder
2268///
2269/// ```test_harness,no_run
2270/// extern crate hyper;
2271/// extern crate hyper_rustls;
2272/// extern crate google_calendar3 as calendar3;
2273///
2274/// # async fn dox() {
2275/// use calendar3::{CalendarHub, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
2276///
2277/// let secret: yup_oauth2::ApplicationSecret = Default::default();
2278/// let connector = hyper_rustls::HttpsConnectorBuilder::new()
2279/// .with_native_roots()
2280/// .unwrap()
2281/// .https_only()
2282/// .enable_http2()
2283/// .build();
2284///
2285/// let executor = hyper_util::rt::TokioExecutor::new();
2286/// let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
2287/// secret,
2288/// yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
2289/// yup_oauth2::client::CustomHyperClientBuilder::from(
2290/// hyper_util::client::legacy::Client::builder(executor).build(connector),
2291/// ),
2292/// ).build().await.unwrap();
2293///
2294/// let client = hyper_util::client::legacy::Client::builder(
2295/// hyper_util::rt::TokioExecutor::new()
2296/// )
2297/// .build(
2298/// hyper_rustls::HttpsConnectorBuilder::new()
2299/// .with_native_roots()
2300/// .unwrap()
2301/// .https_or_http()
2302/// .enable_http2()
2303/// .build()
2304/// );
2305/// let mut hub = CalendarHub::new(client, auth);
2306/// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders*
2307/// // like `stop(...)`
2308/// // to build up your call.
2309/// let rb = hub.channels();
2310/// # }
2311/// ```
2312pub struct ChannelMethods<'a, C>
2313where
2314 C: 'a,
2315{
2316 hub: &'a CalendarHub<C>,
2317}
2318
2319impl<'a, C> common::MethodsBuilder for ChannelMethods<'a, C> {}
2320
2321impl<'a, C> ChannelMethods<'a, C> {
2322 /// Create a builder to help you perform the following task:
2323 ///
2324 /// Stop watching resources through this channel
2325 ///
2326 /// # Arguments
2327 ///
2328 /// * `request` - No description provided.
2329 pub fn stop(&self, request: Channel) -> ChannelStopCall<'a, C> {
2330 ChannelStopCall {
2331 hub: self.hub,
2332 _request: request,
2333 _delegate: Default::default(),
2334 _additional_params: Default::default(),
2335 _scopes: Default::default(),
2336 }
2337 }
2338}
2339
2340/// A builder providing access to all methods supported on *color* resources.
2341/// It is not used directly, but through the [`CalendarHub`] hub.
2342///
2343/// # Example
2344///
2345/// Instantiate a resource builder
2346///
2347/// ```test_harness,no_run
2348/// extern crate hyper;
2349/// extern crate hyper_rustls;
2350/// extern crate google_calendar3 as calendar3;
2351///
2352/// # async fn dox() {
2353/// use calendar3::{CalendarHub, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
2354///
2355/// let secret: yup_oauth2::ApplicationSecret = Default::default();
2356/// let connector = hyper_rustls::HttpsConnectorBuilder::new()
2357/// .with_native_roots()
2358/// .unwrap()
2359/// .https_only()
2360/// .enable_http2()
2361/// .build();
2362///
2363/// let executor = hyper_util::rt::TokioExecutor::new();
2364/// let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
2365/// secret,
2366/// yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
2367/// yup_oauth2::client::CustomHyperClientBuilder::from(
2368/// hyper_util::client::legacy::Client::builder(executor).build(connector),
2369/// ),
2370/// ).build().await.unwrap();
2371///
2372/// let client = hyper_util::client::legacy::Client::builder(
2373/// hyper_util::rt::TokioExecutor::new()
2374/// )
2375/// .build(
2376/// hyper_rustls::HttpsConnectorBuilder::new()
2377/// .with_native_roots()
2378/// .unwrap()
2379/// .https_or_http()
2380/// .enable_http2()
2381/// .build()
2382/// );
2383/// let mut hub = CalendarHub::new(client, auth);
2384/// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders*
2385/// // like `get(...)`
2386/// // to build up your call.
2387/// let rb = hub.colors();
2388/// # }
2389/// ```
2390pub struct ColorMethods<'a, C>
2391where
2392 C: 'a,
2393{
2394 hub: &'a CalendarHub<C>,
2395}
2396
2397impl<'a, C> common::MethodsBuilder for ColorMethods<'a, C> {}
2398
2399impl<'a, C> ColorMethods<'a, C> {
2400 /// Create a builder to help you perform the following task:
2401 ///
2402 /// Returns the color definitions for calendars and events.
2403 pub fn get(&self) -> ColorGetCall<'a, C> {
2404 ColorGetCall {
2405 hub: self.hub,
2406 _delegate: Default::default(),
2407 _additional_params: Default::default(),
2408 _scopes: Default::default(),
2409 }
2410 }
2411}
2412
2413/// A builder providing access to all methods supported on *event* resources.
2414/// It is not used directly, but through the [`CalendarHub`] hub.
2415///
2416/// # Example
2417///
2418/// Instantiate a resource builder
2419///
2420/// ```test_harness,no_run
2421/// extern crate hyper;
2422/// extern crate hyper_rustls;
2423/// extern crate google_calendar3 as calendar3;
2424///
2425/// # async fn dox() {
2426/// use calendar3::{CalendarHub, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
2427///
2428/// let secret: yup_oauth2::ApplicationSecret = Default::default();
2429/// let connector = hyper_rustls::HttpsConnectorBuilder::new()
2430/// .with_native_roots()
2431/// .unwrap()
2432/// .https_only()
2433/// .enable_http2()
2434/// .build();
2435///
2436/// let executor = hyper_util::rt::TokioExecutor::new();
2437/// let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
2438/// secret,
2439/// yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
2440/// yup_oauth2::client::CustomHyperClientBuilder::from(
2441/// hyper_util::client::legacy::Client::builder(executor).build(connector),
2442/// ),
2443/// ).build().await.unwrap();
2444///
2445/// let client = hyper_util::client::legacy::Client::builder(
2446/// hyper_util::rt::TokioExecutor::new()
2447/// )
2448/// .build(
2449/// hyper_rustls::HttpsConnectorBuilder::new()
2450/// .with_native_roots()
2451/// .unwrap()
2452/// .https_or_http()
2453/// .enable_http2()
2454/// .build()
2455/// );
2456/// let mut hub = CalendarHub::new(client, auth);
2457/// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders*
2458/// // like `delete(...)`, `get(...)`, `import(...)`, `insert(...)`, `instances(...)`, `list(...)`, `move_(...)`, `patch(...)`, `quick_add(...)`, `update(...)` and `watch(...)`
2459/// // to build up your call.
2460/// let rb = hub.events();
2461/// # }
2462/// ```
2463pub struct EventMethods<'a, C>
2464where
2465 C: 'a,
2466{
2467 hub: &'a CalendarHub<C>,
2468}
2469
2470impl<'a, C> common::MethodsBuilder for EventMethods<'a, C> {}
2471
2472impl<'a, C> EventMethods<'a, C> {
2473 /// Create a builder to help you perform the following task:
2474 ///
2475 /// Deletes an event.
2476 ///
2477 /// # Arguments
2478 ///
2479 /// * `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.
2480 /// * `eventId` - Event identifier.
2481 pub fn delete(&self, calendar_id: &str, event_id: &str) -> EventDeleteCall<'a, C> {
2482 EventDeleteCall {
2483 hub: self.hub,
2484 _calendar_id: calendar_id.to_string(),
2485 _event_id: event_id.to_string(),
2486 _send_updates: Default::default(),
2487 _send_notifications: Default::default(),
2488 _delegate: Default::default(),
2489 _additional_params: Default::default(),
2490 _scopes: Default::default(),
2491 }
2492 }
2493
2494 /// Create a builder to help you perform the following task:
2495 ///
2496 /// 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.
2497 ///
2498 /// # Arguments
2499 ///
2500 /// * `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.
2501 /// * `eventId` - Event identifier.
2502 pub fn get(&self, calendar_id: &str, event_id: &str) -> EventGetCall<'a, C> {
2503 EventGetCall {
2504 hub: self.hub,
2505 _calendar_id: calendar_id.to_string(),
2506 _event_id: event_id.to_string(),
2507 _time_zone: Default::default(),
2508 _max_attendees: Default::default(),
2509 _always_include_email: Default::default(),
2510 _delegate: Default::default(),
2511 _additional_params: Default::default(),
2512 _scopes: Default::default(),
2513 }
2514 }
2515
2516 /// Create a builder to help you perform the following task:
2517 ///
2518 /// 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.
2519 /// 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.
2520 ///
2521 /// # Arguments
2522 ///
2523 /// * `request` - No description provided.
2524 /// * `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.
2525 pub fn import(&self, request: Event, calendar_id: &str) -> EventImportCall<'a, C> {
2526 EventImportCall {
2527 hub: self.hub,
2528 _request: request,
2529 _calendar_id: calendar_id.to_string(),
2530 _supports_attachments: Default::default(),
2531 _conference_data_version: Default::default(),
2532 _delegate: Default::default(),
2533 _additional_params: Default::default(),
2534 _scopes: Default::default(),
2535 }
2536 }
2537
2538 /// Create a builder to help you perform the following task:
2539 ///
2540 /// Creates an event.
2541 ///
2542 /// # Arguments
2543 ///
2544 /// * `request` - No description provided.
2545 /// * `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.
2546 pub fn insert(&self, request: Event, calendar_id: &str) -> EventInsertCall<'a, C> {
2547 EventInsertCall {
2548 hub: self.hub,
2549 _request: request,
2550 _calendar_id: calendar_id.to_string(),
2551 _supports_attachments: Default::default(),
2552 _send_updates: Default::default(),
2553 _send_notifications: Default::default(),
2554 _max_attendees: Default::default(),
2555 _conference_data_version: Default::default(),
2556 _delegate: Default::default(),
2557 _additional_params: Default::default(),
2558 _scopes: Default::default(),
2559 }
2560 }
2561
2562 /// Create a builder to help you perform the following task:
2563 ///
2564 /// Returns instances of the specified recurring event.
2565 ///
2566 /// # Arguments
2567 ///
2568 /// * `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.
2569 /// * `eventId` - Recurring event identifier.
2570 pub fn instances(&self, calendar_id: &str, event_id: &str) -> EventInstanceCall<'a, C> {
2571 EventInstanceCall {
2572 hub: self.hub,
2573 _calendar_id: calendar_id.to_string(),
2574 _event_id: event_id.to_string(),
2575 _time_zone: Default::default(),
2576 _time_min: Default::default(),
2577 _time_max: Default::default(),
2578 _show_deleted: Default::default(),
2579 _page_token: Default::default(),
2580 _original_start: Default::default(),
2581 _max_results: Default::default(),
2582 _max_attendees: Default::default(),
2583 _always_include_email: Default::default(),
2584 _delegate: Default::default(),
2585 _additional_params: Default::default(),
2586 _scopes: Default::default(),
2587 }
2588 }
2589
2590 /// Create a builder to help you perform the following task:
2591 ///
2592 /// Returns events on the specified calendar.
2593 ///
2594 /// # Arguments
2595 ///
2596 /// * `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.
2597 pub fn list(&self, calendar_id: &str) -> EventListCall<'a, C> {
2598 EventListCall {
2599 hub: self.hub,
2600 _calendar_id: calendar_id.to_string(),
2601 _updated_min: Default::default(),
2602 _time_zone: Default::default(),
2603 _time_min: Default::default(),
2604 _time_max: Default::default(),
2605 _sync_token: Default::default(),
2606 _single_events: Default::default(),
2607 _show_hidden_invitations: Default::default(),
2608 _show_deleted: Default::default(),
2609 _shared_extended_property: Default::default(),
2610 _q: Default::default(),
2611 _private_extended_property: Default::default(),
2612 _page_token: Default::default(),
2613 _order_by: Default::default(),
2614 _max_results: Default::default(),
2615 _max_attendees: Default::default(),
2616 _i_cal_uid: Default::default(),
2617 _event_types: Default::default(),
2618 _always_include_email: Default::default(),
2619 _delegate: Default::default(),
2620 _additional_params: Default::default(),
2621 _scopes: Default::default(),
2622 }
2623 }
2624
2625 /// Create a builder to help you perform the following task:
2626 ///
2627 /// Moves an event to another calendar, i.e. changes an event's organizer. Note that only default events can be moved; birthday, focusTime, fromGmail, outOfOffice and workingLocation events cannot be moved.
2628 ///
2629 /// # Arguments
2630 ///
2631 /// * `calendarId` - Calendar identifier of the source calendar where the event currently is on.
2632 /// * `eventId` - Event identifier.
2633 /// * `destination` - Calendar identifier of the target calendar where the event is to be moved to.
2634 pub fn move_(
2635 &self,
2636 calendar_id: &str,
2637 event_id: &str,
2638 destination: &str,
2639 ) -> EventMoveCall<'a, C> {
2640 EventMoveCall {
2641 hub: self.hub,
2642 _calendar_id: calendar_id.to_string(),
2643 _event_id: event_id.to_string(),
2644 _destination: destination.to_string(),
2645 _send_updates: Default::default(),
2646 _send_notifications: Default::default(),
2647 _delegate: Default::default(),
2648 _additional_params: Default::default(),
2649 _scopes: Default::default(),
2650 }
2651 }
2652
2653 /// Create a builder to help you perform the following task:
2654 ///
2655 /// Updates an event. This method supports patch semantics.
2656 ///
2657 /// # Arguments
2658 ///
2659 /// * `request` - No description provided.
2660 /// * `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.
2661 /// * `eventId` - Event identifier.
2662 pub fn patch(
2663 &self,
2664 request: Event,
2665 calendar_id: &str,
2666 event_id: &str,
2667 ) -> EventPatchCall<'a, C> {
2668 EventPatchCall {
2669 hub: self.hub,
2670 _request: request,
2671 _calendar_id: calendar_id.to_string(),
2672 _event_id: event_id.to_string(),
2673 _supports_attachments: Default::default(),
2674 _send_updates: Default::default(),
2675 _send_notifications: Default::default(),
2676 _max_attendees: Default::default(),
2677 _conference_data_version: Default::default(),
2678 _always_include_email: Default::default(),
2679 _delegate: Default::default(),
2680 _additional_params: Default::default(),
2681 _scopes: Default::default(),
2682 }
2683 }
2684
2685 /// Create a builder to help you perform the following task:
2686 ///
2687 /// Creates an event based on a simple text string.
2688 ///
2689 /// # Arguments
2690 ///
2691 /// * `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.
2692 /// * `text` - The text describing the event to be created.
2693 pub fn quick_add(&self, calendar_id: &str, text: &str) -> EventQuickAddCall<'a, C> {
2694 EventQuickAddCall {
2695 hub: self.hub,
2696 _calendar_id: calendar_id.to_string(),
2697 _text: text.to_string(),
2698 _send_updates: Default::default(),
2699 _send_notifications: Default::default(),
2700 _delegate: Default::default(),
2701 _additional_params: Default::default(),
2702 _scopes: Default::default(),
2703 }
2704 }
2705
2706 /// Create a builder to help you perform the following task:
2707 ///
2708 /// Updates an event.
2709 ///
2710 /// # Arguments
2711 ///
2712 /// * `request` - No description provided.
2713 /// * `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.
2714 /// * `eventId` - Event identifier.
2715 pub fn update(
2716 &self,
2717 request: Event,
2718 calendar_id: &str,
2719 event_id: &str,
2720 ) -> EventUpdateCall<'a, C> {
2721 EventUpdateCall {
2722 hub: self.hub,
2723 _request: request,
2724 _calendar_id: calendar_id.to_string(),
2725 _event_id: event_id.to_string(),
2726 _supports_attachments: Default::default(),
2727 _send_updates: Default::default(),
2728 _send_notifications: Default::default(),
2729 _max_attendees: Default::default(),
2730 _conference_data_version: Default::default(),
2731 _always_include_email: Default::default(),
2732 _delegate: Default::default(),
2733 _additional_params: Default::default(),
2734 _scopes: Default::default(),
2735 }
2736 }
2737
2738 /// Create a builder to help you perform the following task:
2739 ///
2740 /// Watch for changes to Events resources.
2741 ///
2742 /// # Arguments
2743 ///
2744 /// * `request` - No description provided.
2745 /// * `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.
2746 pub fn watch(&self, request: Channel, calendar_id: &str) -> EventWatchCall<'a, C> {
2747 EventWatchCall {
2748 hub: self.hub,
2749 _request: request,
2750 _calendar_id: calendar_id.to_string(),
2751 _updated_min: Default::default(),
2752 _time_zone: Default::default(),
2753 _time_min: Default::default(),
2754 _time_max: Default::default(),
2755 _sync_token: Default::default(),
2756 _single_events: Default::default(),
2757 _show_hidden_invitations: Default::default(),
2758 _show_deleted: Default::default(),
2759 _shared_extended_property: Default::default(),
2760 _q: Default::default(),
2761 _private_extended_property: Default::default(),
2762 _page_token: Default::default(),
2763 _order_by: Default::default(),
2764 _max_results: Default::default(),
2765 _max_attendees: Default::default(),
2766 _i_cal_uid: Default::default(),
2767 _event_types: Default::default(),
2768 _always_include_email: Default::default(),
2769 _delegate: Default::default(),
2770 _additional_params: Default::default(),
2771 _scopes: Default::default(),
2772 }
2773 }
2774}
2775
2776/// A builder providing access to all methods supported on *freebusy* resources.
2777/// It is not used directly, but through the [`CalendarHub`] hub.
2778///
2779/// # Example
2780///
2781/// Instantiate a resource builder
2782///
2783/// ```test_harness,no_run
2784/// extern crate hyper;
2785/// extern crate hyper_rustls;
2786/// extern crate google_calendar3 as calendar3;
2787///
2788/// # async fn dox() {
2789/// use calendar3::{CalendarHub, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
2790///
2791/// let secret: yup_oauth2::ApplicationSecret = Default::default();
2792/// let connector = hyper_rustls::HttpsConnectorBuilder::new()
2793/// .with_native_roots()
2794/// .unwrap()
2795/// .https_only()
2796/// .enable_http2()
2797/// .build();
2798///
2799/// let executor = hyper_util::rt::TokioExecutor::new();
2800/// let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
2801/// secret,
2802/// yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
2803/// yup_oauth2::client::CustomHyperClientBuilder::from(
2804/// hyper_util::client::legacy::Client::builder(executor).build(connector),
2805/// ),
2806/// ).build().await.unwrap();
2807///
2808/// let client = hyper_util::client::legacy::Client::builder(
2809/// hyper_util::rt::TokioExecutor::new()
2810/// )
2811/// .build(
2812/// hyper_rustls::HttpsConnectorBuilder::new()
2813/// .with_native_roots()
2814/// .unwrap()
2815/// .https_or_http()
2816/// .enable_http2()
2817/// .build()
2818/// );
2819/// let mut hub = CalendarHub::new(client, auth);
2820/// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders*
2821/// // like `query(...)`
2822/// // to build up your call.
2823/// let rb = hub.freebusy();
2824/// # }
2825/// ```
2826pub struct FreebusyMethods<'a, C>
2827where
2828 C: 'a,
2829{
2830 hub: &'a CalendarHub<C>,
2831}
2832
2833impl<'a, C> common::MethodsBuilder for FreebusyMethods<'a, C> {}
2834
2835impl<'a, C> FreebusyMethods<'a, C> {
2836 /// Create a builder to help you perform the following task:
2837 ///
2838 /// Returns free/busy information for a set of calendars.
2839 ///
2840 /// # Arguments
2841 ///
2842 /// * `request` - No description provided.
2843 pub fn query(&self, request: FreeBusyRequest) -> FreebusyQueryCall<'a, C> {
2844 FreebusyQueryCall {
2845 hub: self.hub,
2846 _request: request,
2847 _delegate: Default::default(),
2848 _additional_params: Default::default(),
2849 _scopes: Default::default(),
2850 }
2851 }
2852}
2853
2854/// A builder providing access to all methods supported on *setting* resources.
2855/// It is not used directly, but through the [`CalendarHub`] hub.
2856///
2857/// # Example
2858///
2859/// Instantiate a resource builder
2860///
2861/// ```test_harness,no_run
2862/// extern crate hyper;
2863/// extern crate hyper_rustls;
2864/// extern crate google_calendar3 as calendar3;
2865///
2866/// # async fn dox() {
2867/// use calendar3::{CalendarHub, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
2868///
2869/// let secret: yup_oauth2::ApplicationSecret = Default::default();
2870/// let connector = hyper_rustls::HttpsConnectorBuilder::new()
2871/// .with_native_roots()
2872/// .unwrap()
2873/// .https_only()
2874/// .enable_http2()
2875/// .build();
2876///
2877/// let executor = hyper_util::rt::TokioExecutor::new();
2878/// let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
2879/// secret,
2880/// yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
2881/// yup_oauth2::client::CustomHyperClientBuilder::from(
2882/// hyper_util::client::legacy::Client::builder(executor).build(connector),
2883/// ),
2884/// ).build().await.unwrap();
2885///
2886/// let client = hyper_util::client::legacy::Client::builder(
2887/// hyper_util::rt::TokioExecutor::new()
2888/// )
2889/// .build(
2890/// hyper_rustls::HttpsConnectorBuilder::new()
2891/// .with_native_roots()
2892/// .unwrap()
2893/// .https_or_http()
2894/// .enable_http2()
2895/// .build()
2896/// );
2897/// let mut hub = CalendarHub::new(client, auth);
2898/// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders*
2899/// // like `get(...)`, `list(...)` and `watch(...)`
2900/// // to build up your call.
2901/// let rb = hub.settings();
2902/// # }
2903/// ```
2904pub struct SettingMethods<'a, C>
2905where
2906 C: 'a,
2907{
2908 hub: &'a CalendarHub<C>,
2909}
2910
2911impl<'a, C> common::MethodsBuilder for SettingMethods<'a, C> {}
2912
2913impl<'a, C> SettingMethods<'a, C> {
2914 /// Create a builder to help you perform the following task:
2915 ///
2916 /// Returns a single user setting.
2917 ///
2918 /// # Arguments
2919 ///
2920 /// * `setting` - The id of the user setting.
2921 pub fn get(&self, setting: &str) -> SettingGetCall<'a, C> {
2922 SettingGetCall {
2923 hub: self.hub,
2924 _setting: setting.to_string(),
2925 _delegate: Default::default(),
2926 _additional_params: Default::default(),
2927 _scopes: Default::default(),
2928 }
2929 }
2930
2931 /// Create a builder to help you perform the following task:
2932 ///
2933 /// Returns all user settings for the authenticated user.
2934 pub fn list(&self) -> SettingListCall<'a, C> {
2935 SettingListCall {
2936 hub: self.hub,
2937 _sync_token: Default::default(),
2938 _page_token: Default::default(),
2939 _max_results: Default::default(),
2940 _delegate: Default::default(),
2941 _additional_params: Default::default(),
2942 _scopes: Default::default(),
2943 }
2944 }
2945
2946 /// Create a builder to help you perform the following task:
2947 ///
2948 /// Watch for changes to Settings resources.
2949 ///
2950 /// # Arguments
2951 ///
2952 /// * `request` - No description provided.
2953 pub fn watch(&self, request: Channel) -> SettingWatchCall<'a, C> {
2954 SettingWatchCall {
2955 hub: self.hub,
2956 _request: request,
2957 _sync_token: Default::default(),
2958 _page_token: Default::default(),
2959 _max_results: Default::default(),
2960 _delegate: Default::default(),
2961 _additional_params: Default::default(),
2962 _scopes: Default::default(),
2963 }
2964 }
2965}
2966
2967// ###################
2968// CallBuilders ###
2969// #################
2970
2971/// Deletes an access control rule.
2972///
2973/// A builder for the *delete* method supported by a *acl* resource.
2974/// It is not used directly, but through a [`AclMethods`] instance.
2975///
2976/// # Example
2977///
2978/// Instantiate a resource method builder
2979///
2980/// ```test_harness,no_run
2981/// # extern crate hyper;
2982/// # extern crate hyper_rustls;
2983/// # extern crate google_calendar3 as calendar3;
2984/// # async fn dox() {
2985/// # use calendar3::{CalendarHub, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
2986///
2987/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
2988/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
2989/// # .with_native_roots()
2990/// # .unwrap()
2991/// # .https_only()
2992/// # .enable_http2()
2993/// # .build();
2994///
2995/// # let executor = hyper_util::rt::TokioExecutor::new();
2996/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
2997/// # secret,
2998/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
2999/// # yup_oauth2::client::CustomHyperClientBuilder::from(
3000/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
3001/// # ),
3002/// # ).build().await.unwrap();
3003///
3004/// # let client = hyper_util::client::legacy::Client::builder(
3005/// # hyper_util::rt::TokioExecutor::new()
3006/// # )
3007/// # .build(
3008/// # hyper_rustls::HttpsConnectorBuilder::new()
3009/// # .with_native_roots()
3010/// # .unwrap()
3011/// # .https_or_http()
3012/// # .enable_http2()
3013/// # .build()
3014/// # );
3015/// # let mut hub = CalendarHub::new(client, auth);
3016/// // You can configure optional parameters by calling the respective setters at will, and
3017/// // execute the final call using `doit()`.
3018/// // Values shown here are possibly random and not representative !
3019/// let result = hub.acl().delete("calendarId", "ruleId")
3020/// .doit().await;
3021/// # }
3022/// ```
3023pub struct AclDeleteCall<'a, C>
3024where
3025 C: 'a,
3026{
3027 hub: &'a CalendarHub<C>,
3028 _calendar_id: String,
3029 _rule_id: String,
3030 _delegate: Option<&'a mut dyn common::Delegate>,
3031 _additional_params: HashMap<String, String>,
3032 _scopes: BTreeSet<String>,
3033}
3034
3035impl<'a, C> common::CallBuilder for AclDeleteCall<'a, C> {}
3036
3037impl<'a, C> AclDeleteCall<'a, C>
3038where
3039 C: common::Connector,
3040{
3041 /// Perform the operation you have build so far.
3042 pub async fn doit(mut self) -> common::Result<common::Response> {
3043 use std::borrow::Cow;
3044 use std::io::{Read, Seek};
3045
3046 use common::{url::Params, ToParts};
3047 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
3048
3049 let mut dd = common::DefaultDelegate;
3050 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
3051 dlg.begin(common::MethodInfo {
3052 id: "calendar.acl.delete",
3053 http_method: hyper::Method::DELETE,
3054 });
3055
3056 for &field in ["calendarId", "ruleId"].iter() {
3057 if self._additional_params.contains_key(field) {
3058 dlg.finished(false);
3059 return Err(common::Error::FieldClash(field));
3060 }
3061 }
3062
3063 let mut params = Params::with_capacity(3 + self._additional_params.len());
3064 params.push("calendarId", self._calendar_id);
3065 params.push("ruleId", self._rule_id);
3066
3067 params.extend(self._additional_params.iter());
3068
3069 let mut url = self.hub._base_url.clone() + "calendars/{calendarId}/acl/{ruleId}";
3070 if self._scopes.is_empty() {
3071 self._scopes.insert(Scope::Full.as_ref().to_string());
3072 }
3073
3074 #[allow(clippy::single_element_loop)]
3075 for &(find_this, param_name) in
3076 [("{calendarId}", "calendarId"), ("{ruleId}", "ruleId")].iter()
3077 {
3078 url = params.uri_replacement(url, param_name, find_this, false);
3079 }
3080 {
3081 let to_remove = ["ruleId", "calendarId"];
3082 params.remove_params(&to_remove);
3083 }
3084
3085 let url = params.parse_with_url(&url);
3086
3087 loop {
3088 let token = match self
3089 .hub
3090 .auth
3091 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
3092 .await
3093 {
3094 Ok(token) => token,
3095 Err(e) => match dlg.token(e) {
3096 Ok(token) => token,
3097 Err(e) => {
3098 dlg.finished(false);
3099 return Err(common::Error::MissingToken(e));
3100 }
3101 },
3102 };
3103 let mut req_result = {
3104 let client = &self.hub.client;
3105 dlg.pre_request();
3106 let mut req_builder = hyper::Request::builder()
3107 .method(hyper::Method::DELETE)
3108 .uri(url.as_str())
3109 .header(USER_AGENT, self.hub._user_agent.clone());
3110
3111 if let Some(token) = token.as_ref() {
3112 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
3113 }
3114
3115 let request = req_builder
3116 .header(CONTENT_LENGTH, 0_u64)
3117 .body(common::to_body::<String>(None));
3118
3119 client.request(request.unwrap()).await
3120 };
3121
3122 match req_result {
3123 Err(err) => {
3124 if let common::Retry::After(d) = dlg.http_error(&err) {
3125 sleep(d).await;
3126 continue;
3127 }
3128 dlg.finished(false);
3129 return Err(common::Error::HttpError(err));
3130 }
3131 Ok(res) => {
3132 let (mut parts, body) = res.into_parts();
3133 let mut body = common::Body::new(body);
3134 if !parts.status.is_success() {
3135 let bytes = common::to_bytes(body).await.unwrap_or_default();
3136 let error = serde_json::from_str(&common::to_string(&bytes));
3137 let response = common::to_response(parts, bytes.into());
3138
3139 if let common::Retry::After(d) =
3140 dlg.http_failure(&response, error.as_ref().ok())
3141 {
3142 sleep(d).await;
3143 continue;
3144 }
3145
3146 dlg.finished(false);
3147
3148 return Err(match error {
3149 Ok(value) => common::Error::BadRequest(value),
3150 _ => common::Error::Failure(response),
3151 });
3152 }
3153 let response = common::Response::from_parts(parts, body);
3154
3155 dlg.finished(true);
3156 return Ok(response);
3157 }
3158 }
3159 }
3160 }
3161
3162 /// 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.
3163 ///
3164 /// Sets the *calendar id* path property to the given value.
3165 ///
3166 /// Even though the property as already been set when instantiating this call,
3167 /// we provide this method for API completeness.
3168 pub fn calendar_id(mut self, new_value: &str) -> AclDeleteCall<'a, C> {
3169 self._calendar_id = new_value.to_string();
3170 self
3171 }
3172 /// ACL rule identifier.
3173 ///
3174 /// Sets the *rule id* path property to the given value.
3175 ///
3176 /// Even though the property as already been set when instantiating this call,
3177 /// we provide this method for API completeness.
3178 pub fn rule_id(mut self, new_value: &str) -> AclDeleteCall<'a, C> {
3179 self._rule_id = new_value.to_string();
3180 self
3181 }
3182 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
3183 /// while executing the actual API request.
3184 ///
3185 /// ````text
3186 /// It should be used to handle progress information, and to implement a certain level of resilience.
3187 /// ````
3188 ///
3189 /// Sets the *delegate* property to the given value.
3190 pub fn delegate(mut self, new_value: &'a mut dyn common::Delegate) -> AclDeleteCall<'a, C> {
3191 self._delegate = Some(new_value);
3192 self
3193 }
3194
3195 /// Set any additional parameter of the query string used in the request.
3196 /// It should be used to set parameters which are not yet available through their own
3197 /// setters.
3198 ///
3199 /// Please note that this method must not be used to set any of the known parameters
3200 /// which have their own setter method. If done anyway, the request will fail.
3201 ///
3202 /// # Additional Parameters
3203 ///
3204 /// * *alt* (query-string) - Data format for the response.
3205 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
3206 /// * *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.
3207 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
3208 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
3209 /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
3210 /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
3211 pub fn param<T>(mut self, name: T, value: T) -> AclDeleteCall<'a, C>
3212 where
3213 T: AsRef<str>,
3214 {
3215 self._additional_params
3216 .insert(name.as_ref().to_string(), value.as_ref().to_string());
3217 self
3218 }
3219
3220 /// Identifies the authorization scope for the method you are building.
3221 ///
3222 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
3223 /// [`Scope::Full`].
3224 ///
3225 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
3226 /// tokens for more than one scope.
3227 ///
3228 /// Usually there is more than one suitable scope to authorize an operation, some of which may
3229 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
3230 /// sufficient, a read-write scope will do as well.
3231 pub fn add_scope<St>(mut self, scope: St) -> AclDeleteCall<'a, C>
3232 where
3233 St: AsRef<str>,
3234 {
3235 self._scopes.insert(String::from(scope.as_ref()));
3236 self
3237 }
3238 /// Identifies the authorization scope(s) for the method you are building.
3239 ///
3240 /// See [`Self::add_scope()`] for details.
3241 pub fn add_scopes<I, St>(mut self, scopes: I) -> AclDeleteCall<'a, C>
3242 where
3243 I: IntoIterator<Item = St>,
3244 St: AsRef<str>,
3245 {
3246 self._scopes
3247 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
3248 self
3249 }
3250
3251 /// Removes all scopes, and no default scope will be used either.
3252 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
3253 /// for details).
3254 pub fn clear_scopes(mut self) -> AclDeleteCall<'a, C> {
3255 self._scopes.clear();
3256 self
3257 }
3258}
3259
3260/// Returns an access control rule.
3261///
3262/// A builder for the *get* method supported by a *acl* resource.
3263/// It is not used directly, but through a [`AclMethods`] instance.
3264///
3265/// # Example
3266///
3267/// Instantiate a resource method builder
3268///
3269/// ```test_harness,no_run
3270/// # extern crate hyper;
3271/// # extern crate hyper_rustls;
3272/// # extern crate google_calendar3 as calendar3;
3273/// # async fn dox() {
3274/// # use calendar3::{CalendarHub, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
3275///
3276/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
3277/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
3278/// # .with_native_roots()
3279/// # .unwrap()
3280/// # .https_only()
3281/// # .enable_http2()
3282/// # .build();
3283///
3284/// # let executor = hyper_util::rt::TokioExecutor::new();
3285/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
3286/// # secret,
3287/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
3288/// # yup_oauth2::client::CustomHyperClientBuilder::from(
3289/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
3290/// # ),
3291/// # ).build().await.unwrap();
3292///
3293/// # let client = hyper_util::client::legacy::Client::builder(
3294/// # hyper_util::rt::TokioExecutor::new()
3295/// # )
3296/// # .build(
3297/// # hyper_rustls::HttpsConnectorBuilder::new()
3298/// # .with_native_roots()
3299/// # .unwrap()
3300/// # .https_or_http()
3301/// # .enable_http2()
3302/// # .build()
3303/// # );
3304/// # let mut hub = CalendarHub::new(client, auth);
3305/// // You can configure optional parameters by calling the respective setters at will, and
3306/// // execute the final call using `doit()`.
3307/// // Values shown here are possibly random and not representative !
3308/// let result = hub.acl().get("calendarId", "ruleId")
3309/// .doit().await;
3310/// # }
3311/// ```
3312pub struct AclGetCall<'a, C>
3313where
3314 C: 'a,
3315{
3316 hub: &'a CalendarHub<C>,
3317 _calendar_id: String,
3318 _rule_id: String,
3319 _delegate: Option<&'a mut dyn common::Delegate>,
3320 _additional_params: HashMap<String, String>,
3321 _scopes: BTreeSet<String>,
3322}
3323
3324impl<'a, C> common::CallBuilder for AclGetCall<'a, C> {}
3325
3326impl<'a, C> AclGetCall<'a, C>
3327where
3328 C: common::Connector,
3329{
3330 /// Perform the operation you have build so far.
3331 pub async fn doit(mut self) -> common::Result<(common::Response, AclRule)> {
3332 use std::borrow::Cow;
3333 use std::io::{Read, Seek};
3334
3335 use common::{url::Params, ToParts};
3336 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
3337
3338 let mut dd = common::DefaultDelegate;
3339 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
3340 dlg.begin(common::MethodInfo {
3341 id: "calendar.acl.get",
3342 http_method: hyper::Method::GET,
3343 });
3344
3345 for &field in ["alt", "calendarId", "ruleId"].iter() {
3346 if self._additional_params.contains_key(field) {
3347 dlg.finished(false);
3348 return Err(common::Error::FieldClash(field));
3349 }
3350 }
3351
3352 let mut params = Params::with_capacity(4 + self._additional_params.len());
3353 params.push("calendarId", self._calendar_id);
3354 params.push("ruleId", self._rule_id);
3355
3356 params.extend(self._additional_params.iter());
3357
3358 params.push("alt", "json");
3359 let mut url = self.hub._base_url.clone() + "calendars/{calendarId}/acl/{ruleId}";
3360 if self._scopes.is_empty() {
3361 self._scopes.insert(Scope::AclReadonly.as_ref().to_string());
3362 }
3363
3364 #[allow(clippy::single_element_loop)]
3365 for &(find_this, param_name) in
3366 [("{calendarId}", "calendarId"), ("{ruleId}", "ruleId")].iter()
3367 {
3368 url = params.uri_replacement(url, param_name, find_this, false);
3369 }
3370 {
3371 let to_remove = ["ruleId", "calendarId"];
3372 params.remove_params(&to_remove);
3373 }
3374
3375 let url = params.parse_with_url(&url);
3376
3377 loop {
3378 let token = match self
3379 .hub
3380 .auth
3381 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
3382 .await
3383 {
3384 Ok(token) => token,
3385 Err(e) => match dlg.token(e) {
3386 Ok(token) => token,
3387 Err(e) => {
3388 dlg.finished(false);
3389 return Err(common::Error::MissingToken(e));
3390 }
3391 },
3392 };
3393 let mut req_result = {
3394 let client = &self.hub.client;
3395 dlg.pre_request();
3396 let mut req_builder = hyper::Request::builder()
3397 .method(hyper::Method::GET)
3398 .uri(url.as_str())
3399 .header(USER_AGENT, self.hub._user_agent.clone());
3400
3401 if let Some(token) = token.as_ref() {
3402 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
3403 }
3404
3405 let request = req_builder
3406 .header(CONTENT_LENGTH, 0_u64)
3407 .body(common::to_body::<String>(None));
3408
3409 client.request(request.unwrap()).await
3410 };
3411
3412 match req_result {
3413 Err(err) => {
3414 if let common::Retry::After(d) = dlg.http_error(&err) {
3415 sleep(d).await;
3416 continue;
3417 }
3418 dlg.finished(false);
3419 return Err(common::Error::HttpError(err));
3420 }
3421 Ok(res) => {
3422 let (mut parts, body) = res.into_parts();
3423 let mut body = common::Body::new(body);
3424 if !parts.status.is_success() {
3425 let bytes = common::to_bytes(body).await.unwrap_or_default();
3426 let error = serde_json::from_str(&common::to_string(&bytes));
3427 let response = common::to_response(parts, bytes.into());
3428
3429 if let common::Retry::After(d) =
3430 dlg.http_failure(&response, error.as_ref().ok())
3431 {
3432 sleep(d).await;
3433 continue;
3434 }
3435
3436 dlg.finished(false);
3437
3438 return Err(match error {
3439 Ok(value) => common::Error::BadRequest(value),
3440 _ => common::Error::Failure(response),
3441 });
3442 }
3443 let response = {
3444 let bytes = common::to_bytes(body).await.unwrap_or_default();
3445 let encoded = common::to_string(&bytes);
3446 match serde_json::from_str(&encoded) {
3447 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
3448 Err(error) => {
3449 dlg.response_json_decode_error(&encoded, &error);
3450 return Err(common::Error::JsonDecodeError(
3451 encoded.to_string(),
3452 error,
3453 ));
3454 }
3455 }
3456 };
3457
3458 dlg.finished(true);
3459 return Ok(response);
3460 }
3461 }
3462 }
3463 }
3464
3465 /// 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.
3466 ///
3467 /// Sets the *calendar id* path property to the given value.
3468 ///
3469 /// Even though the property as already been set when instantiating this call,
3470 /// we provide this method for API completeness.
3471 pub fn calendar_id(mut self, new_value: &str) -> AclGetCall<'a, C> {
3472 self._calendar_id = new_value.to_string();
3473 self
3474 }
3475 /// ACL rule identifier.
3476 ///
3477 /// Sets the *rule id* path property to the given value.
3478 ///
3479 /// Even though the property as already been set when instantiating this call,
3480 /// we provide this method for API completeness.
3481 pub fn rule_id(mut self, new_value: &str) -> AclGetCall<'a, C> {
3482 self._rule_id = new_value.to_string();
3483 self
3484 }
3485 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
3486 /// while executing the actual API request.
3487 ///
3488 /// ````text
3489 /// It should be used to handle progress information, and to implement a certain level of resilience.
3490 /// ````
3491 ///
3492 /// Sets the *delegate* property to the given value.
3493 pub fn delegate(mut self, new_value: &'a mut dyn common::Delegate) -> AclGetCall<'a, C> {
3494 self._delegate = Some(new_value);
3495 self
3496 }
3497
3498 /// Set any additional parameter of the query string used in the request.
3499 /// It should be used to set parameters which are not yet available through their own
3500 /// setters.
3501 ///
3502 /// Please note that this method must not be used to set any of the known parameters
3503 /// which have their own setter method. If done anyway, the request will fail.
3504 ///
3505 /// # Additional Parameters
3506 ///
3507 /// * *alt* (query-string) - Data format for the response.
3508 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
3509 /// * *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.
3510 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
3511 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
3512 /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
3513 /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
3514 pub fn param<T>(mut self, name: T, value: T) -> AclGetCall<'a, C>
3515 where
3516 T: AsRef<str>,
3517 {
3518 self._additional_params
3519 .insert(name.as_ref().to_string(), value.as_ref().to_string());
3520 self
3521 }
3522
3523 /// Identifies the authorization scope for the method you are building.
3524 ///
3525 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
3526 /// [`Scope::AclReadonly`].
3527 ///
3528 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
3529 /// tokens for more than one scope.
3530 ///
3531 /// Usually there is more than one suitable scope to authorize an operation, some of which may
3532 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
3533 /// sufficient, a read-write scope will do as well.
3534 pub fn add_scope<St>(mut self, scope: St) -> AclGetCall<'a, C>
3535 where
3536 St: AsRef<str>,
3537 {
3538 self._scopes.insert(String::from(scope.as_ref()));
3539 self
3540 }
3541 /// Identifies the authorization scope(s) for the method you are building.
3542 ///
3543 /// See [`Self::add_scope()`] for details.
3544 pub fn add_scopes<I, St>(mut self, scopes: I) -> AclGetCall<'a, C>
3545 where
3546 I: IntoIterator<Item = St>,
3547 St: AsRef<str>,
3548 {
3549 self._scopes
3550 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
3551 self
3552 }
3553
3554 /// Removes all scopes, and no default scope will be used either.
3555 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
3556 /// for details).
3557 pub fn clear_scopes(mut self) -> AclGetCall<'a, C> {
3558 self._scopes.clear();
3559 self
3560 }
3561}
3562
3563/// Creates an access control rule.
3564///
3565/// A builder for the *insert* method supported by a *acl* resource.
3566/// It is not used directly, but through a [`AclMethods`] instance.
3567///
3568/// # Example
3569///
3570/// Instantiate a resource method builder
3571///
3572/// ```test_harness,no_run
3573/// # extern crate hyper;
3574/// # extern crate hyper_rustls;
3575/// # extern crate google_calendar3 as calendar3;
3576/// use calendar3::api::AclRule;
3577/// # async fn dox() {
3578/// # use calendar3::{CalendarHub, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
3579///
3580/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
3581/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
3582/// # .with_native_roots()
3583/// # .unwrap()
3584/// # .https_only()
3585/// # .enable_http2()
3586/// # .build();
3587///
3588/// # let executor = hyper_util::rt::TokioExecutor::new();
3589/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
3590/// # secret,
3591/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
3592/// # yup_oauth2::client::CustomHyperClientBuilder::from(
3593/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
3594/// # ),
3595/// # ).build().await.unwrap();
3596///
3597/// # let client = hyper_util::client::legacy::Client::builder(
3598/// # hyper_util::rt::TokioExecutor::new()
3599/// # )
3600/// # .build(
3601/// # hyper_rustls::HttpsConnectorBuilder::new()
3602/// # .with_native_roots()
3603/// # .unwrap()
3604/// # .https_or_http()
3605/// # .enable_http2()
3606/// # .build()
3607/// # );
3608/// # let mut hub = CalendarHub::new(client, auth);
3609/// // As the method needs a request, you would usually fill it with the desired information
3610/// // into the respective structure. Some of the parts shown here might not be applicable !
3611/// // Values shown here are possibly random and not representative !
3612/// let mut req = AclRule::default();
3613///
3614/// // You can configure optional parameters by calling the respective setters at will, and
3615/// // execute the final call using `doit()`.
3616/// // Values shown here are possibly random and not representative !
3617/// let result = hub.acl().insert(req, "calendarId")
3618/// .send_notifications(false)
3619/// .doit().await;
3620/// # }
3621/// ```
3622pub struct AclInsertCall<'a, C>
3623where
3624 C: 'a,
3625{
3626 hub: &'a CalendarHub<C>,
3627 _request: AclRule,
3628 _calendar_id: String,
3629 _send_notifications: Option<bool>,
3630 _delegate: Option<&'a mut dyn common::Delegate>,
3631 _additional_params: HashMap<String, String>,
3632 _scopes: BTreeSet<String>,
3633}
3634
3635impl<'a, C> common::CallBuilder for AclInsertCall<'a, C> {}
3636
3637impl<'a, C> AclInsertCall<'a, C>
3638where
3639 C: common::Connector,
3640{
3641 /// Perform the operation you have build so far.
3642 pub async fn doit(mut self) -> common::Result<(common::Response, AclRule)> {
3643 use std::borrow::Cow;
3644 use std::io::{Read, Seek};
3645
3646 use common::{url::Params, ToParts};
3647 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
3648
3649 let mut dd = common::DefaultDelegate;
3650 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
3651 dlg.begin(common::MethodInfo {
3652 id: "calendar.acl.insert",
3653 http_method: hyper::Method::POST,
3654 });
3655
3656 for &field in ["alt", "calendarId", "sendNotifications"].iter() {
3657 if self._additional_params.contains_key(field) {
3658 dlg.finished(false);
3659 return Err(common::Error::FieldClash(field));
3660 }
3661 }
3662
3663 let mut params = Params::with_capacity(5 + self._additional_params.len());
3664 params.push("calendarId", self._calendar_id);
3665 if let Some(value) = self._send_notifications.as_ref() {
3666 params.push("sendNotifications", value.to_string());
3667 }
3668
3669 params.extend(self._additional_params.iter());
3670
3671 params.push("alt", "json");
3672 let mut url = self.hub._base_url.clone() + "calendars/{calendarId}/acl";
3673 if self._scopes.is_empty() {
3674 self._scopes.insert(Scope::Full.as_ref().to_string());
3675 }
3676
3677 #[allow(clippy::single_element_loop)]
3678 for &(find_this, param_name) in [("{calendarId}", "calendarId")].iter() {
3679 url = params.uri_replacement(url, param_name, find_this, false);
3680 }
3681 {
3682 let to_remove = ["calendarId"];
3683 params.remove_params(&to_remove);
3684 }
3685
3686 let url = params.parse_with_url(&url);
3687
3688 let mut json_mime_type = mime::APPLICATION_JSON;
3689 let mut request_value_reader = {
3690 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
3691 common::remove_json_null_values(&mut value);
3692 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
3693 serde_json::to_writer(&mut dst, &value).unwrap();
3694 dst
3695 };
3696 let request_size = request_value_reader
3697 .seek(std::io::SeekFrom::End(0))
3698 .unwrap();
3699 request_value_reader
3700 .seek(std::io::SeekFrom::Start(0))
3701 .unwrap();
3702
3703 loop {
3704 let token = match self
3705 .hub
3706 .auth
3707 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
3708 .await
3709 {
3710 Ok(token) => token,
3711 Err(e) => match dlg.token(e) {
3712 Ok(token) => token,
3713 Err(e) => {
3714 dlg.finished(false);
3715 return Err(common::Error::MissingToken(e));
3716 }
3717 },
3718 };
3719 request_value_reader
3720 .seek(std::io::SeekFrom::Start(0))
3721 .unwrap();
3722 let mut req_result = {
3723 let client = &self.hub.client;
3724 dlg.pre_request();
3725 let mut req_builder = hyper::Request::builder()
3726 .method(hyper::Method::POST)
3727 .uri(url.as_str())
3728 .header(USER_AGENT, self.hub._user_agent.clone());
3729
3730 if let Some(token) = token.as_ref() {
3731 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
3732 }
3733
3734 let request = req_builder
3735 .header(CONTENT_TYPE, json_mime_type.to_string())
3736 .header(CONTENT_LENGTH, request_size as u64)
3737 .body(common::to_body(
3738 request_value_reader.get_ref().clone().into(),
3739 ));
3740
3741 client.request(request.unwrap()).await
3742 };
3743
3744 match req_result {
3745 Err(err) => {
3746 if let common::Retry::After(d) = dlg.http_error(&err) {
3747 sleep(d).await;
3748 continue;
3749 }
3750 dlg.finished(false);
3751 return Err(common::Error::HttpError(err));
3752 }
3753 Ok(res) => {
3754 let (mut parts, body) = res.into_parts();
3755 let mut body = common::Body::new(body);
3756 if !parts.status.is_success() {
3757 let bytes = common::to_bytes(body).await.unwrap_or_default();
3758 let error = serde_json::from_str(&common::to_string(&bytes));
3759 let response = common::to_response(parts, bytes.into());
3760
3761 if let common::Retry::After(d) =
3762 dlg.http_failure(&response, error.as_ref().ok())
3763 {
3764 sleep(d).await;
3765 continue;
3766 }
3767
3768 dlg.finished(false);
3769
3770 return Err(match error {
3771 Ok(value) => common::Error::BadRequest(value),
3772 _ => common::Error::Failure(response),
3773 });
3774 }
3775 let response = {
3776 let bytes = common::to_bytes(body).await.unwrap_or_default();
3777 let encoded = common::to_string(&bytes);
3778 match serde_json::from_str(&encoded) {
3779 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
3780 Err(error) => {
3781 dlg.response_json_decode_error(&encoded, &error);
3782 return Err(common::Error::JsonDecodeError(
3783 encoded.to_string(),
3784 error,
3785 ));
3786 }
3787 }
3788 };
3789
3790 dlg.finished(true);
3791 return Ok(response);
3792 }
3793 }
3794 }
3795 }
3796
3797 ///
3798 /// Sets the *request* property to the given value.
3799 ///
3800 /// Even though the property as already been set when instantiating this call,
3801 /// we provide this method for API completeness.
3802 pub fn request(mut self, new_value: AclRule) -> AclInsertCall<'a, C> {
3803 self._request = new_value;
3804 self
3805 }
3806 /// 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.
3807 ///
3808 /// Sets the *calendar id* path property to the given value.
3809 ///
3810 /// Even though the property as already been set when instantiating this call,
3811 /// we provide this method for API completeness.
3812 pub fn calendar_id(mut self, new_value: &str) -> AclInsertCall<'a, C> {
3813 self._calendar_id = new_value.to_string();
3814 self
3815 }
3816 /// Whether to send notifications about the calendar sharing change. Optional. The default is True.
3817 ///
3818 /// Sets the *send notifications* query property to the given value.
3819 pub fn send_notifications(mut self, new_value: bool) -> AclInsertCall<'a, C> {
3820 self._send_notifications = Some(new_value);
3821 self
3822 }
3823 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
3824 /// while executing the actual API request.
3825 ///
3826 /// ````text
3827 /// It should be used to handle progress information, and to implement a certain level of resilience.
3828 /// ````
3829 ///
3830 /// Sets the *delegate* property to the given value.
3831 pub fn delegate(mut self, new_value: &'a mut dyn common::Delegate) -> AclInsertCall<'a, C> {
3832 self._delegate = Some(new_value);
3833 self
3834 }
3835
3836 /// Set any additional parameter of the query string used in the request.
3837 /// It should be used to set parameters which are not yet available through their own
3838 /// setters.
3839 ///
3840 /// Please note that this method must not be used to set any of the known parameters
3841 /// which have their own setter method. If done anyway, the request will fail.
3842 ///
3843 /// # Additional Parameters
3844 ///
3845 /// * *alt* (query-string) - Data format for the response.
3846 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
3847 /// * *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.
3848 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
3849 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
3850 /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
3851 /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
3852 pub fn param<T>(mut self, name: T, value: T) -> AclInsertCall<'a, C>
3853 where
3854 T: AsRef<str>,
3855 {
3856 self._additional_params
3857 .insert(name.as_ref().to_string(), value.as_ref().to_string());
3858 self
3859 }
3860
3861 /// Identifies the authorization scope for the method you are building.
3862 ///
3863 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
3864 /// [`Scope::Full`].
3865 ///
3866 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
3867 /// tokens for more than one scope.
3868 ///
3869 /// Usually there is more than one suitable scope to authorize an operation, some of which may
3870 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
3871 /// sufficient, a read-write scope will do as well.
3872 pub fn add_scope<St>(mut self, scope: St) -> AclInsertCall<'a, C>
3873 where
3874 St: AsRef<str>,
3875 {
3876 self._scopes.insert(String::from(scope.as_ref()));
3877 self
3878 }
3879 /// Identifies the authorization scope(s) for the method you are building.
3880 ///
3881 /// See [`Self::add_scope()`] for details.
3882 pub fn add_scopes<I, St>(mut self, scopes: I) -> AclInsertCall<'a, C>
3883 where
3884 I: IntoIterator<Item = St>,
3885 St: AsRef<str>,
3886 {
3887 self._scopes
3888 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
3889 self
3890 }
3891
3892 /// Removes all scopes, and no default scope will be used either.
3893 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
3894 /// for details).
3895 pub fn clear_scopes(mut self) -> AclInsertCall<'a, C> {
3896 self._scopes.clear();
3897 self
3898 }
3899}
3900
3901/// Returns the rules in the access control list for the calendar.
3902///
3903/// A builder for the *list* method supported by a *acl* resource.
3904/// It is not used directly, but through a [`AclMethods`] instance.
3905///
3906/// # Example
3907///
3908/// Instantiate a resource method builder
3909///
3910/// ```test_harness,no_run
3911/// # extern crate hyper;
3912/// # extern crate hyper_rustls;
3913/// # extern crate google_calendar3 as calendar3;
3914/// # async fn dox() {
3915/// # use calendar3::{CalendarHub, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
3916///
3917/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
3918/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
3919/// # .with_native_roots()
3920/// # .unwrap()
3921/// # .https_only()
3922/// # .enable_http2()
3923/// # .build();
3924///
3925/// # let executor = hyper_util::rt::TokioExecutor::new();
3926/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
3927/// # secret,
3928/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
3929/// # yup_oauth2::client::CustomHyperClientBuilder::from(
3930/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
3931/// # ),
3932/// # ).build().await.unwrap();
3933///
3934/// # let client = hyper_util::client::legacy::Client::builder(
3935/// # hyper_util::rt::TokioExecutor::new()
3936/// # )
3937/// # .build(
3938/// # hyper_rustls::HttpsConnectorBuilder::new()
3939/// # .with_native_roots()
3940/// # .unwrap()
3941/// # .https_or_http()
3942/// # .enable_http2()
3943/// # .build()
3944/// # );
3945/// # let mut hub = CalendarHub::new(client, auth);
3946/// // You can configure optional parameters by calling the respective setters at will, and
3947/// // execute the final call using `doit()`.
3948/// // Values shown here are possibly random and not representative !
3949/// let result = hub.acl().list("calendarId")
3950/// .sync_token("invidunt")
3951/// .show_deleted(true)
3952/// .page_token("vero")
3953/// .max_results(-44)
3954/// .doit().await;
3955/// # }
3956/// ```
3957pub struct AclListCall<'a, C>
3958where
3959 C: 'a,
3960{
3961 hub: &'a CalendarHub<C>,
3962 _calendar_id: String,
3963 _sync_token: Option<String>,
3964 _show_deleted: Option<bool>,
3965 _page_token: Option<String>,
3966 _max_results: Option<i32>,
3967 _delegate: Option<&'a mut dyn common::Delegate>,
3968 _additional_params: HashMap<String, String>,
3969 _scopes: BTreeSet<String>,
3970}
3971
3972impl<'a, C> common::CallBuilder for AclListCall<'a, C> {}
3973
3974impl<'a, C> AclListCall<'a, C>
3975where
3976 C: common::Connector,
3977{
3978 /// Perform the operation you have build so far.
3979 pub async fn doit(mut self) -> common::Result<(common::Response, Acl)> {
3980 use std::borrow::Cow;
3981 use std::io::{Read, Seek};
3982
3983 use common::{url::Params, ToParts};
3984 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
3985
3986 let mut dd = common::DefaultDelegate;
3987 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
3988 dlg.begin(common::MethodInfo {
3989 id: "calendar.acl.list",
3990 http_method: hyper::Method::GET,
3991 });
3992
3993 for &field in [
3994 "alt",
3995 "calendarId",
3996 "syncToken",
3997 "showDeleted",
3998 "pageToken",
3999 "maxResults",
4000 ]
4001 .iter()
4002 {
4003 if self._additional_params.contains_key(field) {
4004 dlg.finished(false);
4005 return Err(common::Error::FieldClash(field));
4006 }
4007 }
4008
4009 let mut params = Params::with_capacity(7 + self._additional_params.len());
4010 params.push("calendarId", self._calendar_id);
4011 if let Some(value) = self._sync_token.as_ref() {
4012 params.push("syncToken", value);
4013 }
4014 if let Some(value) = self._show_deleted.as_ref() {
4015 params.push("showDeleted", value.to_string());
4016 }
4017 if let Some(value) = self._page_token.as_ref() {
4018 params.push("pageToken", value);
4019 }
4020 if let Some(value) = self._max_results.as_ref() {
4021 params.push("maxResults", value.to_string());
4022 }
4023
4024 params.extend(self._additional_params.iter());
4025
4026 params.push("alt", "json");
4027 let mut url = self.hub._base_url.clone() + "calendars/{calendarId}/acl";
4028 if self._scopes.is_empty() {
4029 self._scopes.insert(Scope::AclReadonly.as_ref().to_string());
4030 }
4031
4032 #[allow(clippy::single_element_loop)]
4033 for &(find_this, param_name) in [("{calendarId}", "calendarId")].iter() {
4034 url = params.uri_replacement(url, param_name, find_this, false);
4035 }
4036 {
4037 let to_remove = ["calendarId"];
4038 params.remove_params(&to_remove);
4039 }
4040
4041 let url = params.parse_with_url(&url);
4042
4043 loop {
4044 let token = match self
4045 .hub
4046 .auth
4047 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
4048 .await
4049 {
4050 Ok(token) => token,
4051 Err(e) => match dlg.token(e) {
4052 Ok(token) => token,
4053 Err(e) => {
4054 dlg.finished(false);
4055 return Err(common::Error::MissingToken(e));
4056 }
4057 },
4058 };
4059 let mut req_result = {
4060 let client = &self.hub.client;
4061 dlg.pre_request();
4062 let mut req_builder = hyper::Request::builder()
4063 .method(hyper::Method::GET)
4064 .uri(url.as_str())
4065 .header(USER_AGENT, self.hub._user_agent.clone());
4066
4067 if let Some(token) = token.as_ref() {
4068 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
4069 }
4070
4071 let request = req_builder
4072 .header(CONTENT_LENGTH, 0_u64)
4073 .body(common::to_body::<String>(None));
4074
4075 client.request(request.unwrap()).await
4076 };
4077
4078 match req_result {
4079 Err(err) => {
4080 if let common::Retry::After(d) = dlg.http_error(&err) {
4081 sleep(d).await;
4082 continue;
4083 }
4084 dlg.finished(false);
4085 return Err(common::Error::HttpError(err));
4086 }
4087 Ok(res) => {
4088 let (mut parts, body) = res.into_parts();
4089 let mut body = common::Body::new(body);
4090 if !parts.status.is_success() {
4091 let bytes = common::to_bytes(body).await.unwrap_or_default();
4092 let error = serde_json::from_str(&common::to_string(&bytes));
4093 let response = common::to_response(parts, bytes.into());
4094
4095 if let common::Retry::After(d) =
4096 dlg.http_failure(&response, error.as_ref().ok())
4097 {
4098 sleep(d).await;
4099 continue;
4100 }
4101
4102 dlg.finished(false);
4103
4104 return Err(match error {
4105 Ok(value) => common::Error::BadRequest(value),
4106 _ => common::Error::Failure(response),
4107 });
4108 }
4109 let response = {
4110 let bytes = common::to_bytes(body).await.unwrap_or_default();
4111 let encoded = common::to_string(&bytes);
4112 match serde_json::from_str(&encoded) {
4113 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
4114 Err(error) => {
4115 dlg.response_json_decode_error(&encoded, &error);
4116 return Err(common::Error::JsonDecodeError(
4117 encoded.to_string(),
4118 error,
4119 ));
4120 }
4121 }
4122 };
4123
4124 dlg.finished(true);
4125 return Ok(response);
4126 }
4127 }
4128 }
4129 }
4130
4131 /// 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.
4132 ///
4133 /// Sets the *calendar id* path property to the given value.
4134 ///
4135 /// Even though the property as already been set when instantiating this call,
4136 /// we provide this method for API completeness.
4137 pub fn calendar_id(mut self, new_value: &str) -> AclListCall<'a, C> {
4138 self._calendar_id = new_value.to_string();
4139 self
4140 }
4141 /// 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.
4142 /// 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.
4143 /// Learn more about incremental synchronization.
4144 /// Optional. The default is to return all entries.
4145 ///
4146 /// Sets the *sync token* query property to the given value.
4147 pub fn sync_token(mut self, new_value: &str) -> AclListCall<'a, C> {
4148 self._sync_token = Some(new_value.to_string());
4149 self
4150 }
4151 /// 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.
4152 ///
4153 /// Sets the *show deleted* query property to the given value.
4154 pub fn show_deleted(mut self, new_value: bool) -> AclListCall<'a, C> {
4155 self._show_deleted = Some(new_value);
4156 self
4157 }
4158 /// Token specifying which result page to return. Optional.
4159 ///
4160 /// Sets the *page token* query property to the given value.
4161 pub fn page_token(mut self, new_value: &str) -> AclListCall<'a, C> {
4162 self._page_token = Some(new_value.to_string());
4163 self
4164 }
4165 /// 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.
4166 ///
4167 /// Sets the *max results* query property to the given value.
4168 pub fn max_results(mut self, new_value: i32) -> AclListCall<'a, C> {
4169 self._max_results = Some(new_value);
4170 self
4171 }
4172 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
4173 /// while executing the actual API request.
4174 ///
4175 /// ````text
4176 /// It should be used to handle progress information, and to implement a certain level of resilience.
4177 /// ````
4178 ///
4179 /// Sets the *delegate* property to the given value.
4180 pub fn delegate(mut self, new_value: &'a mut dyn common::Delegate) -> AclListCall<'a, C> {
4181 self._delegate = Some(new_value);
4182 self
4183 }
4184
4185 /// Set any additional parameter of the query string used in the request.
4186 /// It should be used to set parameters which are not yet available through their own
4187 /// setters.
4188 ///
4189 /// Please note that this method must not be used to set any of the known parameters
4190 /// which have their own setter method. If done anyway, the request will fail.
4191 ///
4192 /// # Additional Parameters
4193 ///
4194 /// * *alt* (query-string) - Data format for the response.
4195 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
4196 /// * *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.
4197 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
4198 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
4199 /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
4200 /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
4201 pub fn param<T>(mut self, name: T, value: T) -> AclListCall<'a, C>
4202 where
4203 T: AsRef<str>,
4204 {
4205 self._additional_params
4206 .insert(name.as_ref().to_string(), value.as_ref().to_string());
4207 self
4208 }
4209
4210 /// Identifies the authorization scope for the method you are building.
4211 ///
4212 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
4213 /// [`Scope::AclReadonly`].
4214 ///
4215 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
4216 /// tokens for more than one scope.
4217 ///
4218 /// Usually there is more than one suitable scope to authorize an operation, some of which may
4219 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
4220 /// sufficient, a read-write scope will do as well.
4221 pub fn add_scope<St>(mut self, scope: St) -> AclListCall<'a, C>
4222 where
4223 St: AsRef<str>,
4224 {
4225 self._scopes.insert(String::from(scope.as_ref()));
4226 self
4227 }
4228 /// Identifies the authorization scope(s) for the method you are building.
4229 ///
4230 /// See [`Self::add_scope()`] for details.
4231 pub fn add_scopes<I, St>(mut self, scopes: I) -> AclListCall<'a, C>
4232 where
4233 I: IntoIterator<Item = St>,
4234 St: AsRef<str>,
4235 {
4236 self._scopes
4237 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
4238 self
4239 }
4240
4241 /// Removes all scopes, and no default scope will be used either.
4242 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
4243 /// for details).
4244 pub fn clear_scopes(mut self) -> AclListCall<'a, C> {
4245 self._scopes.clear();
4246 self
4247 }
4248}
4249
4250/// Updates an access control rule. This method supports patch semantics.
4251///
4252/// A builder for the *patch* method supported by a *acl* resource.
4253/// It is not used directly, but through a [`AclMethods`] instance.
4254///
4255/// # Example
4256///
4257/// Instantiate a resource method builder
4258///
4259/// ```test_harness,no_run
4260/// # extern crate hyper;
4261/// # extern crate hyper_rustls;
4262/// # extern crate google_calendar3 as calendar3;
4263/// use calendar3::api::AclRule;
4264/// # async fn dox() {
4265/// # use calendar3::{CalendarHub, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
4266///
4267/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
4268/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
4269/// # .with_native_roots()
4270/// # .unwrap()
4271/// # .https_only()
4272/// # .enable_http2()
4273/// # .build();
4274///
4275/// # let executor = hyper_util::rt::TokioExecutor::new();
4276/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
4277/// # secret,
4278/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
4279/// # yup_oauth2::client::CustomHyperClientBuilder::from(
4280/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
4281/// # ),
4282/// # ).build().await.unwrap();
4283///
4284/// # let client = hyper_util::client::legacy::Client::builder(
4285/// # hyper_util::rt::TokioExecutor::new()
4286/// # )
4287/// # .build(
4288/// # hyper_rustls::HttpsConnectorBuilder::new()
4289/// # .with_native_roots()
4290/// # .unwrap()
4291/// # .https_or_http()
4292/// # .enable_http2()
4293/// # .build()
4294/// # );
4295/// # let mut hub = CalendarHub::new(client, auth);
4296/// // As the method needs a request, you would usually fill it with the desired information
4297/// // into the respective structure. Some of the parts shown here might not be applicable !
4298/// // Values shown here are possibly random and not representative !
4299/// let mut req = AclRule::default();
4300///
4301/// // You can configure optional parameters by calling the respective setters at will, and
4302/// // execute the final call using `doit()`.
4303/// // Values shown here are possibly random and not representative !
4304/// let result = hub.acl().patch(req, "calendarId", "ruleId")
4305/// .send_notifications(true)
4306/// .doit().await;
4307/// # }
4308/// ```
4309pub struct AclPatchCall<'a, C>
4310where
4311 C: 'a,
4312{
4313 hub: &'a CalendarHub<C>,
4314 _request: AclRule,
4315 _calendar_id: String,
4316 _rule_id: String,
4317 _send_notifications: Option<bool>,
4318 _delegate: Option<&'a mut dyn common::Delegate>,
4319 _additional_params: HashMap<String, String>,
4320 _scopes: BTreeSet<String>,
4321}
4322
4323impl<'a, C> common::CallBuilder for AclPatchCall<'a, C> {}
4324
4325impl<'a, C> AclPatchCall<'a, C>
4326where
4327 C: common::Connector,
4328{
4329 /// Perform the operation you have build so far.
4330 pub async fn doit(mut self) -> common::Result<(common::Response, AclRule)> {
4331 use std::borrow::Cow;
4332 use std::io::{Read, Seek};
4333
4334 use common::{url::Params, ToParts};
4335 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
4336
4337 let mut dd = common::DefaultDelegate;
4338 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
4339 dlg.begin(common::MethodInfo {
4340 id: "calendar.acl.patch",
4341 http_method: hyper::Method::PATCH,
4342 });
4343
4344 for &field in ["alt", "calendarId", "ruleId", "sendNotifications"].iter() {
4345 if self._additional_params.contains_key(field) {
4346 dlg.finished(false);
4347 return Err(common::Error::FieldClash(field));
4348 }
4349 }
4350
4351 let mut params = Params::with_capacity(6 + self._additional_params.len());
4352 params.push("calendarId", self._calendar_id);
4353 params.push("ruleId", self._rule_id);
4354 if let Some(value) = self._send_notifications.as_ref() {
4355 params.push("sendNotifications", value.to_string());
4356 }
4357
4358 params.extend(self._additional_params.iter());
4359
4360 params.push("alt", "json");
4361 let mut url = self.hub._base_url.clone() + "calendars/{calendarId}/acl/{ruleId}";
4362 if self._scopes.is_empty() {
4363 self._scopes.insert(Scope::Full.as_ref().to_string());
4364 }
4365
4366 #[allow(clippy::single_element_loop)]
4367 for &(find_this, param_name) in
4368 [("{calendarId}", "calendarId"), ("{ruleId}", "ruleId")].iter()
4369 {
4370 url = params.uri_replacement(url, param_name, find_this, false);
4371 }
4372 {
4373 let to_remove = ["ruleId", "calendarId"];
4374 params.remove_params(&to_remove);
4375 }
4376
4377 let url = params.parse_with_url(&url);
4378
4379 let mut json_mime_type = mime::APPLICATION_JSON;
4380 let mut request_value_reader = {
4381 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
4382 common::remove_json_null_values(&mut value);
4383 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
4384 serde_json::to_writer(&mut dst, &value).unwrap();
4385 dst
4386 };
4387 let request_size = request_value_reader
4388 .seek(std::io::SeekFrom::End(0))
4389 .unwrap();
4390 request_value_reader
4391 .seek(std::io::SeekFrom::Start(0))
4392 .unwrap();
4393
4394 loop {
4395 let token = match self
4396 .hub
4397 .auth
4398 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
4399 .await
4400 {
4401 Ok(token) => token,
4402 Err(e) => match dlg.token(e) {
4403 Ok(token) => token,
4404 Err(e) => {
4405 dlg.finished(false);
4406 return Err(common::Error::MissingToken(e));
4407 }
4408 },
4409 };
4410 request_value_reader
4411 .seek(std::io::SeekFrom::Start(0))
4412 .unwrap();
4413 let mut req_result = {
4414 let client = &self.hub.client;
4415 dlg.pre_request();
4416 let mut req_builder = hyper::Request::builder()
4417 .method(hyper::Method::PATCH)
4418 .uri(url.as_str())
4419 .header(USER_AGENT, self.hub._user_agent.clone());
4420
4421 if let Some(token) = token.as_ref() {
4422 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
4423 }
4424
4425 let request = req_builder
4426 .header(CONTENT_TYPE, json_mime_type.to_string())
4427 .header(CONTENT_LENGTH, request_size as u64)
4428 .body(common::to_body(
4429 request_value_reader.get_ref().clone().into(),
4430 ));
4431
4432 client.request(request.unwrap()).await
4433 };
4434
4435 match req_result {
4436 Err(err) => {
4437 if let common::Retry::After(d) = dlg.http_error(&err) {
4438 sleep(d).await;
4439 continue;
4440 }
4441 dlg.finished(false);
4442 return Err(common::Error::HttpError(err));
4443 }
4444 Ok(res) => {
4445 let (mut parts, body) = res.into_parts();
4446 let mut body = common::Body::new(body);
4447 if !parts.status.is_success() {
4448 let bytes = common::to_bytes(body).await.unwrap_or_default();
4449 let error = serde_json::from_str(&common::to_string(&bytes));
4450 let response = common::to_response(parts, bytes.into());
4451
4452 if let common::Retry::After(d) =
4453 dlg.http_failure(&response, error.as_ref().ok())
4454 {
4455 sleep(d).await;
4456 continue;
4457 }
4458
4459 dlg.finished(false);
4460
4461 return Err(match error {
4462 Ok(value) => common::Error::BadRequest(value),
4463 _ => common::Error::Failure(response),
4464 });
4465 }
4466 let response = {
4467 let bytes = common::to_bytes(body).await.unwrap_or_default();
4468 let encoded = common::to_string(&bytes);
4469 match serde_json::from_str(&encoded) {
4470 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
4471 Err(error) => {
4472 dlg.response_json_decode_error(&encoded, &error);
4473 return Err(common::Error::JsonDecodeError(
4474 encoded.to_string(),
4475 error,
4476 ));
4477 }
4478 }
4479 };
4480
4481 dlg.finished(true);
4482 return Ok(response);
4483 }
4484 }
4485 }
4486 }
4487
4488 ///
4489 /// Sets the *request* property to the given value.
4490 ///
4491 /// Even though the property as already been set when instantiating this call,
4492 /// we provide this method for API completeness.
4493 pub fn request(mut self, new_value: AclRule) -> AclPatchCall<'a, C> {
4494 self._request = new_value;
4495 self
4496 }
4497 /// 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.
4498 ///
4499 /// Sets the *calendar id* path property to the given value.
4500 ///
4501 /// Even though the property as already been set when instantiating this call,
4502 /// we provide this method for API completeness.
4503 pub fn calendar_id(mut self, new_value: &str) -> AclPatchCall<'a, C> {
4504 self._calendar_id = new_value.to_string();
4505 self
4506 }
4507 /// ACL rule identifier.
4508 ///
4509 /// Sets the *rule id* path property to the given value.
4510 ///
4511 /// Even though the property as already been set when instantiating this call,
4512 /// we provide this method for API completeness.
4513 pub fn rule_id(mut self, new_value: &str) -> AclPatchCall<'a, C> {
4514 self._rule_id = new_value.to_string();
4515 self
4516 }
4517 /// Whether to send notifications about the calendar sharing change. Note that there are no notifications on access removal. Optional. The default is True.
4518 ///
4519 /// Sets the *send notifications* query property to the given value.
4520 pub fn send_notifications(mut self, new_value: bool) -> AclPatchCall<'a, C> {
4521 self._send_notifications = Some(new_value);
4522 self
4523 }
4524 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
4525 /// while executing the actual API request.
4526 ///
4527 /// ````text
4528 /// It should be used to handle progress information, and to implement a certain level of resilience.
4529 /// ````
4530 ///
4531 /// Sets the *delegate* property to the given value.
4532 pub fn delegate(mut self, new_value: &'a mut dyn common::Delegate) -> AclPatchCall<'a, C> {
4533 self._delegate = Some(new_value);
4534 self
4535 }
4536
4537 /// Set any additional parameter of the query string used in the request.
4538 /// It should be used to set parameters which are not yet available through their own
4539 /// setters.
4540 ///
4541 /// Please note that this method must not be used to set any of the known parameters
4542 /// which have their own setter method. If done anyway, the request will fail.
4543 ///
4544 /// # Additional Parameters
4545 ///
4546 /// * *alt* (query-string) - Data format for the response.
4547 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
4548 /// * *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.
4549 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
4550 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
4551 /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
4552 /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
4553 pub fn param<T>(mut self, name: T, value: T) -> AclPatchCall<'a, C>
4554 where
4555 T: AsRef<str>,
4556 {
4557 self._additional_params
4558 .insert(name.as_ref().to_string(), value.as_ref().to_string());
4559 self
4560 }
4561
4562 /// Identifies the authorization scope for the method you are building.
4563 ///
4564 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
4565 /// [`Scope::Full`].
4566 ///
4567 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
4568 /// tokens for more than one scope.
4569 ///
4570 /// Usually there is more than one suitable scope to authorize an operation, some of which may
4571 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
4572 /// sufficient, a read-write scope will do as well.
4573 pub fn add_scope<St>(mut self, scope: St) -> AclPatchCall<'a, C>
4574 where
4575 St: AsRef<str>,
4576 {
4577 self._scopes.insert(String::from(scope.as_ref()));
4578 self
4579 }
4580 /// Identifies the authorization scope(s) for the method you are building.
4581 ///
4582 /// See [`Self::add_scope()`] for details.
4583 pub fn add_scopes<I, St>(mut self, scopes: I) -> AclPatchCall<'a, C>
4584 where
4585 I: IntoIterator<Item = St>,
4586 St: AsRef<str>,
4587 {
4588 self._scopes
4589 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
4590 self
4591 }
4592
4593 /// Removes all scopes, and no default scope will be used either.
4594 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
4595 /// for details).
4596 pub fn clear_scopes(mut self) -> AclPatchCall<'a, C> {
4597 self._scopes.clear();
4598 self
4599 }
4600}
4601
4602/// Updates an access control rule.
4603///
4604/// A builder for the *update* method supported by a *acl* resource.
4605/// It is not used directly, but through a [`AclMethods`] instance.
4606///
4607/// # Example
4608///
4609/// Instantiate a resource method builder
4610///
4611/// ```test_harness,no_run
4612/// # extern crate hyper;
4613/// # extern crate hyper_rustls;
4614/// # extern crate google_calendar3 as calendar3;
4615/// use calendar3::api::AclRule;
4616/// # async fn dox() {
4617/// # use calendar3::{CalendarHub, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
4618///
4619/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
4620/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
4621/// # .with_native_roots()
4622/// # .unwrap()
4623/// # .https_only()
4624/// # .enable_http2()
4625/// # .build();
4626///
4627/// # let executor = hyper_util::rt::TokioExecutor::new();
4628/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
4629/// # secret,
4630/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
4631/// # yup_oauth2::client::CustomHyperClientBuilder::from(
4632/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
4633/// # ),
4634/// # ).build().await.unwrap();
4635///
4636/// # let client = hyper_util::client::legacy::Client::builder(
4637/// # hyper_util::rt::TokioExecutor::new()
4638/// # )
4639/// # .build(
4640/// # hyper_rustls::HttpsConnectorBuilder::new()
4641/// # .with_native_roots()
4642/// # .unwrap()
4643/// # .https_or_http()
4644/// # .enable_http2()
4645/// # .build()
4646/// # );
4647/// # let mut hub = CalendarHub::new(client, auth);
4648/// // As the method needs a request, you would usually fill it with the desired information
4649/// // into the respective structure. Some of the parts shown here might not be applicable !
4650/// // Values shown here are possibly random and not representative !
4651/// let mut req = AclRule::default();
4652///
4653/// // You can configure optional parameters by calling the respective setters at will, and
4654/// // execute the final call using `doit()`.
4655/// // Values shown here are possibly random and not representative !
4656/// let result = hub.acl().update(req, "calendarId", "ruleId")
4657/// .send_notifications(true)
4658/// .doit().await;
4659/// # }
4660/// ```
4661pub struct AclUpdateCall<'a, C>
4662where
4663 C: 'a,
4664{
4665 hub: &'a CalendarHub<C>,
4666 _request: AclRule,
4667 _calendar_id: String,
4668 _rule_id: String,
4669 _send_notifications: Option<bool>,
4670 _delegate: Option<&'a mut dyn common::Delegate>,
4671 _additional_params: HashMap<String, String>,
4672 _scopes: BTreeSet<String>,
4673}
4674
4675impl<'a, C> common::CallBuilder for AclUpdateCall<'a, C> {}
4676
4677impl<'a, C> AclUpdateCall<'a, C>
4678where
4679 C: common::Connector,
4680{
4681 /// Perform the operation you have build so far.
4682 pub async fn doit(mut self) -> common::Result<(common::Response, AclRule)> {
4683 use std::borrow::Cow;
4684 use std::io::{Read, Seek};
4685
4686 use common::{url::Params, ToParts};
4687 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
4688
4689 let mut dd = common::DefaultDelegate;
4690 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
4691 dlg.begin(common::MethodInfo {
4692 id: "calendar.acl.update",
4693 http_method: hyper::Method::PUT,
4694 });
4695
4696 for &field in ["alt", "calendarId", "ruleId", "sendNotifications"].iter() {
4697 if self._additional_params.contains_key(field) {
4698 dlg.finished(false);
4699 return Err(common::Error::FieldClash(field));
4700 }
4701 }
4702
4703 let mut params = Params::with_capacity(6 + self._additional_params.len());
4704 params.push("calendarId", self._calendar_id);
4705 params.push("ruleId", self._rule_id);
4706 if let Some(value) = self._send_notifications.as_ref() {
4707 params.push("sendNotifications", value.to_string());
4708 }
4709
4710 params.extend(self._additional_params.iter());
4711
4712 params.push("alt", "json");
4713 let mut url = self.hub._base_url.clone() + "calendars/{calendarId}/acl/{ruleId}";
4714 if self._scopes.is_empty() {
4715 self._scopes.insert(Scope::Full.as_ref().to_string());
4716 }
4717
4718 #[allow(clippy::single_element_loop)]
4719 for &(find_this, param_name) in
4720 [("{calendarId}", "calendarId"), ("{ruleId}", "ruleId")].iter()
4721 {
4722 url = params.uri_replacement(url, param_name, find_this, false);
4723 }
4724 {
4725 let to_remove = ["ruleId", "calendarId"];
4726 params.remove_params(&to_remove);
4727 }
4728
4729 let url = params.parse_with_url(&url);
4730
4731 let mut json_mime_type = mime::APPLICATION_JSON;
4732 let mut request_value_reader = {
4733 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
4734 common::remove_json_null_values(&mut value);
4735 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
4736 serde_json::to_writer(&mut dst, &value).unwrap();
4737 dst
4738 };
4739 let request_size = request_value_reader
4740 .seek(std::io::SeekFrom::End(0))
4741 .unwrap();
4742 request_value_reader
4743 .seek(std::io::SeekFrom::Start(0))
4744 .unwrap();
4745
4746 loop {
4747 let token = match self
4748 .hub
4749 .auth
4750 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
4751 .await
4752 {
4753 Ok(token) => token,
4754 Err(e) => match dlg.token(e) {
4755 Ok(token) => token,
4756 Err(e) => {
4757 dlg.finished(false);
4758 return Err(common::Error::MissingToken(e));
4759 }
4760 },
4761 };
4762 request_value_reader
4763 .seek(std::io::SeekFrom::Start(0))
4764 .unwrap();
4765 let mut req_result = {
4766 let client = &self.hub.client;
4767 dlg.pre_request();
4768 let mut req_builder = hyper::Request::builder()
4769 .method(hyper::Method::PUT)
4770 .uri(url.as_str())
4771 .header(USER_AGENT, self.hub._user_agent.clone());
4772
4773 if let Some(token) = token.as_ref() {
4774 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
4775 }
4776
4777 let request = req_builder
4778 .header(CONTENT_TYPE, json_mime_type.to_string())
4779 .header(CONTENT_LENGTH, request_size as u64)
4780 .body(common::to_body(
4781 request_value_reader.get_ref().clone().into(),
4782 ));
4783
4784 client.request(request.unwrap()).await
4785 };
4786
4787 match req_result {
4788 Err(err) => {
4789 if let common::Retry::After(d) = dlg.http_error(&err) {
4790 sleep(d).await;
4791 continue;
4792 }
4793 dlg.finished(false);
4794 return Err(common::Error::HttpError(err));
4795 }
4796 Ok(res) => {
4797 let (mut parts, body) = res.into_parts();
4798 let mut body = common::Body::new(body);
4799 if !parts.status.is_success() {
4800 let bytes = common::to_bytes(body).await.unwrap_or_default();
4801 let error = serde_json::from_str(&common::to_string(&bytes));
4802 let response = common::to_response(parts, bytes.into());
4803
4804 if let common::Retry::After(d) =
4805 dlg.http_failure(&response, error.as_ref().ok())
4806 {
4807 sleep(d).await;
4808 continue;
4809 }
4810
4811 dlg.finished(false);
4812
4813 return Err(match error {
4814 Ok(value) => common::Error::BadRequest(value),
4815 _ => common::Error::Failure(response),
4816 });
4817 }
4818 let response = {
4819 let bytes = common::to_bytes(body).await.unwrap_or_default();
4820 let encoded = common::to_string(&bytes);
4821 match serde_json::from_str(&encoded) {
4822 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
4823 Err(error) => {
4824 dlg.response_json_decode_error(&encoded, &error);
4825 return Err(common::Error::JsonDecodeError(
4826 encoded.to_string(),
4827 error,
4828 ));
4829 }
4830 }
4831 };
4832
4833 dlg.finished(true);
4834 return Ok(response);
4835 }
4836 }
4837 }
4838 }
4839
4840 ///
4841 /// Sets the *request* property to the given value.
4842 ///
4843 /// Even though the property as already been set when instantiating this call,
4844 /// we provide this method for API completeness.
4845 pub fn request(mut self, new_value: AclRule) -> AclUpdateCall<'a, C> {
4846 self._request = new_value;
4847 self
4848 }
4849 /// 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.
4850 ///
4851 /// Sets the *calendar id* path property to the given value.
4852 ///
4853 /// Even though the property as already been set when instantiating this call,
4854 /// we provide this method for API completeness.
4855 pub fn calendar_id(mut self, new_value: &str) -> AclUpdateCall<'a, C> {
4856 self._calendar_id = new_value.to_string();
4857 self
4858 }
4859 /// ACL rule identifier.
4860 ///
4861 /// Sets the *rule id* path property to the given value.
4862 ///
4863 /// Even though the property as already been set when instantiating this call,
4864 /// we provide this method for API completeness.
4865 pub fn rule_id(mut self, new_value: &str) -> AclUpdateCall<'a, C> {
4866 self._rule_id = new_value.to_string();
4867 self
4868 }
4869 /// Whether to send notifications about the calendar sharing change. Note that there are no notifications on access removal. Optional. The default is True.
4870 ///
4871 /// Sets the *send notifications* query property to the given value.
4872 pub fn send_notifications(mut self, new_value: bool) -> AclUpdateCall<'a, C> {
4873 self._send_notifications = Some(new_value);
4874 self
4875 }
4876 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
4877 /// while executing the actual API request.
4878 ///
4879 /// ````text
4880 /// It should be used to handle progress information, and to implement a certain level of resilience.
4881 /// ````
4882 ///
4883 /// Sets the *delegate* property to the given value.
4884 pub fn delegate(mut self, new_value: &'a mut dyn common::Delegate) -> AclUpdateCall<'a, C> {
4885 self._delegate = Some(new_value);
4886 self
4887 }
4888
4889 /// Set any additional parameter of the query string used in the request.
4890 /// It should be used to set parameters which are not yet available through their own
4891 /// setters.
4892 ///
4893 /// Please note that this method must not be used to set any of the known parameters
4894 /// which have their own setter method. If done anyway, the request will fail.
4895 ///
4896 /// # Additional Parameters
4897 ///
4898 /// * *alt* (query-string) - Data format for the response.
4899 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
4900 /// * *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.
4901 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
4902 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
4903 /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
4904 /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
4905 pub fn param<T>(mut self, name: T, value: T) -> AclUpdateCall<'a, C>
4906 where
4907 T: AsRef<str>,
4908 {
4909 self._additional_params
4910 .insert(name.as_ref().to_string(), value.as_ref().to_string());
4911 self
4912 }
4913
4914 /// Identifies the authorization scope for the method you are building.
4915 ///
4916 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
4917 /// [`Scope::Full`].
4918 ///
4919 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
4920 /// tokens for more than one scope.
4921 ///
4922 /// Usually there is more than one suitable scope to authorize an operation, some of which may
4923 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
4924 /// sufficient, a read-write scope will do as well.
4925 pub fn add_scope<St>(mut self, scope: St) -> AclUpdateCall<'a, C>
4926 where
4927 St: AsRef<str>,
4928 {
4929 self._scopes.insert(String::from(scope.as_ref()));
4930 self
4931 }
4932 /// Identifies the authorization scope(s) for the method you are building.
4933 ///
4934 /// See [`Self::add_scope()`] for details.
4935 pub fn add_scopes<I, St>(mut self, scopes: I) -> AclUpdateCall<'a, C>
4936 where
4937 I: IntoIterator<Item = St>,
4938 St: AsRef<str>,
4939 {
4940 self._scopes
4941 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
4942 self
4943 }
4944
4945 /// Removes all scopes, and no default scope will be used either.
4946 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
4947 /// for details).
4948 pub fn clear_scopes(mut self) -> AclUpdateCall<'a, C> {
4949 self._scopes.clear();
4950 self
4951 }
4952}
4953
4954/// Watch for changes to ACL resources.
4955///
4956/// A builder for the *watch* method supported by a *acl* resource.
4957/// It is not used directly, but through a [`AclMethods`] instance.
4958///
4959/// # Example
4960///
4961/// Instantiate a resource method builder
4962///
4963/// ```test_harness,no_run
4964/// # extern crate hyper;
4965/// # extern crate hyper_rustls;
4966/// # extern crate google_calendar3 as calendar3;
4967/// use calendar3::api::Channel;
4968/// # async fn dox() {
4969/// # use calendar3::{CalendarHub, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
4970///
4971/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
4972/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
4973/// # .with_native_roots()
4974/// # .unwrap()
4975/// # .https_only()
4976/// # .enable_http2()
4977/// # .build();
4978///
4979/// # let executor = hyper_util::rt::TokioExecutor::new();
4980/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
4981/// # secret,
4982/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
4983/// # yup_oauth2::client::CustomHyperClientBuilder::from(
4984/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
4985/// # ),
4986/// # ).build().await.unwrap();
4987///
4988/// # let client = hyper_util::client::legacy::Client::builder(
4989/// # hyper_util::rt::TokioExecutor::new()
4990/// # )
4991/// # .build(
4992/// # hyper_rustls::HttpsConnectorBuilder::new()
4993/// # .with_native_roots()
4994/// # .unwrap()
4995/// # .https_or_http()
4996/// # .enable_http2()
4997/// # .build()
4998/// # );
4999/// # let mut hub = CalendarHub::new(client, auth);
5000/// // As the method needs a request, you would usually fill it with the desired information
5001/// // into the respective structure. Some of the parts shown here might not be applicable !
5002/// // Values shown here are possibly random and not representative !
5003/// let mut req = Channel::default();
5004///
5005/// // You can configure optional parameters by calling the respective setters at will, and
5006/// // execute the final call using `doit()`.
5007/// // Values shown here are possibly random and not representative !
5008/// let result = hub.acl().watch(req, "calendarId")
5009/// .sync_token("voluptua.")
5010/// .show_deleted(false)
5011/// .page_token("erat")
5012/// .max_results(-96)
5013/// .doit().await;
5014/// # }
5015/// ```
5016pub struct AclWatchCall<'a, C>
5017where
5018 C: 'a,
5019{
5020 hub: &'a CalendarHub<C>,
5021 _request: Channel,
5022 _calendar_id: String,
5023 _sync_token: Option<String>,
5024 _show_deleted: Option<bool>,
5025 _page_token: Option<String>,
5026 _max_results: Option<i32>,
5027 _delegate: Option<&'a mut dyn common::Delegate>,
5028 _additional_params: HashMap<String, String>,
5029 _scopes: BTreeSet<String>,
5030}
5031
5032impl<'a, C> common::CallBuilder for AclWatchCall<'a, C> {}
5033
5034impl<'a, C> AclWatchCall<'a, C>
5035where
5036 C: common::Connector,
5037{
5038 /// Perform the operation you have build so far.
5039 pub async fn doit(mut self) -> common::Result<(common::Response, Channel)> {
5040 use std::borrow::Cow;
5041 use std::io::{Read, Seek};
5042
5043 use common::{url::Params, ToParts};
5044 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
5045
5046 let mut dd = common::DefaultDelegate;
5047 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
5048 dlg.begin(common::MethodInfo {
5049 id: "calendar.acl.watch",
5050 http_method: hyper::Method::POST,
5051 });
5052
5053 for &field in [
5054 "alt",
5055 "calendarId",
5056 "syncToken",
5057 "showDeleted",
5058 "pageToken",
5059 "maxResults",
5060 ]
5061 .iter()
5062 {
5063 if self._additional_params.contains_key(field) {
5064 dlg.finished(false);
5065 return Err(common::Error::FieldClash(field));
5066 }
5067 }
5068
5069 let mut params = Params::with_capacity(8 + self._additional_params.len());
5070 params.push("calendarId", self._calendar_id);
5071 if let Some(value) = self._sync_token.as_ref() {
5072 params.push("syncToken", value);
5073 }
5074 if let Some(value) = self._show_deleted.as_ref() {
5075 params.push("showDeleted", value.to_string());
5076 }
5077 if let Some(value) = self._page_token.as_ref() {
5078 params.push("pageToken", value);
5079 }
5080 if let Some(value) = self._max_results.as_ref() {
5081 params.push("maxResults", value.to_string());
5082 }
5083
5084 params.extend(self._additional_params.iter());
5085
5086 params.push("alt", "json");
5087 let mut url = self.hub._base_url.clone() + "calendars/{calendarId}/acl/watch";
5088 if self._scopes.is_empty() {
5089 self._scopes.insert(Scope::AclReadonly.as_ref().to_string());
5090 }
5091
5092 #[allow(clippy::single_element_loop)]
5093 for &(find_this, param_name) in [("{calendarId}", "calendarId")].iter() {
5094 url = params.uri_replacement(url, param_name, find_this, false);
5095 }
5096 {
5097 let to_remove = ["calendarId"];
5098 params.remove_params(&to_remove);
5099 }
5100
5101 let url = params.parse_with_url(&url);
5102
5103 let mut json_mime_type = mime::APPLICATION_JSON;
5104 let mut request_value_reader = {
5105 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
5106 common::remove_json_null_values(&mut value);
5107 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
5108 serde_json::to_writer(&mut dst, &value).unwrap();
5109 dst
5110 };
5111 let request_size = request_value_reader
5112 .seek(std::io::SeekFrom::End(0))
5113 .unwrap();
5114 request_value_reader
5115 .seek(std::io::SeekFrom::Start(0))
5116 .unwrap();
5117
5118 loop {
5119 let token = match self
5120 .hub
5121 .auth
5122 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
5123 .await
5124 {
5125 Ok(token) => token,
5126 Err(e) => match dlg.token(e) {
5127 Ok(token) => token,
5128 Err(e) => {
5129 dlg.finished(false);
5130 return Err(common::Error::MissingToken(e));
5131 }
5132 },
5133 };
5134 request_value_reader
5135 .seek(std::io::SeekFrom::Start(0))
5136 .unwrap();
5137 let mut req_result = {
5138 let client = &self.hub.client;
5139 dlg.pre_request();
5140 let mut req_builder = hyper::Request::builder()
5141 .method(hyper::Method::POST)
5142 .uri(url.as_str())
5143 .header(USER_AGENT, self.hub._user_agent.clone());
5144
5145 if let Some(token) = token.as_ref() {
5146 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
5147 }
5148
5149 let request = req_builder
5150 .header(CONTENT_TYPE, json_mime_type.to_string())
5151 .header(CONTENT_LENGTH, request_size as u64)
5152 .body(common::to_body(
5153 request_value_reader.get_ref().clone().into(),
5154 ));
5155
5156 client.request(request.unwrap()).await
5157 };
5158
5159 match req_result {
5160 Err(err) => {
5161 if let common::Retry::After(d) = dlg.http_error(&err) {
5162 sleep(d).await;
5163 continue;
5164 }
5165 dlg.finished(false);
5166 return Err(common::Error::HttpError(err));
5167 }
5168 Ok(res) => {
5169 let (mut parts, body) = res.into_parts();
5170 let mut body = common::Body::new(body);
5171 if !parts.status.is_success() {
5172 let bytes = common::to_bytes(body).await.unwrap_or_default();
5173 let error = serde_json::from_str(&common::to_string(&bytes));
5174 let response = common::to_response(parts, bytes.into());
5175
5176 if let common::Retry::After(d) =
5177 dlg.http_failure(&response, error.as_ref().ok())
5178 {
5179 sleep(d).await;
5180 continue;
5181 }
5182
5183 dlg.finished(false);
5184
5185 return Err(match error {
5186 Ok(value) => common::Error::BadRequest(value),
5187 _ => common::Error::Failure(response),
5188 });
5189 }
5190 let response = {
5191 let bytes = common::to_bytes(body).await.unwrap_or_default();
5192 let encoded = common::to_string(&bytes);
5193 match serde_json::from_str(&encoded) {
5194 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
5195 Err(error) => {
5196 dlg.response_json_decode_error(&encoded, &error);
5197 return Err(common::Error::JsonDecodeError(
5198 encoded.to_string(),
5199 error,
5200 ));
5201 }
5202 }
5203 };
5204
5205 dlg.finished(true);
5206 return Ok(response);
5207 }
5208 }
5209 }
5210 }
5211
5212 ///
5213 /// Sets the *request* property to the given value.
5214 ///
5215 /// Even though the property as already been set when instantiating this call,
5216 /// we provide this method for API completeness.
5217 pub fn request(mut self, new_value: Channel) -> AclWatchCall<'a, C> {
5218 self._request = new_value;
5219 self
5220 }
5221 /// 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.
5222 ///
5223 /// Sets the *calendar id* path property to the given value.
5224 ///
5225 /// Even though the property as already been set when instantiating this call,
5226 /// we provide this method for API completeness.
5227 pub fn calendar_id(mut self, new_value: &str) -> AclWatchCall<'a, C> {
5228 self._calendar_id = new_value.to_string();
5229 self
5230 }
5231 /// 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.
5232 /// 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.
5233 /// Learn more about incremental synchronization.
5234 /// Optional. The default is to return all entries.
5235 ///
5236 /// Sets the *sync token* query property to the given value.
5237 pub fn sync_token(mut self, new_value: &str) -> AclWatchCall<'a, C> {
5238 self._sync_token = Some(new_value.to_string());
5239 self
5240 }
5241 /// 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.
5242 ///
5243 /// Sets the *show deleted* query property to the given value.
5244 pub fn show_deleted(mut self, new_value: bool) -> AclWatchCall<'a, C> {
5245 self._show_deleted = Some(new_value);
5246 self
5247 }
5248 /// Token specifying which result page to return. Optional.
5249 ///
5250 /// Sets the *page token* query property to the given value.
5251 pub fn page_token(mut self, new_value: &str) -> AclWatchCall<'a, C> {
5252 self._page_token = Some(new_value.to_string());
5253 self
5254 }
5255 /// 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.
5256 ///
5257 /// Sets the *max results* query property to the given value.
5258 pub fn max_results(mut self, new_value: i32) -> AclWatchCall<'a, C> {
5259 self._max_results = Some(new_value);
5260 self
5261 }
5262 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
5263 /// while executing the actual API request.
5264 ///
5265 /// ````text
5266 /// It should be used to handle progress information, and to implement a certain level of resilience.
5267 /// ````
5268 ///
5269 /// Sets the *delegate* property to the given value.
5270 pub fn delegate(mut self, new_value: &'a mut dyn common::Delegate) -> AclWatchCall<'a, C> {
5271 self._delegate = Some(new_value);
5272 self
5273 }
5274
5275 /// Set any additional parameter of the query string used in the request.
5276 /// It should be used to set parameters which are not yet available through their own
5277 /// setters.
5278 ///
5279 /// Please note that this method must not be used to set any of the known parameters
5280 /// which have their own setter method. If done anyway, the request will fail.
5281 ///
5282 /// # Additional Parameters
5283 ///
5284 /// * *alt* (query-string) - Data format for the response.
5285 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
5286 /// * *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.
5287 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
5288 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
5289 /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
5290 /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
5291 pub fn param<T>(mut self, name: T, value: T) -> AclWatchCall<'a, C>
5292 where
5293 T: AsRef<str>,
5294 {
5295 self._additional_params
5296 .insert(name.as_ref().to_string(), value.as_ref().to_string());
5297 self
5298 }
5299
5300 /// Identifies the authorization scope for the method you are building.
5301 ///
5302 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
5303 /// [`Scope::AclReadonly`].
5304 ///
5305 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
5306 /// tokens for more than one scope.
5307 ///
5308 /// Usually there is more than one suitable scope to authorize an operation, some of which may
5309 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
5310 /// sufficient, a read-write scope will do as well.
5311 pub fn add_scope<St>(mut self, scope: St) -> AclWatchCall<'a, C>
5312 where
5313 St: AsRef<str>,
5314 {
5315 self._scopes.insert(String::from(scope.as_ref()));
5316 self
5317 }
5318 /// Identifies the authorization scope(s) for the method you are building.
5319 ///
5320 /// See [`Self::add_scope()`] for details.
5321 pub fn add_scopes<I, St>(mut self, scopes: I) -> AclWatchCall<'a, C>
5322 where
5323 I: IntoIterator<Item = St>,
5324 St: AsRef<str>,
5325 {
5326 self._scopes
5327 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
5328 self
5329 }
5330
5331 /// Removes all scopes, and no default scope will be used either.
5332 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
5333 /// for details).
5334 pub fn clear_scopes(mut self) -> AclWatchCall<'a, C> {
5335 self._scopes.clear();
5336 self
5337 }
5338}
5339
5340/// Removes a calendar from the user's calendar list.
5341///
5342/// A builder for the *delete* method supported by a *calendarList* resource.
5343/// It is not used directly, but through a [`CalendarListMethods`] instance.
5344///
5345/// # Example
5346///
5347/// Instantiate a resource method builder
5348///
5349/// ```test_harness,no_run
5350/// # extern crate hyper;
5351/// # extern crate hyper_rustls;
5352/// # extern crate google_calendar3 as calendar3;
5353/// # async fn dox() {
5354/// # use calendar3::{CalendarHub, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
5355///
5356/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
5357/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
5358/// # .with_native_roots()
5359/// # .unwrap()
5360/// # .https_only()
5361/// # .enable_http2()
5362/// # .build();
5363///
5364/// # let executor = hyper_util::rt::TokioExecutor::new();
5365/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
5366/// # secret,
5367/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
5368/// # yup_oauth2::client::CustomHyperClientBuilder::from(
5369/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
5370/// # ),
5371/// # ).build().await.unwrap();
5372///
5373/// # let client = hyper_util::client::legacy::Client::builder(
5374/// # hyper_util::rt::TokioExecutor::new()
5375/// # )
5376/// # .build(
5377/// # hyper_rustls::HttpsConnectorBuilder::new()
5378/// # .with_native_roots()
5379/// # .unwrap()
5380/// # .https_or_http()
5381/// # .enable_http2()
5382/// # .build()
5383/// # );
5384/// # let mut hub = CalendarHub::new(client, auth);
5385/// // You can configure optional parameters by calling the respective setters at will, and
5386/// // execute the final call using `doit()`.
5387/// // Values shown here are possibly random and not representative !
5388/// let result = hub.calendar_list().delete("calendarId")
5389/// .doit().await;
5390/// # }
5391/// ```
5392pub struct CalendarListDeleteCall<'a, C>
5393where
5394 C: 'a,
5395{
5396 hub: &'a CalendarHub<C>,
5397 _calendar_id: String,
5398 _delegate: Option<&'a mut dyn common::Delegate>,
5399 _additional_params: HashMap<String, String>,
5400 _scopes: BTreeSet<String>,
5401}
5402
5403impl<'a, C> common::CallBuilder for CalendarListDeleteCall<'a, C> {}
5404
5405impl<'a, C> CalendarListDeleteCall<'a, C>
5406where
5407 C: common::Connector,
5408{
5409 /// Perform the operation you have build so far.
5410 pub async fn doit(mut self) -> common::Result<common::Response> {
5411 use std::borrow::Cow;
5412 use std::io::{Read, Seek};
5413
5414 use common::{url::Params, ToParts};
5415 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
5416
5417 let mut dd = common::DefaultDelegate;
5418 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
5419 dlg.begin(common::MethodInfo {
5420 id: "calendar.calendarList.delete",
5421 http_method: hyper::Method::DELETE,
5422 });
5423
5424 for &field in ["calendarId"].iter() {
5425 if self._additional_params.contains_key(field) {
5426 dlg.finished(false);
5427 return Err(common::Error::FieldClash(field));
5428 }
5429 }
5430
5431 let mut params = Params::with_capacity(2 + self._additional_params.len());
5432 params.push("calendarId", self._calendar_id);
5433
5434 params.extend(self._additional_params.iter());
5435
5436 let mut url = self.hub._base_url.clone() + "users/me/calendarList/{calendarId}";
5437 if self._scopes.is_empty() {
5438 self._scopes.insert(Scope::Full.as_ref().to_string());
5439 }
5440
5441 #[allow(clippy::single_element_loop)]
5442 for &(find_this, param_name) in [("{calendarId}", "calendarId")].iter() {
5443 url = params.uri_replacement(url, param_name, find_this, false);
5444 }
5445 {
5446 let to_remove = ["calendarId"];
5447 params.remove_params(&to_remove);
5448 }
5449
5450 let url = params.parse_with_url(&url);
5451
5452 loop {
5453 let token = match self
5454 .hub
5455 .auth
5456 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
5457 .await
5458 {
5459 Ok(token) => token,
5460 Err(e) => match dlg.token(e) {
5461 Ok(token) => token,
5462 Err(e) => {
5463 dlg.finished(false);
5464 return Err(common::Error::MissingToken(e));
5465 }
5466 },
5467 };
5468 let mut req_result = {
5469 let client = &self.hub.client;
5470 dlg.pre_request();
5471 let mut req_builder = hyper::Request::builder()
5472 .method(hyper::Method::DELETE)
5473 .uri(url.as_str())
5474 .header(USER_AGENT, self.hub._user_agent.clone());
5475
5476 if let Some(token) = token.as_ref() {
5477 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
5478 }
5479
5480 let request = req_builder
5481 .header(CONTENT_LENGTH, 0_u64)
5482 .body(common::to_body::<String>(None));
5483
5484 client.request(request.unwrap()).await
5485 };
5486
5487 match req_result {
5488 Err(err) => {
5489 if let common::Retry::After(d) = dlg.http_error(&err) {
5490 sleep(d).await;
5491 continue;
5492 }
5493 dlg.finished(false);
5494 return Err(common::Error::HttpError(err));
5495 }
5496 Ok(res) => {
5497 let (mut parts, body) = res.into_parts();
5498 let mut body = common::Body::new(body);
5499 if !parts.status.is_success() {
5500 let bytes = common::to_bytes(body).await.unwrap_or_default();
5501 let error = serde_json::from_str(&common::to_string(&bytes));
5502 let response = common::to_response(parts, bytes.into());
5503
5504 if let common::Retry::After(d) =
5505 dlg.http_failure(&response, error.as_ref().ok())
5506 {
5507 sleep(d).await;
5508 continue;
5509 }
5510
5511 dlg.finished(false);
5512
5513 return Err(match error {
5514 Ok(value) => common::Error::BadRequest(value),
5515 _ => common::Error::Failure(response),
5516 });
5517 }
5518 let response = common::Response::from_parts(parts, body);
5519
5520 dlg.finished(true);
5521 return Ok(response);
5522 }
5523 }
5524 }
5525 }
5526
5527 /// 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.
5528 ///
5529 /// Sets the *calendar id* path property to the given value.
5530 ///
5531 /// Even though the property as already been set when instantiating this call,
5532 /// we provide this method for API completeness.
5533 pub fn calendar_id(mut self, new_value: &str) -> CalendarListDeleteCall<'a, C> {
5534 self._calendar_id = new_value.to_string();
5535 self
5536 }
5537 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
5538 /// while executing the actual API request.
5539 ///
5540 /// ````text
5541 /// It should be used to handle progress information, and to implement a certain level of resilience.
5542 /// ````
5543 ///
5544 /// Sets the *delegate* property to the given value.
5545 pub fn delegate(
5546 mut self,
5547 new_value: &'a mut dyn common::Delegate,
5548 ) -> CalendarListDeleteCall<'a, C> {
5549 self._delegate = Some(new_value);
5550 self
5551 }
5552
5553 /// Set any additional parameter of the query string used in the request.
5554 /// It should be used to set parameters which are not yet available through their own
5555 /// setters.
5556 ///
5557 /// Please note that this method must not be used to set any of the known parameters
5558 /// which have their own setter method. If done anyway, the request will fail.
5559 ///
5560 /// # Additional Parameters
5561 ///
5562 /// * *alt* (query-string) - Data format for the response.
5563 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
5564 /// * *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.
5565 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
5566 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
5567 /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
5568 /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
5569 pub fn param<T>(mut self, name: T, value: T) -> CalendarListDeleteCall<'a, C>
5570 where
5571 T: AsRef<str>,
5572 {
5573 self._additional_params
5574 .insert(name.as_ref().to_string(), value.as_ref().to_string());
5575 self
5576 }
5577
5578 /// Identifies the authorization scope for the method you are building.
5579 ///
5580 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
5581 /// [`Scope::Full`].
5582 ///
5583 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
5584 /// tokens for more than one scope.
5585 ///
5586 /// Usually there is more than one suitable scope to authorize an operation, some of which may
5587 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
5588 /// sufficient, a read-write scope will do as well.
5589 pub fn add_scope<St>(mut self, scope: St) -> CalendarListDeleteCall<'a, C>
5590 where
5591 St: AsRef<str>,
5592 {
5593 self._scopes.insert(String::from(scope.as_ref()));
5594 self
5595 }
5596 /// Identifies the authorization scope(s) for the method you are building.
5597 ///
5598 /// See [`Self::add_scope()`] for details.
5599 pub fn add_scopes<I, St>(mut self, scopes: I) -> CalendarListDeleteCall<'a, C>
5600 where
5601 I: IntoIterator<Item = St>,
5602 St: AsRef<str>,
5603 {
5604 self._scopes
5605 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
5606 self
5607 }
5608
5609 /// Removes all scopes, and no default scope will be used either.
5610 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
5611 /// for details).
5612 pub fn clear_scopes(mut self) -> CalendarListDeleteCall<'a, C> {
5613 self._scopes.clear();
5614 self
5615 }
5616}
5617
5618/// Returns a calendar from the user's calendar list.
5619///
5620/// A builder for the *get* method supported by a *calendarList* resource.
5621/// It is not used directly, but through a [`CalendarListMethods`] instance.
5622///
5623/// # Example
5624///
5625/// Instantiate a resource method builder
5626///
5627/// ```test_harness,no_run
5628/// # extern crate hyper;
5629/// # extern crate hyper_rustls;
5630/// # extern crate google_calendar3 as calendar3;
5631/// # async fn dox() {
5632/// # use calendar3::{CalendarHub, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
5633///
5634/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
5635/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
5636/// # .with_native_roots()
5637/// # .unwrap()
5638/// # .https_only()
5639/// # .enable_http2()
5640/// # .build();
5641///
5642/// # let executor = hyper_util::rt::TokioExecutor::new();
5643/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
5644/// # secret,
5645/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
5646/// # yup_oauth2::client::CustomHyperClientBuilder::from(
5647/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
5648/// # ),
5649/// # ).build().await.unwrap();
5650///
5651/// # let client = hyper_util::client::legacy::Client::builder(
5652/// # hyper_util::rt::TokioExecutor::new()
5653/// # )
5654/// # .build(
5655/// # hyper_rustls::HttpsConnectorBuilder::new()
5656/// # .with_native_roots()
5657/// # .unwrap()
5658/// # .https_or_http()
5659/// # .enable_http2()
5660/// # .build()
5661/// # );
5662/// # let mut hub = CalendarHub::new(client, auth);
5663/// // You can configure optional parameters by calling the respective setters at will, and
5664/// // execute the final call using `doit()`.
5665/// // Values shown here are possibly random and not representative !
5666/// let result = hub.calendar_list().get("calendarId")
5667/// .doit().await;
5668/// # }
5669/// ```
5670pub struct CalendarListGetCall<'a, C>
5671where
5672 C: 'a,
5673{
5674 hub: &'a CalendarHub<C>,
5675 _calendar_id: String,
5676 _delegate: Option<&'a mut dyn common::Delegate>,
5677 _additional_params: HashMap<String, String>,
5678 _scopes: BTreeSet<String>,
5679}
5680
5681impl<'a, C> common::CallBuilder for CalendarListGetCall<'a, C> {}
5682
5683impl<'a, C> CalendarListGetCall<'a, C>
5684where
5685 C: common::Connector,
5686{
5687 /// Perform the operation you have build so far.
5688 pub async fn doit(mut self) -> common::Result<(common::Response, CalendarListEntry)> {
5689 use std::borrow::Cow;
5690 use std::io::{Read, Seek};
5691
5692 use common::{url::Params, ToParts};
5693 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
5694
5695 let mut dd = common::DefaultDelegate;
5696 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
5697 dlg.begin(common::MethodInfo {
5698 id: "calendar.calendarList.get",
5699 http_method: hyper::Method::GET,
5700 });
5701
5702 for &field in ["alt", "calendarId"].iter() {
5703 if self._additional_params.contains_key(field) {
5704 dlg.finished(false);
5705 return Err(common::Error::FieldClash(field));
5706 }
5707 }
5708
5709 let mut params = Params::with_capacity(3 + self._additional_params.len());
5710 params.push("calendarId", self._calendar_id);
5711
5712 params.extend(self._additional_params.iter());
5713
5714 params.push("alt", "json");
5715 let mut url = self.hub._base_url.clone() + "users/me/calendarList/{calendarId}";
5716 if self._scopes.is_empty() {
5717 self._scopes
5718 .insert(Scope::CalendarlistReadonly.as_ref().to_string());
5719 }
5720
5721 #[allow(clippy::single_element_loop)]
5722 for &(find_this, param_name) in [("{calendarId}", "calendarId")].iter() {
5723 url = params.uri_replacement(url, param_name, find_this, false);
5724 }
5725 {
5726 let to_remove = ["calendarId"];
5727 params.remove_params(&to_remove);
5728 }
5729
5730 let url = params.parse_with_url(&url);
5731
5732 loop {
5733 let token = match self
5734 .hub
5735 .auth
5736 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
5737 .await
5738 {
5739 Ok(token) => token,
5740 Err(e) => match dlg.token(e) {
5741 Ok(token) => token,
5742 Err(e) => {
5743 dlg.finished(false);
5744 return Err(common::Error::MissingToken(e));
5745 }
5746 },
5747 };
5748 let mut req_result = {
5749 let client = &self.hub.client;
5750 dlg.pre_request();
5751 let mut req_builder = hyper::Request::builder()
5752 .method(hyper::Method::GET)
5753 .uri(url.as_str())
5754 .header(USER_AGENT, self.hub._user_agent.clone());
5755
5756 if let Some(token) = token.as_ref() {
5757 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
5758 }
5759
5760 let request = req_builder
5761 .header(CONTENT_LENGTH, 0_u64)
5762 .body(common::to_body::<String>(None));
5763
5764 client.request(request.unwrap()).await
5765 };
5766
5767 match req_result {
5768 Err(err) => {
5769 if let common::Retry::After(d) = dlg.http_error(&err) {
5770 sleep(d).await;
5771 continue;
5772 }
5773 dlg.finished(false);
5774 return Err(common::Error::HttpError(err));
5775 }
5776 Ok(res) => {
5777 let (mut parts, body) = res.into_parts();
5778 let mut body = common::Body::new(body);
5779 if !parts.status.is_success() {
5780 let bytes = common::to_bytes(body).await.unwrap_or_default();
5781 let error = serde_json::from_str(&common::to_string(&bytes));
5782 let response = common::to_response(parts, bytes.into());
5783
5784 if let common::Retry::After(d) =
5785 dlg.http_failure(&response, error.as_ref().ok())
5786 {
5787 sleep(d).await;
5788 continue;
5789 }
5790
5791 dlg.finished(false);
5792
5793 return Err(match error {
5794 Ok(value) => common::Error::BadRequest(value),
5795 _ => common::Error::Failure(response),
5796 });
5797 }
5798 let response = {
5799 let bytes = common::to_bytes(body).await.unwrap_or_default();
5800 let encoded = common::to_string(&bytes);
5801 match serde_json::from_str(&encoded) {
5802 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
5803 Err(error) => {
5804 dlg.response_json_decode_error(&encoded, &error);
5805 return Err(common::Error::JsonDecodeError(
5806 encoded.to_string(),
5807 error,
5808 ));
5809 }
5810 }
5811 };
5812
5813 dlg.finished(true);
5814 return Ok(response);
5815 }
5816 }
5817 }
5818 }
5819
5820 /// 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.
5821 ///
5822 /// Sets the *calendar id* path 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 calendar_id(mut self, new_value: &str) -> CalendarListGetCall<'a, C> {
5827 self._calendar_id = new_value.to_string();
5828 self
5829 }
5830 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
5831 /// while executing the actual API request.
5832 ///
5833 /// ````text
5834 /// It should be used to handle progress information, and to implement a certain level of resilience.
5835 /// ````
5836 ///
5837 /// Sets the *delegate* property to the given value.
5838 pub fn delegate(
5839 mut self,
5840 new_value: &'a mut dyn common::Delegate,
5841 ) -> CalendarListGetCall<'a, C> {
5842 self._delegate = Some(new_value);
5843 self
5844 }
5845
5846 /// Set any additional parameter of the query string used in the request.
5847 /// It should be used to set parameters which are not yet available through their own
5848 /// setters.
5849 ///
5850 /// Please note that this method must not be used to set any of the known parameters
5851 /// which have their own setter method. If done anyway, the request will fail.
5852 ///
5853 /// # Additional Parameters
5854 ///
5855 /// * *alt* (query-string) - Data format for the response.
5856 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
5857 /// * *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.
5858 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
5859 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
5860 /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
5861 /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
5862 pub fn param<T>(mut self, name: T, value: T) -> CalendarListGetCall<'a, C>
5863 where
5864 T: AsRef<str>,
5865 {
5866 self._additional_params
5867 .insert(name.as_ref().to_string(), value.as_ref().to_string());
5868 self
5869 }
5870
5871 /// Identifies the authorization scope for the method you are building.
5872 ///
5873 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
5874 /// [`Scope::CalendarlistReadonly`].
5875 ///
5876 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
5877 /// tokens for more than one scope.
5878 ///
5879 /// Usually there is more than one suitable scope to authorize an operation, some of which may
5880 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
5881 /// sufficient, a read-write scope will do as well.
5882 pub fn add_scope<St>(mut self, scope: St) -> CalendarListGetCall<'a, C>
5883 where
5884 St: AsRef<str>,
5885 {
5886 self._scopes.insert(String::from(scope.as_ref()));
5887 self
5888 }
5889 /// Identifies the authorization scope(s) for the method you are building.
5890 ///
5891 /// See [`Self::add_scope()`] for details.
5892 pub fn add_scopes<I, St>(mut self, scopes: I) -> CalendarListGetCall<'a, C>
5893 where
5894 I: IntoIterator<Item = St>,
5895 St: AsRef<str>,
5896 {
5897 self._scopes
5898 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
5899 self
5900 }
5901
5902 /// Removes all scopes, and no default scope will be used either.
5903 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
5904 /// for details).
5905 pub fn clear_scopes(mut self) -> CalendarListGetCall<'a, C> {
5906 self._scopes.clear();
5907 self
5908 }
5909}
5910
5911/// Inserts an existing calendar into the user's calendar list.
5912///
5913/// A builder for the *insert* method supported by a *calendarList* resource.
5914/// It is not used directly, but through a [`CalendarListMethods`] instance.
5915///
5916/// # Example
5917///
5918/// Instantiate a resource method builder
5919///
5920/// ```test_harness,no_run
5921/// # extern crate hyper;
5922/// # extern crate hyper_rustls;
5923/// # extern crate google_calendar3 as calendar3;
5924/// use calendar3::api::CalendarListEntry;
5925/// # async fn dox() {
5926/// # use calendar3::{CalendarHub, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
5927///
5928/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
5929/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
5930/// # .with_native_roots()
5931/// # .unwrap()
5932/// # .https_only()
5933/// # .enable_http2()
5934/// # .build();
5935///
5936/// # let executor = hyper_util::rt::TokioExecutor::new();
5937/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
5938/// # secret,
5939/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
5940/// # yup_oauth2::client::CustomHyperClientBuilder::from(
5941/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
5942/// # ),
5943/// # ).build().await.unwrap();
5944///
5945/// # let client = hyper_util::client::legacy::Client::builder(
5946/// # hyper_util::rt::TokioExecutor::new()
5947/// # )
5948/// # .build(
5949/// # hyper_rustls::HttpsConnectorBuilder::new()
5950/// # .with_native_roots()
5951/// # .unwrap()
5952/// # .https_or_http()
5953/// # .enable_http2()
5954/// # .build()
5955/// # );
5956/// # let mut hub = CalendarHub::new(client, auth);
5957/// // As the method needs a request, you would usually fill it with the desired information
5958/// // into the respective structure. Some of the parts shown here might not be applicable !
5959/// // Values shown here are possibly random and not representative !
5960/// let mut req = CalendarListEntry::default();
5961///
5962/// // You can configure optional parameters by calling the respective setters at will, and
5963/// // execute the final call using `doit()`.
5964/// // Values shown here are possibly random and not representative !
5965/// let result = hub.calendar_list().insert(req)
5966/// .color_rgb_format(true)
5967/// .doit().await;
5968/// # }
5969/// ```
5970pub struct CalendarListInsertCall<'a, C>
5971where
5972 C: 'a,
5973{
5974 hub: &'a CalendarHub<C>,
5975 _request: CalendarListEntry,
5976 _color_rgb_format: Option<bool>,
5977 _delegate: Option<&'a mut dyn common::Delegate>,
5978 _additional_params: HashMap<String, String>,
5979 _scopes: BTreeSet<String>,
5980}
5981
5982impl<'a, C> common::CallBuilder for CalendarListInsertCall<'a, C> {}
5983
5984impl<'a, C> CalendarListInsertCall<'a, C>
5985where
5986 C: common::Connector,
5987{
5988 /// Perform the operation you have build so far.
5989 pub async fn doit(mut self) -> common::Result<(common::Response, CalendarListEntry)> {
5990 use std::borrow::Cow;
5991 use std::io::{Read, Seek};
5992
5993 use common::{url::Params, ToParts};
5994 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
5995
5996 let mut dd = common::DefaultDelegate;
5997 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
5998 dlg.begin(common::MethodInfo {
5999 id: "calendar.calendarList.insert",
6000 http_method: hyper::Method::POST,
6001 });
6002
6003 for &field in ["alt", "colorRgbFormat"].iter() {
6004 if self._additional_params.contains_key(field) {
6005 dlg.finished(false);
6006 return Err(common::Error::FieldClash(field));
6007 }
6008 }
6009
6010 let mut params = Params::with_capacity(4 + self._additional_params.len());
6011 if let Some(value) = self._color_rgb_format.as_ref() {
6012 params.push("colorRgbFormat", value.to_string());
6013 }
6014
6015 params.extend(self._additional_params.iter());
6016
6017 params.push("alt", "json");
6018 let mut url = self.hub._base_url.clone() + "users/me/calendarList";
6019 if self._scopes.is_empty() {
6020 self._scopes.insert(Scope::Full.as_ref().to_string());
6021 }
6022
6023 let url = params.parse_with_url(&url);
6024
6025 let mut json_mime_type = mime::APPLICATION_JSON;
6026 let mut request_value_reader = {
6027 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
6028 common::remove_json_null_values(&mut value);
6029 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
6030 serde_json::to_writer(&mut dst, &value).unwrap();
6031 dst
6032 };
6033 let request_size = request_value_reader
6034 .seek(std::io::SeekFrom::End(0))
6035 .unwrap();
6036 request_value_reader
6037 .seek(std::io::SeekFrom::Start(0))
6038 .unwrap();
6039
6040 loop {
6041 let token = match self
6042 .hub
6043 .auth
6044 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
6045 .await
6046 {
6047 Ok(token) => token,
6048 Err(e) => match dlg.token(e) {
6049 Ok(token) => token,
6050 Err(e) => {
6051 dlg.finished(false);
6052 return Err(common::Error::MissingToken(e));
6053 }
6054 },
6055 };
6056 request_value_reader
6057 .seek(std::io::SeekFrom::Start(0))
6058 .unwrap();
6059 let mut req_result = {
6060 let client = &self.hub.client;
6061 dlg.pre_request();
6062 let mut req_builder = hyper::Request::builder()
6063 .method(hyper::Method::POST)
6064 .uri(url.as_str())
6065 .header(USER_AGENT, self.hub._user_agent.clone());
6066
6067 if let Some(token) = token.as_ref() {
6068 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
6069 }
6070
6071 let request = req_builder
6072 .header(CONTENT_TYPE, json_mime_type.to_string())
6073 .header(CONTENT_LENGTH, request_size as u64)
6074 .body(common::to_body(
6075 request_value_reader.get_ref().clone().into(),
6076 ));
6077
6078 client.request(request.unwrap()).await
6079 };
6080
6081 match req_result {
6082 Err(err) => {
6083 if let common::Retry::After(d) = dlg.http_error(&err) {
6084 sleep(d).await;
6085 continue;
6086 }
6087 dlg.finished(false);
6088 return Err(common::Error::HttpError(err));
6089 }
6090 Ok(res) => {
6091 let (mut parts, body) = res.into_parts();
6092 let mut body = common::Body::new(body);
6093 if !parts.status.is_success() {
6094 let bytes = common::to_bytes(body).await.unwrap_or_default();
6095 let error = serde_json::from_str(&common::to_string(&bytes));
6096 let response = common::to_response(parts, bytes.into());
6097
6098 if let common::Retry::After(d) =
6099 dlg.http_failure(&response, error.as_ref().ok())
6100 {
6101 sleep(d).await;
6102 continue;
6103 }
6104
6105 dlg.finished(false);
6106
6107 return Err(match error {
6108 Ok(value) => common::Error::BadRequest(value),
6109 _ => common::Error::Failure(response),
6110 });
6111 }
6112 let response = {
6113 let bytes = common::to_bytes(body).await.unwrap_or_default();
6114 let encoded = common::to_string(&bytes);
6115 match serde_json::from_str(&encoded) {
6116 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
6117 Err(error) => {
6118 dlg.response_json_decode_error(&encoded, &error);
6119 return Err(common::Error::JsonDecodeError(
6120 encoded.to_string(),
6121 error,
6122 ));
6123 }
6124 }
6125 };
6126
6127 dlg.finished(true);
6128 return Ok(response);
6129 }
6130 }
6131 }
6132 }
6133
6134 ///
6135 /// Sets the *request* property to the given value.
6136 ///
6137 /// Even though the property as already been set when instantiating this call,
6138 /// we provide this method for API completeness.
6139 pub fn request(mut self, new_value: CalendarListEntry) -> CalendarListInsertCall<'a, C> {
6140 self._request = new_value;
6141 self
6142 }
6143 /// 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.
6144 ///
6145 /// Sets the *color rgb format* query property to the given value.
6146 pub fn color_rgb_format(mut self, new_value: bool) -> CalendarListInsertCall<'a, C> {
6147 self._color_rgb_format = Some(new_value);
6148 self
6149 }
6150 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
6151 /// while executing the actual API request.
6152 ///
6153 /// ````text
6154 /// It should be used to handle progress information, and to implement a certain level of resilience.
6155 /// ````
6156 ///
6157 /// Sets the *delegate* property to the given value.
6158 pub fn delegate(
6159 mut self,
6160 new_value: &'a mut dyn common::Delegate,
6161 ) -> CalendarListInsertCall<'a, C> {
6162 self._delegate = Some(new_value);
6163 self
6164 }
6165
6166 /// Set any additional parameter of the query string used in the request.
6167 /// It should be used to set parameters which are not yet available through their own
6168 /// setters.
6169 ///
6170 /// Please note that this method must not be used to set any of the known parameters
6171 /// which have their own setter method. If done anyway, the request will fail.
6172 ///
6173 /// # Additional Parameters
6174 ///
6175 /// * *alt* (query-string) - Data format for the response.
6176 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
6177 /// * *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.
6178 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
6179 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
6180 /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
6181 /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
6182 pub fn param<T>(mut self, name: T, value: T) -> CalendarListInsertCall<'a, C>
6183 where
6184 T: AsRef<str>,
6185 {
6186 self._additional_params
6187 .insert(name.as_ref().to_string(), value.as_ref().to_string());
6188 self
6189 }
6190
6191 /// Identifies the authorization scope for the method you are building.
6192 ///
6193 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
6194 /// [`Scope::Full`].
6195 ///
6196 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
6197 /// tokens for more than one scope.
6198 ///
6199 /// Usually there is more than one suitable scope to authorize an operation, some of which may
6200 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
6201 /// sufficient, a read-write scope will do as well.
6202 pub fn add_scope<St>(mut self, scope: St) -> CalendarListInsertCall<'a, C>
6203 where
6204 St: AsRef<str>,
6205 {
6206 self._scopes.insert(String::from(scope.as_ref()));
6207 self
6208 }
6209 /// Identifies the authorization scope(s) for the method you are building.
6210 ///
6211 /// See [`Self::add_scope()`] for details.
6212 pub fn add_scopes<I, St>(mut self, scopes: I) -> CalendarListInsertCall<'a, C>
6213 where
6214 I: IntoIterator<Item = St>,
6215 St: AsRef<str>,
6216 {
6217 self._scopes
6218 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
6219 self
6220 }
6221
6222 /// Removes all scopes, and no default scope will be used either.
6223 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
6224 /// for details).
6225 pub fn clear_scopes(mut self) -> CalendarListInsertCall<'a, C> {
6226 self._scopes.clear();
6227 self
6228 }
6229}
6230
6231/// Returns the calendars on the user's calendar list.
6232///
6233/// A builder for the *list* method supported by a *calendarList* resource.
6234/// It is not used directly, but through a [`CalendarListMethods`] instance.
6235///
6236/// # Example
6237///
6238/// Instantiate a resource method builder
6239///
6240/// ```test_harness,no_run
6241/// # extern crate hyper;
6242/// # extern crate hyper_rustls;
6243/// # extern crate google_calendar3 as calendar3;
6244/// # async fn dox() {
6245/// # use calendar3::{CalendarHub, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
6246///
6247/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
6248/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
6249/// # .with_native_roots()
6250/// # .unwrap()
6251/// # .https_only()
6252/// # .enable_http2()
6253/// # .build();
6254///
6255/// # let executor = hyper_util::rt::TokioExecutor::new();
6256/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
6257/// # secret,
6258/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
6259/// # yup_oauth2::client::CustomHyperClientBuilder::from(
6260/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
6261/// # ),
6262/// # ).build().await.unwrap();
6263///
6264/// # let client = hyper_util::client::legacy::Client::builder(
6265/// # hyper_util::rt::TokioExecutor::new()
6266/// # )
6267/// # .build(
6268/// # hyper_rustls::HttpsConnectorBuilder::new()
6269/// # .with_native_roots()
6270/// # .unwrap()
6271/// # .https_or_http()
6272/// # .enable_http2()
6273/// # .build()
6274/// # );
6275/// # let mut hub = CalendarHub::new(client, auth);
6276/// // You can configure optional parameters by calling the respective setters at will, and
6277/// // execute the final call using `doit()`.
6278/// // Values shown here are possibly random and not representative !
6279/// let result = hub.calendar_list().list()
6280/// .sync_token("et")
6281/// .show_hidden(false)
6282/// .show_deleted(false)
6283/// .page_token("amet.")
6284/// .min_access_role("ea")
6285/// .max_results(-95)
6286/// .doit().await;
6287/// # }
6288/// ```
6289pub struct CalendarListListCall<'a, C>
6290where
6291 C: 'a,
6292{
6293 hub: &'a CalendarHub<C>,
6294 _sync_token: Option<String>,
6295 _show_hidden: Option<bool>,
6296 _show_deleted: Option<bool>,
6297 _page_token: Option<String>,
6298 _min_access_role: Option<String>,
6299 _max_results: Option<i32>,
6300 _delegate: Option<&'a mut dyn common::Delegate>,
6301 _additional_params: HashMap<String, String>,
6302 _scopes: BTreeSet<String>,
6303}
6304
6305impl<'a, C> common::CallBuilder for CalendarListListCall<'a, C> {}
6306
6307impl<'a, C> CalendarListListCall<'a, C>
6308where
6309 C: common::Connector,
6310{
6311 /// Perform the operation you have build so far.
6312 pub async fn doit(mut self) -> common::Result<(common::Response, CalendarList)> {
6313 use std::borrow::Cow;
6314 use std::io::{Read, Seek};
6315
6316 use common::{url::Params, ToParts};
6317 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
6318
6319 let mut dd = common::DefaultDelegate;
6320 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
6321 dlg.begin(common::MethodInfo {
6322 id: "calendar.calendarList.list",
6323 http_method: hyper::Method::GET,
6324 });
6325
6326 for &field in [
6327 "alt",
6328 "syncToken",
6329 "showHidden",
6330 "showDeleted",
6331 "pageToken",
6332 "minAccessRole",
6333 "maxResults",
6334 ]
6335 .iter()
6336 {
6337 if self._additional_params.contains_key(field) {
6338 dlg.finished(false);
6339 return Err(common::Error::FieldClash(field));
6340 }
6341 }
6342
6343 let mut params = Params::with_capacity(8 + self._additional_params.len());
6344 if let Some(value) = self._sync_token.as_ref() {
6345 params.push("syncToken", value);
6346 }
6347 if let Some(value) = self._show_hidden.as_ref() {
6348 params.push("showHidden", value.to_string());
6349 }
6350 if let Some(value) = self._show_deleted.as_ref() {
6351 params.push("showDeleted", value.to_string());
6352 }
6353 if let Some(value) = self._page_token.as_ref() {
6354 params.push("pageToken", value);
6355 }
6356 if let Some(value) = self._min_access_role.as_ref() {
6357 params.push("minAccessRole", value);
6358 }
6359 if let Some(value) = self._max_results.as_ref() {
6360 params.push("maxResults", value.to_string());
6361 }
6362
6363 params.extend(self._additional_params.iter());
6364
6365 params.push("alt", "json");
6366 let mut url = self.hub._base_url.clone() + "users/me/calendarList";
6367 if self._scopes.is_empty() {
6368 self._scopes
6369 .insert(Scope::CalendarlistReadonly.as_ref().to_string());
6370 }
6371
6372 let url = params.parse_with_url(&url);
6373
6374 loop {
6375 let token = match self
6376 .hub
6377 .auth
6378 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
6379 .await
6380 {
6381 Ok(token) => token,
6382 Err(e) => match dlg.token(e) {
6383 Ok(token) => token,
6384 Err(e) => {
6385 dlg.finished(false);
6386 return Err(common::Error::MissingToken(e));
6387 }
6388 },
6389 };
6390 let mut req_result = {
6391 let client = &self.hub.client;
6392 dlg.pre_request();
6393 let mut req_builder = hyper::Request::builder()
6394 .method(hyper::Method::GET)
6395 .uri(url.as_str())
6396 .header(USER_AGENT, self.hub._user_agent.clone());
6397
6398 if let Some(token) = token.as_ref() {
6399 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
6400 }
6401
6402 let request = req_builder
6403 .header(CONTENT_LENGTH, 0_u64)
6404 .body(common::to_body::<String>(None));
6405
6406 client.request(request.unwrap()).await
6407 };
6408
6409 match req_result {
6410 Err(err) => {
6411 if let common::Retry::After(d) = dlg.http_error(&err) {
6412 sleep(d).await;
6413 continue;
6414 }
6415 dlg.finished(false);
6416 return Err(common::Error::HttpError(err));
6417 }
6418 Ok(res) => {
6419 let (mut parts, body) = res.into_parts();
6420 let mut body = common::Body::new(body);
6421 if !parts.status.is_success() {
6422 let bytes = common::to_bytes(body).await.unwrap_or_default();
6423 let error = serde_json::from_str(&common::to_string(&bytes));
6424 let response = common::to_response(parts, bytes.into());
6425
6426 if let common::Retry::After(d) =
6427 dlg.http_failure(&response, error.as_ref().ok())
6428 {
6429 sleep(d).await;
6430 continue;
6431 }
6432
6433 dlg.finished(false);
6434
6435 return Err(match error {
6436 Ok(value) => common::Error::BadRequest(value),
6437 _ => common::Error::Failure(response),
6438 });
6439 }
6440 let response = {
6441 let bytes = common::to_bytes(body).await.unwrap_or_default();
6442 let encoded = common::to_string(&bytes);
6443 match serde_json::from_str(&encoded) {
6444 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
6445 Err(error) => {
6446 dlg.response_json_decode_error(&encoded, &error);
6447 return Err(common::Error::JsonDecodeError(
6448 encoded.to_string(),
6449 error,
6450 ));
6451 }
6452 }
6453 };
6454
6455 dlg.finished(true);
6456 return Ok(response);
6457 }
6458 }
6459 }
6460 }
6461
6462 /// 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.
6463 /// To ensure client state consistency minAccessRole query parameter cannot be specified together with nextSyncToken.
6464 /// 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.
6465 /// Learn more about incremental synchronization.
6466 /// Optional. The default is to return all entries.
6467 ///
6468 /// Sets the *sync token* query property to the given value.
6469 pub fn sync_token(mut self, new_value: &str) -> CalendarListListCall<'a, C> {
6470 self._sync_token = Some(new_value.to_string());
6471 self
6472 }
6473 /// Whether to show hidden entries. Optional. The default is False.
6474 ///
6475 /// Sets the *show hidden* query property to the given value.
6476 pub fn show_hidden(mut self, new_value: bool) -> CalendarListListCall<'a, C> {
6477 self._show_hidden = Some(new_value);
6478 self
6479 }
6480 /// Whether to include deleted calendar list entries in the result. Optional. The default is False.
6481 ///
6482 /// Sets the *show deleted* query property to the given value.
6483 pub fn show_deleted(mut self, new_value: bool) -> CalendarListListCall<'a, C> {
6484 self._show_deleted = Some(new_value);
6485 self
6486 }
6487 /// Token specifying which result page to return. Optional.
6488 ///
6489 /// Sets the *page token* query property to the given value.
6490 pub fn page_token(mut self, new_value: &str) -> CalendarListListCall<'a, C> {
6491 self._page_token = Some(new_value.to_string());
6492 self
6493 }
6494 /// The minimum access role for the user in the returned entries. Optional. The default is no restriction.
6495 ///
6496 /// Sets the *min access role* query property to the given value.
6497 pub fn min_access_role(mut self, new_value: &str) -> CalendarListListCall<'a, C> {
6498 self._min_access_role = Some(new_value.to_string());
6499 self
6500 }
6501 /// 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.
6502 ///
6503 /// Sets the *max results* query property to the given value.
6504 pub fn max_results(mut self, new_value: i32) -> CalendarListListCall<'a, C> {
6505 self._max_results = Some(new_value);
6506 self
6507 }
6508 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
6509 /// while executing the actual API request.
6510 ///
6511 /// ````text
6512 /// It should be used to handle progress information, and to implement a certain level of resilience.
6513 /// ````
6514 ///
6515 /// Sets the *delegate* property to the given value.
6516 pub fn delegate(
6517 mut self,
6518 new_value: &'a mut dyn common::Delegate,
6519 ) -> CalendarListListCall<'a, C> {
6520 self._delegate = Some(new_value);
6521 self
6522 }
6523
6524 /// Set any additional parameter of the query string used in the request.
6525 /// It should be used to set parameters which are not yet available through their own
6526 /// setters.
6527 ///
6528 /// Please note that this method must not be used to set any of the known parameters
6529 /// which have their own setter method. If done anyway, the request will fail.
6530 ///
6531 /// # Additional Parameters
6532 ///
6533 /// * *alt* (query-string) - Data format for the response.
6534 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
6535 /// * *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.
6536 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
6537 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
6538 /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
6539 /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
6540 pub fn param<T>(mut self, name: T, value: T) -> CalendarListListCall<'a, C>
6541 where
6542 T: AsRef<str>,
6543 {
6544 self._additional_params
6545 .insert(name.as_ref().to_string(), value.as_ref().to_string());
6546 self
6547 }
6548
6549 /// Identifies the authorization scope for the method you are building.
6550 ///
6551 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
6552 /// [`Scope::CalendarlistReadonly`].
6553 ///
6554 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
6555 /// tokens for more than one scope.
6556 ///
6557 /// Usually there is more than one suitable scope to authorize an operation, some of which may
6558 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
6559 /// sufficient, a read-write scope will do as well.
6560 pub fn add_scope<St>(mut self, scope: St) -> CalendarListListCall<'a, C>
6561 where
6562 St: AsRef<str>,
6563 {
6564 self._scopes.insert(String::from(scope.as_ref()));
6565 self
6566 }
6567 /// Identifies the authorization scope(s) for the method you are building.
6568 ///
6569 /// See [`Self::add_scope()`] for details.
6570 pub fn add_scopes<I, St>(mut self, scopes: I) -> CalendarListListCall<'a, C>
6571 where
6572 I: IntoIterator<Item = St>,
6573 St: AsRef<str>,
6574 {
6575 self._scopes
6576 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
6577 self
6578 }
6579
6580 /// Removes all scopes, and no default scope will be used either.
6581 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
6582 /// for details).
6583 pub fn clear_scopes(mut self) -> CalendarListListCall<'a, C> {
6584 self._scopes.clear();
6585 self
6586 }
6587}
6588
6589/// Updates an existing calendar on the user's calendar list. This method supports patch semantics.
6590///
6591/// A builder for the *patch* method supported by a *calendarList* resource.
6592/// It is not used directly, but through a [`CalendarListMethods`] instance.
6593///
6594/// # Example
6595///
6596/// Instantiate a resource method builder
6597///
6598/// ```test_harness,no_run
6599/// # extern crate hyper;
6600/// # extern crate hyper_rustls;
6601/// # extern crate google_calendar3 as calendar3;
6602/// use calendar3::api::CalendarListEntry;
6603/// # async fn dox() {
6604/// # use calendar3::{CalendarHub, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
6605///
6606/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
6607/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
6608/// # .with_native_roots()
6609/// # .unwrap()
6610/// # .https_only()
6611/// # .enable_http2()
6612/// # .build();
6613///
6614/// # let executor = hyper_util::rt::TokioExecutor::new();
6615/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
6616/// # secret,
6617/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
6618/// # yup_oauth2::client::CustomHyperClientBuilder::from(
6619/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
6620/// # ),
6621/// # ).build().await.unwrap();
6622///
6623/// # let client = hyper_util::client::legacy::Client::builder(
6624/// # hyper_util::rt::TokioExecutor::new()
6625/// # )
6626/// # .build(
6627/// # hyper_rustls::HttpsConnectorBuilder::new()
6628/// # .with_native_roots()
6629/// # .unwrap()
6630/// # .https_or_http()
6631/// # .enable_http2()
6632/// # .build()
6633/// # );
6634/// # let mut hub = CalendarHub::new(client, auth);
6635/// // As the method needs a request, you would usually fill it with the desired information
6636/// // into the respective structure. Some of the parts shown here might not be applicable !
6637/// // Values shown here are possibly random and not representative !
6638/// let mut req = CalendarListEntry::default();
6639///
6640/// // You can configure optional parameters by calling the respective setters at will, and
6641/// // execute the final call using `doit()`.
6642/// // Values shown here are possibly random and not representative !
6643/// let result = hub.calendar_list().patch(req, "calendarId")
6644/// .color_rgb_format(true)
6645/// .doit().await;
6646/// # }
6647/// ```
6648pub struct CalendarListPatchCall<'a, C>
6649where
6650 C: 'a,
6651{
6652 hub: &'a CalendarHub<C>,
6653 _request: CalendarListEntry,
6654 _calendar_id: String,
6655 _color_rgb_format: Option<bool>,
6656 _delegate: Option<&'a mut dyn common::Delegate>,
6657 _additional_params: HashMap<String, String>,
6658 _scopes: BTreeSet<String>,
6659}
6660
6661impl<'a, C> common::CallBuilder for CalendarListPatchCall<'a, C> {}
6662
6663impl<'a, C> CalendarListPatchCall<'a, C>
6664where
6665 C: common::Connector,
6666{
6667 /// Perform the operation you have build so far.
6668 pub async fn doit(mut self) -> common::Result<(common::Response, CalendarListEntry)> {
6669 use std::borrow::Cow;
6670 use std::io::{Read, Seek};
6671
6672 use common::{url::Params, ToParts};
6673 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
6674
6675 let mut dd = common::DefaultDelegate;
6676 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
6677 dlg.begin(common::MethodInfo {
6678 id: "calendar.calendarList.patch",
6679 http_method: hyper::Method::PATCH,
6680 });
6681
6682 for &field in ["alt", "calendarId", "colorRgbFormat"].iter() {
6683 if self._additional_params.contains_key(field) {
6684 dlg.finished(false);
6685 return Err(common::Error::FieldClash(field));
6686 }
6687 }
6688
6689 let mut params = Params::with_capacity(5 + self._additional_params.len());
6690 params.push("calendarId", self._calendar_id);
6691 if let Some(value) = self._color_rgb_format.as_ref() {
6692 params.push("colorRgbFormat", value.to_string());
6693 }
6694
6695 params.extend(self._additional_params.iter());
6696
6697 params.push("alt", "json");
6698 let mut url = self.hub._base_url.clone() + "users/me/calendarList/{calendarId}";
6699 if self._scopes.is_empty() {
6700 self._scopes.insert(Scope::Full.as_ref().to_string());
6701 }
6702
6703 #[allow(clippy::single_element_loop)]
6704 for &(find_this, param_name) in [("{calendarId}", "calendarId")].iter() {
6705 url = params.uri_replacement(url, param_name, find_this, false);
6706 }
6707 {
6708 let to_remove = ["calendarId"];
6709 params.remove_params(&to_remove);
6710 }
6711
6712 let url = params.parse_with_url(&url);
6713
6714 let mut json_mime_type = mime::APPLICATION_JSON;
6715 let mut request_value_reader = {
6716 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
6717 common::remove_json_null_values(&mut value);
6718 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
6719 serde_json::to_writer(&mut dst, &value).unwrap();
6720 dst
6721 };
6722 let request_size = request_value_reader
6723 .seek(std::io::SeekFrom::End(0))
6724 .unwrap();
6725 request_value_reader
6726 .seek(std::io::SeekFrom::Start(0))
6727 .unwrap();
6728
6729 loop {
6730 let token = match self
6731 .hub
6732 .auth
6733 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
6734 .await
6735 {
6736 Ok(token) => token,
6737 Err(e) => match dlg.token(e) {
6738 Ok(token) => token,
6739 Err(e) => {
6740 dlg.finished(false);
6741 return Err(common::Error::MissingToken(e));
6742 }
6743 },
6744 };
6745 request_value_reader
6746 .seek(std::io::SeekFrom::Start(0))
6747 .unwrap();
6748 let mut req_result = {
6749 let client = &self.hub.client;
6750 dlg.pre_request();
6751 let mut req_builder = hyper::Request::builder()
6752 .method(hyper::Method::PATCH)
6753 .uri(url.as_str())
6754 .header(USER_AGENT, self.hub._user_agent.clone());
6755
6756 if let Some(token) = token.as_ref() {
6757 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
6758 }
6759
6760 let request = req_builder
6761 .header(CONTENT_TYPE, json_mime_type.to_string())
6762 .header(CONTENT_LENGTH, request_size as u64)
6763 .body(common::to_body(
6764 request_value_reader.get_ref().clone().into(),
6765 ));
6766
6767 client.request(request.unwrap()).await
6768 };
6769
6770 match req_result {
6771 Err(err) => {
6772 if let common::Retry::After(d) = dlg.http_error(&err) {
6773 sleep(d).await;
6774 continue;
6775 }
6776 dlg.finished(false);
6777 return Err(common::Error::HttpError(err));
6778 }
6779 Ok(res) => {
6780 let (mut parts, body) = res.into_parts();
6781 let mut body = common::Body::new(body);
6782 if !parts.status.is_success() {
6783 let bytes = common::to_bytes(body).await.unwrap_or_default();
6784 let error = serde_json::from_str(&common::to_string(&bytes));
6785 let response = common::to_response(parts, bytes.into());
6786
6787 if let common::Retry::After(d) =
6788 dlg.http_failure(&response, error.as_ref().ok())
6789 {
6790 sleep(d).await;
6791 continue;
6792 }
6793
6794 dlg.finished(false);
6795
6796 return Err(match error {
6797 Ok(value) => common::Error::BadRequest(value),
6798 _ => common::Error::Failure(response),
6799 });
6800 }
6801 let response = {
6802 let bytes = common::to_bytes(body).await.unwrap_or_default();
6803 let encoded = common::to_string(&bytes);
6804 match serde_json::from_str(&encoded) {
6805 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
6806 Err(error) => {
6807 dlg.response_json_decode_error(&encoded, &error);
6808 return Err(common::Error::JsonDecodeError(
6809 encoded.to_string(),
6810 error,
6811 ));
6812 }
6813 }
6814 };
6815
6816 dlg.finished(true);
6817 return Ok(response);
6818 }
6819 }
6820 }
6821 }
6822
6823 ///
6824 /// Sets the *request* property to the given value.
6825 ///
6826 /// Even though the property as already been set when instantiating this call,
6827 /// we provide this method for API completeness.
6828 pub fn request(mut self, new_value: CalendarListEntry) -> CalendarListPatchCall<'a, C> {
6829 self._request = new_value;
6830 self
6831 }
6832 /// 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.
6833 ///
6834 /// Sets the *calendar id* path property to the given value.
6835 ///
6836 /// Even though the property as already been set when instantiating this call,
6837 /// we provide this method for API completeness.
6838 pub fn calendar_id(mut self, new_value: &str) -> CalendarListPatchCall<'a, C> {
6839 self._calendar_id = new_value.to_string();
6840 self
6841 }
6842 /// 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.
6843 ///
6844 /// Sets the *color rgb format* query property to the given value.
6845 pub fn color_rgb_format(mut self, new_value: bool) -> CalendarListPatchCall<'a, C> {
6846 self._color_rgb_format = Some(new_value);
6847 self
6848 }
6849 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
6850 /// while executing the actual API request.
6851 ///
6852 /// ````text
6853 /// It should be used to handle progress information, and to implement a certain level of resilience.
6854 /// ````
6855 ///
6856 /// Sets the *delegate* property to the given value.
6857 pub fn delegate(
6858 mut self,
6859 new_value: &'a mut dyn common::Delegate,
6860 ) -> CalendarListPatchCall<'a, C> {
6861 self._delegate = Some(new_value);
6862 self
6863 }
6864
6865 /// Set any additional parameter of the query string used in the request.
6866 /// It should be used to set parameters which are not yet available through their own
6867 /// setters.
6868 ///
6869 /// Please note that this method must not be used to set any of the known parameters
6870 /// which have their own setter method. If done anyway, the request will fail.
6871 ///
6872 /// # Additional Parameters
6873 ///
6874 /// * *alt* (query-string) - Data format for the response.
6875 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
6876 /// * *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.
6877 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
6878 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
6879 /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
6880 /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
6881 pub fn param<T>(mut self, name: T, value: T) -> CalendarListPatchCall<'a, C>
6882 where
6883 T: AsRef<str>,
6884 {
6885 self._additional_params
6886 .insert(name.as_ref().to_string(), value.as_ref().to_string());
6887 self
6888 }
6889
6890 /// Identifies the authorization scope for the method you are building.
6891 ///
6892 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
6893 /// [`Scope::Full`].
6894 ///
6895 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
6896 /// tokens for more than one scope.
6897 ///
6898 /// Usually there is more than one suitable scope to authorize an operation, some of which may
6899 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
6900 /// sufficient, a read-write scope will do as well.
6901 pub fn add_scope<St>(mut self, scope: St) -> CalendarListPatchCall<'a, C>
6902 where
6903 St: AsRef<str>,
6904 {
6905 self._scopes.insert(String::from(scope.as_ref()));
6906 self
6907 }
6908 /// Identifies the authorization scope(s) for the method you are building.
6909 ///
6910 /// See [`Self::add_scope()`] for details.
6911 pub fn add_scopes<I, St>(mut self, scopes: I) -> CalendarListPatchCall<'a, C>
6912 where
6913 I: IntoIterator<Item = St>,
6914 St: AsRef<str>,
6915 {
6916 self._scopes
6917 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
6918 self
6919 }
6920
6921 /// Removes all scopes, and no default scope will be used either.
6922 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
6923 /// for details).
6924 pub fn clear_scopes(mut self) -> CalendarListPatchCall<'a, C> {
6925 self._scopes.clear();
6926 self
6927 }
6928}
6929
6930/// Updates an existing calendar on the user's calendar list.
6931///
6932/// A builder for the *update* method supported by a *calendarList* resource.
6933/// It is not used directly, but through a [`CalendarListMethods`] instance.
6934///
6935/// # Example
6936///
6937/// Instantiate a resource method builder
6938///
6939/// ```test_harness,no_run
6940/// # extern crate hyper;
6941/// # extern crate hyper_rustls;
6942/// # extern crate google_calendar3 as calendar3;
6943/// use calendar3::api::CalendarListEntry;
6944/// # async fn dox() {
6945/// # use calendar3::{CalendarHub, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
6946///
6947/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
6948/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
6949/// # .with_native_roots()
6950/// # .unwrap()
6951/// # .https_only()
6952/// # .enable_http2()
6953/// # .build();
6954///
6955/// # let executor = hyper_util::rt::TokioExecutor::new();
6956/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
6957/// # secret,
6958/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
6959/// # yup_oauth2::client::CustomHyperClientBuilder::from(
6960/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
6961/// # ),
6962/// # ).build().await.unwrap();
6963///
6964/// # let client = hyper_util::client::legacy::Client::builder(
6965/// # hyper_util::rt::TokioExecutor::new()
6966/// # )
6967/// # .build(
6968/// # hyper_rustls::HttpsConnectorBuilder::new()
6969/// # .with_native_roots()
6970/// # .unwrap()
6971/// # .https_or_http()
6972/// # .enable_http2()
6973/// # .build()
6974/// # );
6975/// # let mut hub = CalendarHub::new(client, auth);
6976/// // As the method needs a request, you would usually fill it with the desired information
6977/// // into the respective structure. Some of the parts shown here might not be applicable !
6978/// // Values shown here are possibly random and not representative !
6979/// let mut req = CalendarListEntry::default();
6980///
6981/// // You can configure optional parameters by calling the respective setters at will, and
6982/// // execute the final call using `doit()`.
6983/// // Values shown here are possibly random and not representative !
6984/// let result = hub.calendar_list().update(req, "calendarId")
6985/// .color_rgb_format(true)
6986/// .doit().await;
6987/// # }
6988/// ```
6989pub struct CalendarListUpdateCall<'a, C>
6990where
6991 C: 'a,
6992{
6993 hub: &'a CalendarHub<C>,
6994 _request: CalendarListEntry,
6995 _calendar_id: String,
6996 _color_rgb_format: Option<bool>,
6997 _delegate: Option<&'a mut dyn common::Delegate>,
6998 _additional_params: HashMap<String, String>,
6999 _scopes: BTreeSet<String>,
7000}
7001
7002impl<'a, C> common::CallBuilder for CalendarListUpdateCall<'a, C> {}
7003
7004impl<'a, C> CalendarListUpdateCall<'a, C>
7005where
7006 C: common::Connector,
7007{
7008 /// Perform the operation you have build so far.
7009 pub async fn doit(mut self) -> common::Result<(common::Response, CalendarListEntry)> {
7010 use std::borrow::Cow;
7011 use std::io::{Read, Seek};
7012
7013 use common::{url::Params, ToParts};
7014 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
7015
7016 let mut dd = common::DefaultDelegate;
7017 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
7018 dlg.begin(common::MethodInfo {
7019 id: "calendar.calendarList.update",
7020 http_method: hyper::Method::PUT,
7021 });
7022
7023 for &field in ["alt", "calendarId", "colorRgbFormat"].iter() {
7024 if self._additional_params.contains_key(field) {
7025 dlg.finished(false);
7026 return Err(common::Error::FieldClash(field));
7027 }
7028 }
7029
7030 let mut params = Params::with_capacity(5 + self._additional_params.len());
7031 params.push("calendarId", self._calendar_id);
7032 if let Some(value) = self._color_rgb_format.as_ref() {
7033 params.push("colorRgbFormat", value.to_string());
7034 }
7035
7036 params.extend(self._additional_params.iter());
7037
7038 params.push("alt", "json");
7039 let mut url = self.hub._base_url.clone() + "users/me/calendarList/{calendarId}";
7040 if self._scopes.is_empty() {
7041 self._scopes.insert(Scope::Full.as_ref().to_string());
7042 }
7043
7044 #[allow(clippy::single_element_loop)]
7045 for &(find_this, param_name) in [("{calendarId}", "calendarId")].iter() {
7046 url = params.uri_replacement(url, param_name, find_this, false);
7047 }
7048 {
7049 let to_remove = ["calendarId"];
7050 params.remove_params(&to_remove);
7051 }
7052
7053 let url = params.parse_with_url(&url);
7054
7055 let mut json_mime_type = mime::APPLICATION_JSON;
7056 let mut request_value_reader = {
7057 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
7058 common::remove_json_null_values(&mut value);
7059 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
7060 serde_json::to_writer(&mut dst, &value).unwrap();
7061 dst
7062 };
7063 let request_size = request_value_reader
7064 .seek(std::io::SeekFrom::End(0))
7065 .unwrap();
7066 request_value_reader
7067 .seek(std::io::SeekFrom::Start(0))
7068 .unwrap();
7069
7070 loop {
7071 let token = match self
7072 .hub
7073 .auth
7074 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
7075 .await
7076 {
7077 Ok(token) => token,
7078 Err(e) => match dlg.token(e) {
7079 Ok(token) => token,
7080 Err(e) => {
7081 dlg.finished(false);
7082 return Err(common::Error::MissingToken(e));
7083 }
7084 },
7085 };
7086 request_value_reader
7087 .seek(std::io::SeekFrom::Start(0))
7088 .unwrap();
7089 let mut req_result = {
7090 let client = &self.hub.client;
7091 dlg.pre_request();
7092 let mut req_builder = hyper::Request::builder()
7093 .method(hyper::Method::PUT)
7094 .uri(url.as_str())
7095 .header(USER_AGENT, self.hub._user_agent.clone());
7096
7097 if let Some(token) = token.as_ref() {
7098 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
7099 }
7100
7101 let request = req_builder
7102 .header(CONTENT_TYPE, json_mime_type.to_string())
7103 .header(CONTENT_LENGTH, request_size as u64)
7104 .body(common::to_body(
7105 request_value_reader.get_ref().clone().into(),
7106 ));
7107
7108 client.request(request.unwrap()).await
7109 };
7110
7111 match req_result {
7112 Err(err) => {
7113 if let common::Retry::After(d) = dlg.http_error(&err) {
7114 sleep(d).await;
7115 continue;
7116 }
7117 dlg.finished(false);
7118 return Err(common::Error::HttpError(err));
7119 }
7120 Ok(res) => {
7121 let (mut parts, body) = res.into_parts();
7122 let mut body = common::Body::new(body);
7123 if !parts.status.is_success() {
7124 let bytes = common::to_bytes(body).await.unwrap_or_default();
7125 let error = serde_json::from_str(&common::to_string(&bytes));
7126 let response = common::to_response(parts, bytes.into());
7127
7128 if let common::Retry::After(d) =
7129 dlg.http_failure(&response, error.as_ref().ok())
7130 {
7131 sleep(d).await;
7132 continue;
7133 }
7134
7135 dlg.finished(false);
7136
7137 return Err(match error {
7138 Ok(value) => common::Error::BadRequest(value),
7139 _ => common::Error::Failure(response),
7140 });
7141 }
7142 let response = {
7143 let bytes = common::to_bytes(body).await.unwrap_or_default();
7144 let encoded = common::to_string(&bytes);
7145 match serde_json::from_str(&encoded) {
7146 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
7147 Err(error) => {
7148 dlg.response_json_decode_error(&encoded, &error);
7149 return Err(common::Error::JsonDecodeError(
7150 encoded.to_string(),
7151 error,
7152 ));
7153 }
7154 }
7155 };
7156
7157 dlg.finished(true);
7158 return Ok(response);
7159 }
7160 }
7161 }
7162 }
7163
7164 ///
7165 /// Sets the *request* property to the given value.
7166 ///
7167 /// Even though the property as already been set when instantiating this call,
7168 /// we provide this method for API completeness.
7169 pub fn request(mut self, new_value: CalendarListEntry) -> CalendarListUpdateCall<'a, C> {
7170 self._request = new_value;
7171 self
7172 }
7173 /// 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.
7174 ///
7175 /// Sets the *calendar id* path property to the given value.
7176 ///
7177 /// Even though the property as already been set when instantiating this call,
7178 /// we provide this method for API completeness.
7179 pub fn calendar_id(mut self, new_value: &str) -> CalendarListUpdateCall<'a, C> {
7180 self._calendar_id = new_value.to_string();
7181 self
7182 }
7183 /// 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.
7184 ///
7185 /// Sets the *color rgb format* query property to the given value.
7186 pub fn color_rgb_format(mut self, new_value: bool) -> CalendarListUpdateCall<'a, C> {
7187 self._color_rgb_format = Some(new_value);
7188 self
7189 }
7190 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
7191 /// while executing the actual API request.
7192 ///
7193 /// ````text
7194 /// It should be used to handle progress information, and to implement a certain level of resilience.
7195 /// ````
7196 ///
7197 /// Sets the *delegate* property to the given value.
7198 pub fn delegate(
7199 mut self,
7200 new_value: &'a mut dyn common::Delegate,
7201 ) -> CalendarListUpdateCall<'a, C> {
7202 self._delegate = Some(new_value);
7203 self
7204 }
7205
7206 /// Set any additional parameter of the query string used in the request.
7207 /// It should be used to set parameters which are not yet available through their own
7208 /// setters.
7209 ///
7210 /// Please note that this method must not be used to set any of the known parameters
7211 /// which have their own setter method. If done anyway, the request will fail.
7212 ///
7213 /// # Additional Parameters
7214 ///
7215 /// * *alt* (query-string) - Data format for the response.
7216 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
7217 /// * *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.
7218 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
7219 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
7220 /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
7221 /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
7222 pub fn param<T>(mut self, name: T, value: T) -> CalendarListUpdateCall<'a, C>
7223 where
7224 T: AsRef<str>,
7225 {
7226 self._additional_params
7227 .insert(name.as_ref().to_string(), value.as_ref().to_string());
7228 self
7229 }
7230
7231 /// Identifies the authorization scope for the method you are building.
7232 ///
7233 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
7234 /// [`Scope::Full`].
7235 ///
7236 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
7237 /// tokens for more than one scope.
7238 ///
7239 /// Usually there is more than one suitable scope to authorize an operation, some of which may
7240 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
7241 /// sufficient, a read-write scope will do as well.
7242 pub fn add_scope<St>(mut self, scope: St) -> CalendarListUpdateCall<'a, C>
7243 where
7244 St: AsRef<str>,
7245 {
7246 self._scopes.insert(String::from(scope.as_ref()));
7247 self
7248 }
7249 /// Identifies the authorization scope(s) for the method you are building.
7250 ///
7251 /// See [`Self::add_scope()`] for details.
7252 pub fn add_scopes<I, St>(mut self, scopes: I) -> CalendarListUpdateCall<'a, C>
7253 where
7254 I: IntoIterator<Item = St>,
7255 St: AsRef<str>,
7256 {
7257 self._scopes
7258 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
7259 self
7260 }
7261
7262 /// Removes all scopes, and no default scope will be used either.
7263 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
7264 /// for details).
7265 pub fn clear_scopes(mut self) -> CalendarListUpdateCall<'a, C> {
7266 self._scopes.clear();
7267 self
7268 }
7269}
7270
7271/// Watch for changes to CalendarList resources.
7272///
7273/// A builder for the *watch* method supported by a *calendarList* resource.
7274/// It is not used directly, but through a [`CalendarListMethods`] instance.
7275///
7276/// # Example
7277///
7278/// Instantiate a resource method builder
7279///
7280/// ```test_harness,no_run
7281/// # extern crate hyper;
7282/// # extern crate hyper_rustls;
7283/// # extern crate google_calendar3 as calendar3;
7284/// use calendar3::api::Channel;
7285/// # async fn dox() {
7286/// # use calendar3::{CalendarHub, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
7287///
7288/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
7289/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
7290/// # .with_native_roots()
7291/// # .unwrap()
7292/// # .https_only()
7293/// # .enable_http2()
7294/// # .build();
7295///
7296/// # let executor = hyper_util::rt::TokioExecutor::new();
7297/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
7298/// # secret,
7299/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
7300/// # yup_oauth2::client::CustomHyperClientBuilder::from(
7301/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
7302/// # ),
7303/// # ).build().await.unwrap();
7304///
7305/// # let client = hyper_util::client::legacy::Client::builder(
7306/// # hyper_util::rt::TokioExecutor::new()
7307/// # )
7308/// # .build(
7309/// # hyper_rustls::HttpsConnectorBuilder::new()
7310/// # .with_native_roots()
7311/// # .unwrap()
7312/// # .https_or_http()
7313/// # .enable_http2()
7314/// # .build()
7315/// # );
7316/// # let mut hub = CalendarHub::new(client, auth);
7317/// // As the method needs a request, you would usually fill it with the desired information
7318/// // into the respective structure. Some of the parts shown here might not be applicable !
7319/// // Values shown here are possibly random and not representative !
7320/// let mut req = Channel::default();
7321///
7322/// // You can configure optional parameters by calling the respective setters at will, and
7323/// // execute the final call using `doit()`.
7324/// // Values shown here are possibly random and not representative !
7325/// let result = hub.calendar_list().watch(req)
7326/// .sync_token("sit")
7327/// .show_hidden(true)
7328/// .show_deleted(true)
7329/// .page_token("est")
7330/// .min_access_role("sed")
7331/// .max_results(-29)
7332/// .doit().await;
7333/// # }
7334/// ```
7335pub struct CalendarListWatchCall<'a, C>
7336where
7337 C: 'a,
7338{
7339 hub: &'a CalendarHub<C>,
7340 _request: Channel,
7341 _sync_token: Option<String>,
7342 _show_hidden: Option<bool>,
7343 _show_deleted: Option<bool>,
7344 _page_token: Option<String>,
7345 _min_access_role: Option<String>,
7346 _max_results: Option<i32>,
7347 _delegate: Option<&'a mut dyn common::Delegate>,
7348 _additional_params: HashMap<String, String>,
7349 _scopes: BTreeSet<String>,
7350}
7351
7352impl<'a, C> common::CallBuilder for CalendarListWatchCall<'a, C> {}
7353
7354impl<'a, C> CalendarListWatchCall<'a, C>
7355where
7356 C: common::Connector,
7357{
7358 /// Perform the operation you have build so far.
7359 pub async fn doit(mut self) -> common::Result<(common::Response, Channel)> {
7360 use std::borrow::Cow;
7361 use std::io::{Read, Seek};
7362
7363 use common::{url::Params, ToParts};
7364 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
7365
7366 let mut dd = common::DefaultDelegate;
7367 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
7368 dlg.begin(common::MethodInfo {
7369 id: "calendar.calendarList.watch",
7370 http_method: hyper::Method::POST,
7371 });
7372
7373 for &field in [
7374 "alt",
7375 "syncToken",
7376 "showHidden",
7377 "showDeleted",
7378 "pageToken",
7379 "minAccessRole",
7380 "maxResults",
7381 ]
7382 .iter()
7383 {
7384 if self._additional_params.contains_key(field) {
7385 dlg.finished(false);
7386 return Err(common::Error::FieldClash(field));
7387 }
7388 }
7389
7390 let mut params = Params::with_capacity(9 + self._additional_params.len());
7391 if let Some(value) = self._sync_token.as_ref() {
7392 params.push("syncToken", value);
7393 }
7394 if let Some(value) = self._show_hidden.as_ref() {
7395 params.push("showHidden", value.to_string());
7396 }
7397 if let Some(value) = self._show_deleted.as_ref() {
7398 params.push("showDeleted", value.to_string());
7399 }
7400 if let Some(value) = self._page_token.as_ref() {
7401 params.push("pageToken", value);
7402 }
7403 if let Some(value) = self._min_access_role.as_ref() {
7404 params.push("minAccessRole", value);
7405 }
7406 if let Some(value) = self._max_results.as_ref() {
7407 params.push("maxResults", value.to_string());
7408 }
7409
7410 params.extend(self._additional_params.iter());
7411
7412 params.push("alt", "json");
7413 let mut url = self.hub._base_url.clone() + "users/me/calendarList/watch";
7414 if self._scopes.is_empty() {
7415 self._scopes
7416 .insert(Scope::CalendarlistReadonly.as_ref().to_string());
7417 }
7418
7419 let url = params.parse_with_url(&url);
7420
7421 let mut json_mime_type = mime::APPLICATION_JSON;
7422 let mut request_value_reader = {
7423 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
7424 common::remove_json_null_values(&mut value);
7425 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
7426 serde_json::to_writer(&mut dst, &value).unwrap();
7427 dst
7428 };
7429 let request_size = request_value_reader
7430 .seek(std::io::SeekFrom::End(0))
7431 .unwrap();
7432 request_value_reader
7433 .seek(std::io::SeekFrom::Start(0))
7434 .unwrap();
7435
7436 loop {
7437 let token = match self
7438 .hub
7439 .auth
7440 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
7441 .await
7442 {
7443 Ok(token) => token,
7444 Err(e) => match dlg.token(e) {
7445 Ok(token) => token,
7446 Err(e) => {
7447 dlg.finished(false);
7448 return Err(common::Error::MissingToken(e));
7449 }
7450 },
7451 };
7452 request_value_reader
7453 .seek(std::io::SeekFrom::Start(0))
7454 .unwrap();
7455 let mut req_result = {
7456 let client = &self.hub.client;
7457 dlg.pre_request();
7458 let mut req_builder = hyper::Request::builder()
7459 .method(hyper::Method::POST)
7460 .uri(url.as_str())
7461 .header(USER_AGENT, self.hub._user_agent.clone());
7462
7463 if let Some(token) = token.as_ref() {
7464 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
7465 }
7466
7467 let request = req_builder
7468 .header(CONTENT_TYPE, json_mime_type.to_string())
7469 .header(CONTENT_LENGTH, request_size as u64)
7470 .body(common::to_body(
7471 request_value_reader.get_ref().clone().into(),
7472 ));
7473
7474 client.request(request.unwrap()).await
7475 };
7476
7477 match req_result {
7478 Err(err) => {
7479 if let common::Retry::After(d) = dlg.http_error(&err) {
7480 sleep(d).await;
7481 continue;
7482 }
7483 dlg.finished(false);
7484 return Err(common::Error::HttpError(err));
7485 }
7486 Ok(res) => {
7487 let (mut parts, body) = res.into_parts();
7488 let mut body = common::Body::new(body);
7489 if !parts.status.is_success() {
7490 let bytes = common::to_bytes(body).await.unwrap_or_default();
7491 let error = serde_json::from_str(&common::to_string(&bytes));
7492 let response = common::to_response(parts, bytes.into());
7493
7494 if let common::Retry::After(d) =
7495 dlg.http_failure(&response, error.as_ref().ok())
7496 {
7497 sleep(d).await;
7498 continue;
7499 }
7500
7501 dlg.finished(false);
7502
7503 return Err(match error {
7504 Ok(value) => common::Error::BadRequest(value),
7505 _ => common::Error::Failure(response),
7506 });
7507 }
7508 let response = {
7509 let bytes = common::to_bytes(body).await.unwrap_or_default();
7510 let encoded = common::to_string(&bytes);
7511 match serde_json::from_str(&encoded) {
7512 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
7513 Err(error) => {
7514 dlg.response_json_decode_error(&encoded, &error);
7515 return Err(common::Error::JsonDecodeError(
7516 encoded.to_string(),
7517 error,
7518 ));
7519 }
7520 }
7521 };
7522
7523 dlg.finished(true);
7524 return Ok(response);
7525 }
7526 }
7527 }
7528 }
7529
7530 ///
7531 /// Sets the *request* property to the given value.
7532 ///
7533 /// Even though the property as already been set when instantiating this call,
7534 /// we provide this method for API completeness.
7535 pub fn request(mut self, new_value: Channel) -> CalendarListWatchCall<'a, C> {
7536 self._request = new_value;
7537 self
7538 }
7539 /// 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.
7540 /// To ensure client state consistency minAccessRole query parameter cannot be specified together with nextSyncToken.
7541 /// 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.
7542 /// Learn more about incremental synchronization.
7543 /// Optional. The default is to return all entries.
7544 ///
7545 /// Sets the *sync token* query property to the given value.
7546 pub fn sync_token(mut self, new_value: &str) -> CalendarListWatchCall<'a, C> {
7547 self._sync_token = Some(new_value.to_string());
7548 self
7549 }
7550 /// Whether to show hidden entries. Optional. The default is False.
7551 ///
7552 /// Sets the *show hidden* query property to the given value.
7553 pub fn show_hidden(mut self, new_value: bool) -> CalendarListWatchCall<'a, C> {
7554 self._show_hidden = Some(new_value);
7555 self
7556 }
7557 /// Whether to include deleted calendar list entries in the result. Optional. The default is False.
7558 ///
7559 /// Sets the *show deleted* query property to the given value.
7560 pub fn show_deleted(mut self, new_value: bool) -> CalendarListWatchCall<'a, C> {
7561 self._show_deleted = Some(new_value);
7562 self
7563 }
7564 /// Token specifying which result page to return. Optional.
7565 ///
7566 /// Sets the *page token* query property to the given value.
7567 pub fn page_token(mut self, new_value: &str) -> CalendarListWatchCall<'a, C> {
7568 self._page_token = Some(new_value.to_string());
7569 self
7570 }
7571 /// The minimum access role for the user in the returned entries. Optional. The default is no restriction.
7572 ///
7573 /// Sets the *min access role* query property to the given value.
7574 pub fn min_access_role(mut self, new_value: &str) -> CalendarListWatchCall<'a, C> {
7575 self._min_access_role = Some(new_value.to_string());
7576 self
7577 }
7578 /// 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.
7579 ///
7580 /// Sets the *max results* query property to the given value.
7581 pub fn max_results(mut self, new_value: i32) -> CalendarListWatchCall<'a, C> {
7582 self._max_results = Some(new_value);
7583 self
7584 }
7585 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
7586 /// while executing the actual API request.
7587 ///
7588 /// ````text
7589 /// It should be used to handle progress information, and to implement a certain level of resilience.
7590 /// ````
7591 ///
7592 /// Sets the *delegate* property to the given value.
7593 pub fn delegate(
7594 mut self,
7595 new_value: &'a mut dyn common::Delegate,
7596 ) -> CalendarListWatchCall<'a, C> {
7597 self._delegate = Some(new_value);
7598 self
7599 }
7600
7601 /// Set any additional parameter of the query string used in the request.
7602 /// It should be used to set parameters which are not yet available through their own
7603 /// setters.
7604 ///
7605 /// Please note that this method must not be used to set any of the known parameters
7606 /// which have their own setter method. If done anyway, the request will fail.
7607 ///
7608 /// # Additional Parameters
7609 ///
7610 /// * *alt* (query-string) - Data format for the response.
7611 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
7612 /// * *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.
7613 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
7614 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
7615 /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
7616 /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
7617 pub fn param<T>(mut self, name: T, value: T) -> CalendarListWatchCall<'a, C>
7618 where
7619 T: AsRef<str>,
7620 {
7621 self._additional_params
7622 .insert(name.as_ref().to_string(), value.as_ref().to_string());
7623 self
7624 }
7625
7626 /// Identifies the authorization scope for the method you are building.
7627 ///
7628 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
7629 /// [`Scope::CalendarlistReadonly`].
7630 ///
7631 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
7632 /// tokens for more than one scope.
7633 ///
7634 /// Usually there is more than one suitable scope to authorize an operation, some of which may
7635 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
7636 /// sufficient, a read-write scope will do as well.
7637 pub fn add_scope<St>(mut self, scope: St) -> CalendarListWatchCall<'a, C>
7638 where
7639 St: AsRef<str>,
7640 {
7641 self._scopes.insert(String::from(scope.as_ref()));
7642 self
7643 }
7644 /// Identifies the authorization scope(s) for the method you are building.
7645 ///
7646 /// See [`Self::add_scope()`] for details.
7647 pub fn add_scopes<I, St>(mut self, scopes: I) -> CalendarListWatchCall<'a, C>
7648 where
7649 I: IntoIterator<Item = St>,
7650 St: AsRef<str>,
7651 {
7652 self._scopes
7653 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
7654 self
7655 }
7656
7657 /// Removes all scopes, and no default scope will be used either.
7658 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
7659 /// for details).
7660 pub fn clear_scopes(mut self) -> CalendarListWatchCall<'a, C> {
7661 self._scopes.clear();
7662 self
7663 }
7664}
7665
7666/// Clears a primary calendar. This operation deletes all events associated with the primary calendar of an account.
7667///
7668/// A builder for the *clear* method supported by a *calendar* resource.
7669/// It is not used directly, but through a [`CalendarMethods`] instance.
7670///
7671/// # Example
7672///
7673/// Instantiate a resource method builder
7674///
7675/// ```test_harness,no_run
7676/// # extern crate hyper;
7677/// # extern crate hyper_rustls;
7678/// # extern crate google_calendar3 as calendar3;
7679/// # async fn dox() {
7680/// # use calendar3::{CalendarHub, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
7681///
7682/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
7683/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
7684/// # .with_native_roots()
7685/// # .unwrap()
7686/// # .https_only()
7687/// # .enable_http2()
7688/// # .build();
7689///
7690/// # let executor = hyper_util::rt::TokioExecutor::new();
7691/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
7692/// # secret,
7693/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
7694/// # yup_oauth2::client::CustomHyperClientBuilder::from(
7695/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
7696/// # ),
7697/// # ).build().await.unwrap();
7698///
7699/// # let client = hyper_util::client::legacy::Client::builder(
7700/// # hyper_util::rt::TokioExecutor::new()
7701/// # )
7702/// # .build(
7703/// # hyper_rustls::HttpsConnectorBuilder::new()
7704/// # .with_native_roots()
7705/// # .unwrap()
7706/// # .https_or_http()
7707/// # .enable_http2()
7708/// # .build()
7709/// # );
7710/// # let mut hub = CalendarHub::new(client, auth);
7711/// // You can configure optional parameters by calling the respective setters at will, and
7712/// // execute the final call using `doit()`.
7713/// // Values shown here are possibly random and not representative !
7714/// let result = hub.calendars().clear("calendarId")
7715/// .doit().await;
7716/// # }
7717/// ```
7718pub struct CalendarClearCall<'a, C>
7719where
7720 C: 'a,
7721{
7722 hub: &'a CalendarHub<C>,
7723 _calendar_id: String,
7724 _delegate: Option<&'a mut dyn common::Delegate>,
7725 _additional_params: HashMap<String, String>,
7726 _scopes: BTreeSet<String>,
7727}
7728
7729impl<'a, C> common::CallBuilder for CalendarClearCall<'a, C> {}
7730
7731impl<'a, C> CalendarClearCall<'a, C>
7732where
7733 C: common::Connector,
7734{
7735 /// Perform the operation you have build so far.
7736 pub async fn doit(mut self) -> common::Result<common::Response> {
7737 use std::borrow::Cow;
7738 use std::io::{Read, Seek};
7739
7740 use common::{url::Params, ToParts};
7741 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
7742
7743 let mut dd = common::DefaultDelegate;
7744 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
7745 dlg.begin(common::MethodInfo {
7746 id: "calendar.calendars.clear",
7747 http_method: hyper::Method::POST,
7748 });
7749
7750 for &field in ["calendarId"].iter() {
7751 if self._additional_params.contains_key(field) {
7752 dlg.finished(false);
7753 return Err(common::Error::FieldClash(field));
7754 }
7755 }
7756
7757 let mut params = Params::with_capacity(2 + self._additional_params.len());
7758 params.push("calendarId", self._calendar_id);
7759
7760 params.extend(self._additional_params.iter());
7761
7762 let mut url = self.hub._base_url.clone() + "calendars/{calendarId}/clear";
7763 if self._scopes.is_empty() {
7764 self._scopes.insert(Scope::Full.as_ref().to_string());
7765 }
7766
7767 #[allow(clippy::single_element_loop)]
7768 for &(find_this, param_name) in [("{calendarId}", "calendarId")].iter() {
7769 url = params.uri_replacement(url, param_name, find_this, false);
7770 }
7771 {
7772 let to_remove = ["calendarId"];
7773 params.remove_params(&to_remove);
7774 }
7775
7776 let url = params.parse_with_url(&url);
7777
7778 loop {
7779 let token = match self
7780 .hub
7781 .auth
7782 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
7783 .await
7784 {
7785 Ok(token) => token,
7786 Err(e) => match dlg.token(e) {
7787 Ok(token) => token,
7788 Err(e) => {
7789 dlg.finished(false);
7790 return Err(common::Error::MissingToken(e));
7791 }
7792 },
7793 };
7794 let mut req_result = {
7795 let client = &self.hub.client;
7796 dlg.pre_request();
7797 let mut req_builder = hyper::Request::builder()
7798 .method(hyper::Method::POST)
7799 .uri(url.as_str())
7800 .header(USER_AGENT, self.hub._user_agent.clone());
7801
7802 if let Some(token) = token.as_ref() {
7803 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
7804 }
7805
7806 let request = req_builder
7807 .header(CONTENT_LENGTH, 0_u64)
7808 .body(common::to_body::<String>(None));
7809
7810 client.request(request.unwrap()).await
7811 };
7812
7813 match req_result {
7814 Err(err) => {
7815 if let common::Retry::After(d) = dlg.http_error(&err) {
7816 sleep(d).await;
7817 continue;
7818 }
7819 dlg.finished(false);
7820 return Err(common::Error::HttpError(err));
7821 }
7822 Ok(res) => {
7823 let (mut parts, body) = res.into_parts();
7824 let mut body = common::Body::new(body);
7825 if !parts.status.is_success() {
7826 let bytes = common::to_bytes(body).await.unwrap_or_default();
7827 let error = serde_json::from_str(&common::to_string(&bytes));
7828 let response = common::to_response(parts, bytes.into());
7829
7830 if let common::Retry::After(d) =
7831 dlg.http_failure(&response, error.as_ref().ok())
7832 {
7833 sleep(d).await;
7834 continue;
7835 }
7836
7837 dlg.finished(false);
7838
7839 return Err(match error {
7840 Ok(value) => common::Error::BadRequest(value),
7841 _ => common::Error::Failure(response),
7842 });
7843 }
7844 let response = common::Response::from_parts(parts, body);
7845
7846 dlg.finished(true);
7847 return Ok(response);
7848 }
7849 }
7850 }
7851 }
7852
7853 /// 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.
7854 ///
7855 /// Sets the *calendar id* path property to the given value.
7856 ///
7857 /// Even though the property as already been set when instantiating this call,
7858 /// we provide this method for API completeness.
7859 pub fn calendar_id(mut self, new_value: &str) -> CalendarClearCall<'a, C> {
7860 self._calendar_id = new_value.to_string();
7861 self
7862 }
7863 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
7864 /// while executing the actual API request.
7865 ///
7866 /// ````text
7867 /// It should be used to handle progress information, and to implement a certain level of resilience.
7868 /// ````
7869 ///
7870 /// Sets the *delegate* property to the given value.
7871 pub fn delegate(mut self, new_value: &'a mut dyn common::Delegate) -> CalendarClearCall<'a, C> {
7872 self._delegate = Some(new_value);
7873 self
7874 }
7875
7876 /// Set any additional parameter of the query string used in the request.
7877 /// It should be used to set parameters which are not yet available through their own
7878 /// setters.
7879 ///
7880 /// Please note that this method must not be used to set any of the known parameters
7881 /// which have their own setter method. If done anyway, the request will fail.
7882 ///
7883 /// # Additional Parameters
7884 ///
7885 /// * *alt* (query-string) - Data format for the response.
7886 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
7887 /// * *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.
7888 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
7889 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
7890 /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
7891 /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
7892 pub fn param<T>(mut self, name: T, value: T) -> CalendarClearCall<'a, C>
7893 where
7894 T: AsRef<str>,
7895 {
7896 self._additional_params
7897 .insert(name.as_ref().to_string(), value.as_ref().to_string());
7898 self
7899 }
7900
7901 /// Identifies the authorization scope for the method you are building.
7902 ///
7903 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
7904 /// [`Scope::Full`].
7905 ///
7906 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
7907 /// tokens for more than one scope.
7908 ///
7909 /// Usually there is more than one suitable scope to authorize an operation, some of which may
7910 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
7911 /// sufficient, a read-write scope will do as well.
7912 pub fn add_scope<St>(mut self, scope: St) -> CalendarClearCall<'a, C>
7913 where
7914 St: AsRef<str>,
7915 {
7916 self._scopes.insert(String::from(scope.as_ref()));
7917 self
7918 }
7919 /// Identifies the authorization scope(s) for the method you are building.
7920 ///
7921 /// See [`Self::add_scope()`] for details.
7922 pub fn add_scopes<I, St>(mut self, scopes: I) -> CalendarClearCall<'a, C>
7923 where
7924 I: IntoIterator<Item = St>,
7925 St: AsRef<str>,
7926 {
7927 self._scopes
7928 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
7929 self
7930 }
7931
7932 /// Removes all scopes, and no default scope will be used either.
7933 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
7934 /// for details).
7935 pub fn clear_scopes(mut self) -> CalendarClearCall<'a, C> {
7936 self._scopes.clear();
7937 self
7938 }
7939}
7940
7941/// Deletes a secondary calendar. Use calendars.clear for clearing all events on primary calendars.
7942///
7943/// A builder for the *delete* method supported by a *calendar* resource.
7944/// It is not used directly, but through a [`CalendarMethods`] instance.
7945///
7946/// # Example
7947///
7948/// Instantiate a resource method builder
7949///
7950/// ```test_harness,no_run
7951/// # extern crate hyper;
7952/// # extern crate hyper_rustls;
7953/// # extern crate google_calendar3 as calendar3;
7954/// # async fn dox() {
7955/// # use calendar3::{CalendarHub, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
7956///
7957/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
7958/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
7959/// # .with_native_roots()
7960/// # .unwrap()
7961/// # .https_only()
7962/// # .enable_http2()
7963/// # .build();
7964///
7965/// # let executor = hyper_util::rt::TokioExecutor::new();
7966/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
7967/// # secret,
7968/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
7969/// # yup_oauth2::client::CustomHyperClientBuilder::from(
7970/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
7971/// # ),
7972/// # ).build().await.unwrap();
7973///
7974/// # let client = hyper_util::client::legacy::Client::builder(
7975/// # hyper_util::rt::TokioExecutor::new()
7976/// # )
7977/// # .build(
7978/// # hyper_rustls::HttpsConnectorBuilder::new()
7979/// # .with_native_roots()
7980/// # .unwrap()
7981/// # .https_or_http()
7982/// # .enable_http2()
7983/// # .build()
7984/// # );
7985/// # let mut hub = CalendarHub::new(client, auth);
7986/// // You can configure optional parameters by calling the respective setters at will, and
7987/// // execute the final call using `doit()`.
7988/// // Values shown here are possibly random and not representative !
7989/// let result = hub.calendars().delete("calendarId")
7990/// .doit().await;
7991/// # }
7992/// ```
7993pub struct CalendarDeleteCall<'a, C>
7994where
7995 C: 'a,
7996{
7997 hub: &'a CalendarHub<C>,
7998 _calendar_id: String,
7999 _delegate: Option<&'a mut dyn common::Delegate>,
8000 _additional_params: HashMap<String, String>,
8001 _scopes: BTreeSet<String>,
8002}
8003
8004impl<'a, C> common::CallBuilder for CalendarDeleteCall<'a, C> {}
8005
8006impl<'a, C> CalendarDeleteCall<'a, C>
8007where
8008 C: common::Connector,
8009{
8010 /// Perform the operation you have build so far.
8011 pub async fn doit(mut self) -> common::Result<common::Response> {
8012 use std::borrow::Cow;
8013 use std::io::{Read, Seek};
8014
8015 use common::{url::Params, ToParts};
8016 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
8017
8018 let mut dd = common::DefaultDelegate;
8019 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
8020 dlg.begin(common::MethodInfo {
8021 id: "calendar.calendars.delete",
8022 http_method: hyper::Method::DELETE,
8023 });
8024
8025 for &field in ["calendarId"].iter() {
8026 if self._additional_params.contains_key(field) {
8027 dlg.finished(false);
8028 return Err(common::Error::FieldClash(field));
8029 }
8030 }
8031
8032 let mut params = Params::with_capacity(2 + self._additional_params.len());
8033 params.push("calendarId", self._calendar_id);
8034
8035 params.extend(self._additional_params.iter());
8036
8037 let mut url = self.hub._base_url.clone() + "calendars/{calendarId}";
8038 if self._scopes.is_empty() {
8039 self._scopes.insert(Scope::Full.as_ref().to_string());
8040 }
8041
8042 #[allow(clippy::single_element_loop)]
8043 for &(find_this, param_name) in [("{calendarId}", "calendarId")].iter() {
8044 url = params.uri_replacement(url, param_name, find_this, false);
8045 }
8046 {
8047 let to_remove = ["calendarId"];
8048 params.remove_params(&to_remove);
8049 }
8050
8051 let url = params.parse_with_url(&url);
8052
8053 loop {
8054 let token = match self
8055 .hub
8056 .auth
8057 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
8058 .await
8059 {
8060 Ok(token) => token,
8061 Err(e) => match dlg.token(e) {
8062 Ok(token) => token,
8063 Err(e) => {
8064 dlg.finished(false);
8065 return Err(common::Error::MissingToken(e));
8066 }
8067 },
8068 };
8069 let mut req_result = {
8070 let client = &self.hub.client;
8071 dlg.pre_request();
8072 let mut req_builder = hyper::Request::builder()
8073 .method(hyper::Method::DELETE)
8074 .uri(url.as_str())
8075 .header(USER_AGENT, self.hub._user_agent.clone());
8076
8077 if let Some(token) = token.as_ref() {
8078 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
8079 }
8080
8081 let request = req_builder
8082 .header(CONTENT_LENGTH, 0_u64)
8083 .body(common::to_body::<String>(None));
8084
8085 client.request(request.unwrap()).await
8086 };
8087
8088 match req_result {
8089 Err(err) => {
8090 if let common::Retry::After(d) = dlg.http_error(&err) {
8091 sleep(d).await;
8092 continue;
8093 }
8094 dlg.finished(false);
8095 return Err(common::Error::HttpError(err));
8096 }
8097 Ok(res) => {
8098 let (mut parts, body) = res.into_parts();
8099 let mut body = common::Body::new(body);
8100 if !parts.status.is_success() {
8101 let bytes = common::to_bytes(body).await.unwrap_or_default();
8102 let error = serde_json::from_str(&common::to_string(&bytes));
8103 let response = common::to_response(parts, bytes.into());
8104
8105 if let common::Retry::After(d) =
8106 dlg.http_failure(&response, error.as_ref().ok())
8107 {
8108 sleep(d).await;
8109 continue;
8110 }
8111
8112 dlg.finished(false);
8113
8114 return Err(match error {
8115 Ok(value) => common::Error::BadRequest(value),
8116 _ => common::Error::Failure(response),
8117 });
8118 }
8119 let response = common::Response::from_parts(parts, body);
8120
8121 dlg.finished(true);
8122 return Ok(response);
8123 }
8124 }
8125 }
8126 }
8127
8128 /// 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.
8129 ///
8130 /// Sets the *calendar id* path property to the given value.
8131 ///
8132 /// Even though the property as already been set when instantiating this call,
8133 /// we provide this method for API completeness.
8134 pub fn calendar_id(mut self, new_value: &str) -> CalendarDeleteCall<'a, C> {
8135 self._calendar_id = new_value.to_string();
8136 self
8137 }
8138 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
8139 /// while executing the actual API request.
8140 ///
8141 /// ````text
8142 /// It should be used to handle progress information, and to implement a certain level of resilience.
8143 /// ````
8144 ///
8145 /// Sets the *delegate* property to the given value.
8146 pub fn delegate(
8147 mut self,
8148 new_value: &'a mut dyn common::Delegate,
8149 ) -> CalendarDeleteCall<'a, C> {
8150 self._delegate = Some(new_value);
8151 self
8152 }
8153
8154 /// Set any additional parameter of the query string used in the request.
8155 /// It should be used to set parameters which are not yet available through their own
8156 /// setters.
8157 ///
8158 /// Please note that this method must not be used to set any of the known parameters
8159 /// which have their own setter method. If done anyway, the request will fail.
8160 ///
8161 /// # Additional Parameters
8162 ///
8163 /// * *alt* (query-string) - Data format for the response.
8164 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
8165 /// * *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.
8166 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
8167 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
8168 /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
8169 /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
8170 pub fn param<T>(mut self, name: T, value: T) -> CalendarDeleteCall<'a, C>
8171 where
8172 T: AsRef<str>,
8173 {
8174 self._additional_params
8175 .insert(name.as_ref().to_string(), value.as_ref().to_string());
8176 self
8177 }
8178
8179 /// Identifies the authorization scope for the method you are building.
8180 ///
8181 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
8182 /// [`Scope::Full`].
8183 ///
8184 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
8185 /// tokens for more than one scope.
8186 ///
8187 /// Usually there is more than one suitable scope to authorize an operation, some of which may
8188 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
8189 /// sufficient, a read-write scope will do as well.
8190 pub fn add_scope<St>(mut self, scope: St) -> CalendarDeleteCall<'a, C>
8191 where
8192 St: AsRef<str>,
8193 {
8194 self._scopes.insert(String::from(scope.as_ref()));
8195 self
8196 }
8197 /// Identifies the authorization scope(s) for the method you are building.
8198 ///
8199 /// See [`Self::add_scope()`] for details.
8200 pub fn add_scopes<I, St>(mut self, scopes: I) -> CalendarDeleteCall<'a, C>
8201 where
8202 I: IntoIterator<Item = St>,
8203 St: AsRef<str>,
8204 {
8205 self._scopes
8206 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
8207 self
8208 }
8209
8210 /// Removes all scopes, and no default scope will be used either.
8211 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
8212 /// for details).
8213 pub fn clear_scopes(mut self) -> CalendarDeleteCall<'a, C> {
8214 self._scopes.clear();
8215 self
8216 }
8217}
8218
8219/// Returns metadata for a calendar.
8220///
8221/// A builder for the *get* method supported by a *calendar* resource.
8222/// It is not used directly, but through a [`CalendarMethods`] instance.
8223///
8224/// # Example
8225///
8226/// Instantiate a resource method builder
8227///
8228/// ```test_harness,no_run
8229/// # extern crate hyper;
8230/// # extern crate hyper_rustls;
8231/// # extern crate google_calendar3 as calendar3;
8232/// # async fn dox() {
8233/// # use calendar3::{CalendarHub, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
8234///
8235/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
8236/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
8237/// # .with_native_roots()
8238/// # .unwrap()
8239/// # .https_only()
8240/// # .enable_http2()
8241/// # .build();
8242///
8243/// # let executor = hyper_util::rt::TokioExecutor::new();
8244/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
8245/// # secret,
8246/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
8247/// # yup_oauth2::client::CustomHyperClientBuilder::from(
8248/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
8249/// # ),
8250/// # ).build().await.unwrap();
8251///
8252/// # let client = hyper_util::client::legacy::Client::builder(
8253/// # hyper_util::rt::TokioExecutor::new()
8254/// # )
8255/// # .build(
8256/// # hyper_rustls::HttpsConnectorBuilder::new()
8257/// # .with_native_roots()
8258/// # .unwrap()
8259/// # .https_or_http()
8260/// # .enable_http2()
8261/// # .build()
8262/// # );
8263/// # let mut hub = CalendarHub::new(client, auth);
8264/// // You can configure optional parameters by calling the respective setters at will, and
8265/// // execute the final call using `doit()`.
8266/// // Values shown here are possibly random and not representative !
8267/// let result = hub.calendars().get("calendarId")
8268/// .doit().await;
8269/// # }
8270/// ```
8271pub struct CalendarGetCall<'a, C>
8272where
8273 C: 'a,
8274{
8275 hub: &'a CalendarHub<C>,
8276 _calendar_id: String,
8277 _delegate: Option<&'a mut dyn common::Delegate>,
8278 _additional_params: HashMap<String, String>,
8279 _scopes: BTreeSet<String>,
8280}
8281
8282impl<'a, C> common::CallBuilder for CalendarGetCall<'a, C> {}
8283
8284impl<'a, C> CalendarGetCall<'a, C>
8285where
8286 C: common::Connector,
8287{
8288 /// Perform the operation you have build so far.
8289 pub async fn doit(mut self) -> common::Result<(common::Response, Calendar)> {
8290 use std::borrow::Cow;
8291 use std::io::{Read, Seek};
8292
8293 use common::{url::Params, ToParts};
8294 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
8295
8296 let mut dd = common::DefaultDelegate;
8297 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
8298 dlg.begin(common::MethodInfo {
8299 id: "calendar.calendars.get",
8300 http_method: hyper::Method::GET,
8301 });
8302
8303 for &field in ["alt", "calendarId"].iter() {
8304 if self._additional_params.contains_key(field) {
8305 dlg.finished(false);
8306 return Err(common::Error::FieldClash(field));
8307 }
8308 }
8309
8310 let mut params = Params::with_capacity(3 + self._additional_params.len());
8311 params.push("calendarId", self._calendar_id);
8312
8313 params.extend(self._additional_params.iter());
8314
8315 params.push("alt", "json");
8316 let mut url = self.hub._base_url.clone() + "calendars/{calendarId}";
8317 if self._scopes.is_empty() {
8318 self._scopes
8319 .insert(Scope::CalendarReadonly.as_ref().to_string());
8320 }
8321
8322 #[allow(clippy::single_element_loop)]
8323 for &(find_this, param_name) in [("{calendarId}", "calendarId")].iter() {
8324 url = params.uri_replacement(url, param_name, find_this, false);
8325 }
8326 {
8327 let to_remove = ["calendarId"];
8328 params.remove_params(&to_remove);
8329 }
8330
8331 let url = params.parse_with_url(&url);
8332
8333 loop {
8334 let token = match self
8335 .hub
8336 .auth
8337 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
8338 .await
8339 {
8340 Ok(token) => token,
8341 Err(e) => match dlg.token(e) {
8342 Ok(token) => token,
8343 Err(e) => {
8344 dlg.finished(false);
8345 return Err(common::Error::MissingToken(e));
8346 }
8347 },
8348 };
8349 let mut req_result = {
8350 let client = &self.hub.client;
8351 dlg.pre_request();
8352 let mut req_builder = hyper::Request::builder()
8353 .method(hyper::Method::GET)
8354 .uri(url.as_str())
8355 .header(USER_AGENT, self.hub._user_agent.clone());
8356
8357 if let Some(token) = token.as_ref() {
8358 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
8359 }
8360
8361 let request = req_builder
8362 .header(CONTENT_LENGTH, 0_u64)
8363 .body(common::to_body::<String>(None));
8364
8365 client.request(request.unwrap()).await
8366 };
8367
8368 match req_result {
8369 Err(err) => {
8370 if let common::Retry::After(d) = dlg.http_error(&err) {
8371 sleep(d).await;
8372 continue;
8373 }
8374 dlg.finished(false);
8375 return Err(common::Error::HttpError(err));
8376 }
8377 Ok(res) => {
8378 let (mut parts, body) = res.into_parts();
8379 let mut body = common::Body::new(body);
8380 if !parts.status.is_success() {
8381 let bytes = common::to_bytes(body).await.unwrap_or_default();
8382 let error = serde_json::from_str(&common::to_string(&bytes));
8383 let response = common::to_response(parts, bytes.into());
8384
8385 if let common::Retry::After(d) =
8386 dlg.http_failure(&response, error.as_ref().ok())
8387 {
8388 sleep(d).await;
8389 continue;
8390 }
8391
8392 dlg.finished(false);
8393
8394 return Err(match error {
8395 Ok(value) => common::Error::BadRequest(value),
8396 _ => common::Error::Failure(response),
8397 });
8398 }
8399 let response = {
8400 let bytes = common::to_bytes(body).await.unwrap_or_default();
8401 let encoded = common::to_string(&bytes);
8402 match serde_json::from_str(&encoded) {
8403 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
8404 Err(error) => {
8405 dlg.response_json_decode_error(&encoded, &error);
8406 return Err(common::Error::JsonDecodeError(
8407 encoded.to_string(),
8408 error,
8409 ));
8410 }
8411 }
8412 };
8413
8414 dlg.finished(true);
8415 return Ok(response);
8416 }
8417 }
8418 }
8419 }
8420
8421 /// 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.
8422 ///
8423 /// Sets the *calendar id* path property to the given value.
8424 ///
8425 /// Even though the property as already been set when instantiating this call,
8426 /// we provide this method for API completeness.
8427 pub fn calendar_id(mut self, new_value: &str) -> CalendarGetCall<'a, C> {
8428 self._calendar_id = new_value.to_string();
8429 self
8430 }
8431 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
8432 /// while executing the actual API request.
8433 ///
8434 /// ````text
8435 /// It should be used to handle progress information, and to implement a certain level of resilience.
8436 /// ````
8437 ///
8438 /// Sets the *delegate* property to the given value.
8439 pub fn delegate(mut self, new_value: &'a mut dyn common::Delegate) -> CalendarGetCall<'a, C> {
8440 self._delegate = Some(new_value);
8441 self
8442 }
8443
8444 /// Set any additional parameter of the query string used in the request.
8445 /// It should be used to set parameters which are not yet available through their own
8446 /// setters.
8447 ///
8448 /// Please note that this method must not be used to set any of the known parameters
8449 /// which have their own setter method. If done anyway, the request will fail.
8450 ///
8451 /// # Additional Parameters
8452 ///
8453 /// * *alt* (query-string) - Data format for the response.
8454 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
8455 /// * *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.
8456 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
8457 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
8458 /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
8459 /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
8460 pub fn param<T>(mut self, name: T, value: T) -> CalendarGetCall<'a, C>
8461 where
8462 T: AsRef<str>,
8463 {
8464 self._additional_params
8465 .insert(name.as_ref().to_string(), value.as_ref().to_string());
8466 self
8467 }
8468
8469 /// Identifies the authorization scope for the method you are building.
8470 ///
8471 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
8472 /// [`Scope::CalendarReadonly`].
8473 ///
8474 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
8475 /// tokens for more than one scope.
8476 ///
8477 /// Usually there is more than one suitable scope to authorize an operation, some of which may
8478 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
8479 /// sufficient, a read-write scope will do as well.
8480 pub fn add_scope<St>(mut self, scope: St) -> CalendarGetCall<'a, C>
8481 where
8482 St: AsRef<str>,
8483 {
8484 self._scopes.insert(String::from(scope.as_ref()));
8485 self
8486 }
8487 /// Identifies the authorization scope(s) for the method you are building.
8488 ///
8489 /// See [`Self::add_scope()`] for details.
8490 pub fn add_scopes<I, St>(mut self, scopes: I) -> CalendarGetCall<'a, C>
8491 where
8492 I: IntoIterator<Item = St>,
8493 St: AsRef<str>,
8494 {
8495 self._scopes
8496 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
8497 self
8498 }
8499
8500 /// Removes all scopes, and no default scope will be used either.
8501 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
8502 /// for details).
8503 pub fn clear_scopes(mut self) -> CalendarGetCall<'a, C> {
8504 self._scopes.clear();
8505 self
8506 }
8507}
8508
8509/// Creates a secondary calendar.
8510/// The authenticated user for the request is made the data owner of the new calendar.
8511///
8512/// Note: We recommend to authenticate as the intended data owner of the calendar. You can use domain-wide delegation of authority to allow applications to act on behalf of a specific user. Don't use a service account for authentication. If you use a service account for authentication, the service account is the data owner, which can lead to unexpected behavior. For example, if a service account is the data owner, data ownership cannot be transferred.
8513///
8514/// A builder for the *insert* method supported by a *calendar* resource.
8515/// It is not used directly, but through a [`CalendarMethods`] instance.
8516///
8517/// # Example
8518///
8519/// Instantiate a resource method builder
8520///
8521/// ```test_harness,no_run
8522/// # extern crate hyper;
8523/// # extern crate hyper_rustls;
8524/// # extern crate google_calendar3 as calendar3;
8525/// use calendar3::api::Calendar;
8526/// # async fn dox() {
8527/// # use calendar3::{CalendarHub, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
8528///
8529/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
8530/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
8531/// # .with_native_roots()
8532/// # .unwrap()
8533/// # .https_only()
8534/// # .enable_http2()
8535/// # .build();
8536///
8537/// # let executor = hyper_util::rt::TokioExecutor::new();
8538/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
8539/// # secret,
8540/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
8541/// # yup_oauth2::client::CustomHyperClientBuilder::from(
8542/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
8543/// # ),
8544/// # ).build().await.unwrap();
8545///
8546/// # let client = hyper_util::client::legacy::Client::builder(
8547/// # hyper_util::rt::TokioExecutor::new()
8548/// # )
8549/// # .build(
8550/// # hyper_rustls::HttpsConnectorBuilder::new()
8551/// # .with_native_roots()
8552/// # .unwrap()
8553/// # .https_or_http()
8554/// # .enable_http2()
8555/// # .build()
8556/// # );
8557/// # let mut hub = CalendarHub::new(client, auth);
8558/// // As the method needs a request, you would usually fill it with the desired information
8559/// // into the respective structure. Some of the parts shown here might not be applicable !
8560/// // Values shown here are possibly random and not representative !
8561/// let mut req = Calendar::default();
8562///
8563/// // You can configure optional parameters by calling the respective setters at will, and
8564/// // execute the final call using `doit()`.
8565/// // Values shown here are possibly random and not representative !
8566/// let result = hub.calendars().insert(req)
8567/// .doit().await;
8568/// # }
8569/// ```
8570pub struct CalendarInsertCall<'a, C>
8571where
8572 C: 'a,
8573{
8574 hub: &'a CalendarHub<C>,
8575 _request: Calendar,
8576 _delegate: Option<&'a mut dyn common::Delegate>,
8577 _additional_params: HashMap<String, String>,
8578 _scopes: BTreeSet<String>,
8579}
8580
8581impl<'a, C> common::CallBuilder for CalendarInsertCall<'a, C> {}
8582
8583impl<'a, C> CalendarInsertCall<'a, C>
8584where
8585 C: common::Connector,
8586{
8587 /// Perform the operation you have build so far.
8588 pub async fn doit(mut self) -> common::Result<(common::Response, Calendar)> {
8589 use std::borrow::Cow;
8590 use std::io::{Read, Seek};
8591
8592 use common::{url::Params, ToParts};
8593 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
8594
8595 let mut dd = common::DefaultDelegate;
8596 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
8597 dlg.begin(common::MethodInfo {
8598 id: "calendar.calendars.insert",
8599 http_method: hyper::Method::POST,
8600 });
8601
8602 for &field in ["alt"].iter() {
8603 if self._additional_params.contains_key(field) {
8604 dlg.finished(false);
8605 return Err(common::Error::FieldClash(field));
8606 }
8607 }
8608
8609 let mut params = Params::with_capacity(3 + self._additional_params.len());
8610
8611 params.extend(self._additional_params.iter());
8612
8613 params.push("alt", "json");
8614 let mut url = self.hub._base_url.clone() + "calendars";
8615 if self._scopes.is_empty() {
8616 self._scopes.insert(Scope::Full.as_ref().to_string());
8617 }
8618
8619 let url = params.parse_with_url(&url);
8620
8621 let mut json_mime_type = mime::APPLICATION_JSON;
8622 let mut request_value_reader = {
8623 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
8624 common::remove_json_null_values(&mut value);
8625 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
8626 serde_json::to_writer(&mut dst, &value).unwrap();
8627 dst
8628 };
8629 let request_size = request_value_reader
8630 .seek(std::io::SeekFrom::End(0))
8631 .unwrap();
8632 request_value_reader
8633 .seek(std::io::SeekFrom::Start(0))
8634 .unwrap();
8635
8636 loop {
8637 let token = match self
8638 .hub
8639 .auth
8640 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
8641 .await
8642 {
8643 Ok(token) => token,
8644 Err(e) => match dlg.token(e) {
8645 Ok(token) => token,
8646 Err(e) => {
8647 dlg.finished(false);
8648 return Err(common::Error::MissingToken(e));
8649 }
8650 },
8651 };
8652 request_value_reader
8653 .seek(std::io::SeekFrom::Start(0))
8654 .unwrap();
8655 let mut req_result = {
8656 let client = &self.hub.client;
8657 dlg.pre_request();
8658 let mut req_builder = hyper::Request::builder()
8659 .method(hyper::Method::POST)
8660 .uri(url.as_str())
8661 .header(USER_AGENT, self.hub._user_agent.clone());
8662
8663 if let Some(token) = token.as_ref() {
8664 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
8665 }
8666
8667 let request = req_builder
8668 .header(CONTENT_TYPE, json_mime_type.to_string())
8669 .header(CONTENT_LENGTH, request_size as u64)
8670 .body(common::to_body(
8671 request_value_reader.get_ref().clone().into(),
8672 ));
8673
8674 client.request(request.unwrap()).await
8675 };
8676
8677 match req_result {
8678 Err(err) => {
8679 if let common::Retry::After(d) = dlg.http_error(&err) {
8680 sleep(d).await;
8681 continue;
8682 }
8683 dlg.finished(false);
8684 return Err(common::Error::HttpError(err));
8685 }
8686 Ok(res) => {
8687 let (mut parts, body) = res.into_parts();
8688 let mut body = common::Body::new(body);
8689 if !parts.status.is_success() {
8690 let bytes = common::to_bytes(body).await.unwrap_or_default();
8691 let error = serde_json::from_str(&common::to_string(&bytes));
8692 let response = common::to_response(parts, bytes.into());
8693
8694 if let common::Retry::After(d) =
8695 dlg.http_failure(&response, error.as_ref().ok())
8696 {
8697 sleep(d).await;
8698 continue;
8699 }
8700
8701 dlg.finished(false);
8702
8703 return Err(match error {
8704 Ok(value) => common::Error::BadRequest(value),
8705 _ => common::Error::Failure(response),
8706 });
8707 }
8708 let response = {
8709 let bytes = common::to_bytes(body).await.unwrap_or_default();
8710 let encoded = common::to_string(&bytes);
8711 match serde_json::from_str(&encoded) {
8712 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
8713 Err(error) => {
8714 dlg.response_json_decode_error(&encoded, &error);
8715 return Err(common::Error::JsonDecodeError(
8716 encoded.to_string(),
8717 error,
8718 ));
8719 }
8720 }
8721 };
8722
8723 dlg.finished(true);
8724 return Ok(response);
8725 }
8726 }
8727 }
8728 }
8729
8730 ///
8731 /// Sets the *request* property to the given value.
8732 ///
8733 /// Even though the property as already been set when instantiating this call,
8734 /// we provide this method for API completeness.
8735 pub fn request(mut self, new_value: Calendar) -> CalendarInsertCall<'a, C> {
8736 self._request = new_value;
8737 self
8738 }
8739 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
8740 /// while executing the actual API request.
8741 ///
8742 /// ````text
8743 /// It should be used to handle progress information, and to implement a certain level of resilience.
8744 /// ````
8745 ///
8746 /// Sets the *delegate* property to the given value.
8747 pub fn delegate(
8748 mut self,
8749 new_value: &'a mut dyn common::Delegate,
8750 ) -> CalendarInsertCall<'a, C> {
8751 self._delegate = Some(new_value);
8752 self
8753 }
8754
8755 /// Set any additional parameter of the query string used in the request.
8756 /// It should be used to set parameters which are not yet available through their own
8757 /// setters.
8758 ///
8759 /// Please note that this method must not be used to set any of the known parameters
8760 /// which have their own setter method. If done anyway, the request will fail.
8761 ///
8762 /// # Additional Parameters
8763 ///
8764 /// * *alt* (query-string) - Data format for the response.
8765 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
8766 /// * *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.
8767 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
8768 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
8769 /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
8770 /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
8771 pub fn param<T>(mut self, name: T, value: T) -> CalendarInsertCall<'a, C>
8772 where
8773 T: AsRef<str>,
8774 {
8775 self._additional_params
8776 .insert(name.as_ref().to_string(), value.as_ref().to_string());
8777 self
8778 }
8779
8780 /// Identifies the authorization scope for the method you are building.
8781 ///
8782 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
8783 /// [`Scope::Full`].
8784 ///
8785 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
8786 /// tokens for more than one scope.
8787 ///
8788 /// Usually there is more than one suitable scope to authorize an operation, some of which may
8789 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
8790 /// sufficient, a read-write scope will do as well.
8791 pub fn add_scope<St>(mut self, scope: St) -> CalendarInsertCall<'a, C>
8792 where
8793 St: AsRef<str>,
8794 {
8795 self._scopes.insert(String::from(scope.as_ref()));
8796 self
8797 }
8798 /// Identifies the authorization scope(s) for the method you are building.
8799 ///
8800 /// See [`Self::add_scope()`] for details.
8801 pub fn add_scopes<I, St>(mut self, scopes: I) -> CalendarInsertCall<'a, C>
8802 where
8803 I: IntoIterator<Item = St>,
8804 St: AsRef<str>,
8805 {
8806 self._scopes
8807 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
8808 self
8809 }
8810
8811 /// Removes all scopes, and no default scope will be used either.
8812 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
8813 /// for details).
8814 pub fn clear_scopes(mut self) -> CalendarInsertCall<'a, C> {
8815 self._scopes.clear();
8816 self
8817 }
8818}
8819
8820/// Updates metadata for a calendar. This method supports patch semantics.
8821///
8822/// A builder for the *patch* method supported by a *calendar* resource.
8823/// It is not used directly, but through a [`CalendarMethods`] instance.
8824///
8825/// # Example
8826///
8827/// Instantiate a resource method builder
8828///
8829/// ```test_harness,no_run
8830/// # extern crate hyper;
8831/// # extern crate hyper_rustls;
8832/// # extern crate google_calendar3 as calendar3;
8833/// use calendar3::api::Calendar;
8834/// # async fn dox() {
8835/// # use calendar3::{CalendarHub, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
8836///
8837/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
8838/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
8839/// # .with_native_roots()
8840/// # .unwrap()
8841/// # .https_only()
8842/// # .enable_http2()
8843/// # .build();
8844///
8845/// # let executor = hyper_util::rt::TokioExecutor::new();
8846/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
8847/// # secret,
8848/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
8849/// # yup_oauth2::client::CustomHyperClientBuilder::from(
8850/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
8851/// # ),
8852/// # ).build().await.unwrap();
8853///
8854/// # let client = hyper_util::client::legacy::Client::builder(
8855/// # hyper_util::rt::TokioExecutor::new()
8856/// # )
8857/// # .build(
8858/// # hyper_rustls::HttpsConnectorBuilder::new()
8859/// # .with_native_roots()
8860/// # .unwrap()
8861/// # .https_or_http()
8862/// # .enable_http2()
8863/// # .build()
8864/// # );
8865/// # let mut hub = CalendarHub::new(client, auth);
8866/// // As the method needs a request, you would usually fill it with the desired information
8867/// // into the respective structure. Some of the parts shown here might not be applicable !
8868/// // Values shown here are possibly random and not representative !
8869/// let mut req = Calendar::default();
8870///
8871/// // You can configure optional parameters by calling the respective setters at will, and
8872/// // execute the final call using `doit()`.
8873/// // Values shown here are possibly random and not representative !
8874/// let result = hub.calendars().patch(req, "calendarId")
8875/// .doit().await;
8876/// # }
8877/// ```
8878pub struct CalendarPatchCall<'a, C>
8879where
8880 C: 'a,
8881{
8882 hub: &'a CalendarHub<C>,
8883 _request: Calendar,
8884 _calendar_id: String,
8885 _delegate: Option<&'a mut dyn common::Delegate>,
8886 _additional_params: HashMap<String, String>,
8887 _scopes: BTreeSet<String>,
8888}
8889
8890impl<'a, C> common::CallBuilder for CalendarPatchCall<'a, C> {}
8891
8892impl<'a, C> CalendarPatchCall<'a, C>
8893where
8894 C: common::Connector,
8895{
8896 /// Perform the operation you have build so far.
8897 pub async fn doit(mut self) -> common::Result<(common::Response, Calendar)> {
8898 use std::borrow::Cow;
8899 use std::io::{Read, Seek};
8900
8901 use common::{url::Params, ToParts};
8902 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
8903
8904 let mut dd = common::DefaultDelegate;
8905 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
8906 dlg.begin(common::MethodInfo {
8907 id: "calendar.calendars.patch",
8908 http_method: hyper::Method::PATCH,
8909 });
8910
8911 for &field in ["alt", "calendarId"].iter() {
8912 if self._additional_params.contains_key(field) {
8913 dlg.finished(false);
8914 return Err(common::Error::FieldClash(field));
8915 }
8916 }
8917
8918 let mut params = Params::with_capacity(4 + self._additional_params.len());
8919 params.push("calendarId", self._calendar_id);
8920
8921 params.extend(self._additional_params.iter());
8922
8923 params.push("alt", "json");
8924 let mut url = self.hub._base_url.clone() + "calendars/{calendarId}";
8925 if self._scopes.is_empty() {
8926 self._scopes.insert(Scope::Full.as_ref().to_string());
8927 }
8928
8929 #[allow(clippy::single_element_loop)]
8930 for &(find_this, param_name) in [("{calendarId}", "calendarId")].iter() {
8931 url = params.uri_replacement(url, param_name, find_this, false);
8932 }
8933 {
8934 let to_remove = ["calendarId"];
8935 params.remove_params(&to_remove);
8936 }
8937
8938 let url = params.parse_with_url(&url);
8939
8940 let mut json_mime_type = mime::APPLICATION_JSON;
8941 let mut request_value_reader = {
8942 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
8943 common::remove_json_null_values(&mut value);
8944 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
8945 serde_json::to_writer(&mut dst, &value).unwrap();
8946 dst
8947 };
8948 let request_size = request_value_reader
8949 .seek(std::io::SeekFrom::End(0))
8950 .unwrap();
8951 request_value_reader
8952 .seek(std::io::SeekFrom::Start(0))
8953 .unwrap();
8954
8955 loop {
8956 let token = match self
8957 .hub
8958 .auth
8959 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
8960 .await
8961 {
8962 Ok(token) => token,
8963 Err(e) => match dlg.token(e) {
8964 Ok(token) => token,
8965 Err(e) => {
8966 dlg.finished(false);
8967 return Err(common::Error::MissingToken(e));
8968 }
8969 },
8970 };
8971 request_value_reader
8972 .seek(std::io::SeekFrom::Start(0))
8973 .unwrap();
8974 let mut req_result = {
8975 let client = &self.hub.client;
8976 dlg.pre_request();
8977 let mut req_builder = hyper::Request::builder()
8978 .method(hyper::Method::PATCH)
8979 .uri(url.as_str())
8980 .header(USER_AGENT, self.hub._user_agent.clone());
8981
8982 if let Some(token) = token.as_ref() {
8983 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
8984 }
8985
8986 let request = req_builder
8987 .header(CONTENT_TYPE, json_mime_type.to_string())
8988 .header(CONTENT_LENGTH, request_size as u64)
8989 .body(common::to_body(
8990 request_value_reader.get_ref().clone().into(),
8991 ));
8992
8993 client.request(request.unwrap()).await
8994 };
8995
8996 match req_result {
8997 Err(err) => {
8998 if let common::Retry::After(d) = dlg.http_error(&err) {
8999 sleep(d).await;
9000 continue;
9001 }
9002 dlg.finished(false);
9003 return Err(common::Error::HttpError(err));
9004 }
9005 Ok(res) => {
9006 let (mut parts, body) = res.into_parts();
9007 let mut body = common::Body::new(body);
9008 if !parts.status.is_success() {
9009 let bytes = common::to_bytes(body).await.unwrap_or_default();
9010 let error = serde_json::from_str(&common::to_string(&bytes));
9011 let response = common::to_response(parts, bytes.into());
9012
9013 if let common::Retry::After(d) =
9014 dlg.http_failure(&response, error.as_ref().ok())
9015 {
9016 sleep(d).await;
9017 continue;
9018 }
9019
9020 dlg.finished(false);
9021
9022 return Err(match error {
9023 Ok(value) => common::Error::BadRequest(value),
9024 _ => common::Error::Failure(response),
9025 });
9026 }
9027 let response = {
9028 let bytes = common::to_bytes(body).await.unwrap_or_default();
9029 let encoded = common::to_string(&bytes);
9030 match serde_json::from_str(&encoded) {
9031 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
9032 Err(error) => {
9033 dlg.response_json_decode_error(&encoded, &error);
9034 return Err(common::Error::JsonDecodeError(
9035 encoded.to_string(),
9036 error,
9037 ));
9038 }
9039 }
9040 };
9041
9042 dlg.finished(true);
9043 return Ok(response);
9044 }
9045 }
9046 }
9047 }
9048
9049 ///
9050 /// Sets the *request* property to the given value.
9051 ///
9052 /// Even though the property as already been set when instantiating this call,
9053 /// we provide this method for API completeness.
9054 pub fn request(mut self, new_value: Calendar) -> CalendarPatchCall<'a, C> {
9055 self._request = new_value;
9056 self
9057 }
9058 /// 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.
9059 ///
9060 /// Sets the *calendar id* path property to the given value.
9061 ///
9062 /// Even though the property as already been set when instantiating this call,
9063 /// we provide this method for API completeness.
9064 pub fn calendar_id(mut self, new_value: &str) -> CalendarPatchCall<'a, C> {
9065 self._calendar_id = new_value.to_string();
9066 self
9067 }
9068 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
9069 /// while executing the actual API request.
9070 ///
9071 /// ````text
9072 /// It should be used to handle progress information, and to implement a certain level of resilience.
9073 /// ````
9074 ///
9075 /// Sets the *delegate* property to the given value.
9076 pub fn delegate(mut self, new_value: &'a mut dyn common::Delegate) -> CalendarPatchCall<'a, C> {
9077 self._delegate = Some(new_value);
9078 self
9079 }
9080
9081 /// Set any additional parameter of the query string used in the request.
9082 /// It should be used to set parameters which are not yet available through their own
9083 /// setters.
9084 ///
9085 /// Please note that this method must not be used to set any of the known parameters
9086 /// which have their own setter method. If done anyway, the request will fail.
9087 ///
9088 /// # Additional Parameters
9089 ///
9090 /// * *alt* (query-string) - Data format for the response.
9091 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
9092 /// * *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.
9093 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
9094 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
9095 /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
9096 /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
9097 pub fn param<T>(mut self, name: T, value: T) -> CalendarPatchCall<'a, C>
9098 where
9099 T: AsRef<str>,
9100 {
9101 self._additional_params
9102 .insert(name.as_ref().to_string(), value.as_ref().to_string());
9103 self
9104 }
9105
9106 /// Identifies the authorization scope for the method you are building.
9107 ///
9108 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
9109 /// [`Scope::Full`].
9110 ///
9111 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
9112 /// tokens for more than one scope.
9113 ///
9114 /// Usually there is more than one suitable scope to authorize an operation, some of which may
9115 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
9116 /// sufficient, a read-write scope will do as well.
9117 pub fn add_scope<St>(mut self, scope: St) -> CalendarPatchCall<'a, C>
9118 where
9119 St: AsRef<str>,
9120 {
9121 self._scopes.insert(String::from(scope.as_ref()));
9122 self
9123 }
9124 /// Identifies the authorization scope(s) for the method you are building.
9125 ///
9126 /// See [`Self::add_scope()`] for details.
9127 pub fn add_scopes<I, St>(mut self, scopes: I) -> CalendarPatchCall<'a, C>
9128 where
9129 I: IntoIterator<Item = St>,
9130 St: AsRef<str>,
9131 {
9132 self._scopes
9133 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
9134 self
9135 }
9136
9137 /// Removes all scopes, and no default scope will be used either.
9138 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
9139 /// for details).
9140 pub fn clear_scopes(mut self) -> CalendarPatchCall<'a, C> {
9141 self._scopes.clear();
9142 self
9143 }
9144}
9145
9146/// Updates metadata for a calendar.
9147///
9148/// A builder for the *update* method supported by a *calendar* resource.
9149/// It is not used directly, but through a [`CalendarMethods`] instance.
9150///
9151/// # Example
9152///
9153/// Instantiate a resource method builder
9154///
9155/// ```test_harness,no_run
9156/// # extern crate hyper;
9157/// # extern crate hyper_rustls;
9158/// # extern crate google_calendar3 as calendar3;
9159/// use calendar3::api::Calendar;
9160/// # async fn dox() {
9161/// # use calendar3::{CalendarHub, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
9162///
9163/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
9164/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
9165/// # .with_native_roots()
9166/// # .unwrap()
9167/// # .https_only()
9168/// # .enable_http2()
9169/// # .build();
9170///
9171/// # let executor = hyper_util::rt::TokioExecutor::new();
9172/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
9173/// # secret,
9174/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
9175/// # yup_oauth2::client::CustomHyperClientBuilder::from(
9176/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
9177/// # ),
9178/// # ).build().await.unwrap();
9179///
9180/// # let client = hyper_util::client::legacy::Client::builder(
9181/// # hyper_util::rt::TokioExecutor::new()
9182/// # )
9183/// # .build(
9184/// # hyper_rustls::HttpsConnectorBuilder::new()
9185/// # .with_native_roots()
9186/// # .unwrap()
9187/// # .https_or_http()
9188/// # .enable_http2()
9189/// # .build()
9190/// # );
9191/// # let mut hub = CalendarHub::new(client, auth);
9192/// // As the method needs a request, you would usually fill it with the desired information
9193/// // into the respective structure. Some of the parts shown here might not be applicable !
9194/// // Values shown here are possibly random and not representative !
9195/// let mut req = Calendar::default();
9196///
9197/// // You can configure optional parameters by calling the respective setters at will, and
9198/// // execute the final call using `doit()`.
9199/// // Values shown here are possibly random and not representative !
9200/// let result = hub.calendars().update(req, "calendarId")
9201/// .doit().await;
9202/// # }
9203/// ```
9204pub struct CalendarUpdateCall<'a, C>
9205where
9206 C: 'a,
9207{
9208 hub: &'a CalendarHub<C>,
9209 _request: Calendar,
9210 _calendar_id: String,
9211 _delegate: Option<&'a mut dyn common::Delegate>,
9212 _additional_params: HashMap<String, String>,
9213 _scopes: BTreeSet<String>,
9214}
9215
9216impl<'a, C> common::CallBuilder for CalendarUpdateCall<'a, C> {}
9217
9218impl<'a, C> CalendarUpdateCall<'a, C>
9219where
9220 C: common::Connector,
9221{
9222 /// Perform the operation you have build so far.
9223 pub async fn doit(mut self) -> common::Result<(common::Response, Calendar)> {
9224 use std::borrow::Cow;
9225 use std::io::{Read, Seek};
9226
9227 use common::{url::Params, ToParts};
9228 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
9229
9230 let mut dd = common::DefaultDelegate;
9231 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
9232 dlg.begin(common::MethodInfo {
9233 id: "calendar.calendars.update",
9234 http_method: hyper::Method::PUT,
9235 });
9236
9237 for &field in ["alt", "calendarId"].iter() {
9238 if self._additional_params.contains_key(field) {
9239 dlg.finished(false);
9240 return Err(common::Error::FieldClash(field));
9241 }
9242 }
9243
9244 let mut params = Params::with_capacity(4 + self._additional_params.len());
9245 params.push("calendarId", self._calendar_id);
9246
9247 params.extend(self._additional_params.iter());
9248
9249 params.push("alt", "json");
9250 let mut url = self.hub._base_url.clone() + "calendars/{calendarId}";
9251 if self._scopes.is_empty() {
9252 self._scopes.insert(Scope::Full.as_ref().to_string());
9253 }
9254
9255 #[allow(clippy::single_element_loop)]
9256 for &(find_this, param_name) in [("{calendarId}", "calendarId")].iter() {
9257 url = params.uri_replacement(url, param_name, find_this, false);
9258 }
9259 {
9260 let to_remove = ["calendarId"];
9261 params.remove_params(&to_remove);
9262 }
9263
9264 let url = params.parse_with_url(&url);
9265
9266 let mut json_mime_type = mime::APPLICATION_JSON;
9267 let mut request_value_reader = {
9268 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
9269 common::remove_json_null_values(&mut value);
9270 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
9271 serde_json::to_writer(&mut dst, &value).unwrap();
9272 dst
9273 };
9274 let request_size = request_value_reader
9275 .seek(std::io::SeekFrom::End(0))
9276 .unwrap();
9277 request_value_reader
9278 .seek(std::io::SeekFrom::Start(0))
9279 .unwrap();
9280
9281 loop {
9282 let token = match self
9283 .hub
9284 .auth
9285 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
9286 .await
9287 {
9288 Ok(token) => token,
9289 Err(e) => match dlg.token(e) {
9290 Ok(token) => token,
9291 Err(e) => {
9292 dlg.finished(false);
9293 return Err(common::Error::MissingToken(e));
9294 }
9295 },
9296 };
9297 request_value_reader
9298 .seek(std::io::SeekFrom::Start(0))
9299 .unwrap();
9300 let mut req_result = {
9301 let client = &self.hub.client;
9302 dlg.pre_request();
9303 let mut req_builder = hyper::Request::builder()
9304 .method(hyper::Method::PUT)
9305 .uri(url.as_str())
9306 .header(USER_AGENT, self.hub._user_agent.clone());
9307
9308 if let Some(token) = token.as_ref() {
9309 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
9310 }
9311
9312 let request = req_builder
9313 .header(CONTENT_TYPE, json_mime_type.to_string())
9314 .header(CONTENT_LENGTH, request_size as u64)
9315 .body(common::to_body(
9316 request_value_reader.get_ref().clone().into(),
9317 ));
9318
9319 client.request(request.unwrap()).await
9320 };
9321
9322 match req_result {
9323 Err(err) => {
9324 if let common::Retry::After(d) = dlg.http_error(&err) {
9325 sleep(d).await;
9326 continue;
9327 }
9328 dlg.finished(false);
9329 return Err(common::Error::HttpError(err));
9330 }
9331 Ok(res) => {
9332 let (mut parts, body) = res.into_parts();
9333 let mut body = common::Body::new(body);
9334 if !parts.status.is_success() {
9335 let bytes = common::to_bytes(body).await.unwrap_or_default();
9336 let error = serde_json::from_str(&common::to_string(&bytes));
9337 let response = common::to_response(parts, bytes.into());
9338
9339 if let common::Retry::After(d) =
9340 dlg.http_failure(&response, error.as_ref().ok())
9341 {
9342 sleep(d).await;
9343 continue;
9344 }
9345
9346 dlg.finished(false);
9347
9348 return Err(match error {
9349 Ok(value) => common::Error::BadRequest(value),
9350 _ => common::Error::Failure(response),
9351 });
9352 }
9353 let response = {
9354 let bytes = common::to_bytes(body).await.unwrap_or_default();
9355 let encoded = common::to_string(&bytes);
9356 match serde_json::from_str(&encoded) {
9357 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
9358 Err(error) => {
9359 dlg.response_json_decode_error(&encoded, &error);
9360 return Err(common::Error::JsonDecodeError(
9361 encoded.to_string(),
9362 error,
9363 ));
9364 }
9365 }
9366 };
9367
9368 dlg.finished(true);
9369 return Ok(response);
9370 }
9371 }
9372 }
9373 }
9374
9375 ///
9376 /// Sets the *request* property to the given value.
9377 ///
9378 /// Even though the property as already been set when instantiating this call,
9379 /// we provide this method for API completeness.
9380 pub fn request(mut self, new_value: Calendar) -> CalendarUpdateCall<'a, C> {
9381 self._request = new_value;
9382 self
9383 }
9384 /// 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.
9385 ///
9386 /// Sets the *calendar id* path property to the given value.
9387 ///
9388 /// Even though the property as already been set when instantiating this call,
9389 /// we provide this method for API completeness.
9390 pub fn calendar_id(mut self, new_value: &str) -> CalendarUpdateCall<'a, C> {
9391 self._calendar_id = new_value.to_string();
9392 self
9393 }
9394 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
9395 /// while executing the actual API request.
9396 ///
9397 /// ````text
9398 /// It should be used to handle progress information, and to implement a certain level of resilience.
9399 /// ````
9400 ///
9401 /// Sets the *delegate* property to the given value.
9402 pub fn delegate(
9403 mut self,
9404 new_value: &'a mut dyn common::Delegate,
9405 ) -> CalendarUpdateCall<'a, C> {
9406 self._delegate = Some(new_value);
9407 self
9408 }
9409
9410 /// Set any additional parameter of the query string used in the request.
9411 /// It should be used to set parameters which are not yet available through their own
9412 /// setters.
9413 ///
9414 /// Please note that this method must not be used to set any of the known parameters
9415 /// which have their own setter method. If done anyway, the request will fail.
9416 ///
9417 /// # Additional Parameters
9418 ///
9419 /// * *alt* (query-string) - Data format for the response.
9420 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
9421 /// * *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.
9422 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
9423 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
9424 /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
9425 /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
9426 pub fn param<T>(mut self, name: T, value: T) -> CalendarUpdateCall<'a, C>
9427 where
9428 T: AsRef<str>,
9429 {
9430 self._additional_params
9431 .insert(name.as_ref().to_string(), value.as_ref().to_string());
9432 self
9433 }
9434
9435 /// Identifies the authorization scope for the method you are building.
9436 ///
9437 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
9438 /// [`Scope::Full`].
9439 ///
9440 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
9441 /// tokens for more than one scope.
9442 ///
9443 /// Usually there is more than one suitable scope to authorize an operation, some of which may
9444 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
9445 /// sufficient, a read-write scope will do as well.
9446 pub fn add_scope<St>(mut self, scope: St) -> CalendarUpdateCall<'a, C>
9447 where
9448 St: AsRef<str>,
9449 {
9450 self._scopes.insert(String::from(scope.as_ref()));
9451 self
9452 }
9453 /// Identifies the authorization scope(s) for the method you are building.
9454 ///
9455 /// See [`Self::add_scope()`] for details.
9456 pub fn add_scopes<I, St>(mut self, scopes: I) -> CalendarUpdateCall<'a, C>
9457 where
9458 I: IntoIterator<Item = St>,
9459 St: AsRef<str>,
9460 {
9461 self._scopes
9462 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
9463 self
9464 }
9465
9466 /// Removes all scopes, and no default scope will be used either.
9467 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
9468 /// for details).
9469 pub fn clear_scopes(mut self) -> CalendarUpdateCall<'a, C> {
9470 self._scopes.clear();
9471 self
9472 }
9473}
9474
9475/// Stop watching resources through this channel
9476///
9477/// A builder for the *stop* method supported by a *channel* resource.
9478/// It is not used directly, but through a [`ChannelMethods`] instance.
9479///
9480/// # Example
9481///
9482/// Instantiate a resource method builder
9483///
9484/// ```test_harness,no_run
9485/// # extern crate hyper;
9486/// # extern crate hyper_rustls;
9487/// # extern crate google_calendar3 as calendar3;
9488/// use calendar3::api::Channel;
9489/// # async fn dox() {
9490/// # use calendar3::{CalendarHub, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
9491///
9492/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
9493/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
9494/// # .with_native_roots()
9495/// # .unwrap()
9496/// # .https_only()
9497/// # .enable_http2()
9498/// # .build();
9499///
9500/// # let executor = hyper_util::rt::TokioExecutor::new();
9501/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
9502/// # secret,
9503/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
9504/// # yup_oauth2::client::CustomHyperClientBuilder::from(
9505/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
9506/// # ),
9507/// # ).build().await.unwrap();
9508///
9509/// # let client = hyper_util::client::legacy::Client::builder(
9510/// # hyper_util::rt::TokioExecutor::new()
9511/// # )
9512/// # .build(
9513/// # hyper_rustls::HttpsConnectorBuilder::new()
9514/// # .with_native_roots()
9515/// # .unwrap()
9516/// # .https_or_http()
9517/// # .enable_http2()
9518/// # .build()
9519/// # );
9520/// # let mut hub = CalendarHub::new(client, auth);
9521/// // As the method needs a request, you would usually fill it with the desired information
9522/// // into the respective structure. Some of the parts shown here might not be applicable !
9523/// // Values shown here are possibly random and not representative !
9524/// let mut req = Channel::default();
9525///
9526/// // You can configure optional parameters by calling the respective setters at will, and
9527/// // execute the final call using `doit()`.
9528/// // Values shown here are possibly random and not representative !
9529/// let result = hub.channels().stop(req)
9530/// .doit().await;
9531/// # }
9532/// ```
9533pub struct ChannelStopCall<'a, C>
9534where
9535 C: 'a,
9536{
9537 hub: &'a CalendarHub<C>,
9538 _request: Channel,
9539 _delegate: Option<&'a mut dyn common::Delegate>,
9540 _additional_params: HashMap<String, String>,
9541 _scopes: BTreeSet<String>,
9542}
9543
9544impl<'a, C> common::CallBuilder for ChannelStopCall<'a, C> {}
9545
9546impl<'a, C> ChannelStopCall<'a, C>
9547where
9548 C: common::Connector,
9549{
9550 /// Perform the operation you have build so far.
9551 pub async fn doit(mut self) -> common::Result<common::Response> {
9552 use std::borrow::Cow;
9553 use std::io::{Read, Seek};
9554
9555 use common::{url::Params, ToParts};
9556 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
9557
9558 let mut dd = common::DefaultDelegate;
9559 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
9560 dlg.begin(common::MethodInfo {
9561 id: "calendar.channels.stop",
9562 http_method: hyper::Method::POST,
9563 });
9564
9565 for &field in [].iter() {
9566 if self._additional_params.contains_key(field) {
9567 dlg.finished(false);
9568 return Err(common::Error::FieldClash(field));
9569 }
9570 }
9571
9572 let mut params = Params::with_capacity(2 + self._additional_params.len());
9573
9574 params.extend(self._additional_params.iter());
9575
9576 let mut url = self.hub._base_url.clone() + "channels/stop";
9577 if self._scopes.is_empty() {
9578 self._scopes.insert(Scope::AclReadonly.as_ref().to_string());
9579 }
9580
9581 let url = params.parse_with_url(&url);
9582
9583 let mut json_mime_type = mime::APPLICATION_JSON;
9584 let mut request_value_reader = {
9585 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
9586 common::remove_json_null_values(&mut value);
9587 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
9588 serde_json::to_writer(&mut dst, &value).unwrap();
9589 dst
9590 };
9591 let request_size = request_value_reader
9592 .seek(std::io::SeekFrom::End(0))
9593 .unwrap();
9594 request_value_reader
9595 .seek(std::io::SeekFrom::Start(0))
9596 .unwrap();
9597
9598 loop {
9599 let token = match self
9600 .hub
9601 .auth
9602 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
9603 .await
9604 {
9605 Ok(token) => token,
9606 Err(e) => match dlg.token(e) {
9607 Ok(token) => token,
9608 Err(e) => {
9609 dlg.finished(false);
9610 return Err(common::Error::MissingToken(e));
9611 }
9612 },
9613 };
9614 request_value_reader
9615 .seek(std::io::SeekFrom::Start(0))
9616 .unwrap();
9617 let mut req_result = {
9618 let client = &self.hub.client;
9619 dlg.pre_request();
9620 let mut req_builder = hyper::Request::builder()
9621 .method(hyper::Method::POST)
9622 .uri(url.as_str())
9623 .header(USER_AGENT, self.hub._user_agent.clone());
9624
9625 if let Some(token) = token.as_ref() {
9626 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
9627 }
9628
9629 let request = req_builder
9630 .header(CONTENT_TYPE, json_mime_type.to_string())
9631 .header(CONTENT_LENGTH, request_size as u64)
9632 .body(common::to_body(
9633 request_value_reader.get_ref().clone().into(),
9634 ));
9635
9636 client.request(request.unwrap()).await
9637 };
9638
9639 match req_result {
9640 Err(err) => {
9641 if let common::Retry::After(d) = dlg.http_error(&err) {
9642 sleep(d).await;
9643 continue;
9644 }
9645 dlg.finished(false);
9646 return Err(common::Error::HttpError(err));
9647 }
9648 Ok(res) => {
9649 let (mut parts, body) = res.into_parts();
9650 let mut body = common::Body::new(body);
9651 if !parts.status.is_success() {
9652 let bytes = common::to_bytes(body).await.unwrap_or_default();
9653 let error = serde_json::from_str(&common::to_string(&bytes));
9654 let response = common::to_response(parts, bytes.into());
9655
9656 if let common::Retry::After(d) =
9657 dlg.http_failure(&response, error.as_ref().ok())
9658 {
9659 sleep(d).await;
9660 continue;
9661 }
9662
9663 dlg.finished(false);
9664
9665 return Err(match error {
9666 Ok(value) => common::Error::BadRequest(value),
9667 _ => common::Error::Failure(response),
9668 });
9669 }
9670 let response = common::Response::from_parts(parts, body);
9671
9672 dlg.finished(true);
9673 return Ok(response);
9674 }
9675 }
9676 }
9677 }
9678
9679 ///
9680 /// Sets the *request* property to the given value.
9681 ///
9682 /// Even though the property as already been set when instantiating this call,
9683 /// we provide this method for API completeness.
9684 pub fn request(mut self, new_value: Channel) -> ChannelStopCall<'a, C> {
9685 self._request = new_value;
9686 self
9687 }
9688 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
9689 /// while executing the actual API request.
9690 ///
9691 /// ````text
9692 /// It should be used to handle progress information, and to implement a certain level of resilience.
9693 /// ````
9694 ///
9695 /// Sets the *delegate* property to the given value.
9696 pub fn delegate(mut self, new_value: &'a mut dyn common::Delegate) -> ChannelStopCall<'a, C> {
9697 self._delegate = Some(new_value);
9698 self
9699 }
9700
9701 /// Set any additional parameter of the query string used in the request.
9702 /// It should be used to set parameters which are not yet available through their own
9703 /// setters.
9704 ///
9705 /// Please note that this method must not be used to set any of the known parameters
9706 /// which have their own setter method. If done anyway, the request will fail.
9707 ///
9708 /// # Additional Parameters
9709 ///
9710 /// * *alt* (query-string) - Data format for the response.
9711 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
9712 /// * *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.
9713 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
9714 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
9715 /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
9716 /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
9717 pub fn param<T>(mut self, name: T, value: T) -> ChannelStopCall<'a, C>
9718 where
9719 T: AsRef<str>,
9720 {
9721 self._additional_params
9722 .insert(name.as_ref().to_string(), value.as_ref().to_string());
9723 self
9724 }
9725
9726 /// Identifies the authorization scope for the method you are building.
9727 ///
9728 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
9729 /// [`Scope::AclReadonly`].
9730 ///
9731 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
9732 /// tokens for more than one scope.
9733 ///
9734 /// Usually there is more than one suitable scope to authorize an operation, some of which may
9735 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
9736 /// sufficient, a read-write scope will do as well.
9737 pub fn add_scope<St>(mut self, scope: St) -> ChannelStopCall<'a, C>
9738 where
9739 St: AsRef<str>,
9740 {
9741 self._scopes.insert(String::from(scope.as_ref()));
9742 self
9743 }
9744 /// Identifies the authorization scope(s) for the method you are building.
9745 ///
9746 /// See [`Self::add_scope()`] for details.
9747 pub fn add_scopes<I, St>(mut self, scopes: I) -> ChannelStopCall<'a, C>
9748 where
9749 I: IntoIterator<Item = St>,
9750 St: AsRef<str>,
9751 {
9752 self._scopes
9753 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
9754 self
9755 }
9756
9757 /// Removes all scopes, and no default scope will be used either.
9758 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
9759 /// for details).
9760 pub fn clear_scopes(mut self) -> ChannelStopCall<'a, C> {
9761 self._scopes.clear();
9762 self
9763 }
9764}
9765
9766/// Returns the color definitions for calendars and events.
9767///
9768/// A builder for the *get* method supported by a *color* resource.
9769/// It is not used directly, but through a [`ColorMethods`] instance.
9770///
9771/// # Example
9772///
9773/// Instantiate a resource method builder
9774///
9775/// ```test_harness,no_run
9776/// # extern crate hyper;
9777/// # extern crate hyper_rustls;
9778/// # extern crate google_calendar3 as calendar3;
9779/// # async fn dox() {
9780/// # use calendar3::{CalendarHub, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
9781///
9782/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
9783/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
9784/// # .with_native_roots()
9785/// # .unwrap()
9786/// # .https_only()
9787/// # .enable_http2()
9788/// # .build();
9789///
9790/// # let executor = hyper_util::rt::TokioExecutor::new();
9791/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
9792/// # secret,
9793/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
9794/// # yup_oauth2::client::CustomHyperClientBuilder::from(
9795/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
9796/// # ),
9797/// # ).build().await.unwrap();
9798///
9799/// # let client = hyper_util::client::legacy::Client::builder(
9800/// # hyper_util::rt::TokioExecutor::new()
9801/// # )
9802/// # .build(
9803/// # hyper_rustls::HttpsConnectorBuilder::new()
9804/// # .with_native_roots()
9805/// # .unwrap()
9806/// # .https_or_http()
9807/// # .enable_http2()
9808/// # .build()
9809/// # );
9810/// # let mut hub = CalendarHub::new(client, auth);
9811/// // You can configure optional parameters by calling the respective setters at will, and
9812/// // execute the final call using `doit()`.
9813/// // Values shown here are possibly random and not representative !
9814/// let result = hub.colors().get()
9815/// .doit().await;
9816/// # }
9817/// ```
9818pub struct ColorGetCall<'a, C>
9819where
9820 C: 'a,
9821{
9822 hub: &'a CalendarHub<C>,
9823 _delegate: Option<&'a mut dyn common::Delegate>,
9824 _additional_params: HashMap<String, String>,
9825 _scopes: BTreeSet<String>,
9826}
9827
9828impl<'a, C> common::CallBuilder for ColorGetCall<'a, C> {}
9829
9830impl<'a, C> ColorGetCall<'a, C>
9831where
9832 C: common::Connector,
9833{
9834 /// Perform the operation you have build so far.
9835 pub async fn doit(mut self) -> common::Result<(common::Response, Colors)> {
9836 use std::borrow::Cow;
9837 use std::io::{Read, Seek};
9838
9839 use common::{url::Params, ToParts};
9840 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
9841
9842 let mut dd = common::DefaultDelegate;
9843 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
9844 dlg.begin(common::MethodInfo {
9845 id: "calendar.colors.get",
9846 http_method: hyper::Method::GET,
9847 });
9848
9849 for &field in ["alt"].iter() {
9850 if self._additional_params.contains_key(field) {
9851 dlg.finished(false);
9852 return Err(common::Error::FieldClash(field));
9853 }
9854 }
9855
9856 let mut params = Params::with_capacity(2 + self._additional_params.len());
9857
9858 params.extend(self._additional_params.iter());
9859
9860 params.push("alt", "json");
9861 let mut url = self.hub._base_url.clone() + "colors";
9862 if self._scopes.is_empty() {
9863 self._scopes
9864 .insert(Scope::CalendarlistReadonly.as_ref().to_string());
9865 }
9866
9867 let url = params.parse_with_url(&url);
9868
9869 loop {
9870 let token = match self
9871 .hub
9872 .auth
9873 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
9874 .await
9875 {
9876 Ok(token) => token,
9877 Err(e) => match dlg.token(e) {
9878 Ok(token) => token,
9879 Err(e) => {
9880 dlg.finished(false);
9881 return Err(common::Error::MissingToken(e));
9882 }
9883 },
9884 };
9885 let mut req_result = {
9886 let client = &self.hub.client;
9887 dlg.pre_request();
9888 let mut req_builder = hyper::Request::builder()
9889 .method(hyper::Method::GET)
9890 .uri(url.as_str())
9891 .header(USER_AGENT, self.hub._user_agent.clone());
9892
9893 if let Some(token) = token.as_ref() {
9894 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
9895 }
9896
9897 let request = req_builder
9898 .header(CONTENT_LENGTH, 0_u64)
9899 .body(common::to_body::<String>(None));
9900
9901 client.request(request.unwrap()).await
9902 };
9903
9904 match req_result {
9905 Err(err) => {
9906 if let common::Retry::After(d) = dlg.http_error(&err) {
9907 sleep(d).await;
9908 continue;
9909 }
9910 dlg.finished(false);
9911 return Err(common::Error::HttpError(err));
9912 }
9913 Ok(res) => {
9914 let (mut parts, body) = res.into_parts();
9915 let mut body = common::Body::new(body);
9916 if !parts.status.is_success() {
9917 let bytes = common::to_bytes(body).await.unwrap_or_default();
9918 let error = serde_json::from_str(&common::to_string(&bytes));
9919 let response = common::to_response(parts, bytes.into());
9920
9921 if let common::Retry::After(d) =
9922 dlg.http_failure(&response, error.as_ref().ok())
9923 {
9924 sleep(d).await;
9925 continue;
9926 }
9927
9928 dlg.finished(false);
9929
9930 return Err(match error {
9931 Ok(value) => common::Error::BadRequest(value),
9932 _ => common::Error::Failure(response),
9933 });
9934 }
9935 let response = {
9936 let bytes = common::to_bytes(body).await.unwrap_or_default();
9937 let encoded = common::to_string(&bytes);
9938 match serde_json::from_str(&encoded) {
9939 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
9940 Err(error) => {
9941 dlg.response_json_decode_error(&encoded, &error);
9942 return Err(common::Error::JsonDecodeError(
9943 encoded.to_string(),
9944 error,
9945 ));
9946 }
9947 }
9948 };
9949
9950 dlg.finished(true);
9951 return Ok(response);
9952 }
9953 }
9954 }
9955 }
9956
9957 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
9958 /// while executing the actual API request.
9959 ///
9960 /// ````text
9961 /// It should be used to handle progress information, and to implement a certain level of resilience.
9962 /// ````
9963 ///
9964 /// Sets the *delegate* property to the given value.
9965 pub fn delegate(mut self, new_value: &'a mut dyn common::Delegate) -> ColorGetCall<'a, C> {
9966 self._delegate = Some(new_value);
9967 self
9968 }
9969
9970 /// Set any additional parameter of the query string used in the request.
9971 /// It should be used to set parameters which are not yet available through their own
9972 /// setters.
9973 ///
9974 /// Please note that this method must not be used to set any of the known parameters
9975 /// which have their own setter method. If done anyway, the request will fail.
9976 ///
9977 /// # Additional Parameters
9978 ///
9979 /// * *alt* (query-string) - Data format for the response.
9980 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
9981 /// * *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.
9982 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
9983 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
9984 /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
9985 /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
9986 pub fn param<T>(mut self, name: T, value: T) -> ColorGetCall<'a, C>
9987 where
9988 T: AsRef<str>,
9989 {
9990 self._additional_params
9991 .insert(name.as_ref().to_string(), value.as_ref().to_string());
9992 self
9993 }
9994
9995 /// Identifies the authorization scope for the method you are building.
9996 ///
9997 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
9998 /// [`Scope::CalendarlistReadonly`].
9999 ///
10000 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
10001 /// tokens for more than one scope.
10002 ///
10003 /// Usually there is more than one suitable scope to authorize an operation, some of which may
10004 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
10005 /// sufficient, a read-write scope will do as well.
10006 pub fn add_scope<St>(mut self, scope: St) -> ColorGetCall<'a, C>
10007 where
10008 St: AsRef<str>,
10009 {
10010 self._scopes.insert(String::from(scope.as_ref()));
10011 self
10012 }
10013 /// Identifies the authorization scope(s) for the method you are building.
10014 ///
10015 /// See [`Self::add_scope()`] for details.
10016 pub fn add_scopes<I, St>(mut self, scopes: I) -> ColorGetCall<'a, C>
10017 where
10018 I: IntoIterator<Item = St>,
10019 St: AsRef<str>,
10020 {
10021 self._scopes
10022 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
10023 self
10024 }
10025
10026 /// Removes all scopes, and no default scope will be used either.
10027 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
10028 /// for details).
10029 pub fn clear_scopes(mut self) -> ColorGetCall<'a, C> {
10030 self._scopes.clear();
10031 self
10032 }
10033}
10034
10035/// Deletes an event.
10036///
10037/// A builder for the *delete* method supported by a *event* resource.
10038/// It is not used directly, but through a [`EventMethods`] instance.
10039///
10040/// # Example
10041///
10042/// Instantiate a resource method builder
10043///
10044/// ```test_harness,no_run
10045/// # extern crate hyper;
10046/// # extern crate hyper_rustls;
10047/// # extern crate google_calendar3 as calendar3;
10048/// # async fn dox() {
10049/// # use calendar3::{CalendarHub, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
10050///
10051/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
10052/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
10053/// # .with_native_roots()
10054/// # .unwrap()
10055/// # .https_only()
10056/// # .enable_http2()
10057/// # .build();
10058///
10059/// # let executor = hyper_util::rt::TokioExecutor::new();
10060/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
10061/// # secret,
10062/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
10063/// # yup_oauth2::client::CustomHyperClientBuilder::from(
10064/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
10065/// # ),
10066/// # ).build().await.unwrap();
10067///
10068/// # let client = hyper_util::client::legacy::Client::builder(
10069/// # hyper_util::rt::TokioExecutor::new()
10070/// # )
10071/// # .build(
10072/// # hyper_rustls::HttpsConnectorBuilder::new()
10073/// # .with_native_roots()
10074/// # .unwrap()
10075/// # .https_or_http()
10076/// # .enable_http2()
10077/// # .build()
10078/// # );
10079/// # let mut hub = CalendarHub::new(client, auth);
10080/// // You can configure optional parameters by calling the respective setters at will, and
10081/// // execute the final call using `doit()`.
10082/// // Values shown here are possibly random and not representative !
10083/// let result = hub.events().delete("calendarId", "eventId")
10084/// .send_updates("sed")
10085/// .send_notifications(true)
10086/// .doit().await;
10087/// # }
10088/// ```
10089pub struct EventDeleteCall<'a, C>
10090where
10091 C: 'a,
10092{
10093 hub: &'a CalendarHub<C>,
10094 _calendar_id: String,
10095 _event_id: String,
10096 _send_updates: Option<String>,
10097 _send_notifications: Option<bool>,
10098 _delegate: Option<&'a mut dyn common::Delegate>,
10099 _additional_params: HashMap<String, String>,
10100 _scopes: BTreeSet<String>,
10101}
10102
10103impl<'a, C> common::CallBuilder for EventDeleteCall<'a, C> {}
10104
10105impl<'a, C> EventDeleteCall<'a, C>
10106where
10107 C: common::Connector,
10108{
10109 /// Perform the operation you have build so far.
10110 pub async fn doit(mut self) -> common::Result<common::Response> {
10111 use std::borrow::Cow;
10112 use std::io::{Read, Seek};
10113
10114 use common::{url::Params, ToParts};
10115 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
10116
10117 let mut dd = common::DefaultDelegate;
10118 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
10119 dlg.begin(common::MethodInfo {
10120 id: "calendar.events.delete",
10121 http_method: hyper::Method::DELETE,
10122 });
10123
10124 for &field in ["calendarId", "eventId", "sendUpdates", "sendNotifications"].iter() {
10125 if self._additional_params.contains_key(field) {
10126 dlg.finished(false);
10127 return Err(common::Error::FieldClash(field));
10128 }
10129 }
10130
10131 let mut params = Params::with_capacity(5 + self._additional_params.len());
10132 params.push("calendarId", self._calendar_id);
10133 params.push("eventId", self._event_id);
10134 if let Some(value) = self._send_updates.as_ref() {
10135 params.push("sendUpdates", value);
10136 }
10137 if let Some(value) = self._send_notifications.as_ref() {
10138 params.push("sendNotifications", value.to_string());
10139 }
10140
10141 params.extend(self._additional_params.iter());
10142
10143 let mut url = self.hub._base_url.clone() + "calendars/{calendarId}/events/{eventId}";
10144 if self._scopes.is_empty() {
10145 self._scopes.insert(Scope::Full.as_ref().to_string());
10146 }
10147
10148 #[allow(clippy::single_element_loop)]
10149 for &(find_this, param_name) in
10150 [("{calendarId}", "calendarId"), ("{eventId}", "eventId")].iter()
10151 {
10152 url = params.uri_replacement(url, param_name, find_this, false);
10153 }
10154 {
10155 let to_remove = ["eventId", "calendarId"];
10156 params.remove_params(&to_remove);
10157 }
10158
10159 let url = params.parse_with_url(&url);
10160
10161 loop {
10162 let token = match self
10163 .hub
10164 .auth
10165 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
10166 .await
10167 {
10168 Ok(token) => token,
10169 Err(e) => match dlg.token(e) {
10170 Ok(token) => token,
10171 Err(e) => {
10172 dlg.finished(false);
10173 return Err(common::Error::MissingToken(e));
10174 }
10175 },
10176 };
10177 let mut req_result = {
10178 let client = &self.hub.client;
10179 dlg.pre_request();
10180 let mut req_builder = hyper::Request::builder()
10181 .method(hyper::Method::DELETE)
10182 .uri(url.as_str())
10183 .header(USER_AGENT, self.hub._user_agent.clone());
10184
10185 if let Some(token) = token.as_ref() {
10186 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
10187 }
10188
10189 let request = req_builder
10190 .header(CONTENT_LENGTH, 0_u64)
10191 .body(common::to_body::<String>(None));
10192
10193 client.request(request.unwrap()).await
10194 };
10195
10196 match req_result {
10197 Err(err) => {
10198 if let common::Retry::After(d) = dlg.http_error(&err) {
10199 sleep(d).await;
10200 continue;
10201 }
10202 dlg.finished(false);
10203 return Err(common::Error::HttpError(err));
10204 }
10205 Ok(res) => {
10206 let (mut parts, body) = res.into_parts();
10207 let mut body = common::Body::new(body);
10208 if !parts.status.is_success() {
10209 let bytes = common::to_bytes(body).await.unwrap_or_default();
10210 let error = serde_json::from_str(&common::to_string(&bytes));
10211 let response = common::to_response(parts, bytes.into());
10212
10213 if let common::Retry::After(d) =
10214 dlg.http_failure(&response, error.as_ref().ok())
10215 {
10216 sleep(d).await;
10217 continue;
10218 }
10219
10220 dlg.finished(false);
10221
10222 return Err(match error {
10223 Ok(value) => common::Error::BadRequest(value),
10224 _ => common::Error::Failure(response),
10225 });
10226 }
10227 let response = common::Response::from_parts(parts, body);
10228
10229 dlg.finished(true);
10230 return Ok(response);
10231 }
10232 }
10233 }
10234 }
10235
10236 /// 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.
10237 ///
10238 /// Sets the *calendar id* path property to the given value.
10239 ///
10240 /// Even though the property as already been set when instantiating this call,
10241 /// we provide this method for API completeness.
10242 pub fn calendar_id(mut self, new_value: &str) -> EventDeleteCall<'a, C> {
10243 self._calendar_id = new_value.to_string();
10244 self
10245 }
10246 /// Event identifier.
10247 ///
10248 /// Sets the *event id* path property to the given value.
10249 ///
10250 /// Even though the property as already been set when instantiating this call,
10251 /// we provide this method for API completeness.
10252 pub fn event_id(mut self, new_value: &str) -> EventDeleteCall<'a, C> {
10253 self._event_id = new_value.to_string();
10254 self
10255 }
10256 /// Guests who should receive notifications about the deletion of the event.
10257 ///
10258 /// Sets the *send updates* query property to the given value.
10259 pub fn send_updates(mut self, new_value: &str) -> EventDeleteCall<'a, C> {
10260 self._send_updates = Some(new_value.to_string());
10261 self
10262 }
10263 /// Deprecated. Please use sendUpdates instead.
10264 ///
10265 /// 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.
10266 ///
10267 /// Sets the *send notifications* query property to the given value.
10268 pub fn send_notifications(mut self, new_value: bool) -> EventDeleteCall<'a, C> {
10269 self._send_notifications = Some(new_value);
10270 self
10271 }
10272 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
10273 /// while executing the actual API request.
10274 ///
10275 /// ````text
10276 /// It should be used to handle progress information, and to implement a certain level of resilience.
10277 /// ````
10278 ///
10279 /// Sets the *delegate* property to the given value.
10280 pub fn delegate(mut self, new_value: &'a mut dyn common::Delegate) -> EventDeleteCall<'a, C> {
10281 self._delegate = Some(new_value);
10282 self
10283 }
10284
10285 /// Set any additional parameter of the query string used in the request.
10286 /// It should be used to set parameters which are not yet available through their own
10287 /// setters.
10288 ///
10289 /// Please note that this method must not be used to set any of the known parameters
10290 /// which have their own setter method. If done anyway, the request will fail.
10291 ///
10292 /// # Additional Parameters
10293 ///
10294 /// * *alt* (query-string) - Data format for the response.
10295 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
10296 /// * *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.
10297 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
10298 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
10299 /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
10300 /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
10301 pub fn param<T>(mut self, name: T, value: T) -> EventDeleteCall<'a, C>
10302 where
10303 T: AsRef<str>,
10304 {
10305 self._additional_params
10306 .insert(name.as_ref().to_string(), value.as_ref().to_string());
10307 self
10308 }
10309
10310 /// Identifies the authorization scope for the method you are building.
10311 ///
10312 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
10313 /// [`Scope::Full`].
10314 ///
10315 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
10316 /// tokens for more than one scope.
10317 ///
10318 /// Usually there is more than one suitable scope to authorize an operation, some of which may
10319 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
10320 /// sufficient, a read-write scope will do as well.
10321 pub fn add_scope<St>(mut self, scope: St) -> EventDeleteCall<'a, C>
10322 where
10323 St: AsRef<str>,
10324 {
10325 self._scopes.insert(String::from(scope.as_ref()));
10326 self
10327 }
10328 /// Identifies the authorization scope(s) for the method you are building.
10329 ///
10330 /// See [`Self::add_scope()`] for details.
10331 pub fn add_scopes<I, St>(mut self, scopes: I) -> EventDeleteCall<'a, C>
10332 where
10333 I: IntoIterator<Item = St>,
10334 St: AsRef<str>,
10335 {
10336 self._scopes
10337 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
10338 self
10339 }
10340
10341 /// Removes all scopes, and no default scope will be used either.
10342 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
10343 /// for details).
10344 pub fn clear_scopes(mut self) -> EventDeleteCall<'a, C> {
10345 self._scopes.clear();
10346 self
10347 }
10348}
10349
10350/// 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.
10351///
10352/// A builder for the *get* method supported by a *event* resource.
10353/// It is not used directly, but through a [`EventMethods`] instance.
10354///
10355/// # Example
10356///
10357/// Instantiate a resource method builder
10358///
10359/// ```test_harness,no_run
10360/// # extern crate hyper;
10361/// # extern crate hyper_rustls;
10362/// # extern crate google_calendar3 as calendar3;
10363/// # async fn dox() {
10364/// # use calendar3::{CalendarHub, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
10365///
10366/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
10367/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
10368/// # .with_native_roots()
10369/// # .unwrap()
10370/// # .https_only()
10371/// # .enable_http2()
10372/// # .build();
10373///
10374/// # let executor = hyper_util::rt::TokioExecutor::new();
10375/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
10376/// # secret,
10377/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
10378/// # yup_oauth2::client::CustomHyperClientBuilder::from(
10379/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
10380/// # ),
10381/// # ).build().await.unwrap();
10382///
10383/// # let client = hyper_util::client::legacy::Client::builder(
10384/// # hyper_util::rt::TokioExecutor::new()
10385/// # )
10386/// # .build(
10387/// # hyper_rustls::HttpsConnectorBuilder::new()
10388/// # .with_native_roots()
10389/// # .unwrap()
10390/// # .https_or_http()
10391/// # .enable_http2()
10392/// # .build()
10393/// # );
10394/// # let mut hub = CalendarHub::new(client, auth);
10395/// // You can configure optional parameters by calling the respective setters at will, and
10396/// // execute the final call using `doit()`.
10397/// // Values shown here are possibly random and not representative !
10398/// let result = hub.events().get("calendarId", "eventId")
10399/// .time_zone("sadipscing")
10400/// .max_attendees(-32)
10401/// .always_include_email(true)
10402/// .doit().await;
10403/// # }
10404/// ```
10405pub struct EventGetCall<'a, C>
10406where
10407 C: 'a,
10408{
10409 hub: &'a CalendarHub<C>,
10410 _calendar_id: String,
10411 _event_id: String,
10412 _time_zone: Option<String>,
10413 _max_attendees: Option<i32>,
10414 _always_include_email: Option<bool>,
10415 _delegate: Option<&'a mut dyn common::Delegate>,
10416 _additional_params: HashMap<String, String>,
10417 _scopes: BTreeSet<String>,
10418}
10419
10420impl<'a, C> common::CallBuilder for EventGetCall<'a, C> {}
10421
10422impl<'a, C> EventGetCall<'a, C>
10423where
10424 C: common::Connector,
10425{
10426 /// Perform the operation you have build so far.
10427 pub async fn doit(mut self) -> common::Result<(common::Response, Event)> {
10428 use std::borrow::Cow;
10429 use std::io::{Read, Seek};
10430
10431 use common::{url::Params, ToParts};
10432 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
10433
10434 let mut dd = common::DefaultDelegate;
10435 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
10436 dlg.begin(common::MethodInfo {
10437 id: "calendar.events.get",
10438 http_method: hyper::Method::GET,
10439 });
10440
10441 for &field in [
10442 "alt",
10443 "calendarId",
10444 "eventId",
10445 "timeZone",
10446 "maxAttendees",
10447 "alwaysIncludeEmail",
10448 ]
10449 .iter()
10450 {
10451 if self._additional_params.contains_key(field) {
10452 dlg.finished(false);
10453 return Err(common::Error::FieldClash(field));
10454 }
10455 }
10456
10457 let mut params = Params::with_capacity(7 + self._additional_params.len());
10458 params.push("calendarId", self._calendar_id);
10459 params.push("eventId", self._event_id);
10460 if let Some(value) = self._time_zone.as_ref() {
10461 params.push("timeZone", value);
10462 }
10463 if let Some(value) = self._max_attendees.as_ref() {
10464 params.push("maxAttendees", value.to_string());
10465 }
10466 if let Some(value) = self._always_include_email.as_ref() {
10467 params.push("alwaysIncludeEmail", value.to_string());
10468 }
10469
10470 params.extend(self._additional_params.iter());
10471
10472 params.push("alt", "json");
10473 let mut url = self.hub._base_url.clone() + "calendars/{calendarId}/events/{eventId}";
10474 if self._scopes.is_empty() {
10475 self._scopes
10476 .insert(Scope::EventOwnedReadonly.as_ref().to_string());
10477 }
10478
10479 #[allow(clippy::single_element_loop)]
10480 for &(find_this, param_name) in
10481 [("{calendarId}", "calendarId"), ("{eventId}", "eventId")].iter()
10482 {
10483 url = params.uri_replacement(url, param_name, find_this, false);
10484 }
10485 {
10486 let to_remove = ["eventId", "calendarId"];
10487 params.remove_params(&to_remove);
10488 }
10489
10490 let url = params.parse_with_url(&url);
10491
10492 loop {
10493 let token = match self
10494 .hub
10495 .auth
10496 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
10497 .await
10498 {
10499 Ok(token) => token,
10500 Err(e) => match dlg.token(e) {
10501 Ok(token) => token,
10502 Err(e) => {
10503 dlg.finished(false);
10504 return Err(common::Error::MissingToken(e));
10505 }
10506 },
10507 };
10508 let mut req_result = {
10509 let client = &self.hub.client;
10510 dlg.pre_request();
10511 let mut req_builder = hyper::Request::builder()
10512 .method(hyper::Method::GET)
10513 .uri(url.as_str())
10514 .header(USER_AGENT, self.hub._user_agent.clone());
10515
10516 if let Some(token) = token.as_ref() {
10517 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
10518 }
10519
10520 let request = req_builder
10521 .header(CONTENT_LENGTH, 0_u64)
10522 .body(common::to_body::<String>(None));
10523
10524 client.request(request.unwrap()).await
10525 };
10526
10527 match req_result {
10528 Err(err) => {
10529 if let common::Retry::After(d) = dlg.http_error(&err) {
10530 sleep(d).await;
10531 continue;
10532 }
10533 dlg.finished(false);
10534 return Err(common::Error::HttpError(err));
10535 }
10536 Ok(res) => {
10537 let (mut parts, body) = res.into_parts();
10538 let mut body = common::Body::new(body);
10539 if !parts.status.is_success() {
10540 let bytes = common::to_bytes(body).await.unwrap_or_default();
10541 let error = serde_json::from_str(&common::to_string(&bytes));
10542 let response = common::to_response(parts, bytes.into());
10543
10544 if let common::Retry::After(d) =
10545 dlg.http_failure(&response, error.as_ref().ok())
10546 {
10547 sleep(d).await;
10548 continue;
10549 }
10550
10551 dlg.finished(false);
10552
10553 return Err(match error {
10554 Ok(value) => common::Error::BadRequest(value),
10555 _ => common::Error::Failure(response),
10556 });
10557 }
10558 let response = {
10559 let bytes = common::to_bytes(body).await.unwrap_or_default();
10560 let encoded = common::to_string(&bytes);
10561 match serde_json::from_str(&encoded) {
10562 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
10563 Err(error) => {
10564 dlg.response_json_decode_error(&encoded, &error);
10565 return Err(common::Error::JsonDecodeError(
10566 encoded.to_string(),
10567 error,
10568 ));
10569 }
10570 }
10571 };
10572
10573 dlg.finished(true);
10574 return Ok(response);
10575 }
10576 }
10577 }
10578 }
10579
10580 /// 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.
10581 ///
10582 /// Sets the *calendar id* path property to the given value.
10583 ///
10584 /// Even though the property as already been set when instantiating this call,
10585 /// we provide this method for API completeness.
10586 pub fn calendar_id(mut self, new_value: &str) -> EventGetCall<'a, C> {
10587 self._calendar_id = new_value.to_string();
10588 self
10589 }
10590 /// Event identifier.
10591 ///
10592 /// Sets the *event id* path property to the given value.
10593 ///
10594 /// Even though the property as already been set when instantiating this call,
10595 /// we provide this method for API completeness.
10596 pub fn event_id(mut self, new_value: &str) -> EventGetCall<'a, C> {
10597 self._event_id = new_value.to_string();
10598 self
10599 }
10600 /// Time zone used in the response. Optional. The default is the time zone of the calendar.
10601 ///
10602 /// Sets the *time zone* query property to the given value.
10603 pub fn time_zone(mut self, new_value: &str) -> EventGetCall<'a, C> {
10604 self._time_zone = Some(new_value.to_string());
10605 self
10606 }
10607 /// 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.
10608 ///
10609 /// Sets the *max attendees* query property to the given value.
10610 pub fn max_attendees(mut self, new_value: i32) -> EventGetCall<'a, C> {
10611 self._max_attendees = Some(new_value);
10612 self
10613 }
10614 /// 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).
10615 ///
10616 /// Sets the *always include email* query property to the given value.
10617 pub fn always_include_email(mut self, new_value: bool) -> EventGetCall<'a, C> {
10618 self._always_include_email = Some(new_value);
10619 self
10620 }
10621 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
10622 /// while executing the actual API request.
10623 ///
10624 /// ````text
10625 /// It should be used to handle progress information, and to implement a certain level of resilience.
10626 /// ````
10627 ///
10628 /// Sets the *delegate* property to the given value.
10629 pub fn delegate(mut self, new_value: &'a mut dyn common::Delegate) -> EventGetCall<'a, C> {
10630 self._delegate = Some(new_value);
10631 self
10632 }
10633
10634 /// Set any additional parameter of the query string used in the request.
10635 /// It should be used to set parameters which are not yet available through their own
10636 /// setters.
10637 ///
10638 /// Please note that this method must not be used to set any of the known parameters
10639 /// which have their own setter method. If done anyway, the request will fail.
10640 ///
10641 /// # Additional Parameters
10642 ///
10643 /// * *alt* (query-string) - Data format for the response.
10644 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
10645 /// * *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.
10646 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
10647 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
10648 /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
10649 /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
10650 pub fn param<T>(mut self, name: T, value: T) -> EventGetCall<'a, C>
10651 where
10652 T: AsRef<str>,
10653 {
10654 self._additional_params
10655 .insert(name.as_ref().to_string(), value.as_ref().to_string());
10656 self
10657 }
10658
10659 /// Identifies the authorization scope for the method you are building.
10660 ///
10661 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
10662 /// [`Scope::EventOwnedReadonly`].
10663 ///
10664 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
10665 /// tokens for more than one scope.
10666 ///
10667 /// Usually there is more than one suitable scope to authorize an operation, some of which may
10668 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
10669 /// sufficient, a read-write scope will do as well.
10670 pub fn add_scope<St>(mut self, scope: St) -> EventGetCall<'a, C>
10671 where
10672 St: AsRef<str>,
10673 {
10674 self._scopes.insert(String::from(scope.as_ref()));
10675 self
10676 }
10677 /// Identifies the authorization scope(s) for the method you are building.
10678 ///
10679 /// See [`Self::add_scope()`] for details.
10680 pub fn add_scopes<I, St>(mut self, scopes: I) -> EventGetCall<'a, C>
10681 where
10682 I: IntoIterator<Item = St>,
10683 St: AsRef<str>,
10684 {
10685 self._scopes
10686 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
10687 self
10688 }
10689
10690 /// Removes all scopes, and no default scope will be used either.
10691 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
10692 /// for details).
10693 pub fn clear_scopes(mut self) -> EventGetCall<'a, C> {
10694 self._scopes.clear();
10695 self
10696 }
10697}
10698
10699/// 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.
10700/// 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.
10701///
10702/// A builder for the *import* method supported by a *event* resource.
10703/// It is not used directly, but through a [`EventMethods`] instance.
10704///
10705/// # Example
10706///
10707/// Instantiate a resource method builder
10708///
10709/// ```test_harness,no_run
10710/// # extern crate hyper;
10711/// # extern crate hyper_rustls;
10712/// # extern crate google_calendar3 as calendar3;
10713/// use calendar3::api::Event;
10714/// # async fn dox() {
10715/// # use calendar3::{CalendarHub, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
10716///
10717/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
10718/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
10719/// # .with_native_roots()
10720/// # .unwrap()
10721/// # .https_only()
10722/// # .enable_http2()
10723/// # .build();
10724///
10725/// # let executor = hyper_util::rt::TokioExecutor::new();
10726/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
10727/// # secret,
10728/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
10729/// # yup_oauth2::client::CustomHyperClientBuilder::from(
10730/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
10731/// # ),
10732/// # ).build().await.unwrap();
10733///
10734/// # let client = hyper_util::client::legacy::Client::builder(
10735/// # hyper_util::rt::TokioExecutor::new()
10736/// # )
10737/// # .build(
10738/// # hyper_rustls::HttpsConnectorBuilder::new()
10739/// # .with_native_roots()
10740/// # .unwrap()
10741/// # .https_or_http()
10742/// # .enable_http2()
10743/// # .build()
10744/// # );
10745/// # let mut hub = CalendarHub::new(client, auth);
10746/// // As the method needs a request, you would usually fill it with the desired information
10747/// // into the respective structure. Some of the parts shown here might not be applicable !
10748/// // Values shown here are possibly random and not representative !
10749/// let mut req = Event::default();
10750///
10751/// // You can configure optional parameters by calling the respective setters at will, and
10752/// // execute the final call using `doit()`.
10753/// // Values shown here are possibly random and not representative !
10754/// let result = hub.events().import(req, "calendarId")
10755/// .supports_attachments(false)
10756/// .conference_data_version(-47)
10757/// .doit().await;
10758/// # }
10759/// ```
10760pub struct EventImportCall<'a, C>
10761where
10762 C: 'a,
10763{
10764 hub: &'a CalendarHub<C>,
10765 _request: Event,
10766 _calendar_id: String,
10767 _supports_attachments: Option<bool>,
10768 _conference_data_version: Option<i32>,
10769 _delegate: Option<&'a mut dyn common::Delegate>,
10770 _additional_params: HashMap<String, String>,
10771 _scopes: BTreeSet<String>,
10772}
10773
10774impl<'a, C> common::CallBuilder for EventImportCall<'a, C> {}
10775
10776impl<'a, C> EventImportCall<'a, C>
10777where
10778 C: common::Connector,
10779{
10780 /// Perform the operation you have build so far.
10781 pub async fn doit(mut self) -> common::Result<(common::Response, Event)> {
10782 use std::borrow::Cow;
10783 use std::io::{Read, Seek};
10784
10785 use common::{url::Params, ToParts};
10786 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
10787
10788 let mut dd = common::DefaultDelegate;
10789 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
10790 dlg.begin(common::MethodInfo {
10791 id: "calendar.events.import",
10792 http_method: hyper::Method::POST,
10793 });
10794
10795 for &field in [
10796 "alt",
10797 "calendarId",
10798 "supportsAttachments",
10799 "conferenceDataVersion",
10800 ]
10801 .iter()
10802 {
10803 if self._additional_params.contains_key(field) {
10804 dlg.finished(false);
10805 return Err(common::Error::FieldClash(field));
10806 }
10807 }
10808
10809 let mut params = Params::with_capacity(6 + self._additional_params.len());
10810 params.push("calendarId", self._calendar_id);
10811 if let Some(value) = self._supports_attachments.as_ref() {
10812 params.push("supportsAttachments", value.to_string());
10813 }
10814 if let Some(value) = self._conference_data_version.as_ref() {
10815 params.push("conferenceDataVersion", value.to_string());
10816 }
10817
10818 params.extend(self._additional_params.iter());
10819
10820 params.push("alt", "json");
10821 let mut url = self.hub._base_url.clone() + "calendars/{calendarId}/events/import";
10822 if self._scopes.is_empty() {
10823 self._scopes.insert(Scope::Full.as_ref().to_string());
10824 }
10825
10826 #[allow(clippy::single_element_loop)]
10827 for &(find_this, param_name) in [("{calendarId}", "calendarId")].iter() {
10828 url = params.uri_replacement(url, param_name, find_this, false);
10829 }
10830 {
10831 let to_remove = ["calendarId"];
10832 params.remove_params(&to_remove);
10833 }
10834
10835 let url = params.parse_with_url(&url);
10836
10837 let mut json_mime_type = mime::APPLICATION_JSON;
10838 let mut request_value_reader = {
10839 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
10840 common::remove_json_null_values(&mut value);
10841 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
10842 serde_json::to_writer(&mut dst, &value).unwrap();
10843 dst
10844 };
10845 let request_size = request_value_reader
10846 .seek(std::io::SeekFrom::End(0))
10847 .unwrap();
10848 request_value_reader
10849 .seek(std::io::SeekFrom::Start(0))
10850 .unwrap();
10851
10852 loop {
10853 let token = match self
10854 .hub
10855 .auth
10856 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
10857 .await
10858 {
10859 Ok(token) => token,
10860 Err(e) => match dlg.token(e) {
10861 Ok(token) => token,
10862 Err(e) => {
10863 dlg.finished(false);
10864 return Err(common::Error::MissingToken(e));
10865 }
10866 },
10867 };
10868 request_value_reader
10869 .seek(std::io::SeekFrom::Start(0))
10870 .unwrap();
10871 let mut req_result = {
10872 let client = &self.hub.client;
10873 dlg.pre_request();
10874 let mut req_builder = hyper::Request::builder()
10875 .method(hyper::Method::POST)
10876 .uri(url.as_str())
10877 .header(USER_AGENT, self.hub._user_agent.clone());
10878
10879 if let Some(token) = token.as_ref() {
10880 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
10881 }
10882
10883 let request = req_builder
10884 .header(CONTENT_TYPE, json_mime_type.to_string())
10885 .header(CONTENT_LENGTH, request_size as u64)
10886 .body(common::to_body(
10887 request_value_reader.get_ref().clone().into(),
10888 ));
10889
10890 client.request(request.unwrap()).await
10891 };
10892
10893 match req_result {
10894 Err(err) => {
10895 if let common::Retry::After(d) = dlg.http_error(&err) {
10896 sleep(d).await;
10897 continue;
10898 }
10899 dlg.finished(false);
10900 return Err(common::Error::HttpError(err));
10901 }
10902 Ok(res) => {
10903 let (mut parts, body) = res.into_parts();
10904 let mut body = common::Body::new(body);
10905 if !parts.status.is_success() {
10906 let bytes = common::to_bytes(body).await.unwrap_or_default();
10907 let error = serde_json::from_str(&common::to_string(&bytes));
10908 let response = common::to_response(parts, bytes.into());
10909
10910 if let common::Retry::After(d) =
10911 dlg.http_failure(&response, error.as_ref().ok())
10912 {
10913 sleep(d).await;
10914 continue;
10915 }
10916
10917 dlg.finished(false);
10918
10919 return Err(match error {
10920 Ok(value) => common::Error::BadRequest(value),
10921 _ => common::Error::Failure(response),
10922 });
10923 }
10924 let response = {
10925 let bytes = common::to_bytes(body).await.unwrap_or_default();
10926 let encoded = common::to_string(&bytes);
10927 match serde_json::from_str(&encoded) {
10928 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
10929 Err(error) => {
10930 dlg.response_json_decode_error(&encoded, &error);
10931 return Err(common::Error::JsonDecodeError(
10932 encoded.to_string(),
10933 error,
10934 ));
10935 }
10936 }
10937 };
10938
10939 dlg.finished(true);
10940 return Ok(response);
10941 }
10942 }
10943 }
10944 }
10945
10946 ///
10947 /// Sets the *request* property to the given value.
10948 ///
10949 /// Even though the property as already been set when instantiating this call,
10950 /// we provide this method for API completeness.
10951 pub fn request(mut self, new_value: Event) -> EventImportCall<'a, C> {
10952 self._request = new_value;
10953 self
10954 }
10955 /// 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.
10956 ///
10957 /// Sets the *calendar id* path property to the given value.
10958 ///
10959 /// Even though the property as already been set when instantiating this call,
10960 /// we provide this method for API completeness.
10961 pub fn calendar_id(mut self, new_value: &str) -> EventImportCall<'a, C> {
10962 self._calendar_id = new_value.to_string();
10963 self
10964 }
10965 /// Whether API client performing operation supports event attachments. Optional. The default is False.
10966 ///
10967 /// Sets the *supports attachments* query property to the given value.
10968 pub fn supports_attachments(mut self, new_value: bool) -> EventImportCall<'a, C> {
10969 self._supports_attachments = Some(new_value);
10970 self
10971 }
10972 /// 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.
10973 ///
10974 /// Sets the *conference data version* query property to the given value.
10975 pub fn conference_data_version(mut self, new_value: i32) -> EventImportCall<'a, C> {
10976 self._conference_data_version = Some(new_value);
10977 self
10978 }
10979 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
10980 /// while executing the actual API request.
10981 ///
10982 /// ````text
10983 /// It should be used to handle progress information, and to implement a certain level of resilience.
10984 /// ````
10985 ///
10986 /// Sets the *delegate* property to the given value.
10987 pub fn delegate(mut self, new_value: &'a mut dyn common::Delegate) -> EventImportCall<'a, C> {
10988 self._delegate = Some(new_value);
10989 self
10990 }
10991
10992 /// Set any additional parameter of the query string used in the request.
10993 /// It should be used to set parameters which are not yet available through their own
10994 /// setters.
10995 ///
10996 /// Please note that this method must not be used to set any of the known parameters
10997 /// which have their own setter method. If done anyway, the request will fail.
10998 ///
10999 /// # Additional Parameters
11000 ///
11001 /// * *alt* (query-string) - Data format for the response.
11002 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
11003 /// * *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.
11004 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
11005 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
11006 /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
11007 /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
11008 pub fn param<T>(mut self, name: T, value: T) -> EventImportCall<'a, C>
11009 where
11010 T: AsRef<str>,
11011 {
11012 self._additional_params
11013 .insert(name.as_ref().to_string(), value.as_ref().to_string());
11014 self
11015 }
11016
11017 /// Identifies the authorization scope for the method you are building.
11018 ///
11019 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
11020 /// [`Scope::Full`].
11021 ///
11022 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
11023 /// tokens for more than one scope.
11024 ///
11025 /// Usually there is more than one suitable scope to authorize an operation, some of which may
11026 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
11027 /// sufficient, a read-write scope will do as well.
11028 pub fn add_scope<St>(mut self, scope: St) -> EventImportCall<'a, C>
11029 where
11030 St: AsRef<str>,
11031 {
11032 self._scopes.insert(String::from(scope.as_ref()));
11033 self
11034 }
11035 /// Identifies the authorization scope(s) for the method you are building.
11036 ///
11037 /// See [`Self::add_scope()`] for details.
11038 pub fn add_scopes<I, St>(mut self, scopes: I) -> EventImportCall<'a, C>
11039 where
11040 I: IntoIterator<Item = St>,
11041 St: AsRef<str>,
11042 {
11043 self._scopes
11044 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
11045 self
11046 }
11047
11048 /// Removes all scopes, and no default scope will be used either.
11049 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
11050 /// for details).
11051 pub fn clear_scopes(mut self) -> EventImportCall<'a, C> {
11052 self._scopes.clear();
11053 self
11054 }
11055}
11056
11057/// Creates an event.
11058///
11059/// A builder for the *insert* method supported by a *event* resource.
11060/// It is not used directly, but through a [`EventMethods`] instance.
11061///
11062/// # Example
11063///
11064/// Instantiate a resource method builder
11065///
11066/// ```test_harness,no_run
11067/// # extern crate hyper;
11068/// # extern crate hyper_rustls;
11069/// # extern crate google_calendar3 as calendar3;
11070/// use calendar3::api::Event;
11071/// # async fn dox() {
11072/// # use calendar3::{CalendarHub, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
11073///
11074/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
11075/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
11076/// # .with_native_roots()
11077/// # .unwrap()
11078/// # .https_only()
11079/// # .enable_http2()
11080/// # .build();
11081///
11082/// # let executor = hyper_util::rt::TokioExecutor::new();
11083/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
11084/// # secret,
11085/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
11086/// # yup_oauth2::client::CustomHyperClientBuilder::from(
11087/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
11088/// # ),
11089/// # ).build().await.unwrap();
11090///
11091/// # let client = hyper_util::client::legacy::Client::builder(
11092/// # hyper_util::rt::TokioExecutor::new()
11093/// # )
11094/// # .build(
11095/// # hyper_rustls::HttpsConnectorBuilder::new()
11096/// # .with_native_roots()
11097/// # .unwrap()
11098/// # .https_or_http()
11099/// # .enable_http2()
11100/// # .build()
11101/// # );
11102/// # let mut hub = CalendarHub::new(client, auth);
11103/// // As the method needs a request, you would usually fill it with the desired information
11104/// // into the respective structure. Some of the parts shown here might not be applicable !
11105/// // Values shown here are possibly random and not representative !
11106/// let mut req = Event::default();
11107///
11108/// // You can configure optional parameters by calling the respective setters at will, and
11109/// // execute the final call using `doit()`.
11110/// // Values shown here are possibly random and not representative !
11111/// let result = hub.events().insert(req, "calendarId")
11112/// .supports_attachments(false)
11113/// .send_updates("consetetur")
11114/// .send_notifications(true)
11115/// .max_attendees(-7)
11116/// .conference_data_version(-82)
11117/// .doit().await;
11118/// # }
11119/// ```
11120pub struct EventInsertCall<'a, C>
11121where
11122 C: 'a,
11123{
11124 hub: &'a CalendarHub<C>,
11125 _request: Event,
11126 _calendar_id: String,
11127 _supports_attachments: Option<bool>,
11128 _send_updates: Option<String>,
11129 _send_notifications: Option<bool>,
11130 _max_attendees: Option<i32>,
11131 _conference_data_version: Option<i32>,
11132 _delegate: Option<&'a mut dyn common::Delegate>,
11133 _additional_params: HashMap<String, String>,
11134 _scopes: BTreeSet<String>,
11135}
11136
11137impl<'a, C> common::CallBuilder for EventInsertCall<'a, C> {}
11138
11139impl<'a, C> EventInsertCall<'a, C>
11140where
11141 C: common::Connector,
11142{
11143 /// Perform the operation you have build so far.
11144 pub async fn doit(mut self) -> common::Result<(common::Response, Event)> {
11145 use std::borrow::Cow;
11146 use std::io::{Read, Seek};
11147
11148 use common::{url::Params, ToParts};
11149 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
11150
11151 let mut dd = common::DefaultDelegate;
11152 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
11153 dlg.begin(common::MethodInfo {
11154 id: "calendar.events.insert",
11155 http_method: hyper::Method::POST,
11156 });
11157
11158 for &field in [
11159 "alt",
11160 "calendarId",
11161 "supportsAttachments",
11162 "sendUpdates",
11163 "sendNotifications",
11164 "maxAttendees",
11165 "conferenceDataVersion",
11166 ]
11167 .iter()
11168 {
11169 if self._additional_params.contains_key(field) {
11170 dlg.finished(false);
11171 return Err(common::Error::FieldClash(field));
11172 }
11173 }
11174
11175 let mut params = Params::with_capacity(9 + self._additional_params.len());
11176 params.push("calendarId", self._calendar_id);
11177 if let Some(value) = self._supports_attachments.as_ref() {
11178 params.push("supportsAttachments", value.to_string());
11179 }
11180 if let Some(value) = self._send_updates.as_ref() {
11181 params.push("sendUpdates", value);
11182 }
11183 if let Some(value) = self._send_notifications.as_ref() {
11184 params.push("sendNotifications", value.to_string());
11185 }
11186 if let Some(value) = self._max_attendees.as_ref() {
11187 params.push("maxAttendees", value.to_string());
11188 }
11189 if let Some(value) = self._conference_data_version.as_ref() {
11190 params.push("conferenceDataVersion", value.to_string());
11191 }
11192
11193 params.extend(self._additional_params.iter());
11194
11195 params.push("alt", "json");
11196 let mut url = self.hub._base_url.clone() + "calendars/{calendarId}/events";
11197 if self._scopes.is_empty() {
11198 self._scopes.insert(Scope::Full.as_ref().to_string());
11199 }
11200
11201 #[allow(clippy::single_element_loop)]
11202 for &(find_this, param_name) in [("{calendarId}", "calendarId")].iter() {
11203 url = params.uri_replacement(url, param_name, find_this, false);
11204 }
11205 {
11206 let to_remove = ["calendarId"];
11207 params.remove_params(&to_remove);
11208 }
11209
11210 let url = params.parse_with_url(&url);
11211
11212 let mut json_mime_type = mime::APPLICATION_JSON;
11213 let mut request_value_reader = {
11214 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
11215 common::remove_json_null_values(&mut value);
11216 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
11217 serde_json::to_writer(&mut dst, &value).unwrap();
11218 dst
11219 };
11220 let request_size = request_value_reader
11221 .seek(std::io::SeekFrom::End(0))
11222 .unwrap();
11223 request_value_reader
11224 .seek(std::io::SeekFrom::Start(0))
11225 .unwrap();
11226
11227 loop {
11228 let token = match self
11229 .hub
11230 .auth
11231 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
11232 .await
11233 {
11234 Ok(token) => token,
11235 Err(e) => match dlg.token(e) {
11236 Ok(token) => token,
11237 Err(e) => {
11238 dlg.finished(false);
11239 return Err(common::Error::MissingToken(e));
11240 }
11241 },
11242 };
11243 request_value_reader
11244 .seek(std::io::SeekFrom::Start(0))
11245 .unwrap();
11246 let mut req_result = {
11247 let client = &self.hub.client;
11248 dlg.pre_request();
11249 let mut req_builder = hyper::Request::builder()
11250 .method(hyper::Method::POST)
11251 .uri(url.as_str())
11252 .header(USER_AGENT, self.hub._user_agent.clone());
11253
11254 if let Some(token) = token.as_ref() {
11255 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
11256 }
11257
11258 let request = req_builder
11259 .header(CONTENT_TYPE, json_mime_type.to_string())
11260 .header(CONTENT_LENGTH, request_size as u64)
11261 .body(common::to_body(
11262 request_value_reader.get_ref().clone().into(),
11263 ));
11264
11265 client.request(request.unwrap()).await
11266 };
11267
11268 match req_result {
11269 Err(err) => {
11270 if let common::Retry::After(d) = dlg.http_error(&err) {
11271 sleep(d).await;
11272 continue;
11273 }
11274 dlg.finished(false);
11275 return Err(common::Error::HttpError(err));
11276 }
11277 Ok(res) => {
11278 let (mut parts, body) = res.into_parts();
11279 let mut body = common::Body::new(body);
11280 if !parts.status.is_success() {
11281 let bytes = common::to_bytes(body).await.unwrap_or_default();
11282 let error = serde_json::from_str(&common::to_string(&bytes));
11283 let response = common::to_response(parts, bytes.into());
11284
11285 if let common::Retry::After(d) =
11286 dlg.http_failure(&response, error.as_ref().ok())
11287 {
11288 sleep(d).await;
11289 continue;
11290 }
11291
11292 dlg.finished(false);
11293
11294 return Err(match error {
11295 Ok(value) => common::Error::BadRequest(value),
11296 _ => common::Error::Failure(response),
11297 });
11298 }
11299 let response = {
11300 let bytes = common::to_bytes(body).await.unwrap_or_default();
11301 let encoded = common::to_string(&bytes);
11302 match serde_json::from_str(&encoded) {
11303 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
11304 Err(error) => {
11305 dlg.response_json_decode_error(&encoded, &error);
11306 return Err(common::Error::JsonDecodeError(
11307 encoded.to_string(),
11308 error,
11309 ));
11310 }
11311 }
11312 };
11313
11314 dlg.finished(true);
11315 return Ok(response);
11316 }
11317 }
11318 }
11319 }
11320
11321 ///
11322 /// Sets the *request* property to the given value.
11323 ///
11324 /// Even though the property as already been set when instantiating this call,
11325 /// we provide this method for API completeness.
11326 pub fn request(mut self, new_value: Event) -> EventInsertCall<'a, C> {
11327 self._request = new_value;
11328 self
11329 }
11330 /// 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.
11331 ///
11332 /// Sets the *calendar id* path property to the given value.
11333 ///
11334 /// Even though the property as already been set when instantiating this call,
11335 /// we provide this method for API completeness.
11336 pub fn calendar_id(mut self, new_value: &str) -> EventInsertCall<'a, C> {
11337 self._calendar_id = new_value.to_string();
11338 self
11339 }
11340 /// Whether API client performing operation supports event attachments. Optional. The default is False.
11341 ///
11342 /// Sets the *supports attachments* query property to the given value.
11343 pub fn supports_attachments(mut self, new_value: bool) -> EventInsertCall<'a, C> {
11344 self._supports_attachments = Some(new_value);
11345 self
11346 }
11347 /// Whether to send notifications about the creation of the new event. Note that some emails might still be sent. The default is false.
11348 ///
11349 /// Sets the *send updates* query property to the given value.
11350 pub fn send_updates(mut self, new_value: &str) -> EventInsertCall<'a, C> {
11351 self._send_updates = Some(new_value.to_string());
11352 self
11353 }
11354 /// Deprecated. Please use sendUpdates instead.
11355 ///
11356 /// 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.
11357 ///
11358 /// Sets the *send notifications* query property to the given value.
11359 pub fn send_notifications(mut self, new_value: bool) -> EventInsertCall<'a, C> {
11360 self._send_notifications = Some(new_value);
11361 self
11362 }
11363 /// 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.
11364 ///
11365 /// Sets the *max attendees* query property to the given value.
11366 pub fn max_attendees(mut self, new_value: i32) -> EventInsertCall<'a, C> {
11367 self._max_attendees = Some(new_value);
11368 self
11369 }
11370 /// 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.
11371 ///
11372 /// Sets the *conference data version* query property to the given value.
11373 pub fn conference_data_version(mut self, new_value: i32) -> EventInsertCall<'a, C> {
11374 self._conference_data_version = Some(new_value);
11375 self
11376 }
11377 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
11378 /// while executing the actual API request.
11379 ///
11380 /// ````text
11381 /// It should be used to handle progress information, and to implement a certain level of resilience.
11382 /// ````
11383 ///
11384 /// Sets the *delegate* property to the given value.
11385 pub fn delegate(mut self, new_value: &'a mut dyn common::Delegate) -> EventInsertCall<'a, C> {
11386 self._delegate = Some(new_value);
11387 self
11388 }
11389
11390 /// Set any additional parameter of the query string used in the request.
11391 /// It should be used to set parameters which are not yet available through their own
11392 /// setters.
11393 ///
11394 /// Please note that this method must not be used to set any of the known parameters
11395 /// which have their own setter method. If done anyway, the request will fail.
11396 ///
11397 /// # Additional Parameters
11398 ///
11399 /// * *alt* (query-string) - Data format for the response.
11400 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
11401 /// * *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.
11402 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
11403 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
11404 /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
11405 /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
11406 pub fn param<T>(mut self, name: T, value: T) -> EventInsertCall<'a, C>
11407 where
11408 T: AsRef<str>,
11409 {
11410 self._additional_params
11411 .insert(name.as_ref().to_string(), value.as_ref().to_string());
11412 self
11413 }
11414
11415 /// Identifies the authorization scope for the method you are building.
11416 ///
11417 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
11418 /// [`Scope::Full`].
11419 ///
11420 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
11421 /// tokens for more than one scope.
11422 ///
11423 /// Usually there is more than one suitable scope to authorize an operation, some of which may
11424 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
11425 /// sufficient, a read-write scope will do as well.
11426 pub fn add_scope<St>(mut self, scope: St) -> EventInsertCall<'a, C>
11427 where
11428 St: AsRef<str>,
11429 {
11430 self._scopes.insert(String::from(scope.as_ref()));
11431 self
11432 }
11433 /// Identifies the authorization scope(s) for the method you are building.
11434 ///
11435 /// See [`Self::add_scope()`] for details.
11436 pub fn add_scopes<I, St>(mut self, scopes: I) -> EventInsertCall<'a, C>
11437 where
11438 I: IntoIterator<Item = St>,
11439 St: AsRef<str>,
11440 {
11441 self._scopes
11442 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
11443 self
11444 }
11445
11446 /// Removes all scopes, and no default scope will be used either.
11447 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
11448 /// for details).
11449 pub fn clear_scopes(mut self) -> EventInsertCall<'a, C> {
11450 self._scopes.clear();
11451 self
11452 }
11453}
11454
11455/// Returns instances of the specified recurring event.
11456///
11457/// A builder for the *instances* method supported by a *event* resource.
11458/// It is not used directly, but through a [`EventMethods`] instance.
11459///
11460/// # Example
11461///
11462/// Instantiate a resource method builder
11463///
11464/// ```test_harness,no_run
11465/// # extern crate hyper;
11466/// # extern crate hyper_rustls;
11467/// # extern crate google_calendar3 as calendar3;
11468/// # async fn dox() {
11469/// # use calendar3::{CalendarHub, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
11470///
11471/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
11472/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
11473/// # .with_native_roots()
11474/// # .unwrap()
11475/// # .https_only()
11476/// # .enable_http2()
11477/// # .build();
11478///
11479/// # let executor = hyper_util::rt::TokioExecutor::new();
11480/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
11481/// # secret,
11482/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
11483/// # yup_oauth2::client::CustomHyperClientBuilder::from(
11484/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
11485/// # ),
11486/// # ).build().await.unwrap();
11487///
11488/// # let client = hyper_util::client::legacy::Client::builder(
11489/// # hyper_util::rt::TokioExecutor::new()
11490/// # )
11491/// # .build(
11492/// # hyper_rustls::HttpsConnectorBuilder::new()
11493/// # .with_native_roots()
11494/// # .unwrap()
11495/// # .https_or_http()
11496/// # .enable_http2()
11497/// # .build()
11498/// # );
11499/// # let mut hub = CalendarHub::new(client, auth);
11500/// // You can configure optional parameters by calling the respective setters at will, and
11501/// // execute the final call using `doit()`.
11502/// // Values shown here are possibly random and not representative !
11503/// let result = hub.events().instances("calendarId", "eventId")
11504/// .time_zone("diam")
11505/// .time_min(chrono::Utc::now())
11506/// .time_max(chrono::Utc::now())
11507/// .show_deleted(true)
11508/// .page_token("sit")
11509/// .original_start("sed")
11510/// .max_results(-75)
11511/// .max_attendees(-56)
11512/// .always_include_email(true)
11513/// .doit().await;
11514/// # }
11515/// ```
11516pub struct EventInstanceCall<'a, C>
11517where
11518 C: 'a,
11519{
11520 hub: &'a CalendarHub<C>,
11521 _calendar_id: String,
11522 _event_id: String,
11523 _time_zone: Option<String>,
11524 _time_min: Option<chrono::DateTime<chrono::offset::Utc>>,
11525 _time_max: Option<chrono::DateTime<chrono::offset::Utc>>,
11526 _show_deleted: Option<bool>,
11527 _page_token: Option<String>,
11528 _original_start: Option<String>,
11529 _max_results: Option<i32>,
11530 _max_attendees: Option<i32>,
11531 _always_include_email: Option<bool>,
11532 _delegate: Option<&'a mut dyn common::Delegate>,
11533 _additional_params: HashMap<String, String>,
11534 _scopes: BTreeSet<String>,
11535}
11536
11537impl<'a, C> common::CallBuilder for EventInstanceCall<'a, C> {}
11538
11539impl<'a, C> EventInstanceCall<'a, C>
11540where
11541 C: common::Connector,
11542{
11543 /// Perform the operation you have build so far.
11544 pub async fn doit(mut self) -> common::Result<(common::Response, Events)> {
11545 use std::borrow::Cow;
11546 use std::io::{Read, Seek};
11547
11548 use common::{url::Params, ToParts};
11549 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
11550
11551 let mut dd = common::DefaultDelegate;
11552 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
11553 dlg.begin(common::MethodInfo {
11554 id: "calendar.events.instances",
11555 http_method: hyper::Method::GET,
11556 });
11557
11558 for &field in [
11559 "alt",
11560 "calendarId",
11561 "eventId",
11562 "timeZone",
11563 "timeMin",
11564 "timeMax",
11565 "showDeleted",
11566 "pageToken",
11567 "originalStart",
11568 "maxResults",
11569 "maxAttendees",
11570 "alwaysIncludeEmail",
11571 ]
11572 .iter()
11573 {
11574 if self._additional_params.contains_key(field) {
11575 dlg.finished(false);
11576 return Err(common::Error::FieldClash(field));
11577 }
11578 }
11579
11580 let mut params = Params::with_capacity(13 + self._additional_params.len());
11581 params.push("calendarId", self._calendar_id);
11582 params.push("eventId", self._event_id);
11583 if let Some(value) = self._time_zone.as_ref() {
11584 params.push("timeZone", value);
11585 }
11586 if let Some(value) = self._time_min.as_ref() {
11587 params.push("timeMin", common::serde::datetime_to_string(&value));
11588 }
11589 if let Some(value) = self._time_max.as_ref() {
11590 params.push("timeMax", common::serde::datetime_to_string(&value));
11591 }
11592 if let Some(value) = self._show_deleted.as_ref() {
11593 params.push("showDeleted", value.to_string());
11594 }
11595 if let Some(value) = self._page_token.as_ref() {
11596 params.push("pageToken", value);
11597 }
11598 if let Some(value) = self._original_start.as_ref() {
11599 params.push("originalStart", value);
11600 }
11601 if let Some(value) = self._max_results.as_ref() {
11602 params.push("maxResults", value.to_string());
11603 }
11604 if let Some(value) = self._max_attendees.as_ref() {
11605 params.push("maxAttendees", value.to_string());
11606 }
11607 if let Some(value) = self._always_include_email.as_ref() {
11608 params.push("alwaysIncludeEmail", value.to_string());
11609 }
11610
11611 params.extend(self._additional_params.iter());
11612
11613 params.push("alt", "json");
11614 let mut url =
11615 self.hub._base_url.clone() + "calendars/{calendarId}/events/{eventId}/instances";
11616 if self._scopes.is_empty() {
11617 self._scopes
11618 .insert(Scope::EventOwnedReadonly.as_ref().to_string());
11619 }
11620
11621 #[allow(clippy::single_element_loop)]
11622 for &(find_this, param_name) in
11623 [("{calendarId}", "calendarId"), ("{eventId}", "eventId")].iter()
11624 {
11625 url = params.uri_replacement(url, param_name, find_this, false);
11626 }
11627 {
11628 let to_remove = ["eventId", "calendarId"];
11629 params.remove_params(&to_remove);
11630 }
11631
11632 let url = params.parse_with_url(&url);
11633
11634 loop {
11635 let token = match self
11636 .hub
11637 .auth
11638 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
11639 .await
11640 {
11641 Ok(token) => token,
11642 Err(e) => match dlg.token(e) {
11643 Ok(token) => token,
11644 Err(e) => {
11645 dlg.finished(false);
11646 return Err(common::Error::MissingToken(e));
11647 }
11648 },
11649 };
11650 let mut req_result = {
11651 let client = &self.hub.client;
11652 dlg.pre_request();
11653 let mut req_builder = hyper::Request::builder()
11654 .method(hyper::Method::GET)
11655 .uri(url.as_str())
11656 .header(USER_AGENT, self.hub._user_agent.clone());
11657
11658 if let Some(token) = token.as_ref() {
11659 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
11660 }
11661
11662 let request = req_builder
11663 .header(CONTENT_LENGTH, 0_u64)
11664 .body(common::to_body::<String>(None));
11665
11666 client.request(request.unwrap()).await
11667 };
11668
11669 match req_result {
11670 Err(err) => {
11671 if let common::Retry::After(d) = dlg.http_error(&err) {
11672 sleep(d).await;
11673 continue;
11674 }
11675 dlg.finished(false);
11676 return Err(common::Error::HttpError(err));
11677 }
11678 Ok(res) => {
11679 let (mut parts, body) = res.into_parts();
11680 let mut body = common::Body::new(body);
11681 if !parts.status.is_success() {
11682 let bytes = common::to_bytes(body).await.unwrap_or_default();
11683 let error = serde_json::from_str(&common::to_string(&bytes));
11684 let response = common::to_response(parts, bytes.into());
11685
11686 if let common::Retry::After(d) =
11687 dlg.http_failure(&response, error.as_ref().ok())
11688 {
11689 sleep(d).await;
11690 continue;
11691 }
11692
11693 dlg.finished(false);
11694
11695 return Err(match error {
11696 Ok(value) => common::Error::BadRequest(value),
11697 _ => common::Error::Failure(response),
11698 });
11699 }
11700 let response = {
11701 let bytes = common::to_bytes(body).await.unwrap_or_default();
11702 let encoded = common::to_string(&bytes);
11703 match serde_json::from_str(&encoded) {
11704 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
11705 Err(error) => {
11706 dlg.response_json_decode_error(&encoded, &error);
11707 return Err(common::Error::JsonDecodeError(
11708 encoded.to_string(),
11709 error,
11710 ));
11711 }
11712 }
11713 };
11714
11715 dlg.finished(true);
11716 return Ok(response);
11717 }
11718 }
11719 }
11720 }
11721
11722 /// 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.
11723 ///
11724 /// Sets the *calendar id* path property to the given value.
11725 ///
11726 /// Even though the property as already been set when instantiating this call,
11727 /// we provide this method for API completeness.
11728 pub fn calendar_id(mut self, new_value: &str) -> EventInstanceCall<'a, C> {
11729 self._calendar_id = new_value.to_string();
11730 self
11731 }
11732 /// Recurring event identifier.
11733 ///
11734 /// Sets the *event id* path property to the given value.
11735 ///
11736 /// Even though the property as already been set when instantiating this call,
11737 /// we provide this method for API completeness.
11738 pub fn event_id(mut self, new_value: &str) -> EventInstanceCall<'a, C> {
11739 self._event_id = new_value.to_string();
11740 self
11741 }
11742 /// Time zone used in the response. Optional. The default is the time zone of the calendar.
11743 ///
11744 /// Sets the *time zone* query property to the given value.
11745 pub fn time_zone(mut self, new_value: &str) -> EventInstanceCall<'a, C> {
11746 self._time_zone = Some(new_value.to_string());
11747 self
11748 }
11749 /// 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.
11750 ///
11751 /// Sets the *time min* query property to the given value.
11752 pub fn time_min(
11753 mut self,
11754 new_value: chrono::DateTime<chrono::offset::Utc>,
11755 ) -> EventInstanceCall<'a, C> {
11756 self._time_min = Some(new_value);
11757 self
11758 }
11759 /// 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.
11760 ///
11761 /// Sets the *time max* query property to the given value.
11762 pub fn time_max(
11763 mut self,
11764 new_value: chrono::DateTime<chrono::offset::Utc>,
11765 ) -> EventInstanceCall<'a, C> {
11766 self._time_max = Some(new_value);
11767 self
11768 }
11769 /// 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.
11770 ///
11771 /// Sets the *show deleted* query property to the given value.
11772 pub fn show_deleted(mut self, new_value: bool) -> EventInstanceCall<'a, C> {
11773 self._show_deleted = Some(new_value);
11774 self
11775 }
11776 /// Token specifying which result page to return. Optional.
11777 ///
11778 /// Sets the *page token* query property to the given value.
11779 pub fn page_token(mut self, new_value: &str) -> EventInstanceCall<'a, C> {
11780 self._page_token = Some(new_value.to_string());
11781 self
11782 }
11783 /// The original start time of the instance in the result. Optional.
11784 ///
11785 /// Sets the *original start* query property to the given value.
11786 pub fn original_start(mut self, new_value: &str) -> EventInstanceCall<'a, C> {
11787 self._original_start = Some(new_value.to_string());
11788 self
11789 }
11790 /// 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.
11791 ///
11792 /// Sets the *max results* query property to the given value.
11793 pub fn max_results(mut self, new_value: i32) -> EventInstanceCall<'a, C> {
11794 self._max_results = Some(new_value);
11795 self
11796 }
11797 /// 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.
11798 ///
11799 /// Sets the *max attendees* query property to the given value.
11800 pub fn max_attendees(mut self, new_value: i32) -> EventInstanceCall<'a, C> {
11801 self._max_attendees = Some(new_value);
11802 self
11803 }
11804 /// 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).
11805 ///
11806 /// Sets the *always include email* query property to the given value.
11807 pub fn always_include_email(mut self, new_value: bool) -> EventInstanceCall<'a, C> {
11808 self._always_include_email = Some(new_value);
11809 self
11810 }
11811 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
11812 /// while executing the actual API request.
11813 ///
11814 /// ````text
11815 /// It should be used to handle progress information, and to implement a certain level of resilience.
11816 /// ````
11817 ///
11818 /// Sets the *delegate* property to the given value.
11819 pub fn delegate(mut self, new_value: &'a mut dyn common::Delegate) -> EventInstanceCall<'a, C> {
11820 self._delegate = Some(new_value);
11821 self
11822 }
11823
11824 /// Set any additional parameter of the query string used in the request.
11825 /// It should be used to set parameters which are not yet available through their own
11826 /// setters.
11827 ///
11828 /// Please note that this method must not be used to set any of the known parameters
11829 /// which have their own setter method. If done anyway, the request will fail.
11830 ///
11831 /// # Additional Parameters
11832 ///
11833 /// * *alt* (query-string) - Data format for the response.
11834 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
11835 /// * *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.
11836 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
11837 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
11838 /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
11839 /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
11840 pub fn param<T>(mut self, name: T, value: T) -> EventInstanceCall<'a, C>
11841 where
11842 T: AsRef<str>,
11843 {
11844 self._additional_params
11845 .insert(name.as_ref().to_string(), value.as_ref().to_string());
11846 self
11847 }
11848
11849 /// Identifies the authorization scope for the method you are building.
11850 ///
11851 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
11852 /// [`Scope::EventOwnedReadonly`].
11853 ///
11854 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
11855 /// tokens for more than one scope.
11856 ///
11857 /// Usually there is more than one suitable scope to authorize an operation, some of which may
11858 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
11859 /// sufficient, a read-write scope will do as well.
11860 pub fn add_scope<St>(mut self, scope: St) -> EventInstanceCall<'a, C>
11861 where
11862 St: AsRef<str>,
11863 {
11864 self._scopes.insert(String::from(scope.as_ref()));
11865 self
11866 }
11867 /// Identifies the authorization scope(s) for the method you are building.
11868 ///
11869 /// See [`Self::add_scope()`] for details.
11870 pub fn add_scopes<I, St>(mut self, scopes: I) -> EventInstanceCall<'a, C>
11871 where
11872 I: IntoIterator<Item = St>,
11873 St: AsRef<str>,
11874 {
11875 self._scopes
11876 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
11877 self
11878 }
11879
11880 /// Removes all scopes, and no default scope will be used either.
11881 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
11882 /// for details).
11883 pub fn clear_scopes(mut self) -> EventInstanceCall<'a, C> {
11884 self._scopes.clear();
11885 self
11886 }
11887}
11888
11889/// Returns events on the specified calendar.
11890///
11891/// A builder for the *list* method supported by a *event* resource.
11892/// It is not used directly, but through a [`EventMethods`] instance.
11893///
11894/// # Example
11895///
11896/// Instantiate a resource method builder
11897///
11898/// ```test_harness,no_run
11899/// # extern crate hyper;
11900/// # extern crate hyper_rustls;
11901/// # extern crate google_calendar3 as calendar3;
11902/// # async fn dox() {
11903/// # use calendar3::{CalendarHub, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
11904///
11905/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
11906/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
11907/// # .with_native_roots()
11908/// # .unwrap()
11909/// # .https_only()
11910/// # .enable_http2()
11911/// # .build();
11912///
11913/// # let executor = hyper_util::rt::TokioExecutor::new();
11914/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
11915/// # secret,
11916/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
11917/// # yup_oauth2::client::CustomHyperClientBuilder::from(
11918/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
11919/// # ),
11920/// # ).build().await.unwrap();
11921///
11922/// # let client = hyper_util::client::legacy::Client::builder(
11923/// # hyper_util::rt::TokioExecutor::new()
11924/// # )
11925/// # .build(
11926/// # hyper_rustls::HttpsConnectorBuilder::new()
11927/// # .with_native_roots()
11928/// # .unwrap()
11929/// # .https_or_http()
11930/// # .enable_http2()
11931/// # .build()
11932/// # );
11933/// # let mut hub = CalendarHub::new(client, auth);
11934/// // You can configure optional parameters by calling the respective setters at will, and
11935/// // execute the final call using `doit()`.
11936/// // Values shown here are possibly random and not representative !
11937/// let result = hub.events().list("calendarId")
11938/// .updated_min(chrono::Utc::now())
11939/// .time_zone("et")
11940/// .time_min(chrono::Utc::now())
11941/// .time_max(chrono::Utc::now())
11942/// .sync_token("At")
11943/// .single_events(false)
11944/// .show_hidden_invitations(true)
11945/// .show_deleted(true)
11946/// .add_shared_extended_property("accusam")
11947/// .q("amet")
11948/// .add_private_extended_property("erat")
11949/// .page_token("dolores")
11950/// .order_by("erat")
11951/// .max_results(-73)
11952/// .max_attendees(-10)
11953/// .i_cal_uid("takimata")
11954/// .add_event_types("Lorem")
11955/// .always_include_email(false)
11956/// .doit().await;
11957/// # }
11958/// ```
11959pub struct EventListCall<'a, C>
11960where
11961 C: 'a,
11962{
11963 hub: &'a CalendarHub<C>,
11964 _calendar_id: String,
11965 _updated_min: Option<chrono::DateTime<chrono::offset::Utc>>,
11966 _time_zone: Option<String>,
11967 _time_min: Option<chrono::DateTime<chrono::offset::Utc>>,
11968 _time_max: Option<chrono::DateTime<chrono::offset::Utc>>,
11969 _sync_token: Option<String>,
11970 _single_events: Option<bool>,
11971 _show_hidden_invitations: Option<bool>,
11972 _show_deleted: Option<bool>,
11973 _shared_extended_property: Vec<String>,
11974 _q: Option<String>,
11975 _private_extended_property: Vec<String>,
11976 _page_token: Option<String>,
11977 _order_by: Option<String>,
11978 _max_results: Option<i32>,
11979 _max_attendees: Option<i32>,
11980 _i_cal_uid: Option<String>,
11981 _event_types: Vec<String>,
11982 _always_include_email: Option<bool>,
11983 _delegate: Option<&'a mut dyn common::Delegate>,
11984 _additional_params: HashMap<String, String>,
11985 _scopes: BTreeSet<String>,
11986}
11987
11988impl<'a, C> common::CallBuilder for EventListCall<'a, C> {}
11989
11990impl<'a, C> EventListCall<'a, C>
11991where
11992 C: common::Connector,
11993{
11994 /// Perform the operation you have build so far.
11995 pub async fn doit(mut self) -> common::Result<(common::Response, Events)> {
11996 use std::borrow::Cow;
11997 use std::io::{Read, Seek};
11998
11999 use common::{url::Params, ToParts};
12000 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
12001
12002 let mut dd = common::DefaultDelegate;
12003 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
12004 dlg.begin(common::MethodInfo {
12005 id: "calendar.events.list",
12006 http_method: hyper::Method::GET,
12007 });
12008
12009 for &field in [
12010 "alt",
12011 "calendarId",
12012 "updatedMin",
12013 "timeZone",
12014 "timeMin",
12015 "timeMax",
12016 "syncToken",
12017 "singleEvents",
12018 "showHiddenInvitations",
12019 "showDeleted",
12020 "sharedExtendedProperty",
12021 "q",
12022 "privateExtendedProperty",
12023 "pageToken",
12024 "orderBy",
12025 "maxResults",
12026 "maxAttendees",
12027 "iCalUID",
12028 "eventTypes",
12029 "alwaysIncludeEmail",
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(21 + self._additional_params.len());
12040 params.push("calendarId", self._calendar_id);
12041 if let Some(value) = self._updated_min.as_ref() {
12042 params.push("updatedMin", common::serde::datetime_to_string(&value));
12043 }
12044 if let Some(value) = self._time_zone.as_ref() {
12045 params.push("timeZone", value);
12046 }
12047 if let Some(value) = self._time_min.as_ref() {
12048 params.push("timeMin", common::serde::datetime_to_string(&value));
12049 }
12050 if let Some(value) = self._time_max.as_ref() {
12051 params.push("timeMax", common::serde::datetime_to_string(&value));
12052 }
12053 if let Some(value) = self._sync_token.as_ref() {
12054 params.push("syncToken", value);
12055 }
12056 if let Some(value) = self._single_events.as_ref() {
12057 params.push("singleEvents", value.to_string());
12058 }
12059 if let Some(value) = self._show_hidden_invitations.as_ref() {
12060 params.push("showHiddenInvitations", value.to_string());
12061 }
12062 if let Some(value) = self._show_deleted.as_ref() {
12063 params.push("showDeleted", value.to_string());
12064 }
12065 if !self._shared_extended_property.is_empty() {
12066 for f in self._shared_extended_property.iter() {
12067 params.push("sharedExtendedProperty", f);
12068 }
12069 }
12070 if let Some(value) = self._q.as_ref() {
12071 params.push("q", value);
12072 }
12073 if !self._private_extended_property.is_empty() {
12074 for f in self._private_extended_property.iter() {
12075 params.push("privateExtendedProperty", f);
12076 }
12077 }
12078 if let Some(value) = self._page_token.as_ref() {
12079 params.push("pageToken", value);
12080 }
12081 if let Some(value) = self._order_by.as_ref() {
12082 params.push("orderBy", value);
12083 }
12084 if let Some(value) = self._max_results.as_ref() {
12085 params.push("maxResults", value.to_string());
12086 }
12087 if let Some(value) = self._max_attendees.as_ref() {
12088 params.push("maxAttendees", value.to_string());
12089 }
12090 if let Some(value) = self._i_cal_uid.as_ref() {
12091 params.push("iCalUID", value);
12092 }
12093 if !self._event_types.is_empty() {
12094 for f in self._event_types.iter() {
12095 params.push("eventTypes", f);
12096 }
12097 }
12098 if let Some(value) = self._always_include_email.as_ref() {
12099 params.push("alwaysIncludeEmail", value.to_string());
12100 }
12101
12102 params.extend(self._additional_params.iter());
12103
12104 params.push("alt", "json");
12105 let mut url = self.hub._base_url.clone() + "calendars/{calendarId}/events";
12106 if self._scopes.is_empty() {
12107 self._scopes
12108 .insert(Scope::EventOwnedReadonly.as_ref().to_string());
12109 }
12110
12111 #[allow(clippy::single_element_loop)]
12112 for &(find_this, param_name) in [("{calendarId}", "calendarId")].iter() {
12113 url = params.uri_replacement(url, param_name, find_this, false);
12114 }
12115 {
12116 let to_remove = ["calendarId"];
12117 params.remove_params(&to_remove);
12118 }
12119
12120 let url = params.parse_with_url(&url);
12121
12122 loop {
12123 let token = match self
12124 .hub
12125 .auth
12126 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
12127 .await
12128 {
12129 Ok(token) => token,
12130 Err(e) => match dlg.token(e) {
12131 Ok(token) => token,
12132 Err(e) => {
12133 dlg.finished(false);
12134 return Err(common::Error::MissingToken(e));
12135 }
12136 },
12137 };
12138 let mut req_result = {
12139 let client = &self.hub.client;
12140 dlg.pre_request();
12141 let mut req_builder = hyper::Request::builder()
12142 .method(hyper::Method::GET)
12143 .uri(url.as_str())
12144 .header(USER_AGENT, self.hub._user_agent.clone());
12145
12146 if let Some(token) = token.as_ref() {
12147 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
12148 }
12149
12150 let request = req_builder
12151 .header(CONTENT_LENGTH, 0_u64)
12152 .body(common::to_body::<String>(None));
12153
12154 client.request(request.unwrap()).await
12155 };
12156
12157 match req_result {
12158 Err(err) => {
12159 if let common::Retry::After(d) = dlg.http_error(&err) {
12160 sleep(d).await;
12161 continue;
12162 }
12163 dlg.finished(false);
12164 return Err(common::Error::HttpError(err));
12165 }
12166 Ok(res) => {
12167 let (mut parts, body) = res.into_parts();
12168 let mut body = common::Body::new(body);
12169 if !parts.status.is_success() {
12170 let bytes = common::to_bytes(body).await.unwrap_or_default();
12171 let error = serde_json::from_str(&common::to_string(&bytes));
12172 let response = common::to_response(parts, bytes.into());
12173
12174 if let common::Retry::After(d) =
12175 dlg.http_failure(&response, error.as_ref().ok())
12176 {
12177 sleep(d).await;
12178 continue;
12179 }
12180
12181 dlg.finished(false);
12182
12183 return Err(match error {
12184 Ok(value) => common::Error::BadRequest(value),
12185 _ => common::Error::Failure(response),
12186 });
12187 }
12188 let response = {
12189 let bytes = common::to_bytes(body).await.unwrap_or_default();
12190 let encoded = common::to_string(&bytes);
12191 match serde_json::from_str(&encoded) {
12192 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
12193 Err(error) => {
12194 dlg.response_json_decode_error(&encoded, &error);
12195 return Err(common::Error::JsonDecodeError(
12196 encoded.to_string(),
12197 error,
12198 ));
12199 }
12200 }
12201 };
12202
12203 dlg.finished(true);
12204 return Ok(response);
12205 }
12206 }
12207 }
12208 }
12209
12210 /// 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.
12211 ///
12212 /// Sets the *calendar id* path property to the given value.
12213 ///
12214 /// Even though the property as already been set when instantiating this call,
12215 /// we provide this method for API completeness.
12216 pub fn calendar_id(mut self, new_value: &str) -> EventListCall<'a, C> {
12217 self._calendar_id = new_value.to_string();
12218 self
12219 }
12220 /// 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.
12221 ///
12222 /// Sets the *updated min* query property to the given value.
12223 pub fn updated_min(
12224 mut self,
12225 new_value: chrono::DateTime<chrono::offset::Utc>,
12226 ) -> EventListCall<'a, C> {
12227 self._updated_min = Some(new_value);
12228 self
12229 }
12230 /// Time zone used in the response. Optional. The default is the time zone of the calendar.
12231 ///
12232 /// Sets the *time zone* query property to the given value.
12233 pub fn time_zone(mut self, new_value: &str) -> EventListCall<'a, C> {
12234 self._time_zone = Some(new_value.to_string());
12235 self
12236 }
12237 /// 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.
12238 ///
12239 /// Sets the *time min* query property to the given value.
12240 pub fn time_min(
12241 mut self,
12242 new_value: chrono::DateTime<chrono::offset::Utc>,
12243 ) -> EventListCall<'a, C> {
12244 self._time_min = Some(new_value);
12245 self
12246 }
12247 /// 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.
12248 ///
12249 /// Sets the *time max* query property to the given value.
12250 pub fn time_max(
12251 mut self,
12252 new_value: chrono::DateTime<chrono::offset::Utc>,
12253 ) -> EventListCall<'a, C> {
12254 self._time_max = Some(new_value);
12255 self
12256 }
12257 /// 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.
12258 /// There are several query parameters that cannot be specified together with nextSyncToken to ensure consistency of the client state.
12259 ///
12260 /// These are:
12261 /// - iCalUID
12262 /// - orderBy
12263 /// - privateExtendedProperty
12264 /// - q
12265 /// - sharedExtendedProperty
12266 /// - timeMin
12267 /// - timeMax
12268 /// - 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.
12269 /// Learn more about incremental synchronization.
12270 /// Optional. The default is to return all entries.
12271 ///
12272 /// Sets the *sync token* query property to the given value.
12273 pub fn sync_token(mut self, new_value: &str) -> EventListCall<'a, C> {
12274 self._sync_token = Some(new_value.to_string());
12275 self
12276 }
12277 /// 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.
12278 ///
12279 /// Sets the *single events* query property to the given value.
12280 pub fn single_events(mut self, new_value: bool) -> EventListCall<'a, C> {
12281 self._single_events = Some(new_value);
12282 self
12283 }
12284 /// Whether to include hidden invitations in the result. Optional. The default is False.
12285 ///
12286 /// Sets the *show hidden invitations* query property to the given value.
12287 pub fn show_hidden_invitations(mut self, new_value: bool) -> EventListCall<'a, C> {
12288 self._show_hidden_invitations = Some(new_value);
12289 self
12290 }
12291 /// 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.
12292 ///
12293 /// Sets the *show deleted* query property to the given value.
12294 pub fn show_deleted(mut self, new_value: bool) -> EventListCall<'a, C> {
12295 self._show_deleted = Some(new_value);
12296 self
12297 }
12298 /// 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.
12299 ///
12300 /// Append the given value to the *shared extended property* query property.
12301 /// Each appended value will retain its original ordering and be '/'-separated in the URL's parameters.
12302 pub fn add_shared_extended_property(mut self, new_value: &str) -> EventListCall<'a, C> {
12303 self._shared_extended_property.push(new_value.to_string());
12304 self
12305 }
12306 /// Free text search terms to find events that match these terms in the following fields:
12307 ///
12308 /// - summary
12309 /// - description
12310 /// - location
12311 /// - attendee's displayName
12312 /// - attendee's email
12313 /// - organizer's displayName
12314 /// - organizer's email
12315 /// - workingLocationProperties.officeLocation.buildingId
12316 /// - workingLocationProperties.officeLocation.deskId
12317 /// - workingLocationProperties.officeLocation.label
12318 /// - workingLocationProperties.customLocation.label
12319 /// 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.
12320 ///
12321 /// Sets the *q* query property to the given value.
12322 pub fn q(mut self, new_value: &str) -> EventListCall<'a, C> {
12323 self._q = Some(new_value.to_string());
12324 self
12325 }
12326 /// 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.
12327 ///
12328 /// Append the given value to the *private extended property* query property.
12329 /// Each appended value will retain its original ordering and be '/'-separated in the URL's parameters.
12330 pub fn add_private_extended_property(mut self, new_value: &str) -> EventListCall<'a, C> {
12331 self._private_extended_property.push(new_value.to_string());
12332 self
12333 }
12334 /// Token specifying which result page to return. Optional.
12335 ///
12336 /// Sets the *page token* query property to the given value.
12337 pub fn page_token(mut self, new_value: &str) -> EventListCall<'a, C> {
12338 self._page_token = Some(new_value.to_string());
12339 self
12340 }
12341 /// The order of the events returned in the result. Optional. The default is an unspecified, stable order.
12342 ///
12343 /// Sets the *order by* query property to the given value.
12344 pub fn order_by(mut self, new_value: &str) -> EventListCall<'a, C> {
12345 self._order_by = Some(new_value.to_string());
12346 self
12347 }
12348 /// 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.
12349 ///
12350 /// Sets the *max results* query property to the given value.
12351 pub fn max_results(mut self, new_value: i32) -> EventListCall<'a, C> {
12352 self._max_results = Some(new_value);
12353 self
12354 }
12355 /// 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.
12356 ///
12357 /// Sets the *max attendees* query property to the given value.
12358 pub fn max_attendees(mut self, new_value: i32) -> EventListCall<'a, C> {
12359 self._max_attendees = Some(new_value);
12360 self
12361 }
12362 /// 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.
12363 ///
12364 /// Sets the *i cal uid* query property to the given value.
12365 pub fn i_cal_uid(mut self, new_value: &str) -> EventListCall<'a, C> {
12366 self._i_cal_uid = Some(new_value.to_string());
12367 self
12368 }
12369 /// Event types to return. Optional. This parameter can be repeated multiple times to return events of different types. If unset, returns all event types.
12370 ///
12371 /// Append the given value to the *event types* query property.
12372 /// Each appended value will retain its original ordering and be '/'-separated in the URL's parameters.
12373 pub fn add_event_types(mut self, new_value: &str) -> EventListCall<'a, C> {
12374 self._event_types.push(new_value.to_string());
12375 self
12376 }
12377 /// Deprecated and ignored.
12378 ///
12379 /// Sets the *always include email* query property to the given value.
12380 pub fn always_include_email(mut self, new_value: bool) -> EventListCall<'a, C> {
12381 self._always_include_email = Some(new_value);
12382 self
12383 }
12384 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
12385 /// while executing the actual API request.
12386 ///
12387 /// ````text
12388 /// It should be used to handle progress information, and to implement a certain level of resilience.
12389 /// ````
12390 ///
12391 /// Sets the *delegate* property to the given value.
12392 pub fn delegate(mut self, new_value: &'a mut dyn common::Delegate) -> EventListCall<'a, C> {
12393 self._delegate = Some(new_value);
12394 self
12395 }
12396
12397 /// Set any additional parameter of the query string used in the request.
12398 /// It should be used to set parameters which are not yet available through their own
12399 /// setters.
12400 ///
12401 /// Please note that this method must not be used to set any of the known parameters
12402 /// which have their own setter method. If done anyway, the request will fail.
12403 ///
12404 /// # Additional Parameters
12405 ///
12406 /// * *alt* (query-string) - Data format for the response.
12407 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
12408 /// * *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.
12409 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
12410 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
12411 /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
12412 /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
12413 pub fn param<T>(mut self, name: T, value: T) -> EventListCall<'a, C>
12414 where
12415 T: AsRef<str>,
12416 {
12417 self._additional_params
12418 .insert(name.as_ref().to_string(), value.as_ref().to_string());
12419 self
12420 }
12421
12422 /// Identifies the authorization scope for the method you are building.
12423 ///
12424 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
12425 /// [`Scope::EventOwnedReadonly`].
12426 ///
12427 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
12428 /// tokens for more than one scope.
12429 ///
12430 /// Usually there is more than one suitable scope to authorize an operation, some of which may
12431 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
12432 /// sufficient, a read-write scope will do as well.
12433 pub fn add_scope<St>(mut self, scope: St) -> EventListCall<'a, C>
12434 where
12435 St: AsRef<str>,
12436 {
12437 self._scopes.insert(String::from(scope.as_ref()));
12438 self
12439 }
12440 /// Identifies the authorization scope(s) for the method you are building.
12441 ///
12442 /// See [`Self::add_scope()`] for details.
12443 pub fn add_scopes<I, St>(mut self, scopes: I) -> EventListCall<'a, C>
12444 where
12445 I: IntoIterator<Item = St>,
12446 St: AsRef<str>,
12447 {
12448 self._scopes
12449 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
12450 self
12451 }
12452
12453 /// Removes all scopes, and no default scope will be used either.
12454 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
12455 /// for details).
12456 pub fn clear_scopes(mut self) -> EventListCall<'a, C> {
12457 self._scopes.clear();
12458 self
12459 }
12460}
12461
12462/// Moves an event to another calendar, i.e. changes an event's organizer. Note that only default events can be moved; birthday, focusTime, fromGmail, outOfOffice and workingLocation events cannot be moved.
12463///
12464/// A builder for the *move* method supported by a *event* resource.
12465/// It is not used directly, but through a [`EventMethods`] instance.
12466///
12467/// # Example
12468///
12469/// Instantiate a resource method builder
12470///
12471/// ```test_harness,no_run
12472/// # extern crate hyper;
12473/// # extern crate hyper_rustls;
12474/// # extern crate google_calendar3 as calendar3;
12475/// # async fn dox() {
12476/// # use calendar3::{CalendarHub, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
12477///
12478/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
12479/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
12480/// # .with_native_roots()
12481/// # .unwrap()
12482/// # .https_only()
12483/// # .enable_http2()
12484/// # .build();
12485///
12486/// # let executor = hyper_util::rt::TokioExecutor::new();
12487/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
12488/// # secret,
12489/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
12490/// # yup_oauth2::client::CustomHyperClientBuilder::from(
12491/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
12492/// # ),
12493/// # ).build().await.unwrap();
12494///
12495/// # let client = hyper_util::client::legacy::Client::builder(
12496/// # hyper_util::rt::TokioExecutor::new()
12497/// # )
12498/// # .build(
12499/// # hyper_rustls::HttpsConnectorBuilder::new()
12500/// # .with_native_roots()
12501/// # .unwrap()
12502/// # .https_or_http()
12503/// # .enable_http2()
12504/// # .build()
12505/// # );
12506/// # let mut hub = CalendarHub::new(client, auth);
12507/// // You can configure optional parameters by calling the respective setters at will, and
12508/// // execute the final call using `doit()`.
12509/// // Values shown here are possibly random and not representative !
12510/// let result = hub.events().move_("calendarId", "eventId", "destination")
12511/// .send_updates("erat")
12512/// .send_notifications(true)
12513/// .doit().await;
12514/// # }
12515/// ```
12516pub struct EventMoveCall<'a, C>
12517where
12518 C: 'a,
12519{
12520 hub: &'a CalendarHub<C>,
12521 _calendar_id: String,
12522 _event_id: String,
12523 _destination: String,
12524 _send_updates: Option<String>,
12525 _send_notifications: Option<bool>,
12526 _delegate: Option<&'a mut dyn common::Delegate>,
12527 _additional_params: HashMap<String, String>,
12528 _scopes: BTreeSet<String>,
12529}
12530
12531impl<'a, C> common::CallBuilder for EventMoveCall<'a, C> {}
12532
12533impl<'a, C> EventMoveCall<'a, C>
12534where
12535 C: common::Connector,
12536{
12537 /// Perform the operation you have build so far.
12538 pub async fn doit(mut self) -> common::Result<(common::Response, Event)> {
12539 use std::borrow::Cow;
12540 use std::io::{Read, Seek};
12541
12542 use common::{url::Params, ToParts};
12543 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
12544
12545 let mut dd = common::DefaultDelegate;
12546 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
12547 dlg.begin(common::MethodInfo {
12548 id: "calendar.events.move",
12549 http_method: hyper::Method::POST,
12550 });
12551
12552 for &field in [
12553 "alt",
12554 "calendarId",
12555 "eventId",
12556 "destination",
12557 "sendUpdates",
12558 "sendNotifications",
12559 ]
12560 .iter()
12561 {
12562 if self._additional_params.contains_key(field) {
12563 dlg.finished(false);
12564 return Err(common::Error::FieldClash(field));
12565 }
12566 }
12567
12568 let mut params = Params::with_capacity(7 + self._additional_params.len());
12569 params.push("calendarId", self._calendar_id);
12570 params.push("eventId", self._event_id);
12571 params.push("destination", self._destination);
12572 if let Some(value) = self._send_updates.as_ref() {
12573 params.push("sendUpdates", value);
12574 }
12575 if let Some(value) = self._send_notifications.as_ref() {
12576 params.push("sendNotifications", value.to_string());
12577 }
12578
12579 params.extend(self._additional_params.iter());
12580
12581 params.push("alt", "json");
12582 let mut url = self.hub._base_url.clone() + "calendars/{calendarId}/events/{eventId}/move";
12583 if self._scopes.is_empty() {
12584 self._scopes.insert(Scope::Full.as_ref().to_string());
12585 }
12586
12587 #[allow(clippy::single_element_loop)]
12588 for &(find_this, param_name) in
12589 [("{calendarId}", "calendarId"), ("{eventId}", "eventId")].iter()
12590 {
12591 url = params.uri_replacement(url, param_name, find_this, false);
12592 }
12593 {
12594 let to_remove = ["eventId", "calendarId"];
12595 params.remove_params(&to_remove);
12596 }
12597
12598 let url = params.parse_with_url(&url);
12599
12600 loop {
12601 let token = match self
12602 .hub
12603 .auth
12604 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
12605 .await
12606 {
12607 Ok(token) => token,
12608 Err(e) => match dlg.token(e) {
12609 Ok(token) => token,
12610 Err(e) => {
12611 dlg.finished(false);
12612 return Err(common::Error::MissingToken(e));
12613 }
12614 },
12615 };
12616 let mut req_result = {
12617 let client = &self.hub.client;
12618 dlg.pre_request();
12619 let mut req_builder = hyper::Request::builder()
12620 .method(hyper::Method::POST)
12621 .uri(url.as_str())
12622 .header(USER_AGENT, self.hub._user_agent.clone());
12623
12624 if let Some(token) = token.as_ref() {
12625 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
12626 }
12627
12628 let request = req_builder
12629 .header(CONTENT_LENGTH, 0_u64)
12630 .body(common::to_body::<String>(None));
12631
12632 client.request(request.unwrap()).await
12633 };
12634
12635 match req_result {
12636 Err(err) => {
12637 if let common::Retry::After(d) = dlg.http_error(&err) {
12638 sleep(d).await;
12639 continue;
12640 }
12641 dlg.finished(false);
12642 return Err(common::Error::HttpError(err));
12643 }
12644 Ok(res) => {
12645 let (mut parts, body) = res.into_parts();
12646 let mut body = common::Body::new(body);
12647 if !parts.status.is_success() {
12648 let bytes = common::to_bytes(body).await.unwrap_or_default();
12649 let error = serde_json::from_str(&common::to_string(&bytes));
12650 let response = common::to_response(parts, bytes.into());
12651
12652 if let common::Retry::After(d) =
12653 dlg.http_failure(&response, error.as_ref().ok())
12654 {
12655 sleep(d).await;
12656 continue;
12657 }
12658
12659 dlg.finished(false);
12660
12661 return Err(match error {
12662 Ok(value) => common::Error::BadRequest(value),
12663 _ => common::Error::Failure(response),
12664 });
12665 }
12666 let response = {
12667 let bytes = common::to_bytes(body).await.unwrap_or_default();
12668 let encoded = common::to_string(&bytes);
12669 match serde_json::from_str(&encoded) {
12670 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
12671 Err(error) => {
12672 dlg.response_json_decode_error(&encoded, &error);
12673 return Err(common::Error::JsonDecodeError(
12674 encoded.to_string(),
12675 error,
12676 ));
12677 }
12678 }
12679 };
12680
12681 dlg.finished(true);
12682 return Ok(response);
12683 }
12684 }
12685 }
12686 }
12687
12688 /// Calendar identifier of the source calendar where the event currently is on.
12689 ///
12690 /// Sets the *calendar id* path property to the given value.
12691 ///
12692 /// Even though the property as already been set when instantiating this call,
12693 /// we provide this method for API completeness.
12694 pub fn calendar_id(mut self, new_value: &str) -> EventMoveCall<'a, C> {
12695 self._calendar_id = new_value.to_string();
12696 self
12697 }
12698 /// Event identifier.
12699 ///
12700 /// Sets the *event id* path property to the given value.
12701 ///
12702 /// Even though the property as already been set when instantiating this call,
12703 /// we provide this method for API completeness.
12704 pub fn event_id(mut self, new_value: &str) -> EventMoveCall<'a, C> {
12705 self._event_id = new_value.to_string();
12706 self
12707 }
12708 /// Calendar identifier of the target calendar where the event is to be moved to.
12709 ///
12710 /// Sets the *destination* query property to the given value.
12711 ///
12712 /// Even though the property as already been set when instantiating this call,
12713 /// we provide this method for API completeness.
12714 pub fn destination(mut self, new_value: &str) -> EventMoveCall<'a, C> {
12715 self._destination = new_value.to_string();
12716 self
12717 }
12718 /// Guests who should receive notifications about the change of the event's organizer.
12719 ///
12720 /// Sets the *send updates* query property to the given value.
12721 pub fn send_updates(mut self, new_value: &str) -> EventMoveCall<'a, C> {
12722 self._send_updates = Some(new_value.to_string());
12723 self
12724 }
12725 /// Deprecated. Please use sendUpdates instead.
12726 ///
12727 /// 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.
12728 ///
12729 /// Sets the *send notifications* query property to the given value.
12730 pub fn send_notifications(mut self, new_value: bool) -> EventMoveCall<'a, C> {
12731 self._send_notifications = Some(new_value);
12732 self
12733 }
12734 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
12735 /// while executing the actual API request.
12736 ///
12737 /// ````text
12738 /// It should be used to handle progress information, and to implement a certain level of resilience.
12739 /// ````
12740 ///
12741 /// Sets the *delegate* property to the given value.
12742 pub fn delegate(mut self, new_value: &'a mut dyn common::Delegate) -> EventMoveCall<'a, C> {
12743 self._delegate = Some(new_value);
12744 self
12745 }
12746
12747 /// Set any additional parameter of the query string used in the request.
12748 /// It should be used to set parameters which are not yet available through their own
12749 /// setters.
12750 ///
12751 /// Please note that this method must not be used to set any of the known parameters
12752 /// which have their own setter method. If done anyway, the request will fail.
12753 ///
12754 /// # Additional Parameters
12755 ///
12756 /// * *alt* (query-string) - Data format for the response.
12757 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
12758 /// * *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.
12759 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
12760 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
12761 /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
12762 /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
12763 pub fn param<T>(mut self, name: T, value: T) -> EventMoveCall<'a, C>
12764 where
12765 T: AsRef<str>,
12766 {
12767 self._additional_params
12768 .insert(name.as_ref().to_string(), value.as_ref().to_string());
12769 self
12770 }
12771
12772 /// Identifies the authorization scope for the method you are building.
12773 ///
12774 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
12775 /// [`Scope::Full`].
12776 ///
12777 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
12778 /// tokens for more than one scope.
12779 ///
12780 /// Usually there is more than one suitable scope to authorize an operation, some of which may
12781 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
12782 /// sufficient, a read-write scope will do as well.
12783 pub fn add_scope<St>(mut self, scope: St) -> EventMoveCall<'a, C>
12784 where
12785 St: AsRef<str>,
12786 {
12787 self._scopes.insert(String::from(scope.as_ref()));
12788 self
12789 }
12790 /// Identifies the authorization scope(s) for the method you are building.
12791 ///
12792 /// See [`Self::add_scope()`] for details.
12793 pub fn add_scopes<I, St>(mut self, scopes: I) -> EventMoveCall<'a, C>
12794 where
12795 I: IntoIterator<Item = St>,
12796 St: AsRef<str>,
12797 {
12798 self._scopes
12799 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
12800 self
12801 }
12802
12803 /// Removes all scopes, and no default scope will be used either.
12804 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
12805 /// for details).
12806 pub fn clear_scopes(mut self) -> EventMoveCall<'a, C> {
12807 self._scopes.clear();
12808 self
12809 }
12810}
12811
12812/// Updates an event. This method supports patch semantics.
12813///
12814/// A builder for the *patch* method supported by a *event* resource.
12815/// It is not used directly, but through a [`EventMethods`] instance.
12816///
12817/// # Example
12818///
12819/// Instantiate a resource method builder
12820///
12821/// ```test_harness,no_run
12822/// # extern crate hyper;
12823/// # extern crate hyper_rustls;
12824/// # extern crate google_calendar3 as calendar3;
12825/// use calendar3::api::Event;
12826/// # async fn dox() {
12827/// # use calendar3::{CalendarHub, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
12828///
12829/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
12830/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
12831/// # .with_native_roots()
12832/// # .unwrap()
12833/// # .https_only()
12834/// # .enable_http2()
12835/// # .build();
12836///
12837/// # let executor = hyper_util::rt::TokioExecutor::new();
12838/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
12839/// # secret,
12840/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
12841/// # yup_oauth2::client::CustomHyperClientBuilder::from(
12842/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
12843/// # ),
12844/// # ).build().await.unwrap();
12845///
12846/// # let client = hyper_util::client::legacy::Client::builder(
12847/// # hyper_util::rt::TokioExecutor::new()
12848/// # )
12849/// # .build(
12850/// # hyper_rustls::HttpsConnectorBuilder::new()
12851/// # .with_native_roots()
12852/// # .unwrap()
12853/// # .https_or_http()
12854/// # .enable_http2()
12855/// # .build()
12856/// # );
12857/// # let mut hub = CalendarHub::new(client, auth);
12858/// // As the method needs a request, you would usually fill it with the desired information
12859/// // into the respective structure. Some of the parts shown here might not be applicable !
12860/// // Values shown here are possibly random and not representative !
12861/// let mut req = Event::default();
12862///
12863/// // You can configure optional parameters by calling the respective setters at will, and
12864/// // execute the final call using `doit()`.
12865/// // Values shown here are possibly random and not representative !
12866/// let result = hub.events().patch(req, "calendarId", "eventId")
12867/// .supports_attachments(true)
12868/// .send_updates("consetetur")
12869/// .send_notifications(false)
12870/// .max_attendees(-32)
12871/// .conference_data_version(-25)
12872/// .always_include_email(false)
12873/// .doit().await;
12874/// # }
12875/// ```
12876pub struct EventPatchCall<'a, C>
12877where
12878 C: 'a,
12879{
12880 hub: &'a CalendarHub<C>,
12881 _request: Event,
12882 _calendar_id: String,
12883 _event_id: String,
12884 _supports_attachments: Option<bool>,
12885 _send_updates: Option<String>,
12886 _send_notifications: Option<bool>,
12887 _max_attendees: Option<i32>,
12888 _conference_data_version: Option<i32>,
12889 _always_include_email: Option<bool>,
12890 _delegate: Option<&'a mut dyn common::Delegate>,
12891 _additional_params: HashMap<String, String>,
12892 _scopes: BTreeSet<String>,
12893}
12894
12895impl<'a, C> common::CallBuilder for EventPatchCall<'a, C> {}
12896
12897impl<'a, C> EventPatchCall<'a, C>
12898where
12899 C: common::Connector,
12900{
12901 /// Perform the operation you have build so far.
12902 pub async fn doit(mut self) -> common::Result<(common::Response, Event)> {
12903 use std::borrow::Cow;
12904 use std::io::{Read, Seek};
12905
12906 use common::{url::Params, ToParts};
12907 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
12908
12909 let mut dd = common::DefaultDelegate;
12910 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
12911 dlg.begin(common::MethodInfo {
12912 id: "calendar.events.patch",
12913 http_method: hyper::Method::PATCH,
12914 });
12915
12916 for &field in [
12917 "alt",
12918 "calendarId",
12919 "eventId",
12920 "supportsAttachments",
12921 "sendUpdates",
12922 "sendNotifications",
12923 "maxAttendees",
12924 "conferenceDataVersion",
12925 "alwaysIncludeEmail",
12926 ]
12927 .iter()
12928 {
12929 if self._additional_params.contains_key(field) {
12930 dlg.finished(false);
12931 return Err(common::Error::FieldClash(field));
12932 }
12933 }
12934
12935 let mut params = Params::with_capacity(11 + self._additional_params.len());
12936 params.push("calendarId", self._calendar_id);
12937 params.push("eventId", self._event_id);
12938 if let Some(value) = self._supports_attachments.as_ref() {
12939 params.push("supportsAttachments", value.to_string());
12940 }
12941 if let Some(value) = self._send_updates.as_ref() {
12942 params.push("sendUpdates", value);
12943 }
12944 if let Some(value) = self._send_notifications.as_ref() {
12945 params.push("sendNotifications", value.to_string());
12946 }
12947 if let Some(value) = self._max_attendees.as_ref() {
12948 params.push("maxAttendees", value.to_string());
12949 }
12950 if let Some(value) = self._conference_data_version.as_ref() {
12951 params.push("conferenceDataVersion", value.to_string());
12952 }
12953 if let Some(value) = self._always_include_email.as_ref() {
12954 params.push("alwaysIncludeEmail", value.to_string());
12955 }
12956
12957 params.extend(self._additional_params.iter());
12958
12959 params.push("alt", "json");
12960 let mut url = self.hub._base_url.clone() + "calendars/{calendarId}/events/{eventId}";
12961 if self._scopes.is_empty() {
12962 self._scopes.insert(Scope::Full.as_ref().to_string());
12963 }
12964
12965 #[allow(clippy::single_element_loop)]
12966 for &(find_this, param_name) in
12967 [("{calendarId}", "calendarId"), ("{eventId}", "eventId")].iter()
12968 {
12969 url = params.uri_replacement(url, param_name, find_this, false);
12970 }
12971 {
12972 let to_remove = ["eventId", "calendarId"];
12973 params.remove_params(&to_remove);
12974 }
12975
12976 let url = params.parse_with_url(&url);
12977
12978 let mut json_mime_type = mime::APPLICATION_JSON;
12979 let mut request_value_reader = {
12980 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
12981 common::remove_json_null_values(&mut value);
12982 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
12983 serde_json::to_writer(&mut dst, &value).unwrap();
12984 dst
12985 };
12986 let request_size = request_value_reader
12987 .seek(std::io::SeekFrom::End(0))
12988 .unwrap();
12989 request_value_reader
12990 .seek(std::io::SeekFrom::Start(0))
12991 .unwrap();
12992
12993 loop {
12994 let token = match self
12995 .hub
12996 .auth
12997 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
12998 .await
12999 {
13000 Ok(token) => token,
13001 Err(e) => match dlg.token(e) {
13002 Ok(token) => token,
13003 Err(e) => {
13004 dlg.finished(false);
13005 return Err(common::Error::MissingToken(e));
13006 }
13007 },
13008 };
13009 request_value_reader
13010 .seek(std::io::SeekFrom::Start(0))
13011 .unwrap();
13012 let mut req_result = {
13013 let client = &self.hub.client;
13014 dlg.pre_request();
13015 let mut req_builder = hyper::Request::builder()
13016 .method(hyper::Method::PATCH)
13017 .uri(url.as_str())
13018 .header(USER_AGENT, self.hub._user_agent.clone());
13019
13020 if let Some(token) = token.as_ref() {
13021 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
13022 }
13023
13024 let request = req_builder
13025 .header(CONTENT_TYPE, json_mime_type.to_string())
13026 .header(CONTENT_LENGTH, request_size as u64)
13027 .body(common::to_body(
13028 request_value_reader.get_ref().clone().into(),
13029 ));
13030
13031 client.request(request.unwrap()).await
13032 };
13033
13034 match req_result {
13035 Err(err) => {
13036 if let common::Retry::After(d) = dlg.http_error(&err) {
13037 sleep(d).await;
13038 continue;
13039 }
13040 dlg.finished(false);
13041 return Err(common::Error::HttpError(err));
13042 }
13043 Ok(res) => {
13044 let (mut parts, body) = res.into_parts();
13045 let mut body = common::Body::new(body);
13046 if !parts.status.is_success() {
13047 let bytes = common::to_bytes(body).await.unwrap_or_default();
13048 let error = serde_json::from_str(&common::to_string(&bytes));
13049 let response = common::to_response(parts, bytes.into());
13050
13051 if let common::Retry::After(d) =
13052 dlg.http_failure(&response, error.as_ref().ok())
13053 {
13054 sleep(d).await;
13055 continue;
13056 }
13057
13058 dlg.finished(false);
13059
13060 return Err(match error {
13061 Ok(value) => common::Error::BadRequest(value),
13062 _ => common::Error::Failure(response),
13063 });
13064 }
13065 let response = {
13066 let bytes = common::to_bytes(body).await.unwrap_or_default();
13067 let encoded = common::to_string(&bytes);
13068 match serde_json::from_str(&encoded) {
13069 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
13070 Err(error) => {
13071 dlg.response_json_decode_error(&encoded, &error);
13072 return Err(common::Error::JsonDecodeError(
13073 encoded.to_string(),
13074 error,
13075 ));
13076 }
13077 }
13078 };
13079
13080 dlg.finished(true);
13081 return Ok(response);
13082 }
13083 }
13084 }
13085 }
13086
13087 ///
13088 /// Sets the *request* property to the given value.
13089 ///
13090 /// Even though the property as already been set when instantiating this call,
13091 /// we provide this method for API completeness.
13092 pub fn request(mut self, new_value: Event) -> EventPatchCall<'a, C> {
13093 self._request = new_value;
13094 self
13095 }
13096 /// 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.
13097 ///
13098 /// Sets the *calendar id* path property to the given value.
13099 ///
13100 /// Even though the property as already been set when instantiating this call,
13101 /// we provide this method for API completeness.
13102 pub fn calendar_id(mut self, new_value: &str) -> EventPatchCall<'a, C> {
13103 self._calendar_id = new_value.to_string();
13104 self
13105 }
13106 /// Event identifier.
13107 ///
13108 /// Sets the *event id* path property to the given value.
13109 ///
13110 /// Even though the property as already been set when instantiating this call,
13111 /// we provide this method for API completeness.
13112 pub fn event_id(mut self, new_value: &str) -> EventPatchCall<'a, C> {
13113 self._event_id = new_value.to_string();
13114 self
13115 }
13116 /// Whether API client performing operation supports event attachments. Optional. The default is False.
13117 ///
13118 /// Sets the *supports attachments* query property to the given value.
13119 pub fn supports_attachments(mut self, new_value: bool) -> EventPatchCall<'a, C> {
13120 self._supports_attachments = Some(new_value);
13121 self
13122 }
13123 /// Guests who should receive notifications about the event update (for example, title changes, etc.).
13124 ///
13125 /// Sets the *send updates* query property to the given value.
13126 pub fn send_updates(mut self, new_value: &str) -> EventPatchCall<'a, C> {
13127 self._send_updates = Some(new_value.to_string());
13128 self
13129 }
13130 /// Deprecated. Please use sendUpdates instead.
13131 ///
13132 /// 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.
13133 ///
13134 /// Sets the *send notifications* query property to the given value.
13135 pub fn send_notifications(mut self, new_value: bool) -> EventPatchCall<'a, C> {
13136 self._send_notifications = Some(new_value);
13137 self
13138 }
13139 /// 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.
13140 ///
13141 /// Sets the *max attendees* query property to the given value.
13142 pub fn max_attendees(mut self, new_value: i32) -> EventPatchCall<'a, C> {
13143 self._max_attendees = Some(new_value);
13144 self
13145 }
13146 /// 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.
13147 ///
13148 /// Sets the *conference data version* query property to the given value.
13149 pub fn conference_data_version(mut self, new_value: i32) -> EventPatchCall<'a, C> {
13150 self._conference_data_version = Some(new_value);
13151 self
13152 }
13153 /// 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).
13154 ///
13155 /// Sets the *always include email* query property to the given value.
13156 pub fn always_include_email(mut self, new_value: bool) -> EventPatchCall<'a, C> {
13157 self._always_include_email = Some(new_value);
13158 self
13159 }
13160 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
13161 /// while executing the actual API request.
13162 ///
13163 /// ````text
13164 /// It should be used to handle progress information, and to implement a certain level of resilience.
13165 /// ````
13166 ///
13167 /// Sets the *delegate* property to the given value.
13168 pub fn delegate(mut self, new_value: &'a mut dyn common::Delegate) -> EventPatchCall<'a, C> {
13169 self._delegate = Some(new_value);
13170 self
13171 }
13172
13173 /// Set any additional parameter of the query string used in the request.
13174 /// It should be used to set parameters which are not yet available through their own
13175 /// setters.
13176 ///
13177 /// Please note that this method must not be used to set any of the known parameters
13178 /// which have their own setter method. If done anyway, the request will fail.
13179 ///
13180 /// # Additional Parameters
13181 ///
13182 /// * *alt* (query-string) - Data format for the response.
13183 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
13184 /// * *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.
13185 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
13186 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
13187 /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
13188 /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
13189 pub fn param<T>(mut self, name: T, value: T) -> EventPatchCall<'a, C>
13190 where
13191 T: AsRef<str>,
13192 {
13193 self._additional_params
13194 .insert(name.as_ref().to_string(), value.as_ref().to_string());
13195 self
13196 }
13197
13198 /// Identifies the authorization scope for the method you are building.
13199 ///
13200 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
13201 /// [`Scope::Full`].
13202 ///
13203 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
13204 /// tokens for more than one scope.
13205 ///
13206 /// Usually there is more than one suitable scope to authorize an operation, some of which may
13207 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
13208 /// sufficient, a read-write scope will do as well.
13209 pub fn add_scope<St>(mut self, scope: St) -> EventPatchCall<'a, C>
13210 where
13211 St: AsRef<str>,
13212 {
13213 self._scopes.insert(String::from(scope.as_ref()));
13214 self
13215 }
13216 /// Identifies the authorization scope(s) for the method you are building.
13217 ///
13218 /// See [`Self::add_scope()`] for details.
13219 pub fn add_scopes<I, St>(mut self, scopes: I) -> EventPatchCall<'a, C>
13220 where
13221 I: IntoIterator<Item = St>,
13222 St: AsRef<str>,
13223 {
13224 self._scopes
13225 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
13226 self
13227 }
13228
13229 /// Removes all scopes, and no default scope will be used either.
13230 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
13231 /// for details).
13232 pub fn clear_scopes(mut self) -> EventPatchCall<'a, C> {
13233 self._scopes.clear();
13234 self
13235 }
13236}
13237
13238/// Creates an event based on a simple text string.
13239///
13240/// A builder for the *quickAdd* method supported by a *event* resource.
13241/// It is not used directly, but through a [`EventMethods`] instance.
13242///
13243/// # Example
13244///
13245/// Instantiate a resource method builder
13246///
13247/// ```test_harness,no_run
13248/// # extern crate hyper;
13249/// # extern crate hyper_rustls;
13250/// # extern crate google_calendar3 as calendar3;
13251/// # async fn dox() {
13252/// # use calendar3::{CalendarHub, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
13253///
13254/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
13255/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
13256/// # .with_native_roots()
13257/// # .unwrap()
13258/// # .https_only()
13259/// # .enable_http2()
13260/// # .build();
13261///
13262/// # let executor = hyper_util::rt::TokioExecutor::new();
13263/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
13264/// # secret,
13265/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
13266/// # yup_oauth2::client::CustomHyperClientBuilder::from(
13267/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
13268/// # ),
13269/// # ).build().await.unwrap();
13270///
13271/// # let client = hyper_util::client::legacy::Client::builder(
13272/// # hyper_util::rt::TokioExecutor::new()
13273/// # )
13274/// # .build(
13275/// # hyper_rustls::HttpsConnectorBuilder::new()
13276/// # .with_native_roots()
13277/// # .unwrap()
13278/// # .https_or_http()
13279/// # .enable_http2()
13280/// # .build()
13281/// # );
13282/// # let mut hub = CalendarHub::new(client, auth);
13283/// // You can configure optional parameters by calling the respective setters at will, and
13284/// // execute the final call using `doit()`.
13285/// // Values shown here are possibly random and not representative !
13286/// let result = hub.events().quick_add("calendarId", "text")
13287/// .send_updates("gubergren")
13288/// .send_notifications(true)
13289/// .doit().await;
13290/// # }
13291/// ```
13292pub struct EventQuickAddCall<'a, C>
13293where
13294 C: 'a,
13295{
13296 hub: &'a CalendarHub<C>,
13297 _calendar_id: String,
13298 _text: String,
13299 _send_updates: Option<String>,
13300 _send_notifications: Option<bool>,
13301 _delegate: Option<&'a mut dyn common::Delegate>,
13302 _additional_params: HashMap<String, String>,
13303 _scopes: BTreeSet<String>,
13304}
13305
13306impl<'a, C> common::CallBuilder for EventQuickAddCall<'a, C> {}
13307
13308impl<'a, C> EventQuickAddCall<'a, C>
13309where
13310 C: common::Connector,
13311{
13312 /// Perform the operation you have build so far.
13313 pub async fn doit(mut self) -> common::Result<(common::Response, Event)> {
13314 use std::borrow::Cow;
13315 use std::io::{Read, Seek};
13316
13317 use common::{url::Params, ToParts};
13318 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
13319
13320 let mut dd = common::DefaultDelegate;
13321 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
13322 dlg.begin(common::MethodInfo {
13323 id: "calendar.events.quickAdd",
13324 http_method: hyper::Method::POST,
13325 });
13326
13327 for &field in [
13328 "alt",
13329 "calendarId",
13330 "text",
13331 "sendUpdates",
13332 "sendNotifications",
13333 ]
13334 .iter()
13335 {
13336 if self._additional_params.contains_key(field) {
13337 dlg.finished(false);
13338 return Err(common::Error::FieldClash(field));
13339 }
13340 }
13341
13342 let mut params = Params::with_capacity(6 + self._additional_params.len());
13343 params.push("calendarId", self._calendar_id);
13344 params.push("text", self._text);
13345 if let Some(value) = self._send_updates.as_ref() {
13346 params.push("sendUpdates", value);
13347 }
13348 if let Some(value) = self._send_notifications.as_ref() {
13349 params.push("sendNotifications", value.to_string());
13350 }
13351
13352 params.extend(self._additional_params.iter());
13353
13354 params.push("alt", "json");
13355 let mut url = self.hub._base_url.clone() + "calendars/{calendarId}/events/quickAdd";
13356 if self._scopes.is_empty() {
13357 self._scopes.insert(Scope::Full.as_ref().to_string());
13358 }
13359
13360 #[allow(clippy::single_element_loop)]
13361 for &(find_this, param_name) in [("{calendarId}", "calendarId")].iter() {
13362 url = params.uri_replacement(url, param_name, find_this, false);
13363 }
13364 {
13365 let to_remove = ["calendarId"];
13366 params.remove_params(&to_remove);
13367 }
13368
13369 let url = params.parse_with_url(&url);
13370
13371 loop {
13372 let token = match self
13373 .hub
13374 .auth
13375 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
13376 .await
13377 {
13378 Ok(token) => token,
13379 Err(e) => match dlg.token(e) {
13380 Ok(token) => token,
13381 Err(e) => {
13382 dlg.finished(false);
13383 return Err(common::Error::MissingToken(e));
13384 }
13385 },
13386 };
13387 let mut req_result = {
13388 let client = &self.hub.client;
13389 dlg.pre_request();
13390 let mut req_builder = hyper::Request::builder()
13391 .method(hyper::Method::POST)
13392 .uri(url.as_str())
13393 .header(USER_AGENT, self.hub._user_agent.clone());
13394
13395 if let Some(token) = token.as_ref() {
13396 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
13397 }
13398
13399 let request = req_builder
13400 .header(CONTENT_LENGTH, 0_u64)
13401 .body(common::to_body::<String>(None));
13402
13403 client.request(request.unwrap()).await
13404 };
13405
13406 match req_result {
13407 Err(err) => {
13408 if let common::Retry::After(d) = dlg.http_error(&err) {
13409 sleep(d).await;
13410 continue;
13411 }
13412 dlg.finished(false);
13413 return Err(common::Error::HttpError(err));
13414 }
13415 Ok(res) => {
13416 let (mut parts, body) = res.into_parts();
13417 let mut body = common::Body::new(body);
13418 if !parts.status.is_success() {
13419 let bytes = common::to_bytes(body).await.unwrap_or_default();
13420 let error = serde_json::from_str(&common::to_string(&bytes));
13421 let response = common::to_response(parts, bytes.into());
13422
13423 if let common::Retry::After(d) =
13424 dlg.http_failure(&response, error.as_ref().ok())
13425 {
13426 sleep(d).await;
13427 continue;
13428 }
13429
13430 dlg.finished(false);
13431
13432 return Err(match error {
13433 Ok(value) => common::Error::BadRequest(value),
13434 _ => common::Error::Failure(response),
13435 });
13436 }
13437 let response = {
13438 let bytes = common::to_bytes(body).await.unwrap_or_default();
13439 let encoded = common::to_string(&bytes);
13440 match serde_json::from_str(&encoded) {
13441 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
13442 Err(error) => {
13443 dlg.response_json_decode_error(&encoded, &error);
13444 return Err(common::Error::JsonDecodeError(
13445 encoded.to_string(),
13446 error,
13447 ));
13448 }
13449 }
13450 };
13451
13452 dlg.finished(true);
13453 return Ok(response);
13454 }
13455 }
13456 }
13457 }
13458
13459 /// 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.
13460 ///
13461 /// Sets the *calendar id* path property to the given value.
13462 ///
13463 /// Even though the property as already been set when instantiating this call,
13464 /// we provide this method for API completeness.
13465 pub fn calendar_id(mut self, new_value: &str) -> EventQuickAddCall<'a, C> {
13466 self._calendar_id = new_value.to_string();
13467 self
13468 }
13469 /// The text describing the event to be created.
13470 ///
13471 /// Sets the *text* query property to the given value.
13472 ///
13473 /// Even though the property as already been set when instantiating this call,
13474 /// we provide this method for API completeness.
13475 pub fn text(mut self, new_value: &str) -> EventQuickAddCall<'a, C> {
13476 self._text = new_value.to_string();
13477 self
13478 }
13479 /// Guests who should receive notifications about the creation of the new event.
13480 ///
13481 /// Sets the *send updates* query property to the given value.
13482 pub fn send_updates(mut self, new_value: &str) -> EventQuickAddCall<'a, C> {
13483 self._send_updates = Some(new_value.to_string());
13484 self
13485 }
13486 /// Deprecated. Please use sendUpdates instead.
13487 ///
13488 /// 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.
13489 ///
13490 /// Sets the *send notifications* query property to the given value.
13491 pub fn send_notifications(mut self, new_value: bool) -> EventQuickAddCall<'a, C> {
13492 self._send_notifications = Some(new_value);
13493 self
13494 }
13495 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
13496 /// while executing the actual API request.
13497 ///
13498 /// ````text
13499 /// It should be used to handle progress information, and to implement a certain level of resilience.
13500 /// ````
13501 ///
13502 /// Sets the *delegate* property to the given value.
13503 pub fn delegate(mut self, new_value: &'a mut dyn common::Delegate) -> EventQuickAddCall<'a, C> {
13504 self._delegate = Some(new_value);
13505 self
13506 }
13507
13508 /// Set any additional parameter of the query string used in the request.
13509 /// It should be used to set parameters which are not yet available through their own
13510 /// setters.
13511 ///
13512 /// Please note that this method must not be used to set any of the known parameters
13513 /// which have their own setter method. If done anyway, the request will fail.
13514 ///
13515 /// # Additional Parameters
13516 ///
13517 /// * *alt* (query-string) - Data format for the response.
13518 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
13519 /// * *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.
13520 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
13521 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
13522 /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
13523 /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
13524 pub fn param<T>(mut self, name: T, value: T) -> EventQuickAddCall<'a, C>
13525 where
13526 T: AsRef<str>,
13527 {
13528 self._additional_params
13529 .insert(name.as_ref().to_string(), value.as_ref().to_string());
13530 self
13531 }
13532
13533 /// Identifies the authorization scope for the method you are building.
13534 ///
13535 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
13536 /// [`Scope::Full`].
13537 ///
13538 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
13539 /// tokens for more than one scope.
13540 ///
13541 /// Usually there is more than one suitable scope to authorize an operation, some of which may
13542 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
13543 /// sufficient, a read-write scope will do as well.
13544 pub fn add_scope<St>(mut self, scope: St) -> EventQuickAddCall<'a, C>
13545 where
13546 St: AsRef<str>,
13547 {
13548 self._scopes.insert(String::from(scope.as_ref()));
13549 self
13550 }
13551 /// Identifies the authorization scope(s) for the method you are building.
13552 ///
13553 /// See [`Self::add_scope()`] for details.
13554 pub fn add_scopes<I, St>(mut self, scopes: I) -> EventQuickAddCall<'a, C>
13555 where
13556 I: IntoIterator<Item = St>,
13557 St: AsRef<str>,
13558 {
13559 self._scopes
13560 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
13561 self
13562 }
13563
13564 /// Removes all scopes, and no default scope will be used either.
13565 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
13566 /// for details).
13567 pub fn clear_scopes(mut self) -> EventQuickAddCall<'a, C> {
13568 self._scopes.clear();
13569 self
13570 }
13571}
13572
13573/// Updates an event.
13574///
13575/// A builder for the *update* method supported by a *event* resource.
13576/// It is not used directly, but through a [`EventMethods`] instance.
13577///
13578/// # Example
13579///
13580/// Instantiate a resource method builder
13581///
13582/// ```test_harness,no_run
13583/// # extern crate hyper;
13584/// # extern crate hyper_rustls;
13585/// # extern crate google_calendar3 as calendar3;
13586/// use calendar3::api::Event;
13587/// # async fn dox() {
13588/// # use calendar3::{CalendarHub, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
13589///
13590/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
13591/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
13592/// # .with_native_roots()
13593/// # .unwrap()
13594/// # .https_only()
13595/// # .enable_http2()
13596/// # .build();
13597///
13598/// # let executor = hyper_util::rt::TokioExecutor::new();
13599/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
13600/// # secret,
13601/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
13602/// # yup_oauth2::client::CustomHyperClientBuilder::from(
13603/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
13604/// # ),
13605/// # ).build().await.unwrap();
13606///
13607/// # let client = hyper_util::client::legacy::Client::builder(
13608/// # hyper_util::rt::TokioExecutor::new()
13609/// # )
13610/// # .build(
13611/// # hyper_rustls::HttpsConnectorBuilder::new()
13612/// # .with_native_roots()
13613/// # .unwrap()
13614/// # .https_or_http()
13615/// # .enable_http2()
13616/// # .build()
13617/// # );
13618/// # let mut hub = CalendarHub::new(client, auth);
13619/// // As the method needs a request, you would usually fill it with the desired information
13620/// // into the respective structure. Some of the parts shown here might not be applicable !
13621/// // Values shown here are possibly random and not representative !
13622/// let mut req = Event::default();
13623///
13624/// // You can configure optional parameters by calling the respective setters at will, and
13625/// // execute the final call using `doit()`.
13626/// // Values shown here are possibly random and not representative !
13627/// let result = hub.events().update(req, "calendarId", "eventId")
13628/// .supports_attachments(true)
13629/// .send_updates("accusam")
13630/// .send_notifications(true)
13631/// .max_attendees(-45)
13632/// .conference_data_version(-27)
13633/// .always_include_email(true)
13634/// .doit().await;
13635/// # }
13636/// ```
13637pub struct EventUpdateCall<'a, C>
13638where
13639 C: 'a,
13640{
13641 hub: &'a CalendarHub<C>,
13642 _request: Event,
13643 _calendar_id: String,
13644 _event_id: String,
13645 _supports_attachments: Option<bool>,
13646 _send_updates: Option<String>,
13647 _send_notifications: Option<bool>,
13648 _max_attendees: Option<i32>,
13649 _conference_data_version: Option<i32>,
13650 _always_include_email: Option<bool>,
13651 _delegate: Option<&'a mut dyn common::Delegate>,
13652 _additional_params: HashMap<String, String>,
13653 _scopes: BTreeSet<String>,
13654}
13655
13656impl<'a, C> common::CallBuilder for EventUpdateCall<'a, C> {}
13657
13658impl<'a, C> EventUpdateCall<'a, C>
13659where
13660 C: common::Connector,
13661{
13662 /// Perform the operation you have build so far.
13663 pub async fn doit(mut self) -> common::Result<(common::Response, Event)> {
13664 use std::borrow::Cow;
13665 use std::io::{Read, Seek};
13666
13667 use common::{url::Params, ToParts};
13668 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
13669
13670 let mut dd = common::DefaultDelegate;
13671 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
13672 dlg.begin(common::MethodInfo {
13673 id: "calendar.events.update",
13674 http_method: hyper::Method::PUT,
13675 });
13676
13677 for &field in [
13678 "alt",
13679 "calendarId",
13680 "eventId",
13681 "supportsAttachments",
13682 "sendUpdates",
13683 "sendNotifications",
13684 "maxAttendees",
13685 "conferenceDataVersion",
13686 "alwaysIncludeEmail",
13687 ]
13688 .iter()
13689 {
13690 if self._additional_params.contains_key(field) {
13691 dlg.finished(false);
13692 return Err(common::Error::FieldClash(field));
13693 }
13694 }
13695
13696 let mut params = Params::with_capacity(11 + self._additional_params.len());
13697 params.push("calendarId", self._calendar_id);
13698 params.push("eventId", self._event_id);
13699 if let Some(value) = self._supports_attachments.as_ref() {
13700 params.push("supportsAttachments", value.to_string());
13701 }
13702 if let Some(value) = self._send_updates.as_ref() {
13703 params.push("sendUpdates", value);
13704 }
13705 if let Some(value) = self._send_notifications.as_ref() {
13706 params.push("sendNotifications", value.to_string());
13707 }
13708 if let Some(value) = self._max_attendees.as_ref() {
13709 params.push("maxAttendees", value.to_string());
13710 }
13711 if let Some(value) = self._conference_data_version.as_ref() {
13712 params.push("conferenceDataVersion", value.to_string());
13713 }
13714 if let Some(value) = self._always_include_email.as_ref() {
13715 params.push("alwaysIncludeEmail", value.to_string());
13716 }
13717
13718 params.extend(self._additional_params.iter());
13719
13720 params.push("alt", "json");
13721 let mut url = self.hub._base_url.clone() + "calendars/{calendarId}/events/{eventId}";
13722 if self._scopes.is_empty() {
13723 self._scopes.insert(Scope::Full.as_ref().to_string());
13724 }
13725
13726 #[allow(clippy::single_element_loop)]
13727 for &(find_this, param_name) in
13728 [("{calendarId}", "calendarId"), ("{eventId}", "eventId")].iter()
13729 {
13730 url = params.uri_replacement(url, param_name, find_this, false);
13731 }
13732 {
13733 let to_remove = ["eventId", "calendarId"];
13734 params.remove_params(&to_remove);
13735 }
13736
13737 let url = params.parse_with_url(&url);
13738
13739 let mut json_mime_type = mime::APPLICATION_JSON;
13740 let mut request_value_reader = {
13741 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
13742 common::remove_json_null_values(&mut value);
13743 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
13744 serde_json::to_writer(&mut dst, &value).unwrap();
13745 dst
13746 };
13747 let request_size = request_value_reader
13748 .seek(std::io::SeekFrom::End(0))
13749 .unwrap();
13750 request_value_reader
13751 .seek(std::io::SeekFrom::Start(0))
13752 .unwrap();
13753
13754 loop {
13755 let token = match self
13756 .hub
13757 .auth
13758 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
13759 .await
13760 {
13761 Ok(token) => token,
13762 Err(e) => match dlg.token(e) {
13763 Ok(token) => token,
13764 Err(e) => {
13765 dlg.finished(false);
13766 return Err(common::Error::MissingToken(e));
13767 }
13768 },
13769 };
13770 request_value_reader
13771 .seek(std::io::SeekFrom::Start(0))
13772 .unwrap();
13773 let mut req_result = {
13774 let client = &self.hub.client;
13775 dlg.pre_request();
13776 let mut req_builder = hyper::Request::builder()
13777 .method(hyper::Method::PUT)
13778 .uri(url.as_str())
13779 .header(USER_AGENT, self.hub._user_agent.clone());
13780
13781 if let Some(token) = token.as_ref() {
13782 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
13783 }
13784
13785 let request = req_builder
13786 .header(CONTENT_TYPE, json_mime_type.to_string())
13787 .header(CONTENT_LENGTH, request_size as u64)
13788 .body(common::to_body(
13789 request_value_reader.get_ref().clone().into(),
13790 ));
13791
13792 client.request(request.unwrap()).await
13793 };
13794
13795 match req_result {
13796 Err(err) => {
13797 if let common::Retry::After(d) = dlg.http_error(&err) {
13798 sleep(d).await;
13799 continue;
13800 }
13801 dlg.finished(false);
13802 return Err(common::Error::HttpError(err));
13803 }
13804 Ok(res) => {
13805 let (mut parts, body) = res.into_parts();
13806 let mut body = common::Body::new(body);
13807 if !parts.status.is_success() {
13808 let bytes = common::to_bytes(body).await.unwrap_or_default();
13809 let error = serde_json::from_str(&common::to_string(&bytes));
13810 let response = common::to_response(parts, bytes.into());
13811
13812 if let common::Retry::After(d) =
13813 dlg.http_failure(&response, error.as_ref().ok())
13814 {
13815 sleep(d).await;
13816 continue;
13817 }
13818
13819 dlg.finished(false);
13820
13821 return Err(match error {
13822 Ok(value) => common::Error::BadRequest(value),
13823 _ => common::Error::Failure(response),
13824 });
13825 }
13826 let response = {
13827 let bytes = common::to_bytes(body).await.unwrap_or_default();
13828 let encoded = common::to_string(&bytes);
13829 match serde_json::from_str(&encoded) {
13830 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
13831 Err(error) => {
13832 dlg.response_json_decode_error(&encoded, &error);
13833 return Err(common::Error::JsonDecodeError(
13834 encoded.to_string(),
13835 error,
13836 ));
13837 }
13838 }
13839 };
13840
13841 dlg.finished(true);
13842 return Ok(response);
13843 }
13844 }
13845 }
13846 }
13847
13848 ///
13849 /// Sets the *request* property to the given value.
13850 ///
13851 /// Even though the property as already been set when instantiating this call,
13852 /// we provide this method for API completeness.
13853 pub fn request(mut self, new_value: Event) -> EventUpdateCall<'a, C> {
13854 self._request = new_value;
13855 self
13856 }
13857 /// 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.
13858 ///
13859 /// Sets the *calendar id* path property to the given value.
13860 ///
13861 /// Even though the property as already been set when instantiating this call,
13862 /// we provide this method for API completeness.
13863 pub fn calendar_id(mut self, new_value: &str) -> EventUpdateCall<'a, C> {
13864 self._calendar_id = new_value.to_string();
13865 self
13866 }
13867 /// Event identifier.
13868 ///
13869 /// Sets the *event id* path property to the given value.
13870 ///
13871 /// Even though the property as already been set when instantiating this call,
13872 /// we provide this method for API completeness.
13873 pub fn event_id(mut self, new_value: &str) -> EventUpdateCall<'a, C> {
13874 self._event_id = new_value.to_string();
13875 self
13876 }
13877 /// Whether API client performing operation supports event attachments. Optional. The default is False.
13878 ///
13879 /// Sets the *supports attachments* query property to the given value.
13880 pub fn supports_attachments(mut self, new_value: bool) -> EventUpdateCall<'a, C> {
13881 self._supports_attachments = Some(new_value);
13882 self
13883 }
13884 /// Guests who should receive notifications about the event update (for example, title changes, etc.).
13885 ///
13886 /// Sets the *send updates* query property to the given value.
13887 pub fn send_updates(mut self, new_value: &str) -> EventUpdateCall<'a, C> {
13888 self._send_updates = Some(new_value.to_string());
13889 self
13890 }
13891 /// Deprecated. Please use sendUpdates instead.
13892 ///
13893 /// 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.
13894 ///
13895 /// Sets the *send notifications* query property to the given value.
13896 pub fn send_notifications(mut self, new_value: bool) -> EventUpdateCall<'a, C> {
13897 self._send_notifications = Some(new_value);
13898 self
13899 }
13900 /// 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.
13901 ///
13902 /// Sets the *max attendees* query property to the given value.
13903 pub fn max_attendees(mut self, new_value: i32) -> EventUpdateCall<'a, C> {
13904 self._max_attendees = Some(new_value);
13905 self
13906 }
13907 /// 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.
13908 ///
13909 /// Sets the *conference data version* query property to the given value.
13910 pub fn conference_data_version(mut self, new_value: i32) -> EventUpdateCall<'a, C> {
13911 self._conference_data_version = Some(new_value);
13912 self
13913 }
13914 /// 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).
13915 ///
13916 /// Sets the *always include email* query property to the given value.
13917 pub fn always_include_email(mut self, new_value: bool) -> EventUpdateCall<'a, C> {
13918 self._always_include_email = Some(new_value);
13919 self
13920 }
13921 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
13922 /// while executing the actual API request.
13923 ///
13924 /// ````text
13925 /// It should be used to handle progress information, and to implement a certain level of resilience.
13926 /// ````
13927 ///
13928 /// Sets the *delegate* property to the given value.
13929 pub fn delegate(mut self, new_value: &'a mut dyn common::Delegate) -> EventUpdateCall<'a, C> {
13930 self._delegate = Some(new_value);
13931 self
13932 }
13933
13934 /// Set any additional parameter of the query string used in the request.
13935 /// It should be used to set parameters which are not yet available through their own
13936 /// setters.
13937 ///
13938 /// Please note that this method must not be used to set any of the known parameters
13939 /// which have their own setter method. If done anyway, the request will fail.
13940 ///
13941 /// # Additional Parameters
13942 ///
13943 /// * *alt* (query-string) - Data format for the response.
13944 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
13945 /// * *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.
13946 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
13947 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
13948 /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
13949 /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
13950 pub fn param<T>(mut self, name: T, value: T) -> EventUpdateCall<'a, C>
13951 where
13952 T: AsRef<str>,
13953 {
13954 self._additional_params
13955 .insert(name.as_ref().to_string(), value.as_ref().to_string());
13956 self
13957 }
13958
13959 /// Identifies the authorization scope for the method you are building.
13960 ///
13961 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
13962 /// [`Scope::Full`].
13963 ///
13964 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
13965 /// tokens for more than one scope.
13966 ///
13967 /// Usually there is more than one suitable scope to authorize an operation, some of which may
13968 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
13969 /// sufficient, a read-write scope will do as well.
13970 pub fn add_scope<St>(mut self, scope: St) -> EventUpdateCall<'a, C>
13971 where
13972 St: AsRef<str>,
13973 {
13974 self._scopes.insert(String::from(scope.as_ref()));
13975 self
13976 }
13977 /// Identifies the authorization scope(s) for the method you are building.
13978 ///
13979 /// See [`Self::add_scope()`] for details.
13980 pub fn add_scopes<I, St>(mut self, scopes: I) -> EventUpdateCall<'a, C>
13981 where
13982 I: IntoIterator<Item = St>,
13983 St: AsRef<str>,
13984 {
13985 self._scopes
13986 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
13987 self
13988 }
13989
13990 /// Removes all scopes, and no default scope will be used either.
13991 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
13992 /// for details).
13993 pub fn clear_scopes(mut self) -> EventUpdateCall<'a, C> {
13994 self._scopes.clear();
13995 self
13996 }
13997}
13998
13999/// Watch for changes to Events resources.
14000///
14001/// A builder for the *watch* method supported by a *event* resource.
14002/// It is not used directly, but through a [`EventMethods`] instance.
14003///
14004/// # Example
14005///
14006/// Instantiate a resource method builder
14007///
14008/// ```test_harness,no_run
14009/// # extern crate hyper;
14010/// # extern crate hyper_rustls;
14011/// # extern crate google_calendar3 as calendar3;
14012/// use calendar3::api::Channel;
14013/// # async fn dox() {
14014/// # use calendar3::{CalendarHub, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
14015///
14016/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
14017/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
14018/// # .with_native_roots()
14019/// # .unwrap()
14020/// # .https_only()
14021/// # .enable_http2()
14022/// # .build();
14023///
14024/// # let executor = hyper_util::rt::TokioExecutor::new();
14025/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
14026/// # secret,
14027/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
14028/// # yup_oauth2::client::CustomHyperClientBuilder::from(
14029/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
14030/// # ),
14031/// # ).build().await.unwrap();
14032///
14033/// # let client = hyper_util::client::legacy::Client::builder(
14034/// # hyper_util::rt::TokioExecutor::new()
14035/// # )
14036/// # .build(
14037/// # hyper_rustls::HttpsConnectorBuilder::new()
14038/// # .with_native_roots()
14039/// # .unwrap()
14040/// # .https_or_http()
14041/// # .enable_http2()
14042/// # .build()
14043/// # );
14044/// # let mut hub = CalendarHub::new(client, auth);
14045/// // As the method needs a request, you would usually fill it with the desired information
14046/// // into the respective structure. Some of the parts shown here might not be applicable !
14047/// // Values shown here are possibly random and not representative !
14048/// let mut req = Channel::default();
14049///
14050/// // You can configure optional parameters by calling the respective setters at will, and
14051/// // execute the final call using `doit()`.
14052/// // Values shown here are possibly random and not representative !
14053/// let result = hub.events().watch(req, "calendarId")
14054/// .updated_min(chrono::Utc::now())
14055/// .time_zone("sit")
14056/// .time_min(chrono::Utc::now())
14057/// .time_max(chrono::Utc::now())
14058/// .sync_token("magna")
14059/// .single_events(true)
14060/// .show_hidden_invitations(false)
14061/// .show_deleted(true)
14062/// .add_shared_extended_property("no")
14063/// .q("nonumy")
14064/// .add_private_extended_property("sed")
14065/// .page_token("kasd")
14066/// .order_by("Lorem")
14067/// .max_results(-58)
14068/// .max_attendees(-91)
14069/// .i_cal_uid("rebum.")
14070/// .add_event_types("tempor")
14071/// .always_include_email(true)
14072/// .doit().await;
14073/// # }
14074/// ```
14075pub struct EventWatchCall<'a, C>
14076where
14077 C: 'a,
14078{
14079 hub: &'a CalendarHub<C>,
14080 _request: Channel,
14081 _calendar_id: String,
14082 _updated_min: Option<chrono::DateTime<chrono::offset::Utc>>,
14083 _time_zone: Option<String>,
14084 _time_min: Option<chrono::DateTime<chrono::offset::Utc>>,
14085 _time_max: Option<chrono::DateTime<chrono::offset::Utc>>,
14086 _sync_token: Option<String>,
14087 _single_events: Option<bool>,
14088 _show_hidden_invitations: Option<bool>,
14089 _show_deleted: Option<bool>,
14090 _shared_extended_property: Vec<String>,
14091 _q: Option<String>,
14092 _private_extended_property: Vec<String>,
14093 _page_token: Option<String>,
14094 _order_by: Option<String>,
14095 _max_results: Option<i32>,
14096 _max_attendees: Option<i32>,
14097 _i_cal_uid: Option<String>,
14098 _event_types: Vec<String>,
14099 _always_include_email: Option<bool>,
14100 _delegate: Option<&'a mut dyn common::Delegate>,
14101 _additional_params: HashMap<String, String>,
14102 _scopes: BTreeSet<String>,
14103}
14104
14105impl<'a, C> common::CallBuilder for EventWatchCall<'a, C> {}
14106
14107impl<'a, C> EventWatchCall<'a, C>
14108where
14109 C: common::Connector,
14110{
14111 /// Perform the operation you have build so far.
14112 pub async fn doit(mut self) -> common::Result<(common::Response, Channel)> {
14113 use std::borrow::Cow;
14114 use std::io::{Read, Seek};
14115
14116 use common::{url::Params, ToParts};
14117 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
14118
14119 let mut dd = common::DefaultDelegate;
14120 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
14121 dlg.begin(common::MethodInfo {
14122 id: "calendar.events.watch",
14123 http_method: hyper::Method::POST,
14124 });
14125
14126 for &field in [
14127 "alt",
14128 "calendarId",
14129 "updatedMin",
14130 "timeZone",
14131 "timeMin",
14132 "timeMax",
14133 "syncToken",
14134 "singleEvents",
14135 "showHiddenInvitations",
14136 "showDeleted",
14137 "sharedExtendedProperty",
14138 "q",
14139 "privateExtendedProperty",
14140 "pageToken",
14141 "orderBy",
14142 "maxResults",
14143 "maxAttendees",
14144 "iCalUID",
14145 "eventTypes",
14146 "alwaysIncludeEmail",
14147 ]
14148 .iter()
14149 {
14150 if self._additional_params.contains_key(field) {
14151 dlg.finished(false);
14152 return Err(common::Error::FieldClash(field));
14153 }
14154 }
14155
14156 let mut params = Params::with_capacity(22 + self._additional_params.len());
14157 params.push("calendarId", self._calendar_id);
14158 if let Some(value) = self._updated_min.as_ref() {
14159 params.push("updatedMin", common::serde::datetime_to_string(&value));
14160 }
14161 if let Some(value) = self._time_zone.as_ref() {
14162 params.push("timeZone", value);
14163 }
14164 if let Some(value) = self._time_min.as_ref() {
14165 params.push("timeMin", common::serde::datetime_to_string(&value));
14166 }
14167 if let Some(value) = self._time_max.as_ref() {
14168 params.push("timeMax", common::serde::datetime_to_string(&value));
14169 }
14170 if let Some(value) = self._sync_token.as_ref() {
14171 params.push("syncToken", value);
14172 }
14173 if let Some(value) = self._single_events.as_ref() {
14174 params.push("singleEvents", value.to_string());
14175 }
14176 if let Some(value) = self._show_hidden_invitations.as_ref() {
14177 params.push("showHiddenInvitations", value.to_string());
14178 }
14179 if let Some(value) = self._show_deleted.as_ref() {
14180 params.push("showDeleted", value.to_string());
14181 }
14182 if !self._shared_extended_property.is_empty() {
14183 for f in self._shared_extended_property.iter() {
14184 params.push("sharedExtendedProperty", f);
14185 }
14186 }
14187 if let Some(value) = self._q.as_ref() {
14188 params.push("q", value);
14189 }
14190 if !self._private_extended_property.is_empty() {
14191 for f in self._private_extended_property.iter() {
14192 params.push("privateExtendedProperty", f);
14193 }
14194 }
14195 if let Some(value) = self._page_token.as_ref() {
14196 params.push("pageToken", value);
14197 }
14198 if let Some(value) = self._order_by.as_ref() {
14199 params.push("orderBy", value);
14200 }
14201 if let Some(value) = self._max_results.as_ref() {
14202 params.push("maxResults", value.to_string());
14203 }
14204 if let Some(value) = self._max_attendees.as_ref() {
14205 params.push("maxAttendees", value.to_string());
14206 }
14207 if let Some(value) = self._i_cal_uid.as_ref() {
14208 params.push("iCalUID", value);
14209 }
14210 if !self._event_types.is_empty() {
14211 for f in self._event_types.iter() {
14212 params.push("eventTypes", f);
14213 }
14214 }
14215 if let Some(value) = self._always_include_email.as_ref() {
14216 params.push("alwaysIncludeEmail", value.to_string());
14217 }
14218
14219 params.extend(self._additional_params.iter());
14220
14221 params.push("alt", "json");
14222 let mut url = self.hub._base_url.clone() + "calendars/{calendarId}/events/watch";
14223 if self._scopes.is_empty() {
14224 self._scopes
14225 .insert(Scope::EventOwnedReadonly.as_ref().to_string());
14226 }
14227
14228 #[allow(clippy::single_element_loop)]
14229 for &(find_this, param_name) in [("{calendarId}", "calendarId")].iter() {
14230 url = params.uri_replacement(url, param_name, find_this, false);
14231 }
14232 {
14233 let to_remove = ["calendarId"];
14234 params.remove_params(&to_remove);
14235 }
14236
14237 let url = params.parse_with_url(&url);
14238
14239 let mut json_mime_type = mime::APPLICATION_JSON;
14240 let mut request_value_reader = {
14241 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
14242 common::remove_json_null_values(&mut value);
14243 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
14244 serde_json::to_writer(&mut dst, &value).unwrap();
14245 dst
14246 };
14247 let request_size = request_value_reader
14248 .seek(std::io::SeekFrom::End(0))
14249 .unwrap();
14250 request_value_reader
14251 .seek(std::io::SeekFrom::Start(0))
14252 .unwrap();
14253
14254 loop {
14255 let token = match self
14256 .hub
14257 .auth
14258 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
14259 .await
14260 {
14261 Ok(token) => token,
14262 Err(e) => match dlg.token(e) {
14263 Ok(token) => token,
14264 Err(e) => {
14265 dlg.finished(false);
14266 return Err(common::Error::MissingToken(e));
14267 }
14268 },
14269 };
14270 request_value_reader
14271 .seek(std::io::SeekFrom::Start(0))
14272 .unwrap();
14273 let mut req_result = {
14274 let client = &self.hub.client;
14275 dlg.pre_request();
14276 let mut req_builder = hyper::Request::builder()
14277 .method(hyper::Method::POST)
14278 .uri(url.as_str())
14279 .header(USER_AGENT, self.hub._user_agent.clone());
14280
14281 if let Some(token) = token.as_ref() {
14282 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
14283 }
14284
14285 let request = req_builder
14286 .header(CONTENT_TYPE, json_mime_type.to_string())
14287 .header(CONTENT_LENGTH, request_size as u64)
14288 .body(common::to_body(
14289 request_value_reader.get_ref().clone().into(),
14290 ));
14291
14292 client.request(request.unwrap()).await
14293 };
14294
14295 match req_result {
14296 Err(err) => {
14297 if let common::Retry::After(d) = dlg.http_error(&err) {
14298 sleep(d).await;
14299 continue;
14300 }
14301 dlg.finished(false);
14302 return Err(common::Error::HttpError(err));
14303 }
14304 Ok(res) => {
14305 let (mut parts, body) = res.into_parts();
14306 let mut body = common::Body::new(body);
14307 if !parts.status.is_success() {
14308 let bytes = common::to_bytes(body).await.unwrap_or_default();
14309 let error = serde_json::from_str(&common::to_string(&bytes));
14310 let response = common::to_response(parts, bytes.into());
14311
14312 if let common::Retry::After(d) =
14313 dlg.http_failure(&response, error.as_ref().ok())
14314 {
14315 sleep(d).await;
14316 continue;
14317 }
14318
14319 dlg.finished(false);
14320
14321 return Err(match error {
14322 Ok(value) => common::Error::BadRequest(value),
14323 _ => common::Error::Failure(response),
14324 });
14325 }
14326 let response = {
14327 let bytes = common::to_bytes(body).await.unwrap_or_default();
14328 let encoded = common::to_string(&bytes);
14329 match serde_json::from_str(&encoded) {
14330 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
14331 Err(error) => {
14332 dlg.response_json_decode_error(&encoded, &error);
14333 return Err(common::Error::JsonDecodeError(
14334 encoded.to_string(),
14335 error,
14336 ));
14337 }
14338 }
14339 };
14340
14341 dlg.finished(true);
14342 return Ok(response);
14343 }
14344 }
14345 }
14346 }
14347
14348 ///
14349 /// Sets the *request* property to the given value.
14350 ///
14351 /// Even though the property as already been set when instantiating this call,
14352 /// we provide this method for API completeness.
14353 pub fn request(mut self, new_value: Channel) -> EventWatchCall<'a, C> {
14354 self._request = new_value;
14355 self
14356 }
14357 /// 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.
14358 ///
14359 /// Sets the *calendar id* path property to the given value.
14360 ///
14361 /// Even though the property as already been set when instantiating this call,
14362 /// we provide this method for API completeness.
14363 pub fn calendar_id(mut self, new_value: &str) -> EventWatchCall<'a, C> {
14364 self._calendar_id = new_value.to_string();
14365 self
14366 }
14367 /// 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.
14368 ///
14369 /// Sets the *updated min* query property to the given value.
14370 pub fn updated_min(
14371 mut self,
14372 new_value: chrono::DateTime<chrono::offset::Utc>,
14373 ) -> EventWatchCall<'a, C> {
14374 self._updated_min = Some(new_value);
14375 self
14376 }
14377 /// Time zone used in the response. Optional. The default is the time zone of the calendar.
14378 ///
14379 /// Sets the *time zone* query property to the given value.
14380 pub fn time_zone(mut self, new_value: &str) -> EventWatchCall<'a, C> {
14381 self._time_zone = Some(new_value.to_string());
14382 self
14383 }
14384 /// 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.
14385 ///
14386 /// Sets the *time min* query property to the given value.
14387 pub fn time_min(
14388 mut self,
14389 new_value: chrono::DateTime<chrono::offset::Utc>,
14390 ) -> EventWatchCall<'a, C> {
14391 self._time_min = Some(new_value);
14392 self
14393 }
14394 /// 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.
14395 ///
14396 /// Sets the *time max* query property to the given value.
14397 pub fn time_max(
14398 mut self,
14399 new_value: chrono::DateTime<chrono::offset::Utc>,
14400 ) -> EventWatchCall<'a, C> {
14401 self._time_max = Some(new_value);
14402 self
14403 }
14404 /// 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.
14405 /// There are several query parameters that cannot be specified together with nextSyncToken to ensure consistency of the client state.
14406 ///
14407 /// These are:
14408 /// - iCalUID
14409 /// - orderBy
14410 /// - privateExtendedProperty
14411 /// - q
14412 /// - sharedExtendedProperty
14413 /// - timeMin
14414 /// - timeMax
14415 /// - 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.
14416 /// Learn more about incremental synchronization.
14417 /// Optional. The default is to return all entries.
14418 ///
14419 /// Sets the *sync token* query property to the given value.
14420 pub fn sync_token(mut self, new_value: &str) -> EventWatchCall<'a, C> {
14421 self._sync_token = Some(new_value.to_string());
14422 self
14423 }
14424 /// 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.
14425 ///
14426 /// Sets the *single events* query property to the given value.
14427 pub fn single_events(mut self, new_value: bool) -> EventWatchCall<'a, C> {
14428 self._single_events = Some(new_value);
14429 self
14430 }
14431 /// Whether to include hidden invitations in the result. Optional. The default is False.
14432 ///
14433 /// Sets the *show hidden invitations* query property to the given value.
14434 pub fn show_hidden_invitations(mut self, new_value: bool) -> EventWatchCall<'a, C> {
14435 self._show_hidden_invitations = Some(new_value);
14436 self
14437 }
14438 /// 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.
14439 ///
14440 /// Sets the *show deleted* query property to the given value.
14441 pub fn show_deleted(mut self, new_value: bool) -> EventWatchCall<'a, C> {
14442 self._show_deleted = Some(new_value);
14443 self
14444 }
14445 /// 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.
14446 ///
14447 /// Append the given value to the *shared extended property* query property.
14448 /// Each appended value will retain its original ordering and be '/'-separated in the URL's parameters.
14449 pub fn add_shared_extended_property(mut self, new_value: &str) -> EventWatchCall<'a, C> {
14450 self._shared_extended_property.push(new_value.to_string());
14451 self
14452 }
14453 /// Free text search terms to find events that match these terms in the following fields:
14454 ///
14455 /// - summary
14456 /// - description
14457 /// - location
14458 /// - attendee's displayName
14459 /// - attendee's email
14460 /// - organizer's displayName
14461 /// - organizer's email
14462 /// - workingLocationProperties.officeLocation.buildingId
14463 /// - workingLocationProperties.officeLocation.deskId
14464 /// - workingLocationProperties.officeLocation.label
14465 /// - workingLocationProperties.customLocation.label
14466 /// 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.
14467 ///
14468 /// Sets the *q* query property to the given value.
14469 pub fn q(mut self, new_value: &str) -> EventWatchCall<'a, C> {
14470 self._q = Some(new_value.to_string());
14471 self
14472 }
14473 /// 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.
14474 ///
14475 /// Append the given value to the *private extended property* query property.
14476 /// Each appended value will retain its original ordering and be '/'-separated in the URL's parameters.
14477 pub fn add_private_extended_property(mut self, new_value: &str) -> EventWatchCall<'a, C> {
14478 self._private_extended_property.push(new_value.to_string());
14479 self
14480 }
14481 /// Token specifying which result page to return. Optional.
14482 ///
14483 /// Sets the *page token* query property to the given value.
14484 pub fn page_token(mut self, new_value: &str) -> EventWatchCall<'a, C> {
14485 self._page_token = Some(new_value.to_string());
14486 self
14487 }
14488 /// The order of the events returned in the result. Optional. The default is an unspecified, stable order.
14489 ///
14490 /// Sets the *order by* query property to the given value.
14491 pub fn order_by(mut self, new_value: &str) -> EventWatchCall<'a, C> {
14492 self._order_by = Some(new_value.to_string());
14493 self
14494 }
14495 /// 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.
14496 ///
14497 /// Sets the *max results* query property to the given value.
14498 pub fn max_results(mut self, new_value: i32) -> EventWatchCall<'a, C> {
14499 self._max_results = Some(new_value);
14500 self
14501 }
14502 /// 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.
14503 ///
14504 /// Sets the *max attendees* query property to the given value.
14505 pub fn max_attendees(mut self, new_value: i32) -> EventWatchCall<'a, C> {
14506 self._max_attendees = Some(new_value);
14507 self
14508 }
14509 /// 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.
14510 ///
14511 /// Sets the *i cal uid* query property to the given value.
14512 pub fn i_cal_uid(mut self, new_value: &str) -> EventWatchCall<'a, C> {
14513 self._i_cal_uid = Some(new_value.to_string());
14514 self
14515 }
14516 /// Event types to return. Optional. This parameter can be repeated multiple times to return events of different types. If unset, returns all event types.
14517 ///
14518 /// Append the given value to the *event types* query property.
14519 /// Each appended value will retain its original ordering and be '/'-separated in the URL's parameters.
14520 pub fn add_event_types(mut self, new_value: &str) -> EventWatchCall<'a, C> {
14521 self._event_types.push(new_value.to_string());
14522 self
14523 }
14524 /// Deprecated and ignored.
14525 ///
14526 /// Sets the *always include email* query property to the given value.
14527 pub fn always_include_email(mut self, new_value: bool) -> EventWatchCall<'a, C> {
14528 self._always_include_email = Some(new_value);
14529 self
14530 }
14531 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
14532 /// while executing the actual API request.
14533 ///
14534 /// ````text
14535 /// It should be used to handle progress information, and to implement a certain level of resilience.
14536 /// ````
14537 ///
14538 /// Sets the *delegate* property to the given value.
14539 pub fn delegate(mut self, new_value: &'a mut dyn common::Delegate) -> EventWatchCall<'a, C> {
14540 self._delegate = Some(new_value);
14541 self
14542 }
14543
14544 /// Set any additional parameter of the query string used in the request.
14545 /// It should be used to set parameters which are not yet available through their own
14546 /// setters.
14547 ///
14548 /// Please note that this method must not be used to set any of the known parameters
14549 /// which have their own setter method. If done anyway, the request will fail.
14550 ///
14551 /// # Additional Parameters
14552 ///
14553 /// * *alt* (query-string) - Data format for the response.
14554 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
14555 /// * *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.
14556 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
14557 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
14558 /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
14559 /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
14560 pub fn param<T>(mut self, name: T, value: T) -> EventWatchCall<'a, C>
14561 where
14562 T: AsRef<str>,
14563 {
14564 self._additional_params
14565 .insert(name.as_ref().to_string(), value.as_ref().to_string());
14566 self
14567 }
14568
14569 /// Identifies the authorization scope for the method you are building.
14570 ///
14571 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
14572 /// [`Scope::EventOwnedReadonly`].
14573 ///
14574 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
14575 /// tokens for more than one scope.
14576 ///
14577 /// Usually there is more than one suitable scope to authorize an operation, some of which may
14578 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
14579 /// sufficient, a read-write scope will do as well.
14580 pub fn add_scope<St>(mut self, scope: St) -> EventWatchCall<'a, C>
14581 where
14582 St: AsRef<str>,
14583 {
14584 self._scopes.insert(String::from(scope.as_ref()));
14585 self
14586 }
14587 /// Identifies the authorization scope(s) for the method you are building.
14588 ///
14589 /// See [`Self::add_scope()`] for details.
14590 pub fn add_scopes<I, St>(mut self, scopes: I) -> EventWatchCall<'a, C>
14591 where
14592 I: IntoIterator<Item = St>,
14593 St: AsRef<str>,
14594 {
14595 self._scopes
14596 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
14597 self
14598 }
14599
14600 /// Removes all scopes, and no default scope will be used either.
14601 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
14602 /// for details).
14603 pub fn clear_scopes(mut self) -> EventWatchCall<'a, C> {
14604 self._scopes.clear();
14605 self
14606 }
14607}
14608
14609/// Returns free/busy information for a set of calendars.
14610///
14611/// A builder for the *query* method supported by a *freebusy* resource.
14612/// It is not used directly, but through a [`FreebusyMethods`] instance.
14613///
14614/// # Example
14615///
14616/// Instantiate a resource method builder
14617///
14618/// ```test_harness,no_run
14619/// # extern crate hyper;
14620/// # extern crate hyper_rustls;
14621/// # extern crate google_calendar3 as calendar3;
14622/// use calendar3::api::FreeBusyRequest;
14623/// # async fn dox() {
14624/// # use calendar3::{CalendarHub, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
14625///
14626/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
14627/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
14628/// # .with_native_roots()
14629/// # .unwrap()
14630/// # .https_only()
14631/// # .enable_http2()
14632/// # .build();
14633///
14634/// # let executor = hyper_util::rt::TokioExecutor::new();
14635/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
14636/// # secret,
14637/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
14638/// # yup_oauth2::client::CustomHyperClientBuilder::from(
14639/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
14640/// # ),
14641/// # ).build().await.unwrap();
14642///
14643/// # let client = hyper_util::client::legacy::Client::builder(
14644/// # hyper_util::rt::TokioExecutor::new()
14645/// # )
14646/// # .build(
14647/// # hyper_rustls::HttpsConnectorBuilder::new()
14648/// # .with_native_roots()
14649/// # .unwrap()
14650/// # .https_or_http()
14651/// # .enable_http2()
14652/// # .build()
14653/// # );
14654/// # let mut hub = CalendarHub::new(client, auth);
14655/// // As the method needs a request, you would usually fill it with the desired information
14656/// // into the respective structure. Some of the parts shown here might not be applicable !
14657/// // Values shown here are possibly random and not representative !
14658/// let mut req = FreeBusyRequest::default();
14659///
14660/// // You can configure optional parameters by calling the respective setters at will, and
14661/// // execute the final call using `doit()`.
14662/// // Values shown here are possibly random and not representative !
14663/// let result = hub.freebusy().query(req)
14664/// .doit().await;
14665/// # }
14666/// ```
14667pub struct FreebusyQueryCall<'a, C>
14668where
14669 C: 'a,
14670{
14671 hub: &'a CalendarHub<C>,
14672 _request: FreeBusyRequest,
14673 _delegate: Option<&'a mut dyn common::Delegate>,
14674 _additional_params: HashMap<String, String>,
14675 _scopes: BTreeSet<String>,
14676}
14677
14678impl<'a, C> common::CallBuilder for FreebusyQueryCall<'a, C> {}
14679
14680impl<'a, C> FreebusyQueryCall<'a, C>
14681where
14682 C: common::Connector,
14683{
14684 /// Perform the operation you have build so far.
14685 pub async fn doit(mut self) -> common::Result<(common::Response, FreeBusyResponse)> {
14686 use std::borrow::Cow;
14687 use std::io::{Read, Seek};
14688
14689 use common::{url::Params, ToParts};
14690 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
14691
14692 let mut dd = common::DefaultDelegate;
14693 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
14694 dlg.begin(common::MethodInfo {
14695 id: "calendar.freebusy.query",
14696 http_method: hyper::Method::POST,
14697 });
14698
14699 for &field in ["alt"].iter() {
14700 if self._additional_params.contains_key(field) {
14701 dlg.finished(false);
14702 return Err(common::Error::FieldClash(field));
14703 }
14704 }
14705
14706 let mut params = Params::with_capacity(3 + self._additional_params.len());
14707
14708 params.extend(self._additional_params.iter());
14709
14710 params.push("alt", "json");
14711 let mut url = self.hub._base_url.clone() + "freeBusy";
14712 if self._scopes.is_empty() {
14713 self._scopes.insert(Scope::Readonly.as_ref().to_string());
14714 }
14715
14716 let url = params.parse_with_url(&url);
14717
14718 let mut json_mime_type = mime::APPLICATION_JSON;
14719 let mut request_value_reader = {
14720 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
14721 common::remove_json_null_values(&mut value);
14722 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
14723 serde_json::to_writer(&mut dst, &value).unwrap();
14724 dst
14725 };
14726 let request_size = request_value_reader
14727 .seek(std::io::SeekFrom::End(0))
14728 .unwrap();
14729 request_value_reader
14730 .seek(std::io::SeekFrom::Start(0))
14731 .unwrap();
14732
14733 loop {
14734 let token = match self
14735 .hub
14736 .auth
14737 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
14738 .await
14739 {
14740 Ok(token) => token,
14741 Err(e) => match dlg.token(e) {
14742 Ok(token) => token,
14743 Err(e) => {
14744 dlg.finished(false);
14745 return Err(common::Error::MissingToken(e));
14746 }
14747 },
14748 };
14749 request_value_reader
14750 .seek(std::io::SeekFrom::Start(0))
14751 .unwrap();
14752 let mut req_result = {
14753 let client = &self.hub.client;
14754 dlg.pre_request();
14755 let mut req_builder = hyper::Request::builder()
14756 .method(hyper::Method::POST)
14757 .uri(url.as_str())
14758 .header(USER_AGENT, self.hub._user_agent.clone());
14759
14760 if let Some(token) = token.as_ref() {
14761 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
14762 }
14763
14764 let request = req_builder
14765 .header(CONTENT_TYPE, json_mime_type.to_string())
14766 .header(CONTENT_LENGTH, request_size as u64)
14767 .body(common::to_body(
14768 request_value_reader.get_ref().clone().into(),
14769 ));
14770
14771 client.request(request.unwrap()).await
14772 };
14773
14774 match req_result {
14775 Err(err) => {
14776 if let common::Retry::After(d) = dlg.http_error(&err) {
14777 sleep(d).await;
14778 continue;
14779 }
14780 dlg.finished(false);
14781 return Err(common::Error::HttpError(err));
14782 }
14783 Ok(res) => {
14784 let (mut parts, body) = res.into_parts();
14785 let mut body = common::Body::new(body);
14786 if !parts.status.is_success() {
14787 let bytes = common::to_bytes(body).await.unwrap_or_default();
14788 let error = serde_json::from_str(&common::to_string(&bytes));
14789 let response = common::to_response(parts, bytes.into());
14790
14791 if let common::Retry::After(d) =
14792 dlg.http_failure(&response, error.as_ref().ok())
14793 {
14794 sleep(d).await;
14795 continue;
14796 }
14797
14798 dlg.finished(false);
14799
14800 return Err(match error {
14801 Ok(value) => common::Error::BadRequest(value),
14802 _ => common::Error::Failure(response),
14803 });
14804 }
14805 let response = {
14806 let bytes = common::to_bytes(body).await.unwrap_or_default();
14807 let encoded = common::to_string(&bytes);
14808 match serde_json::from_str(&encoded) {
14809 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
14810 Err(error) => {
14811 dlg.response_json_decode_error(&encoded, &error);
14812 return Err(common::Error::JsonDecodeError(
14813 encoded.to_string(),
14814 error,
14815 ));
14816 }
14817 }
14818 };
14819
14820 dlg.finished(true);
14821 return Ok(response);
14822 }
14823 }
14824 }
14825 }
14826
14827 ///
14828 /// Sets the *request* property to the given value.
14829 ///
14830 /// Even though the property as already been set when instantiating this call,
14831 /// we provide this method for API completeness.
14832 pub fn request(mut self, new_value: FreeBusyRequest) -> FreebusyQueryCall<'a, C> {
14833 self._request = new_value;
14834 self
14835 }
14836 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
14837 /// while executing the actual API request.
14838 ///
14839 /// ````text
14840 /// It should be used to handle progress information, and to implement a certain level of resilience.
14841 /// ````
14842 ///
14843 /// Sets the *delegate* property to the given value.
14844 pub fn delegate(mut self, new_value: &'a mut dyn common::Delegate) -> FreebusyQueryCall<'a, C> {
14845 self._delegate = Some(new_value);
14846 self
14847 }
14848
14849 /// Set any additional parameter of the query string used in the request.
14850 /// It should be used to set parameters which are not yet available through their own
14851 /// setters.
14852 ///
14853 /// Please note that this method must not be used to set any of the known parameters
14854 /// which have their own setter method. If done anyway, the request will fail.
14855 ///
14856 /// # Additional Parameters
14857 ///
14858 /// * *alt* (query-string) - Data format for the response.
14859 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
14860 /// * *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.
14861 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
14862 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
14863 /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
14864 /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
14865 pub fn param<T>(mut self, name: T, value: T) -> FreebusyQueryCall<'a, C>
14866 where
14867 T: AsRef<str>,
14868 {
14869 self._additional_params
14870 .insert(name.as_ref().to_string(), value.as_ref().to_string());
14871 self
14872 }
14873
14874 /// Identifies the authorization scope for the method you are building.
14875 ///
14876 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
14877 /// [`Scope::Readonly`].
14878 ///
14879 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
14880 /// tokens for more than one scope.
14881 ///
14882 /// Usually there is more than one suitable scope to authorize an operation, some of which may
14883 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
14884 /// sufficient, a read-write scope will do as well.
14885 pub fn add_scope<St>(mut self, scope: St) -> FreebusyQueryCall<'a, C>
14886 where
14887 St: AsRef<str>,
14888 {
14889 self._scopes.insert(String::from(scope.as_ref()));
14890 self
14891 }
14892 /// Identifies the authorization scope(s) for the method you are building.
14893 ///
14894 /// See [`Self::add_scope()`] for details.
14895 pub fn add_scopes<I, St>(mut self, scopes: I) -> FreebusyQueryCall<'a, C>
14896 where
14897 I: IntoIterator<Item = St>,
14898 St: AsRef<str>,
14899 {
14900 self._scopes
14901 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
14902 self
14903 }
14904
14905 /// Removes all scopes, and no default scope will be used either.
14906 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
14907 /// for details).
14908 pub fn clear_scopes(mut self) -> FreebusyQueryCall<'a, C> {
14909 self._scopes.clear();
14910 self
14911 }
14912}
14913
14914/// Returns a single user setting.
14915///
14916/// A builder for the *get* method supported by a *setting* resource.
14917/// It is not used directly, but through a [`SettingMethods`] instance.
14918///
14919/// # Example
14920///
14921/// Instantiate a resource method builder
14922///
14923/// ```test_harness,no_run
14924/// # extern crate hyper;
14925/// # extern crate hyper_rustls;
14926/// # extern crate google_calendar3 as calendar3;
14927/// # async fn dox() {
14928/// # use calendar3::{CalendarHub, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
14929///
14930/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
14931/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
14932/// # .with_native_roots()
14933/// # .unwrap()
14934/// # .https_only()
14935/// # .enable_http2()
14936/// # .build();
14937///
14938/// # let executor = hyper_util::rt::TokioExecutor::new();
14939/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
14940/// # secret,
14941/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
14942/// # yup_oauth2::client::CustomHyperClientBuilder::from(
14943/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
14944/// # ),
14945/// # ).build().await.unwrap();
14946///
14947/// # let client = hyper_util::client::legacy::Client::builder(
14948/// # hyper_util::rt::TokioExecutor::new()
14949/// # )
14950/// # .build(
14951/// # hyper_rustls::HttpsConnectorBuilder::new()
14952/// # .with_native_roots()
14953/// # .unwrap()
14954/// # .https_or_http()
14955/// # .enable_http2()
14956/// # .build()
14957/// # );
14958/// # let mut hub = CalendarHub::new(client, auth);
14959/// // You can configure optional parameters by calling the respective setters at will, and
14960/// // execute the final call using `doit()`.
14961/// // Values shown here are possibly random and not representative !
14962/// let result = hub.settings().get("setting")
14963/// .doit().await;
14964/// # }
14965/// ```
14966pub struct SettingGetCall<'a, C>
14967where
14968 C: 'a,
14969{
14970 hub: &'a CalendarHub<C>,
14971 _setting: String,
14972 _delegate: Option<&'a mut dyn common::Delegate>,
14973 _additional_params: HashMap<String, String>,
14974 _scopes: BTreeSet<String>,
14975}
14976
14977impl<'a, C> common::CallBuilder for SettingGetCall<'a, C> {}
14978
14979impl<'a, C> SettingGetCall<'a, C>
14980where
14981 C: common::Connector,
14982{
14983 /// Perform the operation you have build so far.
14984 pub async fn doit(mut self) -> common::Result<(common::Response, Setting)> {
14985 use std::borrow::Cow;
14986 use std::io::{Read, Seek};
14987
14988 use common::{url::Params, ToParts};
14989 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
14990
14991 let mut dd = common::DefaultDelegate;
14992 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
14993 dlg.begin(common::MethodInfo {
14994 id: "calendar.settings.get",
14995 http_method: hyper::Method::GET,
14996 });
14997
14998 for &field in ["alt", "setting"].iter() {
14999 if self._additional_params.contains_key(field) {
15000 dlg.finished(false);
15001 return Err(common::Error::FieldClash(field));
15002 }
15003 }
15004
15005 let mut params = Params::with_capacity(3 + self._additional_params.len());
15006 params.push("setting", self._setting);
15007
15008 params.extend(self._additional_params.iter());
15009
15010 params.push("alt", "json");
15011 let mut url = self.hub._base_url.clone() + "users/me/settings/{setting}";
15012 if self._scopes.is_empty() {
15013 self._scopes.insert(Scope::Readonly.as_ref().to_string());
15014 }
15015
15016 #[allow(clippy::single_element_loop)]
15017 for &(find_this, param_name) in [("{setting}", "setting")].iter() {
15018 url = params.uri_replacement(url, param_name, find_this, false);
15019 }
15020 {
15021 let to_remove = ["setting"];
15022 params.remove_params(&to_remove);
15023 }
15024
15025 let url = params.parse_with_url(&url);
15026
15027 loop {
15028 let token = match self
15029 .hub
15030 .auth
15031 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
15032 .await
15033 {
15034 Ok(token) => token,
15035 Err(e) => match dlg.token(e) {
15036 Ok(token) => token,
15037 Err(e) => {
15038 dlg.finished(false);
15039 return Err(common::Error::MissingToken(e));
15040 }
15041 },
15042 };
15043 let mut req_result = {
15044 let client = &self.hub.client;
15045 dlg.pre_request();
15046 let mut req_builder = hyper::Request::builder()
15047 .method(hyper::Method::GET)
15048 .uri(url.as_str())
15049 .header(USER_AGENT, self.hub._user_agent.clone());
15050
15051 if let Some(token) = token.as_ref() {
15052 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
15053 }
15054
15055 let request = req_builder
15056 .header(CONTENT_LENGTH, 0_u64)
15057 .body(common::to_body::<String>(None));
15058
15059 client.request(request.unwrap()).await
15060 };
15061
15062 match req_result {
15063 Err(err) => {
15064 if let common::Retry::After(d) = dlg.http_error(&err) {
15065 sleep(d).await;
15066 continue;
15067 }
15068 dlg.finished(false);
15069 return Err(common::Error::HttpError(err));
15070 }
15071 Ok(res) => {
15072 let (mut parts, body) = res.into_parts();
15073 let mut body = common::Body::new(body);
15074 if !parts.status.is_success() {
15075 let bytes = common::to_bytes(body).await.unwrap_or_default();
15076 let error = serde_json::from_str(&common::to_string(&bytes));
15077 let response = common::to_response(parts, bytes.into());
15078
15079 if let common::Retry::After(d) =
15080 dlg.http_failure(&response, error.as_ref().ok())
15081 {
15082 sleep(d).await;
15083 continue;
15084 }
15085
15086 dlg.finished(false);
15087
15088 return Err(match error {
15089 Ok(value) => common::Error::BadRequest(value),
15090 _ => common::Error::Failure(response),
15091 });
15092 }
15093 let response = {
15094 let bytes = common::to_bytes(body).await.unwrap_or_default();
15095 let encoded = common::to_string(&bytes);
15096 match serde_json::from_str(&encoded) {
15097 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
15098 Err(error) => {
15099 dlg.response_json_decode_error(&encoded, &error);
15100 return Err(common::Error::JsonDecodeError(
15101 encoded.to_string(),
15102 error,
15103 ));
15104 }
15105 }
15106 };
15107
15108 dlg.finished(true);
15109 return Ok(response);
15110 }
15111 }
15112 }
15113 }
15114
15115 /// The id of the user setting.
15116 ///
15117 /// Sets the *setting* path property to the given value.
15118 ///
15119 /// Even though the property as already been set when instantiating this call,
15120 /// we provide this method for API completeness.
15121 pub fn setting(mut self, new_value: &str) -> SettingGetCall<'a, C> {
15122 self._setting = new_value.to_string();
15123 self
15124 }
15125 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
15126 /// while executing the actual API request.
15127 ///
15128 /// ````text
15129 /// It should be used to handle progress information, and to implement a certain level of resilience.
15130 /// ````
15131 ///
15132 /// Sets the *delegate* property to the given value.
15133 pub fn delegate(mut self, new_value: &'a mut dyn common::Delegate) -> SettingGetCall<'a, C> {
15134 self._delegate = Some(new_value);
15135 self
15136 }
15137
15138 /// Set any additional parameter of the query string used in the request.
15139 /// It should be used to set parameters which are not yet available through their own
15140 /// setters.
15141 ///
15142 /// Please note that this method must not be used to set any of the known parameters
15143 /// which have their own setter method. If done anyway, the request will fail.
15144 ///
15145 /// # Additional Parameters
15146 ///
15147 /// * *alt* (query-string) - Data format for the response.
15148 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
15149 /// * *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.
15150 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
15151 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
15152 /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
15153 /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
15154 pub fn param<T>(mut self, name: T, value: T) -> SettingGetCall<'a, C>
15155 where
15156 T: AsRef<str>,
15157 {
15158 self._additional_params
15159 .insert(name.as_ref().to_string(), value.as_ref().to_string());
15160 self
15161 }
15162
15163 /// Identifies the authorization scope for the method you are building.
15164 ///
15165 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
15166 /// [`Scope::Readonly`].
15167 ///
15168 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
15169 /// tokens for more than one scope.
15170 ///
15171 /// Usually there is more than one suitable scope to authorize an operation, some of which may
15172 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
15173 /// sufficient, a read-write scope will do as well.
15174 pub fn add_scope<St>(mut self, scope: St) -> SettingGetCall<'a, C>
15175 where
15176 St: AsRef<str>,
15177 {
15178 self._scopes.insert(String::from(scope.as_ref()));
15179 self
15180 }
15181 /// Identifies the authorization scope(s) for the method you are building.
15182 ///
15183 /// See [`Self::add_scope()`] for details.
15184 pub fn add_scopes<I, St>(mut self, scopes: I) -> SettingGetCall<'a, C>
15185 where
15186 I: IntoIterator<Item = St>,
15187 St: AsRef<str>,
15188 {
15189 self._scopes
15190 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
15191 self
15192 }
15193
15194 /// Removes all scopes, and no default scope will be used either.
15195 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
15196 /// for details).
15197 pub fn clear_scopes(mut self) -> SettingGetCall<'a, C> {
15198 self._scopes.clear();
15199 self
15200 }
15201}
15202
15203/// Returns all user settings for the authenticated user.
15204///
15205/// A builder for the *list* method supported by a *setting* resource.
15206/// It is not used directly, but through a [`SettingMethods`] instance.
15207///
15208/// # Example
15209///
15210/// Instantiate a resource method builder
15211///
15212/// ```test_harness,no_run
15213/// # extern crate hyper;
15214/// # extern crate hyper_rustls;
15215/// # extern crate google_calendar3 as calendar3;
15216/// # async fn dox() {
15217/// # use calendar3::{CalendarHub, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
15218///
15219/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
15220/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
15221/// # .with_native_roots()
15222/// # .unwrap()
15223/// # .https_only()
15224/// # .enable_http2()
15225/// # .build();
15226///
15227/// # let executor = hyper_util::rt::TokioExecutor::new();
15228/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
15229/// # secret,
15230/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
15231/// # yup_oauth2::client::CustomHyperClientBuilder::from(
15232/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
15233/// # ),
15234/// # ).build().await.unwrap();
15235///
15236/// # let client = hyper_util::client::legacy::Client::builder(
15237/// # hyper_util::rt::TokioExecutor::new()
15238/// # )
15239/// # .build(
15240/// # hyper_rustls::HttpsConnectorBuilder::new()
15241/// # .with_native_roots()
15242/// # .unwrap()
15243/// # .https_or_http()
15244/// # .enable_http2()
15245/// # .build()
15246/// # );
15247/// # let mut hub = CalendarHub::new(client, auth);
15248/// // You can configure optional parameters by calling the respective setters at will, and
15249/// // execute the final call using `doit()`.
15250/// // Values shown here are possibly random and not representative !
15251/// let result = hub.settings().list()
15252/// .sync_token("amet")
15253/// .page_token("ut")
15254/// .max_results(-27)
15255/// .doit().await;
15256/// # }
15257/// ```
15258pub struct SettingListCall<'a, C>
15259where
15260 C: 'a,
15261{
15262 hub: &'a CalendarHub<C>,
15263 _sync_token: Option<String>,
15264 _page_token: Option<String>,
15265 _max_results: Option<i32>,
15266 _delegate: Option<&'a mut dyn common::Delegate>,
15267 _additional_params: HashMap<String, String>,
15268 _scopes: BTreeSet<String>,
15269}
15270
15271impl<'a, C> common::CallBuilder for SettingListCall<'a, C> {}
15272
15273impl<'a, C> SettingListCall<'a, C>
15274where
15275 C: common::Connector,
15276{
15277 /// Perform the operation you have build so far.
15278 pub async fn doit(mut self) -> common::Result<(common::Response, Settings)> {
15279 use std::borrow::Cow;
15280 use std::io::{Read, Seek};
15281
15282 use common::{url::Params, ToParts};
15283 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
15284
15285 let mut dd = common::DefaultDelegate;
15286 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
15287 dlg.begin(common::MethodInfo {
15288 id: "calendar.settings.list",
15289 http_method: hyper::Method::GET,
15290 });
15291
15292 for &field in ["alt", "syncToken", "pageToken", "maxResults"].iter() {
15293 if self._additional_params.contains_key(field) {
15294 dlg.finished(false);
15295 return Err(common::Error::FieldClash(field));
15296 }
15297 }
15298
15299 let mut params = Params::with_capacity(5 + self._additional_params.len());
15300 if let Some(value) = self._sync_token.as_ref() {
15301 params.push("syncToken", value);
15302 }
15303 if let Some(value) = self._page_token.as_ref() {
15304 params.push("pageToken", value);
15305 }
15306 if let Some(value) = self._max_results.as_ref() {
15307 params.push("maxResults", value.to_string());
15308 }
15309
15310 params.extend(self._additional_params.iter());
15311
15312 params.push("alt", "json");
15313 let mut url = self.hub._base_url.clone() + "users/me/settings";
15314 if self._scopes.is_empty() {
15315 self._scopes.insert(Scope::Readonly.as_ref().to_string());
15316 }
15317
15318 let url = params.parse_with_url(&url);
15319
15320 loop {
15321 let token = match self
15322 .hub
15323 .auth
15324 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
15325 .await
15326 {
15327 Ok(token) => token,
15328 Err(e) => match dlg.token(e) {
15329 Ok(token) => token,
15330 Err(e) => {
15331 dlg.finished(false);
15332 return Err(common::Error::MissingToken(e));
15333 }
15334 },
15335 };
15336 let mut req_result = {
15337 let client = &self.hub.client;
15338 dlg.pre_request();
15339 let mut req_builder = hyper::Request::builder()
15340 .method(hyper::Method::GET)
15341 .uri(url.as_str())
15342 .header(USER_AGENT, self.hub._user_agent.clone());
15343
15344 if let Some(token) = token.as_ref() {
15345 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
15346 }
15347
15348 let request = req_builder
15349 .header(CONTENT_LENGTH, 0_u64)
15350 .body(common::to_body::<String>(None));
15351
15352 client.request(request.unwrap()).await
15353 };
15354
15355 match req_result {
15356 Err(err) => {
15357 if let common::Retry::After(d) = dlg.http_error(&err) {
15358 sleep(d).await;
15359 continue;
15360 }
15361 dlg.finished(false);
15362 return Err(common::Error::HttpError(err));
15363 }
15364 Ok(res) => {
15365 let (mut parts, body) = res.into_parts();
15366 let mut body = common::Body::new(body);
15367 if !parts.status.is_success() {
15368 let bytes = common::to_bytes(body).await.unwrap_or_default();
15369 let error = serde_json::from_str(&common::to_string(&bytes));
15370 let response = common::to_response(parts, bytes.into());
15371
15372 if let common::Retry::After(d) =
15373 dlg.http_failure(&response, error.as_ref().ok())
15374 {
15375 sleep(d).await;
15376 continue;
15377 }
15378
15379 dlg.finished(false);
15380
15381 return Err(match error {
15382 Ok(value) => common::Error::BadRequest(value),
15383 _ => common::Error::Failure(response),
15384 });
15385 }
15386 let response = {
15387 let bytes = common::to_bytes(body).await.unwrap_or_default();
15388 let encoded = common::to_string(&bytes);
15389 match serde_json::from_str(&encoded) {
15390 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
15391 Err(error) => {
15392 dlg.response_json_decode_error(&encoded, &error);
15393 return Err(common::Error::JsonDecodeError(
15394 encoded.to_string(),
15395 error,
15396 ));
15397 }
15398 }
15399 };
15400
15401 dlg.finished(true);
15402 return Ok(response);
15403 }
15404 }
15405 }
15406 }
15407
15408 /// 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.
15409 /// 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.
15410 /// Learn more about incremental synchronization.
15411 /// Optional. The default is to return all entries.
15412 ///
15413 /// Sets the *sync token* query property to the given value.
15414 pub fn sync_token(mut self, new_value: &str) -> SettingListCall<'a, C> {
15415 self._sync_token = Some(new_value.to_string());
15416 self
15417 }
15418 /// Token specifying which result page to return. Optional.
15419 ///
15420 /// Sets the *page token* query property to the given value.
15421 pub fn page_token(mut self, new_value: &str) -> SettingListCall<'a, C> {
15422 self._page_token = Some(new_value.to_string());
15423 self
15424 }
15425 /// 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.
15426 ///
15427 /// Sets the *max results* query property to the given value.
15428 pub fn max_results(mut self, new_value: i32) -> SettingListCall<'a, C> {
15429 self._max_results = Some(new_value);
15430 self
15431 }
15432 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
15433 /// while executing the actual API request.
15434 ///
15435 /// ````text
15436 /// It should be used to handle progress information, and to implement a certain level of resilience.
15437 /// ````
15438 ///
15439 /// Sets the *delegate* property to the given value.
15440 pub fn delegate(mut self, new_value: &'a mut dyn common::Delegate) -> SettingListCall<'a, C> {
15441 self._delegate = Some(new_value);
15442 self
15443 }
15444
15445 /// Set any additional parameter of the query string used in the request.
15446 /// It should be used to set parameters which are not yet available through their own
15447 /// setters.
15448 ///
15449 /// Please note that this method must not be used to set any of the known parameters
15450 /// which have their own setter method. If done anyway, the request will fail.
15451 ///
15452 /// # Additional Parameters
15453 ///
15454 /// * *alt* (query-string) - Data format for the response.
15455 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
15456 /// * *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.
15457 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
15458 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
15459 /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
15460 /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
15461 pub fn param<T>(mut self, name: T, value: T) -> SettingListCall<'a, C>
15462 where
15463 T: AsRef<str>,
15464 {
15465 self._additional_params
15466 .insert(name.as_ref().to_string(), value.as_ref().to_string());
15467 self
15468 }
15469
15470 /// Identifies the authorization scope for the method you are building.
15471 ///
15472 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
15473 /// [`Scope::Readonly`].
15474 ///
15475 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
15476 /// tokens for more than one scope.
15477 ///
15478 /// Usually there is more than one suitable scope to authorize an operation, some of which may
15479 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
15480 /// sufficient, a read-write scope will do as well.
15481 pub fn add_scope<St>(mut self, scope: St) -> SettingListCall<'a, C>
15482 where
15483 St: AsRef<str>,
15484 {
15485 self._scopes.insert(String::from(scope.as_ref()));
15486 self
15487 }
15488 /// Identifies the authorization scope(s) for the method you are building.
15489 ///
15490 /// See [`Self::add_scope()`] for details.
15491 pub fn add_scopes<I, St>(mut self, scopes: I) -> SettingListCall<'a, C>
15492 where
15493 I: IntoIterator<Item = St>,
15494 St: AsRef<str>,
15495 {
15496 self._scopes
15497 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
15498 self
15499 }
15500
15501 /// Removes all scopes, and no default scope will be used either.
15502 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
15503 /// for details).
15504 pub fn clear_scopes(mut self) -> SettingListCall<'a, C> {
15505 self._scopes.clear();
15506 self
15507 }
15508}
15509
15510/// Watch for changes to Settings resources.
15511///
15512/// A builder for the *watch* method supported by a *setting* resource.
15513/// It is not used directly, but through a [`SettingMethods`] instance.
15514///
15515/// # Example
15516///
15517/// Instantiate a resource method builder
15518///
15519/// ```test_harness,no_run
15520/// # extern crate hyper;
15521/// # extern crate hyper_rustls;
15522/// # extern crate google_calendar3 as calendar3;
15523/// use calendar3::api::Channel;
15524/// # async fn dox() {
15525/// # use calendar3::{CalendarHub, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
15526///
15527/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
15528/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
15529/// # .with_native_roots()
15530/// # .unwrap()
15531/// # .https_only()
15532/// # .enable_http2()
15533/// # .build();
15534///
15535/// # let executor = hyper_util::rt::TokioExecutor::new();
15536/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
15537/// # secret,
15538/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
15539/// # yup_oauth2::client::CustomHyperClientBuilder::from(
15540/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
15541/// # ),
15542/// # ).build().await.unwrap();
15543///
15544/// # let client = hyper_util::client::legacy::Client::builder(
15545/// # hyper_util::rt::TokioExecutor::new()
15546/// # )
15547/// # .build(
15548/// # hyper_rustls::HttpsConnectorBuilder::new()
15549/// # .with_native_roots()
15550/// # .unwrap()
15551/// # .https_or_http()
15552/// # .enable_http2()
15553/// # .build()
15554/// # );
15555/// # let mut hub = CalendarHub::new(client, auth);
15556/// // As the method needs a request, you would usually fill it with the desired information
15557/// // into the respective structure. Some of the parts shown here might not be applicable !
15558/// // Values shown here are possibly random and not representative !
15559/// let mut req = Channel::default();
15560///
15561/// // You can configure optional parameters by calling the respective setters at will, and
15562/// // execute the final call using `doit()`.
15563/// // Values shown here are possibly random and not representative !
15564/// let result = hub.settings().watch(req)
15565/// .sync_token("sit")
15566/// .page_token("vero")
15567/// .max_results(-20)
15568/// .doit().await;
15569/// # }
15570/// ```
15571pub struct SettingWatchCall<'a, C>
15572where
15573 C: 'a,
15574{
15575 hub: &'a CalendarHub<C>,
15576 _request: Channel,
15577 _sync_token: Option<String>,
15578 _page_token: Option<String>,
15579 _max_results: Option<i32>,
15580 _delegate: Option<&'a mut dyn common::Delegate>,
15581 _additional_params: HashMap<String, String>,
15582 _scopes: BTreeSet<String>,
15583}
15584
15585impl<'a, C> common::CallBuilder for SettingWatchCall<'a, C> {}
15586
15587impl<'a, C> SettingWatchCall<'a, C>
15588where
15589 C: common::Connector,
15590{
15591 /// Perform the operation you have build so far.
15592 pub async fn doit(mut self) -> common::Result<(common::Response, Channel)> {
15593 use std::borrow::Cow;
15594 use std::io::{Read, Seek};
15595
15596 use common::{url::Params, ToParts};
15597 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
15598
15599 let mut dd = common::DefaultDelegate;
15600 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
15601 dlg.begin(common::MethodInfo {
15602 id: "calendar.settings.watch",
15603 http_method: hyper::Method::POST,
15604 });
15605
15606 for &field in ["alt", "syncToken", "pageToken", "maxResults"].iter() {
15607 if self._additional_params.contains_key(field) {
15608 dlg.finished(false);
15609 return Err(common::Error::FieldClash(field));
15610 }
15611 }
15612
15613 let mut params = Params::with_capacity(6 + self._additional_params.len());
15614 if let Some(value) = self._sync_token.as_ref() {
15615 params.push("syncToken", value);
15616 }
15617 if let Some(value) = self._page_token.as_ref() {
15618 params.push("pageToken", value);
15619 }
15620 if let Some(value) = self._max_results.as_ref() {
15621 params.push("maxResults", value.to_string());
15622 }
15623
15624 params.extend(self._additional_params.iter());
15625
15626 params.push("alt", "json");
15627 let mut url = self.hub._base_url.clone() + "users/me/settings/watch";
15628 if self._scopes.is_empty() {
15629 self._scopes.insert(Scope::Readonly.as_ref().to_string());
15630 }
15631
15632 let url = params.parse_with_url(&url);
15633
15634 let mut json_mime_type = mime::APPLICATION_JSON;
15635 let mut request_value_reader = {
15636 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
15637 common::remove_json_null_values(&mut value);
15638 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
15639 serde_json::to_writer(&mut dst, &value).unwrap();
15640 dst
15641 };
15642 let request_size = request_value_reader
15643 .seek(std::io::SeekFrom::End(0))
15644 .unwrap();
15645 request_value_reader
15646 .seek(std::io::SeekFrom::Start(0))
15647 .unwrap();
15648
15649 loop {
15650 let token = match self
15651 .hub
15652 .auth
15653 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
15654 .await
15655 {
15656 Ok(token) => token,
15657 Err(e) => match dlg.token(e) {
15658 Ok(token) => token,
15659 Err(e) => {
15660 dlg.finished(false);
15661 return Err(common::Error::MissingToken(e));
15662 }
15663 },
15664 };
15665 request_value_reader
15666 .seek(std::io::SeekFrom::Start(0))
15667 .unwrap();
15668 let mut req_result = {
15669 let client = &self.hub.client;
15670 dlg.pre_request();
15671 let mut req_builder = hyper::Request::builder()
15672 .method(hyper::Method::POST)
15673 .uri(url.as_str())
15674 .header(USER_AGENT, self.hub._user_agent.clone());
15675
15676 if let Some(token) = token.as_ref() {
15677 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
15678 }
15679
15680 let request = req_builder
15681 .header(CONTENT_TYPE, json_mime_type.to_string())
15682 .header(CONTENT_LENGTH, request_size as u64)
15683 .body(common::to_body(
15684 request_value_reader.get_ref().clone().into(),
15685 ));
15686
15687 client.request(request.unwrap()).await
15688 };
15689
15690 match req_result {
15691 Err(err) => {
15692 if let common::Retry::After(d) = dlg.http_error(&err) {
15693 sleep(d).await;
15694 continue;
15695 }
15696 dlg.finished(false);
15697 return Err(common::Error::HttpError(err));
15698 }
15699 Ok(res) => {
15700 let (mut parts, body) = res.into_parts();
15701 let mut body = common::Body::new(body);
15702 if !parts.status.is_success() {
15703 let bytes = common::to_bytes(body).await.unwrap_or_default();
15704 let error = serde_json::from_str(&common::to_string(&bytes));
15705 let response = common::to_response(parts, bytes.into());
15706
15707 if let common::Retry::After(d) =
15708 dlg.http_failure(&response, error.as_ref().ok())
15709 {
15710 sleep(d).await;
15711 continue;
15712 }
15713
15714 dlg.finished(false);
15715
15716 return Err(match error {
15717 Ok(value) => common::Error::BadRequest(value),
15718 _ => common::Error::Failure(response),
15719 });
15720 }
15721 let response = {
15722 let bytes = common::to_bytes(body).await.unwrap_or_default();
15723 let encoded = common::to_string(&bytes);
15724 match serde_json::from_str(&encoded) {
15725 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
15726 Err(error) => {
15727 dlg.response_json_decode_error(&encoded, &error);
15728 return Err(common::Error::JsonDecodeError(
15729 encoded.to_string(),
15730 error,
15731 ));
15732 }
15733 }
15734 };
15735
15736 dlg.finished(true);
15737 return Ok(response);
15738 }
15739 }
15740 }
15741 }
15742
15743 ///
15744 /// Sets the *request* property to the given value.
15745 ///
15746 /// Even though the property as already been set when instantiating this call,
15747 /// we provide this method for API completeness.
15748 pub fn request(mut self, new_value: Channel) -> SettingWatchCall<'a, C> {
15749 self._request = new_value;
15750 self
15751 }
15752 /// 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.
15753 /// 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.
15754 /// Learn more about incremental synchronization.
15755 /// Optional. The default is to return all entries.
15756 ///
15757 /// Sets the *sync token* query property to the given value.
15758 pub fn sync_token(mut self, new_value: &str) -> SettingWatchCall<'a, C> {
15759 self._sync_token = Some(new_value.to_string());
15760 self
15761 }
15762 /// Token specifying which result page to return. Optional.
15763 ///
15764 /// Sets the *page token* query property to the given value.
15765 pub fn page_token(mut self, new_value: &str) -> SettingWatchCall<'a, C> {
15766 self._page_token = Some(new_value.to_string());
15767 self
15768 }
15769 /// 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.
15770 ///
15771 /// Sets the *max results* query property to the given value.
15772 pub fn max_results(mut self, new_value: i32) -> SettingWatchCall<'a, C> {
15773 self._max_results = Some(new_value);
15774 self
15775 }
15776 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
15777 /// while executing the actual API request.
15778 ///
15779 /// ````text
15780 /// It should be used to handle progress information, and to implement a certain level of resilience.
15781 /// ````
15782 ///
15783 /// Sets the *delegate* property to the given value.
15784 pub fn delegate(mut self, new_value: &'a mut dyn common::Delegate) -> SettingWatchCall<'a, C> {
15785 self._delegate = Some(new_value);
15786 self
15787 }
15788
15789 /// Set any additional parameter of the query string used in the request.
15790 /// It should be used to set parameters which are not yet available through their own
15791 /// setters.
15792 ///
15793 /// Please note that this method must not be used to set any of the known parameters
15794 /// which have their own setter method. If done anyway, the request will fail.
15795 ///
15796 /// # Additional Parameters
15797 ///
15798 /// * *alt* (query-string) - Data format for the response.
15799 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
15800 /// * *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.
15801 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
15802 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
15803 /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
15804 /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
15805 pub fn param<T>(mut self, name: T, value: T) -> SettingWatchCall<'a, C>
15806 where
15807 T: AsRef<str>,
15808 {
15809 self._additional_params
15810 .insert(name.as_ref().to_string(), value.as_ref().to_string());
15811 self
15812 }
15813
15814 /// Identifies the authorization scope for the method you are building.
15815 ///
15816 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
15817 /// [`Scope::Readonly`].
15818 ///
15819 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
15820 /// tokens for more than one scope.
15821 ///
15822 /// Usually there is more than one suitable scope to authorize an operation, some of which may
15823 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
15824 /// sufficient, a read-write scope will do as well.
15825 pub fn add_scope<St>(mut self, scope: St) -> SettingWatchCall<'a, C>
15826 where
15827 St: AsRef<str>,
15828 {
15829 self._scopes.insert(String::from(scope.as_ref()));
15830 self
15831 }
15832 /// Identifies the authorization scope(s) for the method you are building.
15833 ///
15834 /// See [`Self::add_scope()`] for details.
15835 pub fn add_scopes<I, St>(mut self, scopes: I) -> SettingWatchCall<'a, C>
15836 where
15837 I: IntoIterator<Item = St>,
15838 St: AsRef<str>,
15839 {
15840 self._scopes
15841 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
15842 self
15843 }
15844
15845 /// Removes all scopes, and no default scope will be used either.
15846 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
15847 /// for details).
15848 pub fn clear_scopes(mut self) -> SettingWatchCall<'a, C> {
15849 self._scopes.clear();
15850 self
15851 }
15852}