google_mybusinessnotifications1/
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// ########
12// HUB ###
13// ######
14
15/// Central instance to access all MyBusinessNotificationSettings related resource activities
16///
17/// # Examples
18///
19/// Instantiate a new hub
20///
21/// ```test_harness,no_run
22/// extern crate hyper;
23/// extern crate hyper_rustls;
24/// extern crate google_mybusinessnotifications1 as mybusinessnotifications1;
25/// use mybusinessnotifications1::api::NotificationSetting;
26/// use mybusinessnotifications1::{Result, Error};
27/// # async fn dox() {
28/// use mybusinessnotifications1::{MyBusinessNotificationSettings, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
29///
30/// // Get an ApplicationSecret instance by some means. It contains the `client_id` and
31/// // `client_secret`, among other things.
32/// let secret: yup_oauth2::ApplicationSecret = Default::default();
33/// // Instantiate the authenticator. It will choose a suitable authentication flow for you,
34/// // unless you replace  `None` with the desired Flow.
35/// // Provide your own `AuthenticatorDelegate` to adjust the way it operates and get feedback about
36/// // what's going on. You probably want to bring in your own `TokenStorage` to persist tokens and
37/// // retrieve them from storage.
38/// let connector = hyper_rustls::HttpsConnectorBuilder::new()
39///     .with_native_roots()
40///     .unwrap()
41///     .https_only()
42///     .enable_http2()
43///     .build();
44///
45/// let executor = hyper_util::rt::TokioExecutor::new();
46/// let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
47///     secret,
48///     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
49///     yup_oauth2::client::CustomHyperClientBuilder::from(
50///         hyper_util::client::legacy::Client::builder(executor).build(connector),
51///     ),
52/// ).build().await.unwrap();
53///
54/// let client = hyper_util::client::legacy::Client::builder(
55///     hyper_util::rt::TokioExecutor::new()
56/// )
57/// .build(
58///     hyper_rustls::HttpsConnectorBuilder::new()
59///         .with_native_roots()
60///         .unwrap()
61///         .https_or_http()
62///         .enable_http2()
63///         .build()
64/// );
65/// let mut hub = MyBusinessNotificationSettings::new(client, auth);
66/// // As the method needs a request, you would usually fill it with the desired information
67/// // into the respective structure. Some of the parts shown here might not be applicable !
68/// // Values shown here are possibly random and not representative !
69/// let mut req = NotificationSetting::default();
70///
71/// // You can configure optional parameters by calling the respective setters at will, and
72/// // execute the final call using `doit()`.
73/// // Values shown here are possibly random and not representative !
74/// let result = hub.accounts().update_notification_setting(req, "name")
75///              .update_mask(FieldMask::new::<&str>(&[]))
76///              .doit().await;
77///
78/// match result {
79///     Err(e) => match e {
80///         // The Error enum provides details about what exactly happened.
81///         // You can also just use its `Debug`, `Display` or `Error` traits
82///          Error::HttpError(_)
83///         |Error::Io(_)
84///         |Error::MissingAPIKey
85///         |Error::MissingToken(_)
86///         |Error::Cancelled
87///         |Error::UploadSizeLimitExceeded(_, _)
88///         |Error::Failure(_)
89///         |Error::BadRequest(_)
90///         |Error::FieldClash(_)
91///         |Error::JsonDecodeError(_, _) => println!("{}", e),
92///     },
93///     Ok(res) => println!("Success: {:?}", res),
94/// }
95/// # }
96/// ```
97#[derive(Clone)]
98pub struct MyBusinessNotificationSettings<C> {
99    pub client: common::Client<C>,
100    pub auth: Box<dyn common::GetToken>,
101    _user_agent: String,
102    _base_url: String,
103    _root_url: String,
104}
105
106impl<C> common::Hub for MyBusinessNotificationSettings<C> {}
107
108impl<'a, C> MyBusinessNotificationSettings<C> {
109    pub fn new<A: 'static + common::GetToken>(
110        client: common::Client<C>,
111        auth: A,
112    ) -> MyBusinessNotificationSettings<C> {
113        MyBusinessNotificationSettings {
114            client,
115            auth: Box::new(auth),
116            _user_agent: "google-api-rust-client/7.0.0".to_string(),
117            _base_url: "https://mybusinessnotifications.googleapis.com/".to_string(),
118            _root_url: "https://mybusinessnotifications.googleapis.com/".to_string(),
119        }
120    }
121
122    pub fn accounts(&'a self) -> AccountMethods<'a, C> {
123        AccountMethods { hub: self }
124    }
125
126    /// Set the user-agent header field to use in all requests to the server.
127    /// It defaults to `google-api-rust-client/7.0.0`.
128    ///
129    /// Returns the previously set user-agent.
130    pub fn user_agent(&mut self, agent_name: String) -> String {
131        std::mem::replace(&mut self._user_agent, agent_name)
132    }
133
134    /// Set the base url to use in all requests to the server.
135    /// It defaults to `https://mybusinessnotifications.googleapis.com/`.
136    ///
137    /// Returns the previously set base url.
138    pub fn base_url(&mut self, new_base_url: String) -> String {
139        std::mem::replace(&mut self._base_url, new_base_url)
140    }
141
142    /// Set the root url to use in all requests to the server.
143    /// It defaults to `https://mybusinessnotifications.googleapis.com/`.
144    ///
145    /// Returns the previously set root url.
146    pub fn root_url(&mut self, new_root_url: String) -> String {
147        std::mem::replace(&mut self._root_url, new_root_url)
148    }
149}
150
151// ############
152// SCHEMAS ###
153// ##########
154/// A Google Pub/Sub topic where notifications can be published when a location is updated or has a new review. There will be only one notification setting resource per-account.
155///
156/// # Activities
157///
158/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
159/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
160///
161/// * [get notification setting accounts](AccountGetNotificationSettingCall) (response)
162/// * [update notification setting accounts](AccountUpdateNotificationSettingCall) (request|response)
163#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
164#[serde_with::serde_as]
165#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
166pub struct NotificationSetting {
167    /// Required. The resource name this setting is for. This is of the form `accounts/{account_id}/notificationSetting`.
168    pub name: Option<String>,
169    /// The types of notifications that will be sent to the Pub/Sub topic. To stop receiving notifications entirely, use NotificationSettings.UpdateNotificationSetting with an empty notification_types or set the pubsub_topic to an empty string.
170    #[serde(rename = "notificationTypes")]
171    pub notification_types: Option<Vec<String>>,
172    /// Optional. The Google Pub/Sub topic that will receive notifications when locations managed by this account are updated. If unset, no notifications will be posted. The account mybusiness-api-pubsub@system.gserviceaccount.com must have at least Publish permissions on the Pub/Sub topic.
173    #[serde(rename = "pubsubTopic")]
174    pub pubsub_topic: Option<String>,
175}
176
177impl common::RequestValue for NotificationSetting {}
178impl common::ResponseResult for NotificationSetting {}
179
180// ###################
181// MethodBuilders ###
182// #################
183
184/// A builder providing access to all methods supported on *account* resources.
185/// It is not used directly, but through the [`MyBusinessNotificationSettings`] hub.
186///
187/// # Example
188///
189/// Instantiate a resource builder
190///
191/// ```test_harness,no_run
192/// extern crate hyper;
193/// extern crate hyper_rustls;
194/// extern crate google_mybusinessnotifications1 as mybusinessnotifications1;
195///
196/// # async fn dox() {
197/// use mybusinessnotifications1::{MyBusinessNotificationSettings, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
198///
199/// let secret: yup_oauth2::ApplicationSecret = Default::default();
200/// let connector = hyper_rustls::HttpsConnectorBuilder::new()
201///     .with_native_roots()
202///     .unwrap()
203///     .https_only()
204///     .enable_http2()
205///     .build();
206///
207/// let executor = hyper_util::rt::TokioExecutor::new();
208/// let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
209///     secret,
210///     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
211///     yup_oauth2::client::CustomHyperClientBuilder::from(
212///         hyper_util::client::legacy::Client::builder(executor).build(connector),
213///     ),
214/// ).build().await.unwrap();
215///
216/// let client = hyper_util::client::legacy::Client::builder(
217///     hyper_util::rt::TokioExecutor::new()
218/// )
219/// .build(
220///     hyper_rustls::HttpsConnectorBuilder::new()
221///         .with_native_roots()
222///         .unwrap()
223///         .https_or_http()
224///         .enable_http2()
225///         .build()
226/// );
227/// let mut hub = MyBusinessNotificationSettings::new(client, auth);
228/// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders*
229/// // like `get_notification_setting(...)` and `update_notification_setting(...)`
230/// // to build up your call.
231/// let rb = hub.accounts();
232/// # }
233/// ```
234pub struct AccountMethods<'a, C>
235where
236    C: 'a,
237{
238    hub: &'a MyBusinessNotificationSettings<C>,
239}
240
241impl<'a, C> common::MethodsBuilder for AccountMethods<'a, C> {}
242
243impl<'a, C> AccountMethods<'a, C> {
244    /// Create a builder to help you perform the following task:
245    ///
246    /// Returns the pubsub notification settings for the account.
247    ///
248    /// # Arguments
249    ///
250    /// * `name` - Required. The resource name of the notification setting we are trying to fetch.
251    pub fn get_notification_setting(&self, name: &str) -> AccountGetNotificationSettingCall<'a, C> {
252        AccountGetNotificationSettingCall {
253            hub: self.hub,
254            _name: name.to_string(),
255            _delegate: Default::default(),
256            _additional_params: Default::default(),
257        }
258    }
259
260    /// Create a builder to help you perform the following task:
261    ///
262    /// Sets the pubsub notification setting for the account informing Google which topic to send pubsub notifications for. Use the notification_types field within notification_setting to manipulate the events an account wants to subscribe to. An account will only have one notification setting resource, and only one pubsub topic can be set. To delete the setting, update with an empty notification_types
263    ///
264    /// # Arguments
265    ///
266    /// * `request` - No description provided.
267    /// * `name` - Required. The resource name this setting is for. This is of the form `accounts/{account_id}/notificationSetting`.
268    pub fn update_notification_setting(
269        &self,
270        request: NotificationSetting,
271        name: &str,
272    ) -> AccountUpdateNotificationSettingCall<'a, C> {
273        AccountUpdateNotificationSettingCall {
274            hub: self.hub,
275            _request: request,
276            _name: name.to_string(),
277            _update_mask: Default::default(),
278            _delegate: Default::default(),
279            _additional_params: Default::default(),
280        }
281    }
282}
283
284// ###################
285// CallBuilders   ###
286// #################
287
288/// Returns the pubsub notification settings for the account.
289///
290/// A builder for the *getNotificationSetting* method supported by a *account* resource.
291/// It is not used directly, but through a [`AccountMethods`] instance.
292///
293/// # Example
294///
295/// Instantiate a resource method builder
296///
297/// ```test_harness,no_run
298/// # extern crate hyper;
299/// # extern crate hyper_rustls;
300/// # extern crate google_mybusinessnotifications1 as mybusinessnotifications1;
301/// # async fn dox() {
302/// # use mybusinessnotifications1::{MyBusinessNotificationSettings, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
303///
304/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
305/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
306/// #     .with_native_roots()
307/// #     .unwrap()
308/// #     .https_only()
309/// #     .enable_http2()
310/// #     .build();
311///
312/// # let executor = hyper_util::rt::TokioExecutor::new();
313/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
314/// #     secret,
315/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
316/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
317/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
318/// #     ),
319/// # ).build().await.unwrap();
320///
321/// # let client = hyper_util::client::legacy::Client::builder(
322/// #     hyper_util::rt::TokioExecutor::new()
323/// # )
324/// # .build(
325/// #     hyper_rustls::HttpsConnectorBuilder::new()
326/// #         .with_native_roots()
327/// #         .unwrap()
328/// #         .https_or_http()
329/// #         .enable_http2()
330/// #         .build()
331/// # );
332/// # let mut hub = MyBusinessNotificationSettings::new(client, auth);
333/// // You can configure optional parameters by calling the respective setters at will, and
334/// // execute the final call using `doit()`.
335/// // Values shown here are possibly random and not representative !
336/// let result = hub.accounts().get_notification_setting("name")
337///              .doit().await;
338/// # }
339/// ```
340pub struct AccountGetNotificationSettingCall<'a, C>
341where
342    C: 'a,
343{
344    hub: &'a MyBusinessNotificationSettings<C>,
345    _name: String,
346    _delegate: Option<&'a mut dyn common::Delegate>,
347    _additional_params: HashMap<String, String>,
348}
349
350impl<'a, C> common::CallBuilder for AccountGetNotificationSettingCall<'a, C> {}
351
352impl<'a, C> AccountGetNotificationSettingCall<'a, C>
353where
354    C: common::Connector,
355{
356    /// Perform the operation you have build so far.
357    pub async fn doit(mut self) -> common::Result<(common::Response, NotificationSetting)> {
358        use std::borrow::Cow;
359        use std::io::{Read, Seek};
360
361        use common::{url::Params, ToParts};
362        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
363
364        let mut dd = common::DefaultDelegate;
365        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
366        dlg.begin(common::MethodInfo {
367            id: "mybusinessnotifications.accounts.getNotificationSetting",
368            http_method: hyper::Method::GET,
369        });
370
371        for &field in ["alt", "name"].iter() {
372            if self._additional_params.contains_key(field) {
373                dlg.finished(false);
374                return Err(common::Error::FieldClash(field));
375            }
376        }
377
378        let mut params = Params::with_capacity(3 + self._additional_params.len());
379        params.push("name", self._name);
380
381        params.extend(self._additional_params.iter());
382
383        params.push("alt", "json");
384        let mut url = self.hub._base_url.clone() + "v1/{+name}";
385
386        match dlg.api_key() {
387            Some(value) => params.push("key", value),
388            None => {
389                dlg.finished(false);
390                return Err(common::Error::MissingAPIKey);
391            }
392        }
393
394        #[allow(clippy::single_element_loop)]
395        for &(find_this, param_name) in [("{+name}", "name")].iter() {
396            url = params.uri_replacement(url, param_name, find_this, true);
397        }
398        {
399            let to_remove = ["name"];
400            params.remove_params(&to_remove);
401        }
402
403        let url = params.parse_with_url(&url);
404
405        loop {
406            let mut req_result = {
407                let client = &self.hub.client;
408                dlg.pre_request();
409                let mut req_builder = hyper::Request::builder()
410                    .method(hyper::Method::GET)
411                    .uri(url.as_str())
412                    .header(USER_AGENT, self.hub._user_agent.clone());
413
414                let request = req_builder
415                    .header(CONTENT_LENGTH, 0_u64)
416                    .body(common::to_body::<String>(None));
417
418                client.request(request.unwrap()).await
419            };
420
421            match req_result {
422                Err(err) => {
423                    if let common::Retry::After(d) = dlg.http_error(&err) {
424                        sleep(d).await;
425                        continue;
426                    }
427                    dlg.finished(false);
428                    return Err(common::Error::HttpError(err));
429                }
430                Ok(res) => {
431                    let (mut parts, body) = res.into_parts();
432                    let mut body = common::Body::new(body);
433                    if !parts.status.is_success() {
434                        let bytes = common::to_bytes(body).await.unwrap_or_default();
435                        let error = serde_json::from_str(&common::to_string(&bytes));
436                        let response = common::to_response(parts, bytes.into());
437
438                        if let common::Retry::After(d) =
439                            dlg.http_failure(&response, error.as_ref().ok())
440                        {
441                            sleep(d).await;
442                            continue;
443                        }
444
445                        dlg.finished(false);
446
447                        return Err(match error {
448                            Ok(value) => common::Error::BadRequest(value),
449                            _ => common::Error::Failure(response),
450                        });
451                    }
452                    let response = {
453                        let bytes = common::to_bytes(body).await.unwrap_or_default();
454                        let encoded = common::to_string(&bytes);
455                        match serde_json::from_str(&encoded) {
456                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
457                            Err(error) => {
458                                dlg.response_json_decode_error(&encoded, &error);
459                                return Err(common::Error::JsonDecodeError(
460                                    encoded.to_string(),
461                                    error,
462                                ));
463                            }
464                        }
465                    };
466
467                    dlg.finished(true);
468                    return Ok(response);
469                }
470            }
471        }
472    }
473
474    /// Required. The resource name of the notification setting we are trying to fetch.
475    ///
476    /// Sets the *name* path property to the given value.
477    ///
478    /// Even though the property as already been set when instantiating this call,
479    /// we provide this method for API completeness.
480    pub fn name(mut self, new_value: &str) -> AccountGetNotificationSettingCall<'a, C> {
481        self._name = new_value.to_string();
482        self
483    }
484    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
485    /// while executing the actual API request.
486    ///
487    /// ````text
488    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
489    /// ````
490    ///
491    /// Sets the *delegate* property to the given value.
492    pub fn delegate(
493        mut self,
494        new_value: &'a mut dyn common::Delegate,
495    ) -> AccountGetNotificationSettingCall<'a, C> {
496        self._delegate = Some(new_value);
497        self
498    }
499
500    /// Set any additional parameter of the query string used in the request.
501    /// It should be used to set parameters which are not yet available through their own
502    /// setters.
503    ///
504    /// Please note that this method must not be used to set any of the known parameters
505    /// which have their own setter method. If done anyway, the request will fail.
506    ///
507    /// # Additional Parameters
508    ///
509    /// * *$.xgafv* (query-string) - V1 error format.
510    /// * *access_token* (query-string) - OAuth access token.
511    /// * *alt* (query-string) - Data format for response.
512    /// * *callback* (query-string) - JSONP
513    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
514    /// * *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.
515    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
516    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
517    /// * *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.
518    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
519    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
520    pub fn param<T>(mut self, name: T, value: T) -> AccountGetNotificationSettingCall<'a, C>
521    where
522        T: AsRef<str>,
523    {
524        self._additional_params
525            .insert(name.as_ref().to_string(), value.as_ref().to_string());
526        self
527    }
528}
529
530/// Sets the pubsub notification setting for the account informing Google which topic to send pubsub notifications for. Use the notification_types field within notification_setting to manipulate the events an account wants to subscribe to. An account will only have one notification setting resource, and only one pubsub topic can be set. To delete the setting, update with an empty notification_types
531///
532/// A builder for the *updateNotificationSetting* method supported by a *account* resource.
533/// It is not used directly, but through a [`AccountMethods`] instance.
534///
535/// # Example
536///
537/// Instantiate a resource method builder
538///
539/// ```test_harness,no_run
540/// # extern crate hyper;
541/// # extern crate hyper_rustls;
542/// # extern crate google_mybusinessnotifications1 as mybusinessnotifications1;
543/// use mybusinessnotifications1::api::NotificationSetting;
544/// # async fn dox() {
545/// # use mybusinessnotifications1::{MyBusinessNotificationSettings, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
546///
547/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
548/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
549/// #     .with_native_roots()
550/// #     .unwrap()
551/// #     .https_only()
552/// #     .enable_http2()
553/// #     .build();
554///
555/// # let executor = hyper_util::rt::TokioExecutor::new();
556/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
557/// #     secret,
558/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
559/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
560/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
561/// #     ),
562/// # ).build().await.unwrap();
563///
564/// # let client = hyper_util::client::legacy::Client::builder(
565/// #     hyper_util::rt::TokioExecutor::new()
566/// # )
567/// # .build(
568/// #     hyper_rustls::HttpsConnectorBuilder::new()
569/// #         .with_native_roots()
570/// #         .unwrap()
571/// #         .https_or_http()
572/// #         .enable_http2()
573/// #         .build()
574/// # );
575/// # let mut hub = MyBusinessNotificationSettings::new(client, auth);
576/// // As the method needs a request, you would usually fill it with the desired information
577/// // into the respective structure. Some of the parts shown here might not be applicable !
578/// // Values shown here are possibly random and not representative !
579/// let mut req = NotificationSetting::default();
580///
581/// // You can configure optional parameters by calling the respective setters at will, and
582/// // execute the final call using `doit()`.
583/// // Values shown here are possibly random and not representative !
584/// let result = hub.accounts().update_notification_setting(req, "name")
585///              .update_mask(FieldMask::new::<&str>(&[]))
586///              .doit().await;
587/// # }
588/// ```
589pub struct AccountUpdateNotificationSettingCall<'a, C>
590where
591    C: 'a,
592{
593    hub: &'a MyBusinessNotificationSettings<C>,
594    _request: NotificationSetting,
595    _name: String,
596    _update_mask: Option<common::FieldMask>,
597    _delegate: Option<&'a mut dyn common::Delegate>,
598    _additional_params: HashMap<String, String>,
599}
600
601impl<'a, C> common::CallBuilder for AccountUpdateNotificationSettingCall<'a, C> {}
602
603impl<'a, C> AccountUpdateNotificationSettingCall<'a, C>
604where
605    C: common::Connector,
606{
607    /// Perform the operation you have build so far.
608    pub async fn doit(mut self) -> common::Result<(common::Response, NotificationSetting)> {
609        use std::borrow::Cow;
610        use std::io::{Read, Seek};
611
612        use common::{url::Params, ToParts};
613        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
614
615        let mut dd = common::DefaultDelegate;
616        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
617        dlg.begin(common::MethodInfo {
618            id: "mybusinessnotifications.accounts.updateNotificationSetting",
619            http_method: hyper::Method::PATCH,
620        });
621
622        for &field in ["alt", "name", "updateMask"].iter() {
623            if self._additional_params.contains_key(field) {
624                dlg.finished(false);
625                return Err(common::Error::FieldClash(field));
626            }
627        }
628
629        let mut params = Params::with_capacity(5 + self._additional_params.len());
630        params.push("name", self._name);
631        if let Some(value) = self._update_mask.as_ref() {
632            params.push("updateMask", value.to_string());
633        }
634
635        params.extend(self._additional_params.iter());
636
637        params.push("alt", "json");
638        let mut url = self.hub._base_url.clone() + "v1/{+name}";
639
640        match dlg.api_key() {
641            Some(value) => params.push("key", value),
642            None => {
643                dlg.finished(false);
644                return Err(common::Error::MissingAPIKey);
645            }
646        }
647
648        #[allow(clippy::single_element_loop)]
649        for &(find_this, param_name) in [("{+name}", "name")].iter() {
650            url = params.uri_replacement(url, param_name, find_this, true);
651        }
652        {
653            let to_remove = ["name"];
654            params.remove_params(&to_remove);
655        }
656
657        let url = params.parse_with_url(&url);
658
659        let mut json_mime_type = mime::APPLICATION_JSON;
660        let mut request_value_reader = {
661            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
662            common::remove_json_null_values(&mut value);
663            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
664            serde_json::to_writer(&mut dst, &value).unwrap();
665            dst
666        };
667        let request_size = request_value_reader
668            .seek(std::io::SeekFrom::End(0))
669            .unwrap();
670        request_value_reader
671            .seek(std::io::SeekFrom::Start(0))
672            .unwrap();
673
674        loop {
675            request_value_reader
676                .seek(std::io::SeekFrom::Start(0))
677                .unwrap();
678            let mut req_result = {
679                let client = &self.hub.client;
680                dlg.pre_request();
681                let mut req_builder = hyper::Request::builder()
682                    .method(hyper::Method::PATCH)
683                    .uri(url.as_str())
684                    .header(USER_AGENT, self.hub._user_agent.clone());
685
686                let request = req_builder
687                    .header(CONTENT_TYPE, json_mime_type.to_string())
688                    .header(CONTENT_LENGTH, request_size as u64)
689                    .body(common::to_body(
690                        request_value_reader.get_ref().clone().into(),
691                    ));
692
693                client.request(request.unwrap()).await
694            };
695
696            match req_result {
697                Err(err) => {
698                    if let common::Retry::After(d) = dlg.http_error(&err) {
699                        sleep(d).await;
700                        continue;
701                    }
702                    dlg.finished(false);
703                    return Err(common::Error::HttpError(err));
704                }
705                Ok(res) => {
706                    let (mut parts, body) = res.into_parts();
707                    let mut body = common::Body::new(body);
708                    if !parts.status.is_success() {
709                        let bytes = common::to_bytes(body).await.unwrap_or_default();
710                        let error = serde_json::from_str(&common::to_string(&bytes));
711                        let response = common::to_response(parts, bytes.into());
712
713                        if let common::Retry::After(d) =
714                            dlg.http_failure(&response, error.as_ref().ok())
715                        {
716                            sleep(d).await;
717                            continue;
718                        }
719
720                        dlg.finished(false);
721
722                        return Err(match error {
723                            Ok(value) => common::Error::BadRequest(value),
724                            _ => common::Error::Failure(response),
725                        });
726                    }
727                    let response = {
728                        let bytes = common::to_bytes(body).await.unwrap_or_default();
729                        let encoded = common::to_string(&bytes);
730                        match serde_json::from_str(&encoded) {
731                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
732                            Err(error) => {
733                                dlg.response_json_decode_error(&encoded, &error);
734                                return Err(common::Error::JsonDecodeError(
735                                    encoded.to_string(),
736                                    error,
737                                ));
738                            }
739                        }
740                    };
741
742                    dlg.finished(true);
743                    return Ok(response);
744                }
745            }
746        }
747    }
748
749    ///
750    /// Sets the *request* property to the given value.
751    ///
752    /// Even though the property as already been set when instantiating this call,
753    /// we provide this method for API completeness.
754    pub fn request(
755        mut self,
756        new_value: NotificationSetting,
757    ) -> AccountUpdateNotificationSettingCall<'a, C> {
758        self._request = new_value;
759        self
760    }
761    /// Required. The resource name this setting is for. This is of the form `accounts/{account_id}/notificationSetting`.
762    ///
763    /// Sets the *name* path property to the given value.
764    ///
765    /// Even though the property as already been set when instantiating this call,
766    /// we provide this method for API completeness.
767    pub fn name(mut self, new_value: &str) -> AccountUpdateNotificationSettingCall<'a, C> {
768        self._name = new_value.to_string();
769        self
770    }
771    /// Required. The specific fields that should be updated. The only editable field is notification_setting.
772    ///
773    /// Sets the *update mask* query property to the given value.
774    pub fn update_mask(
775        mut self,
776        new_value: common::FieldMask,
777    ) -> AccountUpdateNotificationSettingCall<'a, C> {
778        self._update_mask = Some(new_value);
779        self
780    }
781    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
782    /// while executing the actual API request.
783    ///
784    /// ````text
785    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
786    /// ````
787    ///
788    /// Sets the *delegate* property to the given value.
789    pub fn delegate(
790        mut self,
791        new_value: &'a mut dyn common::Delegate,
792    ) -> AccountUpdateNotificationSettingCall<'a, C> {
793        self._delegate = Some(new_value);
794        self
795    }
796
797    /// Set any additional parameter of the query string used in the request.
798    /// It should be used to set parameters which are not yet available through their own
799    /// setters.
800    ///
801    /// Please note that this method must not be used to set any of the known parameters
802    /// which have their own setter method. If done anyway, the request will fail.
803    ///
804    /// # Additional Parameters
805    ///
806    /// * *$.xgafv* (query-string) - V1 error format.
807    /// * *access_token* (query-string) - OAuth access token.
808    /// * *alt* (query-string) - Data format for response.
809    /// * *callback* (query-string) - JSONP
810    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
811    /// * *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.
812    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
813    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
814    /// * *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.
815    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
816    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
817    pub fn param<T>(mut self, name: T, value: T) -> AccountUpdateNotificationSettingCall<'a, C>
818    where
819        T: AsRef<str>,
820    {
821        self._additional_params
822            .insert(name.as_ref().to_string(), value.as_ref().to_string());
823        self
824    }
825}