google_fcmdata1_beta1/
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, configure, and delete your Google Cloud data and see the email address for your Google Account.
17    CloudPlatform,
18}
19
20impl AsRef<str> for Scope {
21    fn as_ref(&self) -> &str {
22        match *self {
23            Scope::CloudPlatform => "https://www.googleapis.com/auth/cloud-platform",
24        }
25    }
26}
27
28#[allow(clippy::derivable_impls)]
29impl Default for Scope {
30    fn default() -> Scope {
31        Scope::CloudPlatform
32    }
33}
34
35// ########
36// HUB ###
37// ######
38
39/// Central instance to access all Fcmdata 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_fcmdata1_beta1 as fcmdata1_beta1;
49/// use fcmdata1_beta1::{Result, Error};
50/// # async fn dox() {
51/// use fcmdata1_beta1::{Fcmdata, 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 = Fcmdata::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.projects().android_apps_delivery_data_list("parent")
93///              .page_token("sed")
94///              .page_size(-2)
95///              .doit().await;
96///
97/// match result {
98///     Err(e) => match e {
99///         // The Error enum provides details about what exactly happened.
100///         // You can also just use its `Debug`, `Display` or `Error` traits
101///          Error::HttpError(_)
102///         |Error::Io(_)
103///         |Error::MissingAPIKey
104///         |Error::MissingToken(_)
105///         |Error::Cancelled
106///         |Error::UploadSizeLimitExceeded(_, _)
107///         |Error::Failure(_)
108///         |Error::BadRequest(_)
109///         |Error::FieldClash(_)
110///         |Error::JsonDecodeError(_, _) => println!("{}", e),
111///     },
112///     Ok(res) => println!("Success: {:?}", res),
113/// }
114/// # }
115/// ```
116#[derive(Clone)]
117pub struct Fcmdata<C> {
118    pub client: common::Client<C>,
119    pub auth: Box<dyn common::GetToken>,
120    _user_agent: String,
121    _base_url: String,
122    _root_url: String,
123}
124
125impl<C> common::Hub for Fcmdata<C> {}
126
127impl<'a, C> Fcmdata<C> {
128    pub fn new<A: 'static + common::GetToken>(client: common::Client<C>, auth: A) -> Fcmdata<C> {
129        Fcmdata {
130            client,
131            auth: Box::new(auth),
132            _user_agent: "google-api-rust-client/7.0.0".to_string(),
133            _base_url: "https://fcmdata.googleapis.com/".to_string(),
134            _root_url: "https://fcmdata.googleapis.com/".to_string(),
135        }
136    }
137
138    pub fn projects(&'a self) -> ProjectMethods<'a, C> {
139        ProjectMethods { hub: self }
140    }
141
142    /// Set the user-agent header field to use in all requests to the server.
143    /// It defaults to `google-api-rust-client/7.0.0`.
144    ///
145    /// Returns the previously set user-agent.
146    pub fn user_agent(&mut self, agent_name: String) -> String {
147        std::mem::replace(&mut self._user_agent, agent_name)
148    }
149
150    /// Set the base url to use in all requests to the server.
151    /// It defaults to `https://fcmdata.googleapis.com/`.
152    ///
153    /// Returns the previously set base url.
154    pub fn base_url(&mut self, new_base_url: String) -> String {
155        std::mem::replace(&mut self._base_url, new_base_url)
156    }
157
158    /// Set the root url to use in all requests to the server.
159    /// It defaults to `https://fcmdata.googleapis.com/`.
160    ///
161    /// Returns the previously set root url.
162    pub fn root_url(&mut self, new_root_url: String) -> String {
163        std::mem::replace(&mut self._root_url, new_root_url)
164    }
165}
166
167// ############
168// SCHEMAS ###
169// ##########
170/// Message delivery data for a given date, app, and analytics label combination.
171///
172/// This type is not used in any activity, and only used as *part* of another schema.
173///
174#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
175#[serde_with::serde_as]
176#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
177pub struct GoogleFirebaseFcmDataV1beta1AndroidDeliveryData {
178    /// The analytics label associated with the messages sent. All messages sent without an analytics label will be grouped together in a single entry.
179    #[serde(rename = "analyticsLabel")]
180    pub analytics_label: Option<String>,
181    /// The app ID to which the messages were sent.
182    #[serde(rename = "appId")]
183    pub app_id: Option<String>,
184    /// The data for the specified appId, date, and analyticsLabel.
185    pub data: Option<GoogleFirebaseFcmDataV1beta1Data>,
186    /// The date represented by this entry.
187    pub date: Option<GoogleTypeDate>,
188}
189
190impl common::Part for GoogleFirebaseFcmDataV1beta1AndroidDeliveryData {}
191
192/// Data detailing messaging delivery
193///
194/// This type is not used in any activity, and only used as *part* of another schema.
195///
196#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
197#[serde_with::serde_as]
198#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
199pub struct GoogleFirebaseFcmDataV1beta1Data {
200    /// Count of messages accepted by FCM intended for Android devices. The targeted device must have opted in to the collection of usage and diagnostic information.
201    #[serde(rename = "countMessagesAccepted")]
202    #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
203    pub count_messages_accepted: Option<i64>,
204    /// Count of notifications accepted by FCM intended for Android devices. The targeted device must have opted in to the collection of usage and diagnostic information.
205    #[serde(rename = "countNotificationsAccepted")]
206    #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
207    pub count_notifications_accepted: Option<i64>,
208    /// Additional information about delivery performance for messages that were successfully delivered.
209    #[serde(rename = "deliveryPerformancePercents")]
210    pub delivery_performance_percents:
211        Option<GoogleFirebaseFcmDataV1beta1DeliveryPerformancePercents>,
212    /// Additional general insights about message delivery.
213    #[serde(rename = "messageInsightPercents")]
214    pub message_insight_percents: Option<GoogleFirebaseFcmDataV1beta1MessageInsightPercents>,
215    /// Mutually exclusive breakdown of message delivery outcomes.
216    #[serde(rename = "messageOutcomePercents")]
217    pub message_outcome_percents: Option<GoogleFirebaseFcmDataV1beta1MessageOutcomePercents>,
218    /// Additional insights about proxy notification delivery.
219    #[serde(rename = "proxyNotificationInsightPercents")]
220    pub proxy_notification_insight_percents:
221        Option<GoogleFirebaseFcmDataV1beta1ProxyNotificationInsightPercents>,
222}
223
224impl common::Part for GoogleFirebaseFcmDataV1beta1Data {}
225
226/// Overview of delivery performance for messages that were successfully delivered. All percentages are calculated with countMessagesAccepted as the denominator. These categories are not mutually exclusive; a message can be delayed for multiple reasons.
227///
228/// This type is not used in any activity, and only used as *part* of another schema.
229///
230#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
231#[serde_with::serde_as]
232#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
233pub struct GoogleFirebaseFcmDataV1beta1DeliveryPerformancePercents {
234    /// The percentage of accepted messages that were delayed because the device was in doze mode. Only [normal priority messages](https://firebase.google.com/docs/cloud-messaging/concept-options#setting-the-priority-of-a-message) should be delayed due to doze mode.
235    #[serde(rename = "delayedDeviceDoze")]
236    pub delayed_device_doze: Option<f32>,
237    /// The percentage of accepted messages that were delayed because the target device was not connected at the time of sending. These messages were eventually delivered when the device reconnected.
238    #[serde(rename = "delayedDeviceOffline")]
239    pub delayed_device_offline: Option<f32>,
240    /// The percentage of accepted messages that were delayed due to message throttling, such as [collapsible message throttling](https://firebase.google.com/docs/cloud-messaging/concept-options#collapsible_throttling) or [maximum message rate throttling](https://firebase.google.com/docs/cloud-messaging/concept-options#device_throttling).
241    #[serde(rename = "delayedMessageThrottled")]
242    pub delayed_message_throttled: Option<f32>,
243    /// The percentage of accepted messages that were delayed because the intended device user-profile was [stopped](https://firebase.google.com/docs/cloud-messaging/android/receive#handling_messages) on the target device at the time of the send. The messages were eventually delivered when the user-profile was started again.
244    #[serde(rename = "delayedUserStopped")]
245    pub delayed_user_stopped: Option<f32>,
246    /// The percentage of accepted messages that were delivered to the device without delay from the FCM system.
247    #[serde(rename = "deliveredNoDelay")]
248    pub delivered_no_delay: Option<f32>,
249}
250
251impl common::Part for GoogleFirebaseFcmDataV1beta1DeliveryPerformancePercents {}
252
253/// Response message for ListAndroidDeliveryData.
254///
255/// # Activities
256///
257/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
258/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
259///
260/// * [android apps delivery data list projects](ProjectAndroidAppDeliveryDataListCall) (response)
261#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
262#[serde_with::serde_as]
263#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
264pub struct GoogleFirebaseFcmDataV1beta1ListAndroidDeliveryDataResponse {
265    /// The delivery data for the provided app. There will be one entry per combination of app, date, and analytics label.
266    #[serde(rename = "androidDeliveryData")]
267    pub android_delivery_data: Option<Vec<GoogleFirebaseFcmDataV1beta1AndroidDeliveryData>>,
268    /// A token, which can be sent as `page_token` to retrieve the next page. If this field is omitted, there are no subsequent pages.
269    #[serde(rename = "nextPageToken")]
270    pub next_page_token: Option<String>,
271}
272
273impl common::ResponseResult for GoogleFirebaseFcmDataV1beta1ListAndroidDeliveryDataResponse {}
274
275/// Additional information about message delivery. All percentages are calculated with countMessagesAccepted as the denominator.
276///
277/// This type is not used in any activity, and only used as *part* of another schema.
278///
279#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
280#[serde_with::serde_as]
281#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
282pub struct GoogleFirebaseFcmDataV1beta1MessageInsightPercents {
283    /// The percentage of accepted messages that had their priority lowered from high to normal. See [documentation for setting message priority](https://firebase.google.com/docs/cloud-messaging/android/message-priority).
284    #[serde(rename = "priorityLowered")]
285    pub priority_lowered: Option<f32>,
286}
287
288impl common::Part for GoogleFirebaseFcmDataV1beta1MessageInsightPercents {}
289
290/// Percentage breakdown of message delivery outcomes. These categories are mutually exclusive. All percentages are calculated with countMessagesAccepted as the denominator. These categories may not account for all message outcomes.
291///
292/// This type is not used in any activity, and only used as *part* of another schema.
293///
294#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
295#[serde_with::serde_as]
296#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
297pub struct GoogleFirebaseFcmDataV1beta1MessageOutcomePercents {
298    /// The percentage of accepted messages that were [collapsed](https://firebase.google.com/docs/cloud-messaging/concept-options#collapsible_and_non-collapsible_messages) by another message.
299    pub collapsed: Option<f32>,
300    /// The percentage of all accepted messages that were successfully delivered to the device.
301    pub delivered: Option<f32>,
302    /// The percentage of accepted messages that were dropped because the application was force stopped on the device at the time of delivery and retries were unsuccessful.
303    #[serde(rename = "droppedAppForceStopped")]
304    pub dropped_app_force_stopped: Option<f32>,
305    /// The percentage of accepted messages that were dropped because the target device is inactive. FCM will drop messages if the target device is deemed inactive by our servers. If a device does reconnect, we call [OnDeletedMessages()](https://firebase.google.com/docs/cloud-messaging/android/receive#override-ondeletedmessages) in our SDK instead of delivering the messages.
306    #[serde(rename = "droppedDeviceInactive")]
307    pub dropped_device_inactive: Option<f32>,
308    /// The percentage of accepted messages that were dropped due to [too many undelivered non-collapsible messages](https://firebase.google.com/docs/cloud-messaging/concept-options#collapsible_and_non-collapsible_messages). Specifically, each app instance can only have 100 pending messages stored on our servers for a device which is disconnected. When that device reconnects, those messages are delivered. When there are more than the maximum pending messages, we call [OnDeletedMessages()](https://firebase.google.com/docs/cloud-messaging/android/receive#override-ondeletedmessages) in our SDK instead of delivering the messages.
309    #[serde(rename = "droppedTooManyPendingMessages")]
310    pub dropped_too_many_pending_messages: Option<f32>,
311    /// The percentage of accepted messages that expired because [Time To Live (TTL)](https://firebase.google.com/docs/cloud-messaging/concept-options#ttl) elapsed before the target device reconnected.
312    #[serde(rename = "droppedTtlExpired")]
313    pub dropped_ttl_expired: Option<f32>,
314    /// The percentage of messages accepted on this day that were not dropped and not delivered, due to the device being disconnected (as of the end of the America/Los_Angeles day when the message was sent to FCM). A portion of these messages will be delivered the next day when the device connects but others may be destined to devices that ultimately never reconnect.
315    pub pending: Option<f32>,
316}
317
318impl common::Part for GoogleFirebaseFcmDataV1beta1MessageOutcomePercents {}
319
320/// Additional information about [proxy notification](https://firebase.google.com/docs/cloud-messaging/android/message-priority#proxy) delivery. All percentages are calculated with countNotificationsAccepted as the denominator.
321///
322/// This type is not used in any activity, and only used as *part* of another schema.
323///
324#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
325#[serde_with::serde_as]
326#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
327pub struct GoogleFirebaseFcmDataV1beta1ProxyNotificationInsightPercents {
328    /// The percentage of accepted notifications that failed to be proxied. This is usually caused by exceptions that occurred while calling [notifyAsPackage](https://developer.android.com/reference/android/app/NotificationManager#notifyAsPackage%28java.lang.String,%20java.lang.String,%20int,%20android.app.Notification%29).
329    pub failed: Option<f32>,
330    /// The percentage of accepted notifications that were successfully proxied by [Google Play services](https://developers.google.com/android/guides/overview).
331    pub proxied: Option<f32>,
332    /// The percentage of accepted notifications that were skipped because the messages were not throttled.
333    #[serde(rename = "skippedNotThrottled")]
334    pub skipped_not_throttled: Option<f32>,
335    /// The percentage of accepted notifications that were skipped because the app disallowed these messages to be proxied.
336    #[serde(rename = "skippedOptedOut")]
337    pub skipped_opted_out: Option<f32>,
338    /// The percentage of accepted notifications that were skipped because configurations required for notifications to be proxied were missing.
339    #[serde(rename = "skippedUnconfigured")]
340    pub skipped_unconfigured: Option<f32>,
341    /// The percentage of accepted notifications that were skipped because proxy notification is unsupported for the recipient.
342    #[serde(rename = "skippedUnsupported")]
343    pub skipped_unsupported: Option<f32>,
344}
345
346impl common::Part for GoogleFirebaseFcmDataV1beta1ProxyNotificationInsightPercents {}
347
348/// Represents a whole or partial calendar date, such as a birthday. The time of day and time zone are either specified elsewhere or are insignificant. The date is relative to the Gregorian Calendar. This can represent one of the following: * A full date, with non-zero year, month, and day values. * A month and day, with a zero year (for example, an anniversary). * A year on its own, with a zero month and a zero day. * A year and month, with a zero day (for example, a credit card expiration date). Related types: * google.type.TimeOfDay * google.type.DateTime * google.protobuf.Timestamp
349///
350/// This type is not used in any activity, and only used as *part* of another schema.
351///
352#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
353#[serde_with::serde_as]
354#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
355pub struct GoogleTypeDate {
356    /// Day of a month. Must be from 1 to 31 and valid for the year and month, or 0 to specify a year by itself or a year and month where the day isn't significant.
357    pub day: Option<i32>,
358    /// Month of a year. Must be from 1 to 12, or 0 to specify a year without a month and day.
359    pub month: Option<i32>,
360    /// Year of the date. Must be from 1 to 9999, or 0 to specify a date without a year.
361    pub year: Option<i32>,
362}
363
364impl common::Part for GoogleTypeDate {}
365
366// ###################
367// MethodBuilders ###
368// #################
369
370/// A builder providing access to all methods supported on *project* resources.
371/// It is not used directly, but through the [`Fcmdata`] hub.
372///
373/// # Example
374///
375/// Instantiate a resource builder
376///
377/// ```test_harness,no_run
378/// extern crate hyper;
379/// extern crate hyper_rustls;
380/// extern crate google_fcmdata1_beta1 as fcmdata1_beta1;
381///
382/// # async fn dox() {
383/// use fcmdata1_beta1::{Fcmdata, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
384///
385/// let secret: yup_oauth2::ApplicationSecret = Default::default();
386/// let connector = hyper_rustls::HttpsConnectorBuilder::new()
387///     .with_native_roots()
388///     .unwrap()
389///     .https_only()
390///     .enable_http2()
391///     .build();
392///
393/// let executor = hyper_util::rt::TokioExecutor::new();
394/// let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
395///     secret,
396///     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
397///     yup_oauth2::client::CustomHyperClientBuilder::from(
398///         hyper_util::client::legacy::Client::builder(executor).build(connector),
399///     ),
400/// ).build().await.unwrap();
401///
402/// let client = hyper_util::client::legacy::Client::builder(
403///     hyper_util::rt::TokioExecutor::new()
404/// )
405/// .build(
406///     hyper_rustls::HttpsConnectorBuilder::new()
407///         .with_native_roots()
408///         .unwrap()
409///         .https_or_http()
410///         .enable_http2()
411///         .build()
412/// );
413/// let mut hub = Fcmdata::new(client, auth);
414/// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders*
415/// // like `android_apps_delivery_data_list(...)`
416/// // to build up your call.
417/// let rb = hub.projects();
418/// # }
419/// ```
420pub struct ProjectMethods<'a, C>
421where
422    C: 'a,
423{
424    hub: &'a Fcmdata<C>,
425}
426
427impl<'a, C> common::MethodsBuilder for ProjectMethods<'a, C> {}
428
429impl<'a, C> ProjectMethods<'a, C> {
430    /// Create a builder to help you perform the following task:
431    ///
432    /// List aggregate delivery data for the given Android application.
433    ///
434    /// # Arguments
435    ///
436    /// * `parent` - Required. The application for which to list delivery data. Format: `projects/{project_id}/androidApps/{app_id}`
437    pub fn android_apps_delivery_data_list(
438        &self,
439        parent: &str,
440    ) -> ProjectAndroidAppDeliveryDataListCall<'a, C> {
441        ProjectAndroidAppDeliveryDataListCall {
442            hub: self.hub,
443            _parent: parent.to_string(),
444            _page_token: Default::default(),
445            _page_size: Default::default(),
446            _delegate: Default::default(),
447            _additional_params: Default::default(),
448            _scopes: Default::default(),
449        }
450    }
451}
452
453// ###################
454// CallBuilders   ###
455// #################
456
457/// List aggregate delivery data for the given Android application.
458///
459/// A builder for the *androidApps.deliveryData.list* method supported by a *project* resource.
460/// It is not used directly, but through a [`ProjectMethods`] instance.
461///
462/// # Example
463///
464/// Instantiate a resource method builder
465///
466/// ```test_harness,no_run
467/// # extern crate hyper;
468/// # extern crate hyper_rustls;
469/// # extern crate google_fcmdata1_beta1 as fcmdata1_beta1;
470/// # async fn dox() {
471/// # use fcmdata1_beta1::{Fcmdata, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
472///
473/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
474/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
475/// #     .with_native_roots()
476/// #     .unwrap()
477/// #     .https_only()
478/// #     .enable_http2()
479/// #     .build();
480///
481/// # let executor = hyper_util::rt::TokioExecutor::new();
482/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
483/// #     secret,
484/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
485/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
486/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
487/// #     ),
488/// # ).build().await.unwrap();
489///
490/// # let client = hyper_util::client::legacy::Client::builder(
491/// #     hyper_util::rt::TokioExecutor::new()
492/// # )
493/// # .build(
494/// #     hyper_rustls::HttpsConnectorBuilder::new()
495/// #         .with_native_roots()
496/// #         .unwrap()
497/// #         .https_or_http()
498/// #         .enable_http2()
499/// #         .build()
500/// # );
501/// # let mut hub = Fcmdata::new(client, auth);
502/// // You can configure optional parameters by calling the respective setters at will, and
503/// // execute the final call using `doit()`.
504/// // Values shown here are possibly random and not representative !
505/// let result = hub.projects().android_apps_delivery_data_list("parent")
506///              .page_token("amet.")
507///              .page_size(-20)
508///              .doit().await;
509/// # }
510/// ```
511pub struct ProjectAndroidAppDeliveryDataListCall<'a, C>
512where
513    C: 'a,
514{
515    hub: &'a Fcmdata<C>,
516    _parent: String,
517    _page_token: Option<String>,
518    _page_size: Option<i32>,
519    _delegate: Option<&'a mut dyn common::Delegate>,
520    _additional_params: HashMap<String, String>,
521    _scopes: BTreeSet<String>,
522}
523
524impl<'a, C> common::CallBuilder for ProjectAndroidAppDeliveryDataListCall<'a, C> {}
525
526impl<'a, C> ProjectAndroidAppDeliveryDataListCall<'a, C>
527where
528    C: common::Connector,
529{
530    /// Perform the operation you have build so far.
531    pub async fn doit(
532        mut self,
533    ) -> common::Result<(
534        common::Response,
535        GoogleFirebaseFcmDataV1beta1ListAndroidDeliveryDataResponse,
536    )> {
537        use std::borrow::Cow;
538        use std::io::{Read, Seek};
539
540        use common::{url::Params, ToParts};
541        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
542
543        let mut dd = common::DefaultDelegate;
544        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
545        dlg.begin(common::MethodInfo {
546            id: "fcmdata.projects.androidApps.deliveryData.list",
547            http_method: hyper::Method::GET,
548        });
549
550        for &field in ["alt", "parent", "pageToken", "pageSize"].iter() {
551            if self._additional_params.contains_key(field) {
552                dlg.finished(false);
553                return Err(common::Error::FieldClash(field));
554            }
555        }
556
557        let mut params = Params::with_capacity(5 + self._additional_params.len());
558        params.push("parent", self._parent);
559        if let Some(value) = self._page_token.as_ref() {
560            params.push("pageToken", value);
561        }
562        if let Some(value) = self._page_size.as_ref() {
563            params.push("pageSize", value.to_string());
564        }
565
566        params.extend(self._additional_params.iter());
567
568        params.push("alt", "json");
569        let mut url = self.hub._base_url.clone() + "v1beta1/{+parent}/deliveryData";
570        if self._scopes.is_empty() {
571            self._scopes
572                .insert(Scope::CloudPlatform.as_ref().to_string());
573        }
574
575        #[allow(clippy::single_element_loop)]
576        for &(find_this, param_name) in [("{+parent}", "parent")].iter() {
577            url = params.uri_replacement(url, param_name, find_this, true);
578        }
579        {
580            let to_remove = ["parent"];
581            params.remove_params(&to_remove);
582        }
583
584        let url = params.parse_with_url(&url);
585
586        loop {
587            let token = match self
588                .hub
589                .auth
590                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
591                .await
592            {
593                Ok(token) => token,
594                Err(e) => match dlg.token(e) {
595                    Ok(token) => token,
596                    Err(e) => {
597                        dlg.finished(false);
598                        return Err(common::Error::MissingToken(e));
599                    }
600                },
601            };
602            let mut req_result = {
603                let client = &self.hub.client;
604                dlg.pre_request();
605                let mut req_builder = hyper::Request::builder()
606                    .method(hyper::Method::GET)
607                    .uri(url.as_str())
608                    .header(USER_AGENT, self.hub._user_agent.clone());
609
610                if let Some(token) = token.as_ref() {
611                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
612                }
613
614                let request = req_builder
615                    .header(CONTENT_LENGTH, 0_u64)
616                    .body(common::to_body::<String>(None));
617
618                client.request(request.unwrap()).await
619            };
620
621            match req_result {
622                Err(err) => {
623                    if let common::Retry::After(d) = dlg.http_error(&err) {
624                        sleep(d).await;
625                        continue;
626                    }
627                    dlg.finished(false);
628                    return Err(common::Error::HttpError(err));
629                }
630                Ok(res) => {
631                    let (mut parts, body) = res.into_parts();
632                    let mut body = common::Body::new(body);
633                    if !parts.status.is_success() {
634                        let bytes = common::to_bytes(body).await.unwrap_or_default();
635                        let error = serde_json::from_str(&common::to_string(&bytes));
636                        let response = common::to_response(parts, bytes.into());
637
638                        if let common::Retry::After(d) =
639                            dlg.http_failure(&response, error.as_ref().ok())
640                        {
641                            sleep(d).await;
642                            continue;
643                        }
644
645                        dlg.finished(false);
646
647                        return Err(match error {
648                            Ok(value) => common::Error::BadRequest(value),
649                            _ => common::Error::Failure(response),
650                        });
651                    }
652                    let response = {
653                        let bytes = common::to_bytes(body).await.unwrap_or_default();
654                        let encoded = common::to_string(&bytes);
655                        match serde_json::from_str(&encoded) {
656                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
657                            Err(error) => {
658                                dlg.response_json_decode_error(&encoded, &error);
659                                return Err(common::Error::JsonDecodeError(
660                                    encoded.to_string(),
661                                    error,
662                                ));
663                            }
664                        }
665                    };
666
667                    dlg.finished(true);
668                    return Ok(response);
669                }
670            }
671        }
672    }
673
674    /// Required. The application for which to list delivery data. Format: `projects/{project_id}/androidApps/{app_id}`
675    ///
676    /// Sets the *parent* path property to the given value.
677    ///
678    /// Even though the property as already been set when instantiating this call,
679    /// we provide this method for API completeness.
680    pub fn parent(mut self, new_value: &str) -> ProjectAndroidAppDeliveryDataListCall<'a, C> {
681        self._parent = new_value.to_string();
682        self
683    }
684    /// A page token, received from a previous `ListAndroidDeliveryDataRequest` call. Provide this to retrieve the subsequent page. When paginating, all other parameters provided to `ListAndroidDeliveryDataRequest` must match the call that provided the page token.
685    ///
686    /// Sets the *page token* query property to the given value.
687    pub fn page_token(mut self, new_value: &str) -> ProjectAndroidAppDeliveryDataListCall<'a, C> {
688        self._page_token = Some(new_value.to_string());
689        self
690    }
691    /// The maximum number of entries to return. The service may return fewer than this value. If unspecified, at most 1,000 entries will be returned. The maximum value is 10,000; values above 10,000 will be capped to 10,000. This default may change over time.
692    ///
693    /// Sets the *page size* query property to the given value.
694    pub fn page_size(mut self, new_value: i32) -> ProjectAndroidAppDeliveryDataListCall<'a, C> {
695        self._page_size = Some(new_value);
696        self
697    }
698    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
699    /// while executing the actual API request.
700    ///
701    /// ````text
702    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
703    /// ````
704    ///
705    /// Sets the *delegate* property to the given value.
706    pub fn delegate(
707        mut self,
708        new_value: &'a mut dyn common::Delegate,
709    ) -> ProjectAndroidAppDeliveryDataListCall<'a, C> {
710        self._delegate = Some(new_value);
711        self
712    }
713
714    /// Set any additional parameter of the query string used in the request.
715    /// It should be used to set parameters which are not yet available through their own
716    /// setters.
717    ///
718    /// Please note that this method must not be used to set any of the known parameters
719    /// which have their own setter method. If done anyway, the request will fail.
720    ///
721    /// # Additional Parameters
722    ///
723    /// * *$.xgafv* (query-string) - V1 error format.
724    /// * *access_token* (query-string) - OAuth access token.
725    /// * *alt* (query-string) - Data format for response.
726    /// * *callback* (query-string) - JSONP
727    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
728    /// * *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.
729    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
730    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
731    /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
732    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
733    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
734    pub fn param<T>(mut self, name: T, value: T) -> ProjectAndroidAppDeliveryDataListCall<'a, C>
735    where
736        T: AsRef<str>,
737    {
738        self._additional_params
739            .insert(name.as_ref().to_string(), value.as_ref().to_string());
740        self
741    }
742
743    /// Identifies the authorization scope for the method you are building.
744    ///
745    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
746    /// [`Scope::CloudPlatform`].
747    ///
748    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
749    /// tokens for more than one scope.
750    ///
751    /// Usually there is more than one suitable scope to authorize an operation, some of which may
752    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
753    /// sufficient, a read-write scope will do as well.
754    pub fn add_scope<St>(mut self, scope: St) -> ProjectAndroidAppDeliveryDataListCall<'a, C>
755    where
756        St: AsRef<str>,
757    {
758        self._scopes.insert(String::from(scope.as_ref()));
759        self
760    }
761    /// Identifies the authorization scope(s) for the method you are building.
762    ///
763    /// See [`Self::add_scope()`] for details.
764    pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectAndroidAppDeliveryDataListCall<'a, C>
765    where
766        I: IntoIterator<Item = St>,
767        St: AsRef<str>,
768    {
769        self._scopes
770            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
771        self
772    }
773
774    /// Removes all scopes, and no default scope will be used either.
775    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
776    /// for details).
777    pub fn clear_scopes(mut self) -> ProjectAndroidAppDeliveryDataListCall<'a, C> {
778        self._scopes.clear();
779        self
780    }
781}