google_appsactivity1/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 /// View the activity history of your Google apps
17 Activity,
18}
19
20impl AsRef<str> for Scope {
21 fn as_ref(&self) -> &str {
22 match *self {
23 Scope::Activity => "https://www.googleapis.com/auth/activity",
24 }
25 }
26}
27
28#[allow(clippy::derivable_impls)]
29impl Default for Scope {
30 fn default() -> Scope {
31 Scope::Activity
32 }
33}
34
35// ########
36// HUB ###
37// ######
38
39/// Central instance to access all Appsactivity related resource activities
40///
41/// # Examples
42///
43/// Instantiate a new hub
44///
45/// ```test_harness,no_run
46/// extern crate hyper;
47/// extern crate hyper_rustls;
48/// extern crate google_appsactivity1 as appsactivity1;
49/// use appsactivity1::{Result, Error};
50/// # async fn dox() {
51/// use appsactivity1::{Appsactivity, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
52///
53/// // Get an ApplicationSecret instance by some means. It contains the `client_id` and
54/// // `client_secret`, among other things.
55/// let secret: yup_oauth2::ApplicationSecret = Default::default();
56/// // Instantiate the authenticator. It will choose a suitable authentication flow for you,
57/// // unless you replace `None` with the desired Flow.
58/// // Provide your own `AuthenticatorDelegate` to adjust the way it operates and get feedback about
59/// // what's going on. You probably want to bring in your own `TokenStorage` to persist tokens and
60/// // retrieve them from storage.
61/// let connector = hyper_rustls::HttpsConnectorBuilder::new()
62/// .with_native_roots()
63/// .unwrap()
64/// .https_only()
65/// .enable_http2()
66/// .build();
67///
68/// let executor = hyper_util::rt::TokioExecutor::new();
69/// let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
70/// secret,
71/// yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
72/// yup_oauth2::client::CustomHyperClientBuilder::from(
73/// hyper_util::client::legacy::Client::builder(executor).build(connector),
74/// ),
75/// ).build().await.unwrap();
76///
77/// let client = hyper_util::client::legacy::Client::builder(
78/// hyper_util::rt::TokioExecutor::new()
79/// )
80/// .build(
81/// hyper_rustls::HttpsConnectorBuilder::new()
82/// .with_native_roots()
83/// .unwrap()
84/// .https_or_http()
85/// .enable_http2()
86/// .build()
87/// );
88/// let mut hub = Appsactivity::new(client, auth);
89/// // You can configure optional parameters by calling the respective setters at will, and
90/// // execute the final call using `doit()`.
91/// // Values shown here are possibly random and not representative !
92/// let result = hub.activities().list()
93/// .user_id("Lorem")
94/// .source("gubergren")
95/// .page_token("eos")
96/// .page_size(-4)
97/// .grouping_strategy("ea")
98/// .drive_file_id("ipsum")
99/// .drive_ancestor_id("invidunt")
100/// .doit().await;
101///
102/// match result {
103/// Err(e) => match e {
104/// // The Error enum provides details about what exactly happened.
105/// // You can also just use its `Debug`, `Display` or `Error` traits
106/// Error::HttpError(_)
107/// |Error::Io(_)
108/// |Error::MissingAPIKey
109/// |Error::MissingToken(_)
110/// |Error::Cancelled
111/// |Error::UploadSizeLimitExceeded(_, _)
112/// |Error::Failure(_)
113/// |Error::BadRequest(_)
114/// |Error::FieldClash(_)
115/// |Error::JsonDecodeError(_, _) => println!("{}", e),
116/// },
117/// Ok(res) => println!("Success: {:?}", res),
118/// }
119/// # }
120/// ```
121#[derive(Clone)]
122pub struct Appsactivity<C> {
123 pub client: common::Client<C>,
124 pub auth: Box<dyn common::GetToken>,
125 _user_agent: String,
126 _base_url: String,
127 _root_url: String,
128}
129
130impl<C> common::Hub for Appsactivity<C> {}
131
132impl<'a, C> Appsactivity<C> {
133 pub fn new<A: 'static + common::GetToken>(
134 client: common::Client<C>,
135 auth: A,
136 ) -> Appsactivity<C> {
137 Appsactivity {
138 client,
139 auth: Box::new(auth),
140 _user_agent: "google-api-rust-client/7.0.0".to_string(),
141 _base_url: "https://www.googleapis.com/appsactivity/v1/".to_string(),
142 _root_url: "https://www.googleapis.com/".to_string(),
143 }
144 }
145
146 pub fn activities(&'a self) -> ActivityMethods<'a, C> {
147 ActivityMethods { hub: self }
148 }
149
150 /// Set the user-agent header field to use in all requests to the server.
151 /// It defaults to `google-api-rust-client/7.0.0`.
152 ///
153 /// Returns the previously set user-agent.
154 pub fn user_agent(&mut self, agent_name: String) -> String {
155 std::mem::replace(&mut self._user_agent, agent_name)
156 }
157
158 /// Set the base url to use in all requests to the server.
159 /// It defaults to `https://www.googleapis.com/appsactivity/v1/`.
160 ///
161 /// Returns the previously set base url.
162 pub fn base_url(&mut self, new_base_url: String) -> String {
163 std::mem::replace(&mut self._base_url, new_base_url)
164 }
165
166 /// Set the root url to use in all requests to the server.
167 /// It defaults to `https://www.googleapis.com/`.
168 ///
169 /// Returns the previously set root url.
170 pub fn root_url(&mut self, new_root_url: String) -> String {
171 std::mem::replace(&mut self._root_url, new_root_url)
172 }
173}
174
175// ############
176// SCHEMAS ###
177// ##########
178/// An Activity resource is a combined view of multiple events. An activity has a list of individual events and a combined view of the common fields among all events.
179///
180/// This type is not used in any activity, and only used as *part* of another schema.
181///
182#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
183#[serde_with::serde_as]
184#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
185pub struct Activity {
186 /// The fields common to all of the singleEvents that make up the Activity.
187 #[serde(rename = "combinedEvent")]
188 pub combined_event: Option<Event>,
189 /// A list of all the Events that make up the Activity.
190 #[serde(rename = "singleEvents")]
191 pub single_events: Option<Vec<Event>>,
192}
193
194impl common::Part for Activity {}
195
196/// Represents the changes associated with an action taken by a user.
197///
198/// This type is not used in any activity, and only used as *part* of another schema.
199///
200#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
201#[serde_with::serde_as]
202#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
203pub struct Event {
204 /// Additional event types. Some events may have multiple types when multiple actions are part of a single event. For example, creating a document, renaming it, and sharing it may be part of a single file-creation event.
205 #[serde(rename = "additionalEventTypes")]
206 pub additional_event_types: Option<Vec<String>>,
207 /// The time at which the event occurred formatted as Unix time in milliseconds.
208 #[serde(rename = "eventTimeMillis")]
209 #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
210 pub event_time_millis: Option<u64>,
211 /// Whether this event is caused by a user being deleted.
212 #[serde(rename = "fromUserDeletion")]
213 pub from_user_deletion: Option<bool>,
214 /// Extra information for move type events, such as changes in an object's parents.
215 #[serde(rename = "move")]
216 pub move_: Option<Move>,
217 /// Extra information for permissionChange type events, such as the user or group the new permission applies to.
218 #[serde(rename = "permissionChanges")]
219 pub permission_changes: Option<Vec<PermissionChange>>,
220 /// The main type of event that occurred.
221 #[serde(rename = "primaryEventType")]
222 pub primary_event_type: Option<String>,
223 /// Extra information for rename type events, such as the old and new names.
224 pub rename: Option<Rename>,
225 /// Information specific to the Target object modified by the event.
226 pub target: Option<Target>,
227 /// Represents the user responsible for the event.
228 pub user: Option<User>,
229}
230
231impl common::Part for Event {}
232
233/// The response from the list request. Contains a list of activities and a token to retrieve the next page of results.
234///
235/// # Activities
236///
237/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
238/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
239///
240/// * [list activities](ActivityListCall) (response)
241#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
242#[serde_with::serde_as]
243#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
244pub struct ListActivitiesResponse {
245 /// List of activities.
246 pub activities: Option<Vec<Activity>>,
247 /// Token for the next page of results.
248 #[serde(rename = "nextPageToken")]
249 pub next_page_token: Option<String>,
250}
251
252impl common::ResponseResult for ListActivitiesResponse {}
253
254/// Contains information about changes in an object's parents as a result of a move type event.
255///
256/// This type is not used in any activity, and only used as *part* of another schema.
257///
258#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
259#[serde_with::serde_as]
260#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
261pub struct Move {
262 /// The added parent(s).
263 #[serde(rename = "addedParents")]
264 pub added_parents: Option<Vec<Parent>>,
265 /// The removed parent(s).
266 #[serde(rename = "removedParents")]
267 pub removed_parents: Option<Vec<Parent>>,
268}
269
270impl common::Part for Move {}
271
272/// Contains information about a parent object. For example, a folder in Drive is a parent for all files within it.
273///
274/// This type is not used in any activity, and only used as *part* of another schema.
275///
276#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
277#[serde_with::serde_as]
278#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
279pub struct Parent {
280 /// The parent's ID.
281 pub id: Option<String>,
282 /// Whether this is the root folder.
283 #[serde(rename = "isRoot")]
284 pub is_root: Option<bool>,
285 /// The parent's title.
286 pub title: Option<String>,
287}
288
289impl common::Part for Parent {}
290
291/// Contains information about the permissions and type of access allowed with regards to a Google Drive object. This is a subset of the fields contained in a corresponding Drive Permissions object.
292///
293/// This type is not used in any activity, and only used as *part* of another schema.
294///
295#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
296#[serde_with::serde_as]
297#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
298pub struct Permission {
299 /// The name of the user or group the permission applies to.
300 pub name: Option<String>,
301 /// The ID for this permission. Corresponds to the Drive API's permission ID returned as part of the Drive Permissions resource.
302 #[serde(rename = "permissionId")]
303 pub permission_id: Option<String>,
304 /// Indicates the Google Drive permissions role. The role determines a user's ability to read, write, or comment on the file.
305 pub role: Option<String>,
306 /// Indicates how widely permissions are granted.
307 #[serde(rename = "type")]
308 pub type_: Option<String>,
309 /// The user's information if the type is USER.
310 pub user: Option<User>,
311 /// Whether the permission requires a link to the file.
312 #[serde(rename = "withLink")]
313 pub with_link: Option<bool>,
314}
315
316impl common::Part for Permission {}
317
318/// Contains information about a Drive object's permissions that changed as a result of a permissionChange type event.
319///
320/// This type is not used in any activity, and only used as *part* of another schema.
321///
322#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
323#[serde_with::serde_as]
324#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
325pub struct PermissionChange {
326 /// Lists all Permission objects added.
327 #[serde(rename = "addedPermissions")]
328 pub added_permissions: Option<Vec<Permission>>,
329 /// Lists all Permission objects removed.
330 #[serde(rename = "removedPermissions")]
331 pub removed_permissions: Option<Vec<Permission>>,
332}
333
334impl common::Part for PermissionChange {}
335
336/// Photo information for a user.
337///
338/// This type is not used in any activity, and only used as *part* of another schema.
339///
340#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
341#[serde_with::serde_as]
342#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
343pub struct Photo {
344 /// The URL of the photo.
345 pub url: Option<String>,
346}
347
348impl common::Part for Photo {}
349
350/// Contains information about a renametype event.
351///
352/// This type is not used in any activity, and only used as *part* of another schema.
353///
354#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
355#[serde_with::serde_as]
356#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
357pub struct Rename {
358 /// The new title.
359 #[serde(rename = "newTitle")]
360 pub new_title: Option<String>,
361 /// The old title.
362 #[serde(rename = "oldTitle")]
363 pub old_title: Option<String>,
364}
365
366impl common::Part for Rename {}
367
368/// Information about the object modified by the event.
369///
370/// This type is not used in any activity, and only used as *part* of another schema.
371///
372#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
373#[serde_with::serde_as]
374#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
375pub struct Target {
376 /// The ID of the target. For example, in Google Drive, this is the file or folder ID.
377 pub id: Option<String>,
378 /// The MIME type of the target.
379 #[serde(rename = "mimeType")]
380 pub mime_type: Option<String>,
381 /// The name of the target. For example, in Google Drive, this is the title of the file.
382 pub name: Option<String>,
383}
384
385impl common::Part for Target {}
386
387/// A representation of a user.
388///
389/// This type is not used in any activity, and only used as *part* of another schema.
390///
391#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
392#[serde_with::serde_as]
393#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
394pub struct User {
395 /// A boolean which indicates whether the specified User was deleted. If true, name, photo and permission_id will be omitted.
396 #[serde(rename = "isDeleted")]
397 pub is_deleted: Option<bool>,
398 /// Whether the user is the authenticated user.
399 #[serde(rename = "isMe")]
400 pub is_me: Option<bool>,
401 /// The displayable name of the user.
402 pub name: Option<String>,
403 /// The permission ID associated with this user. Equivalent to the Drive API's permission ID for this user, returned as part of the Drive Permissions resource.
404 #[serde(rename = "permissionId")]
405 pub permission_id: Option<String>,
406 /// The profile photo of the user. Not present if the user has no profile photo.
407 pub photo: Option<Photo>,
408}
409
410impl common::Part for User {}
411
412// ###################
413// MethodBuilders ###
414// #################
415
416/// A builder providing access to all methods supported on *activity* resources.
417/// It is not used directly, but through the [`Appsactivity`] hub.
418///
419/// # Example
420///
421/// Instantiate a resource builder
422///
423/// ```test_harness,no_run
424/// extern crate hyper;
425/// extern crate hyper_rustls;
426/// extern crate google_appsactivity1 as appsactivity1;
427///
428/// # async fn dox() {
429/// use appsactivity1::{Appsactivity, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
430///
431/// let secret: yup_oauth2::ApplicationSecret = Default::default();
432/// let connector = hyper_rustls::HttpsConnectorBuilder::new()
433/// .with_native_roots()
434/// .unwrap()
435/// .https_only()
436/// .enable_http2()
437/// .build();
438///
439/// let executor = hyper_util::rt::TokioExecutor::new();
440/// let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
441/// secret,
442/// yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
443/// yup_oauth2::client::CustomHyperClientBuilder::from(
444/// hyper_util::client::legacy::Client::builder(executor).build(connector),
445/// ),
446/// ).build().await.unwrap();
447///
448/// let client = hyper_util::client::legacy::Client::builder(
449/// hyper_util::rt::TokioExecutor::new()
450/// )
451/// .build(
452/// hyper_rustls::HttpsConnectorBuilder::new()
453/// .with_native_roots()
454/// .unwrap()
455/// .https_or_http()
456/// .enable_http2()
457/// .build()
458/// );
459/// let mut hub = Appsactivity::new(client, auth);
460/// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders*
461/// // like `list(...)`
462/// // to build up your call.
463/// let rb = hub.activities();
464/// # }
465/// ```
466pub struct ActivityMethods<'a, C>
467where
468 C: 'a,
469{
470 hub: &'a Appsactivity<C>,
471}
472
473impl<'a, C> common::MethodsBuilder for ActivityMethods<'a, C> {}
474
475impl<'a, C> ActivityMethods<'a, C> {
476 /// Create a builder to help you perform the following task:
477 ///
478 /// Returns a list of activities visible to the current logged in user. Visible activities are determined by the visibility settings of the object that was acted on, e.g. Drive files a user can see. An activity is a record of past events. Multiple events may be merged if they are similar. A request is scoped to activities from a given Google service using the source parameter.
479 pub fn list(&self) -> ActivityListCall<'a, C> {
480 ActivityListCall {
481 hub: self.hub,
482 _user_id: Default::default(),
483 _source: Default::default(),
484 _page_token: Default::default(),
485 _page_size: Default::default(),
486 _grouping_strategy: Default::default(),
487 _drive_file_id: Default::default(),
488 _drive_ancestor_id: Default::default(),
489 _delegate: Default::default(),
490 _additional_params: Default::default(),
491 _scopes: Default::default(),
492 }
493 }
494}
495
496// ###################
497// CallBuilders ###
498// #################
499
500/// Returns a list of activities visible to the current logged in user. Visible activities are determined by the visibility settings of the object that was acted on, e.g. Drive files a user can see. An activity is a record of past events. Multiple events may be merged if they are similar. A request is scoped to activities from a given Google service using the source parameter.
501///
502/// A builder for the *list* method supported by a *activity* resource.
503/// It is not used directly, but through a [`ActivityMethods`] instance.
504///
505/// # Example
506///
507/// Instantiate a resource method builder
508///
509/// ```test_harness,no_run
510/// # extern crate hyper;
511/// # extern crate hyper_rustls;
512/// # extern crate google_appsactivity1 as appsactivity1;
513/// # async fn dox() {
514/// # use appsactivity1::{Appsactivity, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
515///
516/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
517/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
518/// # .with_native_roots()
519/// # .unwrap()
520/// # .https_only()
521/// # .enable_http2()
522/// # .build();
523///
524/// # let executor = hyper_util::rt::TokioExecutor::new();
525/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
526/// # secret,
527/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
528/// # yup_oauth2::client::CustomHyperClientBuilder::from(
529/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
530/// # ),
531/// # ).build().await.unwrap();
532///
533/// # let client = hyper_util::client::legacy::Client::builder(
534/// # hyper_util::rt::TokioExecutor::new()
535/// # )
536/// # .build(
537/// # hyper_rustls::HttpsConnectorBuilder::new()
538/// # .with_native_roots()
539/// # .unwrap()
540/// # .https_or_http()
541/// # .enable_http2()
542/// # .build()
543/// # );
544/// # let mut hub = Appsactivity::new(client, auth);
545/// // You can configure optional parameters by calling the respective setters at will, and
546/// // execute the final call using `doit()`.
547/// // Values shown here are possibly random and not representative !
548/// let result = hub.activities().list()
549/// .user_id("amet")
550/// .source("duo")
551/// .page_token("ipsum")
552/// .page_size(-93)
553/// .grouping_strategy("ut")
554/// .drive_file_id("gubergren")
555/// .drive_ancestor_id("rebum.")
556/// .doit().await;
557/// # }
558/// ```
559pub struct ActivityListCall<'a, C>
560where
561 C: 'a,
562{
563 hub: &'a Appsactivity<C>,
564 _user_id: Option<String>,
565 _source: Option<String>,
566 _page_token: Option<String>,
567 _page_size: Option<i32>,
568 _grouping_strategy: Option<String>,
569 _drive_file_id: Option<String>,
570 _drive_ancestor_id: Option<String>,
571 _delegate: Option<&'a mut dyn common::Delegate>,
572 _additional_params: HashMap<String, String>,
573 _scopes: BTreeSet<String>,
574}
575
576impl<'a, C> common::CallBuilder for ActivityListCall<'a, C> {}
577
578impl<'a, C> ActivityListCall<'a, C>
579where
580 C: common::Connector,
581{
582 /// Perform the operation you have build so far.
583 pub async fn doit(mut self) -> common::Result<(common::Response, ListActivitiesResponse)> {
584 use std::borrow::Cow;
585 use std::io::{Read, Seek};
586
587 use common::{url::Params, ToParts};
588 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
589
590 let mut dd = common::DefaultDelegate;
591 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
592 dlg.begin(common::MethodInfo {
593 id: "appsactivity.activities.list",
594 http_method: hyper::Method::GET,
595 });
596
597 for &field in [
598 "alt",
599 "userId",
600 "source",
601 "pageToken",
602 "pageSize",
603 "groupingStrategy",
604 "drive.fileId",
605 "drive.ancestorId",
606 ]
607 .iter()
608 {
609 if self._additional_params.contains_key(field) {
610 dlg.finished(false);
611 return Err(common::Error::FieldClash(field));
612 }
613 }
614
615 let mut params = Params::with_capacity(9 + self._additional_params.len());
616 if let Some(value) = self._user_id.as_ref() {
617 params.push("userId", value);
618 }
619 if let Some(value) = self._source.as_ref() {
620 params.push("source", value);
621 }
622 if let Some(value) = self._page_token.as_ref() {
623 params.push("pageToken", value);
624 }
625 if let Some(value) = self._page_size.as_ref() {
626 params.push("pageSize", value.to_string());
627 }
628 if let Some(value) = self._grouping_strategy.as_ref() {
629 params.push("groupingStrategy", value);
630 }
631 if let Some(value) = self._drive_file_id.as_ref() {
632 params.push("drive.fileId", value);
633 }
634 if let Some(value) = self._drive_ancestor_id.as_ref() {
635 params.push("drive.ancestorId", value);
636 }
637
638 params.extend(self._additional_params.iter());
639
640 params.push("alt", "json");
641 let mut url = self.hub._base_url.clone() + "activities";
642 if self._scopes.is_empty() {
643 self._scopes.insert(Scope::Activity.as_ref().to_string());
644 }
645
646 let url = params.parse_with_url(&url);
647
648 loop {
649 let token = match self
650 .hub
651 .auth
652 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
653 .await
654 {
655 Ok(token) => token,
656 Err(e) => match dlg.token(e) {
657 Ok(token) => token,
658 Err(e) => {
659 dlg.finished(false);
660 return Err(common::Error::MissingToken(e));
661 }
662 },
663 };
664 let mut req_result = {
665 let client = &self.hub.client;
666 dlg.pre_request();
667 let mut req_builder = hyper::Request::builder()
668 .method(hyper::Method::GET)
669 .uri(url.as_str())
670 .header(USER_AGENT, self.hub._user_agent.clone());
671
672 if let Some(token) = token.as_ref() {
673 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
674 }
675
676 let request = req_builder
677 .header(CONTENT_LENGTH, 0_u64)
678 .body(common::to_body::<String>(None));
679
680 client.request(request.unwrap()).await
681 };
682
683 match req_result {
684 Err(err) => {
685 if let common::Retry::After(d) = dlg.http_error(&err) {
686 sleep(d).await;
687 continue;
688 }
689 dlg.finished(false);
690 return Err(common::Error::HttpError(err));
691 }
692 Ok(res) => {
693 let (mut parts, body) = res.into_parts();
694 let mut body = common::Body::new(body);
695 if !parts.status.is_success() {
696 let bytes = common::to_bytes(body).await.unwrap_or_default();
697 let error = serde_json::from_str(&common::to_string(&bytes));
698 let response = common::to_response(parts, bytes.into());
699
700 if let common::Retry::After(d) =
701 dlg.http_failure(&response, error.as_ref().ok())
702 {
703 sleep(d).await;
704 continue;
705 }
706
707 dlg.finished(false);
708
709 return Err(match error {
710 Ok(value) => common::Error::BadRequest(value),
711 _ => common::Error::Failure(response),
712 });
713 }
714 let response = {
715 let bytes = common::to_bytes(body).await.unwrap_or_default();
716 let encoded = common::to_string(&bytes);
717 match serde_json::from_str(&encoded) {
718 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
719 Err(error) => {
720 dlg.response_json_decode_error(&encoded, &error);
721 return Err(common::Error::JsonDecodeError(
722 encoded.to_string(),
723 error,
724 ));
725 }
726 }
727 };
728
729 dlg.finished(true);
730 return Ok(response);
731 }
732 }
733 }
734 }
735
736 /// The ID used for ACL checks (does not filter the resulting event list by the assigned value). Use the special value me to indicate the currently authenticated user.
737 ///
738 /// Sets the *user id* query property to the given value.
739 pub fn user_id(mut self, new_value: &str) -> ActivityListCall<'a, C> {
740 self._user_id = Some(new_value.to_string());
741 self
742 }
743 /// The Google service from which to return activities. Possible values of source are:
744 /// - drive.google.com
745 ///
746 /// Sets the *source* query property to the given value.
747 pub fn source(mut self, new_value: &str) -> ActivityListCall<'a, C> {
748 self._source = Some(new_value.to_string());
749 self
750 }
751 /// A token to retrieve a specific page of results.
752 ///
753 /// Sets the *page token* query property to the given value.
754 pub fn page_token(mut self, new_value: &str) -> ActivityListCall<'a, C> {
755 self._page_token = Some(new_value.to_string());
756 self
757 }
758 /// The maximum number of events to return on a page. The response includes a continuation token if there are more events.
759 ///
760 /// Sets the *page size* query property to the given value.
761 pub fn page_size(mut self, new_value: i32) -> ActivityListCall<'a, C> {
762 self._page_size = Some(new_value);
763 self
764 }
765 /// Indicates the strategy to use when grouping singleEvents items in the associated combinedEvent object.
766 ///
767 /// Sets the *grouping strategy* query property to the given value.
768 pub fn grouping_strategy(mut self, new_value: &str) -> ActivityListCall<'a, C> {
769 self._grouping_strategy = Some(new_value.to_string());
770 self
771 }
772 /// Identifies the Drive item to return activities for.
773 ///
774 /// Sets the *drive.file id* query property to the given value.
775 pub fn drive_file_id(mut self, new_value: &str) -> ActivityListCall<'a, C> {
776 self._drive_file_id = Some(new_value.to_string());
777 self
778 }
779 /// Identifies the Drive folder containing the items for which to return activities.
780 ///
781 /// Sets the *drive.ancestor id* query property to the given value.
782 pub fn drive_ancestor_id(mut self, new_value: &str) -> ActivityListCall<'a, C> {
783 self._drive_ancestor_id = Some(new_value.to_string());
784 self
785 }
786 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
787 /// while executing the actual API request.
788 ///
789 /// ````text
790 /// It should be used to handle progress information, and to implement a certain level of resilience.
791 /// ````
792 ///
793 /// Sets the *delegate* property to the given value.
794 pub fn delegate(mut self, new_value: &'a mut dyn common::Delegate) -> ActivityListCall<'a, C> {
795 self._delegate = Some(new_value);
796 self
797 }
798
799 /// Set any additional parameter of the query string used in the request.
800 /// It should be used to set parameters which are not yet available through their own
801 /// setters.
802 ///
803 /// Please note that this method must not be used to set any of the known parameters
804 /// which have their own setter method. If done anyway, the request will fail.
805 ///
806 /// # Additional Parameters
807 ///
808 /// * *alt* (query-string) - Data format for the response.
809 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
810 /// * *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.
811 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
812 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
813 /// * *quotaUser* (query-string) - An opaque string that represents a user for quota purposes. Must not exceed 40 characters.
814 /// * *userIp* (query-string) - Deprecated. Please use quotaUser instead.
815 pub fn param<T>(mut self, name: T, value: T) -> ActivityListCall<'a, C>
816 where
817 T: AsRef<str>,
818 {
819 self._additional_params
820 .insert(name.as_ref().to_string(), value.as_ref().to_string());
821 self
822 }
823
824 /// Identifies the authorization scope for the method you are building.
825 ///
826 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
827 /// [`Scope::Activity`].
828 ///
829 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
830 /// tokens for more than one scope.
831 ///
832 /// Usually there is more than one suitable scope to authorize an operation, some of which may
833 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
834 /// sufficient, a read-write scope will do as well.
835 pub fn add_scope<St>(mut self, scope: St) -> ActivityListCall<'a, C>
836 where
837 St: AsRef<str>,
838 {
839 self._scopes.insert(String::from(scope.as_ref()));
840 self
841 }
842 /// Identifies the authorization scope(s) for the method you are building.
843 ///
844 /// See [`Self::add_scope()`] for details.
845 pub fn add_scopes<I, St>(mut self, scopes: I) -> ActivityListCall<'a, C>
846 where
847 I: IntoIterator<Item = St>,
848 St: AsRef<str>,
849 {
850 self._scopes
851 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
852 self
853 }
854
855 /// Removes all scopes, and no default scope will be used either.
856 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
857 /// for details).
858 pub fn clear_scopes(mut self) -> ActivityListCall<'a, C> {
859 self._scopes.clear();
860 self
861 }
862}