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