google_firebasedatabase1_beta/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 /// View your data across Google Cloud services and see the email address of your Google Account
20 CloudPlatformReadOnly,
21
22 /// View and administer all your Firebase data and settings
23 Firebase,
24
25 /// View all your Firebase data and settings
26 FirebaseReadonly,
27}
28
29impl AsRef<str> for Scope {
30 fn as_ref(&self) -> &str {
31 match *self {
32 Scope::CloudPlatform => "https://www.googleapis.com/auth/cloud-platform",
33 Scope::CloudPlatformReadOnly => {
34 "https://www.googleapis.com/auth/cloud-platform.read-only"
35 }
36 Scope::Firebase => "https://www.googleapis.com/auth/firebase",
37 Scope::FirebaseReadonly => "https://www.googleapis.com/auth/firebase.readonly",
38 }
39 }
40}
41
42#[allow(clippy::derivable_impls)]
43impl Default for Scope {
44 fn default() -> Scope {
45 Scope::FirebaseReadonly
46 }
47}
48
49// ########
50// HUB ###
51// ######
52
53/// Central instance to access all FirebaseRealtimeDatabase related resource activities
54///
55/// # Examples
56///
57/// Instantiate a new hub
58///
59/// ```test_harness,no_run
60/// extern crate hyper;
61/// extern crate hyper_rustls;
62/// extern crate google_firebasedatabase1_beta as firebasedatabase1_beta;
63/// use firebasedatabase1_beta::api::DatabaseInstance;
64/// use firebasedatabase1_beta::{Result, Error};
65/// # async fn dox() {
66/// use firebasedatabase1_beta::{FirebaseRealtimeDatabase, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
67///
68/// // Get an ApplicationSecret instance by some means. It contains the `client_id` and
69/// // `client_secret`, among other things.
70/// let secret: yup_oauth2::ApplicationSecret = Default::default();
71/// // Instantiate the authenticator. It will choose a suitable authentication flow for you,
72/// // unless you replace `None` with the desired Flow.
73/// // Provide your own `AuthenticatorDelegate` to adjust the way it operates and get feedback about
74/// // what's going on. You probably want to bring in your own `TokenStorage` to persist tokens and
75/// // retrieve them from storage.
76/// let connector = hyper_rustls::HttpsConnectorBuilder::new()
77/// .with_native_roots()
78/// .unwrap()
79/// .https_only()
80/// .enable_http2()
81/// .build();
82///
83/// let executor = hyper_util::rt::TokioExecutor::new();
84/// let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
85/// secret,
86/// yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
87/// yup_oauth2::client::CustomHyperClientBuilder::from(
88/// hyper_util::client::legacy::Client::builder(executor).build(connector),
89/// ),
90/// ).build().await.unwrap();
91///
92/// let client = hyper_util::client::legacy::Client::builder(
93/// hyper_util::rt::TokioExecutor::new()
94/// )
95/// .build(
96/// hyper_rustls::HttpsConnectorBuilder::new()
97/// .with_native_roots()
98/// .unwrap()
99/// .https_or_http()
100/// .enable_http2()
101/// .build()
102/// );
103/// let mut hub = FirebaseRealtimeDatabase::new(client, auth);
104/// // As the method needs a request, you would usually fill it with the desired information
105/// // into the respective structure. Some of the parts shown here might not be applicable !
106/// // Values shown here are possibly random and not representative !
107/// let mut req = DatabaseInstance::default();
108///
109/// // You can configure optional parameters by calling the respective setters at will, and
110/// // execute the final call using `doit()`.
111/// // Values shown here are possibly random and not representative !
112/// let result = hub.projects().locations_instances_create(req, "parent")
113/// .validate_only(true)
114/// .database_id("duo")
115/// .doit().await;
116///
117/// match result {
118/// Err(e) => match e {
119/// // The Error enum provides details about what exactly happened.
120/// // You can also just use its `Debug`, `Display` or `Error` traits
121/// Error::HttpError(_)
122/// |Error::Io(_)
123/// |Error::MissingAPIKey
124/// |Error::MissingToken(_)
125/// |Error::Cancelled
126/// |Error::UploadSizeLimitExceeded(_, _)
127/// |Error::Failure(_)
128/// |Error::BadRequest(_)
129/// |Error::FieldClash(_)
130/// |Error::JsonDecodeError(_, _) => println!("{}", e),
131/// },
132/// Ok(res) => println!("Success: {:?}", res),
133/// }
134/// # }
135/// ```
136#[derive(Clone)]
137pub struct FirebaseRealtimeDatabase<C> {
138 pub client: common::Client<C>,
139 pub auth: Box<dyn common::GetToken>,
140 _user_agent: String,
141 _base_url: String,
142 _root_url: String,
143}
144
145impl<C> common::Hub for FirebaseRealtimeDatabase<C> {}
146
147impl<'a, C> FirebaseRealtimeDatabase<C> {
148 pub fn new<A: 'static + common::GetToken>(
149 client: common::Client<C>,
150 auth: A,
151 ) -> FirebaseRealtimeDatabase<C> {
152 FirebaseRealtimeDatabase {
153 client,
154 auth: Box::new(auth),
155 _user_agent: "google-api-rust-client/7.0.0".to_string(),
156 _base_url: "https://firebasedatabase.googleapis.com/".to_string(),
157 _root_url: "https://firebasedatabase.googleapis.com/".to_string(),
158 }
159 }
160
161 pub fn projects(&'a self) -> ProjectMethods<'a, C> {
162 ProjectMethods { hub: self }
163 }
164
165 /// Set the user-agent header field to use in all requests to the server.
166 /// It defaults to `google-api-rust-client/7.0.0`.
167 ///
168 /// Returns the previously set user-agent.
169 pub fn user_agent(&mut self, agent_name: String) -> String {
170 std::mem::replace(&mut self._user_agent, agent_name)
171 }
172
173 /// Set the base url to use in all requests to the server.
174 /// It defaults to `https://firebasedatabase.googleapis.com/`.
175 ///
176 /// Returns the previously set base url.
177 pub fn base_url(&mut self, new_base_url: String) -> String {
178 std::mem::replace(&mut self._base_url, new_base_url)
179 }
180
181 /// Set the root url to use in all requests to the server.
182 /// It defaults to `https://firebasedatabase.googleapis.com/`.
183 ///
184 /// Returns the previously set root url.
185 pub fn root_url(&mut self, new_root_url: String) -> String {
186 std::mem::replace(&mut self._root_url, new_root_url)
187 }
188}
189
190// ############
191// SCHEMAS ###
192// ##########
193/// Representation of a Realtime Database instance. Details on interacting with contents of a DatabaseInstance can be found at: https://firebase.google.com/docs/database/rest/start.
194///
195/// # Activities
196///
197/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
198/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
199///
200/// * [locations instances create projects](ProjectLocationInstanceCreateCall) (request|response)
201/// * [locations instances delete projects](ProjectLocationInstanceDeleteCall) (response)
202/// * [locations instances disable projects](ProjectLocationInstanceDisableCall) (response)
203/// * [locations instances get projects](ProjectLocationInstanceGetCall) (response)
204/// * [locations instances reenable projects](ProjectLocationInstanceReenableCall) (response)
205/// * [locations instances undelete projects](ProjectLocationInstanceUndeleteCall) (response)
206#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
207#[serde_with::serde_as]
208#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
209pub struct DatabaseInstance {
210 /// Output only. Output Only. The globally unique hostname of the database.
211 #[serde(rename = "databaseUrl")]
212 pub database_url: Option<String>,
213 /// The fully qualified resource name of the database instance, in the form: `projects/{project-number}/locations/{location-id}/instances/{database-id}`.
214 pub name: Option<String>,
215 /// Output only. The resource name of the project this instance belongs to. For example: `projects/{project-number}`.
216 pub project: Option<String>,
217 /// Output only. The database's lifecycle state. Read-only.
218 pub state: Option<String>,
219 /// Immutable. The database instance type. On creation only USER_DATABASE is allowed, which is also the default when omitted.
220 #[serde(rename = "type")]
221 pub type_: Option<String>,
222}
223
224impl common::RequestValue for DatabaseInstance {}
225impl common::ResponseResult for DatabaseInstance {}
226
227/// The request sent to the DisableDatabaseInstance method.
228///
229/// # Activities
230///
231/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
232/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
233///
234/// * [locations instances disable projects](ProjectLocationInstanceDisableCall) (request)
235#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
236#[serde_with::serde_as]
237#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
238pub struct DisableDatabaseInstanceRequest {
239 _never_set: Option<bool>,
240}
241
242impl common::RequestValue for DisableDatabaseInstanceRequest {}
243
244/// The response from the ListDatabaseInstances method.
245///
246/// # Activities
247///
248/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
249/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
250///
251/// * [locations instances list projects](ProjectLocationInstanceListCall) (response)
252#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
253#[serde_with::serde_as]
254#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
255pub struct ListDatabaseInstancesResponse {
256 /// List of each DatabaseInstance that is in the parent Firebase project.
257 pub instances: Option<Vec<DatabaseInstance>>,
258 /// If the result list is too large to fit in a single response, then a token is returned. If the string is empty, then this response is the last page of results. This token can be used in a subsequent call to `ListDatabaseInstances` to find the next group of database instances. Page tokens are short-lived and should not be persisted.
259 #[serde(rename = "nextPageToken")]
260 pub next_page_token: Option<String>,
261}
262
263impl common::ResponseResult for ListDatabaseInstancesResponse {}
264
265/// The request sent to the ReenableDatabaseInstance method.
266///
267/// # Activities
268///
269/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
270/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
271///
272/// * [locations instances reenable projects](ProjectLocationInstanceReenableCall) (request)
273#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
274#[serde_with::serde_as]
275#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
276pub struct ReenableDatabaseInstanceRequest {
277 _never_set: Option<bool>,
278}
279
280impl common::RequestValue for ReenableDatabaseInstanceRequest {}
281
282/// The request sent to UndeleteDatabaseInstance method.
283///
284/// # Activities
285///
286/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
287/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
288///
289/// * [locations instances undelete projects](ProjectLocationInstanceUndeleteCall) (request)
290#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
291#[serde_with::serde_as]
292#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
293pub struct UndeleteDatabaseInstanceRequest {
294 _never_set: Option<bool>,
295}
296
297impl common::RequestValue for UndeleteDatabaseInstanceRequest {}
298
299// ###################
300// MethodBuilders ###
301// #################
302
303/// A builder providing access to all methods supported on *project* resources.
304/// It is not used directly, but through the [`FirebaseRealtimeDatabase`] hub.
305///
306/// # Example
307///
308/// Instantiate a resource builder
309///
310/// ```test_harness,no_run
311/// extern crate hyper;
312/// extern crate hyper_rustls;
313/// extern crate google_firebasedatabase1_beta as firebasedatabase1_beta;
314///
315/// # async fn dox() {
316/// use firebasedatabase1_beta::{FirebaseRealtimeDatabase, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
317///
318/// let secret: yup_oauth2::ApplicationSecret = Default::default();
319/// let connector = hyper_rustls::HttpsConnectorBuilder::new()
320/// .with_native_roots()
321/// .unwrap()
322/// .https_only()
323/// .enable_http2()
324/// .build();
325///
326/// let executor = hyper_util::rt::TokioExecutor::new();
327/// let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
328/// secret,
329/// yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
330/// yup_oauth2::client::CustomHyperClientBuilder::from(
331/// hyper_util::client::legacy::Client::builder(executor).build(connector),
332/// ),
333/// ).build().await.unwrap();
334///
335/// let client = hyper_util::client::legacy::Client::builder(
336/// hyper_util::rt::TokioExecutor::new()
337/// )
338/// .build(
339/// hyper_rustls::HttpsConnectorBuilder::new()
340/// .with_native_roots()
341/// .unwrap()
342/// .https_or_http()
343/// .enable_http2()
344/// .build()
345/// );
346/// let mut hub = FirebaseRealtimeDatabase::new(client, auth);
347/// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders*
348/// // like `locations_instances_create(...)`, `locations_instances_delete(...)`, `locations_instances_disable(...)`, `locations_instances_get(...)`, `locations_instances_list(...)`, `locations_instances_reenable(...)` and `locations_instances_undelete(...)`
349/// // to build up your call.
350/// let rb = hub.projects();
351/// # }
352/// ```
353pub struct ProjectMethods<'a, C>
354where
355 C: 'a,
356{
357 hub: &'a FirebaseRealtimeDatabase<C>,
358}
359
360impl<'a, C> common::MethodsBuilder for ProjectMethods<'a, C> {}
361
362impl<'a, C> ProjectMethods<'a, C> {
363 /// Create a builder to help you perform the following task:
364 ///
365 /// Requests that a new DatabaseInstance be created. The state of a successfully created DatabaseInstance is ACTIVE. Only available for projects on the Blaze plan. Projects can be upgraded using the Cloud Billing API https://cloud.google.com/billing/reference/rest/v1/projects/updateBillingInfo. Note that it might take a few minutes for billing enablement state to propagate to Firebase systems.
366 ///
367 /// # Arguments
368 ///
369 /// * `request` - No description provided.
370 /// * `parent` - Required. The parent project for which to create a database instance, in the form: `projects/{project-number}/locations/{location-id}`.
371 pub fn locations_instances_create(
372 &self,
373 request: DatabaseInstance,
374 parent: &str,
375 ) -> ProjectLocationInstanceCreateCall<'a, C> {
376 ProjectLocationInstanceCreateCall {
377 hub: self.hub,
378 _request: request,
379 _parent: parent.to_string(),
380 _validate_only: Default::default(),
381 _database_id: Default::default(),
382 _delegate: Default::default(),
383 _additional_params: Default::default(),
384 _scopes: Default::default(),
385 }
386 }
387
388 /// Create a builder to help you perform the following task:
389 ///
390 /// Marks a DatabaseInstance to be deleted. The DatabaseInstance will be set to the DELETED state for 20 days, and will be purged within 30 days. The default database cannot be deleted. IDs for deleted database instances may never be recovered or re-used. The Database may only be deleted if it is already in a DISABLED state.
391 ///
392 /// # Arguments
393 ///
394 /// * `name` - Required. The fully qualified resource name of the database instance, in the form: `projects/{project-number}/locations/{location-id}/instances/{database-id}`
395 pub fn locations_instances_delete(
396 &self,
397 name: &str,
398 ) -> ProjectLocationInstanceDeleteCall<'a, C> {
399 ProjectLocationInstanceDeleteCall {
400 hub: self.hub,
401 _name: name.to_string(),
402 _delegate: Default::default(),
403 _additional_params: Default::default(),
404 _scopes: Default::default(),
405 }
406 }
407
408 /// Create a builder to help you perform the following task:
409 ///
410 /// Disables a DatabaseInstance. The database can be re-enabled later using ReenableDatabaseInstance. When a database is disabled, all reads and writes are denied, including view access in the Firebase console.
411 ///
412 /// # Arguments
413 ///
414 /// * `request` - No description provided.
415 /// * `name` - Required. The fully qualified resource name of the database instance, in the form: `projects/{project-number}/locations/{location-id}/instances/{database-id}`
416 pub fn locations_instances_disable(
417 &self,
418 request: DisableDatabaseInstanceRequest,
419 name: &str,
420 ) -> ProjectLocationInstanceDisableCall<'a, C> {
421 ProjectLocationInstanceDisableCall {
422 hub: self.hub,
423 _request: request,
424 _name: name.to_string(),
425 _delegate: Default::default(),
426 _additional_params: Default::default(),
427 _scopes: Default::default(),
428 }
429 }
430
431 /// Create a builder to help you perform the following task:
432 ///
433 /// Gets the DatabaseInstance identified by the specified resource name.
434 ///
435 /// # Arguments
436 ///
437 /// * `name` - Required. The fully qualified resource name of the database instance, in the form: `projects/{project-number}/locations/{location-id}/instances/{database-id}`. `database-id` is a globally unique identifier across all parent collections. For convenience, this method allows you to supply `-` as a wildcard character in place of specific collections under `projects` and `locations`. The resulting wildcarding form of the method is: `projects/-/locations/-/instances/{database-id}`.
438 pub fn locations_instances_get(&self, name: &str) -> ProjectLocationInstanceGetCall<'a, C> {
439 ProjectLocationInstanceGetCall {
440 hub: self.hub,
441 _name: name.to_string(),
442 _delegate: Default::default(),
443 _additional_params: Default::default(),
444 _scopes: Default::default(),
445 }
446 }
447
448 /// Create a builder to help you perform the following task:
449 ///
450 /// Lists each DatabaseInstance associated with the specified parent project. The list items are returned in no particular order, but will be a consistent view of the database instances when additional requests are made with a `pageToken`. The resulting list contains instances in any STATE. The list results may be stale by a few seconds. Use GetDatabaseInstance for consistent reads.
451 ///
452 /// # Arguments
453 ///
454 /// * `parent` - Required. The parent project for which to list database instances, in the form: `projects/{project-number}/locations/{location-id}` To list across all locations, use a parent in the form: `projects/{project-number}/locations/-`
455 pub fn locations_instances_list(&self, parent: &str) -> ProjectLocationInstanceListCall<'a, C> {
456 ProjectLocationInstanceListCall {
457 hub: self.hub,
458 _parent: parent.to_string(),
459 _show_deleted: Default::default(),
460 _page_token: Default::default(),
461 _page_size: Default::default(),
462 _delegate: Default::default(),
463 _additional_params: Default::default(),
464 _scopes: Default::default(),
465 }
466 }
467
468 /// Create a builder to help you perform the following task:
469 ///
470 /// Enables a DatabaseInstance. The database must have been disabled previously using DisableDatabaseInstance. The state of a successfully reenabled DatabaseInstance is ACTIVE.
471 ///
472 /// # Arguments
473 ///
474 /// * `request` - No description provided.
475 /// * `name` - Required. The fully qualified resource name of the database instance, in the form: `projects/{project-number}/locations/{location-id}/instances/{database-id}`
476 pub fn locations_instances_reenable(
477 &self,
478 request: ReenableDatabaseInstanceRequest,
479 name: &str,
480 ) -> ProjectLocationInstanceReenableCall<'a, C> {
481 ProjectLocationInstanceReenableCall {
482 hub: self.hub,
483 _request: request,
484 _name: name.to_string(),
485 _delegate: Default::default(),
486 _additional_params: Default::default(),
487 _scopes: Default::default(),
488 }
489 }
490
491 /// Create a builder to help you perform the following task:
492 ///
493 /// Restores a DatabaseInstance that was previously marked to be deleted. After the delete method is used, DatabaseInstances are set to the DELETED state for 20 days, and will be purged within 30 days. Databases in the DELETED state can be undeleted without losing any data. This method may only be used on a DatabaseInstance in the DELETED state. Purged DatabaseInstances may not be recovered.
494 ///
495 /// # Arguments
496 ///
497 /// * `request` - No description provided.
498 /// * `name` - Required. The fully qualified resource name of the database instance, in the form: `projects/{project-number}/locations/{location-id}/instances/{database-id}`
499 pub fn locations_instances_undelete(
500 &self,
501 request: UndeleteDatabaseInstanceRequest,
502 name: &str,
503 ) -> ProjectLocationInstanceUndeleteCall<'a, C> {
504 ProjectLocationInstanceUndeleteCall {
505 hub: self.hub,
506 _request: request,
507 _name: name.to_string(),
508 _delegate: Default::default(),
509 _additional_params: Default::default(),
510 _scopes: Default::default(),
511 }
512 }
513}
514
515// ###################
516// CallBuilders ###
517// #################
518
519/// Requests that a new DatabaseInstance be created. The state of a successfully created DatabaseInstance is ACTIVE. Only available for projects on the Blaze plan. Projects can be upgraded using the Cloud Billing API https://cloud.google.com/billing/reference/rest/v1/projects/updateBillingInfo. Note that it might take a few minutes for billing enablement state to propagate to Firebase systems.
520///
521/// A builder for the *locations.instances.create* method supported by a *project* resource.
522/// It is not used directly, but through a [`ProjectMethods`] instance.
523///
524/// # Example
525///
526/// Instantiate a resource method builder
527///
528/// ```test_harness,no_run
529/// # extern crate hyper;
530/// # extern crate hyper_rustls;
531/// # extern crate google_firebasedatabase1_beta as firebasedatabase1_beta;
532/// use firebasedatabase1_beta::api::DatabaseInstance;
533/// # async fn dox() {
534/// # use firebasedatabase1_beta::{FirebaseRealtimeDatabase, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
535///
536/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
537/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
538/// # .with_native_roots()
539/// # .unwrap()
540/// # .https_only()
541/// # .enable_http2()
542/// # .build();
543///
544/// # let executor = hyper_util::rt::TokioExecutor::new();
545/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
546/// # secret,
547/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
548/// # yup_oauth2::client::CustomHyperClientBuilder::from(
549/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
550/// # ),
551/// # ).build().await.unwrap();
552///
553/// # let client = hyper_util::client::legacy::Client::builder(
554/// # hyper_util::rt::TokioExecutor::new()
555/// # )
556/// # .build(
557/// # hyper_rustls::HttpsConnectorBuilder::new()
558/// # .with_native_roots()
559/// # .unwrap()
560/// # .https_or_http()
561/// # .enable_http2()
562/// # .build()
563/// # );
564/// # let mut hub = FirebaseRealtimeDatabase::new(client, auth);
565/// // As the method needs a request, you would usually fill it with the desired information
566/// // into the respective structure. Some of the parts shown here might not be applicable !
567/// // Values shown here are possibly random and not representative !
568/// let mut req = DatabaseInstance::default();
569///
570/// // You can configure optional parameters by calling the respective setters at will, and
571/// // execute the final call using `doit()`.
572/// // Values shown here are possibly random and not representative !
573/// let result = hub.projects().locations_instances_create(req, "parent")
574/// .validate_only(true)
575/// .database_id("Lorem")
576/// .doit().await;
577/// # }
578/// ```
579pub struct ProjectLocationInstanceCreateCall<'a, C>
580where
581 C: 'a,
582{
583 hub: &'a FirebaseRealtimeDatabase<C>,
584 _request: DatabaseInstance,
585 _parent: String,
586 _validate_only: Option<bool>,
587 _database_id: Option<String>,
588 _delegate: Option<&'a mut dyn common::Delegate>,
589 _additional_params: HashMap<String, String>,
590 _scopes: BTreeSet<String>,
591}
592
593impl<'a, C> common::CallBuilder for ProjectLocationInstanceCreateCall<'a, C> {}
594
595impl<'a, C> ProjectLocationInstanceCreateCall<'a, C>
596where
597 C: common::Connector,
598{
599 /// Perform the operation you have build so far.
600 pub async fn doit(mut self) -> common::Result<(common::Response, DatabaseInstance)> {
601 use std::borrow::Cow;
602 use std::io::{Read, Seek};
603
604 use common::{url::Params, ToParts};
605 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
606
607 let mut dd = common::DefaultDelegate;
608 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
609 dlg.begin(common::MethodInfo {
610 id: "firebasedatabase.projects.locations.instances.create",
611 http_method: hyper::Method::POST,
612 });
613
614 for &field in ["alt", "parent", "validateOnly", "databaseId"].iter() {
615 if self._additional_params.contains_key(field) {
616 dlg.finished(false);
617 return Err(common::Error::FieldClash(field));
618 }
619 }
620
621 let mut params = Params::with_capacity(6 + self._additional_params.len());
622 params.push("parent", self._parent);
623 if let Some(value) = self._validate_only.as_ref() {
624 params.push("validateOnly", value.to_string());
625 }
626 if let Some(value) = self._database_id.as_ref() {
627 params.push("databaseId", value);
628 }
629
630 params.extend(self._additional_params.iter());
631
632 params.push("alt", "json");
633 let mut url = self.hub._base_url.clone() + "v1beta/{+parent}/instances";
634 if self._scopes.is_empty() {
635 self._scopes
636 .insert(Scope::CloudPlatform.as_ref().to_string());
637 }
638
639 #[allow(clippy::single_element_loop)]
640 for &(find_this, param_name) in [("{+parent}", "parent")].iter() {
641 url = params.uri_replacement(url, param_name, find_this, true);
642 }
643 {
644 let to_remove = ["parent"];
645 params.remove_params(&to_remove);
646 }
647
648 let url = params.parse_with_url(&url);
649
650 let mut json_mime_type = mime::APPLICATION_JSON;
651 let mut request_value_reader = {
652 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
653 common::remove_json_null_values(&mut value);
654 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
655 serde_json::to_writer(&mut dst, &value).unwrap();
656 dst
657 };
658 let request_size = request_value_reader
659 .seek(std::io::SeekFrom::End(0))
660 .unwrap();
661 request_value_reader
662 .seek(std::io::SeekFrom::Start(0))
663 .unwrap();
664
665 loop {
666 let token = match self
667 .hub
668 .auth
669 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
670 .await
671 {
672 Ok(token) => token,
673 Err(e) => match dlg.token(e) {
674 Ok(token) => token,
675 Err(e) => {
676 dlg.finished(false);
677 return Err(common::Error::MissingToken(e));
678 }
679 },
680 };
681 request_value_reader
682 .seek(std::io::SeekFrom::Start(0))
683 .unwrap();
684 let mut req_result = {
685 let client = &self.hub.client;
686 dlg.pre_request();
687 let mut req_builder = hyper::Request::builder()
688 .method(hyper::Method::POST)
689 .uri(url.as_str())
690 .header(USER_AGENT, self.hub._user_agent.clone());
691
692 if let Some(token) = token.as_ref() {
693 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
694 }
695
696 let request = req_builder
697 .header(CONTENT_TYPE, json_mime_type.to_string())
698 .header(CONTENT_LENGTH, request_size as u64)
699 .body(common::to_body(
700 request_value_reader.get_ref().clone().into(),
701 ));
702
703 client.request(request.unwrap()).await
704 };
705
706 match req_result {
707 Err(err) => {
708 if let common::Retry::After(d) = dlg.http_error(&err) {
709 sleep(d).await;
710 continue;
711 }
712 dlg.finished(false);
713 return Err(common::Error::HttpError(err));
714 }
715 Ok(res) => {
716 let (mut parts, body) = res.into_parts();
717 let mut body = common::Body::new(body);
718 if !parts.status.is_success() {
719 let bytes = common::to_bytes(body).await.unwrap_or_default();
720 let error = serde_json::from_str(&common::to_string(&bytes));
721 let response = common::to_response(parts, bytes.into());
722
723 if let common::Retry::After(d) =
724 dlg.http_failure(&response, error.as_ref().ok())
725 {
726 sleep(d).await;
727 continue;
728 }
729
730 dlg.finished(false);
731
732 return Err(match error {
733 Ok(value) => common::Error::BadRequest(value),
734 _ => common::Error::Failure(response),
735 });
736 }
737 let response = {
738 let bytes = common::to_bytes(body).await.unwrap_or_default();
739 let encoded = common::to_string(&bytes);
740 match serde_json::from_str(&encoded) {
741 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
742 Err(error) => {
743 dlg.response_json_decode_error(&encoded, &error);
744 return Err(common::Error::JsonDecodeError(
745 encoded.to_string(),
746 error,
747 ));
748 }
749 }
750 };
751
752 dlg.finished(true);
753 return Ok(response);
754 }
755 }
756 }
757 }
758
759 ///
760 /// Sets the *request* property to the given value.
761 ///
762 /// Even though the property as already been set when instantiating this call,
763 /// we provide this method for API completeness.
764 pub fn request(
765 mut self,
766 new_value: DatabaseInstance,
767 ) -> ProjectLocationInstanceCreateCall<'a, C> {
768 self._request = new_value;
769 self
770 }
771 /// Required. The parent project for which to create a database instance, in the form: `projects/{project-number}/locations/{location-id}`.
772 ///
773 /// Sets the *parent* path property to the given value.
774 ///
775 /// Even though the property as already been set when instantiating this call,
776 /// we provide this method for API completeness.
777 pub fn parent(mut self, new_value: &str) -> ProjectLocationInstanceCreateCall<'a, C> {
778 self._parent = new_value.to_string();
779 self
780 }
781 /// When set to true, the request will be validated but not submitted.
782 ///
783 /// Sets the *validate only* query property to the given value.
784 pub fn validate_only(mut self, new_value: bool) -> ProjectLocationInstanceCreateCall<'a, C> {
785 self._validate_only = Some(new_value);
786 self
787 }
788 /// The globally unique identifier of the database instance.
789 ///
790 /// Sets the *database id* query property to the given value.
791 pub fn database_id(mut self, new_value: &str) -> ProjectLocationInstanceCreateCall<'a, C> {
792 self._database_id = Some(new_value.to_string());
793 self
794 }
795 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
796 /// while executing the actual API request.
797 ///
798 /// ````text
799 /// It should be used to handle progress information, and to implement a certain level of resilience.
800 /// ````
801 ///
802 /// Sets the *delegate* property to the given value.
803 pub fn delegate(
804 mut self,
805 new_value: &'a mut dyn common::Delegate,
806 ) -> ProjectLocationInstanceCreateCall<'a, C> {
807 self._delegate = Some(new_value);
808 self
809 }
810
811 /// Set any additional parameter of the query string used in the request.
812 /// It should be used to set parameters which are not yet available through their own
813 /// setters.
814 ///
815 /// Please note that this method must not be used to set any of the known parameters
816 /// which have their own setter method. If done anyway, the request will fail.
817 ///
818 /// # Additional Parameters
819 ///
820 /// * *$.xgafv* (query-string) - V1 error format.
821 /// * *access_token* (query-string) - OAuth access token.
822 /// * *alt* (query-string) - Data format for response.
823 /// * *callback* (query-string) - JSONP
824 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
825 /// * *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.
826 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
827 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
828 /// * *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.
829 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
830 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
831 pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationInstanceCreateCall<'a, C>
832 where
833 T: AsRef<str>,
834 {
835 self._additional_params
836 .insert(name.as_ref().to_string(), value.as_ref().to_string());
837 self
838 }
839
840 /// Identifies the authorization scope for the method you are building.
841 ///
842 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
843 /// [`Scope::CloudPlatform`].
844 ///
845 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
846 /// tokens for more than one scope.
847 ///
848 /// Usually there is more than one suitable scope to authorize an operation, some of which may
849 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
850 /// sufficient, a read-write scope will do as well.
851 pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationInstanceCreateCall<'a, C>
852 where
853 St: AsRef<str>,
854 {
855 self._scopes.insert(String::from(scope.as_ref()));
856 self
857 }
858 /// Identifies the authorization scope(s) for the method you are building.
859 ///
860 /// See [`Self::add_scope()`] for details.
861 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationInstanceCreateCall<'a, C>
862 where
863 I: IntoIterator<Item = St>,
864 St: AsRef<str>,
865 {
866 self._scopes
867 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
868 self
869 }
870
871 /// Removes all scopes, and no default scope will be used either.
872 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
873 /// for details).
874 pub fn clear_scopes(mut self) -> ProjectLocationInstanceCreateCall<'a, C> {
875 self._scopes.clear();
876 self
877 }
878}
879
880/// Marks a DatabaseInstance to be deleted. The DatabaseInstance will be set to the DELETED state for 20 days, and will be purged within 30 days. The default database cannot be deleted. IDs for deleted database instances may never be recovered or re-used. The Database may only be deleted if it is already in a DISABLED state.
881///
882/// A builder for the *locations.instances.delete* method supported by a *project* resource.
883/// It is not used directly, but through a [`ProjectMethods`] instance.
884///
885/// # Example
886///
887/// Instantiate a resource method builder
888///
889/// ```test_harness,no_run
890/// # extern crate hyper;
891/// # extern crate hyper_rustls;
892/// # extern crate google_firebasedatabase1_beta as firebasedatabase1_beta;
893/// # async fn dox() {
894/// # use firebasedatabase1_beta::{FirebaseRealtimeDatabase, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
895///
896/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
897/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
898/// # .with_native_roots()
899/// # .unwrap()
900/// # .https_only()
901/// # .enable_http2()
902/// # .build();
903///
904/// # let executor = hyper_util::rt::TokioExecutor::new();
905/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
906/// # secret,
907/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
908/// # yup_oauth2::client::CustomHyperClientBuilder::from(
909/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
910/// # ),
911/// # ).build().await.unwrap();
912///
913/// # let client = hyper_util::client::legacy::Client::builder(
914/// # hyper_util::rt::TokioExecutor::new()
915/// # )
916/// # .build(
917/// # hyper_rustls::HttpsConnectorBuilder::new()
918/// # .with_native_roots()
919/// # .unwrap()
920/// # .https_or_http()
921/// # .enable_http2()
922/// # .build()
923/// # );
924/// # let mut hub = FirebaseRealtimeDatabase::new(client, auth);
925/// // You can configure optional parameters by calling the respective setters at will, and
926/// // execute the final call using `doit()`.
927/// // Values shown here are possibly random and not representative !
928/// let result = hub.projects().locations_instances_delete("name")
929/// .doit().await;
930/// # }
931/// ```
932pub struct ProjectLocationInstanceDeleteCall<'a, C>
933where
934 C: 'a,
935{
936 hub: &'a FirebaseRealtimeDatabase<C>,
937 _name: String,
938 _delegate: Option<&'a mut dyn common::Delegate>,
939 _additional_params: HashMap<String, String>,
940 _scopes: BTreeSet<String>,
941}
942
943impl<'a, C> common::CallBuilder for ProjectLocationInstanceDeleteCall<'a, C> {}
944
945impl<'a, C> ProjectLocationInstanceDeleteCall<'a, C>
946where
947 C: common::Connector,
948{
949 /// Perform the operation you have build so far.
950 pub async fn doit(mut self) -> common::Result<(common::Response, DatabaseInstance)> {
951 use std::borrow::Cow;
952 use std::io::{Read, Seek};
953
954 use common::{url::Params, ToParts};
955 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
956
957 let mut dd = common::DefaultDelegate;
958 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
959 dlg.begin(common::MethodInfo {
960 id: "firebasedatabase.projects.locations.instances.delete",
961 http_method: hyper::Method::DELETE,
962 });
963
964 for &field in ["alt", "name"].iter() {
965 if self._additional_params.contains_key(field) {
966 dlg.finished(false);
967 return Err(common::Error::FieldClash(field));
968 }
969 }
970
971 let mut params = Params::with_capacity(3 + self._additional_params.len());
972 params.push("name", self._name);
973
974 params.extend(self._additional_params.iter());
975
976 params.push("alt", "json");
977 let mut url = self.hub._base_url.clone() + "v1beta/{+name}";
978 if self._scopes.is_empty() {
979 self._scopes
980 .insert(Scope::CloudPlatform.as_ref().to_string());
981 }
982
983 #[allow(clippy::single_element_loop)]
984 for &(find_this, param_name) in [("{+name}", "name")].iter() {
985 url = params.uri_replacement(url, param_name, find_this, true);
986 }
987 {
988 let to_remove = ["name"];
989 params.remove_params(&to_remove);
990 }
991
992 let url = params.parse_with_url(&url);
993
994 loop {
995 let token = match self
996 .hub
997 .auth
998 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
999 .await
1000 {
1001 Ok(token) => token,
1002 Err(e) => match dlg.token(e) {
1003 Ok(token) => token,
1004 Err(e) => {
1005 dlg.finished(false);
1006 return Err(common::Error::MissingToken(e));
1007 }
1008 },
1009 };
1010 let mut req_result = {
1011 let client = &self.hub.client;
1012 dlg.pre_request();
1013 let mut req_builder = hyper::Request::builder()
1014 .method(hyper::Method::DELETE)
1015 .uri(url.as_str())
1016 .header(USER_AGENT, self.hub._user_agent.clone());
1017
1018 if let Some(token) = token.as_ref() {
1019 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
1020 }
1021
1022 let request = req_builder
1023 .header(CONTENT_LENGTH, 0_u64)
1024 .body(common::to_body::<String>(None));
1025
1026 client.request(request.unwrap()).await
1027 };
1028
1029 match req_result {
1030 Err(err) => {
1031 if let common::Retry::After(d) = dlg.http_error(&err) {
1032 sleep(d).await;
1033 continue;
1034 }
1035 dlg.finished(false);
1036 return Err(common::Error::HttpError(err));
1037 }
1038 Ok(res) => {
1039 let (mut parts, body) = res.into_parts();
1040 let mut body = common::Body::new(body);
1041 if !parts.status.is_success() {
1042 let bytes = common::to_bytes(body).await.unwrap_or_default();
1043 let error = serde_json::from_str(&common::to_string(&bytes));
1044 let response = common::to_response(parts, bytes.into());
1045
1046 if let common::Retry::After(d) =
1047 dlg.http_failure(&response, error.as_ref().ok())
1048 {
1049 sleep(d).await;
1050 continue;
1051 }
1052
1053 dlg.finished(false);
1054
1055 return Err(match error {
1056 Ok(value) => common::Error::BadRequest(value),
1057 _ => common::Error::Failure(response),
1058 });
1059 }
1060 let response = {
1061 let bytes = common::to_bytes(body).await.unwrap_or_default();
1062 let encoded = common::to_string(&bytes);
1063 match serde_json::from_str(&encoded) {
1064 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
1065 Err(error) => {
1066 dlg.response_json_decode_error(&encoded, &error);
1067 return Err(common::Error::JsonDecodeError(
1068 encoded.to_string(),
1069 error,
1070 ));
1071 }
1072 }
1073 };
1074
1075 dlg.finished(true);
1076 return Ok(response);
1077 }
1078 }
1079 }
1080 }
1081
1082 /// Required. The fully qualified resource name of the database instance, in the form: `projects/{project-number}/locations/{location-id}/instances/{database-id}`
1083 ///
1084 /// Sets the *name* path property to the given value.
1085 ///
1086 /// Even though the property as already been set when instantiating this call,
1087 /// we provide this method for API completeness.
1088 pub fn name(mut self, new_value: &str) -> ProjectLocationInstanceDeleteCall<'a, C> {
1089 self._name = new_value.to_string();
1090 self
1091 }
1092 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
1093 /// while executing the actual API request.
1094 ///
1095 /// ````text
1096 /// It should be used to handle progress information, and to implement a certain level of resilience.
1097 /// ````
1098 ///
1099 /// Sets the *delegate* property to the given value.
1100 pub fn delegate(
1101 mut self,
1102 new_value: &'a mut dyn common::Delegate,
1103 ) -> ProjectLocationInstanceDeleteCall<'a, C> {
1104 self._delegate = Some(new_value);
1105 self
1106 }
1107
1108 /// Set any additional parameter of the query string used in the request.
1109 /// It should be used to set parameters which are not yet available through their own
1110 /// setters.
1111 ///
1112 /// Please note that this method must not be used to set any of the known parameters
1113 /// which have their own setter method. If done anyway, the request will fail.
1114 ///
1115 /// # Additional Parameters
1116 ///
1117 /// * *$.xgafv* (query-string) - V1 error format.
1118 /// * *access_token* (query-string) - OAuth access token.
1119 /// * *alt* (query-string) - Data format for response.
1120 /// * *callback* (query-string) - JSONP
1121 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
1122 /// * *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.
1123 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
1124 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
1125 /// * *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.
1126 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
1127 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
1128 pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationInstanceDeleteCall<'a, C>
1129 where
1130 T: AsRef<str>,
1131 {
1132 self._additional_params
1133 .insert(name.as_ref().to_string(), value.as_ref().to_string());
1134 self
1135 }
1136
1137 /// Identifies the authorization scope for the method you are building.
1138 ///
1139 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
1140 /// [`Scope::CloudPlatform`].
1141 ///
1142 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
1143 /// tokens for more than one scope.
1144 ///
1145 /// Usually there is more than one suitable scope to authorize an operation, some of which may
1146 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
1147 /// sufficient, a read-write scope will do as well.
1148 pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationInstanceDeleteCall<'a, C>
1149 where
1150 St: AsRef<str>,
1151 {
1152 self._scopes.insert(String::from(scope.as_ref()));
1153 self
1154 }
1155 /// Identifies the authorization scope(s) for the method you are building.
1156 ///
1157 /// See [`Self::add_scope()`] for details.
1158 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationInstanceDeleteCall<'a, C>
1159 where
1160 I: IntoIterator<Item = St>,
1161 St: AsRef<str>,
1162 {
1163 self._scopes
1164 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
1165 self
1166 }
1167
1168 /// Removes all scopes, and no default scope will be used either.
1169 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
1170 /// for details).
1171 pub fn clear_scopes(mut self) -> ProjectLocationInstanceDeleteCall<'a, C> {
1172 self._scopes.clear();
1173 self
1174 }
1175}
1176
1177/// Disables a DatabaseInstance. The database can be re-enabled later using ReenableDatabaseInstance. When a database is disabled, all reads and writes are denied, including view access in the Firebase console.
1178///
1179/// A builder for the *locations.instances.disable* method supported by a *project* resource.
1180/// It is not used directly, but through a [`ProjectMethods`] instance.
1181///
1182/// # Example
1183///
1184/// Instantiate a resource method builder
1185///
1186/// ```test_harness,no_run
1187/// # extern crate hyper;
1188/// # extern crate hyper_rustls;
1189/// # extern crate google_firebasedatabase1_beta as firebasedatabase1_beta;
1190/// use firebasedatabase1_beta::api::DisableDatabaseInstanceRequest;
1191/// # async fn dox() {
1192/// # use firebasedatabase1_beta::{FirebaseRealtimeDatabase, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
1193///
1194/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
1195/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
1196/// # .with_native_roots()
1197/// # .unwrap()
1198/// # .https_only()
1199/// # .enable_http2()
1200/// # .build();
1201///
1202/// # let executor = hyper_util::rt::TokioExecutor::new();
1203/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
1204/// # secret,
1205/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
1206/// # yup_oauth2::client::CustomHyperClientBuilder::from(
1207/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
1208/// # ),
1209/// # ).build().await.unwrap();
1210///
1211/// # let client = hyper_util::client::legacy::Client::builder(
1212/// # hyper_util::rt::TokioExecutor::new()
1213/// # )
1214/// # .build(
1215/// # hyper_rustls::HttpsConnectorBuilder::new()
1216/// # .with_native_roots()
1217/// # .unwrap()
1218/// # .https_or_http()
1219/// # .enable_http2()
1220/// # .build()
1221/// # );
1222/// # let mut hub = FirebaseRealtimeDatabase::new(client, auth);
1223/// // As the method needs a request, you would usually fill it with the desired information
1224/// // into the respective structure. Some of the parts shown here might not be applicable !
1225/// // Values shown here are possibly random and not representative !
1226/// let mut req = DisableDatabaseInstanceRequest::default();
1227///
1228/// // You can configure optional parameters by calling the respective setters at will, and
1229/// // execute the final call using `doit()`.
1230/// // Values shown here are possibly random and not representative !
1231/// let result = hub.projects().locations_instances_disable(req, "name")
1232/// .doit().await;
1233/// # }
1234/// ```
1235pub struct ProjectLocationInstanceDisableCall<'a, C>
1236where
1237 C: 'a,
1238{
1239 hub: &'a FirebaseRealtimeDatabase<C>,
1240 _request: DisableDatabaseInstanceRequest,
1241 _name: String,
1242 _delegate: Option<&'a mut dyn common::Delegate>,
1243 _additional_params: HashMap<String, String>,
1244 _scopes: BTreeSet<String>,
1245}
1246
1247impl<'a, C> common::CallBuilder for ProjectLocationInstanceDisableCall<'a, C> {}
1248
1249impl<'a, C> ProjectLocationInstanceDisableCall<'a, C>
1250where
1251 C: common::Connector,
1252{
1253 /// Perform the operation you have build so far.
1254 pub async fn doit(mut self) -> common::Result<(common::Response, DatabaseInstance)> {
1255 use std::borrow::Cow;
1256 use std::io::{Read, Seek};
1257
1258 use common::{url::Params, ToParts};
1259 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
1260
1261 let mut dd = common::DefaultDelegate;
1262 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
1263 dlg.begin(common::MethodInfo {
1264 id: "firebasedatabase.projects.locations.instances.disable",
1265 http_method: hyper::Method::POST,
1266 });
1267
1268 for &field in ["alt", "name"].iter() {
1269 if self._additional_params.contains_key(field) {
1270 dlg.finished(false);
1271 return Err(common::Error::FieldClash(field));
1272 }
1273 }
1274
1275 let mut params = Params::with_capacity(4 + self._additional_params.len());
1276 params.push("name", self._name);
1277
1278 params.extend(self._additional_params.iter());
1279
1280 params.push("alt", "json");
1281 let mut url = self.hub._base_url.clone() + "v1beta/{+name}:disable";
1282 if self._scopes.is_empty() {
1283 self._scopes
1284 .insert(Scope::CloudPlatform.as_ref().to_string());
1285 }
1286
1287 #[allow(clippy::single_element_loop)]
1288 for &(find_this, param_name) in [("{+name}", "name")].iter() {
1289 url = params.uri_replacement(url, param_name, find_this, true);
1290 }
1291 {
1292 let to_remove = ["name"];
1293 params.remove_params(&to_remove);
1294 }
1295
1296 let url = params.parse_with_url(&url);
1297
1298 let mut json_mime_type = mime::APPLICATION_JSON;
1299 let mut request_value_reader = {
1300 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
1301 common::remove_json_null_values(&mut value);
1302 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
1303 serde_json::to_writer(&mut dst, &value).unwrap();
1304 dst
1305 };
1306 let request_size = request_value_reader
1307 .seek(std::io::SeekFrom::End(0))
1308 .unwrap();
1309 request_value_reader
1310 .seek(std::io::SeekFrom::Start(0))
1311 .unwrap();
1312
1313 loop {
1314 let token = match self
1315 .hub
1316 .auth
1317 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
1318 .await
1319 {
1320 Ok(token) => token,
1321 Err(e) => match dlg.token(e) {
1322 Ok(token) => token,
1323 Err(e) => {
1324 dlg.finished(false);
1325 return Err(common::Error::MissingToken(e));
1326 }
1327 },
1328 };
1329 request_value_reader
1330 .seek(std::io::SeekFrom::Start(0))
1331 .unwrap();
1332 let mut req_result = {
1333 let client = &self.hub.client;
1334 dlg.pre_request();
1335 let mut req_builder = hyper::Request::builder()
1336 .method(hyper::Method::POST)
1337 .uri(url.as_str())
1338 .header(USER_AGENT, self.hub._user_agent.clone());
1339
1340 if let Some(token) = token.as_ref() {
1341 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
1342 }
1343
1344 let request = req_builder
1345 .header(CONTENT_TYPE, json_mime_type.to_string())
1346 .header(CONTENT_LENGTH, request_size as u64)
1347 .body(common::to_body(
1348 request_value_reader.get_ref().clone().into(),
1349 ));
1350
1351 client.request(request.unwrap()).await
1352 };
1353
1354 match req_result {
1355 Err(err) => {
1356 if let common::Retry::After(d) = dlg.http_error(&err) {
1357 sleep(d).await;
1358 continue;
1359 }
1360 dlg.finished(false);
1361 return Err(common::Error::HttpError(err));
1362 }
1363 Ok(res) => {
1364 let (mut parts, body) = res.into_parts();
1365 let mut body = common::Body::new(body);
1366 if !parts.status.is_success() {
1367 let bytes = common::to_bytes(body).await.unwrap_or_default();
1368 let error = serde_json::from_str(&common::to_string(&bytes));
1369 let response = common::to_response(parts, bytes.into());
1370
1371 if let common::Retry::After(d) =
1372 dlg.http_failure(&response, error.as_ref().ok())
1373 {
1374 sleep(d).await;
1375 continue;
1376 }
1377
1378 dlg.finished(false);
1379
1380 return Err(match error {
1381 Ok(value) => common::Error::BadRequest(value),
1382 _ => common::Error::Failure(response),
1383 });
1384 }
1385 let response = {
1386 let bytes = common::to_bytes(body).await.unwrap_or_default();
1387 let encoded = common::to_string(&bytes);
1388 match serde_json::from_str(&encoded) {
1389 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
1390 Err(error) => {
1391 dlg.response_json_decode_error(&encoded, &error);
1392 return Err(common::Error::JsonDecodeError(
1393 encoded.to_string(),
1394 error,
1395 ));
1396 }
1397 }
1398 };
1399
1400 dlg.finished(true);
1401 return Ok(response);
1402 }
1403 }
1404 }
1405 }
1406
1407 ///
1408 /// Sets the *request* property to the given value.
1409 ///
1410 /// Even though the property as already been set when instantiating this call,
1411 /// we provide this method for API completeness.
1412 pub fn request(
1413 mut self,
1414 new_value: DisableDatabaseInstanceRequest,
1415 ) -> ProjectLocationInstanceDisableCall<'a, C> {
1416 self._request = new_value;
1417 self
1418 }
1419 /// Required. The fully qualified resource name of the database instance, in the form: `projects/{project-number}/locations/{location-id}/instances/{database-id}`
1420 ///
1421 /// Sets the *name* path property to the given value.
1422 ///
1423 /// Even though the property as already been set when instantiating this call,
1424 /// we provide this method for API completeness.
1425 pub fn name(mut self, new_value: &str) -> ProjectLocationInstanceDisableCall<'a, C> {
1426 self._name = new_value.to_string();
1427 self
1428 }
1429 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
1430 /// while executing the actual API request.
1431 ///
1432 /// ````text
1433 /// It should be used to handle progress information, and to implement a certain level of resilience.
1434 /// ````
1435 ///
1436 /// Sets the *delegate* property to the given value.
1437 pub fn delegate(
1438 mut self,
1439 new_value: &'a mut dyn common::Delegate,
1440 ) -> ProjectLocationInstanceDisableCall<'a, C> {
1441 self._delegate = Some(new_value);
1442 self
1443 }
1444
1445 /// Set any additional parameter of the query string used in the request.
1446 /// It should be used to set parameters which are not yet available through their own
1447 /// setters.
1448 ///
1449 /// Please note that this method must not be used to set any of the known parameters
1450 /// which have their own setter method. If done anyway, the request will fail.
1451 ///
1452 /// # Additional Parameters
1453 ///
1454 /// * *$.xgafv* (query-string) - V1 error format.
1455 /// * *access_token* (query-string) - OAuth access token.
1456 /// * *alt* (query-string) - Data format for response.
1457 /// * *callback* (query-string) - JSONP
1458 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
1459 /// * *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.
1460 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
1461 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
1462 /// * *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.
1463 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
1464 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
1465 pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationInstanceDisableCall<'a, C>
1466 where
1467 T: AsRef<str>,
1468 {
1469 self._additional_params
1470 .insert(name.as_ref().to_string(), value.as_ref().to_string());
1471 self
1472 }
1473
1474 /// Identifies the authorization scope for the method you are building.
1475 ///
1476 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
1477 /// [`Scope::CloudPlatform`].
1478 ///
1479 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
1480 /// tokens for more than one scope.
1481 ///
1482 /// Usually there is more than one suitable scope to authorize an operation, some of which may
1483 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
1484 /// sufficient, a read-write scope will do as well.
1485 pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationInstanceDisableCall<'a, C>
1486 where
1487 St: AsRef<str>,
1488 {
1489 self._scopes.insert(String::from(scope.as_ref()));
1490 self
1491 }
1492 /// Identifies the authorization scope(s) for the method you are building.
1493 ///
1494 /// See [`Self::add_scope()`] for details.
1495 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationInstanceDisableCall<'a, C>
1496 where
1497 I: IntoIterator<Item = St>,
1498 St: AsRef<str>,
1499 {
1500 self._scopes
1501 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
1502 self
1503 }
1504
1505 /// Removes all scopes, and no default scope will be used either.
1506 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
1507 /// for details).
1508 pub fn clear_scopes(mut self) -> ProjectLocationInstanceDisableCall<'a, C> {
1509 self._scopes.clear();
1510 self
1511 }
1512}
1513
1514/// Gets the DatabaseInstance identified by the specified resource name.
1515///
1516/// A builder for the *locations.instances.get* method supported by a *project* resource.
1517/// It is not used directly, but through a [`ProjectMethods`] instance.
1518///
1519/// # Example
1520///
1521/// Instantiate a resource method builder
1522///
1523/// ```test_harness,no_run
1524/// # extern crate hyper;
1525/// # extern crate hyper_rustls;
1526/// # extern crate google_firebasedatabase1_beta as firebasedatabase1_beta;
1527/// # async fn dox() {
1528/// # use firebasedatabase1_beta::{FirebaseRealtimeDatabase, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
1529///
1530/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
1531/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
1532/// # .with_native_roots()
1533/// # .unwrap()
1534/// # .https_only()
1535/// # .enable_http2()
1536/// # .build();
1537///
1538/// # let executor = hyper_util::rt::TokioExecutor::new();
1539/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
1540/// # secret,
1541/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
1542/// # yup_oauth2::client::CustomHyperClientBuilder::from(
1543/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
1544/// # ),
1545/// # ).build().await.unwrap();
1546///
1547/// # let client = hyper_util::client::legacy::Client::builder(
1548/// # hyper_util::rt::TokioExecutor::new()
1549/// # )
1550/// # .build(
1551/// # hyper_rustls::HttpsConnectorBuilder::new()
1552/// # .with_native_roots()
1553/// # .unwrap()
1554/// # .https_or_http()
1555/// # .enable_http2()
1556/// # .build()
1557/// # );
1558/// # let mut hub = FirebaseRealtimeDatabase::new(client, auth);
1559/// // You can configure optional parameters by calling the respective setters at will, and
1560/// // execute the final call using `doit()`.
1561/// // Values shown here are possibly random and not representative !
1562/// let result = hub.projects().locations_instances_get("name")
1563/// .doit().await;
1564/// # }
1565/// ```
1566pub struct ProjectLocationInstanceGetCall<'a, C>
1567where
1568 C: 'a,
1569{
1570 hub: &'a FirebaseRealtimeDatabase<C>,
1571 _name: String,
1572 _delegate: Option<&'a mut dyn common::Delegate>,
1573 _additional_params: HashMap<String, String>,
1574 _scopes: BTreeSet<String>,
1575}
1576
1577impl<'a, C> common::CallBuilder for ProjectLocationInstanceGetCall<'a, C> {}
1578
1579impl<'a, C> ProjectLocationInstanceGetCall<'a, C>
1580where
1581 C: common::Connector,
1582{
1583 /// Perform the operation you have build so far.
1584 pub async fn doit(mut self) -> common::Result<(common::Response, DatabaseInstance)> {
1585 use std::borrow::Cow;
1586 use std::io::{Read, Seek};
1587
1588 use common::{url::Params, ToParts};
1589 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
1590
1591 let mut dd = common::DefaultDelegate;
1592 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
1593 dlg.begin(common::MethodInfo {
1594 id: "firebasedatabase.projects.locations.instances.get",
1595 http_method: hyper::Method::GET,
1596 });
1597
1598 for &field in ["alt", "name"].iter() {
1599 if self._additional_params.contains_key(field) {
1600 dlg.finished(false);
1601 return Err(common::Error::FieldClash(field));
1602 }
1603 }
1604
1605 let mut params = Params::with_capacity(3 + self._additional_params.len());
1606 params.push("name", self._name);
1607
1608 params.extend(self._additional_params.iter());
1609
1610 params.push("alt", "json");
1611 let mut url = self.hub._base_url.clone() + "v1beta/{+name}";
1612 if self._scopes.is_empty() {
1613 self._scopes
1614 .insert(Scope::FirebaseReadonly.as_ref().to_string());
1615 }
1616
1617 #[allow(clippy::single_element_loop)]
1618 for &(find_this, param_name) in [("{+name}", "name")].iter() {
1619 url = params.uri_replacement(url, param_name, find_this, true);
1620 }
1621 {
1622 let to_remove = ["name"];
1623 params.remove_params(&to_remove);
1624 }
1625
1626 let url = params.parse_with_url(&url);
1627
1628 loop {
1629 let token = match self
1630 .hub
1631 .auth
1632 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
1633 .await
1634 {
1635 Ok(token) => token,
1636 Err(e) => match dlg.token(e) {
1637 Ok(token) => token,
1638 Err(e) => {
1639 dlg.finished(false);
1640 return Err(common::Error::MissingToken(e));
1641 }
1642 },
1643 };
1644 let mut req_result = {
1645 let client = &self.hub.client;
1646 dlg.pre_request();
1647 let mut req_builder = hyper::Request::builder()
1648 .method(hyper::Method::GET)
1649 .uri(url.as_str())
1650 .header(USER_AGENT, self.hub._user_agent.clone());
1651
1652 if let Some(token) = token.as_ref() {
1653 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
1654 }
1655
1656 let request = req_builder
1657 .header(CONTENT_LENGTH, 0_u64)
1658 .body(common::to_body::<String>(None));
1659
1660 client.request(request.unwrap()).await
1661 };
1662
1663 match req_result {
1664 Err(err) => {
1665 if let common::Retry::After(d) = dlg.http_error(&err) {
1666 sleep(d).await;
1667 continue;
1668 }
1669 dlg.finished(false);
1670 return Err(common::Error::HttpError(err));
1671 }
1672 Ok(res) => {
1673 let (mut parts, body) = res.into_parts();
1674 let mut body = common::Body::new(body);
1675 if !parts.status.is_success() {
1676 let bytes = common::to_bytes(body).await.unwrap_or_default();
1677 let error = serde_json::from_str(&common::to_string(&bytes));
1678 let response = common::to_response(parts, bytes.into());
1679
1680 if let common::Retry::After(d) =
1681 dlg.http_failure(&response, error.as_ref().ok())
1682 {
1683 sleep(d).await;
1684 continue;
1685 }
1686
1687 dlg.finished(false);
1688
1689 return Err(match error {
1690 Ok(value) => common::Error::BadRequest(value),
1691 _ => common::Error::Failure(response),
1692 });
1693 }
1694 let response = {
1695 let bytes = common::to_bytes(body).await.unwrap_or_default();
1696 let encoded = common::to_string(&bytes);
1697 match serde_json::from_str(&encoded) {
1698 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
1699 Err(error) => {
1700 dlg.response_json_decode_error(&encoded, &error);
1701 return Err(common::Error::JsonDecodeError(
1702 encoded.to_string(),
1703 error,
1704 ));
1705 }
1706 }
1707 };
1708
1709 dlg.finished(true);
1710 return Ok(response);
1711 }
1712 }
1713 }
1714 }
1715
1716 /// Required. The fully qualified resource name of the database instance, in the form: `projects/{project-number}/locations/{location-id}/instances/{database-id}`. `database-id` is a globally unique identifier across all parent collections. For convenience, this method allows you to supply `-` as a wildcard character in place of specific collections under `projects` and `locations`. The resulting wildcarding form of the method is: `projects/-/locations/-/instances/{database-id}`.
1717 ///
1718 /// Sets the *name* path property to the given value.
1719 ///
1720 /// Even though the property as already been set when instantiating this call,
1721 /// we provide this method for API completeness.
1722 pub fn name(mut self, new_value: &str) -> ProjectLocationInstanceGetCall<'a, C> {
1723 self._name = new_value.to_string();
1724 self
1725 }
1726 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
1727 /// while executing the actual API request.
1728 ///
1729 /// ````text
1730 /// It should be used to handle progress information, and to implement a certain level of resilience.
1731 /// ````
1732 ///
1733 /// Sets the *delegate* property to the given value.
1734 pub fn delegate(
1735 mut self,
1736 new_value: &'a mut dyn common::Delegate,
1737 ) -> ProjectLocationInstanceGetCall<'a, C> {
1738 self._delegate = Some(new_value);
1739 self
1740 }
1741
1742 /// Set any additional parameter of the query string used in the request.
1743 /// It should be used to set parameters which are not yet available through their own
1744 /// setters.
1745 ///
1746 /// Please note that this method must not be used to set any of the known parameters
1747 /// which have their own setter method. If done anyway, the request will fail.
1748 ///
1749 /// # Additional Parameters
1750 ///
1751 /// * *$.xgafv* (query-string) - V1 error format.
1752 /// * *access_token* (query-string) - OAuth access token.
1753 /// * *alt* (query-string) - Data format for response.
1754 /// * *callback* (query-string) - JSONP
1755 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
1756 /// * *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.
1757 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
1758 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
1759 /// * *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.
1760 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
1761 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
1762 pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationInstanceGetCall<'a, C>
1763 where
1764 T: AsRef<str>,
1765 {
1766 self._additional_params
1767 .insert(name.as_ref().to_string(), value.as_ref().to_string());
1768 self
1769 }
1770
1771 /// Identifies the authorization scope for the method you are building.
1772 ///
1773 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
1774 /// [`Scope::FirebaseReadonly`].
1775 ///
1776 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
1777 /// tokens for more than one scope.
1778 ///
1779 /// Usually there is more than one suitable scope to authorize an operation, some of which may
1780 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
1781 /// sufficient, a read-write scope will do as well.
1782 pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationInstanceGetCall<'a, C>
1783 where
1784 St: AsRef<str>,
1785 {
1786 self._scopes.insert(String::from(scope.as_ref()));
1787 self
1788 }
1789 /// Identifies the authorization scope(s) for the method you are building.
1790 ///
1791 /// See [`Self::add_scope()`] for details.
1792 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationInstanceGetCall<'a, C>
1793 where
1794 I: IntoIterator<Item = St>,
1795 St: AsRef<str>,
1796 {
1797 self._scopes
1798 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
1799 self
1800 }
1801
1802 /// Removes all scopes, and no default scope will be used either.
1803 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
1804 /// for details).
1805 pub fn clear_scopes(mut self) -> ProjectLocationInstanceGetCall<'a, C> {
1806 self._scopes.clear();
1807 self
1808 }
1809}
1810
1811/// Lists each DatabaseInstance associated with the specified parent project. The list items are returned in no particular order, but will be a consistent view of the database instances when additional requests are made with a `pageToken`. The resulting list contains instances in any STATE. The list results may be stale by a few seconds. Use GetDatabaseInstance for consistent reads.
1812///
1813/// A builder for the *locations.instances.list* method supported by a *project* resource.
1814/// It is not used directly, but through a [`ProjectMethods`] instance.
1815///
1816/// # Example
1817///
1818/// Instantiate a resource method builder
1819///
1820/// ```test_harness,no_run
1821/// # extern crate hyper;
1822/// # extern crate hyper_rustls;
1823/// # extern crate google_firebasedatabase1_beta as firebasedatabase1_beta;
1824/// # async fn dox() {
1825/// # use firebasedatabase1_beta::{FirebaseRealtimeDatabase, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
1826///
1827/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
1828/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
1829/// # .with_native_roots()
1830/// # .unwrap()
1831/// # .https_only()
1832/// # .enable_http2()
1833/// # .build();
1834///
1835/// # let executor = hyper_util::rt::TokioExecutor::new();
1836/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
1837/// # secret,
1838/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
1839/// # yup_oauth2::client::CustomHyperClientBuilder::from(
1840/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
1841/// # ),
1842/// # ).build().await.unwrap();
1843///
1844/// # let client = hyper_util::client::legacy::Client::builder(
1845/// # hyper_util::rt::TokioExecutor::new()
1846/// # )
1847/// # .build(
1848/// # hyper_rustls::HttpsConnectorBuilder::new()
1849/// # .with_native_roots()
1850/// # .unwrap()
1851/// # .https_or_http()
1852/// # .enable_http2()
1853/// # .build()
1854/// # );
1855/// # let mut hub = FirebaseRealtimeDatabase::new(client, auth);
1856/// // You can configure optional parameters by calling the respective setters at will, and
1857/// // execute the final call using `doit()`.
1858/// // Values shown here are possibly random and not representative !
1859/// let result = hub.projects().locations_instances_list("parent")
1860/// .show_deleted(true)
1861/// .page_token("invidunt")
1862/// .page_size(-47)
1863/// .doit().await;
1864/// # }
1865/// ```
1866pub struct ProjectLocationInstanceListCall<'a, C>
1867where
1868 C: 'a,
1869{
1870 hub: &'a FirebaseRealtimeDatabase<C>,
1871 _parent: String,
1872 _show_deleted: Option<bool>,
1873 _page_token: Option<String>,
1874 _page_size: Option<i32>,
1875 _delegate: Option<&'a mut dyn common::Delegate>,
1876 _additional_params: HashMap<String, String>,
1877 _scopes: BTreeSet<String>,
1878}
1879
1880impl<'a, C> common::CallBuilder for ProjectLocationInstanceListCall<'a, C> {}
1881
1882impl<'a, C> ProjectLocationInstanceListCall<'a, C>
1883where
1884 C: common::Connector,
1885{
1886 /// Perform the operation you have build so far.
1887 pub async fn doit(
1888 mut self,
1889 ) -> common::Result<(common::Response, ListDatabaseInstancesResponse)> {
1890 use std::borrow::Cow;
1891 use std::io::{Read, Seek};
1892
1893 use common::{url::Params, ToParts};
1894 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
1895
1896 let mut dd = common::DefaultDelegate;
1897 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
1898 dlg.begin(common::MethodInfo {
1899 id: "firebasedatabase.projects.locations.instances.list",
1900 http_method: hyper::Method::GET,
1901 });
1902
1903 for &field in ["alt", "parent", "showDeleted", "pageToken", "pageSize"].iter() {
1904 if self._additional_params.contains_key(field) {
1905 dlg.finished(false);
1906 return Err(common::Error::FieldClash(field));
1907 }
1908 }
1909
1910 let mut params = Params::with_capacity(6 + self._additional_params.len());
1911 params.push("parent", self._parent);
1912 if let Some(value) = self._show_deleted.as_ref() {
1913 params.push("showDeleted", value.to_string());
1914 }
1915 if let Some(value) = self._page_token.as_ref() {
1916 params.push("pageToken", value);
1917 }
1918 if let Some(value) = self._page_size.as_ref() {
1919 params.push("pageSize", value.to_string());
1920 }
1921
1922 params.extend(self._additional_params.iter());
1923
1924 params.push("alt", "json");
1925 let mut url = self.hub._base_url.clone() + "v1beta/{+parent}/instances";
1926 if self._scopes.is_empty() {
1927 self._scopes
1928 .insert(Scope::FirebaseReadonly.as_ref().to_string());
1929 }
1930
1931 #[allow(clippy::single_element_loop)]
1932 for &(find_this, param_name) in [("{+parent}", "parent")].iter() {
1933 url = params.uri_replacement(url, param_name, find_this, true);
1934 }
1935 {
1936 let to_remove = ["parent"];
1937 params.remove_params(&to_remove);
1938 }
1939
1940 let url = params.parse_with_url(&url);
1941
1942 loop {
1943 let token = match self
1944 .hub
1945 .auth
1946 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
1947 .await
1948 {
1949 Ok(token) => token,
1950 Err(e) => match dlg.token(e) {
1951 Ok(token) => token,
1952 Err(e) => {
1953 dlg.finished(false);
1954 return Err(common::Error::MissingToken(e));
1955 }
1956 },
1957 };
1958 let mut req_result = {
1959 let client = &self.hub.client;
1960 dlg.pre_request();
1961 let mut req_builder = hyper::Request::builder()
1962 .method(hyper::Method::GET)
1963 .uri(url.as_str())
1964 .header(USER_AGENT, self.hub._user_agent.clone());
1965
1966 if let Some(token) = token.as_ref() {
1967 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
1968 }
1969
1970 let request = req_builder
1971 .header(CONTENT_LENGTH, 0_u64)
1972 .body(common::to_body::<String>(None));
1973
1974 client.request(request.unwrap()).await
1975 };
1976
1977 match req_result {
1978 Err(err) => {
1979 if let common::Retry::After(d) = dlg.http_error(&err) {
1980 sleep(d).await;
1981 continue;
1982 }
1983 dlg.finished(false);
1984 return Err(common::Error::HttpError(err));
1985 }
1986 Ok(res) => {
1987 let (mut parts, body) = res.into_parts();
1988 let mut body = common::Body::new(body);
1989 if !parts.status.is_success() {
1990 let bytes = common::to_bytes(body).await.unwrap_or_default();
1991 let error = serde_json::from_str(&common::to_string(&bytes));
1992 let response = common::to_response(parts, bytes.into());
1993
1994 if let common::Retry::After(d) =
1995 dlg.http_failure(&response, error.as_ref().ok())
1996 {
1997 sleep(d).await;
1998 continue;
1999 }
2000
2001 dlg.finished(false);
2002
2003 return Err(match error {
2004 Ok(value) => common::Error::BadRequest(value),
2005 _ => common::Error::Failure(response),
2006 });
2007 }
2008 let response = {
2009 let bytes = common::to_bytes(body).await.unwrap_or_default();
2010 let encoded = common::to_string(&bytes);
2011 match serde_json::from_str(&encoded) {
2012 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
2013 Err(error) => {
2014 dlg.response_json_decode_error(&encoded, &error);
2015 return Err(common::Error::JsonDecodeError(
2016 encoded.to_string(),
2017 error,
2018 ));
2019 }
2020 }
2021 };
2022
2023 dlg.finished(true);
2024 return Ok(response);
2025 }
2026 }
2027 }
2028 }
2029
2030 /// Required. The parent project for which to list database instances, in the form: `projects/{project-number}/locations/{location-id}` To list across all locations, use a parent in the form: `projects/{project-number}/locations/-`
2031 ///
2032 /// Sets the *parent* path property to the given value.
2033 ///
2034 /// Even though the property as already been set when instantiating this call,
2035 /// we provide this method for API completeness.
2036 pub fn parent(mut self, new_value: &str) -> ProjectLocationInstanceListCall<'a, C> {
2037 self._parent = new_value.to_string();
2038 self
2039 }
2040 /// Indicate that DatabaseInstances in the `DELETED` state should also be returned.
2041 ///
2042 /// Sets the *show deleted* query property to the given value.
2043 pub fn show_deleted(mut self, new_value: bool) -> ProjectLocationInstanceListCall<'a, C> {
2044 self._show_deleted = Some(new_value);
2045 self
2046 }
2047 /// Token returned from a previous call to `ListDatabaseInstances` indicating where in the set of database instances to resume listing.
2048 ///
2049 /// Sets the *page token* query property to the given value.
2050 pub fn page_token(mut self, new_value: &str) -> ProjectLocationInstanceListCall<'a, C> {
2051 self._page_token = Some(new_value.to_string());
2052 self
2053 }
2054 /// The maximum number of database instances to return in the response. The server may return fewer than this at its discretion. If no value is specified (or too large a value is specified), then the server will impose its own limit.
2055 ///
2056 /// Sets the *page size* query property to the given value.
2057 pub fn page_size(mut self, new_value: i32) -> ProjectLocationInstanceListCall<'a, C> {
2058 self._page_size = Some(new_value);
2059 self
2060 }
2061 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
2062 /// while executing the actual API request.
2063 ///
2064 /// ````text
2065 /// It should be used to handle progress information, and to implement a certain level of resilience.
2066 /// ````
2067 ///
2068 /// Sets the *delegate* property to the given value.
2069 pub fn delegate(
2070 mut self,
2071 new_value: &'a mut dyn common::Delegate,
2072 ) -> ProjectLocationInstanceListCall<'a, C> {
2073 self._delegate = Some(new_value);
2074 self
2075 }
2076
2077 /// Set any additional parameter of the query string used in the request.
2078 /// It should be used to set parameters which are not yet available through their own
2079 /// setters.
2080 ///
2081 /// Please note that this method must not be used to set any of the known parameters
2082 /// which have their own setter method. If done anyway, the request will fail.
2083 ///
2084 /// # Additional Parameters
2085 ///
2086 /// * *$.xgafv* (query-string) - V1 error format.
2087 /// * *access_token* (query-string) - OAuth access token.
2088 /// * *alt* (query-string) - Data format for response.
2089 /// * *callback* (query-string) - JSONP
2090 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
2091 /// * *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.
2092 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
2093 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
2094 /// * *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.
2095 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
2096 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
2097 pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationInstanceListCall<'a, C>
2098 where
2099 T: AsRef<str>,
2100 {
2101 self._additional_params
2102 .insert(name.as_ref().to_string(), value.as_ref().to_string());
2103 self
2104 }
2105
2106 /// Identifies the authorization scope for the method you are building.
2107 ///
2108 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
2109 /// [`Scope::FirebaseReadonly`].
2110 ///
2111 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
2112 /// tokens for more than one scope.
2113 ///
2114 /// Usually there is more than one suitable scope to authorize an operation, some of which may
2115 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
2116 /// sufficient, a read-write scope will do as well.
2117 pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationInstanceListCall<'a, C>
2118 where
2119 St: AsRef<str>,
2120 {
2121 self._scopes.insert(String::from(scope.as_ref()));
2122 self
2123 }
2124 /// Identifies the authorization scope(s) for the method you are building.
2125 ///
2126 /// See [`Self::add_scope()`] for details.
2127 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationInstanceListCall<'a, C>
2128 where
2129 I: IntoIterator<Item = St>,
2130 St: AsRef<str>,
2131 {
2132 self._scopes
2133 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
2134 self
2135 }
2136
2137 /// Removes all scopes, and no default scope will be used either.
2138 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
2139 /// for details).
2140 pub fn clear_scopes(mut self) -> ProjectLocationInstanceListCall<'a, C> {
2141 self._scopes.clear();
2142 self
2143 }
2144}
2145
2146/// Enables a DatabaseInstance. The database must have been disabled previously using DisableDatabaseInstance. The state of a successfully reenabled DatabaseInstance is ACTIVE.
2147///
2148/// A builder for the *locations.instances.reenable* method supported by a *project* resource.
2149/// It is not used directly, but through a [`ProjectMethods`] instance.
2150///
2151/// # Example
2152///
2153/// Instantiate a resource method builder
2154///
2155/// ```test_harness,no_run
2156/// # extern crate hyper;
2157/// # extern crate hyper_rustls;
2158/// # extern crate google_firebasedatabase1_beta as firebasedatabase1_beta;
2159/// use firebasedatabase1_beta::api::ReenableDatabaseInstanceRequest;
2160/// # async fn dox() {
2161/// # use firebasedatabase1_beta::{FirebaseRealtimeDatabase, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
2162///
2163/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
2164/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
2165/// # .with_native_roots()
2166/// # .unwrap()
2167/// # .https_only()
2168/// # .enable_http2()
2169/// # .build();
2170///
2171/// # let executor = hyper_util::rt::TokioExecutor::new();
2172/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
2173/// # secret,
2174/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
2175/// # yup_oauth2::client::CustomHyperClientBuilder::from(
2176/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
2177/// # ),
2178/// # ).build().await.unwrap();
2179///
2180/// # let client = hyper_util::client::legacy::Client::builder(
2181/// # hyper_util::rt::TokioExecutor::new()
2182/// # )
2183/// # .build(
2184/// # hyper_rustls::HttpsConnectorBuilder::new()
2185/// # .with_native_roots()
2186/// # .unwrap()
2187/// # .https_or_http()
2188/// # .enable_http2()
2189/// # .build()
2190/// # );
2191/// # let mut hub = FirebaseRealtimeDatabase::new(client, auth);
2192/// // As the method needs a request, you would usually fill it with the desired information
2193/// // into the respective structure. Some of the parts shown here might not be applicable !
2194/// // Values shown here are possibly random and not representative !
2195/// let mut req = ReenableDatabaseInstanceRequest::default();
2196///
2197/// // You can configure optional parameters by calling the respective setters at will, and
2198/// // execute the final call using `doit()`.
2199/// // Values shown here are possibly random and not representative !
2200/// let result = hub.projects().locations_instances_reenable(req, "name")
2201/// .doit().await;
2202/// # }
2203/// ```
2204pub struct ProjectLocationInstanceReenableCall<'a, C>
2205where
2206 C: 'a,
2207{
2208 hub: &'a FirebaseRealtimeDatabase<C>,
2209 _request: ReenableDatabaseInstanceRequest,
2210 _name: String,
2211 _delegate: Option<&'a mut dyn common::Delegate>,
2212 _additional_params: HashMap<String, String>,
2213 _scopes: BTreeSet<String>,
2214}
2215
2216impl<'a, C> common::CallBuilder for ProjectLocationInstanceReenableCall<'a, C> {}
2217
2218impl<'a, C> ProjectLocationInstanceReenableCall<'a, C>
2219where
2220 C: common::Connector,
2221{
2222 /// Perform the operation you have build so far.
2223 pub async fn doit(mut self) -> common::Result<(common::Response, DatabaseInstance)> {
2224 use std::borrow::Cow;
2225 use std::io::{Read, Seek};
2226
2227 use common::{url::Params, ToParts};
2228 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
2229
2230 let mut dd = common::DefaultDelegate;
2231 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
2232 dlg.begin(common::MethodInfo {
2233 id: "firebasedatabase.projects.locations.instances.reenable",
2234 http_method: hyper::Method::POST,
2235 });
2236
2237 for &field in ["alt", "name"].iter() {
2238 if self._additional_params.contains_key(field) {
2239 dlg.finished(false);
2240 return Err(common::Error::FieldClash(field));
2241 }
2242 }
2243
2244 let mut params = Params::with_capacity(4 + self._additional_params.len());
2245 params.push("name", self._name);
2246
2247 params.extend(self._additional_params.iter());
2248
2249 params.push("alt", "json");
2250 let mut url = self.hub._base_url.clone() + "v1beta/{+name}:reenable";
2251 if self._scopes.is_empty() {
2252 self._scopes
2253 .insert(Scope::CloudPlatform.as_ref().to_string());
2254 }
2255
2256 #[allow(clippy::single_element_loop)]
2257 for &(find_this, param_name) in [("{+name}", "name")].iter() {
2258 url = params.uri_replacement(url, param_name, find_this, true);
2259 }
2260 {
2261 let to_remove = ["name"];
2262 params.remove_params(&to_remove);
2263 }
2264
2265 let url = params.parse_with_url(&url);
2266
2267 let mut json_mime_type = mime::APPLICATION_JSON;
2268 let mut request_value_reader = {
2269 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
2270 common::remove_json_null_values(&mut value);
2271 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
2272 serde_json::to_writer(&mut dst, &value).unwrap();
2273 dst
2274 };
2275 let request_size = request_value_reader
2276 .seek(std::io::SeekFrom::End(0))
2277 .unwrap();
2278 request_value_reader
2279 .seek(std::io::SeekFrom::Start(0))
2280 .unwrap();
2281
2282 loop {
2283 let token = match self
2284 .hub
2285 .auth
2286 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
2287 .await
2288 {
2289 Ok(token) => token,
2290 Err(e) => match dlg.token(e) {
2291 Ok(token) => token,
2292 Err(e) => {
2293 dlg.finished(false);
2294 return Err(common::Error::MissingToken(e));
2295 }
2296 },
2297 };
2298 request_value_reader
2299 .seek(std::io::SeekFrom::Start(0))
2300 .unwrap();
2301 let mut req_result = {
2302 let client = &self.hub.client;
2303 dlg.pre_request();
2304 let mut req_builder = hyper::Request::builder()
2305 .method(hyper::Method::POST)
2306 .uri(url.as_str())
2307 .header(USER_AGENT, self.hub._user_agent.clone());
2308
2309 if let Some(token) = token.as_ref() {
2310 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
2311 }
2312
2313 let request = req_builder
2314 .header(CONTENT_TYPE, json_mime_type.to_string())
2315 .header(CONTENT_LENGTH, request_size as u64)
2316 .body(common::to_body(
2317 request_value_reader.get_ref().clone().into(),
2318 ));
2319
2320 client.request(request.unwrap()).await
2321 };
2322
2323 match req_result {
2324 Err(err) => {
2325 if let common::Retry::After(d) = dlg.http_error(&err) {
2326 sleep(d).await;
2327 continue;
2328 }
2329 dlg.finished(false);
2330 return Err(common::Error::HttpError(err));
2331 }
2332 Ok(res) => {
2333 let (mut parts, body) = res.into_parts();
2334 let mut body = common::Body::new(body);
2335 if !parts.status.is_success() {
2336 let bytes = common::to_bytes(body).await.unwrap_or_default();
2337 let error = serde_json::from_str(&common::to_string(&bytes));
2338 let response = common::to_response(parts, bytes.into());
2339
2340 if let common::Retry::After(d) =
2341 dlg.http_failure(&response, error.as_ref().ok())
2342 {
2343 sleep(d).await;
2344 continue;
2345 }
2346
2347 dlg.finished(false);
2348
2349 return Err(match error {
2350 Ok(value) => common::Error::BadRequest(value),
2351 _ => common::Error::Failure(response),
2352 });
2353 }
2354 let response = {
2355 let bytes = common::to_bytes(body).await.unwrap_or_default();
2356 let encoded = common::to_string(&bytes);
2357 match serde_json::from_str(&encoded) {
2358 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
2359 Err(error) => {
2360 dlg.response_json_decode_error(&encoded, &error);
2361 return Err(common::Error::JsonDecodeError(
2362 encoded.to_string(),
2363 error,
2364 ));
2365 }
2366 }
2367 };
2368
2369 dlg.finished(true);
2370 return Ok(response);
2371 }
2372 }
2373 }
2374 }
2375
2376 ///
2377 /// Sets the *request* property to the given value.
2378 ///
2379 /// Even though the property as already been set when instantiating this call,
2380 /// we provide this method for API completeness.
2381 pub fn request(
2382 mut self,
2383 new_value: ReenableDatabaseInstanceRequest,
2384 ) -> ProjectLocationInstanceReenableCall<'a, C> {
2385 self._request = new_value;
2386 self
2387 }
2388 /// Required. The fully qualified resource name of the database instance, in the form: `projects/{project-number}/locations/{location-id}/instances/{database-id}`
2389 ///
2390 /// Sets the *name* path property to the given value.
2391 ///
2392 /// Even though the property as already been set when instantiating this call,
2393 /// we provide this method for API completeness.
2394 pub fn name(mut self, new_value: &str) -> ProjectLocationInstanceReenableCall<'a, C> {
2395 self._name = new_value.to_string();
2396 self
2397 }
2398 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
2399 /// while executing the actual API request.
2400 ///
2401 /// ````text
2402 /// It should be used to handle progress information, and to implement a certain level of resilience.
2403 /// ````
2404 ///
2405 /// Sets the *delegate* property to the given value.
2406 pub fn delegate(
2407 mut self,
2408 new_value: &'a mut dyn common::Delegate,
2409 ) -> ProjectLocationInstanceReenableCall<'a, C> {
2410 self._delegate = Some(new_value);
2411 self
2412 }
2413
2414 /// Set any additional parameter of the query string used in the request.
2415 /// It should be used to set parameters which are not yet available through their own
2416 /// setters.
2417 ///
2418 /// Please note that this method must not be used to set any of the known parameters
2419 /// which have their own setter method. If done anyway, the request will fail.
2420 ///
2421 /// # Additional Parameters
2422 ///
2423 /// * *$.xgafv* (query-string) - V1 error format.
2424 /// * *access_token* (query-string) - OAuth access token.
2425 /// * *alt* (query-string) - Data format for response.
2426 /// * *callback* (query-string) - JSONP
2427 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
2428 /// * *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.
2429 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
2430 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
2431 /// * *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.
2432 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
2433 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
2434 pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationInstanceReenableCall<'a, C>
2435 where
2436 T: AsRef<str>,
2437 {
2438 self._additional_params
2439 .insert(name.as_ref().to_string(), value.as_ref().to_string());
2440 self
2441 }
2442
2443 /// Identifies the authorization scope for the method you are building.
2444 ///
2445 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
2446 /// [`Scope::CloudPlatform`].
2447 ///
2448 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
2449 /// tokens for more than one scope.
2450 ///
2451 /// Usually there is more than one suitable scope to authorize an operation, some of which may
2452 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
2453 /// sufficient, a read-write scope will do as well.
2454 pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationInstanceReenableCall<'a, C>
2455 where
2456 St: AsRef<str>,
2457 {
2458 self._scopes.insert(String::from(scope.as_ref()));
2459 self
2460 }
2461 /// Identifies the authorization scope(s) for the method you are building.
2462 ///
2463 /// See [`Self::add_scope()`] for details.
2464 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationInstanceReenableCall<'a, C>
2465 where
2466 I: IntoIterator<Item = St>,
2467 St: AsRef<str>,
2468 {
2469 self._scopes
2470 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
2471 self
2472 }
2473
2474 /// Removes all scopes, and no default scope will be used either.
2475 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
2476 /// for details).
2477 pub fn clear_scopes(mut self) -> ProjectLocationInstanceReenableCall<'a, C> {
2478 self._scopes.clear();
2479 self
2480 }
2481}
2482
2483/// Restores a DatabaseInstance that was previously marked to be deleted. After the delete method is used, DatabaseInstances are set to the DELETED state for 20 days, and will be purged within 30 days. Databases in the DELETED state can be undeleted without losing any data. This method may only be used on a DatabaseInstance in the DELETED state. Purged DatabaseInstances may not be recovered.
2484///
2485/// A builder for the *locations.instances.undelete* method supported by a *project* resource.
2486/// It is not used directly, but through a [`ProjectMethods`] instance.
2487///
2488/// # Example
2489///
2490/// Instantiate a resource method builder
2491///
2492/// ```test_harness,no_run
2493/// # extern crate hyper;
2494/// # extern crate hyper_rustls;
2495/// # extern crate google_firebasedatabase1_beta as firebasedatabase1_beta;
2496/// use firebasedatabase1_beta::api::UndeleteDatabaseInstanceRequest;
2497/// # async fn dox() {
2498/// # use firebasedatabase1_beta::{FirebaseRealtimeDatabase, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
2499///
2500/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
2501/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
2502/// # .with_native_roots()
2503/// # .unwrap()
2504/// # .https_only()
2505/// # .enable_http2()
2506/// # .build();
2507///
2508/// # let executor = hyper_util::rt::TokioExecutor::new();
2509/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
2510/// # secret,
2511/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
2512/// # yup_oauth2::client::CustomHyperClientBuilder::from(
2513/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
2514/// # ),
2515/// # ).build().await.unwrap();
2516///
2517/// # let client = hyper_util::client::legacy::Client::builder(
2518/// # hyper_util::rt::TokioExecutor::new()
2519/// # )
2520/// # .build(
2521/// # hyper_rustls::HttpsConnectorBuilder::new()
2522/// # .with_native_roots()
2523/// # .unwrap()
2524/// # .https_or_http()
2525/// # .enable_http2()
2526/// # .build()
2527/// # );
2528/// # let mut hub = FirebaseRealtimeDatabase::new(client, auth);
2529/// // As the method needs a request, you would usually fill it with the desired information
2530/// // into the respective structure. Some of the parts shown here might not be applicable !
2531/// // Values shown here are possibly random and not representative !
2532/// let mut req = UndeleteDatabaseInstanceRequest::default();
2533///
2534/// // You can configure optional parameters by calling the respective setters at will, and
2535/// // execute the final call using `doit()`.
2536/// // Values shown here are possibly random and not representative !
2537/// let result = hub.projects().locations_instances_undelete(req, "name")
2538/// .doit().await;
2539/// # }
2540/// ```
2541pub struct ProjectLocationInstanceUndeleteCall<'a, C>
2542where
2543 C: 'a,
2544{
2545 hub: &'a FirebaseRealtimeDatabase<C>,
2546 _request: UndeleteDatabaseInstanceRequest,
2547 _name: String,
2548 _delegate: Option<&'a mut dyn common::Delegate>,
2549 _additional_params: HashMap<String, String>,
2550 _scopes: BTreeSet<String>,
2551}
2552
2553impl<'a, C> common::CallBuilder for ProjectLocationInstanceUndeleteCall<'a, C> {}
2554
2555impl<'a, C> ProjectLocationInstanceUndeleteCall<'a, C>
2556where
2557 C: common::Connector,
2558{
2559 /// Perform the operation you have build so far.
2560 pub async fn doit(mut self) -> common::Result<(common::Response, DatabaseInstance)> {
2561 use std::borrow::Cow;
2562 use std::io::{Read, Seek};
2563
2564 use common::{url::Params, ToParts};
2565 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
2566
2567 let mut dd = common::DefaultDelegate;
2568 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
2569 dlg.begin(common::MethodInfo {
2570 id: "firebasedatabase.projects.locations.instances.undelete",
2571 http_method: hyper::Method::POST,
2572 });
2573
2574 for &field in ["alt", "name"].iter() {
2575 if self._additional_params.contains_key(field) {
2576 dlg.finished(false);
2577 return Err(common::Error::FieldClash(field));
2578 }
2579 }
2580
2581 let mut params = Params::with_capacity(4 + self._additional_params.len());
2582 params.push("name", self._name);
2583
2584 params.extend(self._additional_params.iter());
2585
2586 params.push("alt", "json");
2587 let mut url = self.hub._base_url.clone() + "v1beta/{+name}:undelete";
2588 if self._scopes.is_empty() {
2589 self._scopes
2590 .insert(Scope::CloudPlatform.as_ref().to_string());
2591 }
2592
2593 #[allow(clippy::single_element_loop)]
2594 for &(find_this, param_name) in [("{+name}", "name")].iter() {
2595 url = params.uri_replacement(url, param_name, find_this, true);
2596 }
2597 {
2598 let to_remove = ["name"];
2599 params.remove_params(&to_remove);
2600 }
2601
2602 let url = params.parse_with_url(&url);
2603
2604 let mut json_mime_type = mime::APPLICATION_JSON;
2605 let mut request_value_reader = {
2606 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
2607 common::remove_json_null_values(&mut value);
2608 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
2609 serde_json::to_writer(&mut dst, &value).unwrap();
2610 dst
2611 };
2612 let request_size = request_value_reader
2613 .seek(std::io::SeekFrom::End(0))
2614 .unwrap();
2615 request_value_reader
2616 .seek(std::io::SeekFrom::Start(0))
2617 .unwrap();
2618
2619 loop {
2620 let token = match self
2621 .hub
2622 .auth
2623 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
2624 .await
2625 {
2626 Ok(token) => token,
2627 Err(e) => match dlg.token(e) {
2628 Ok(token) => token,
2629 Err(e) => {
2630 dlg.finished(false);
2631 return Err(common::Error::MissingToken(e));
2632 }
2633 },
2634 };
2635 request_value_reader
2636 .seek(std::io::SeekFrom::Start(0))
2637 .unwrap();
2638 let mut req_result = {
2639 let client = &self.hub.client;
2640 dlg.pre_request();
2641 let mut req_builder = hyper::Request::builder()
2642 .method(hyper::Method::POST)
2643 .uri(url.as_str())
2644 .header(USER_AGENT, self.hub._user_agent.clone());
2645
2646 if let Some(token) = token.as_ref() {
2647 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
2648 }
2649
2650 let request = req_builder
2651 .header(CONTENT_TYPE, json_mime_type.to_string())
2652 .header(CONTENT_LENGTH, request_size as u64)
2653 .body(common::to_body(
2654 request_value_reader.get_ref().clone().into(),
2655 ));
2656
2657 client.request(request.unwrap()).await
2658 };
2659
2660 match req_result {
2661 Err(err) => {
2662 if let common::Retry::After(d) = dlg.http_error(&err) {
2663 sleep(d).await;
2664 continue;
2665 }
2666 dlg.finished(false);
2667 return Err(common::Error::HttpError(err));
2668 }
2669 Ok(res) => {
2670 let (mut parts, body) = res.into_parts();
2671 let mut body = common::Body::new(body);
2672 if !parts.status.is_success() {
2673 let bytes = common::to_bytes(body).await.unwrap_or_default();
2674 let error = serde_json::from_str(&common::to_string(&bytes));
2675 let response = common::to_response(parts, bytes.into());
2676
2677 if let common::Retry::After(d) =
2678 dlg.http_failure(&response, error.as_ref().ok())
2679 {
2680 sleep(d).await;
2681 continue;
2682 }
2683
2684 dlg.finished(false);
2685
2686 return Err(match error {
2687 Ok(value) => common::Error::BadRequest(value),
2688 _ => common::Error::Failure(response),
2689 });
2690 }
2691 let response = {
2692 let bytes = common::to_bytes(body).await.unwrap_or_default();
2693 let encoded = common::to_string(&bytes);
2694 match serde_json::from_str(&encoded) {
2695 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
2696 Err(error) => {
2697 dlg.response_json_decode_error(&encoded, &error);
2698 return Err(common::Error::JsonDecodeError(
2699 encoded.to_string(),
2700 error,
2701 ));
2702 }
2703 }
2704 };
2705
2706 dlg.finished(true);
2707 return Ok(response);
2708 }
2709 }
2710 }
2711 }
2712
2713 ///
2714 /// Sets the *request* property to the given value.
2715 ///
2716 /// Even though the property as already been set when instantiating this call,
2717 /// we provide this method for API completeness.
2718 pub fn request(
2719 mut self,
2720 new_value: UndeleteDatabaseInstanceRequest,
2721 ) -> ProjectLocationInstanceUndeleteCall<'a, C> {
2722 self._request = new_value;
2723 self
2724 }
2725 /// Required. The fully qualified resource name of the database instance, in the form: `projects/{project-number}/locations/{location-id}/instances/{database-id}`
2726 ///
2727 /// Sets the *name* path property to the given value.
2728 ///
2729 /// Even though the property as already been set when instantiating this call,
2730 /// we provide this method for API completeness.
2731 pub fn name(mut self, new_value: &str) -> ProjectLocationInstanceUndeleteCall<'a, C> {
2732 self._name = new_value.to_string();
2733 self
2734 }
2735 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
2736 /// while executing the actual API request.
2737 ///
2738 /// ````text
2739 /// It should be used to handle progress information, and to implement a certain level of resilience.
2740 /// ````
2741 ///
2742 /// Sets the *delegate* property to the given value.
2743 pub fn delegate(
2744 mut self,
2745 new_value: &'a mut dyn common::Delegate,
2746 ) -> ProjectLocationInstanceUndeleteCall<'a, C> {
2747 self._delegate = Some(new_value);
2748 self
2749 }
2750
2751 /// Set any additional parameter of the query string used in the request.
2752 /// It should be used to set parameters which are not yet available through their own
2753 /// setters.
2754 ///
2755 /// Please note that this method must not be used to set any of the known parameters
2756 /// which have their own setter method. If done anyway, the request will fail.
2757 ///
2758 /// # Additional Parameters
2759 ///
2760 /// * *$.xgafv* (query-string) - V1 error format.
2761 /// * *access_token* (query-string) - OAuth access token.
2762 /// * *alt* (query-string) - Data format for response.
2763 /// * *callback* (query-string) - JSONP
2764 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
2765 /// * *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.
2766 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
2767 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
2768 /// * *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.
2769 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
2770 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
2771 pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationInstanceUndeleteCall<'a, C>
2772 where
2773 T: AsRef<str>,
2774 {
2775 self._additional_params
2776 .insert(name.as_ref().to_string(), value.as_ref().to_string());
2777 self
2778 }
2779
2780 /// Identifies the authorization scope for the method you are building.
2781 ///
2782 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
2783 /// [`Scope::CloudPlatform`].
2784 ///
2785 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
2786 /// tokens for more than one scope.
2787 ///
2788 /// Usually there is more than one suitable scope to authorize an operation, some of which may
2789 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
2790 /// sufficient, a read-write scope will do as well.
2791 pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationInstanceUndeleteCall<'a, C>
2792 where
2793 St: AsRef<str>,
2794 {
2795 self._scopes.insert(String::from(scope.as_ref()));
2796 self
2797 }
2798 /// Identifies the authorization scope(s) for the method you are building.
2799 ///
2800 /// See [`Self::add_scope()`] for details.
2801 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationInstanceUndeleteCall<'a, C>
2802 where
2803 I: IntoIterator<Item = St>,
2804 St: AsRef<str>,
2805 {
2806 self._scopes
2807 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
2808 self
2809 }
2810
2811 /// Removes all scopes, and no default scope will be used either.
2812 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
2813 /// for details).
2814 pub fn clear_scopes(mut self) -> ProjectLocationInstanceUndeleteCall<'a, C> {
2815 self._scopes.clear();
2816 self
2817 }
2818}